Repository navigation
fix: load fused-SWA batch_id_per_token as int32, not int64 - #3793
Merged
Merged
Conversation
The fused decode SWA scatter (added in #3776) hardcoded an int64 buffer_load for batch_id_per_token. The V4 decode producers are not uniformly int64 though: the MTP-draft path reuses the int32 cu_seqlens_q slice as the per-token batch id. Feeding that int32 tensor tripped the wrapper's "batch_id_per_token must be 1-D int64" check, so DeepSeek-V4-Pro MTP decode raised a TypeError before the first token — the server never came up and the accuracy job timed out. batch_id values are bounded by the batch size, far below 2^31, so int32 is always sufficient. Standardize on int32: the kernel loads batch_id at i32 width (dropping the trunc), the wrapper validates int32, the dummy is int32, and the smoke test now builds an int32 batch_id. Validated end-to-end: DeepSeek-V4-Pro MTP3 GSM8K (3-shot) flexible 0.9477 / strict 0.9484, above the 0.94 CI threshold; decode drained cleanly with no TypeError.
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the fused FlyDSL decode SWA scatter path in flydsl_qk_norm_rope_quant to treat batch_id_per_token as int32 (including kernel load width, Python-side validation, and test construction), fixing failures when callers provide an int32 batch-id tensor (e.g., MTP draft decode paths).
Changes:
- Switch
batch_id_per_tokenfrom int64→int32 in the FlyDSL kernel interface and load logic (removing the now-unneeded truncation). - Update the Python wrapper’s dtype validation and dummy argument allocation to int32.
- Update the kv-write smoke/unit test to build an int32
batch_id_per_token.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
aiter/ops/flydsl/kernels/qk_norm_rope_quant.py |
Changes SWA-scatter batch-id dtype contract to int32 in both kernel and wrapper validation/dummies. |
op_tests/test_flydsl_qk_norm_rope_quant.py |
Adjusts the kv-write test to provide int32 batch_id_per_token. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1098
to
+1101
| if state_slot_mapping.dim() != 1 or state_slot_mapping.dtype != torch.int32: | ||
| raise TypeError("state_slot_mapping must be 1-D int32") | ||
| if batch_id_per_token.dim() != 1 or batch_id_per_token.dtype != torch.int64: | ||
| raise TypeError("batch_id_per_token must be 1-D int64") | ||
| if batch_id_per_token.dim() != 1 or batch_id_per_token.dtype != torch.int32: | ||
| raise TypeError("batch_id_per_token must be 1-D int32") |
valarLip
added a commit
to ROCm/ATOM
that referenced
this pull request
Jun 18, 2026
The fused decode SWA scatter loads batch_id_per_token at int32 width (see ROCm/aiter#3793). The producers were int64, which raised "batch_id_per_token must be 1-D int64" on the V4-Pro MTP decode path (server failed to start -> accuracy job timed out). Make all batch_id_per_token producers int32: - v4_batch_id_per_token CpuGpuBuffer (model_runner path) int64 -> int32 - batch_id numpy sources (per-fwd + MTP draft) int64 -> int32 - sglang / vllm plugin bridge batch_id buffers + numpy sources -> int32 int32 indices are accepted by torch advanced-indexing (indexer meta) and by the triton kernels (tl.load is dtype-agnostic); the explicit .to(torch.int64) casts in csa_translate_pack / sglang remain and tolerate int32 input. batch_id values are bounded by batch size, far below 2^31. Validated end-to-end: DeepSeek-V4-Pro MTP3 GSM8K (3-shot) flexible 0.9477 / strict 0.9484, above the 0.94 CI threshold; decode drained cleanly with no TypeError.
valarLip
added a commit
to ROCm/ATOM
that referenced
this pull request
Jun 18, 2026
…1272) * feat: fuse V4 decode SWA cache-write into qk_norm_rope_maybe_quant Thread the SWA ring scatter through the qk_norm+rope bridge so the V4 decode path no longer launches a standalone swa_write per layer. When swa_kv is provided, the post-norm/rope KV row is written into swa_kv[slot, pos % cache_size, :] (slot = state_slot_mapping[ batch_id_per_token[t]]) inside the same kernel: - flydsl path: fuses the scatter into the qk_norm launch (no extra kernel, no [T, D] KV HBM round-trip), via the new swa_kv / state_slot_mapping / batch_id_per_token args on flydsl_qk_norm_rope_quant. - Triton fallback: emits the existing swa_write as a separate launch (driven by swa_cu_seqlens_q + state_slot_mapping) so both backends have identical side effects. deepseek_v4.py decode deletes its standalone swa_write call and passes the SWA args through the bridge instead; prefill is unchanged (still writes its in-chunk SWA tail via swa_write after sparse_attn). BF16 only. Requires the matching aiter change (ROCm/aiter#3776) for the flydsl fused-scatter kernel support. * ci: drop GLM-5-FP8 from benchmark matrix to stay under 256 cells The nightly atom-benchmark grid had grown to 264 fully-expanded matrix cells, exceeding GitHub Actions' hard limit of 256 configurations per job. Remove the GLM-5-FP8 benchmark variant (superseded by GLM-5.2-FP8, which is retained) and its workflow_dispatch checkbox (keeping it in sync with the catalog prefixes). Matrix now resolves to 250 cells. Accuracy validation (models_accuracy.json) and the dashboard color map are left unchanged — GLM-5-FP8 stays covered there. * fix: standardize V4 batch_id_per_token on int32 for fused SWA scatter The fused decode SWA scatter loads batch_id_per_token at int32 width (see ROCm/aiter#3793). The producers were int64, which raised "batch_id_per_token must be 1-D int64" on the V4-Pro MTP decode path (server failed to start -> accuracy job timed out). Make all batch_id_per_token producers int32: - v4_batch_id_per_token CpuGpuBuffer (model_runner path) int64 -> int32 - batch_id numpy sources (per-fwd + MTP draft) int64 -> int32 - sglang / vllm plugin bridge batch_id buffers + numpy sources -> int32 int32 indices are accepted by torch advanced-indexing (indexer meta) and by the triton kernels (tl.load is dtype-agnostic); the explicit .to(torch.int64) casts in csa_translate_pack / sglang remain and tolerate int32 input. batch_id values are bounded by batch size, far below 2^31. Validated end-to-end: DeepSeek-V4-Pro MTP3 GSM8K (3-shot) flexible 0.9477 / strict 0.9484, above the 0.94 CI threshold; decode drained cleanly with no TypeError.
valarLip
pushed a commit
that referenced
this pull request
Jun 19, 2026
#3804) * [FlyDSL] Port compress_attn kernels to gfx1250 (wave32) Port CSA and HCA fused_compress_attn kernels from wave64 (CDNA) to wave32 (RDNA4/gfx1250). Key changes: BLOCK_THREADS=32, VEC=16 for D=512, generalized load/store paths for >dwordx4, shuffle width=32, FP8 linear layout (no preshuffle), and extract_strided_slice API fix. Adds gfx1250 dispatch routing in existing entry points and a dedicated test file. Co-Authored-By: Claude Opus 4 <[email protected]> * [FlyDSL] Port qk_norm_rope_quant to gfx1250 (wave32) Wave32 variant of the fused RMSNorm + GPT-J RoPE + FP8 quant kernel for RDNA4/gfx1250. BLOCK_THREADS=32, VEC=16 for D=512, generalized load/store paths (2x dwordx4 split for VEC>8), FP8 packing via VEC/4 dwords, and butterfly shuffle width=32. BF16 mode verified on cmodel (H=16/64/128). Co-Authored-By: Claude Opus 4 <[email protected]> * [FlyDSL] Apply ruff format and lint fixes to gfx1250 kernels Co-Authored-By: Claude Opus 4 <[email protected]> * [FlyDSL] Fix black formatting for CI Co-Authored-By: Claude Opus 4 <[email protected]> * trigger CI re-run Co-Authored-By: Claude Opus 4 <[email protected]> * [FlyDSL] Port fused SWA kv_write scatter to gfx1250 qk_norm_rope_quant Add the fused SWA cache-write path (batch_id_per_token as int32 per upstream PR #3793) to the gfx1250 wave32 variant so the kernel can scatter post-norm/rope KV rows into swa_kv[slot, pos%cache, :] in the same launch, and fix the gfx1250 dispatch to forward the new params. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude Opus 4 <[email protected]>
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.
Summary
The fused decode SWA scatter added in #3776 hardcoded an int64
buffer_loadforbatch_id_per_token. But the V4 decode producers are not uniformly int64 — the MTP-draft decode path reuses the int32cu_seqlens_qslice as the per-token batch id. Feeding that int32 tensor tripped the wrapper'sbatch_id_per_token must be 1-D int64check, so DeepSeek-V4-Pro MTP decode raised aTypeErrorbefore the first token → server never came up → the accuracy job timed out.Fix
batch_idvalues are bounded by the batch size (≪ 2³¹), so int32 is always sufficient. Standardize on int32:batch_idat i32 width (drops the now-unneededtrunci)kv_writedummy is int32batch_idNo behavior change for the int64-free fast path; this only widens/realigns the SWA-scatter dtype contract.
Test plan
test_flydsl_qk_norm_rope_quant_kv_write(int32 batch_id) — bit-exact PASSswa_write, 24 configs (bs×mtp×pad) — allmax_diff=0TypeError