[GH-ISSUE #3721] [Engine] conversation cache: borrow (#1164) also under --layer-split #1553

Closed
opened 2026-11-04 01:52:11 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mantovaniluca91 on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3721

Since 0.1.45 a new conversation that matches a checkpoint inside another parked conversation borrows it (ConversationCache::borrows(), PR #1164) instead of taking the whole entry. Under --layer-split this never happens — in v0.2.2 src/program/generate.cpp:

// (a layer split restores whole stage images only, so it never borrows; ...)
bool borrow = stages.empty() && parked.tokens > std::max(resume, slot_tokens) &&
              conversations.borrows(parked);

So on a layer split the sibling's parked conversation is still taken whole, and its next turn reads its history again. For agent clients with many conversations sharing one long system prompt, this is the case that matters most, and multi-GPU layer splits are exactly where people run long contexts. Could borrowing be extended to layer splits (copying each stage's share of the checkpoint and K/V up to the match), or is there a reason it cannot work there?

Setup

  • Strata 0.1.43.1 (we have read the 0.1.45 / 0.2.2 sources; the line above is unchanged in v0.2.2), Linux, ROCm, older-CPU (AVX-only) build.
  • 2× RX 7900 XTX, --layer-split 27 --batch 2 --batch-groups auto, MTP, --kv int8 --kv-resident 32768, 262K context, GSQ-RCO IQ3_XXS.
  • --conversation-cache-mib 40960 --conversation-cache-slots 16 --conversation-cache-min-tokens 8192 --prompt-cache-every 32768.
  • Client: Hermes Agent. Kanban workers and desktop sessions share the same tools + system prompt (22K–38K tokens), several conversations alive at once, each growing to 60K–190K.
  • Planned: a second engine on 2× MI50 (gfx906), where prefill is ~500–560 tok/s. There every re-read of a 100K history costs ~3 minutes instead of ~1, so this matters even more.

What we see (one working day, 22/10, 10:20–14:41, ~500 requests)

  • At most 4–5 conversations above 8K tokens alive at the same time, yet the cache stays at 16 parked entries; evictions reached 148.

  • 9 requests of conversations that were already running (not new ones, and not right after a client-side compaction) read their prompt from token 0: 23K–165K tokens, 15–110 s each, ~6 minutes of prefill in total. Example from /metrics?requests=all: a desktop session resumed from the cache on its previous turns, then at 13:59 prompt_tokens 165358, reused 0, 110 s of prefill, with no change in its history (message count still growing, system prompt and tools identical).

  • From the log alone we cannot tell which of these were plain evictions and which were a sibling taking the entry (take()), because a take of another conversation's entry prints the same conversation cache: restored N tokens (checkpoint) line as a normal resume. Our reading of the code (0.1.43.1, best() + take(parked.index)) is that a new conversation matching the shared system-prompt checkpoint inside conversation A's entry moves A's whole entry out, and A's next turn starts again from its root.

Requests, in order of usefulness to us

  1. Borrow under --layer-split (per-stage copy of the matched checkpoint and the K/V up to it, the donor stays parked).
  2. If that is not possible soon: a log line when an entry is taken by a different conversation (e.g. taken by a sibling: N tokens of a parked M-token conversation), and a counter in /metrics next to borrowed, so the cost can be measured.
  3. Related, already open: PR #3517 (retention pin on the real system-prompt root, issue #3090). With a system prompt longer than --prompt-cache-every we saw the pinned item be the 16K checkpoint, and new conversations resume from 16K/32K instead of the end of the system prompt; we moved to --prompt-cache-every 32768 as a workaround.

We can test any build on 2× 7900 XTX now and on 2× MI50 later, and report the same day counts (borrowed, evictions, re-reads from the root).

Originally created by @mantovaniluca91 on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3721 Since 0.1.45 a new conversation that matches a checkpoint inside *another* parked conversation borrows it (`ConversationCache::borrows()`, PR #1164) instead of taking the whole entry. Under `--layer-split` this never happens — in v0.2.2 `src/program/generate.cpp`: ```cpp // (a layer split restores whole stage images only, so it never borrows; ...) bool borrow = stages.empty() && parked.tokens > std::max(resume, slot_tokens) && conversations.borrows(parked); ``` So on a layer split the sibling's parked conversation is still taken whole, and its next turn reads its history again. For agent clients with many conversations sharing one long system prompt, this is the case that matters most, and multi-GPU layer splits are exactly where people run long contexts. Could borrowing be extended to layer splits (copying each stage's share of the checkpoint and K/V up to the match), or is there a reason it cannot work there? **Setup** - Strata 0.1.43.1 (we have read the 0.1.45 / 0.2.2 sources; the line above is unchanged in v0.2.2), Linux, ROCm, older-CPU (AVX-only) build. - 2× RX 7900 XTX, `--layer-split 27 --batch 2 --batch-groups auto`, MTP, `--kv int8 --kv-resident 32768`, 262K context, GSQ-RCO IQ3_XXS. - `--conversation-cache-mib 40960 --conversation-cache-slots 16 --conversation-cache-min-tokens 8192 --prompt-cache-every 32768`. - Client: Hermes Agent. Kanban workers and desktop sessions share the same tools + system prompt (22K–38K tokens), several conversations alive at once, each growing to 60K–190K. - Planned: a second engine on 2× MI50 (gfx906), where prefill is ~500–560 tok/s. There every re-read of a 100K history costs ~3 minutes instead of ~1, so this matters even more. **What we see (one working day, 22/10, 10:20–14:41, ~500 requests)** - At most 4–5 conversations above 8K tokens alive at the same time, yet the cache stays at 16 parked entries; `evictions` reached 148. - 9 requests of conversations that were already running (not new ones, and not right after a client-side compaction) read their prompt from token 0: 23K–165K tokens, 15–110 s each, ~6 minutes of prefill in total. Example from `/metrics?requests=all`: a desktop session resumed from the cache on its previous turns, then at 13:59 `prompt_tokens 165358, reused 0`, 110 s of prefill, with no change in its history (message count still growing, system prompt and tools identical). - From the log alone we cannot tell which of these were plain evictions and which were a sibling taking the entry (`take()`), because a take of another conversation's entry prints the same `conversation cache: restored N tokens (checkpoint)` line as a normal resume. Our reading of the code (0.1.43.1, `best()` + `take(parked.index)`) is that a new conversation matching the shared system-prompt checkpoint inside conversation A's entry moves A's whole entry out, and A's next turn starts again from its root. **Requests, in order of usefulness to us** 1. Borrow under `--layer-split` (per-stage copy of the matched checkpoint and the K/V up to it, the donor stays parked). 2. If that is not possible soon: a log line when an entry is taken by a *different* conversation (e.g. `taken by a sibling: N tokens of a parked M-token conversation`), and a counter in `/metrics` next to `borrowed`, so the cost can be measured. 3. Related, already open: PR #3517 (retention pin on the real system-prompt root, issue #3090). With a system prompt longer than `--prompt-cache-every` we saw the pinned item be the 16K checkpoint, and new conversations resume from 16K/32K instead of the end of the system prompt; we moved to `--prompt-cache-every 32768` as a workaround. We can test any build on 2× 7900 XTX now and on 2× MI50 later, and report the same day counts (`borrowed`, `evictions`, re-reads from the root).
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6659662505 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1553
No description provided.