Skip to content

[None][fix] Drop the stale choices list on --moe-backend-for-prefill - #17612

Merged
ruodil merged 3 commits into
NVIDIA:mainfrom
ruodil:user/ruodil/lwb-prefill-moe-choices
Aug 17, 2026
Merged

ruodil merged 3 commits into
NVIDIA:mainfrom
ruodil:user/ruodil/lwb-prefill-moe-choices

Conversation

@ruodil

@ruodil ruodil commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

What

--moe-backend-for-prefill carried an argparse choices list that had drifted out of sync with the values the library actually supports, so passing a supported backend failed before anything ran:

run.py: error: argument --moe-backend-for-prefill: invalid choice: 'TRTLLM'
        (choose from 'CUTLASS', 'DEEPGEMM')

Why the list should not be there

--moe-backend and --moe-backend-for-prefill are handed to the same Runner(moe_backend=...), which puts both into MoeConfig(backend=...):

  • examples/layer_wise_benchmarks/run.py:184 — Runner(..., moe_backend=args.moe_backend, ...)
  • examples/layer_wise_benchmarks/run.py:254 — Runner(..., moe_backend=args.moe_backend_for_prefill, ...)
  • tensorrt_llm/tools/layer_wise_benchmarks/runner.py:411 — llm_args = TorchLlmArgs(..., moe_config=MoeConfig(backend=moe_backend, ...))

MoeConfig.backend is a pydantic Literal and is the authoritative list. --moe-backend has no choices and relies on exactly that. The second list could only ever drift from it, and it did:

source accepted values
MoeConfig.backend (authoritative, llm_args.py:1420) AUTO, CUTLASS, CUTEDSL, WIDEEP, TRTLLM, DEEPGEMM, DENSEGEMM, VANILLA, TRITON, MARLIN, MEGAMOE_DEEPGEMM, MEGAMOE_CUTEDSL
replace_routing_method_ctx (tensorrt_llm/tools/layer_wise_benchmarks/runner.py:692) CUTEDSL, CUTLASS, DEEPGEMM, TRTLLM
run.py --moe-backend-for-prefill (before) CUTLASS, DEEPGEMM

TRTLLM and CUTEDSL are excluded by the CLI even though replace_routing_method_ctx names both as supported. TRTLLM is what the DeepSeek-V4 configs actually use, which is how this surfaced.

Removing the list makes the two flags symmetric and leaves validation with MoeConfig, which cannot drift from itself.

Flagged, not changed

This argument defaults to CUTLASS when unset (run.py:137-138). CUTLASS fp8 block-scale GEMM is Hopper-only, so the default path is not usable on Blackwell — a caller on B200 must pass the flag, and until this change could not pass the backend its model uses. Changing a default affects existing users, so it belongs in its own change rather than being folded in here.

Test Coverage

Argparse-level change only. No behaviour change for any value that was already accepted, and no new value is accepted that MoeConfig would not accept.

I could not execute the validation path locally — this machine has neither torch nor pydantic installed. The claim that MoeConfig rejects invalid values rests on reading the type chain (class MoeConfig(StrictBaseModel) → StrictBaseModel(pydantic.BaseModel) → backend: Literal[...]), which is standard pydantic semantics, rather than on a run. Worth a reviewer confirming that an obviously bogus value still fails cleanly — just later, and with a pydantic error instead of an argparse one.

Review follow-ups

Two corrections from @brnguyen2's review, both verified against main:

  • The table previously listed WIDEEP among the backends replace_routing_method_ctx accepts. It does not — the check at tensorrt_llm/tools/layer_wise_benchmarks/runner.py:692 allows only CUTEDSL/CUTLASS/DEEPGEMM/TRTLLM. Fixed above.
  • The in-file comment claimed replace_routing_method_ctx lives in "this file's own runner.py". There is no runner.py under examples/layer_wise_benchmarks/; the function is in tensorrt_llm/tools/layer_wise_benchmarks/runner.py:688.

The comment block also said MoeConfig.backend had "eleven values" — it has had twelve since #16190 (2026-07-29), so the enumeration was already stale on the day it was written. It has been collapsed to the one claim that cannot drift:

# No choices= (same as --moe-backend above): both flags feed MoeConfig.backend,
# whose Literal is the authoritative list. A second list here can only drift.

PR Checklist

  • PR title follows [None][fix] <description>
  • Commit is signed off (DCO)
  • New/changed tests — n/a, argparse surface only

Dev Engineer Review

  • Removed the stale choices=["CUTLASS", "DEEPGEMM"] restriction from --moe-backend-for-prefill.
  • The flag now matches --moe-backend and delegates backend validation to Runner and MoeConfig(backend=...).
  • Supported backends such as TRTLLM and CUTEDSL can now reach library-level validation.
  • The default remains CUTLASS.
  • No unrelated API, configuration, or test-list changes were made.
  • Local validation was not run because torch and pydantic were unavailable.

QA Engineer Review

No test changes.

--moe-backend and --moe-backend-for-prefill are handed to the same
Runner(moe_backend=...), which puts both into MoeConfig(backend=...).
MoeConfig.backend is a pydantic Literal over eleven values and is the
authoritative list; it rejects anything else with a clear validation error.

--moe-backend has no argparse choices and relies on that. This one carried a
second, hardcoded list, and it drifted: it accepted CUTLASS and DEEPGEMM only,
excluding TRTLLM and CUTEDSL -- both of which runner.py itself names as
supported in replace_routing_method_ctx, and TRTLLM being what the DeepSeek-V4
configs actually use.

The effect is that passing a backend the library supports fails in argparse
before anything runs:

    run.py: error: argument --moe-backend-for-prefill: invalid choice: 'TRTLLM'
            (choose from 'CUTLASS', 'DEEPGEMM')

Removing the list makes the two flags symmetric and leaves validation with
MoeConfig, which cannot drift from itself.

Not changed here, but worth flagging separately: this argument defaults to
CUTLASS when unset, and CUTLASS fp8 block-scale GEMM is Hopper-only, so the
default path is not usable on Blackwell. Changing a default affects existing
users and belongs in its own change.

Signed-off-by: Ruodi Lu <ruodil@users.noreply.github.com>
@ruodil
ruodil requested a review from a team as a code owner August 13, 2026 05:17
@ruodil
ruodil requested review from kaiyux and laikhtewari August 13, 2026 05:17
@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 729ee099-5ffd-4ce9-a247-fdcc376c60f3

📥 Commits

Reviewing files that changed from the base of the PR and between c54ed88 and 79c830f.

📒 Files selected for processing (1)
  • examples/layer_wise_benchmarks/run.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/layer_wise_benchmarks/run.py

Included review availability: Your plan includes up to 12 reviews per rolling hour; 10 remain after this review.


Walkthrough

The benchmark CLI now accepts arbitrary values for --moe-backend-for-prefill. Downstream Runner and MoeConfig validation remains authoritative.

Changes

MoE backend validation

Layer / File(s) Summary
Delegate backend validation
examples/layer_wise_benchmarks/run.py
The argument no longer uses parser-level choices validation. Comments identify downstream MoeConfig.backend validation as authoritative.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 79c83

This change removes a stale CLI restriction so supported MoE backends can be passed through to existing validation; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: laikhtewari, hyukn, kaiyux

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description clearly explains the problem, rationale, scope, validation limits, test coverage, and review follow-ups.
Title check ✅ Passed The title follows the required format and clearly identifies the fix to remove the stale backend choices list.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@ruodil
ruodil requested a review from hyukn August 13, 2026 05:34
@ruodil

ruodil commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65795 [ run ] triggered by Bot. Commit: ef19b46 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65795 [ run ] completed with state FAILURE. Commit: ef19b46
/LLM/main/L0_MergeRequest_PR pipeline #53501 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2 brnguyen2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving — the comments below are optional touch-ups, not blockers.

Removing the choices list is right: both flags feed the same Runner(moe_backend=...) → MoeConfig.backend, and only one of them had a duplicate list to drift. Two small things: the comment block is 6 lines for a 1-line change and will itself go stale (it enumerates counts and backend names); a single line pointing at MoeConfig.backend as the authority would age better. And the PR description lists WIDEEP among the backends replace_routing_method_ctx accepts — the check at tensorrt_llm/tools/layer_wise_benchmarks/runner.py:692 only allows CUTEDSL/CUTLASS/DEEPGEMM/TRTLLM.

Comment thread examples/layer_wise_benchmarks/run.py Resolved
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

…ble claim

The six-line block enumerated backend names and a count, which is exactly
the kind of thing that goes stale: it said "eleven values" while
MoeConfig.backend has had twelve since NVIDIA#16190, and it attributed
replace_routing_method_ctx to "this file's own runner.py" when that
function lives in tensorrt_llm/tools/layer_wise_benchmarks/runner.py.

Keep only the part that cannot drift -- MoeConfig.backend is the
authority, so a second list here can only diverge from it.

Signed-off-by: Ruodi Lu <ruodil@users.noreply.github.com>
@ruodil

ruodil commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Review comments addressed in 79c830f7fc; main merged in. Skipping CI on this one — reasoning below.

Why the last run was red, and why it wasn't this PR. PR_Github #65795 / L0_MergeRequest_PR #53501 on ef19b46 failed, but not on anything this change touches. The CI failure analysis for that build answers "PR likely to blame?" with No, and attributes the failures to three unrelated causes:

# Failure Stage
RC-1 test_modeling_gpt_oss.py::test_gpt_oss_two_model_eagle3_falls_back_to_v1 and ::test_gpt_oss_explicit_v2_rejects_two_model_eagle3 — GPT-OSS Eagle3 KV-cache-manager selection disagreeing with the test DGX_B200-PyTorch-6, DGX_H100-PyTorch-4 (+ retry)
RC-2 CMake FetchContent could not clone pybind11 / cppzmq / nlohmann-json: fatal: could not read Username for 'https://github.com' — transient infra H100_PCIe-CPP-1
RC-3 BERT quickstart timeout RTXPro6000D-PyTorch-1

Both builds passed (Build-x86_64 #1015, Build-SBSA #8164), as did L0_Test-SBSA-Single-GPU #820.

Why skip rather than re-run. The net diff against main is one file, examples/layer_wise_benchmarks/run.py: drop choices=["CUTLASS", "DEEPGEMM"] from --moe-backend-for-prefill, plus a two-line comment. No library code, no test lists, no build inputs — nothing in the pre-merge pipeline exercises this path, and the value space only widens to what MoeConfig.backend already validates. Re-running would spend DGX-H100/B200 hours to re-confirm failures that belong to other changes.

@ruodil

ruodil commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "argparse-only change in examples/layer_wise_benchmarks/run.py; prior #53501 failures (GPT-OSS Eagle3 unit tests, pybind11 FetchContent clone, BERT quickstart timeout) are unrelated"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66665 [ skip ] triggered by Bot. Commit: 79c830f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #66665 [ skip ] completed with state SUCCESS. Commit: 79c830f
Skipping testing for commit 79c830f

Link to invocation

@ruodil
ruodil merged commit bac9a5c into NVIDIA:main Aug 17, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants