mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1997] before_load failure/busy-refusal is ignored ("loading anyway") - two engines co-load, one dies (exit code 1) #797
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#797
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?
Originally created by @NerdyShawn on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1997
Summary: Two Strata servers sharing one GPU via reciprocal
before_loadunload hooks:/unloadanswers{"status":"busy"}mid-turn instead of preempting, butensure_loadedignores the hook's exit code and loads anyway — both engines co-load onto a full card and one dies (exit code 1).Setup. One RTX 5090 (32 GB), two Strata servers, each a 24 GiB quant (coder
:8080, chat:8081). VRAM-exclusive by design: each server'sbefore_loadrunsPOST /unloadagainst the peer before loading.What happens. A request arrives for the idle lane while the busy lane is mid-turn. The hook fires
/unload, which politely answers{"status":"busy"}— refusal, not preemption.ensure_loadedthen logsloading anyway(return code of the hook is not honored) and loads the second 24 GiB quant onto a card that still holds the first. The engine dies with exit code 1 and the server restarts it "a minute or two" later. In a 15-minute replay of realistic concurrent traffic, 17/65 consumer requests got HTTP 503 and the coder engine crash-looped 4x.Log signature (verbatim, engine log):
Workaround we shipped. The hook polls
/unloaduntil the peer reports trulyunloaded/not loaded. Two structural limits remain:before_loadruns under a hardcoded ~120 s subprocess timeout, so the poll budget is ~100 s — a 190 s peer turn outlives any sane wait, and when the poll gives up the load attempt fails as a gracefulmin_free_vram503 (better than the crash, but still a consumer-visible cliff that scales with turn length).busy+ ignored-exit-code combination means the default hook shape everyone will write (singlecurl /unload) produces silent co-load crashes. The dangerous failure is the one that looks successful.Asks.
before_loadfailure: if the hook exits nonzero (or the refusal is still in effect whenensure_loadedproceeds), refuse the request with 503 +Retry-Afterinstead of loading anyway. A temporary refusal beats a wedged engine; today the inverse is true.POST /unloadwith?wait=true, or anaccepted/busyprogress contract) so orchestration can wait on the server's terms instead of racing a hardcoded subprocess timeout.POST /unloadwith an empty body and noContent-Typeheader returns 415 — a success-shaped endpoint that silently fails the most common one-liner call; an empty-body POST arguably deserves none, or the docs should call out the header.Happy to contribute the contention-soak replay harness as a regression test. Related context: #1519 reports the same
exit code 1symptom in a single-server setup (unverified overlap, but our data shows any VRAM squeeze at load time ends in the same crash); #1853/#1034 show the orchestration patterns users are converging on. Measured swap numbers if useful: first cold swap 29.8–30.6 s, preempt-mid-28k-prefill 50.7 s, warm swap-back 13.4 s.@Niko1221 commented on GitHub (Oct 12, 2026):
Thank you, this is a clear report and the log signature made it easy to find. You are right: ensure_loaded ignored the hook's result and loaded anyway.
The fix (0.1.43.1, out now): when a before_load command exits non-zero or times out, the server now checks the card's free VRAM (the existing min_free_vram_mib check). If there is not enough room for the model it does not load: 503 with Retry-After, with the reason in the log and the message. If there is room it loads, with a warning naming the exit code (so a peer that is simply not running, where curl exits 7, does not block loading). Set "min_free_vram_mib" to your model's size for this. "before_load_strict": true always refuses on a failure, "before_load_ignore_failure": true always loads. The 120 s limit is now "before_load_timeout_s" in the config (default unchanged). For your ask 2: POST /unload?wait=1 (or ?wait=, also on /v1/unload) waits for the running turn and then unloads, so the peer can free the card on the server's terms; without wait the answer stays 409/busy as before. Tests cover failure with free and full VRAM, strict, ignore, the timeout and both wait cases.
Ask 3 (415 on an empty body without Content-Type): that is on purpose, it is the guard that stops a web page elsewhere from unloading the model with a plain form POST, so we kept it; the docs now say the header is needed (curl -X POST -H "Content-Type: application/json" ... /unload).
Meanwhile: have the hook poll /unload until the peer says unloaded/not loaded and exit non-zero otherwise, as you did; with the new version a failing hook is then a clean 503 instead of a crash. An offer to share the contention replay as a regression test is welcome.
@NerdyShawn commented on GitHub (Oct 12, 2026):
Confirmed fixed in v0.1.43.1, and covered by a GPU-free regression replay.
Upgraded to v0.1.43.1 (engine rebuilt from source, CUDA arch 120). With
before_load_strict: truethe two-server setup now behaves as the issue describes:POST /unloadwith409 {"status":"busy"};503+Retry-After, the engine is never started, and the coder is untouched (no more 4x crash-loop);POST /unload?wait=1waits for the running turn and then unloads, so the waiting lane no longer races the hook's timeout.I reproduced the 0.1.42 behaviour to confirm what changed: with strict off, the hook fails ("loading anyway"), the free-VRAM check passes because both lanes trust the peer's
/unloadto give the card back, and the second server loads onto the full card and dies — exactly the crash walk.Regression test —
serve/test_server.py,BeforeLoadContention(GPU-free, no hardware needed): two mock servers share one simulated 32 GiB card through the same reciprocalbefore_loadhooks as the report, with a guard on each engine'srestart()that records any "started onto a card the peer did not give back". Three cases: the reported core (coder mid-turn →503+Retry-After, engine never started); the 15-minute replay reduced (5 concurrent requests while the coder is busy all503, next one loads after the coder frees the card); and/unload?wait=1waiting for the running turn before unloading so the waiting lane loads.Run:
.venv/bin/python -m unittest serve.test_server.BeforeLoadContention -v— fullserve.test_serveris 311 tests, all green. I validated it by running the identical bytes against the 0.1.42 tree: all 3 fail with the old signatures; on 0.1.43.1 they pass consistently. Happy to open a PR with just the test class if wanted.@NerdyShawn commented on GitHub (Oct 31, 2026):
Fixed for us by 0.2.9 — commenting to close the loop.
Context: dual-lane RTX 5090 host, two Strata servers swapping one card via reciprocal
before_loadhooks (unload the peer, then load). Per this issue, before the fix the sequence "peer answers /unload with {status: busy}, ensure_loaded ignores the hook's failure, loads anyway" crash-looped the engine under contention (17/65 503s, 4 crashes in our 2026-10-11 soak).On v0.2.9 we can see the native handling in
serve/server.py:before_load_timeout_s(with a 503 +Retry-After: 15refusal path),before_load_ignore_failure,before_load_strict, and the matching test coverage (test_failing_before_load_with_full_vram_refuses_with_503_and_retry_after, strict-mode and timeout tests) — all tagged #1997. Combined with our polling hook (waits until the peer genuinely unloads so the browser consumer never sees the 503), the co-load failure mode is gone; our re-run of the 2026-10-11 soak scenarios passes and our three regression tests for it pass 3/3 against v0.2.9.We'll keep the inline-polling hook for swap transparency (a 503 to open-webui users, even a polite one, is worse UX than a 30 s slow first request), but the refuse-and-retry-after semantics is the right upstream default. Thanks — feel free to consider this resolved from our side.