mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3973] [Engine] test: the byte-identity half of the reuse contract #4858
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#4858
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/3973
Author: @wannagoxuf
Created: 10/24/2026
Status: 🔄 Open
Base:
main← Head:feature/reuse-identity-test📝 Commits (1)
d604729test: the byte-identity half of the reuse contract📊 Changes
2 files changed (+227 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+4 -0)➕
src/core/conversation_reuse_identity_test.cpp(+223 -0)📄 Description
Problem
The snapshot API contract (
include/strata/core/conversation_snapshot.hpp) says:The bookkeeping half of that - which bytes a capture claims are unchanged, and where the claim stops - is
covered in
conversation_cache_test.cpp(retain/limit_reuse/take_reuse). The half that is notcovered is the byte half: whether the bytes really are unchanged.
That question is live in the two pull requests that touch the reuse path (#3711 and the harvest discussed in
#3321), and it is decidable in the shapes the cache actually produces.
Approach
A new test (
src/core/conversation_reuse_identity_test.cpp, 21 checks) that covers:unchanged_tokensclaim rests on: the bytes before the first rewrite are still the ones the session holds.nothing, since identical bytes could just mean the comparison is too coarse to see a difference.
limit_reusecuts it at the first rewrite, a rewrite from the start drops the wholedonation, and a later continuation cannot widen a claim that was already cut.
unchanged_tokensthe capture keeps the donated prefixbytes and not the device's, and past the claimed prefix it takes the device's bytes.
The engine-level half - two independent computations of the same token prefix through different chunkings -
needs a real model and is not decided here. It is measured with
STRATA_STATE_HASH=1(the engine'sper-request fingerprint of the session's K/V) and the result is in #3321: on 4x4090 with
Qwen3.8-Flash-Next IQ3_XXS, the same prompt through
--prefill 4096and--prefill 1024gives differentmain-K/V fingerprints (
2b0d5053ac251873vs42e1a97e3930a0fe), while the same chunking twice gives thesame fingerprint. So equal token IDs do not, in fact, establish equal bytes across a chunking boundary - the
contract's caution is observable, not theoretical.
Validation
Passed:
origin/main(7dd5cf18):cmake -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_CONVERSATION_TESTS=ON+cmake --build . -j 4(CUDA 12.8, driver 580.178.04, 4x RTX 4090).ctest -R conversation --output-on-failure -j 2: 8/8 passed, including the newconversation_reuse_identity_test(21 checks).add_testregistration.Not run:
test uses only
conversation_kv_save/conversation_kv_verify/ConversationCache, none of which arebackend-specific, but that is an argument, not a run.
STRATA_STATE_HASH=1runs) is on the CUDA engine only.Failed: nothing.
Limits
not decide whether two independent computations of the same prefix agree - that needs a model, and the
answer there is no (see the measurement above).
different prefix differs; it cannot show that a real model's prefix bytes are stable across chunkings.
Related
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.