[https://nvbugs/6457853][fix] Allow trtllm-gen MoE autotuner when local_num_experts < top_k#16653
Conversation
📝 WalkthroughWalkthroughDummy top-k generation now tolerates expert pools smaller than ChangesDummy top-k generation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…al_num_experts < top_k The autotuner's dummy top-k generators asserted local_num_experts >= top_k, unsatisfiable once EP > num_experts / top_k (gpt-oss-120b at EP64: 2 local experts, top_k=4) — with attention DP every rank failed executor init during autotuner warmup. Keep dummy rows production-shaped instead: fill min(top_k, local_num_experts) distinct local ids and pad the remaining slots with deterministic out-of-shard ids. No behavior change when local_num_experts >= top_k. Adds a regression test. Verified on main (b8604c4): 1-GPU repro passes full autotune profiling; TP64/EP64 on 16x4 GB200 passes warmup and completes trtllm-bench (stock fails on all 64 ranks). Signed-off-by: Dongfeng Yu <dongfengy@nvidia.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4880ca0 to
87dbbce
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #61035 [ run ] triggered by Bot. Commit: |
|
PR_Github #61035 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #61080 [ run ] triggered by Bot. Commit: |
|
PR_Github #61080 [ run ] completed with state |
Description
Fixes https://nvbugs/6457853 — gpt-oss-120b (128 experts, top_k=4) crashes at autotuner warmup when EP64 leaves 128/64 = 2 local experts per rank:
To time MoE kernel tactics, the autotuner fabricates a dummy token→expert assignment instead of running the real router. Both dummy generators (
randomandbalanced, perTRTLLM_GEN_MOE_AUTOTUNE_DUMMY_DISTRIBUTION) requiredtop_kdistinct LOCAL ids per row, which is impossible onceEP > num_experts / top_k. The real inference path has no such limit: routing pickstop_kdistinct GLOBAL experts, of which at mostlocal_num_expertslive on any rank — so this was autotuner-only.Fix: keep dummy rows production-shaped — fill
min(top_k, local_num_experts)distinct local ids and pad the remaining slots with deterministic out-of-shard ids (remote slots do no local work). No in-row duplicates; zero behavior change whenlocal_num_experts >= top_k.Verified on main (b8604c4, GB200): the 1-GPU repro hits the exact assert on stock code and passes full autotune profiling with this fix; at TP64/EP64 on 16×4 GB200 NVL72, stock fails on all 64 ranks at warmup while the fixed run completes trtllm-bench cleanly (8×32k/8k requests, 48 min). The same A/B was also reproduced on 1.3.0rc18 and rc21.
Test Coverage
tests/unittest/_torch/misc/test_autotuner.py::test_trtllm_gen_moe_dummy_topk_local_experts_less_than_topk[random|balanced]— fails before the fix, passes after; checks rows are production-shaped (distinct ids, all local experts present, pad ids valid).PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
🤖 Generated with Claude Code