[PR #716] [CLOSED] conversation parking with --layer-split #2783

Closed
opened 2026-11-04 02:03:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/716
Author: @evaanp
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: pr/parking-layer-split


📝 Commits (10+)

  • 7efb9ab conversation cache: a checkpoint records the carve its payload was saved from
  • 712343b conversation snapshot: the entry points take the stages, stage 0 first
  • bb89148 conversation snapshot: capture, validate and restore across a layer split
  • 7a55d53 serve: conversation parking no longer refuses --layer-split
  • d144797 conversation validation test: a two-stage split fixture, host-side
  • c5a5bba conversation snapshot test: single-stage call sites take a stage vector
  • 50431c8 conversation snapshot: drain each stage on its own device before reading or writing it
  • 2f344be conversation validation test: a split's copies must follow a drain on their own device
  • 7df55bc serve: parking names stage 0's device instead of leaving it -1
  • e7a3da7 Copy the layer carve into split mid-prompt checkpoints; parity tool runs the server's engine arguments

📊 Changes

9 files changed (+356 additions, -113 deletions)

View changed files

📝 CMakeLists.txt (+4 -1)
📝 docs/DETAILS.md (+5 -3)
📝 include/strata/core/conversation_cache.hpp (+7 -4)
📝 include/strata/core/conversation_snapshot.hpp (+18 -6)
📝 src/core/conversation_snapshot_test.cpp (+12 -11)
📝 src/core/conversation_state.cpp (+134 -59)
📝 src/core/conversation_validation_test.cpp (+158 -18)
📝 src/program/generate.cpp (+15 -9)
📝 tools/conversation_cache_parity.py (+3 -2)

📄 Description

What

Conversation parking (--conversation-cache-mib, #57) refused to start with --layer-split: "conversation parking
does not yet support --layer-split". On two cards every switch between an agent and its sub-agent or side call
then read the whole prompt again. This lets the two work together.

  • One part per stage. A snapshot holds every stage's running state, used K/V pages and checkpoints, and the
    draft-layer K/V on the stage that carries it. Host K/V stays flat, in stage order with the drafter last, so the
    cache's reuse of retained pages works as before; only running state is per stage, the way
    ConversationCheckpoint::stage_parts already stored it.
  • Each part names its carve. ConversationCheckpoint records layer_lo/layer_hi: two same-sized carves with
    different QSA ordinals cannot be told apart by sizes alone, so a part can never be restored into a stage that runs
    other layers.
  • Validate everything, then write. conversation_snapshot_validate checks every part against its own stage
    before anything is restored, as the single-GPU path already did.
  • Each stage on its own device. Capture and restore drain each stage inside its own OnDevice scope and copy
    there. (cudaDeviceSynchronize drains only the current device, so a single sync on stage 0's card would have read
    a later stage's state while its kernels might still be writing it.) Stage 0 is named as device 0 instead of -1.
  • Split checkpoints taken mid-prompt (--prompt-cache-every) now copy the carve too; without it every park of
    a conversation longer than 16K tokens was refused as "a checkpoint from another session layer carve".
  • tools/conversation_cache_parity.py builds the engine arguments the way the server does, so on several GPUs it
    tests the layer split instead of one card.

Tests

  • conversation_validation_test gains a two-stage split fixture (host only): parts, carves, mismatched stage counts
    and carves, and two checks that a later stage is written, and read during capture, only after its own device was
    drained. 1008 checks host-only; conversation_transfer_test 1608. That test now also wraps cudaGetDevice and
    cudaSetDevice (it defined the wrappers, but the link did not use them, so on a machine without a GPU the device
    never changed and the fixture failed on its own harness); with them it passes, and it fails again with the
    per-stage OnDevice scopes removed. Built in the CUDA 13.0 image (-DSTRATA_BUILD_CONVERSATION_TESTS=ON).
  • conversation_cache_test (4175 checks) unchanged; conversation_snapshot_test call sites take a stage vector.
  • On GPUs: tools/conversation_cache_parity.py --scenario reuse with the layer split: A/B/A, greedy, tokens and
    main-model state byte-exact against a run without parking (see Measured).

Measured

IQ3_S on an RTX 5060 Ti 16 GB + RTX 2000 Ada 16 GB (layer_split 30), Ryzen 7 9700X, 64 GB RAM. Measured on our
own branch: v0.1.38 merged with this code plus unrelated patches of ours (the parking code is the same as here),
--conversation-cache-mib 1024. --scenario reuse: PASS, byte-exact. A ~2K-token conversation is a 254 MiB snapshot
across both stages, parked in ~55 ms and restored in ~18 ms (from its live end) to ~20 ms (from a checkpoint). The
same A/B/A also passed on IQ2_XS with the earlier 0.1.34-based version of this code.

Developed with an AI coding assistant; all numbers measured on the machine above (Linux, CUDA 13).


🔄 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/716 **Author:** [@evaanp](https://github.com/evaanp) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/parking-layer-split` --- ### 📝 Commits (10+) - [`7efb9ab`](https://github.com/Niko1221/Strata/commit/7efb9ab73ce03c486b8605bafdc0b9d649ef8b65) conversation cache: a checkpoint records the carve its payload was saved from - [`712343b`](https://github.com/Niko1221/Strata/commit/712343bb3065a1a58ca4f7667f451c817654175b) conversation snapshot: the entry points take the stages, stage 0 first - [`bb89148`](https://github.com/Niko1221/Strata/commit/bb8914848bab0d8200d3b0c507393e3d9e6ebf60) conversation snapshot: capture, validate and restore across a layer split - [`7a55d53`](https://github.com/Niko1221/Strata/commit/7a55d53b122a1bfd1d62c42dd596a207919b043d) serve: conversation parking no longer refuses --layer-split - [`d144797`](https://github.com/Niko1221/Strata/commit/d14479775f7d9ec2d1db687202da16012c936199) conversation validation test: a two-stage split fixture, host-side - [`c5a5bba`](https://github.com/Niko1221/Strata/commit/c5a5bba169169f5480650deda089e09d1aba607a) conversation snapshot test: single-stage call sites take a stage vector - [`50431c8`](https://github.com/Niko1221/Strata/commit/50431c8aab6b33b750db9cf52944e6e67cb77800) conversation snapshot: drain each stage on its own device before reading or writing it - [`2f344be`](https://github.com/Niko1221/Strata/commit/2f344be07a1716da11cba4ed484ae9ea51e3b99d) conversation validation test: a split's copies must follow a drain on their own device - [`7df55bc`](https://github.com/Niko1221/Strata/commit/7df55bc1cd145ea3b7b519b5cf5e838090321a9a) serve: parking names stage 0's device instead of leaving it -1 - [`e7a3da7`](https://github.com/Niko1221/Strata/commit/e7a3da742ac8e8345ec738031cf6a0e163ff1f03) Copy the layer carve into split mid-prompt checkpoints; parity tool runs the server's engine arguments ### 📊 Changes **9 files changed** (+356 additions, -113 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+4 -1) 📝 `docs/DETAILS.md` (+5 -3) 📝 `include/strata/core/conversation_cache.hpp` (+7 -4) 📝 `include/strata/core/conversation_snapshot.hpp` (+18 -6) 📝 `src/core/conversation_snapshot_test.cpp` (+12 -11) 📝 `src/core/conversation_state.cpp` (+134 -59) 📝 `src/core/conversation_validation_test.cpp` (+158 -18) 📝 `src/program/generate.cpp` (+15 -9) 📝 `tools/conversation_cache_parity.py` (+3 -2) </details> ### 📄 Description ## What Conversation parking (`--conversation-cache-mib`, #57) refused to start with `--layer-split`: "conversation parking does not yet support --layer-split". On two cards every switch between an agent and its sub-agent or side call then read the whole prompt again. This lets the two work together. - **One part per stage.** A snapshot holds every stage's running state, used K/V pages and checkpoints, and the draft-layer K/V on the stage that carries it. Host K/V stays flat, in stage order with the drafter last, so the cache's reuse of retained pages works as before; only running state is per stage, the way `ConversationCheckpoint::stage_parts` already stored it. - **Each part names its carve.** `ConversationCheckpoint` records `layer_lo`/`layer_hi`: two same-sized carves with different QSA ordinals cannot be told apart by sizes alone, so a part can never be restored into a stage that runs other layers. - **Validate everything, then write.** `conversation_snapshot_validate` checks every part against its own stage before anything is restored, as the single-GPU path already did. - **Each stage on its own device.** Capture and restore drain each stage inside its own `OnDevice` scope and copy there. (`cudaDeviceSynchronize` drains only the current device, so a single sync on stage 0's card would have read a later stage's state while its kernels might still be writing it.) Stage 0 is named as device 0 instead of -1. - **Split checkpoints taken mid-prompt** (`--prompt-cache-every`) now copy the carve too; without it every park of a conversation longer than 16K tokens was refused as "a checkpoint from another session layer carve". - `tools/conversation_cache_parity.py` builds the engine arguments the way the server does, so on several GPUs it tests the layer split instead of one card. ## Tests - `conversation_validation_test` gains a two-stage split fixture (host only): parts, carves, mismatched stage counts and carves, and two checks that a later stage is written, and read during capture, only after its own device was drained. 1008 checks host-only; `conversation_transfer_test` 1608. That test now also wraps `cudaGetDevice` and `cudaSetDevice` (it defined the wrappers, but the link did not use them, so on a machine without a GPU the device never changed and the fixture failed on its own harness); with them it passes, and it fails again with the per-stage `OnDevice` scopes removed. Built in the CUDA 13.0 image (`-DSTRATA_BUILD_CONVERSATION_TESTS=ON`). - `conversation_cache_test` (4175 checks) unchanged; `conversation_snapshot_test` call sites take a stage vector. - On GPUs: `tools/conversation_cache_parity.py --scenario reuse` with the layer split: A/B/A, greedy, tokens and main-model state byte-exact against a run without parking (see Measured). ## Measured IQ3_S on an RTX 5060 Ti 16 GB + RTX 2000 Ada 16 GB (`layer_split 30`), Ryzen 7 9700X, 64 GB RAM. Measured on our own branch: v0.1.38 merged with this code plus unrelated patches of ours (the parking code is the same as here), `--conversation-cache-mib 1024`. `--scenario reuse`: PASS, byte-exact. A ~2K-token conversation is a 254 MiB snapshot across both stages, parked in ~55 ms and restored in ~18 ms (from its live end) to ~20 ms (from a checkpoint). The same A/B/A also passed on IQ2_XS with the earlier 0.1.34-based version of this code. Developed with an AI coding assistant; all numbers measured on the machine above (Linux, CUDA 13). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:05 +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#2783
No description provided.