[2/N][KV-Cache Layout Refactor] Pack K/V into the content dim across attention backends - #44455
Merged
Merged
Conversation
This was referenced Jun 4, 2026
LucasWilkinson
force-pushed
the
lwilkinson/kv-layout/bucket-layers-refactor
branch
from
June 4, 2026 04:10
926981a to
d356e36
Compare
LucasWilkinson
force-pushed
the
lwilkinson/kv-layout/kv-content-pack
branch
from
June 4, 2026 04:10
6bf3d4c to
f8182a2
Compare
LucasWilkinson
force-pushed
the
lwilkinson/kv-layout/bucket-layers-refactor
branch
from
June 4, 2026 04:31
ff6bd5f to
cef469f
Compare
LucasWilkinson
force-pushed
the
lwilkinson/kv-layout/kv-content-pack
branch
4 times, most recently
from
June 4, 2026 16:54
189706e to
50f97c1
Compare
LucasWilkinson
marked this pull request as ready for review
June 4, 2026 18:14
LucasWilkinson
requested review from
AndreasKaratzas,
ApostaC,
WoosukKwon,
dllehr-amd,
mgoin,
orozery,
tdoublep,
tjtanaa and
tlrmchlsmth
as code owners
June 4, 2026 18:14
Use the actual KV-cache head stride when writing DiffKV packed K/V rows. The FlashAttention DiffKV path passes a transposed cache view for HND layouts, where head stride is block_size * content_size rather than content_size. Co-authored-by: Codex <codex@openai.com> Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
4 tasks
5 tasks
This was referenced Jul 17, 2026
2 tasks
4 tasks
Closed
7 tasks
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.
PR #42374 (first part of RFC #42082) has been split into 4 PRs:
#44454 [1/N][KV-Cache Layout Refactor] Refactor DSV4 KV cache config
-> #44455 [2/N][KV-Cache Layout Refactor] Pack K/V into the content dim across attention backends
#44456 [3/N][KV-Cache Layout Refactor] Standardize Mamba cache; drop
get_transfer_cache_regions#44458 [4/N][KV-Cache Layout Refactor] Standardize KV cache layout
Summary
Packs K and V into the content dimension across attention backends, changing the KV cache shape from
(num_blocks, 2, block_size, num_kv_heads, head_size)(separate leading K/V dim) to(num_blocks, num_kv_heads, block_size, 2*head_size). Backends recover K/V viakv_cache.transpose(1, 2).split(head_size, dim=-1). This removes the need forget_kv_cache_stride_order()in most paths and is a major diff reduction toward #42374.Stacked on top of #44454 (land that first)
Testing
Most backend paths require specific GPUs (ROCm, nvfp4/flashinfer); the submitter will run the relevant subset on appropriate hardware before merge.
AI assistance
This PR was prepared with AI assistance (Claude).