Skip to content

[Bugfix] Avoid repeatedly creating dummy data during engine startup #17935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 13, 2025

Conversation

DarkLight1337
Copy link
Member

@DarkLight1337 DarkLight1337 commented May 10, 2025

This PR fixes an issue where the startup time of multimodal models is multipled because dummy data is created multiple times during profile run and graph capturing. Instead of disabling cache when dummy data is generated, the cache is now always enabled. To conserve memory, the cache is instead cleared at the end of the engine start process.

Cache reset code is taken from #16478

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added multi-modality Related to multi-modality (#4194) v1 labels May 10, 2025
@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label May 11, 2025
@ywang96
Copy link
Member

ywang96 commented May 12, 2025

I'm actually not seeing the speedup from this PR with the following test script

# python3 test.py --model Qwen/Qwen2.5-VL-3B-Instruct

# test.py
from vllm.multimodal import MULTIMODAL_REGISTRY
from vllm.engine.async_llm_engine import AsyncEngineArgs
from vllm.engine.async_llm_engine import UsageContext
from vllm.utils import FlexibleArgumentParser
from vllm.v1.core.encoder_cache_manager import compute_encoder_budget
import time

if __name__ == "__main__":
    parser = FlexibleArgumentParser()
    parser = AsyncEngineArgs.add_cli_args(parser)
    args = parser.parse_args()
    engine_args = AsyncEngineArgs.from_cli_args(args)
    vllm_config = engine_args.create_engine_config(UsageContext.ENGINE_CONTEXT)
    
    start_time = time.perf_counter()
    encoder_compute_budget, encoder_cache_size = compute_encoder_budget(
        model_config=vllm_config.model_config,
        scheduler_config=vllm_config.scheduler_config,
        mm_registry=MULTIMODAL_REGISTRY,
    )
    print(f"Time taken: {time.perf_counter() - start_time}")

On main

Time taken: 10.416103872470558

This branch

Time taken: 16.340763847343624

@DarkLight1337
Copy link
Member Author

DarkLight1337 commented May 12, 2025

The cache is only effective if you run compute_encoder_budget a second time.

@DarkLight1337
Copy link
Member Author

DarkLight1337 commented May 12, 2025

In actual inference this means that the multi-modal data used in dummy run is cached (since it's called after compute_encoder_budget), so there should still be an overall speedup.

@DarkLight1337
Copy link
Member Author

OK it seems that I do need to implement the async version of this method...

Signed-off-by: DarkLight1337 <[email protected]>
@mergify mergify bot added the frontend label May 12, 2025
Signed-off-by: DarkLight1337 <[email protected]>
@vllm-bot vllm-bot merged commit 61e0a50 into vllm-project:main May 13, 2025
62 of 65 checks passed
@DarkLight1337 DarkLight1337 deleted the no-disable-cache branch May 13, 2025 05:40
mawong-amd pushed a commit to ROCm/vllm that referenced this pull request May 14, 2025
ChenheliHua pushed a commit to ChenheliHua/vllm that referenced this pull request May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend multi-modality Related to multi-modality (#4194) ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants