Skip to content

[FlyDSL] [gfx1250] Paged FP8 MQA logits with 8-token KV pages - #6863

Merged
yhl-amd merged 3 commits into
ROCm:mainfrom
yhl-amd:gfx1250-flydsl-paged-mqa-logits
Oct 24, 2026
Merged

yhl-amd merged 3 commits into
ROCm:mainfrom
yhl-amd:gfx1250-flydsl-paged-mqa-logits

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

DeepSeek-V4.1-Flash scores its FP8 index cache with paged MQA logits over 8-token KV pages. On gfx1250 the only implementation was the Triton/Gluon deepgemm_fp8_paged_mqa_logits, which rejects pages shorter than 16 tokens, and every existing FlyDSL MQA-logits kernel targets gfx942/gfx950 (MFMA). This adds a FlyDSL paged FP8 MQA logits kernel for gfx1250 so the V4.1 indexer runs without Triton/Gluon.

Changes

  • New aiter/ops/flydsl/kernels/mqa_logits/fp8_paged_mqa_logits_gfx1250.py, entry flydsl_fp8_paged_mqa_logits_gfx1250(q_fp8, kv_cache, weights, out_logits, context_lens, kv_indices, max_model_len, Preshuffle=True, KVBlockSize=8, *, next_n_lens=None, SplitKV=None, ...). Same arguments and semantics as deepgemm_fp8_paged_mqa_logits (Triton-only kwargs such as ChunkK / WavePerEU are accepted and ignored). It reads the same packed preshuffled cache: per page, KVB*D FP8 bytes shuffled with shuffle_weight(layout=(min(KVB,16),16)), then KVB fp32 scales. Cache writers need no change.
    • Wave32 WMMA 16x16x128 FP8. The preshuffled page bytes already match the WMMA operand layout, so each lane loads its token's key straight into registers (no LDS, no TDM).
    • Each lane looks up its own token's page, so one 16-token tile can span two 8-token pages. Page sizes 8/16/32/64/128/256 share the same address formula.
    • Q fragments and head weights are loaded once per workgroup and stay in registers. The head sum is relu(acc*scale)*w followed by one permlanex16.
    • The context is split across workgroups on 16-token tile boundaries, so no two splits write the same column. The default split count is derived from max_model_len (no host sync, graph-capture safe).
    • Caches of 2 GiB or more compile a 64-bit-offset variant; output row offsets are 64-bit.
  • aiter/ops/flydsl/kernels/mqa_logits/fp8_paged_mqa_logits.py: flydsl_fp8_paged_mqa_logits dispatches by arch (gfx1250 → new kernel, otherwise the existing gfx950 one).
  • aiter/ops/flydsl/__init__.py: the lazy export goes through the dispatcher; flydsl_fp8_paged_mqa_logits_gfx1250 is exported too.

Limits: D=128; H a multiple of 16; next_n ≤ 8 and next_n×H ≤ 256 (Q is held in registers); Preshuffle=True only.

Test

op_tests/test_flydsl_fp8_paged_mqa_logits.py now runs on gfx1250 as well (no separate test file). It compares against its torch fp32 reference and takes --kv-block-size: gfx1250 defaults to pages 8/16/64, gfx950 keeps 64. The tables below run over those page sizes, except probe1079:

  • compact decode/MTP (next_n 1/2/4/8), with Gluon as a second candidate where it supports the page size
  • ragged next_n_lens, including a long-context table
  • a 1M-wide output, whose row offsets pass the i32 boundary
  • probe1079, on its fixed scattered 64-token pool
  • a new gfx1250 table whose KV pool passes 2 GiB, for the 64-bit cache-offset path

All tables pass on gfx1250. black and ruff are clean.

End to end, together with the companion mxfp8_32 GEMM PR and the ATOM change, DeepSeek-V4.1-Flash TP4 on gfx1250 scores the same on GSM8K (3-shot, full set) as with the Triton path.

🤖 Generated with Claude Code

@yhl-amd
yhl-amd requested review from a team and valarLip October 23, 2026 08:33
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6863 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Add a gfx1250 WMMA kernel for the paged FP8 MQA logits that DeepSeek-V4.1's
indexer scores with, reading the same packed preshuffled cache as
deepgemm_fp8_paged_mqa_logits(Preshuffle=True): KVBlockSize * 128 FP8 bytes
shuffled with shuffle_weight(kv, layout=(min(KVBlockSize, 16), 16)), then the
fp32 scales. Pages of 8 to 256 tokens, any 16-multiple head count, next_n up
to 8, context_lens [B] or [B, next_n], optional next_n_lens.

That shuffle already is the wave32 WMMA 16x16x128 FP8 operand layout, so each
lane loads its key column with four 16-byte loads into registers; a 16-token
tile can mix pages, an 8-token page being lanes 0-7 and 8-15 of a tile. Q and
the head weights stay in registers, heads are the WMMA M side, and the head
sum is eight in-lane FMAs and one permlanex16. Sequences split on 16-token
tile boundaries, so splits never write the same column. A two-stage register
pipeline keeps the next step's keys and the page-table entries three steps
ahead in flight. Caches past 2 GiB compile a 64-bit global-load variant.

flydsl_fp8_paged_mqa_logits now dispatches by architecture.

Tests: op_tests/test_flydsl_fp8_paged_mqa_logits.py runs on gfx1250 too, over
page sizes 8/16/64 (--kv-block-size; gfx950 keeps 64) in every table, with a
gfx1250 table whose KV pool passes 2 GiB for the 64-bit cache path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
yhl-amd and others added 2 commits October 23, 2026 20:48
- fp8_paged_mqa_logits: import only the running arch's kernel module
- gfx1250 kernel: require 16-byte aligned q_fp8 / weights base pointers
- test: wide_out keeps kv_len 64 for every page size

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants