mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #41] [CLOSED] serve: preserve primary conversation state across auxiliary calls #2426
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#2426
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/41
Author: @midhatn
Created: 9/28/2026
Status: ❌ Closed
Base:
main← Head:fix/auxiliary-conversation-state📝 Commits (3)
fa0b0f8serve: preserve primary state around explicitly marked auxiliary requestse2d5746serve: report the running engine version before the directory manifest39dcdebdocs: keep snapshot validation examples environment-neutral📊 Changes
11 files changed (+376 additions, -2 deletions)
View changed files
📝
CMakeLists.txt(+6 -0)➕
docs/AUXILIARY_STATE_CACHE.md(+97 -0)📝
include/strata/core/layer.hpp(+2 -0)📝
include/strata/core/mtp.hpp(+3 -0)➕
include/strata/program/conversation_state.hpp(+70 -0)📝
serve/server.py(+11 -2)📝
serve/test_server.py(+52 -0)📝
src/core/layer.cpp(+2 -0)📝
src/core/mtp.cpp(+1 -0)➕
src/program/conversation_state_test.cpp(+47 -0)📝
src/program/generate.cpp(+85 -0)📄 Description
An agent using one local model for both its primary conversation and auxiliary approval/summary calls can lose its primary KV state between turns. The ordinary conversation checkpoints do not preserve an independent positional KV cache, so returning from an unrelated side call can reread thousands of tokens.
This adds an opt-in, bounded host-RAM snapshot around explicitly marked auxiliary requests. A primary → auxiliary → primary sequence restores the primary only when the token/image prefix and control-vector setting match; rewritten history falls back to normal prefill. The feature defaults off and does not add parallel model instances.
Changes
--conversation-cache-mib Nparks one complete mutable primary state, including QSA device/host KV, GDN recurrence/convolution, PLE history, MTP state and the associated checkpoints/token/image metadata. Model weights and expert placement stay in place; device addresses remain stable.strata_auxiliary: trueasaux=1for text and image requests. Further marked auxiliaries do not displace the parked primary, even if their prompts are longer. Reasoning level and prompt text are not used to infer auxiliary intent.BUILD.json. This fixes a custom 0.1.13 executable being displayed as 0.1.12 when it shares a directory with a retained official fallback. Older engines still use the manifest fallback.docs/AUXILIARY_STATE_CACHE.md.Validation
Based on upstream
b89c989a7155e984e544ddd90d1038dda7da9e3d, including the prompt-cache correctness fixes after 0.1.13. The existing patch was also compatibility-tested against v0.1.16; the published implementation has not yet been rebased onto that release.Hardware used for bounded validation: Ryzen 9 7940HS, RTX 4070 Laptop 8 GB, and 64 GB RAM, running Windows.
These are bounded checks, not the requested repeated streamed-KV soak or proof of arbitrary agent-task success. They do not establish bitwise logit parity, cross-platform correctness or a general generation-speed improvement.
Scope for review
This is a draft for review of the API and state ownership. Physical-memory admission currently uses Windows telemetry; other platforms decline admission safely. Linux/cgroup-aware admission is not implemented or validated. The snapshot cap excludes existing small checkpoints, and its RAM-floor check is not a continuous system-wide reservation. Bitwise logit parity across all model/configuration combinations is not claimed.
The cache protects one primary around explicitly marked side calls. It is not persistent storage, arbitrary multi-session caching or a solution for rewritten compression prefixes. The auxiliary inference itself still runs. Deployment-specific configuration and agent delegation changes are outside this PR.
Related to the prompt-cache work in #39, but this snapshots the complete mutable state around explicit auxiliary calls rather than changing checkpoint retention or telemetry. No maintainer action or merging is assumed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.