Skip to content

feat(cuda): host-RAM tier for Qwen3.8-27B prompt states (--ram-tier-gib), 126k window on a 32 GB R9700 - #106

Closed
jkuepker wants to merge 15 commits into
ashhart:mainfrom
jkuepker:rocm-r9700-ramtier
Closed

jkuepker wants to merge 15 commits into
ashhart:mainfrom
jkuepker:rocm-r9700-ramtier

Conversation

@jkuepker

@jkuepker jkuepker commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #100. This branch is stacked on it: review the last two commits (tools: bench_conversations and feat(cuda): host-RAM tier). The rest is #100's and drops out of this diff once it merges.

This adds --ram-tier-gib N, a host-RAM tier for Qwen3.8-27B's prompt states on the CUDA engine (NVIDIA and, with #100, ROCm). Conversations the GPU has no room for come back over PCIe instead of being prefilled again. On one stream the GPU then holds a single window-sized attention buffer, so the startup estimate fits a much larger window: a 32 GB R9700 serves 126,553 tokens instead of 32,768, or 221,382 with #100's --kv-dtype fp8.

Benchmarks

One AMD Radeon AI PRO R9700 (gfx1201, 32 GB) in a host with 62 GiB of RAM; pinned PCIe copies measured at 12.9 GiB/s each way. Same software and checkpoints as #100. Launch: tensorfold serve Vontra/Qwen3.8-27B-MLX-4bit, with and without --ram-tier-gib 24.

Repeat turns. tools/bench_conversations.py (added here): 8 conversations of 24,000 tokens served round-robin, 4 turns each, 32-token greedy replies, thinking off. Each later turn sends the conversation back with the reply and a short question. Tier and no-tier runs sent the same prompts turn for turn (replies feed the next turn).

Window Cold TTFT (median of 8) Repeat-turn TTFT (median of 24)
No tier 32,768 12.15 s 12.21 s
--ram-tier-gib 24 126,553 12.27 s 0.39 s
  • Without the tier, the GPU keeps about two conversations at 24k, so every round-robin turn is prefilled again.
  • A conversation still on the GPU resumes in 0.25 s either way. A switch adds the restore: 1.5 GiB of keys and values at 24k tokens, about 0.12 s over PCIe.
  • A first version pinned host memory in 16 MiB pieces as the tier grew. That ran at 1.5 GiB/s and put 1.2 s on each cold 24k turn (13.62 s cold, 0.67 s repeat). The budget is now pinned at startup in 1 GiB slabs: 5.4 s for 24 GiB.

Long prompts in the larger window. localeval's speed sweep (fresh-nonce prompts, 256 forced tokens, greedy, one rep):

Prompt TTFT Prefill Decode
4,088 2.0 s 1,999 tok/s 144.1 tok/s
16,657 8.4 s 1,995 tok/s 134.1 tok/s
68,885 43.5 s 1,584 tok/s 92.0 tok/s
103,926 77.1 s 1,348 tok/s 101.5 tok/s

Decode follows how many drafts a prompt accepts (one rep each; the 104k prompt accepted more than the 69k one). At long context it relies on #100's tree attention commits. On one fixed prompt a drafted round takes 40 ms at 3k tokens of context and 62 ms at 120k (#100 has the table); before them, the 16k, 69k and 104k rows decoded at 108, 57 and 33 tok/s.

The change

  • cuda/host_tier.py (new): HostTier, prompt states in fixed-size host chunks under a byte budget.
    • A state the prefix cache evicts or drops is copied on a side stream. The allocator keeps the source until the copy lands (record_stream), and later work that may overwrite those rows waits for it (fence).
    • A prompt that extends a host state further than anything on the GPU copies it back.
    • Copies are raw bytes: attention rows below pos, DeltaNet state, and the drafter snapshot. A restored state is the one that left.
  • Keys and values are stored once per token prefix. A cache entry's attention rows depend only on its token ids: entries are prefill states, and prefill bits don't depend on chunking. So segments are keyed by the ids they were computed for.
    • A state reuses the rows earlier states left on the host and copies only its new rows. A shorter state (a message start, the previous turn's end) copies none.
    • DeltaNet and drafter state, about 190 MiB, is copied per state.
    • Idle segments leave first when room is needed, least recently used, then whole states, oldest first.
  • One window buffer on one stream (qwen3_5/cuda/engine.py):
    • Every state uses one attention buffer of the window's size, allocated at startup.
    • Before another conversation takes it, the states on the GPU go to host RAM, longest first. A restore copies into that buffer.
    • gdn_geometry(one_kv=True) charges one buffer, not two retained prefixes, the current state and a growth copy.
    • "draft": false requests and misses take the buffer the same way.
  • With --parallel, the tier keeps evicted states for MultiDecoder. A restored state gets buffers of its own, and the window is the same as without the tier.
  • Startup: the budget is pinned in 1 GiB slabs, because the pinned allocator rounds sizes up to powers of two. If the host refuses more pinned memory, the rest is pageable, with one warning.
    • Refused: a budget above the host's available memory less a tenth (capacity.host_room()), --tp 2, GPUs on the host's memory (DGX Spark), families without the tier, and MLX (which has --spill-gib).
  • cuda/streams.py: PrefixCache removes entries through one hook (on_evict, unset without the tier), plus drop(ids) and clear().
  • Docs: a "Host-RAM tier" section in docs/recipes/qwen3.8-27b.md with these measurements; a README option row.

Checked

  • On the R9700, 135 GPU tests pass. They are the new tests/cuda/test_qwen27_ram_tier.py and tests/cuda/test_qwen27_window_buffer.py, plus the prompt-cache, multi-stream and DFlash2 block suites. Every restored state, every prefill ending on one, the first sampled logits and the replies are compared against fresh prefills and the serial reference, bit for bit. Covered:

    • round-robin conversations;
    • an entry whose shared buffer was overwritten while it sat on the host;
    • drafter snapshots;
    • "draft": false requests taking the window buffer;
    • conversations under a shared system prompt;
    • MultiDecoder restores;
    • pinned and pageable chunks.
  • On a Mac, 3,995 CPU tests pass (rebased with feat: Qwen3.8-27B on AMD GPUs (ROCm), measured on a Radeon AI PRO R9700 #100 on main 0.5.0). tests/test_cuda_host_tier.py runs the tier on CPU tensors, including:

    • prefix sharing, partial segments and diverging ids;
    • restores into given buffers;
    • the budget never exceeded over a long random run of puts and takes, each take checked byte for byte;
    • startup pinning.
      tests/test_cuda_build.py::test_the_lock_named_is_the_one_torch_waits_on fails on the Mac here and on main alike.
  • After the rebase on 0.5.0, on the R9700: the windows are unchanged (126,553 tokens, 221,382 with --kv-dtype fp8), and served replies drafted and with "draft": false are identical at 4,726 and 44,826 tokens in bf16 and fp8.

Not claimed

  • Not served on NVIDIA. The tier is backend-neutral torch code; its CPU tests and tests/cuda pass on a DGX Spark (GB10) with this branch, but it has only served on the R9700, and DGX Spark refuses the flag (the GPU shares host memory). capacity.py (host_room() factored out of available_bytes) and streams.py change code NVIDIA runs without the flag.
  • Not measured with --parallel. It is covered by one GPU test only.
  • Default window with the tier. Without --context, it is the largest the estimate fits, so a 32 GB card prefills up to 126k tokens.

🤖 Generated with Claude Code

@jkuepker
jkuepker force-pushed the rocm-r9700-ramtier branch 5 times, most recently from 0f9e5f4 to 83f1997 Compare September 29, 2026 21:00
jkuepker and others added 11 commits September 29, 2026 17:05
…round

The CUDA backend now runs under ROCm's PyTorch on one GPU for Qwen3.8-27B's MLX 4-bit checkpoint with DFlash2
drafts. Drafted replies equal serial ones and any prompt chunking gives the same bits, as on NVIDIA. Other
families, EXL3 packs and two ranks are refused at startup with a message.

- Build: extensions compile with hipcc for the GPU present (--offload-arch), nvcc flags mapped to clang's.
  DeltaNet kernels take ROCm's 64-bit shuffle mask and bf16 rounding.
- Decode matmul (qmm_rocm.cu): WMMA on 4-bit words repacked at load into 16-output tiles, persistent blocks,
  split-K reduced in-kernel by the last block, up to 32 rows per weight read; [gate|up], [z|b|a] and [k|v] fused
  as views. Row arithmetic never depends on the row count.
- Prompt matmul: NVIDIA's FP8 prompt arithmetic (prefill_glue's e4m3 rows, exact e4m3 codes, per-group scales)
  as a fixed-tile Triton e4m3 GEMM with grouped tile order.
- Attention and DeltaNet: 16-key attention tiles and ROCm schedules for the verify and prompt chains; buffer
  loads off (they read zeros for negative offsets from the attention base).
- Startup estimate counts the 4-bit drafter at its packed size (it counted fp32 and refused every window on 32 GB).
- Every backend: timing-only syncs in draft_decode run only when tracing; fused projection slices reach their
  kernels as strided views instead of copies; the drafter computes shared group sums, pointer tables and window
  updates once per round (~200 fewer launches a round).

Measured on a Radeon AI PRO R9700 (localeval speed sweep, greedy, thinking off): prompts 2,326 tok/s at 4k,
1,849 at 16k, 1,582 at 30k (marginal); decode 112 / 130 / 95 tok/s at 4k / 16k / 30k. The recipe's AMD section
has the setup, tuning variables and limits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
M5's fused SDPA takes head size 256 in flat memory, so the 128-row parts (and their evals) that bound memory on
M1-M4 are not needed there. On an M5 Max, 2,048 queries against 6k-32k keys: 1.38x the parts (41.4-41.9 against
28.6-30.8 TFLOPS). End to end the gain is within run-to-run noise: marginal prefill +1.6% at 16k and +5.7% at
32k (localeval speed sweep, 3 reps). tests/test_prompt_attention.py still pins the stock causal bits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A HIP flash attention kernel for ROCm prompts (attention_rocm.cu): a block per 16 query rows and KV head, a wave
per query head of the group sharing each 16-key K/V tile in shared memory. S^T = K Q^T puts a query's scores in
its lane pair, so its row max and sum take one shuffle and P is already the A operand of P V. Keys fold in 16-key
tiles by absolute position and a row is rescaled only by its own factor, so any chunking gives a row the same bits.
The Triton kernel stays for other head sizes and behind TF_ROCM_ATTN_KERNEL=triton.

On an R9700: 70.5 TFLOPS at 4k queries over 32k keys, against 48.9 for the Triton kernel. A 4,096-token chunk at
28k-32k context takes 2.41 s of GPU time instead of 2.89 (attention 0.72 s instead of 1.04). Served, marginal
prefill 1,974 tok/s at 16k (was 1,854) and 1,784 at 30k (was 1,577); cold 16k prompts 2,069 tok/s (was 1,971).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ROCm's unsorted top-k returns tied logits in a varying order and set, and the
tree policy breaks ties by position, so the same drafter context could propose
different trees. On ROCm the top 16 now go by value, then lower column.
Replies were unaffected (every draft is verified); proposals are now repeatable,
and test_blocks_of_several_streams_equal_their_own passes on the R9700.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tree_attention_rocm.cu replaces the Triton _shared and _tail kernels on ROCm
(the Triton merge stays). A block per committed 512-key chunk and KV head
stages each 16-key tile once for all of a window's (row, head) pairs, a wave
per 16 pairs; up to 64 chunks, four loader waves keep two tiles in flight
through a double buffer, past it every wave loads then folds (twice the blocks
fit). A row's tail chunk folds the same way, so a chunk read whole as
committed keys gets the bits a drafted row's tail gives it; compute waves and
loaders never change a pair's bits (a new test checks 1-8 waves, both
schedules). TF_ROCM_TREE_KERNEL=triton keeps the Triton kernels.

R9700, 12-row drafted rounds on a fixed prompt, WMMA against Triton:
40.4 / 40.5 ms at 3k, 43.0 / 43.0 at 16k, 44.4 / 47.8 at 38k,
51.9 / 63.3 at 77k, 61.7 / 75.2 at 120k tokens of context (decode 101
against 83 tok/s at 120k). Served greedy replies drafted and with
"draft": false were identical on 44,826- and 4,726-token prompts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e bits

attention_rocm.cu now holds both WMMA attention kernels (tree attention moves
in from tree_attention_rocm.cu; one extension). The prompt kernel shares the
tree kernel's 16-key fold and loader machinery: a block per 32 prompt rows (16
below 192 rows) and KV head, a compute wave per 16 rows and query head, and
four loader waves keeping the next tiles in flight through a double buffer.
Every row folds the same tiles in the same order, so its bits are the
committed kernel's (checked on all head groupings and layouts, 60 of 60) and
chunking still never changes them; a new test checks rows a block and loaders
for every head grouping against each other and float64.
TF_ROCM_ATTN_RB and TF_ROCM_ATTN_PIPE override the layout for tuning.

R9700, 24 query / 4 KV heads: 4,096 queries after 28,672 / 61,440 keys went
from 42.9 / 93.0 ms to 39.9 / 82.0 ms (about 78 TFLOPS); 1-57 queries after
24k keys from 1.8-1.9 to 1.3 ms. A 4,096-token prompt chunk at 64k / 96k
tokens of context: 3.35 -> 3.19 s and 4.19 -> 3.88 s (1,223 -> 1,285 and
977 -> 1,056 tok/s). Splitting head dims across wave pairs measured 66-72
TFLOPS before any exchange of scores, so this layout stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The drafter's window keeps up to 2,047 context keys, and its block attention
ran one program per KV head: 8 programs a call on a 64-CU R9700, 0.46 ms each,
2.3 ms a drafted round. On ROCm a program now takes one query head and 512
context keys (or the block's own keys), and a merge adds the parts in key
order: 0.27 ms a round. A stream's drafts stay independent of the streams
beside it; NVIDIA keeps the one-pass kernel.

R9700, 16k tokens of context, a code prompt: 43.0 -> 41.2 ms a round.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rget 64

On ROCm, prepare stacks a GDN layer's [qkv | z | b | a] and an attention
layer's [q | k | v] into one matmul each, the members kept as views (no
memory added); the forward reads qkv and [q | gate] as strided views, so
gdn_pre, attn_prep and gate_mul take their row strides (NVIDIA passes the
contiguous stride and runs as before). Prefill still calls the members.
The WMMA K split now aims for 64 blocks instead of 128: every 27B projection
read at 12 rows as fast or faster. Both change decode bits alike for every
row count, so drafted still equals serial.

R9700, 16k tokens of context, a code prompt, 12 verify rows: 41.2 -> 40.0 ms
a round (matmuls 30.3 -> 29.2 ms, launches 1,007 -> 943), 68.7 -> 71.6 tok/s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… stride

With the stacked [q | k | v] projection (0b469e7), [q | gate] rows are a view
with a wider row stride. attn_prep loaded a query's first values by that
stride but its rotary partner by the old contiguous one, so every verify
window row past the first got another row's partner: drafted replies could
differ from "draft": false ones and fewer drafts were accepted. A lone row
(serial decoding, a window's first row) was unaffected.

The glue test now reads every input as a slice of one stacked output, as the
forward does; it fails with the old line. On the R9700: served greedy replies
drafted and with "draft": false are identical again (4,726 and 28,676-token
prompts), and a code prompt went from 6.79 back to 7.92 tokens a round.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he bytes

Opt-in. Per token and KV head, the 256 values are stored as e4m3 codes of
x * 2^-e (e the smallest exponent putting the row's largest magnitude at or
under 448) followed by e: 272 bytes instead of 512 (cuda/kernels/kv8.py, one
Triton launch per layer call). The WMMA prompt and tree attention kernels
widen each packed row to bf16 while staging it in shared memory, so the tile
and every fold are those of bf16 caches holding the rounded values; a verify
window's own keys and values are rounded the same way before its attention.
Drafted still equals serial, and any chunking gives the same bits.

Quality, the same rounding on bf16 caches: localeval mmlu 0.860 -> 0.864
(228, noise), ifeval 0.900 -> 0.900 (60), judged core set 1.000 -> 0.990 (10);
next-token distributions after 4k/16k/32k tokens of code: top-1 kept
96.9/99.2/97.7%, mean KL 0.007-0.012. The packed caches give those logits
exactly. Speed on the R9700, a drafted round at 64k tokens of context:
48.7 -> 46.5 ms (tree attention 9.7 -> 7.3 ms); 40.1 -> 39.6 ms at 16k. The
startup estimate counts the smaller cache.

Refused on NVIDIA, with --tp 2, with the Triton attention kernels, and for
head sizes other than 256.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CUDA prompt kernel's Triton-bits test: on ROCm, prompt attention runs
attention_rocm.cu (head size 256) or _attend with ROCm's tiles, each with bits
of its own; the chunking test still runs. The MoE experts pack tests: those
kernels are NVIDIA's (ROCm serves Qwen3.8-27B only); the direct reader's own
tests run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jkuepker and others added 3 commits September 29, 2026 18:24
The groups layout and its lane matmul serve ROCm only; on NVIDIA the test
tried to build qmm_rocm.cu. Found running tests/cuda on a DGX Spark (GB10):
with it skipped, the branch passes everything main passes there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Prompt states the GPU prefix cache evicts or drops are copied to pinned host
RAM and copied back (bytes, so replies are a fresh prefill's) when a later
prompt extends one further than any state on the GPU.

- Keys and values are stored once per token prefix: a state reuses the rows
  earlier states left on the host and copies only its new ones.
- On one stream the GPU holds one window-sized attention buffer used by the
  conversation being served; the startup estimate charges one buffer, so a
  32 GB R9700 serves a 126,553-token window instead of 32,768.
- The budget is pinned at startup in 1 GiB slabs; startup refuses a budget
  above the host's available memory.

R9700, 8 conversations of 24,000 tokens round-robin: repeat-turn TTFT
12.21 s -> 0.39 s, cold 12.15 s -> 12.27 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n more

reserve() pinned slabs until the host refused, so under a pinned-memory cap
the tier held all of it and the decode path's per-round pin_memory() staging
(tree attention, GDN and drafter plans) had no room left. After a refusal it
now unpins at least one slab's worth of the last slabs and empties the host
cache; that part of the budget is pageable, as the rest already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ashhart

ashhart commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thank you, this is careful work: the side-stream copies with record_stream, per-prefix segments so a shorter state copies nothing, and the pinned slabs. Your R9700 numbers show what it buys on a 32 GB card: a 126,553-token window instead of 32,768, and repeat-turn TTFT from 12.2 s to 0.39 s.

It's stacked on #100, so it closes with it for the same reason: the 0.3.4.1 base. A host-RAM tier is something we want, especially for 24-32 GB cards. If you bring it back on top of a rebased #100 against 0.6.0, we'll check that a restored state equals a fresh prefill and measure it with --parallel on our Sparks the day it arrives.

@ashhart ashhart closed this Sep 30, 2026
@jkuepker

Copy link
Copy Markdown
Contributor Author

Pushed #106's review fixes to rocm-r9700-ramtier (c760b4b..7bed996, 8 commits; with 976c3b4 and c760b4b before them, 10 in all). They pass the host tests, but the GPU tests haven't run on them yet. 6037964 (a --parallel restore lands in the stream's own buffers) and 7bed996 (a restore into the one-stream window skips rows it already holds) are the two to check first against a fresh prefill. Thanks for taking the rebase.

@jkuepker

jkuepker commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Notes for the 0.6.1 rebase of #106, from reading 0.6.0 and the open PRs that touch the same code:

  1. The window part may no longer be needed. On one GPU, 0.6.0 already lets kept states give way to a live reply (KVRoom, gdn_geometry(evicts=True)), so admission counts one live window. That's what feat(cuda): host-RAM tier for Qwen3.8-27B prompt states (--ram-tier-gib), 126k window on a 32 GB R9700 #106's one-window buffer achieved (one_kv, window_ids, and moving every GPU state to RAM before a conversation switch). On 0.6.0 the tier probably only needs to catch what gets evicted: call on_evict from PrefixCache._drop, which both eviction paths go through (add() past keep, and KVRoom's evict()).
  2. perf(cuda): past --checkpoint-slots, a kept state its conversation has moved past goes first #190 makes _drop evict states their conversation has moved past first. If both land, the tier would copy each of those to host RAM, about 190 MiB of DeltaNet and drafter state apiece, for states that are rarely resumed. Skipping the entries _moved_past flags would avoid that.
  3. Let users size the CUDA memory budget with TENSORFOLD_MEMORY_RESERVE_GIB and TENSORFOLD_CUDA_MEMORY_LIMIT_GB #165 and CUDA admission: bound the host by streaming needs, not checkpoint residency #150 both rewrite available_bytes. The tier's startup check (refuse_ram_tier → host_room) should use the same host-memory figure admission ends up with, or the two will disagree about how much RAM is free (as with TENSORFOLD_MEMORY_RESERVE_GIB, see feat(cuda): TENSORFOLD_MEMORY_RESERVE_GIB sets what the startup budget leaves free #133).
  4. feat(vision): --vision-offload keeps the CUDA image tower in host RAM between images #187 (--vision-offload) keeps the image tower in host RAM. In feat(cuda): host-RAM tier for Qwen3.8-27B prompt states (--ram-tier-gib), 126k window on a 32 GB R9700 #106's engine the tier pins its budget after the tower is placed, and its startup check doesn't count the tower, so with both flags the check should subtract the tower's bytes.

Happy to re-measure whichever shape lands on the R9700.

millaguie added a commit to millaguie/TensorFold that referenced this pull request Oct 3, 2026
…ib), ported onto 0.6.x

jkuepker's tier (ashhart#106, branch rocm-r9700-ramtier): prompt states the GPU prefix cache lets go are
copied to pinned host RAM on a side stream, keys and values stored once per token prefix, and copied back when a
later prompt extends one further than any state on the GPU, so a returning conversation skips its prefill.

Ported without his one-window attention buffer, as he suggested for 0.6: KVRoom already admits one live window, so
the tier only catches what PrefixCache lets go (its _leave hook, through add, evict, drop and clear). host_tier.py,
its CPU tests and tools/bench_conversations.py come over as he wrote them; the three tests of the window buffer are
skipped. The concurrent decoder takes the tier too (its cache evicts into it; an admitted stream resumes from it).

Claude-Session: https://claude.ai/code/session_0177FjqB2W7svyUf7deveRJg
millaguie added a commit to millaguie/TensorFold that referenced this pull request Oct 4, 2026
…ib), ported onto 0.6.x

jkuepker's tier (ashhart#106, branch rocm-r9700-ramtier): prompt states the GPU prefix cache lets go are
copied to pinned host RAM on a side stream, keys and values stored once per token prefix, and copied back when a
later prompt extends one further than any state on the GPU, so a returning conversation skips its prefill.

Ported without his one-window attention buffer, as he suggested for 0.6: KVRoom already admits one live window, so
the tier only catches what PrefixCache lets go (its _leave hook, through add, evict, drop and clear). host_tier.py,
its CPU tests and tools/bench_conversations.py come over as he wrote them; the three tests of the window buffer are
skipped. The concurrent decoder takes the tier too (its cache evicts into it; an admitted stream resumes from it).

Claude-Session: https://claude.ai/code/session_0177FjqB2W7svyUf7deveRJg
Co-authored-by: jkuepker <[email protected]>
millaguie added a commit to millaguie/TensorFold that referenced this pull request Oct 10, 2026
…ib), ported onto 0.6.x

jkuepker's tier (ashhart#106, branch rocm-r9700-ramtier): prompt states the GPU prefix cache lets go are
copied to pinned host RAM on a side stream, keys and values stored once per token prefix, and copied back when a
later prompt extends one further than any state on the GPU, so a returning conversation skips its prefill.

Ported without his one-window attention buffer, as he suggested for 0.6: KVRoom already admits one live window, so
the tier only catches what PrefixCache lets go (its _leave hook, through add, evict, drop and clear). host_tier.py,
its CPU tests and tools/bench_conversations.py come over as he wrote them; the three tests of the window buffer are
skipped. The concurrent decoder takes the tier too (its cache evicts into it; an admitted stream resumes from it).

Co-authored-by: jkuepker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants