Skip to content

[Bug] Guard FlashInfer CUTLASS MoE against 0-token inputs - #38780

Merged
BBuf merged 3 commits into
sgl-project:mainfrom
Betelgeu:fix/mxfp4-empty-tokens
Sep 18, 2026
Merged

BBuf merged 3 commits into
sgl-project:mainfrom
Betelgeu:fix/mxfp4-empty-tokens

Conversation

@Betelgeu

@Betelgeu Betelgeu commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

TBO + DP attention can produce empty child batches. CUTLASS fused MoE asserts a non-null input_activations pointer, and PyTorch 0-row tensors have data_ptr()==0, which crashes flashinfer_mxfp4.

Motivation

Fixes #38773.

FlashInfer CUTLASS flashinfer_mxfp4 asserts on 0-token MoE batches because empty PyTorch tensors have data_ptr() == 0. DP attention + TBO hits this on idle ranks / bs=1 decode (child_a or idle hidden states are [0, H]). TBO is especially important on communication-bound GPUs such as L20N; this crash currently blocks enabling it together with flashinfer_mxfp4.

Modifications

In _fused_experts_flashinfer_mxfp4_cutlass, return StandardCombineInput(hidden_states=x) when x.shape[0] == 0, before pad / CUTLASS. Same identity early-return as moe_runner/aiter.py and moe_runner/humming.py.

Accuracy Tests

N/A. 0-token path is identity; no change to non-empty batches.

Speed Tests and Profiling

Checklist


CI States

Latest PR Test (Base): ❌ Run #35075254113
Latest PR Test (Extra): ❌ Run #35075253797
Latest PR Test (AMD ROCm 10): ❌ Run #35075254187

@Betelgeu

Copy link
Copy Markdown
Contributor Author

@BBuf @Fridge003 could you take a look? Small 0-token guard for FlashInfer CUTLASS mxfp4 (fixes #38773). Could you also /tag-and-rerun-ci?

@Betelgeu

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T08:53:47.887701Z 71ed0e2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 71ed0e2b97

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

TBO + DP attention can produce empty child batches. CUTLASS fused MoE
asserts a non-null input_activations pointer, and PyTorch 0-row tensors
have data_ptr()==0, which crashes flashinfer_mxfp4.

Co-authored-by: Cursor <[email protected]>
@Betelgeu
Betelgeu force-pushed the fix/mxfp4-empty-tokens branch from 71ed0e2 to 11b7cb9 Compare September 10, 2026 09:26
@BBuf BBuf added run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) bypass-fastfail labels Sep 16, 2026
@@ -0,0 +1,70 @@
"""CPU tests for FlashInfer MXFP4 CUTLASS 0-token early return."""

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.

Let's remove this test, because it's a very safe and simpile fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let's remove this test, because it's a very safe and simpile fix.

removed, thanks for the review!

The guard is a tiny identity early-return; BBuf asked to drop the extra CPU test.

Co-authored-by: Cursor <[email protected]>
@Betelgeu

Copy link
Copy Markdown
Contributor Author

@BBuf CI reds look unrelated to this change. Could you merge or /rerun-failed-ci? Thanks!

@BBuf
BBuf merged commit 826d517 into sgl-project:main Sep 18, 2026
180 of 200 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] flashinfer_mxfp4 crashes on 0-token MoE batches

2 participants