mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2526] [Engine] Preserve decoded batch-slot conversations before slot reuse #4099
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4099
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2526
Author: @hotschmoe
Created: 10/15/2026
Status: 🔄 Open
Base:
main← Head:batch-slot-cache-preservation-main📝 Commits (1)
4972d47Preserve decoded batch-slot conversations before slot reuse📊 Changes
4 files changed (+363 additions, -55 deletions)
View changed files
📝
include/strata/core/conversation_cache.hpp(+31 -0)📝
src/core/conversation_cache_test.cpp(+104 -0)📝
src/program/generate.cpp(+120 -34)📝
sycl/src/program/generate.cpp(+108 -21)📄 Description
Problem and result
With
--parallel/--batchslots, an admission (or a prompt read that gives way, BYIELD) copies a new conversation over an idle slot while the conversation cache holds only that slot conversation's prompt as it was read before admission. When the user returns to that chat, the engine reads the decoded reply again, or the whole prefix if the cache evicted the older copies meanwhile. Still the case on 0.2.0-beta (measured below: a returning 10,329-token conversation replayed all 10,329 tokens).With this change an idle text slot is parked into the conversation cache before it is overwritten, so the returning turn reuses everything the engine held: on the same test, 0 tokens replayed for both returning conversations.
Related discussion
none (a correctness fix to existing conversation-cache behaviour; no new flag or default).
Approach
park_slotparks an idle text slot's sessions, checkpoints and per-slot draft K/V through the same budget, RAM admission and snapshot path aspark_current(renamedpark_source), unless the main session or a parked conversation already holds that state (ConversationCache::holds, new).STRATA_SLOT_CKPT_MOVEthey move as the one continued from did.include/strata/core/conversation_cache.hpp,src/core/conversation_cache_test.cpp(new cases),src/program/generate.cpp(CUDA) andsycl/src/program/generate.cpp(SYCL) with the same logic.Validation
Setup: 0.2.0-beta
maine88ee39dagainst this branch rebased on it (head4972d47c). 2x Intel Arc Pro B70 32 GB, kernel 7.1, Compute Runtime 26.22.38646.4, SYCL AOTbmg-g31built with the repository dev image. Qwen3.8-Flash-Next ISTA GSQ-RCO IQ3_XXS,--layer-split 30,"parallel": 2,--max-context 16384 --vram-reserve-mib 512 --kv int8 --spec 4(no MTP: a SYCL layer split turns batch MTP off, and MTP slots without a per-slot drafter are not parked),--conversation-cache-mib 32768 --conversation-cache-slots 4.Test (the same script for both builds): conversations A and B (10,074-token prompts, each with three code words spread through it) decode 256-token replies in the two slots; C and D are then admitted into those slots; A and B return one at a time with their replies kept verbatim and ask for the code words. Expected: the returning turn reuses prompt + reply - 1 = 10,329 tokens.
Passed:
cache_n10,329,prompt_n28, replayed 0; B withcache_n10,329,prompt_n28, replayed 0. The engine logged oneconversation cache: parked 10329 tokens from slot 0 in 212.5 ms(main logs none). Both replies repeat their three code words.maine88ee39d, same test: A replayed 0 (its slot was not overwritten), B returned withcache_n0 and replayed all 10,329 tokens (the failure this fixes). Code words correct in both builds.g++ -std=c++20):conversation_cache_test: 4824 checks passed;conversation_split_failure_testrc=0 (allocation-failure cases preserved at 1, 2 and 3 stages).strata, AOT bmg-g31). Per-card health passed after both runs.Failed: none observed.
Not run: CUDA build and GPU run (
src/program/generate.cppwas edited to mirror the SYCL change and reviewed, not compiled: no NVIDIA card here); MTP slots with a per-slot batch drafter (--batch-mtp, refused on a SYCL layer split); image slots (not parked by design); long contexts (on 0.1.x a 199,501-token four-chat RAM-return test on an expert-parallel development stack reused 199,839 held tokens and replayed 0 reply tokens; not re-run on 0.2.0).Limits
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.