[None][feat] AutoDeploy: propagate layer_type hint across pattern-matcher rewrites - #14835
Conversation
|
/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" |
📝 WalkthroughWalkthroughThis PR implements layer-type hint propagation through AutoDeploy's pattern-matcher infrastructure. SwiGLU ops now carry ChangesLayer-type hint propagation
Sequence DiagramsequenceDiagram
participant PatternMatcher
participant collect_classification_hints as collect hints
participant replace_with_graph as Graph replace
participant stamp_hints as stamp hints
participant FXOp as Fused FX Op
PatternMatcher->>collect_classification_hints: matched.nodes
collect_classification_hints-->>PatternMatcher: hints dict
PatternMatcher->>replace_with_graph: Execute replacement
replace_with_graph-->>PatternMatcher: new nodes inserted
PatternMatcher->>stamp_hints: new_nodes + hints
stamp_hints->>FXOp: Set layer_type arg
stamp_hints-->>PatternMatcher: count updated
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR_Github #51420 [ run ] triggered by Bot. Commit: |
|
PR_Github #51420 [ run ] completed with state
|
|
/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast --post-merge |
|
PR_Github #51848 [ run ] triggered by Bot. Commit: |
|
PR_Github #51848 [ run ] completed with state
|
|
/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast --post-merge |
…rites AutoDeploy pattern matchers that collapse N fine-grained ops into one (e.g. the SwiGLU matchers) dropped the per-op layer_type sharding hint. The hint-driven sharder (apply_sharding_hints / shard_layers) then read layer_type=None on the fused op and, because the whitelist is fail-open, TP-sharded nodes meant to be replicated -- the root cause of the Qwen3.5-MoE NVFP4 shared-expert accuracy regression fixed point-wise in NVIDIA#14667. Generalize the fix into the matcher infra: add an optional layer_type arg to the intermediate SwiGLU ops, add collect_classification_hints / stamp_hints helpers in node_utils, and propagate the consensus layer_type from the matched nodes onto the replacement op in ADReplacementPatternEntry. Per-weight mechanics (tp_mode, output_sizes, ...) are intentionally not propagated: the fused op's ShardableNode re-derives them structurally and they legitimately differ across constituents (an MLA layer mixes none/colwise/rowwise yet shares one layer_type), so generic propagation of the sharding decision is ill-posed. Tested: GPU-free unit tests for the helpers (consensus / conflict-drop / schema-guarded stamping), an NVFP4 end-to-end regression mirroring the Qwen3.5-MoE bug, and the full transformations/library suite (329 passed). Fixes NVIDIA#14834 Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
8981253 to
89daace
Compare
|
/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1" --disable-fail-fast --post-merge |
|
PR_Github #52056 [ run ] triggered by Bot. Commit: |
|
PR_Github #52058 [ run ] triggered by Bot. Commit: |
|
PR_Github #52056 [ run ] completed with state |
|
PR_Github #52058 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #52595 [ run ] triggered by Bot. Commit: |
|
PR_Github #52595 [ run ] completed with state |
|
Tested Qwen3.5 with https://github.com/nv-auto-deploy/TensorRT-LLM/tree/taylor/fix_qwen3.5_acc_new_0607 (Removing redundant patches added in #14667 |
Summary
layer_typesharding hint across AutoDeploy pattern-matcher rewrites, so it survives N->1 fusions (e.g. the SwiGLU matchers) and the downstream hint-driven sharder (apply_sharding_hints/shard_layers) still sees it.Background
The SwiGLU matchers collapse three fine-grained linears into one
torch_(nvfp4_)swiglu_mlpop before sharding. That fused op carried nolayer_type, so the fail-openshard_layerswhitelist TP-sharded the shared expert that was meant to be replicated. The hint must survive the rewrite.Changes
layer_typearg to the intermediate SwiGLU ops (torch_swiglu_mlp,torch_nvfp4_swiglu_mlp,torch_finegrained_fp8_swiglu_mlp) and their fakes so a fused node can carry it.collect_classification_hints(consensus across matched nodes; conflicting values dropped with a warning) andstamp_hints(schema-guarded set) innode_utils.py.ADReplacementPatternEntry.apply: collect frommatch.nodesbefore the rewrite, stamp the inserted op(s) afterward.tp_mode,output_sizes, ...) are intentionally NOT propagated -- a fused op'sShardableNodere-derives them structurally and they legitimately differ across constituents (an MLA layer mixes none/colwise/rowwise yet shares onelayer_type), so generic propagation of the sharding decision is ill-posed.Test plan
tp_mode, conflict-drop, schema-guarded stamping.layer_typesurvives the SwiGLU match onto the fused op (mirrors the Qwen3.5-MoE bug).tests/unittest/auto_deploy/singlegpu/transformations/library/suite: 329 passed locally.Risk
library-visible (matcher infra + custom ops; no public API change).
Notes
wmappropagation can be removed in favor of this central hook.Fixes #14834
Summary by CodeRabbit
New Features
Tests