Skip to content

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

Open
ruodil wants to merge 1 commit into
NVIDIA:mainfrom
ruodil:user/ruodil/lwb-prefill-moe-choices
Open

[None][fix] Drop the stale choices list on --moe-backend-for-prefill#17612
ruodil wants to merge 1 commit 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=...):

  • run.py:182Runner(..., moe_backend=args.moe_backend, ...)
  • run.py:252Runner(..., moe_backend=args.moe_backend_for_prefill, ...)
  • runner.pyllm_args = TorchLlmArgs(..., moe_config=MoeConfig(backend=moe_backend, ...))

MoeConfig.backend is a pydantic Literal over eleven values 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) AUTO, CUTLASS, CUTEDSL, WIDEEP, TRTLLM, DEEPGEMM, DENSEGEMM, VANILLA, TRITON, MARLIN, MEGAMOE_DEEPGEMM
runner.py replace_routing_method_ctx CUTEDSL, CUTLASS, DEEPGEMM, TRTLLM, WIDEEP
run.py --moe-backend-for-prefill (before) CUTLASS, DEEPGEMM

TRTLLM and CUTEDSL are excluded by the CLI even though runner.py in this same directory 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:135-136). 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.

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.
  • No tests were added because this change only updates argparse behavior.

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: 5b2541c5-2e0f-40c1-9491-8cc206a2b7aa

📥 Commits

Reviewing files that changed from the base of the PR and between c9116ef and ef19b46.

📒 Files selected for processing (1)
  • examples/layer_wise_benchmarks/run.py

Walkthrough

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

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

Mergeability Score: ⚪ Minimal · up to ef19b

This localized change removes a stale CLI restriction so supported backend values can reach existing validation; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: bowenfu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix: removing the stale choices list from --moe-backend-for-prefill.
Description check ✅ Passed The description explains the issue, rationale, scope, validation behavior, test coverage, and checklist status.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

parser.add_argument("--max-num-tokens", type=int)
parser.add_argument("--moe-backend", type=str)
parser.add_argument("--moe-backend-for-prefill", type=str, choices=["CUTLASS", "DEEPGEMM"])
# No choices= here, for the same reason --moe-backend above has none: both values reach

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.

The comment says "this file's own runner.py", but replace_routing_method_ctx lives in tensorrt_llm/tools/layer_wise_benchmarks/runner.py:688, not in this directory. Suggest collapsing the whole block to something that can't go stale, e.g.:

# 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.

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