[PR #35] [MERGED] Conversation slots that outlive the engine, and a graceful stop #292

Closed
opened 2026-10-29 21:23:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/35
Author: @ksanislo
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @mw00

Base: main ← Head: persistent-slots


📝 Commits (2)

  • 957befb conversation slots that outlive the engine (STRATA_GLM_SLOT_KEEP=1), and a server that ends the engine on SIGTERM
  • ca119a5 shutdown: a request in progress is wrapped up - its thinking closed, its answer written (STRATA_ENGINE_WRAP_S, 40 s) - then the engine ends and keeps its conversation

📊 Changes

3 files changed (+258 additions, -24 deletions)

View changed files

📝 README.md (+4 -1)
📝 serve/server.py (+82 -1)
📝 src/program/generate.cpp (+172 -22)

📄 Description

Slots are emptied at every start, so after a supervisor's idle stop (llama-swap ttl) every conversation is re-read. The server also had no SIGTERM handler: a stop killed it, the engine kept the GPUs, nothing was saved.

  • STRATA_GLM_SLOT_KEEP=1 (default off): the slot folder is kept and indexed at start; each slot gets a .meta (identity, tokens, size), written atomically; foreign/stale ones and those unused for STRATA_GLM_SLOT_DAYS (7) are removed; the conversation in the model is saved when the engine ends. STRATA_GLM_SLOT_MIN may go down to 1.
  • SIGTERM = Ctrl+C (a second one is ignored). On a stop: queued requests are refused; the running one gets WRAP (thinking closed, answer written) for up to STRATA_ENGINE_WRAP_S (40 s), then STOP; then QUIT within STRATA_ENGINE_QUIT_S (50 s). The engine ignores SIGTERM/SIGINT/SIGPIPE in --serve; QUIT also cancels a request in flight.
  • README: Tuning rows.

Measured - Maya-M, 4x T4: after SIGTERM + restart a ~4K-token conversation continued reading 136 new tokens (taken back in 0.2 s; saved in 0.3 s; ~62 KB/token). A stop 24 s into high-effort thinking: thinking closed 0.7 s later, answer streamed, cut at 40 s with finish_reason: length, queued request refused, conversation saved, server and engine gone 44 s after SIGTERM. Server tests pass.

Not tested: Windows.


🔄 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/mw00/project-maya/pull/35 **Author:** [@ksanislo](https://github.com/ksanislo) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `persistent-slots` --- ### 📝 Commits (2) - [`957befb`](https://github.com/mw00/project-maya/commit/957befbe5021cd16a1a6393b7d0f78737f278365) conversation slots that outlive the engine (STRATA_GLM_SLOT_KEEP=1), and a server that ends the engine on SIGTERM - [`ca119a5`](https://github.com/mw00/project-maya/commit/ca119a5c3b0b2705ef253eae198c614573d04e24) shutdown: a request in progress is wrapped up - its thinking closed, its answer written (STRATA_ENGINE_WRAP_S, 40 s) - then the engine ends and keeps its conversation ### 📊 Changes **3 files changed** (+258 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+4 -1) 📝 `serve/server.py` (+82 -1) 📝 `src/program/generate.cpp` (+172 -22) </details> ### 📄 Description Slots are emptied at every start, so after a supervisor's idle stop (llama-swap `ttl`) every conversation is re-read. The server also had no SIGTERM handler: a stop killed it, the engine kept the GPUs, nothing was saved. - `STRATA_GLM_SLOT_KEEP=1` (default off): the slot folder is kept and indexed at start; each slot gets a `.meta` (identity, tokens, size), written atomically; foreign/stale ones and those unused for `STRATA_GLM_SLOT_DAYS` (7) are removed; the conversation in the model is saved when the engine ends. `STRATA_GLM_SLOT_MIN` may go down to 1. - SIGTERM = Ctrl+C (a second one is ignored). On a stop: queued requests are refused; the running one gets WRAP (thinking closed, answer written) for up to `STRATA_ENGINE_WRAP_S` (40 s), then STOP; then QUIT within `STRATA_ENGINE_QUIT_S` (50 s). The engine ignores SIGTERM/SIGINT/SIGPIPE in `--serve`; QUIT also cancels a request in flight. - README: Tuning rows. **Measured** - Maya-M, 4x T4: after SIGTERM + restart a ~4K-token conversation continued reading 136 new tokens (taken back in 0.2 s; saved in 0.3 s; ~62 KB/token). A stop 24 s into high-effort thinking: thinking closed 0.7 s later, answer streamed, cut at 40 s with `finish_reason: length`, queued request refused, conversation saved, server and engine gone 44 s after SIGTERM. Server tests pass. Not tested: Windows. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:52 +07:00
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#292
No description provided.