[PR #1511] [CLOSED] Trace prompt-cache costs and reuse snapshot buffers #3500

Closed
opened 2026-11-07 14:41:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1511
Author: @InB4DevOps
Created: 10/8/2026
Status: ❌ Closed

Base: main ← Head: prompt-cache-tracing-reuse


📝 Commits (2)

  • 3c66249 Trace prompt-cache costs and reuse snapshot buffers
  • bd6d3bf Move checkpoint chains into parked snapshots

📊 Changes

14 files changed (+1501 additions, -83 deletions)

View changed files

📝 include/strata/core/conversation_cache.hpp (+44 -6)
📝 include/strata/core/conversation_snapshot.hpp (+12 -3)
📝 src/core/conversation_cache_test.cpp (+35 -0)
📝 src/core/conversation_snapshot_test.cpp (+18 -1)
📝 src/core/conversation_state.cpp (+50 -8)
📝 src/program/generate.cpp (+178 -29)
📝 sycl/src/core/conversation_snapshot_test.cpp (+17 -0)
📝 sycl/src/core/conversation_state.cpp (+50 -8)
📝 sycl/src/program/generate.cpp (+176 -28)
➕ tools/analyze_prompt_cache_log.py (+249 -0)
➕ tools/prompt_cache_trace.sh (+160 -0)
➕ tools/prompt_cache_workloads.py (+272 -0)
➕ tools/test_analyze_prompt_cache_log.py (+135 -0)
➕ tools/test_prompt_cache_workloads.py (+105 -0)

📄 Description

Summary

  • Add opt-in, log-only prompt-cache decision and phase tracing for CUDA/HIP and SYCL, including checkpoint allocation, GDN, PLE, and indexer timings and bytes.
  • Add deterministic live workloads, trace analysis, and offline tooling tests.
  • Reuse restored running-state host allocations for the next snapshot capture while refreshing every state byte.
  • On branch switches that replace the active checkpoint chain, move that chain into the parked snapshot rather than deep-copying it. Keep the chain if admission or parking fails; preserve memory-budget accounting.
  • Harden the trace runner against occupied ports, unloaded servers, paths with spaces, and backend-specific build directories.

Performance

Measured on the local branch_switching workload using alternating settings on the same engine build:

  • Running-state allocation reuse (first commit): total park capture 1025.0 ms -> 936.9 ms (-8.6%); eligible restored-branch parks 628.8 ms -> 540.8 ms (-14.0%).
  • Checkpoint-chain move (second commit, with running-state reuse already enabled): five park captures totaled 939.0 ms -> 627.0 ms (-33.2%) across two off/on pairs. Reuse decisions and partial rereads were unchanged.
  • Detailed trace of six checkpoint saves showed 174 ms spent allocating and 411 ms copying about 118 MB of GDN state per save; the chain-move optimization targets parking, not checkpoint creation.

Verification

  • cmake --build build --target strata conversation_cache_test conversation_snapshot_test conversation_validation_test conversation_transfer_test
  • ./build/conversation_cache_test (4,201 checks)
  • ./build/conversation_snapshot_test (3,985 checks)
  • ./build/conversation_validation_test (972 checks)
  • ./build/conversation_transfer_test (1,548 checks)
  • python3 -m unittest tools.test_analyze_prompt_cache_log tools.test_prompt_cache_workloads (19 tests)
  • bash -n tools/prompt_cache_trace.sh and git diff --check
  • Live six-scenario workload (29 requests) completed with the checkpoint-chain move enabled.

SYCL source and tests are mirrored, but a SYCL toolchain was not available locally.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1511 **Author:** [@InB4DevOps](https://github.com/InB4DevOps) **Created:** 10/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `prompt-cache-tracing-reuse` --- ### 📝 Commits (2) - [`3c66249`](https://github.com/Niko1221/Strata/commit/3c662499b11e56c619d2e68834adb95dbeeadbc8) Trace prompt-cache costs and reuse snapshot buffers - [`bd6d3bf`](https://github.com/Niko1221/Strata/commit/bd6d3bf62c116b105bf7fd44d2e172f3ffb4b212) Move checkpoint chains into parked snapshots ### 📊 Changes **14 files changed** (+1501 additions, -83 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/conversation_cache.hpp` (+44 -6) 📝 `include/strata/core/conversation_snapshot.hpp` (+12 -3) 📝 `src/core/conversation_cache_test.cpp` (+35 -0) 📝 `src/core/conversation_snapshot_test.cpp` (+18 -1) 📝 `src/core/conversation_state.cpp` (+50 -8) 📝 `src/program/generate.cpp` (+178 -29) 📝 `sycl/src/core/conversation_snapshot_test.cpp` (+17 -0) 📝 `sycl/src/core/conversation_state.cpp` (+50 -8) 📝 `sycl/src/program/generate.cpp` (+176 -28) ➕ `tools/analyze_prompt_cache_log.py` (+249 -0) ➕ `tools/prompt_cache_trace.sh` (+160 -0) ➕ `tools/prompt_cache_workloads.py` (+272 -0) ➕ `tools/test_analyze_prompt_cache_log.py` (+135 -0) ➕ `tools/test_prompt_cache_workloads.py` (+105 -0) </details> ### 📄 Description ## Summary - Add opt-in, log-only prompt-cache decision and phase tracing for CUDA/HIP and SYCL, including checkpoint allocation, GDN, PLE, and indexer timings and bytes. - Add deterministic live workloads, trace analysis, and offline tooling tests. - Reuse restored running-state host allocations for the next snapshot capture while refreshing every state byte. - On branch switches that replace the active checkpoint chain, move that chain into the parked snapshot rather than deep-copying it. Keep the chain if admission or parking fails; preserve memory-budget accounting. - Harden the trace runner against occupied ports, unloaded servers, paths with spaces, and backend-specific build directories. ## Performance Measured on the local `branch_switching` workload using alternating settings on the same engine build: - Running-state allocation reuse (first commit): total park capture 1025.0 ms -> 936.9 ms (-8.6%); eligible restored-branch parks 628.8 ms -> 540.8 ms (-14.0%). - Checkpoint-chain move (second commit, with running-state reuse already enabled): five park captures totaled 939.0 ms -> 627.0 ms (-33.2%) across two off/on pairs. Reuse decisions and partial rereads were unchanged. - Detailed trace of six checkpoint saves showed 174 ms spent allocating and 411 ms copying about 118 MB of GDN state per save; the chain-move optimization targets parking, not checkpoint creation. ## Verification - `cmake --build build --target strata conversation_cache_test conversation_snapshot_test conversation_validation_test conversation_transfer_test` - `./build/conversation_cache_test` (4,201 checks) - `./build/conversation_snapshot_test` (3,985 checks) - `./build/conversation_validation_test` (972 checks) - `./build/conversation_transfer_test` (1,548 checks) - `python3 -m unittest tools.test_analyze_prompt_cache_log tools.test_prompt_cache_workloads` (19 tests) - `bash -n tools/prompt_cache_trace.sh` and `git diff --check` - Live six-scenario workload (29 requests) completed with the checkpoint-chain move enabled. SYCL source and tests are mirrored, but a SYCL toolchain was not available locally. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:55 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3500
No description provided.