[PR #65] [CLOSED] cache: preserve root system prompt checkpoint across turns and eviction #2437

Closed
opened 2026-11-04 02:00:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/65
Author: @code-martin
Created: 9/28/2026
Status: ❌ Closed

Base: main ← Head: feature/root-checkpoint-retention


📝 Commits (1)

  • c42e92f cache: preserve root system prompt checkpoint across turns and eviction

📊 Changes

1 file changed (+22 additions, -11 deletions)

View changed files

📝 src/program/generate.cpp (+22 -11)

📄 Description

Summary

This PR addresses root checkpoint retention for --serve prompt caching, keeping the root system prompt cached across branching chats and new conversations without compromising v0.1.13 prefill throughput:

  1. Root & Last Turn Checkpoints Only:

    • Rather than checkpointing every turn (which triggers repeated borrow/refill cycles and large memory copies), the prompt reading loop identifies at most two turn boundaries:
      • urn_first: the first <|im_start|> past token 0 (the root boundary after the system prompt).
      • urn_last: the final <|im_start|> before the assistant turn.
    • Long conversation histories remain batched in full chunks (up to 8192 tokens), preserving v0.1.13 speedup.
  2. Root Preservation During Eviction:

    • In checkpoint_at(), when checks.size() > o.prompt_cache, if checks.size() > 2 && checks[0].ids.size() <= checks[1].ids.size(), eviction drops checks[1] (the oldest intermediate turn) instead of checks[0].
    • The root system prompt checkpoint remains resident in checks[0]. Subsequent requests sharing the same system prompt match checks[0] and resume immediately (
      esume == checks[0].ids.size()) without prefilling the system prompt again.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/65 **Author:** [@code-martin](https://github.com/code-martin) **Created:** 9/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/root-checkpoint-retention` --- ### 📝 Commits (1) - [`c42e92f`](https://github.com/Niko1221/Strata/commit/c42e92f60b33338c7f6c05456a6990d6bd6217ef) cache: preserve root system prompt checkpoint across turns and eviction ### 📊 Changes **1 file changed** (+22 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/program/generate.cpp` (+22 -11) </details> ### 📄 Description ### Summary This PR addresses root checkpoint retention for --serve prompt caching, keeping the root system prompt cached across branching chats and new conversations without compromising v0.1.13 prefill throughput: 1. **Root & Last Turn Checkpoints Only**: - Rather than checkpointing every turn (which triggers repeated borrow/refill cycles and large memory copies), the prompt reading loop identifies at most two turn boundaries: - urn_first: the first <|im_start|> past token 0 (the root boundary after the system prompt). - urn_last: the final <|im_start|> before the assistant turn. - Long conversation histories remain batched in full chunks (up to 8192 tokens), preserving v0.1.13 speedup. 2. **Root Preservation During Eviction**: - In checkpoint_at(), when checks.size() > o.prompt_cache, if checks.size() > 2 && checks[0].ids.size() <= checks[1].ids.size(), eviction drops checks[1] (the oldest intermediate turn) instead of checks[0]. - The root system prompt checkpoint remains resident in checks[0]. Subsequent requests sharing the same system prompt match checks[0] and resume immediately ( esume == checks[0].ids.size()) without prefilling the system prompt again. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:06 +07:00
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#2437
No description provided.