Repository navigation
feat(inkling2): read fp8 / int8 per-token-head KV in the attention kernels - #962
Merged
Merged
Conversation
…rnels - prefill reads this chunk's K/V from k_extend / v_extend and the prefix from the cache, with the 3 q heads of a KV head packed into one 128-row tile; bf16 uses the same kernel - decode picks its split count per request at run time instead of a static count per batch - drop the quantized-KV refusal and the cache-only extend kernel
Masked prefix tiles read slot 0 for keys past the prefix without a mask, so a NaN in that slot turned whole output rows into NaN. - fill pool rows outside the slot list, row 0 among them, with NaN in the kernel tests - test several requests in one extend launch and a decode batch wide enough for two rounds of splits - round the window split cap down to a power of two - drop the native e4m3 branch the HIP-only path never takes; rename BITS to BIT_DECODE
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.
Serve Inkling 2 Mini with
--kv-cache-dtype fp8_per_token_headorint8_per_token_head(refused at startup since #957). Both attention kernels read the 8-bit cache, and prefill moves to a new kernel that bf16 uses too.Changes
_extend_attention_split_kernel): this chunk's K/V come as bf16 rows (k_extend/v_extend) and the prefix from the cache, as in the shared triton backend. One program covers 128 rows = 42 tokens x the 3 q heads of a KV head, so each K/V tile is loaded and decoded once per KV head. Key tiles far from the query rows skip the bias and the mask; tiles inside the bias extent skip the mask; only the edges are fully masked. 8-bit tiles are decoded once per CTA and reach the MMA through shared memory. Their scales are applied in powers of two, so no rounding is added. The cache-only extend kernel is removed.models/inkling2/attention.pypasses the KV format, the scales and the chunk's K/V rows.Kernel time (RTX PRO 6000 Blackwell, sm_120)
Ratio = kernel time / vLLM bf16 kernel time, measured in the same process; below 1 is faster. vLLM 49ab32c, its sm_12x Triton kernels: attention +
gate_sinkfor prefill, split attention + combine for decode; its fp8 KV is unit-scale e4m3. main = 42ccacd.Prefill, one request (T = chunk tokens, p = prefix), median of 3 runs:
main's extend kernel spills registers; it is faster at a 128K prefix on full layers (bf16 here 1.21x / 1.17x of main) and slower everywhere else.
Decode (B requests of ctx tokens each), one run:
The 4-request batch is slower than vLLM on main too: its 128K request runs alone after the short ones finish, on 16 splits of 32-key steps against vLLM's 23 splits of 128-key steps.
End to end (
ft serve --moe-strategy fused, median of 5; 128K: 3)--kv-cache-dtypeTests
RTX PRO 6000 (sm_120):
pytest tests/models/inkling2/test_kernels.py: 36 passed. Extend and decode for bf16 / fp8 / int8, full and window layers; one request with two bias row windows, three requests in one launch (prefix 0, a chunk shorter than one tile), and a decode batch wide enough for two rounds of splits. Pool rows outside the slot list, row 0 among them, hold NaN. WithFREETOKEN_FORCE_E4M3_EMU=1 -k fp8: 10 passed.FREETOKEN_INKLING2_MODEL=<checkpoint> pytest tests/models/inkling2: 43 passed.--regAllocOptLevel=2, real launch specializations). Only sm_120 was run.