Skip to content

Update moe gemm - #3239

Merged
aleozlx merged 6 commits into
flashinfer-ai:mainfrom
IwakuraRein:update-moe-gemm
May 8, 2026
Merged

aleozlx merged 6 commits into
flashinfer-ai:mainfrom
IwakuraRein:update-moe-gemm

Conversation

@IwakuraRein

@IwakuraRein IwakuraRein commented May 6, 2026

Copy link
Copy Markdown
Collaborator

📌 Description

Update the trtllm-gen cubin to improve mxfp4 moe, DeepSeek-V3 MoE, and mxfp8 gemm performance.

🔍 Related Issues

🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

Reviewer Notes

Summary by CodeRabbit

  • New Features

    • Improved GPU SM detection to ensure only compatible batched GEMM configurations are considered.
  • Updates

    • Refined low-latency GEMM kernel selection to use updated tile-size and dimension variants.
    • Adjusted FP8 GEMM kernel selection to new kernel variants for better coverage.
    • Updated artifact references and checksums for TRTLLM GEMM/BMM binaries.

Signed-off-by: Siyuan Fu <siyuanf@nvidia.com>
Signed-off-by: Siyuan Fu <siyuanf@nvidia.com>
Signed-off-by: Siyuan Fu <siyuanf@nvidia.com>
@IwakuraRein

Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9010396e-a04b-4959-9639-39877591b228

📥 Commits

Reviewing files that changed from the base of the PR and between 28ff015 and faaf038.

📒 Files selected for processing (1)
  • csrc/trtllm_gemm_runner.cu

📝 Walkthrough

Walkthrough

Adds SM detection and architecture guards to TRTLLM batched GEMM config selection when patchF2fp is enabled; updates low-latency GEMM kernel name constants; and updates prebuilt TRTLLM artifact paths and checksums.

Changes

TRTLLM Architecture Gating & Artifacts

Layer / File(s) Summary
SM Detection & Config Extraction
csrc/trtllm_batched_gemm_runner.cu
Adds sm_version = getSMVersion() and refactors per-config access to use a local config and options = config.mOptions.
Architecture Guards (patchF2fp)
csrc/trtllm_batched_gemm_runner.cu
When options.mPatchF2fp is true, skip configs unless: for sm_version == 103 config.mSm == Sm103a; for sm_version == 100 config.mSm == Sm100a or Sm100f. Existing EpilogueTileM check and passing-config indexing remain.
Artifact Paths & Checksums
flashinfer/artifacts.py
Updates ArtifactPath.TRTLLM_GEN_BMM and ArtifactPath.TRTLLM_GEN_GEMM prebuilt paths and updates CheckSumHash values for BMM/GEMM to new SHA256s.

Low-Latency Kernel Configuration

Layer / File(s) Summary
Kernel Name Constants
csrc/trtllm_low_latency_gemm_runner.cu
Replaces previous KERNEL_MMAN_*_TILEK_* strings with new GEMM kernel-name constants covering tileK = 8/16/32/64 and M/N 128/256 variants; removes the prior 16dp256b variant.
FP8 Kernel Names
csrc/trtllm_gemm_runner.cu
Replaces FP8 kernel-name string constants used in select_kernel_fp8 for high/low N/K ratio branches with updated _transOut_noShfl_dsFp8_... and _transOut_noShfl_dsFp8_schedS_... variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

run-ci, op: gemm, op: moe

Suggested reviewers

  • cyx-6
  • bkryu
  • nv-yunzheq
  • yongwww
  • sricketts
  • aleozlx
  • jimmyzho
  • yzh119

Poem

I hop through SM gates with care,
Guard configs true, and prune the errant pair,
Kernels renamed, artifacts refreshed,
Binaries aligned, the build feels blessed,
A rabbit cheers the compute fair. 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Update moe gemm' is vague and generic, using non-descriptive language that doesn't clearly convey what specific changes were made or their significance. Replace with a more specific title that describes the main change, such as 'Update trtllm-gen cubin for MoE and FP8 GEMM performance improvements' or 'Improve MoE GEMM kernel selection and configuration gating'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required Description section explaining the update purpose and indicates pre-commit checks and tests are complete, meeting core template requirements.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

GitLab MR !633 has been created, and the CI pipeline #50376866 is currently running. I'll report back once the pipeline job completes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates GEMM configuration filtering for SM 100 and 103, cleans up kernel names, and updates artifact hashes. Feedback indicates that the filtering logic for mPatchF2fp is incorrectly placed after the configuration is already accepted, rendering it ineffective. Additionally, the use of std::cerr for error reporting is noted as redundant and should be integrated into the existing FLASHINFER_CHECK macro to better align with library logging practices.

Comment thread csrc/trtllm_batched_gemm_runner.cu Outdated
Comment thread csrc/trtllm_batched_gemm_runner.cu Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@csrc/trtllm_batched_gemm_runner.cu`:
- Around line 124-133: The push of index i into mPassingConfigIndices happens
before the SM/patchF2fp checks so incompatible configs slip through; move or
conditionally perform mPassingConfigIndices.push_back(i) after the patchF2fp/SM
filtering (the blocks that check options.mPatchF2fp, sm_version, and config.mSm
against tg::CudaArch::Sm103a/Sm100a/Sm100f) and also ensure the
transposeMmaOutput check (mOptions.transposeMmaOutput && options.mEpilogueTileM
== mOptions.epilogueTileM) is evaluated only after those SM guards pass, so that
only configs that survive the SM filters get pushed into mPassingConfigIndices.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b015f9b5-b3e5-4c65-86bd-821c96ec416b

📥 Commits

Reviewing files that changed from the base of the PR and between ba30d4f and c72926c.

📒 Files selected for processing (3)
  • csrc/trtllm_batched_gemm_runner.cu
  • csrc/trtllm_low_latency_gemm_runner.cu
  • flashinfer/artifacts.py

Comment thread csrc/trtllm_batched_gemm_runner.cu Outdated
Signed-off-by: Siyuan Fu <siyuanf@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@csrc/trtllm_batched_gemm_runner.cu`:
- Around line 94-95: The code snapshots SM via getSMVersion() at construction
which can differ from the device used in run(), causing incorrect entries in
mPassingConfigIndices for patchF2fp; either (A) bind the runner to a single
device by storing the intended device ID in the constructor and assert that the
device argument passed to run() matches that stored ID before using sm_version
(so the original SM-based filter remains safe), or (B) remove the SM-based
filtering from construction and instead perform the SM filtering of patchF2fp
when computing valid configs in getValidConfigIndices() or inside run() where
the explicit device argument is available (call getSMVersion() for that device
there) and then populate mPassingConfigIndices based on that device-specific SM
version. Ensure you update references to getSMVersion(), mPassingConfigIndices,
run(), getValidConfigIndices(), and patchF2fp accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee9b459e-38e9-4358-94dc-36b3c22d74d4

📥 Commits

Reviewing files that changed from the base of the PR and between c72926c and 52d54c9.

📒 Files selected for processing (1)
  • csrc/trtllm_batched_gemm_runner.cu

Comment on lines +94 to 95
auto sm_version = getSMVersion();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Do not make SM-specific config admission depend on the current device at construction time.

Line 94 snapshots getSMVersion() from whichever CUDA device is current during construction, but the runner later executes against an explicit device argument in run(). That means a runner created on one GPU and reused on another can permanently admit the wrong patchF2fp configs into mPassingConfigIndices, which later drives getValidConfigIndices(). Please either bind the runner to a single device and assert that on use, or move this SM filtering to a path that already knows the target device.

Also applies to: 124-130

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@csrc/trtllm_batched_gemm_runner.cu` around lines 94 - 95, The code snapshots
SM via getSMVersion() at construction which can differ from the device used in
run(), causing incorrect entries in mPassingConfigIndices for patchF2fp; either
(A) bind the runner to a single device by storing the intended device ID in the
constructor and assert that the device argument passed to run() matches that
stored ID before using sm_version (so the original SM-based filter remains
safe), or (B) remove the SM-based filtering from construction and instead
perform the SM filtering of patchF2fp when computing valid configs in
getValidConfigIndices() or inside run() where the explicit device argument is
available (call getSMVersion() for that device there) and then populate
mPassingConfigIndices based on that device-specific SM version. Ensure you
update references to getSMVersion(), mPassingConfigIndices, run(),
getValidConfigIndices(), and patchF2fp accordingly.

Signed-off-by: Siyuan Fu <siyuanf@nvidia.com>
@IwakuraRein

Copy link
Copy Markdown
Collaborator Author

/bot run

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

GitLab MR !633 has been updated with latest changes, and the CI pipeline #50476508 is currently running. I'll report back once the pipeline job completes.

Signed-off-by: Siyuan Fu <siyuanf@nvidia.com>
@IwakuraRein

Copy link
Copy Markdown
Collaborator Author

/bot run

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

GitLab MR !633 has been updated with latest changes, and the CI pipeline #50493570 is currently running. I'll report back once the pipeline job completes.

@IwakuraRein

Copy link
Copy Markdown
Collaborator Author

/bot run

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

GitLab MR !633 has been created, and the CI pipeline #50570842 is currently running. I'll report back once the pipeline job completes.

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.

3 participants