Repository navigation
[FlyDSL] [gfx1250] Paged FP8 MQA logits with 8-token KV pages - #6863
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
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]>
72675e6 to
95fbad2
Compare
- 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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
aiter/ops/flydsl/kernels/mqa_logits/fp8_paged_mqa_logits_gfx1250.py, entryflydsl_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 asdeepgemm_fp8_paged_mqa_logits(Triton-only kwargs such asChunkK/WavePerEUare accepted and ignored). It reads the same packed preshuffled cache: per page,KVB*DFP8 bytes shuffled withshuffle_weight(layout=(min(KVB,16),16)), thenKVBfp32 scales. Cache writers need no change.relu(acc*scale)*wfollowed by onepermlanex16.max_model_len(no host sync, graph-capture safe).aiter/ops/flydsl/kernels/mqa_logits/fp8_paged_mqa_logits.py:flydsl_fp8_paged_mqa_logitsdispatches 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_gfx1250is exported too.Limits: D=128; H a multiple of 16; next_n ≤ 8 and next_n×H ≤ 256 (Q is held in registers);
Preshuffle=Trueonly.Test
op_tests/test_flydsl_fp8_paged_mqa_logits.pynow 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:next_n_lens, including a long-context tableAll 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