feat(qwen35): add paged-attention monolithic decode-only AR foundation#555
Open
Graffioh wants to merge 3 commits into
Open
feat(qwen35): add paged-attention monolithic decode-only AR foundation#555Graffioh wants to merge 3 commits into
Graffioh wants to merge 3 commits into
Conversation
Graffioh
force-pushed
the
codex/qwen36-paged-attention
branch
from
July 23, 2026 09:27
5f7b111 to
e5027ab
Compare
Graffioh
force-pushed
the
codex/qwen36-paged-attention
branch
from
July 23, 2026 10:16
e5027ab to
5ff3bf7
Compare
Graffioh
force-pushed
the
codex/qwen36-paged-attention
branch
5 times, most recently
from
July 24, 2026 10:12
51dda8f to
1a2e479
Compare
Graffioh
marked this pull request as ready for review
July 24, 2026 18:41
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 28 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Graffioh
force-pushed
the
codex/qwen36-paged-attention
branch
3 times, most recently
from
July 24, 2026 19:54
2a36448 to
f1851f9
Compare
Graffioh
commented
Jul 25, 2026
Comment on lines
-1858
to
-1859
| committed++; | ||
| cache_.cur_pos = committed; |
Contributor
Author
There was a problem hiding this comment.
the first emitted output token from prefill writes KV row only during the subsequent forward (that's right)
BUT here on the first decode step, we increment committed by 1, even though for cache we are still considering the first emitted token from prefill, leading to a gap of 1
was there a reason for this?
(in case this needs to be fixed also in other model's backend)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QwBCUqGbQV4LSm6qUkZS3H
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QwBCUqGbQV4LSm6qUkZS3H
Graffioh
force-pushed
the
codex/qwen36-paged-attention
branch
from
July 25, 2026 08:53
f1851f9 to
d91a8fe
Compare
Graffioh
force-pushed
the
codex/qwen36-paged-attention
branch
from
July 25, 2026 11:10
d91a8fe to
ab11bb8
Compare
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.
Summary
GGML_OP_PAGED_ATTNdecode op for D=256 GQA with F16, Q4_0, and Q8_0 K/V.--paged-attention(one CUDA or HIP device).Scope
Paged K/V is the memory-management foundation for heterogeneous 4–8-user serving. This PR establishes exact single-request Qwen integration and a multi-sequence GPU primitive first, following the block-table design in ggml-org/llama.cpp#21961.
HTTP integration stays one active sequence: Qwen3.6's Gated DeltaNet conv/SSM state is backend-global and the worker is run-to-completion. Sequence-indexed recurrent state, batched decode, and a continuous-batching scheduler are follow-up work. The benefit here is memory capacity and request-lifecycle flexibility; the benchmark below measures attention operations, not whole-model tokens/s.
Opt in with
--paged-attention. Unsupported combinations fail explicitly. Requests reaching--max-ctxfinish cleanly.Benchmark results
All runs use Qwen attention dims (
D=256,Hq=24,Hkv=4).Single metric throughout:
paged throughput ÷ contiguous throughput. Above 1.0x = paged faster; below 1.0x = paged slower. (Absolute times differ by GPU class, so only the within-GPU ratio is meaningful.)Uniform batches (identical context per sequence)
Both layouts hold the same K/V payload, so this isolates paged compute/layout overhead. Q4_0 K/V, 4K context, batches
n_seq = 1/2/4/8:Caveat: the HIP paged win largely reflects an optimization gap in GGML's native HIP
flash_attn_ext_vecbaseline, not an inherent advantage of paged addressing. Don't extrapolate it to whole-model serving throughput.Ragged 8-request workload (
128K + 7 × 8K, Q4_0 K/V)What this benchmark represents: this is a standalone synthetic multi-sequence kernel benchmark, not the current HTTP/Qwen execution path. It constructs the eight sequence lengths and their interleaved block table directly. This simulates the layout that a future multi-sequence allocator would produce after concurrent requests, but it does not use
PagedKvPooland does not demonstrate eight concurrent requests in the current server. The current end-to-end integration remains single-sequence (max_sequences = 1).The case models the intended mixed-context workload. Paging stores only live, block-rounded tokens (188,416) instead of padding every sequence to 128K (1,048,576 slots).
Attention step time, same metric on each GPU:
K/V capacity (backend-independent projection over Qwen3.6's 16 full-attention layers; excludes weights, activations, and recurrent state):
The benchmark allocates and measures one synthetic attention layer. The 16-layer values below are projections obtained by multiplying that measured K/V storage by Qwen3.6's 16 full-attention layers; they are not full-model allocations.
→ 5.57x less K/V (82.03% saving). On CUDA this costs +31% attention latency (0.76x throughput); on HIP the paged path is also faster because of the weak native baseline noted above. Either way, this is primarily a memory-capacity win, not a claim that paging makes attention faster.
Roadmap
ggml_paged_attn, block manager, CUDA/HIP integration, benchmarks.Validation
f1851f9: CUDA sm_86 and HIP gfx1151 passpaged_kv_pool,paged_attention, andpaged_attention_direct; default and explicit ragged (4096,2048,1024,512) benchmarks complete on both backends. HIP also buildsdflash_server.128K + 7 × 8Kruns completed on CUDA and HIP; full HIP matrix (F16/Q4_0/Q8_0 at 4K/16K/64K/128K, batches 1/2/4/8) completed withrocprofv3traces.git diff --checkpasses.