Repository navigation
[None][fix] mhc: disable PARALLEL distributed tuning for MhcFusedHc - #14675
Merged
hyukn merged 1 commit intoMay 28, 2026
Merged
Conversation
PR NVIDIA#14458 enabled `distributed_tuning_strategy=DistributedTuningStrategy.PARALLEL` on both MhcPreMappingRunner and MhcFusedHcRunner. The MhcFusedHc setting triggers a non-deterministic CUDA Illegal Memory Access on TP=8 disagg GEN workers during the post-autotune max-batch CUDA-graph capture (observed on the 1024-1024 disagg_ctx1_gen1_tep8_batch256 recipe and the 8192-1024 disagg_ctx1_gen1_dep8_batch512 recipe; ~67% crash rate across 3 reruns of the same config). Mechanism: MhcFusedHcRunner has a per-instance LRU workspace cache (`_FusedHcWorkspaceCache`) keyed on `(B, num_k_splits, tile_m, device)` — all derived from the chosen tactic. Under PARALLEL, each rank measures only `idx % tp_size == tp_rank` of the tactics, so each rank's LRU ends up populated with workspace entries for a different tactic subset. After `_merge_cache_data` writes the global-best tactic to the autotuner cache, ranks that didn't locally measure that tactic hit a workspace-cache miss and call `torch.empty(...)` fresh — inside the post-autotune CUDA-graph-capture region for the max-batch warmup step. Fresh allocations are incompatible with capture; the next collective kernel (MLA attention) dereferences a stale/uncaptured pointer → IMA on the cache-miss rank (rank 6 at TP=8 in the observed cases). MhcPreMappingRunner does NOT have this problem: its forward() uses fresh `torch.empty(...)` every call, keyed only on `(M, n, hidden_size)`, independent of the chosen tactic. So per-rank tactic-subset profiling under PARALLEL produces identical allocation histories across ranks. Per-op cost data on this disagg recipe shows MhcFusedHc PARALLEL adds ~no autotune saving (GEN: 4m 42s with both PARALLEL vs 4m 46s with only MhcPre PARALLEL — within JIT noise), so dropping it is a clean revert with no perf cost. MhcPre PARALLEL still buys ~27% CTX autotune reduction on the same recipe. A/B/C/D variant matrix at TP=8 disagg (3 nodes, max_batch=256): - MhcPre=ON, MhcFused=ON (A): IMA in 2/3 reruns - MhcPre=OFF, MhcFused=OFF (B): clean - MhcPre=OFF, MhcFused=ON (C): IMA - MhcPre=ON, MhcFused=OFF (D): clean ← this PR's configuration Re-enabling MhcFusedHc PARALLEL is a follow-up after the workspace LRU is reworked (e.g. by dropping tactic-dependent keying, or by harmonizing the LRU across ranks post-merge). Signed-off-by: Yukun He <[email protected]>
hyukn
force-pushed
the
fix/mhc_fused_hc_disable_parallel
branch
from
May 28, 2026 07:04
a922991 to
f4f920a
Compare
lfr-0531
approved these changes
May 28, 2026
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 10, 2026
…VIDIA#14675) Signed-off-by: Yukun He <[email protected]>
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 11, 2026
…VIDIA#14675) Signed-off-by: Yukun He <[email protected]>
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 12, 2026
…VIDIA#14675) Signed-off-by: Yukun He <[email protected]>
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 25, 2026
…VIDIA#14675) Signed-off-by: Yukun He <[email protected]> (cherry picked from commit f6f6f14)
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.
Summary
PR #14458 enabled
distributed_tuning_strategy=DistributedTuningStrategy.PARALLELon bothMhcPreMappingRunnerandMhcFusedHcRunner. The MhcFusedHc setting triggers a non-deterministic CUDA Illegal Memory Access on TP=8 disagg GEN workers during the post-autotune max-batch CUDA-graph-capture step.This PR keeps the MhcPre PARALLEL change (where the autotune saving comes from) and disables only the MhcFusedHc PARALLEL change (where the crash comes from).
Reproduction (xqiao container
dsv4-435a0a-pr14458, 3-node disagg, 1024-1024 dataset)Observed on two recipes that ship the same container:
1024-1024/disagg_ctx1_gen1_tep8_batch256_eplb0_mtp0(TP=8 GEN, max_batch=256)8192-1024/disagg_ctx1_gen1_dep8_batch512_eplb384_mtp1(DEP8 GEN, max_batch=512)Crash signature: rank 6
[executor] Failed to initialize executor: CUDA_ERROR_ILLEGAL_ADDRESSatmla_custom_op_inplace(attention.py:1022), during warmup-2 atRun warmup with 256 tokens, include 256 generation tokens— the cuda-graph-capture step.A/B/C/D matrix (TP=8 disagg, 3-node, max_batch=256):
Mechanism
MhcFusedHcRunner.__init__createsself._ws_cache = _FusedHcWorkspaceCache(...).forward()then does:The LRU is keyed on
(B, ws_ks=max(1, num_k_splits), m_batches, device)— i.e. on the chosen tactic's(num_k_splits, tile_m)fields.Under
PARALLEL,_maybe_parallelize_tacticsgives each rank[t for idx, t in enumerate(tactics) if idx % tp_size == tp_rank]. Each rank's local profiling populates the LRU with workspace entries only for the tactics it measured. After_merge_cache_datapicks the global-best tactic per shape, ranks that didn't locally measure that tactic miss the workspace LRU at first replay and call_alloc()→torch.empty(...). Because the post-autotune max-batch warmup is a CUDA-graph-capture stage, the fresh allocation lands in a region inconsistent with the captured snapshot, and the next collective kernel (here MLA attention) dereferences a stale pointer → IMA.MhcPreMappingRunner.forward()does freshtorch.empty(...)every call keyed only on(M, n, hidden_size)— independent of tactic — so its per-rank allocation history is identical under PARALLEL. No divergence, no crash.Cost
distributed_tuning_strategy=PARALLELon MhcFusedHc adds essentially no autotune saving on this recipe at TP=8:The MhcPre PARALLEL change still buys ~27% CTX autotune reduction (12m 42s → 9m 19s). Disabling MhcFusedHc PARALLEL costs ~52 s of CTX autotune in the worst case, within JIT-compile noise.
Follow-up
Re-enabling MhcFusedHc PARALLEL is feasible after
_FusedHcWorkspaceCacheis reworked. Two candidate fixes:(num_k_splits, tile_m)combination).🤖 Generated with Claude Code