mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4307] [Other] serve+webui: unload that works — pre-staged checkpoints, polite waits, honest answers #4993
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#4993
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/4307
Author: @sakuumomo
Created: 10/27/2026
Status: 🔄 Open
Base:
main← Head:pr/serve-unload-works📝 Commits (10+)
b39ec94serve: session ladder decision core (event join, save/restore policy, prefix fidelity)7dad123serve: ladder event intake (ConvCacheLog.drain_events) + per-session bookkeepingaafce06serve: ladder hooks the request path (save-on-switch, restore-before-forward, refuse→prefill posture)e28d04dserve+fix: ladder refusal-class registration + bounded last_prompts (Task 7 review round 1)df2f3e9serve: ladder idle-save, save-all unload, warm-restore engine start8c7bc96serve: ladder config from strata.json (park budget read from engine args)e9d4234serve+fix: ladder refuses to start without a resolvable park budget (Task 9 review round 1)3100881serve+fix: ladder join tolerance, identity-unknown switch, dirty-skipped saves, lock-scoped engine I/O (final-review wave)bde316eserve+fix(dormancy): fidelity matches a grown single-message prompt; a zero-reuse DONE unparks a park claim9adf057docs: the session ladder in DETAILS.md — the opt-in checkpoint ledger, checkpoint-everything unload, warm restore, and its two block keys📊 Changes
9 files changed (+2887 additions, -15 deletions)
View changed files
📝
docs/DETAILS.md(+14 -3)📝
serve/server.py(+295 -3)➕
serve/session_ladder.py(+761 -0)📝
serve/test_monitor.py(+15 -0)📝
serve/test_server.py(+68 -3)➕
serve/test_session_ladder.py(+632 -0)➕
serve/test_session_ladder_lifecycle.py(+550 -0)➕
serve/test_session_ladder_wiring.py(+540 -0)📝
serve/web/monitor.js(+12 -6)📄 Description
Problem and result: Before: every Unload click paid for a synchronous save on the click — 36.7 s+ for a 4 GB conversation on the owner's desktop, with the web control appearing frozen; a click while busy answered 409 claiming "a request is running" even when the engine was actually saving; if the engine died on
/unload,/v1/unloadorPOST /load, the server dropped the connection with a traceback. After: a background pass pre-stages checkpoints once the request queue has been quiet for one expected save length, so a quiet click costs teardown only (measured 2.4 s,{"status": "unloaded"}); a click during a save answers 409 in 0.6 ms with a body you can read:a request is running or the model is saving; try again when it is quiet; engine death answers 503{"error": {"type": "server_error"}}on all three routes; and the last-active session is always parked on unload whatever its size (a 4.3 GB dirty park verified live, then restored as 152,129 tokens in a 3 s prompt read). All existingstatusfields keep their values, so current clients are unaffected.Dependencies: stacked on #4306 — this branch is
main+ the ladder branch's 13 commits (..64925fb4) + 21 new commits (tipb97e6edb): review those twenty-one. If #4306 merges first, this branch re-lands cleanly onmain.Related discussion: extends the same
/load//unloadroutes the chat-header PR #3550 uses;docs/DETAILS.mdis updated in both PRs.Approach: a daemon pre-save pass consults the ladder's gates before touching the request FIFO, saves with a non-blocking FIFO grab only when one is actually possible, and estimates the quiet window from the engine's own measured save durations scaled by conversation growth (size fallback, clamped 5–600 s);
session_ladder.pre_save_idle_spins or disables the estimate (null= adaptive, number = pinned seconds, 0 = any idle moment). A refused save backs off exponentially (5 s doubled, cap 300 s) instead of hammering a failing engine or disk. Retention order: an over-cap save retires an orphan or subagent (child) checkpoint first, then an aux-sized one, with plain least-recent as the fallback — a finished subagent's checkpoint must not evict the expensive main file. WebUI: the monitor page's Unload posts?wait=240(server waits politely for a gap, strictly under the browser's ~300 s fetch timeout) and keeps its label and state-pill consistent while the control request is in flight.Validation:
Passed: full serve suite green on this branch tip and on the owner's rebuilt deploy branch (1386 passed, 17 skipped on the deploy branch rebuilt onto upstream
v0.2.8; see Failed). Live on momo 2026-10-27: quiet unload 200 in 2.4 s with no save behind it; busy click 409 in 0.6 ms with the message quoted above;?wait=240click parked 4.3 GB of dirty conversation and unloaded in 53 s; same-session restores 144,590 / 152,129 tokens with 3 s prompt reads; a manual file deletion racing an in-flight save produced a loggedrefused (io), the cooldown backed off, and the re-save landed clean 5 s later.Failed: two
serve/test_lifeline.pywatcher tests fail identically on the unmodified base on this machine (environment-sensitive, pre-existing).Not run: the post-engine-death backoff loop was not provoked live on the fleet box (pinned in the suite instead); moko renders no
session_ladderblock (build-gate verified only).Limits: the adaptive gate deliberately never opens while requests chain (a busy agent loop is never disturbed — confirmed operationally); pre-stage writes cost up to the conversation size on disk under the 16-file retention cap.
Changes since the last update (2026-11-07)
v0.2.12(123bad4a, engine 0.1.58); branch tipb97e6edb(still those 21 commits on top of the ladder branch). The same one request-path fusion as #4306: the token-seen accounting rides upstream'sseen = 0 if admission_rejected else prompt_tokens_seen(...)shape.?wait=240WebUI contract are all pinned in that suite unchanged. Owner flavor builds (HIP gfx1030, CUDA+HIP hybrid gfx1150) green with installCheck on the redeployed trainnixos@c3e4cdc4. The runtime-requirements and title jobs are green on the new head; the PR is mergeable against currentmain.Commits were re-signed (GPG ed25519) on 2026-11-07 after rebasing onto upstream
v0.2.12(123bad4a); trees are unchanged from the originally validated work; branch tipb97e6edb; the pre-rebase tipb764970estays fetchable as an ancestor of the train tagpin-f6f00908.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.