Skip to content

fix: avoid SM120 MXFP8 MXFP4 autotune crash - #4066

Open
waynehacking8 wants to merge 1 commit into
flashinfer-ai:mainfrom
waynehacking8:wayne/fix-4049-sm120-mxfp8-mxfp4-autotune
Open

waynehacking8 wants to merge 1 commit into
flashinfer-ai:mainfrom
waynehacking8:wayne/fix-4049-sm120-mxfp8-mxfp4-autotune

Conversation

@waynehacking8

@waynehacking8 waynehacking8 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • skip unsafe SM120/SM121 MXFP8 x MXFP4 profiling and use fallback tactics
  • add focused autotune regression coverage

Fixes #4049

Testing

  • focused autotune and non-autotune MXFP8 x MXFP4 tests on SM120
  • ruff check and ruff format --check on changed files

Summary by CodeRabbit

  • Bug Fixes

    • Improved fused Mixture-of-Experts execution on SM120/SM121 for MXFP8 activations with MXFP4 weights by skipping unsupported profiling/tactic autotuning in a specific configuration.
  • Tests

    • Added a use_autotune option to the MXFP8/MXFP4 test to run with autotuning enabled or disabled.
    • Introduced an SM120/SM121-targeted regression test to validate the autotuned path on supported devices.

@coderabbitai

coderabbitai Bot commented Jul 20, 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b8d8e61-14b2-4524-bfed-bde70a465a7c

📥 Commits

Reviewing files that changed from the base of the PR and between 1ff1f79 and 9a99fb8.

📒 Files selected for processing (2)
  • flashinfer/fused_moe/core.py
  • tests/moe/test_trtllm_cutlass_fused_moe.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/moe/test_trtllm_cutlass_fused_moe.py
  • flashinfer/fused_moe/core.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The fused-MoE autotuning path now bypasses SM120/SM121 profiling for MXFP8 activation scaling with int64 expert weights. Tests can enable autotuning and add SM120/SM121-specific regression coverage.

Changes

SM120 fused-MoE autotune guard

Layer / File(s) Summary
Tactic selection guard
flashinfer/fused_moe/core.py
The guarded SM120/SM121 configuration sets both GEMM tactic selections to -1; other profile selection behavior remains unchanged.
Autotune regression coverage
tests/moe/test_trtllm_cutlass_fused_moe.py
The MXFP8/MXFP4 test defaults autotuning to disabled and adds a capability-gated SM120/SM121 regression test with fixed parameters.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 9a99f

This localized change avoids the SM120/SM121 MXFP8×MXFP4 autotune crash by using fallback tactics and adds focused regression coverage; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: aleozlx, yzh119, samuellees

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing the SM120 MXFP8/MXFP4 autotuning crash.
Description check ✅ Passed The description provides a clear summary, links issue #4049, and documents focused testing and lint checks. It omits the repository checklist sections, but the required change and validation informati…
Linked Issues check ✅ Passed The changes satisfy issue #4049 by skipping unsafe SM120/SM121 profiling for the affected MXFP8-activation and MXFP4-weight path, setting both GEMM tactics to the usable fallback, and adding focused r…
Out of Scope Changes check ✅ Passed The changes are limited to the fused-MoE profiling guard and related autotune regression tests. No unrelated code changes are identified.
Full details: Description check

Explanation

The description provides a clear summary, links issue #4049, and documents focused testing and lint checks. It omits the repository checklist sections, but the required change and validation information are present.

Full details: Linked Issues check

Explanation

The changes satisfy issue #4049 by skipping unsafe SM120/SM121 profiling for the affected MXFP8-activation and MXFP4-weight path, setting both GEMM tactics to the usable fallback, and adding focused regression coverage.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 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.

@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 addresses an issue where the SM120/SM121 profiler could poison the CUDA context when profiling MXFP8 x MXFP4 TMA inputs. It bypasses profiling and uses fallback tactics when the backend is SM120/SM121, use_mxfp8_act_scaling is enabled, and fc1_expert_weights are torch.int64. Additionally, a regression test test_moe_mxfp8_mxfp4_autotune_sm120 has been added to verify this behavior under autotuning. I have no further feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@hebo1221

Copy link
Copy Markdown
Contributor

Independent hardware validation on this exact PR head (0268e33d): NVIDIA GB10 / SM121, CUDA 13.x container, source/JIT build. I ran both the existing MXFP8×MXFP4 parameterized test and this PR’s autotune regression node; all 7 cases passed numerically (7 passed, 3 warnings).

While reproducing #4049 on current main, I also isolated all 20 GEMM1 tactics in fresh processes. Every tactic failed for this quantization path; tactics 0, 6, 8, 10, 16, 18 additionally left the CUDA context reporting an illegal instruction on synchronization or the next allocation. The same classification reproduced with the reported model dimensions (hidden_size=4096, intermediate_size=2048). The normal -1 fallback path remained usable, which supports this PR’s narrow profiling guard.

I had opened #4121 after missing this earlier PR; its core guard is equivalent, so I am closing mine as a duplicate and consolidating the validation here. Test orchestration and code navigation were AI-assisted; the builds and GPU results above were executed against this PR head.

@waynehacking8

Copy link
Copy Markdown
Contributor Author

@flashinfer-bot run

@waynehacking8

Copy link
Copy Markdown
Contributor Author

Rebased onto current main as 0923f512c and reran CI. The required Test Results Summary is still blocked by repository authorization, not a test failure; a contributor in @flashinfer-ai/ci-users needs to approve the run.

bkryu pushed a commit that referenced this pull request Aug 11, 2026
## 📌 Description

`GemmProfilerBackend::init()` receives `use_mxfp8_act_scaling` but does
not retain it, so `prepareQuantParams()` always constructs
`QuantParams::FP8MXFP4` on the FP8-activation/MXFP4-weight path. That
leaves the `mxfp8_mxfp4` weight block-scale pointers null, so the MXFPX
scale-factor descriptor setup is skipped during profiling.

VictoriaLogs captured the affected DeepSeek-V4-Flash-0731 TP2 startup
reaching fused-MoE profiling and then exiting after this error surfaced:

```text
[AutoTuner]: Tuning trtllm::fused_moe::gemm1
...
torch.AcceleratorError: CUDA error: an illegal instruction was encountered
...
[2026-07-31 15:42:01] Received sigquit from a child process. It usually means the child failed.
```

This change:

- stores `use_mxfp8_act_scaling` in the profiler;
- sizes the fc1 weight scale-factor workspace for the doubled
gated-activation output;
- initializes the profiler's fc1/fc2 weight block scale-factor
workspaces to UE8M0 unity on the MXFP8-activation path;
- constructs `QuantParams::MXFP8MXFP4` for MXFP8-activation/MXFP4-weight
profiling; and
- runs the existing numerical test with autotuning disabled and enabled.

When `use_mxfp8_act_scaling` is false, the existing
`QuantParams::FP8MXFP4` branch remains in use. The shared fc1
scale-factor workspace sizing is corrected for the gated output in both
branches. PR #4066 skips profiling and selects fallback tactics for
MXFP8×MXFP4 on SM120/SM121; this change repairs the profiler inputs and
retains tactic profiling. Both changes update the same regression test.

If this change is accepted, PR #4066's SM120/SM121 fallback-tactic
override should be removed, or #4066 closed. That override keeps
SM120/SM121 on fallback tactics for this mode, which makes this profiler
fix inert there.

## 🔍 Related Issues

Fixes #4049.

## 🚀 Pull Request Checklist

### ✅ Pre-commit Checks

- [x] I used `uvx pre-commit`.
- [ ] I installed the hooks with `pre-commit install`. Not used; hooks
were run directly with `uvx`.
- [x] Focused pre-commit checks pass for all three changed paths:
`csrc/fused_moe/cutlass_backend/cutlass_fused_moe_kernels.cuh`,
`csrc/nv_internal/tensorrt_llm/kernels/cutlass_kernels/include/moe_kernels.h`,
and `tests/moe/test_trtllm_cutlass_fused_moe.py`.

## 🧪 Tests

- [x] Tests have been added or updated as needed.
- [ ] The complete repository test suite was not run.
- `uv run --no-project python -m pytest -q
tests/moe/test_trtllm_cutlass_fused_moe.py -k mxfp8_mxfp4` on SM120: 12
passed, 6 skipped, 132 deselected.
- With this change applied, a `DeepSeek-V4-Flash-0731` TP2 startup
completed all 10 gemm1 and 10 gemm2 profiler candidates on both ranks,
completed FlashInfer autotuning, captured the target and draft CUDA
graphs, and reached ready state with zero restarts.

Test limitations: the autotuned numerical test exercises this path and
checks numerical parity, but it does not directly inspect the fabricated
workspace contents. The non-MXFP8 activation branch touched by the
shared fc1 scale-factor sizing has no focused autotune regression case
in this validation.

## Reviewer Notes

The table below compares heuristic fallback tactics with
profiler-selected tactics. It is not a direct patched-versus-unpatched
throughput comparison; the patch is what allows the profiled-tactic side
to start successfully. Both sides used the same SGLang revision, model,
TP2 configuration, FP8 KV cache, DSpark width 5, hardware, and workload.
The control skipped `trtllm::fused_moe::gemm1` and `gemm2`; the
candidate profiled them.

Methodology: each decode cell is one unreplicated 30-second run at C1,
C2, C4, C8, C16, and C32. The coding row is the median of five
sequential requests with a 2,000-token cap. The prefill rows are the
median client-observed throughput from standalone cold-prefill runs at
exact 8K, 64K, and 128K prompts with 7, 2, and 1 samples, respectively.
All rows are single comparison runs with no variance estimate, and no
effect size is claimed from any row.

| Cell | Fallback tactics | Profiled tactics |
|---|---:|---:|
| C1 decode (tok/s) | 187.7 | 240.5 |
| C2 decode (tok/s) | 241.4 | 349.5 |
| C4 decode (tok/s) | 347.1 | 515.2 |
| C8 decode (tok/s) | 456.5 | 662.9 |
| C16 decode (tok/s) | 683.8 | 992.8 |
| C32 decode (tok/s) | 1030.7 | 1413.6 |
| Coding median (tok/s) | 218.1 | 264.8 |
| 8K prefill (tok/s) | 7444 | 7638 |
| 64K prefill (tok/s) | 8557 | 8351 |
| 128K prefill (tok/s) | 7922 | 7744 |

The pinned 1,319-row GSM8K gate was not counted as passing because each
run had one response finish at the 1,024-token cap. Two profiled-tactic
runs scored 1,241 and 1,239 correct; the fallback-tactic control scored
1,240 correct. No quality difference is claimed from these runs.

AI was used to assist with implementation.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved profiling for fused mixture-of-experts workloads using MXFP8
activations and MXFP4 weights.
* Corrected workspace sizing and scaling behavior for quantized weight
formats.
  * Added validation for unsupported scaling configurations.

* **Tests**
* Expanded coverage to verify both autotuned and default execution paths
for quantized MoE workloads.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@waynehacking8
waynehacking8 force-pushed the wayne/fix-4049-sm120-mxfp8-mxfp4-autotune branch from 0923f51 to 9a99fb8 Compare August 25, 2026 01:44
@coderabbitai

coderabbitai Bot commented Aug 25, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SM120 fused-MoE gemm1 tactic profiling followed by illegal instruction

3 participants