Repository navigation
[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
Closed
SamMausberg wants to merge 1 commit into
SamMausberg wants to merge 1 commit into
Conversation
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
requested review from
BBuf,
FlamingoPg,
HaiShaw,
ispobock,
merrymercy and
yizhang2077
as code owners
October 2, 2026 21:20
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.
This was referenced Oct 2, 2026
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.
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On a GH200 (aarch64, sm_90), the SM90 CUTLASS GEMMs in the released
sglang-kernel0.4.8 aarch64 wheel compute nothing. Each call printsand 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 fp8wrote 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_opshas 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 forcommon_opsconditional 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.common_ops(both the sm90 and sm100 builds) and tospatial_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=1keeps 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_buildand 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 installedsgl_kernelpackage, in place ofsm90/common_ops.abi3.so.__CUDA_ARCH_FEAT_SM90_ALLgave 1 when built for both (in either gencode order) and 0 for sm_90 alone.--quantization fp8started 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 withUSE_TRITON_W8A8_FP8_KERNEL=1scores 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
sm100build orspatial_opswith sm_90a, so wheel size and build time are not measured.sm100build now also carries sm_90a code that never loads there, as on x86_64.Checklist
Full test details
Motivation
On a GH200 (sm_90, aarch64), the SM90 CUTLASS GEMMs in the released
sglang-kernel0.4.8 wheel compute nothing. Each call prints(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 tofp8_scaled_mm(L2194-L2207; shapes with a tuned Triton config are the exception).The aarch64 wheel's
common_opshas no sm_90a code:The x86_64 wheel of the same release has 35 sm_90a ELFs in both
sm90/andsm100/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 forcommon_opsbecame 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 whyflashmla_opsin 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 frombuild.ninja:common_ops(sm90 and sm100 builds),spatial_ops-DSGL_KERNEL_ENABLE_FA3=ON, the x86_64 default with CUDA >= 12.4), main and this PRAll four were configured on the same aarch64 machine.
The aarch64 wheel still ships the
sm90build that the loader picks on GH200, so GH200 is evidently meant to work. FA3 stays off on aarch64; only thecommon_opsgencode goes back to its condition before #28394.SGL_KERNEL_ENABLE_SM90Astays 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=1keeps 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 installedsgl_kernelpackage withsm90/common_ops.abi3.soreplaced by a build went first onPYTHONPATH; 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_ALLgave 0 when built for sm_90 alone, 1 for sm_90a alone, and 1 when built for both, in either gencode order.cuobjdump --list-elfon the builtsm90/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_mmandint8_scaled_mmcalls at N = 4096, K = 2560, M = 1, 16 and 256, against an FP32 reference. With the wheel's library,fp8_scaled_mmat 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/testsagainst 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_fp8_gemm.pytest_int8_gemm.pytest_fp8_blockwise_moe.pytest_es_fp8_blockwise_moe.pytest_cutlass_w4a8_moe_mm.pyThe 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 aspython -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 withUSE_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
sm100build orspatial_opswith sm_90a, or anything with all six gencodes, so the wheel size is not measured. For comparison,sm90/common_ops.abi3.soin 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).common_opsbuilds andspatial_opscompile one more architecture, and the wheel build (python/sglang/kernels/aot/Dockerfile) runs 2 parallel jobs on ARM. For scale, my builds ofcommon_ops_sm90_buildtook 7 minutes (sm_90a only) and 8 minutes (sm_90 + sm_90a) on 16 cores.sm100build, 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