Skip to content

Conversation

@sarckk
Copy link
Collaborator

@sarckk sarckk commented Jul 16, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

In some cases, we might want to compile multiple subgraphs, e.g. if some submodules in the model are not traceable with torch dynamo. See #14913 and #19719 for motivating scenarios.

This PR adds a test case showcasing how this can be supported in vLLM for piecewise compilation. This requires several components:

  • Each subgraph in the model being compiled needs to be initialized with set_model_tag(tag) to ensure compile cache is not shared between these subgraphs (initially added in [torch.compile] reorganize the cache directory to support compiling multiple models #19064 to support compiling multiple models)
  • Pre-allocate static buffers to be used as arg inputs to each compiled subgraph as CUDA Graph expects static tensor addresses between runs
  • Added ignore_torch_compile helper decorator in scenarios where a class inherits a parent module that has support_torch_compile decorator applied but this class does not want to compile its forward(). Added test_ignore_torch_compile_decorator that tests this.

Also disables AOTAutogradCache in StandaloneInductor adaptor which is needed for compilation caching to work. StandaloneInductorAdaptor in PyTorch 2.8+ will fix this problem (thanks @zou3519)

Test Plan

pytest tests/compile/piecewise/test_multiple_graphs.py

Test Result

Both newly added unit tests (test_ignore_torch_compile_decorator and test_multi_graph_piecewise_compile) pass

@github-actions
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.

🚀

@sarckk sarckk requested review from zou3519 and removed request for zou3519 July 16, 2025 09:33
@sarckk
Copy link
Collaborator Author

sarckk commented Jul 16, 2025

cc: @zou3519 @youkaichao

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new ignore_torch_compile decorator and adds test cases for compiling multiple graphs. There is a potential issue with the inheritance of the IGNORE_COMPILE_KEY that needs to be addressed.

@zou3519 zou3519 requested a review from ProExpertProg July 16, 2025 14:40
Copy link
Collaborator

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me. One minor comment

@zou3519
Copy link
Collaborator

zou3519 commented Jul 16, 2025

cc @BoyuanFeng

Copy link
Contributor

@BoyuanFeng BoyuanFeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! a few minor comments

@sarckk sarckk added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 18, 2025
@sarckk sarckk force-pushed the compile-multiple-graphs branch from c178193 to 0080859 Compare July 19, 2025 04:00
@sarckk
Copy link
Collaborator Author

sarckk commented Jul 22, 2025

@houseroad the failing tests don't seem related to this PR, can we merge it? e.g. for model tests (voxtral unrecognized), the test also fails on main

sarckk added 8 commits July 22, 2025 11:17
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
… and compile

Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
@sarckk sarckk force-pushed the compile-multiple-graphs branch from 0080859 to 7ece902 Compare July 22, 2025 18:18
Comment on lines +426 to +431
# InductorAdaptor (unfortunately) requires AOTAutogradCache
# to be turned off to run. It will fail to acquire the hash_str
# and error if not.
# StandaloneInductorAdaptor (PyTorch 2.8+) fixes this problem.
stack.enter_context(
torch._functorch.config.patch(enable_autograd_cache=False))
Copy link
Collaborator

@zou3519 zou3519 Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw @houseroad @yeqcharlotte this will fix a lot of the compiler cache issues people report

@houseroad houseroad enabled auto-merge (squash) July 23, 2025 00:48
@vllm-bot vllm-bot merged commit 4ac7713 into vllm-project:main Jul 23, 2025
65 of 67 checks passed
@github-project-automation github-project-automation bot moved this from To triage to Done in torch.compile integration Jul 23, 2025
zixi-qi pushed a commit to zixi-qi/vllm that referenced this pull request Jul 23, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: qizixi <qizixi@meta.com>
@sarckk sarckk deleted the compile-multiple-graphs branch July 24, 2025 00:08
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: x22x22 <wadeking@qq.com>
Pradyun92 pushed a commit to Pradyun92/vllm that referenced this pull request Aug 6, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Paul Pak <paulpak58@gmail.com>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants