Skip to content

Commit 9420e49

Browse files
docs(adr-0015): reframe north star — product-grade engine to REPLACE vLLM, Kakeya Attention native
Per direction: ADR 0015's prior 'add chunked-prefill+paged+CUDA-graph' roadmap read as copying vLLM and treated the research bench as the measuring stick. Both wrong. New highest goal recorded in ADR: the Kakeya Inference Engine is a product-grade engine whose goal is to REPLACE vLLM, with Kakeya Attention as its native first-class algorithm. The engine is bounded-KV-native (full history never resident; admission by peak window; restoration fused into prefill/decode), NOT a port of vLLM's full-KV pipeline. The eager-transformers bench is a feasibility probe only, never reported as 'Kakeya performance'. README + reports aligned. Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
1 parent 520b54b commit 9420e49

4 files changed

Lines changed: 117 additions & 100 deletions

File tree

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,19 @@ restoration compute (a proposer forward), quantified below (recall 1.0;
175175
~AR-parity / 1.79–2.06× on CUDA; ~4× more concurrent agents per GB,
176176
[ADR 0014 §3.4](docs/adr/0014-agent-connection-capacity-and-cross-host-topology-tests.md)).
177177

178-
**Engine substrate (target).** Kakeya Attention is the algorithm; the
179-
**Kakeya Inference Engine** combines it with **CUDA graphs + fused-MoE kernels**
180-
to compete with vLLM on absolute throughput. This substrate is a **build target**
181-
([ADR 0015](docs/adr/0015-kakeya-attention-and-engine-substrate.md)): today's
182-
research path runs the algorithm on an **eager HF-transformers** substrate, which
183-
is correct and recall-preserving but ~8–14× slower than vLLM and OOMs on long
184-
prefills — see [the same-H200 comparison](docs/reports/kakeya-vs-vllm-multitenant-h200.md).
178+
**North star — a product-grade engine that replaces vLLM.** Kakeya Attention is
179+
the native algorithm of a **product-grade inference engine whose goal is to
180+
replace vLLM** — not a technique bolted onto HuggingFace transformers, and not
181+
"vLLM with a different cache". The engine is designed **bounded-KV-native**: the
182+
full history is never resident, admission/scheduling sizes sessions by their
183+
**peak window** (not total tokens), and restoration is fused into prefill/decode.
184+
Graph-captured decode, fused-MoE and efficient masking are table stakes built *in
185+
service of* that design, not a port of vLLM's full-KV pipeline
186+
([ADR 0015](docs/adr/0015-kakeya-attention-and-engine-substrate.md)). The
187+
eager-transformers numbers in the comparison reports are **feasibility probes**,
188+
not "Kakeya performance"; the vLLM-beating demonstration runs on a
189+
**full-attention** verifier, where restoration is load-bearing (on gemma-4 its
190+
native sliding window already bounds 25/30 layers, so it is not the showcase).
185191

186192
**Where the bounded-KV win is large (and where it isn't).** The advantage scales
187193
with the model's **full-attention fraction**. On **gemma-4-26B-A4B** only 5 of 30
Lines changed: 90 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,108 @@
1-
# ADR 0015 — Kakeya Attention as an attention algorithm + engine substrate roadmap
1+
# ADR 0015 — Kakeya Inference Engine: a product-grade vLLM replacement, Kakeya Attention native
22

3-
- Status: Accepted (definition); substrate = roadmap
4-
- Date: 2026-06-15
3+
- Status: Accepted (north star + algorithm definition); engine = in design
4+
- Date: 2026-06-15 (rev. 2026-06-15)
55
- Supersedes/extends: the "Kakeya Attention vs PagedAttention/RadixAttention"
6-
framing in README and ADR 0014 §3.4 (MLX serial-only / CUDA batched).
6+
framing in README; ADR 0014 §3.4.
7+
8+
## North star (highest goal — this governs everything below)
9+
10+
The **Kakeya Inference Engine is a product-grade inference engine whose goal is
11+
to replace vLLM.** It is **not** a research script, **not** a technique bolted
12+
onto HuggingFace transformers, and **not** "vLLM with a different cache". Its
13+
**native, first-class attention algorithm is Kakeya Attention** — sink+window
14+
bound + f_θ KV-projection + dLLM-proposer restoration, as **one primitive**. The
15+
whole engine (prefill, KV management, admission/scheduling, kernels) is designed
16+
**around bounded-KV + on-demand restoration as the default invariant**, exactly
17+
the way vLLM is designed around full-KV PagedAttention.
18+
19+
Everything else in this ADR serves that objective. Explicitly:
20+
21+
- The product target is measured against vLLM by the **engine**, never by the
22+
research bench. The bench (`k3_cuda_multitenant_parallel_bench.py`, eager HF
23+
transformers) is **only a correctness/feasibility probe** and is not a thing we
24+
ship or benchmark as "Kakeya".
25+
- "Parity → win" with vLLM is an engine deliverable, not a roadmap of vLLM
26+
features to copy.
27+
28+
## Why "borrow vLLM's pipeline" is the wrong plan (rejected)
29+
30+
vLLM's architecture is **full-KV-centric**: paged blocks store the *whole*
31+
history; chunked prefill and flash masking are optimizations for *processing and
32+
storing the full KV*. Porting Kakeya's bounded cache onto that pipeline inherits
33+
a full-KV-shaped engine and caps the advantage at whatever the cache layout
34+
saves — i.e. it makes Kakeya a vLLM feature, not a replacement.
35+
36+
A product Kakeya engine instead makes **bounded-KV the native invariant**:
37+
38+
- the **full history is never resident**; evicted context is reconstructed by
39+
the proposer on demand (Kakeya Attention);
40+
- **prefill** produces the bounded resident set **+** the restoration path in one
41+
pass — it must never materialize the O(N·T²) attention mask or full-vocab
42+
logits that sink the research bench;
43+
- **admission/scheduling** sizes sessions by their **peak window**, not their
44+
total token count — this is the structural source of the concurrency win;
45+
- graph-captured decode, fused-MoE, efficient masking are **table stakes** any
46+
product engine needs, implemented *in service of* the Kakeya-native design —
47+
not as a port of vLLM's full-KV pipeline.
48+
49+
## Kakeya Attention — the native algorithm
50+
51+
**Kakeya Attention** = sink+window bound + f_θ KV-projection + dLLM-proposer
52+
restoration, taken as one primitive. Peer of, and replacement for, the attention
53+
layer in current engines:
754

8-
## Context
55+
| Algorithm | Replaces | Keeps full KV? |
56+
| --- | --- | --- |
57+
| eager / **FlashAttention** | the **compute** layer | yes |
58+
| vLLM **PagedAttention** / SGLang **RadixAttention** | the **storage** layer | yes |
59+
| **Kakeya Attention** | **compute + storage** | **no — bounded; evicted KV reconstructed on demand** |
960

10-
Kakeya's KV-restoration work (AR verifier + dLLM proposer + f_θ + S5 sink/window)
11-
has been described as a *technique inside* the engine. A same-H200 benchmark vs
12-
vLLM (`docs/reports/kakeya-vs-vllm-multitenant-h200.md`) and a long-context probe
13-
(`docs/reports/kakeya-vs-vllm-longcontext-h200.md`) forced two clarifications:
61+
FlashAttention makes attention compute cheaper; Paged/Radix make the same *total*
62+
KV cheaper to allocate/share. **Kakeya Attention makes the total itself bounded.**
1463

15-
1. The throughput gap to vLLM (~8–14×) is a **substrate** gap (eager HF
16-
transformers decode loop, O(T²) eager prefill), **not** an algorithmic one.
17-
2. The bounded-KV memory advantage is **architecture-dependent** and is a
18-
**decode-time** property that the eager prefill currently masks (OOM at 32k).
64+
## Where the win is real (model architecture matters)
1965

20-
This ADR fixes the vocabulary and the roadmap.
66+
Resident KV is dominated by the **full-attention** layers (they hold full context
67+
in any engine). So the engine's advantage over vLLM scales with the model's
68+
full-attention fraction:
2169

22-
## Decision
70+
- **gemma-4-26B-A4B** is 25/30 **natively sliding** → vLLM already bounds those
71+
layers, and gemma-4 keeps recall 1.0 at `sliding_window=68` *with no
72+
restoration at all***no Kakeya moat on gemma-4** (probed; see below). It is
73+
the wrong showcase model.
74+
- **Full-attention models** (Qwen/Llama, no native sliding): shrinking the window
75+
without restoration **destroys recall**, so f_θ+proposer restoration is the
76+
*only* way to bound memory at full recall — and vLLM, having no restoration,
77+
**must keep full KV and cannot match it**. This is the engine's target regime.
2378

24-
### 1. Kakeya Attention is a first-class attention algorithm
79+
## Feasibility probes so far (informed the design — NOT the product)
2580

26-
Define **Kakeya Attention** = **sink+window bound + f_θ KV-projection +
27-
dLLM-proposer restoration, as one primitive**. It is a peer of, and a drop-in
28-
replacement for, the attention layer in current engines:
81+
These ran on the eager-transformers research bench; they validate correctness and
82+
locate the engine's required invariants. They are not the product engine.
2983

30-
| Algorithm | Replaces | Keeps full KV? |
31-
| --- | --- | --- |
32-
| eager / **FlashAttention** | the **compute** layer | yes |
33-
| vLLM **PagedAttention** / SGLang **RadixAttention** | the **storage** layer | yes |
34-
| **Kakeya Attention** | **compute + storage** | **no — bounded; evicted KV reconstructed on demand** |
84+
- **Restoration prefill, memory-efficient (SDPA + chunked logits + bf16 K/V)**
85+
unblocked long-context execution at recall 1.0 (16k N=1-only→N=4, 32k OOM→N=2,
86+
62k OOM→N=1). Confirms the engine must avoid O(N·T²) masks / full-vocab logits.
87+
- **gemma-4 bounded decode** — recall 1.0 at `sliding_window=68` natively (no
88+
restoration); native bounded decode still fits only N=2 @62k vs vLLM's 15.5
89+
because the bench does non-chunked prefill. Confirms (a) gemma-4 is the wrong
90+
showcase, (b) the engine — not bench retrofits — is what must beat vLLM.
3591

36-
FlashAttention makes attention compute cheaper; Paged/Radix make the same *total*
37-
KV cheaper to allocate/share. **Kakeya Attention makes the total itself bounded**,
38-
and is **composable** with all of them (a flash kernel can compute a Kakeya
39-
window; a paged/radix store can hold it).
40-
41-
### 2. The engine substrate is Kakeya Attention + CUDA graphs + fused MoE
42-
43-
The **Kakeya Inference Engine** = Kakeya Attention on a production substrate
44-
(**CUDA graphs + fused-MoE kernels + memory-efficient prefill**), targeting vLLM
45-
on absolute throughput. This is a **build target**, not yet shipped. The current
46-
research path runs the algorithm on **eager HF transformers**, which is correct
47-
and recall-preserving but (a) ~8–14× slower than vLLM at ctx-1238 and (b) OOMs on
48-
long prefills (N=1-only at 16k, OOM at 32k) due to O(T²) eager scores +
49-
full-vocab logits + a redundant `capture_verifier_own_kv` forward.
50-
51-
**Substrate work items (ordered):**
52-
1.**Memory-efficient restoration prefill** — patched forward routes to
53-
**SDPA** (`--attn-impl sdpa`), LM-head logits chunked (`logits_to_keep=1` on
54-
the restored forward + `capture_verifier_own_kv`), restored K/V held in bf16.
55-
**Unblocked long context** (recall 1.0): 16k went N=1-only→N=4, 32k OOM→N=2,
56-
62k OOM→N=1; 16k N=1 peak 138.8→74.5 GB. (`docs/reports/kakeya-vs-vllm-longcontext-h200.md`.)
57-
2. **Bounded decode cache as the native KV layout** — resident sink+window +
58-
5 exact full-attention layers; no Python per-step `DynamicCache`. **Probed on
59-
gemma-4 and found NOT to beat vLLM there (by architecture):** (a) gemma-4
60-
keeps recall 1.0 at `sliding_window=68` *natively, with no restoration* (5/30
61-
full-attn layers carry recall) — so bounded decode is just a native window
62-
shrink that vLLM can match; (b) even native bounded decode fits only N=2 @62k
63-
vs vLLM's 15.5, because the bottleneck is **non-chunked prefill activations**,
64-
not the KV bound — vLLM wins on **chunked-prefill + paged-KV engineering**.
65-
**Conclusion: the Kakeya bounded-KV win must be demonstrated on a
66-
full-attention model** (Qwen/Llama), where shrinking the window without
67-
restoration destroys recall and only f_θ+proposer restoration bounds memory at
68-
full recall — vLLM, lacking restoration, must keep full KV.
69-
(`docs/reports/kakeya-vs-vllm-longcontext-h200.md` Update 2.)
70-
3. **CUDA graphs** for the decode step; **fused-MoE** kernels for the verifier.
71-
4. (Optional) integrate Kakeya Attention as a **vLLM attention backend** so the
72-
bounded window rides vLLM's paged store + scheduler.
73-
74-
### 3. The bounded-KV win is architecture-dependent
75-
76-
Resident KV is dominated by the **full-attention** layers (they hold full
77-
context in any engine). gemma-4-26B-A4B is 25/30 **natively sliding** → vLLM
78-
already bounds 25 layers → Kakeya's resident-KV edge is **~7 % at 62k**. On a
79-
**full-attention** model (no native sliding) the edge is **~**. Long-context
80-
concurrency "sweet spots" must be claimed **per model architecture**, not
81-
universally. (Consistent with the recorded "S5 free-lunch" caveat: on gemma-4 the
82-
5-exact-layer S5 shortcut already covers recall, so the proposer/f_θ restoration
83-
is *replaced* by S5 on this model.)
92+
(`docs/reports/kakeya-vs-vllm-longcontext-h200.md`.)
8493

8594
## Consequences
8695

87-
- README and docs now present Kakeya Attention as an algorithm peer to
88-
Flash/Paged/Radix, with the substrate explicitly a roadmap.
89-
- Throughput parity with vLLM is gated on the substrate work items above, not on
90-
the algorithm.
91-
- Memory/sweet-spot claims are scoped by full-attention fraction; the strong
92-
long-context demonstration should be run on a full-attention verifier.
96+
- The repo's highest engineering goal is the **product Kakeya Inference Engine
97+
replacing vLLM**, with Kakeya Attention as its native algorithm; the eager
98+
research bench is a probe only and is never reported as "Kakeya performance".
99+
- The engine is designed bounded-KV-native (admission by peak window; restoration
100+
fused into prefill/decode), not as a port of vLLM's full-KV pipeline.
101+
- The vLLM-beating demonstration is to be run on a **full-attention** verifier,
102+
where restoration is load-bearing.
93103

94104
## Evidence
95105

96106
- `docs/reports/kakeya-vs-vllm-multitenant-h200.md` (ctx-1238, same H200)
97-
- `docs/reports/kakeya-vs-vllm-longcontext-h200.md` (16k–62k, OOM ceiling + KV model)
98-
- `results/research/{k3_cuda_multitenant_parallel,vllm_multitenant_parallel}_h200nvl_*.json`
107+
- `docs/reports/kakeya-vs-vllm-longcontext-h200.md` (16k–62k probes + KV model)
108+
- `results/research/{k3_cuda_multitenant_parallel,vllm_multitenant_parallel,gemma_bounded_decode}_h200nvl_*.{json,log}`

docs/adr/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ reader what was *not* chosen.
4141
| 0007 | [Cross-request KV cache reuse for long sessions](0007-cross-request-kv-reuse.md) | Superseded by 0008 |
4242
| 0008 | [Session-bound runtime + gRPC protocol](0008-session-bound-runtime-and-grpc-protocol.md) | Accepted |
4343
| 0014 | [Agent-connection capacity & cross-host proposer/verifier topology: test plan & results](0014-agent-connection-capacity-and-cross-host-topology-tests.md) | Accepted |
44-
| 0015 | [Kakeya Attention as an attention algorithm + engine substrate roadmap](0015-kakeya-attention-and-engine-substrate.md) | Accepted |
44+
| 0015 | [Kakeya Inference Engine: a product-grade vLLM replacement, Kakeya Attention native](0015-kakeya-attention-and-engine-substrate.md) | Accepted |
4545

4646
Note: ADR numbering is monotonically increasing; in-flight or
4747
planned numbers (0005) appear in the index so readers can

docs/reports/kakeya-vs-vllm-longcontext-h200.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,14 @@ patched forward routes to `all_attention_functions["sdpa"]`) + **chunked logits*
9191
(16k N=1 peak dropped 138.8 → 74.5 GB.) This is the item-#1 win: the restoration
9292
prefill now executes at 32k/62k where eager could not.
9393

94-
**Remaining bottleneck (→ items #2–3).** Per-session memory still grows
95-
~linearly with context (~17 GB/session @16k, ~37 GB @32k) because **this bench
96-
captures the full-T K/V into the decode cache** and holds the f_θ projection
97-
intermediates — i.e. it does **not** yet exercise the *bounded* resident cache
98-
(SinkWindowKVCache). So the restored path here is still effectively full-KV at
99-
decode; beating vLLM's **15.5-way** 62k concurrency requires item #2 (bounded
100-
native decode cache: store only sink+window + 5 exact layers, restore on demand)
101-
+ freeing the f_θ intermediates. Item #1 was the prerequisite (it makes long
102-
prefills run at all); the concurrency-ceiling win is gated on #2.
94+
**Remaining bottleneck (this is a bench probe, not the engine).** Per-session
95+
memory still grows ~linearly with context (~17 GB/session @16k, ~37 GB @32k)
96+
because **this research bench captures the full-T K/V into the decode cache** and
97+
holds the f_θ projection intermediates — it does **not** exercise a bounded
98+
resident cache. That is precisely what the **product-grade Kakeya Inference
99+
Engine** (ADR 0015) owns natively: bounded-KV as the resident layout (sink+window
100+
+ 5 exact layers, restore on demand), admission by peak window, restoration fused
101+
into prefill/decode — none of which a transformers research bench provides.
103102

104103
Evidence: `results/research/k3_cuda_mt_longctx_sdpa_ceiling_h200nvl.log`.
105104

@@ -136,9 +135,11 @@ engineering the research bench lacks.
136135
(a) there is no algorithmic lever — vLLM already exploits gemma-4's native hybrid
137136
attention and can shrink the window too; (b) vLLM's long-context concurrency is
138137
**prefill/KV engineering** (chunked prefill, paged KV, CUDA graphs, fused MoE),
139-
not the resident-KV bound. Matching it needs that engine substrate (ADR 0015
140-
items #2–4, essentially a vLLM-class build), which is orthogonal to the Kakeya
141-
algorithm. **The Kakeya advantage requires a full-attention model** (Qwen/Llama):
138+
not the resident-KV bound. Matching/beating it is the job of the **product-grade
139+
Kakeya Inference Engine** (ADR 0015) — a bounded-KV-native engine (admission by
140+
peak window, restoration fused into prefill/decode), **not** a port of vLLM's
141+
full-KV pipeline. **The Kakeya advantage requires a full-attention model**
142+
(Qwen/Llama):
142143
there, shrinking the window without restoration destroys recall, so f_θ+proposer
143144
restoration is the *only* way to bound memory at full recall — and vLLM, having
144145
no restoration, must keep full KV and cannot match it.

0 commit comments

Comments
 (0)