[PR #5452] Metal: restore spare pooled row on checkpoint rewind and rebind session in window_init #5432

Open
opened 2026-11-07 16:35:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5452
Author: @devlier
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: fix/metal-checkpoint-restore-and-rebind


📝 Commits (1)

  • efa1de8 Metal: restore spare pooled row on checkpoint rewind and rebind session in window_init

📊 Changes

1 file changed (+5 additions, -0 deletions)

View changed files

📝 metal/src/engine/window.cpp (+5 -0)

📄 Description

Summary

Follow-up to d01b1817 (Metal: conversations park and restore (#4730, #4144)):

  1. Restore the moving spare pooled_ row in Window::checkpoint_restore:

    • Per src/core/conversation_snapshot.cpp (const int64_t pooled = index && upto > 0 ? upto / s.idx_block + 1 : 0) and CUDA's conversation_checkpoint_restore (src/core/conversation_state.cpp:429-432), rewinding to an earlier turn checkpoint must also restore c.dead into the spare pooled row row = c.ids.size() / 4.
    • Adds the bounds-checked std::memcpy((uint8_t*) pooled_[j].ptr + row * dsz, c.dead.data() + j * dsz, dsz) in Window::checkpoint_restore.
  2. Always bind SessionState in window_init when x->ready() is already true:

    • Previously bind_session(ss) was only invoked inside Window::init on the first !x->ready() call. If window_ensure initialized the singleton window earlier or window_init is called with a re-initialized SessionState, x->bind_session(ss) ensures ss.qsa_states is always bound to the window's K/V buffers.

Verification

  • Built on Apple M4 Max (STRATA_GPU_METAL=1).
  • Verified conversation_memory_test (31 checks), conversation_cache_test (4,842 checks), conversation_validation_test (972 checks), and end-to-end 5,733-token multi-session park/restore (std::memcmp == 0).

🔄 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/5452 **Author:** [@devlier](https://github.com/devlier) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/metal-checkpoint-restore-and-rebind` --- ### 📝 Commits (1) - [`efa1de8`](https://github.com/Niko1221/Strata/commit/efa1de8af142bd5b64c773650746b991fcce714d) Metal: restore spare pooled row on checkpoint rewind and rebind session in window_init ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `metal/src/engine/window.cpp` (+5 -0) </details> ### 📄 Description ## Summary Follow-up to `d01b1817` (`Metal: conversations park and restore (#4730, #4144)`): 1. **Restore the moving spare `pooled_` row in `Window::checkpoint_restore`**: - Per `src/core/conversation_snapshot.cpp` (`const int64_t pooled = index && upto > 0 ? upto / s.idx_block + 1 : 0`) and CUDA's `conversation_checkpoint_restore` (`src/core/conversation_state.cpp:429-432`), rewinding to an earlier turn checkpoint must also restore `c.dead` into the spare pooled row `row = c.ids.size() / 4`. - Adds the bounds-checked `std::memcpy((uint8_t*) pooled_[j].ptr + row * dsz, c.dead.data() + j * dsz, dsz)` in `Window::checkpoint_restore`. 2. **Always bind `SessionState` in `window_init` when `x->ready()` is already true**: - Previously `bind_session(ss)` was only invoked inside `Window::init` on the first `!x->ready()` call. If `window_ensure` initialized the singleton window earlier or `window_init` is called with a re-initialized `SessionState`, `x->bind_session(ss)` ensures `ss.qsa_states` is always bound to the window's K/V buffers. ## Verification - Built on Apple M4 Max (`STRATA_GPU_METAL=1`). - Verified `conversation_memory_test` (31 checks), `conversation_cache_test` (4,842 checks), `conversation_validation_test` (972 checks), and end-to-end 5,733-token multi-session park/restore (`std::memcmp == 0`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5432
No description provided.