Repository navigation
[KDA] Support BF16 recurrent state in the CuTeDSL MTP verify kernel - #41714
Open
milo-modal wants to merge 3 commits into
Open
milo-modal wants to merge 3 commits into
milo-modal wants to merge 3 commits into
Conversation
The fused CuTeDSL KDA MTP verify kernel only accepted FP32 recurrent state, so a BF16 SSM state pool silently fell back to the slower path. Load BF16 state and snapshots through cp.async, widen them to FP32 in registers, and round only the snapshot stores. The recurrence itself stays FP32. Bank-conflict padding is kept constant in bytes, and the alignment checks now require 16-byte slot offsets, which is what cp.async needs. Dispatch now accepts FP32 or BF16 state when the intermediate snapshot cache has the same dtype. The ReplaySSM parity tests run in both dtypes, and a new test checks that BF16 storage of a BF16-representable state gives outputs bitwise equal to FP32 storage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: James Liu <51351043+chromecast56@users.noreply.github.com>
3 of 5 tasks
milo-modal
marked this pull request as ready for review
September 29, 2026 21:15
milo-modal
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve,
hanming-lu,
hebiao064,
yizhang2077 and
yuan-luo
as code owners
September 29, 2026 21:16
Contributor
|
/tag-and-rerun-ci |
This was referenced Oct 3, 2026
This was referenced Oct 10, 2026
This branch has not been deployed
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
The fused CuTeDSL KDA MTP verify kernel (
python/sglang/kernels/ops/attention/kda_decode_mtp.py) only accepts FP32 recurrent state. With a BF16 SSM state pool (mamba_ssm_dtype=bfloat16),KDAAttnBackend._can_run_dspark_cutedsl_mtprejects the call, and target verify falls back to the slower Triton path.Modifications
kda_decode_mtp.py):cp.asynccopies 4 FP32 or 8 BF16 values per 128-bit transfer.intermediate_ssm) round to BF16.fused_kda_decode_mtp_dspark): accept FP32 or BF16 state. Checkcp.asyncalignment in bytes (16-byte slot stride and base pointer). Requireintermediate_ssmto be present, with the same dtype as the state, when the ReplaySSM ring is not used.kda_backend.py): take the fused path for FP32 or BF16 state when the intermediate snapshot cache has the same dtype; otherwise fall back as before.Accuracy Tests
Kernel level,
test/registered/kernels/ops/attention/test_kda_mtp_cutedsl_replayssm_ring.pyon B200 (SM100): 9/9 pass. On currentmain, the three BF16 cases fail and the six FP32 cases pass.test_cutedsl_bf16_state_matches_fp32_register_math_block8: with a BF16-representable initial state, BF16 storage produces output bitwise equal to FP32 storage, and BF16 snapshots equal the FP32 snapshots rounded to BF16. This shows the arithmetic stays FP32.Speed Tests and Profiling
One KDA target-verify layer on B200
main)BF16 state on the selected
nv_cutedslbackend is faster up to about 32 requests per verify step and slower from about 48. Unlike Triton, the CuTeDSL kernel gains little from halving the state size. For FP32 state, CuTeDSL is faster than Triton at every batch size measured (1–256), so FP32 behavior is unchanged. High-concurrency BF16 deployments can keep the previous behavior with--linear-attn-verify-backend triton. This PR honors the selected backend rather than silently falling back.Checklist
CI States
Latest PR Test (Base): ❌ Run #36767611565
Latest PR Test (Extra): ❌ Run #36767611149
Latest PR Test (AMD ROCm 10): ❌ Run #36767611801