mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2443] [Engine] evict redundant holders while preserving pinned prefixes #4048
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#4048
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/2443
Author: @KeyanHu-git
Created: 10/14/2026
Status: 🔄 Open
Base:
main← Head:fix/2255-pinned-eviction📝 Commits (10+)
3a28942conversation cache: evict redundant holders without losing pinned prefixes6af3620docs: describe pinned-prefix retention across conversation holders64a2275conversation cache: align reclaimable bytes with pinned evictionaf1e09dmerge current main and align pinned-prefix reclamation documentation9a08edcValidate pinned-prefix reclamation through session saving and model replay2d3cf51Merge current main and retain pinned-prefix eviction documentationda63fdeMerge v0.2.7 and preserve pending snapshot ownership during evictiondaf1c41Record v0.2.7 cache ownership and model validation8de521aInclude sanitizer test receipts referenced by validation report2f4701cKeep cache PR focused and preserve validation at immutable revision📊 Changes
9 files changed (+603 additions, -77 deletions)
View changed files
📝
docs/DETAILS.md(+5 -4)📝
include/strata/core/conversation_cache.hpp(+136 -24)📝
include/strata/core/session_save_reclaim.hpp(+1 -1)📝
src/core/conversation_cache_test.cpp(+332 -2)📝
src/core/conversation_file_test.cpp(+4 -4)📝
src/core/conversation_snapshot_test.cpp(+28 -11)📝
src/core/conversation_validation_test.cpp(+34 -22)📝
src/core/session_save_reclaim_test.cpp(+41 -0)📝
sycl/src/core/conversation_snapshot_test.cpp(+22 -9)📄 Description
Problem and result
Pinning the same system prompt on every request fills the conversation cache with branches of one prefix. Upstream protects every branch, so later conversations cannot be saved even when the byte budget has room.
This change evicts redundant branches while keeping at least one holder of every pinned prefix. The same 15-request replay against v0.2.7, repeated on this ownership revision, gives:
Related discussion
Fixes #2255. Related admission paths: #2253 and #2082.
Approach
Evict unpinned entries first, then the oldest entry whose pinned prefixes all have another holder. Prefix identity includes token IDs, image identities and steering mode. A borrowed donor stays protected and counts as a surviving holder.
evictable_bytes()simulates the same removals, so admission and session-save reclamation agree with eviction about what can be released. Retained active K/V is accounted separately.Snapshots are move-only resource owners.
SavedConversation,ConversationKvand the retained-K/V package reject copying at compile time; moving transfers the buffers and their pending-copy tokens together. Replacement retires the complete old owner, joining its copies before releasing storage. Cache erasure, capture publication and file-load publication use the same type-level rule.The cache itself is noncopyable and nonmovable because its serials, guards and accounting identify one service instance. Restore and file writing borrow snapshots through the existing completion checks. Ordinary checkpoint values remain copyable for prefix borrowing. Tests reconstruct independent fixtures instead of copying asynchronous owners; no new clone or shared-storage API is introduced.
Validation
Production revision:
ce957e14, based on v0.2.75e8a4cca. The current diff keeps the fix, regression tests and user documentation. Experimental records are preserved at the immutable revision below, outside the merge diff. Recorded requests, outputs, settings, source hashes and reproduction steps.Passed:
The initial CUDA/SYCL builds found a remaining copy in each malformed-payload test. Those tests now capture independent fixtures; the production implementation is unchanged. Historical lifetime counterexamples and earlier validation are retained separately.
HIP disables both
STRATA_PARK_ASYNCandSTRATA_CKPT_ASYNCin the implementation. The flag-set arm therefore validates HIP's fallback, not CUDA background copies. Pending-copy lifetime is tested with sanitizer-checked completion tokens. CUDA asynchronous device execution and CUDA/SYCL/Metal model execution were not run in this batch.Limits
Explicit constructors make the snapshot types non-aggregate; current repository consumers pass all four backend builds. Data-member layout and session-file format are unchanged. Snapshot-owner copies are now rejected by the compiler; data readiness for borrowed reads continues to use the existing synchronization paths.
The eviction search depends on the number of entries, checkpoints and prefix length. Logical freed bytes are used for accounting; physical-memory admission still resamples available memory. The model replay establishes cache reuse and matching outputs on this workload, with diagnostics enabled, rather than a throughput claim.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.