Repository navigation
[None][fix] Honor the torch.compile recompile limit on the executor thread - #19798
Closed
yechank-nvidia wants to merge 2 commits into
Closed
yechank-nvidia wants to merge 2 commits into
yechank-nvidia wants to merge 2 commits into
Conversation
PyTorchModelEngine meant to raise the dynamo recompile limit of the compiled LLM to 16 by assigning torch._dynamo.config.cache_size_limit after torch.compile(). The pinned PyTorch stores dynamo config overrides in ContextVars, so the assignment only reaches the thread that builds the engine and runs warmup. PyExecutor runs forward on its own event-loop thread, where the limit stays at the default 8. Once the compiled frame holds eight entries, the next recompile on that thread raises FailOnRecompileLimitHit under fullgraph=True and stops the event loop. Pass recompile_limit=max(configured limit, 16) to every LLM torch.compile call, including the Qwen2-VL and Qwen3-VL apply_llm_torch_compile hooks, and stop mutating the global dynamo config. Signed-off-by: yechank <161688079+yechank-nvidia@users.noreply.github.com>
Bind the NCCL reformat helpers to at least 16 recompiles and retain larger user limits observed during warmup without changing ambient Dynamo config. Keep nested tracing in the enclosing compiled region and cover helper cache reuse, opaque and nonopaque tracing, exceptions, and CPU CI discovery. Signed-off-by: yechank <161688079+yechank-nvidia@users.noreply.github.com>
Collaborator
Author
|
@trtllm-agent-review please help review it |
Collaborator
|
Thanks, @yechank-nvidia. @trtllm-agent-review starts its reviews at fixed times, every day at 02:00, 08:00, 14:00 and 20:00 Beijing time (04:00, 10:00, 16:00 and 22:00 Pacific time). It will pick up this request at the next one, 14:00 Beijing time on Dec 1 (22:00 Pacific time on Nov 30), and start its review then. |
Collaborator
|
Correction, @yechank-nvidia: the answer above was wrong. @trtllm-agent-review will not review this PR while it is a draft: it was created before 2026-11-05 (Beijing time), and the bot reviews such an older PR only once it is ready for review. Your request stands for 30 days: mark the PR ready for review, and the bot picks it up at its next scan. |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The engine sets
torch._dynamo.config.cache_size_limit = 16after compiling the LLM. In the pinned PyTorch version, that setting is thread-local: warmup sees 16, but the executor worker thread still sees the default limit of 8. Warmup's compiled variants share the same code-object cache, so a new runtime variant can immediately hit that lower limit. Withfullgraph=True, this raisesFailOnRecompileLimitHit; otherwise subsequent uncached variants run eagerly.Bind the recompile budget to the compiled callable so warmup and execution use the same limit.
recompile_limit=max(current_limit, 16)to the decoder-model, multimodal LLM-hook, and whole-model compile paths. Remove the engine's ambient config write and preserve higher caller limits.apply_llm_torch_compilehooks. Out-of-tree implementations of this internal hook must accept the new keyword-onlyrecompile_limitargument.No public configuration option is added. The finite limit can still be exhausted by sufficiently varied workloads.
Evidence and performance
Prior Qwen3-VL-2B-Instruct E2E validation of the LLM fix at
b200a4b17a, before the Helix follow-up: one H200, LLM API, default fullgraph compilation, batch size 8, chunked prefill, and 16 mixed image/text requests with up to four in flight. The baseline failed before completing any request at the limit of 8; the candidate completed 16/16, with 13 compiled entries. This is a correctness result; no serving speedup is claimed.The Helix follow-up in
6de073f2fdalso has a measured host dispatch cost. A CPU-only eager-backend probe used the real helper bodies, warmed fixed shapes, and five paired timing blocks:Times are medians across blocks; percentages are medians of paired relative changes. The sum of median paired added times is about 3.11 µs per pre/post pair. This does not measure GPU fusion, NCCL latency, or model/serving performance.
Validation
6de073f2fd.The Qwen E2E run predates the Helix follow-up. GPU Helix fusion/collectives and current-head serving performance remain unvalidated.