mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2247] [CLOSED] --session-state-codec bf16: a saved/parked conversation's running state at half the bytes #3947
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#3947
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/2247
Author: @sumomomomomo
Created: 10/13/2026
Status: ❌ Closed
Base:
main← Head:feat/state-snapshot-bf16📝 Commits (10+)
fe88a54docs: the plan for a bf16 saved-state codec (parked images and session files)a6def98--session-state-codec bf16: a saved conversation's running state at half the bytes (the file says which codec it used; the live state stays fp32)725714a--session-state-codec: the four things a review ofa6def98foundd178753sycl: the migrated SAVE caller for the preflight's new signatureaad5df6state codec: a stored array converts to another codec in one pass2274c1cdocs: the parked-image, 4K and 128K, cold-read and RAM numbers the PR asked for, and the one-pass conversion09c126flazy restoration: a resumed conversation keeps its parked snapshots in the codec they were parked in (resuming no longer widens the whole retained chain; only the one checkpoint a rewind selects is decoded into the session's fp32 buffers, and its stored bytes stay as they are)fc0003econversation report: a restore failure that cannot allocate its own message does not throwc3e25b1docs: what the code actually does on a park, a SAVE and a restore, and what is still unmeasured387b9c3docs: the fp32 comparison is stated as what it is, and a continuation pays the decode too📊 Changes
23 files changed (+2946 additions, -88 deletions)
View changed files
📝
CMakeLists.txt(+25 -3)📝
docs/DETAILS.md(+40 -1)➕
docs/STATE_SNAPSHOT_BF16.md(+316 -0)📝
include/strata/core/conversation_cache.hpp(+13 -0)📝
include/strata/core/conversation_file.hpp(+9 -4)➕
include/strata/core/conversation_report.hpp(+27 -0)📝
include/strata/core/conversation_snapshot.hpp(+31 -0)📝
include/strata/core/session_save_reclaim.hpp(+4 -2)➕
include/strata/core/state_codec.hpp(+62 -0)📝
src/core/conversation_cache_test.cpp(+54 -0)➕
src/core/conversation_capture_codec_test.cpp(+409 -0)📝
src/core/conversation_copy.hpp(+62 -0)📝
src/core/conversation_file.cpp(+68 -9)📝
src/core/conversation_file_test.cpp(+74 -10)➕
src/core/conversation_report_test.cpp(+241 -0)📝
src/core/conversation_snapshot_test.cpp(+680 -0)📝
src/core/conversation_state.cpp(+173 -22)📝
src/core/session_save_reclaim_test.cpp(+38 -9)➕
src/core/state_codec.cpp(+159 -0)➕
src/core/state_codec_test.cpp(+247 -0)...and 3 more files
📄 Description
Closes #2377
Overview
Adds opt-in
--session-state-codec bf16to reduce the RAM and disk needed for conversation checkpoints. For the tested model, checkpoint state is approximately 50% smaller and session files are 5.6–39.3% smaller, providing headroom for more cached conversations or denser resume points.In the 32K workload, BF16 at 8K checkpoint spacing delivered comparable complete-turn latency to FP32 at the default 16K spacing. Parking was faster across the tested context sizes, while continuing resumes added approximately 2–6 ms.
The benchmark harness, raw results and engine logs are now public.
Architecture
The codec covers GDN recurrence/convolution history, PLE history, and QSA indexer tails/dead keys. Integer positions and K/V storage are unchanged. Encoding uses round-to-nearest-even and is lossy; widening is exact.
Validation
Benchmarks used Linux, CUDA 12.8, a Tesla V100 32 GB as the single model GPU, a 24-core/32-thread Intel CPU, 93 GB reported RAM, IQ3_S, INT8 K/V, and a Samsung 990 EVO Plus SSD.
Latency comparisons used the same
strata.headbinary, with runs recorded ate79abfc0: two rounds with reversed arm order, two warm-ups and ten measured repetitions per round. Figures below are medians of round medians. RSS measurements were re-run at79955461.Checkpoint spacing and turn latency
A fresh 31,813-token document followed by short turns:
Complete-turn timings include parking, resumption and generation; they are not TTFT or isolated capture timings. This sweep measures latency; recall is assessed separately below.
Parked conversation performance
At 16K checkpoint spacing, FP32 → BF16:
In a separate 32K run with four parked images, cache-accounted allocation fell from 3.73 GB to 3.08 GB (17.4%). These figures include allocator capacity; they are not serialized payload sizes or a guarantee of proportionally more conversations per cache budget.
SAVE / RESTORE memory
Observed RSS growth, FP32 → BF16:
First SAVE was measured separately from later saves, which reuse allocations. RESTORE figures are medians of nine repetitions. BF16 RESTORE grew RSS by approximately 56.2 MiB more at both sizes.
RSS was sampled every 20 ms on fresh processes; these are observed increments, not guaranteed peak-memory bounds.
Functional and failure-path checks
ple_parityrequires a missing artifact and also fails before this change.Compatibility and limitations
Implementation and detailed results:
docs/STATE_SNAPSHOT_BF16.md.Public evidence: artifact manifest, harness and reproduction instructions, and raw results. The manifest identifies historical runs, superseded measurements and provenance gaps; earlier session-file timings are not presented as current-build performance.
AI Disclosure
Created with Qwen3.8-Flash-Next-exl3 3.05bpw.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.