Repository navigation
fix(moe_ep): ignore non-finite scores on masked Rubin routes - #7062
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Masked-route validation contract flashinfer/moe_ep/backends/mega/kernel/sm107/validation.py, flashinfer/moe_ep/backends/mega/kernel/sm107/routing_validation.py, tests/moe_ep/test_sm107_block_scaled_contracts.py, tests/moe_ep/test_sm107_preparation.py, docs/design_docs/moe_ep_sm107_qualification.md, CLAUDE.md |
Validation requires finite scores only for active routes. FLASHINFER_SM107_MEGA_CHECK_ROUTES=0 skips route-value checks while metadata checks remain active. Tests cover masked and active routes, fused checking, and the setting. |
Route staging and backend wiring flashinfer/moe_ep/backends/mega/kernel/sm107/routing_staging.py, flashinfer/moe_ep/backends/mega/kernel/sm107/*_cutedsl/backend.py, flashinfer/moe_ep/backends/mega/kernel/sm107/*_cutedsl/staging.py, tests/moe_ep/test_sm107_preparation.py |
stage_routes stages IDs as int32 and scores as float32, setting masked-route scores to zero. Backend paths use route staging. Tests cover layouts, fallback behavior, graph replay, and unchanged caller scores. |
Fused quantization and staging flashinfer/moe_ep/kernel_src/sm100/cutedsl_megamoe/shim/quant_stage.py, flashinfer/moe_ep/backends/mega/kernel/sm107/mxfp8_mxfp8_bf16_cutedsl/staging.py, tests/moe_ep/test_sm107_preparation.py, docs/design_docs/moe_ep_sm107_qualification.md |
Eligible MXFP8 inputs use fused quantization and staging; unsupported inputs use Torch staging. fused_quant_stage adds an MXFP8 normal-scale option. Tests compare fused outputs and scales with reference paths. |
Multirank and graph verification tests/moe_ep/test_moe_ep_sm107_block_scaled_mega_multirank.py |
Multirank tests compare outputs for masked scores containing NaN or infinities with outputs for zeroed scores, including direct calls and graph replays. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant MegaMoEBackend
participant stage_mega_moe_inputs
participant fused_quant_stage
participant Workspace
MegaMoEBackend->>stage_mega_moe_inputs: Stage eligible inputs and routes
stage_mega_moe_inputs->>fused_quant_stage: Pass inputs and route buffers
fused_quant_stage->>Workspace: Write quantized inputs and staged routes
Possibly related issues
- [CAKE] MoE & Routing Kernel Progress Tracker #6597: This tracker covers MegaMoE work, including the routing and staging changes in this PR.
Suggested labels: op: moe
Merge Risk: 
Minimal · up to 25f28
-
No actionable merge-blocking issue is established by the supplied evidence; the change is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description includes the required sections, explains the routing and staging changes, links a related issue, and records pre-commit and test checklist status. The experimental section remains untouched, as appropriate for this non-experimental change.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 11 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
Anerudhan
left a comment
There was a problem hiding this comment.
Codex bot review · model: gpt-6-astra
Reviewed bace29645155 against base 3f398977d75b.
The masked-route contract and staging paths are consistent: inactive scores are zeroed without changing caller inputs, while active routes keep the finite-score and uniqueness checks. Reviewed validation, both backend call paths, fused quantization, route staging, cache specialization, graph bindings, capacity tails, tests, and documentation. No approval-blocking defect found.
[P3] Record before/after staging measurements
This also enables a new fused MXFP8 staging path by default and replaces prequantized route copies with a kernel, but the description has no before/after measurements. Add a reproducible SM107 staging or full-forward benchmark with absolute times, shapes, dtype, and graph mode, as required by the repository review guidance for performance changes.
Evidence: The MXFP8 stage selects fused_quant_stage by default when eligible; the description and qualification document describe the path without measured staging or forward costs. Attribution: New finding from this review.
Validation: 119 focused host tests passed; 231 SM107 preparation cases skipped on the CPU-only test environment. 384 additional cases passed through the actual backend staging functions on CPU: four quantization kinds, BF16/prequantized inputs, four score dtypes, contiguous/strided/offset routes, and live counts 0/1/8/16. Checked masked NaN/+Inf/-Inf scores, input preservation, activation/scale bytes, live counts, and capacity tails. Offline CuTe-DSL 4.8.1/CUDA 12.9 compilation generated SM100a GPU binaries for the new MXFP8 kernels at hidden widths 16384 (E4M3) and 7168 (E5M2), plus six route-staging variants spanning FP16/BF16/FP32 scores and contiguous/strided inputs. No kernel was launched. Checked the current discussions and the existing failed CI summary: its test jobs were skipped pending authorization; it did not report a test assertion failure.
Limitations: No local GPU execution: the shared GPU was occupied. Offline compilation targeted SM100a because the installed CUDA 12.9 compiler does not support SM107a; this does not validate native SM107 behavior, graph replay, multi-rank execution, or performance. The available GitHub focused CI matrix uses H100 for these paths, so its SM107-only tests will skip. Native SM107 staging parity and pooled multi-rank graph tests remain unverified by this review.
Approved: no P0 or high-risk P1 found. Remaining findings stay with the owner; merge timing stays with the owner.
|
Requesting targeted CI for Codex bot review — model |
|
@flashinfer-bot run tests/moe_ep/test_sm107_block_scaled_contracts.py tests/moe_ep/test_sm107_preparation.py |
|
Focused CI completed for The setup and H100 logs both identify merge Codex bot review — model |
Anerudhan
left a comment
There was a problem hiding this comment.
Codex bot review · model: gpt-6-astra
Reviewed 25f286b7852d against base 872554187e41.
The explicit route-check opt-out skips only value checks. Default validation, metadata checks, masked-score zeroing and caller preservation remain intact. Graph behavior is documented correctly: the switch must be set before capture, and changing captured checks requires recapture. No new approval-blocking defect found.
- [P3] Still open: Record before/after staging measurements.
Validation: 125 focused host tests passed, including all six default/enabled/disabled and fused/fallback opt-out cases; 231 SM107 preparation tests skipped in the CPU environment. With FLASHINFER_SM107_MEGA_CHECK_ROUTES=0, 384 cases passed through the actual backend staging functions on CPU: four quantization kinds, BF16/prequantized inputs, four score dtypes, contiguous/strided/offset routes, and live counts 0/1/8/16. Masked NaN/Inf scores were zeroed; caller tensors, activation/scale bytes, live counts and capacity tails were checked. Reviewed the complete four-file follow-up, both backend stage_inputs callers and the metadata-validation boundary. All GPU kernels, quantization, route staging, cache keys and execution bindings are byte-identical to the prior bace296 review. No redundant compilation sweep was run. Current-head run 40405319989 skipped setup/tests pending authorization; its failed summary is not a test assertion failure. Trusted main CI files at 8725541 match the previously read 215f83c versions. A focused contract-file CI request is appropriate after publication.
Limitations: No local GPU, sanitizer, multi-rank or timing run; shared GPUs remain occupied. CPU staging exercises the Torch path, not fused GPU kernels. Prior offline compilation targeted SM100a, not native SM107, and prior H100 CI skipped SM107 preparation. The opt-out assumes caller-validated IDs and active scores; it intentionally does not sanitize invalid active routes.
Comment only: this PR already has an active approval; preserving existing approvals.
|
Requesting targeted CI for Codex bot review — model |
|
@flashinfer-bot run tests/moe_ep/test_sm107_block_scaled_contracts.py |
|
CI follow-up for The H100 job passed all 125 tests in Codex bot review — model |
📌 Description
Rubin MegaMoE rejects NaN and infinite routing scores even when the expert ID is
-1and the slot is unused. Allow those scores for masked slots and stage them as zero without modifying the caller’s tensors. By default, active routes require finite scores, valid expert IDs and no duplicates.Use a route-staging kernel for prequantized NVFP4/MXFP8 inputs. BF16-to-MXFP8 staging quantizes activations and writes routes directly into the workspace, with the same scale rounding as the Torch path. Unsupported layouts retain Torch staging.
Set
FLASHINFER_SM107_MEGA_CHECK_ROUTES=0to skip routing value checks when the caller guarantees valid routing. Metadata checks and masked-score zeroing still run. Set it before warmup and CUDA graph capture.🔍 Related Issues
Related: #6398.
🚀 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
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).🔬 Experimental Track
flashinfer/experimental/and/or an@flashinfer_experimental_api. Tracking issue: #tests/experimental/and were validated on the intended hardware; a runnable example is included.flashinfer/aot.py, and no experimental backend is reachable frombackend="auto"withoutFLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1. (Calling an@flashinfer_experimental_apior naming a backend explicitly is itself the opt-in and needs no environment variable.)Reviewer Notes
None.
Summary by CodeRabbit
-1) now accept NaN or infinite routing scores, which are treated as zero during staging without modifying caller tensors.