Skip to content

[sgl-kernel] Build common_ops for sm_90a when FA3 is off (aarch64 wheels lack it) - #42263

Closed
SamMausberg wants to merge 1 commit into
sgl-project:mainfrom
SamMausberg:fix/sgl-kernel-sm90a-without-fa3
Closed

SamMausberg wants to merge 1 commit into
sgl-project:mainfrom
SamMausberg:fix/sgl-kernel-sm90a-without-fa3

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 2, 2026 •

Copy link
Copy Markdown

Motivation

On a GH200 (aarch64, sm_90), the SM90 CUTLASS GEMMs in the released sglang-kernel 0.4.8 aarch64 wheel compute nothing. Each call prints

ERROR : Arch conditional MMA instruction used without targeting sm90a compute capability. Aborting.

and returns without computing the product. Some calls print the same line with "appropriate" in place of "sm90a"; that is the one the server printed. In my runs the outputs were NaN, values up to 5.8e34, or plain wrong numbers. A Qwen3.5-4B server launched with --quantization fp8 wrote the line 188,469 times (20 MB) in under 50 seconds, starting at prefill CUDA graph capture, until my log cap cut the log off.

The aarch64 wheel's common_ops has no sm_90a code; the x86_64 wheel of the same release has it. #28394 made FA3 default off on aarch64. In the same change, it made the sm_90a gencode for common_ops conditional on FA3 (CMakeLists.txt#L243-L247). Before #28394, every build with CUDA >= 12.4 added it.

Modifications

The condition drops AND SGL_KERNEL_ENABLE_FA3, with a one-line comment saying why. FA3 itself stays off on aarch64.

  • Builds with FA3 on, the x86_64 default with CUDA >= 12.4, get identical flags.
  • Builds with FA3 off, the aarch64 default, add sm_90a to common_ops (both the sm90 and sm100 builds) and to spatial_ops. Other targets are unchanged.

I checked both with a configure-only run on aarch64, reading each target's gencodes from build.ninja.

cutlass_fp8_supported() is unchanged. It cannot tell which SASS a wheel carries without loading or disassembling the library. Wheels that are already released stay affected. On them, USE_TRITON_W8A8_FP8_KERNEL=1 keeps FP8 linear layers off the CUTLASS path, but the INT8 linear layers and the W4A8 MoE GEMMs have no such switch.

Accuracy Tests

I tested on one GH200 (CUDA 13.0, torch 2.13.0+cu130). To keep the builds short, I built only common_ops_sm90_build and only for SM90, twice: once with sm_90 + sm_90a (this PR's layout for SM90) and once with sm_90a alone. Each build went into a copy of the installed sgl_kernel package, in place of sm90/common_ops.abi3.so.

  • sgl-kernel's FP8, INT8 and MoE GEMM tests (five files) pass with both rebuilt libraries, and neither prints the error. Against the wheel's library, each file fails on its first case.
  • When both sm_90 and sm_90a code are present, the driver loads the sm_90a code. A probe kernel that reports __CUDA_ARCH_FEAT_SM90_ALL gave 1 when built for both (in either gencode order) and 0 for sm_90 alone.
  • With the sm_90a-only library, the Qwen3.5-4B server with --quantization fp8 started and did not print the line (two launches). It scores 0.830 on the first 200 GSM8K test questions. With otherwise identical flags, BF16 scores 0.870 and the wheel with USE_TRITON_W8A8_FP8_KERNEL=1 scores 0.845. With 200 questions the 95% intervals are about 10 points wide, so this only shows that the FP8 server answers sensibly.

The full commands, per-file test counts and environment are in the details below.

Speed Tests and Profiling

Not measured: this changes which architectures are compiled, not the kernels.

Not tested

  • An x86_64 configure or build.
  • A full aarch64 wheel. I did not compile the sm100 build or spatial_ops with sm_90a, so wheel size and build time are not measured.
  • Blackwell (GB200). Its sm100 build now also carries sm_90a code that never loads there, as on x86_64.

Checklist

  • Format your code according to the Format code with pre-commit.
  • Add unit tests according to the Run and add unit tests. Build configuration only. The existing sgl-kernel GEMM tests fail against the aarch64 wheel on GH200 and pass against the rebuilt library (results above); no CI runner tests aarch64 wheels on SM90.
  • Update documentation according to Write documentations. Not needed.
  • Provide accuracy and speed benchmark results according to Test the accuracy and Benchmark the speed. Accuracy above; speed not measured (build flags only).
  • Follow the SGLang code style guidance.
Full test details

Motivation

On a GH200 (sm_90, aarch64), the SM90 CUTLASS GEMMs in the released sglang-kernel 0.4.8 wheel compute nothing. Each call prints

ERROR : Arch conditional MMA instruction used without targeting sm90a compute capability. Aborting.

(or the same line with "appropriate" in place of "sm90a", from CUTLASS's TMA warp-specialized pingpong and cooperative kernels; the server printed that one) from the device, then returns without computing the product. In my runs the outputs were NaN, values up to 5.8e34, or plain wrong numbers. With python -m sglang.launch_server --model-path Qwen/Qwen3.5-4B --quantization fp8 (plus memory and batch limits for a shared GPU, listed under Accuracy Tests), the server wrote the line 188,469 times (20 MB) in under 50 seconds, starting at prefill CUDA graph capture, until my log cap cut the log off. cutlass_fp8_supported() is True on any SM90 GPU with CUDA >= 12.0 (fp8_utils.py#L298), so online FP8 quantizes weights per channel and sends the linear layers to fp8_scaled_mm (L2194-L2207; shapes with a tuned Triton config are the exception).

The aarch64 wheel's common_ops has no sm_90a code:

$ cuobjdump --list-elf sgl_kernel/sm90/common_ops.abi3.so | sed 's/.*\.\(sm_[0-9a-z]*\)\..*/\1/' | sort | uniq -c
     35 sm_100
     35 sm_110a
     35 sm_120a
     35 sm_121a
     35 sm_90

The x86_64 wheel of the same release has 35 sm_90a ELFs in both sm90/ and sm100/common_ops, next to sm_80, sm_89, sm_90, sm_100 and sm_120a. CUTLASS's SM90 warp-specialized kernels compile to the stub that prints the message above unless they are built for sm_90a.

The cause is in python/sglang/kernels/aot/CMakeLists.txt. #28394 made FA3 default off on aarch64 (L109-L115). In the same change, the sm_90a gencode for common_ops became conditional on FA3 (L243-L247). Before #28394, every build with CUDA >= 12.4 added it. FlashMLA's build adds sm_90a without looking at FA3 (cmake/flashmla.cmake#L32-L36), which is why flashmla_ops in the same wheel has it.

Modifications

The condition drops AND SGL_KERNEL_ENABLE_FA3, and a one-line comment says why it does not depend on FA3. The flags change only where FA3 is off. I configured the build on aarch64 with CUDA 13.0 (no compile) and read each target's gencodes from build.ninja:

Configuration common_ops (sm90 and sm100 builds), spatial_ops Other targets
FA3 off (aarch64 default), main sm_90, sm_100f, sm_110a, sm_120a, sm_121a
FA3 off (aarch64 default), this PR the same plus sm_90a unchanged
FA3 on (-DSGL_KERNEL_ENABLE_FA3=ON, the x86_64 default with CUDA >= 12.4), main and this PR identical identical

All four were configured on the same aarch64 machine.

The aarch64 wheel still ships the sm90 build that the loader picks on GH200, so GH200 is evidently meant to work. FA3 stays off on aarch64; only the common_ops gencode goes back to its condition before #28394. SGL_KERNEL_ENABLE_SM90A stays declared and unused, as it is on main.

I left cutlass_fp8_supported() alone. It checks the device and the CUDA version, and it cannot tell which SASS a wheel carries without loading or disassembling the library. With the build fixed, its answer is correct again. Wheels that are already released stay affected. On them, USE_TRITON_W8A8_FP8_KERNEL=1 keeps FP8 linear layers off the CUTLASS path; the INT8 linear layers and the W4A8 MoE GEMMs have no such switch, and the FP8 MoE GEMMs use CUTLASS only with --moe-runner-backend cutlass.

Accuracy Tests

On one GH200 (aarch64; driver 570.195 with the CUDA 13.0 forward-compatibility libraries, cuda-compat 580.178; CUDA 13.0 toolkit; torch 2.13.0+cu130), SGLang main at f6fcda8. To keep the builds short, I built only common_ops_sm90_build, from this PR plus a local commit (not part of this PR) that drops gencodes after this PR's condition has added sm_90a. There were two builds: sm_90a alone, and sm_90 + sm_90a, which is this PR's layout for SM90. The full gencode lists above come from the configure-only check. For the tests, a copy of the installed sgl_kernel package with sm90/common_ops.abi3.so replaced by a build went first on PYTHONPATH; no other file changed.

With both sm_90 and sm_90a code present, the driver loads the sm_90a code on GH200. A small probe kernel that reports __CUDA_ARCH_FEAT_SM90_ALL gave 0 when built for sm_90 alone, 1 for sm_90a alone, and 1 when built for both, in either gencode order.

  • cuobjdump --list-elf on the built sm90/common_ops.abi3.so: 35 sm_90a ELFs for the first build, 35 sm_90 and 35 sm_90a for the second (the wheel's has no sm_90a).

  • Direct fp8_scaled_mm and int8_scaled_mm calls at N = 4096, K = 2560, M = 1, 16 and 256, against an FP32 reference. With the wheel's library, fp8_scaled_mm at M = 1 printed the error and returned NaN. With either rebuilt library, every case matched, with identical errors: max |error| at most 1.2e-4 for FP8 (outputs up to 0.023), and at most 0.25 for INT8 with BF16 output (outputs up to 125), which is BF16 rounding.

  • sgl-kernel's tests, run from python/sglang/kernels/aot/tests against each library (the wheel's runs with -x, so they stop at the first failure). Both rebuilt libraries gave the counts in the last column:

    Test file Wheel's library Rebuilt library
    test_fp8_gemm.py first case fails (max abs difference 5.8e34); error printed 512 times 816 passed, 1 skipped
    test_int8_gemm.py first case fails (all 16 elements mismatched); error printed 2,048 times 1260 passed
    test_fp8_blockwise_moe.py first case fails (the test's difference metric is 1.0, limit 0.001); error printed thousands of times 10 passed
    test_es_fp8_blockwise_moe.py first case fails (difference metric 1.0, limit 0.001); error printed thousands of times 10 passed
    test_cutlass_w4a8_moe_mm.py first case fails (945 of 1,024 elements mismatched); error printed thousands of times 605 passed

    The rebuilt libraries printed the error zero times.

  • Qwen/Qwen3.5-4B with --quantization fp8 (online FP8: per-channel weight scales, per-token activation scales), launched as python -m sglang.launch_server --model-path Qwen/Qwen3.5-4B --revision 851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a --attention-backend flashinfer --mm-attention-backend triton_attn --mem-fraction-static 0.25 --max-running-requests 16 --mamba-full-memory-ratio 2 --max-total-tokens 200000 --cuda-graph-max-bs-decode 32 --random-seed 0 --quantization fp8. With the sm_90a-only library the server started and did not print the line (two launches). It scores 0.830 on GSM8K (first 200 test questions, 5-shot, sglang.test.few_shot_gsm8k). With otherwise identical flags, BF16 scores 0.870 and the wheel's library with USE_TRITON_W8A8_FP8_KERNEL=1 (Triton FP8 GEMMs instead of CUTLASS) scores 0.845 and did not print the line either. With 200 questions this only shows that the FP8 server answers sensibly: the 95% intervals (Wilson) are about 10 points wide (0.77-0.88 for 0.830, 0.79-0.89 for 0.845, 0.82-0.91 for 0.870), so it is not a measure of FP8's accuracy.

Speed Tests and Profiling

Not measured: this changes which architectures are compiled, not the kernels.

Not tested

  • An x86_64 configure or build. There FA3 is on by default with CUDA >= 12.4, so the condition is the same as on main, and the FA3-on configure above gave identical flags. An x86_64 build with FA3 turned off by hand now gets sm_90a, as it did before Upgrade fa3 hash #28394.
  • A full aarch64 wheel. I did not compile the sm100 build or spatial_ops with sm_90a, or anything with all six gencodes, so the wheel size is not measured. For comparison, sm90/common_ops.abi3.so in 0.4.8 is 12.3 MB in the x86_64 wheel (six architectures including sm_90a), against 11.1 MB in the aarch64 wheel (five).
  • Build time. Both common_ops builds and spatial_ops compile one more architecture, and the wheel build (python/sglang/kernels/aot/Dockerfile) runs 2 parallel jobs on ARM. For scale, my builds of common_ops_sm90_build took 7 minutes (sm_90a only) and 8 minutes (sm_90 + sm_90a) on 16 cores.
  • Blackwell (GB200). Its loader picks the sm100 build, which now also carries sm_90a code that never loads there, as on x86_64.

CI States

Latest PR Test (Base): ❌ Run #37066240778
Latest PR Test (Extra): ❌ Run #37066240585
Latest PR Test (AMD ROCm 10): ❌ Run #37066240603

Since sgl-project#28394 the sm_90a gencode for common_ops is added only when FA3 is
enabled, and FA3 defaults to off on aarch64. The aarch64 wheels therefore
carry no sm_90a code, and on GH200 the SM90 CUTLASS kernels (fp8_scaled_mm,
int8_scaled_mm, the FP8 blockwise and W4A8 MoE GEMMs) run CUTLASS's
"Arch conditional MMA instruction used without targeting sm90a" stub.
Add sm_90a for CUDA >= 12.4 again, independent of FA3. Builds with FA3 on
(the x86_64 default) get the same flags as before.
SamMausberg added a commit to SamMausberg/verified-progress that referenced this pull request Oct 2, 2026
Row 0002 now says that common_ops in the inspected aarch64 wheel
(sglang-kernel 0.4.8) lacks sm_90a, as the posted
sgl-project/sglang#42263 body does, instead of saying all aarch64 wheels
carry none. Row 0001 names Qwen3.5-4B, lists the head dims checked, and
says sgl-project/sglang#35757 writes the ceil-divide as cute.ceil_div.
SamMausberg added a commit to SamMausberg/verified-progress that referenced this pull request Oct 3, 2026
…es and the upstream patches

BF16 (#222, evidence/bf16_paths): the served benchmark read both gross
positions as ill-conditioned in BF16. #222 supports that for a4db11ff/333
only. At 579ae7ce/439, the paper's 8.9-nat position, transformers in BF16
keeps FP32's top token in all 16 readings, FP32 under one-rounding noise
moves 1756 by at most 0.52 nats, and no single SGLang kernel swap removes
the miss: an SGLang outlier at a selected position, whose frequency the
unselected positions cannot compare with transformers'. The abstract and
§4.5 add "unlike transformers'"; App E.5, the served README (two places)
and a new notes subsection give the reading; register entry bf16-paths in
both registers.

Low-concurrency probes (#220, evidence/speed_lowc): one notes paragraph
(split-KV verify dropped by its rule; FA4's head-dim-256 compile failure
and backport; one-session served FA4 probes, exactness not classified;
fused GDN chain passed its rule but not built), H6, "What did not work",
register entry speed-lowc, and the missing index rows.

Upstream (#226): one notes paragraph and register entry upstream-patches
(the FA4 test as a comment on sgl-project/sglang#35757; the sgl-kernel
sm_90a build fix open as sgl-project/sglang#42263). The two FP8 lines say
the CUTLASS GEMM "fails" rather than "aborts", consistent with the engine
README.

Reviewer's optional item from #227: "calls of up to 30-64 positions" in
the abstract and §4.5 (largest certified calls at each point).

Paid for in §4.5's paragraph with no claim dropped; the main text still
ends at the foot of p10.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @SamMausberg. Closing this because you have 6 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs.

Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one.

Some directories moved recently, so an older branch may need retargeting:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

@github-actions github-actions Bot closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant