Repository navigation
Inkling 2: depth mix with wide blocks for decode and as rows, no copies of its columns - #142
Merged
Merged
Conversation
…blocks Assisted-by: Claude Opus 5.5
…tiguous rows The mix of a query was a column of [Q, n_embd, n_tokens] and every Q, K, V and controller input was a copy of it, also for the one query of the SWA layers. Now each mix is a row; the fused depth mix kernel writes either layout. Assisted-by: Claude Opus 5.5
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.
Inkling 2: the depth mix (attention over the block outputs, 120 launches per token) ran with one 256-thread block per (query, token), so a decode step had 1 to 4 blocks that each looped 9 times over 2304-wide rows twice: 15.7 us per launch. Its result was
[Q, n_embd, n_tokens], and every Q/K/V input and every loop controller message was aggml_contof one column of it, also for the single query of the SWA layers (3 identical copies per SWA layer pass).Change
inkling2.cu: 1024-thread blocks when there are at most one block per SM and rows of at least 2048 (decode).inkling2.cpp: the mix is computed asstates^T x scores->[n_embd, Q, n_tokens], so the mix of one query is a row per token; the rows are used as views, with a copy only when the rows of several tokens are apart (Q > 1 at T > 1). The fused kernel writes either layout (template flag), the matcher accepts both operand orders.test-backend-ops:DEPTH_MIXcases for the new layout.Results
RX 7900 XT (gfx1100), ROCm 10.1, Inkling-2-Mini-UD-IQ4_XS,
llama-bench -fa on, f16 KV, median of 5:Measured on a stack of the open Inkling 2 branches, each line adds one change (pairs in the same block of runs):
The loop controller prompt path alone gave +1.8% pp512 in the same comparison, so the row layout is about +1.4% pp512 and all of the +5.0% tg128. Kernel launches per decode token on the full stack: 1968 (master: 3035).
A first version of the row layout expanded only the scores early, which split the chain and lost the depth mix fusion (tg 58.1 -> 55.7); the result is now expanded right after the scores.
KL divergence against master (
llama-perplexity, 3 x 2048 tokens) on the stack: mean 0.0052 / PPL 3.5238 (master 3.5361), at the level of the flash attention change below it and of master-fa onvs-fa off(0.0053).test-backend-ops -o DEPTH_MIXon ROCm0: 30/30 passed.AI disclosure: written and measured with Claude Code on the hardware above.