[PR #2435] [CLOSED] [Other] serve: return 503 when the elastic image encoder cannot start #4044

Closed
opened 2026-11-07 15:32:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2435
Author: @i-Vladimir-i
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: vision-elastic-split


📝 Commits (3)

  • a38d24b [Codex]: return 503 when an elastic image encoder cannot start
  • de511d3 [Codex]: cover elastic encoder HTTP retries and recovery
  • d7059eb [Codex]: update elastic vision tests on current main and cover real startup failures

📊 Changes

4 files changed (+183 additions, -6 deletions)

View changed files

📝 docs/VRAM_ELASTIC.md (+3 -1)
📝 serve/server.py (+16 -4)
📝 serve/test_vision_elastic.py (+24 -1)
➕ serve/test_vision_elastic_http.py (+140 -0)

📄 Description

Problem and result

When an elastic image encoder fails to restart, its exception escapes request preparation and the client gets a closed connection.
Return HTTP 503 with the startup reason instead. Later image requests retry; text requests and recovery after a successful start keep working.
Log an idle encoder stop even when its cache shrink was refused, and warn that a layer split needs a static reserve for the encoder.

Continues this PR and the server-side report in #2196. Updated onto main 5c8dd322528cc84f68f461ad54a506b9da8fa8d4 (0.2.3).
The newer image-start and tool-picture paths do not replace all of this elastic-start/idle-stop fix.

Draft: the common CI-stability prerequisite is #3590, by justindressler, head acb05a7fe948204ed556a618de8d28063cd80c1d; also tracked in #3407.
That PR fixes process identity in the portable watcher and a telemetry-sampler failure. It is still unmerged.
In line with CONTRIBUTING's one-problem-per-PR rule, its code is not bundled here: serve/lifeline.py, serve/telemetry.py, serve/test_responses.py and CI workflows are identical to main in this branch.
The combination was tested separately below. Please land/review #3590 independently; after it lands I will merge the updated main and rerun the standalone checks before marking this PR ready.
This is a CI-stability prerequisite, not a new functional dependency of the HTTP 503 handler.

No retries, skips, weakened assertions or workflow changes are used to hide the watcher failure. One green test run does not fix it:
a controlled sleeping-to-running state transition still changes the old ps lstart,stat identity on both main and this branch,
so the watcher leaves its child alive after pipe EOF. With #3590 the identity is stable and the child ends;
the wrong-identity and explicit-release guards still preserve the child.

Approach

Use the existing EngineDied/HTTP 503 path for an exception from the elastic encoder's restart().
Keep the success/retry path and cache behavior. The idle-stop log is outside the cache-grow condition.
Only server Python, vision regression tests and docs/VRAM_ELASTIC.md change; no native backend, default or process-supervision changes.

The new Linux regression starts a real temporary encoder program which exits with code 71.
For chat/messages/responses, streamed and non-streamed, and two attempts, it checks HTTP 503, a fresh child per attempt, and that each child is reaped (12 cases).
This is a real subprocess startup-failure test, not a CUDA allocation-failure test.

Validation: 2026-10-23

Exact submitted head: d7059ebe0a43b5245b811757ccb3d7e8edcd74cf.
Environment: Linux x86_64, Python 3.12.3, existing runtime-only dev venv, localhost fake-engine fixtures; GPUs hidden.
Dependency comparisons apply the unchanged #3590 patch only in separate dev trees (patch SHA-256 527ce611a6f32231e19e6809f16713e6b288e2ea63d7b8b245cbff98eea1d93c).
No production service, config or binary was changed.

Passed

  • python -m unittest serve.test_vision_elastic serve.test_vision_elastic_http serve.test_vision_start_error serve.test_vision_tool_image serve.test_vision_token_limit serve.test_ready_timeout -v: 34 tests, no skips, exit 0.

  • Full discovery with no test exclusions, python -m unittest discover -s serve -p 'test_*.py' -v:

    Tree Total Passed Failures/errors Skipped Exit
    main 5c8dd322 + #3590 974 948 0 26 0
    submitted d7059ebe alone 979 953 0 26 0
    submitted d7059ebe + #3590 979 953 0 26 0

    Recorded unittest times: 336.802 / 337.054 / 338.150 s respectively. These are validation durations, not performance benchmarks.
    The same 26 skips are Anthropic SDK (3), pack tokenizer fixtures (5), jsonschema (3), Node not on the initial PATH (12), and Windows (3).

  • Replayed the 12 Node tests using the already installed Node runtime: python -m unittest serve.test_web_api_key serve.test_web_sampling -v, 12/12, exit 0. No package installation.

  • The CI smoke script, python tools/minimal_server_smoke.py --report <new-absolute-report-path>, passes on the submitted head:
    43 passed, 4 skipped out of 47, exit 0, 108.104 s. The venv has numpy/jinja2/requests and no rich/textual.
    The dev venv's unrelated editable gguf-py tree first shadowed the repository's tests namespace; the unchanged smoke script was rerun with only that import path removed through a process-local sitecustomize. Neither the venv nor repository code was changed for this isolation.

  • Controlled S/R identity, EOF, wrong-identity and release checks on main, submitted head and submitted head + #3590; the first two reproduce the known bug and the last removes it.

  • git diff --check; submitted source stays clean. Its diff against main is limited to four vision/docs files.

Failed / negative controls

  • New GitHub CI on the submitted d7059ebe, Python 3.11.17:
    the runtime-only smoke passed (43 passed / 4 skipped out of 47, 108.557 s). Full server discovery ran 979 tests in 339.807 s:
    964 passed, 14 skipped, one failure, exactly test_lifeline.Lifeline.test_the_portable_watcher_ends_the_child_when_the_server_is_killed
    (the child outlived a killed server (watcher)). No other failure/error was reported. This matches the separately reproduced #3590 prerequisite;
    the vision regressions passed. The failed job is retained, not rerun, and this PR stays in draft.
  • The new real-child regression against unmodified main gives 12 dropped-response errors. The submitted head passes all 12 cases.
  • The old GitHub Minimal serving runtime failure on de511d39 remains historical evidence of the common watcher bug. Its deterministic reproduction still fails on the current main and submitted code; the successful standalone full-suite run above is not claimed to repair it.
  • Before process-local import isolation, the smoke script failed with ModuleNotFoundError: tests.terminal on both unchanged main and the candidate. The source was not patched to work around the dev venv.

Not run

  • Fresh GPU/model inference, a real CUDA layer-split OOM, or Windows/macOS execution. The Linux reaping regression is explicitly skipped elsewhere.
  • Please help validate on a CUDA layer split: encoder startup failure returns 503, the next image retries, recovery succeeds, and idle stop is logged when cache shrink was refused. This hardware check and the common CI prerequisite keep the PR in draft.
  • A new Python 3.11 CI environment was not installed on the dev host; GitHub uses 3.11, while the local checks use the existing 3.12.3 venv.
  • Native builds are not applicable to this Python/docs-only change. No performance or hardware-compatibility claim.

Limits

This fixes the HTTP failure/retry path. It does not add per-stage elastic caches or make a layer split free VRAM for the encoder.
No duplicate #3590 implementation and no claim that its unmerged fix is already upstream.


🔄 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/2435 **Author:** [@i-Vladimir-i](https://github.com/i-Vladimir-i) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `vision-elastic-split` --- ### 📝 Commits (3) - [`a38d24b`](https://github.com/Niko1221/Strata/commit/a38d24b30ae323f4fc3689a7773ea9d6038c1f96) [Codex]: return 503 when an elastic image encoder cannot start - [`de511d3`](https://github.com/Niko1221/Strata/commit/de511d394a8f8e35bef25d06df8d35d28845692a) [Codex]: cover elastic encoder HTTP retries and recovery - [`d7059eb`](https://github.com/Niko1221/Strata/commit/d7059ebe0a43b5245b811757ccb3d7e8edcd74cf) [Codex]: update elastic vision tests on current main and cover real startup failures ### 📊 Changes **4 files changed** (+183 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/VRAM_ELASTIC.md` (+3 -1) 📝 `serve/server.py` (+16 -4) 📝 `serve/test_vision_elastic.py` (+24 -1) ➕ `serve/test_vision_elastic_http.py` (+140 -0) </details> ### 📄 Description ## Problem and result When an elastic image encoder fails to restart, its exception escapes request preparation and the client gets a closed connection. Return HTTP 503 with the startup reason instead. Later image requests retry; text requests and recovery after a successful start keep working. Log an idle encoder stop even when its cache shrink was refused, and warn that a layer split needs a static reserve for the encoder. ## Related discussion and CI prerequisite Continues this PR and the server-side report in #2196. Updated onto main `5c8dd322528cc84f68f461ad54a506b9da8fa8d4` (0.2.3). The newer image-start and tool-picture paths do not replace all of this elastic-start/idle-stop fix. **Draft: the common CI-stability prerequisite is #3590**, by `justindressler`, head `acb05a7fe948204ed556a618de8d28063cd80c1d`; also tracked in #3407. That PR fixes process identity in the portable watcher and a telemetry-sampler failure. It is still unmerged. In line with CONTRIBUTING's one-problem-per-PR rule, its code is **not** bundled here: `serve/lifeline.py`, `serve/telemetry.py`, `serve/test_responses.py` and CI workflows are identical to main in this branch. The combination was tested separately below. Please land/review #3590 independently; after it lands I will merge the updated main and rerun the standalone checks before marking this PR ready. This is a CI-stability prerequisite, not a new functional dependency of the HTTP 503 handler. No retries, skips, weakened assertions or workflow changes are used to hide the watcher failure. One green test run does not fix it: a controlled sleeping-to-running state transition still changes the old `ps lstart,stat` identity on both main and this branch, so the watcher leaves its child alive after pipe EOF. With #3590 the identity is stable and the child ends; the wrong-identity and explicit-release guards still preserve the child. ## Approach Use the existing `EngineDied`/HTTP 503 path for an exception from the elastic encoder's `restart()`. Keep the success/retry path and cache behavior. The idle-stop log is outside the cache-grow condition. Only server Python, vision regression tests and `docs/VRAM_ELASTIC.md` change; no native backend, default or process-supervision changes. The new Linux regression starts a real temporary encoder program which exits with code 71. For chat/messages/responses, streamed and non-streamed, and two attempts, it checks HTTP 503, a fresh child per attempt, and that each child is reaped (12 cases). This is a real subprocess startup-failure test, not a CUDA allocation-failure test. ## Validation: 2026-10-23 Exact submitted head: `d7059ebe0a43b5245b811757ccb3d7e8edcd74cf`. Environment: Linux x86_64, Python 3.12.3, existing runtime-only dev venv, localhost fake-engine fixtures; GPUs hidden. Dependency comparisons apply the unchanged #3590 patch only in separate dev trees (patch SHA-256 `527ce611a6f32231e19e6809f16713e6b288e2ea63d7b8b245cbff98eea1d93c`). No production service, config or binary was changed. ### Passed - `python -m unittest serve.test_vision_elastic serve.test_vision_elastic_http serve.test_vision_start_error serve.test_vision_tool_image serve.test_vision_token_limit serve.test_ready_timeout -v`: **34 tests**, no skips, exit 0. - Full discovery with no test exclusions, `python -m unittest discover -s serve -p 'test_*.py' -v`: | Tree | Total | Passed | Failures/errors | Skipped | Exit | | --- | ---: | ---: | ---: | ---: | ---: | | main `5c8dd322` + #3590 | 974 | 948 | 0 | 26 | 0 | | submitted `d7059ebe` alone | 979 | 953 | 0 | 26 | 0 | | submitted `d7059ebe` + #3590 | 979 | 953 | 0 | 26 | 0 | Recorded unittest times: 336.802 / 337.054 / 338.150 s respectively. These are validation durations, not performance benchmarks. The same 26 skips are Anthropic SDK (3), pack tokenizer fixtures (5), jsonschema (3), Node not on the initial PATH (12), and Windows (3). - Replayed the 12 Node tests using the already installed Node runtime: `python -m unittest serve.test_web_api_key serve.test_web_sampling -v`, **12/12**, exit 0. No package installation. - The CI smoke script, `python tools/minimal_server_smoke.py --report <new-absolute-report-path>`, passes on the submitted head: **43 passed, 4 skipped out of 47**, exit 0, 108.104 s. The venv has numpy/jinja2/requests and no rich/textual. The dev venv's unrelated editable gguf-py tree first shadowed the repository's `tests` namespace; the unchanged smoke script was rerun with only that import path removed through a process-local `sitecustomize`. Neither the venv nor repository code was changed for this isolation. - Controlled S/R identity, EOF, wrong-identity and release checks on main, submitted head and submitted head + #3590; the first two reproduce the known bug and the last removes it. - `git diff --check`; submitted source stays clean. Its diff against main is limited to four vision/docs files. ### Failed / negative controls - New [GitHub CI on the submitted `d7059ebe`](https://github.com/Niko1221/Strata/actions/runs/39937461873/job/120360405232), Python 3.11.17: the runtime-only smoke passed (43 passed / 4 skipped out of 47, 108.557 s). Full server discovery ran 979 tests in 339.807 s: **964 passed, 14 skipped, one failure**, exactly `test_lifeline.Lifeline.test_the_portable_watcher_ends_the_child_when_the_server_is_killed` (`the child outlived a killed server (watcher)`). No other failure/error was reported. This matches the separately reproduced #3590 prerequisite; the vision regressions passed. The failed job is retained, not rerun, and this PR stays in draft. - The new real-child regression against unmodified main gives **12 dropped-response errors**. The submitted head passes all 12 cases. - The old [GitHub Minimal serving runtime failure](https://github.com/Niko1221/Strata/actions/runs/39648378521) on `de511d39` remains historical evidence of the common watcher bug. Its deterministic reproduction still fails on the current main and submitted code; the successful standalone full-suite run above is not claimed to repair it. - Before process-local import isolation, the smoke script failed with `ModuleNotFoundError: tests.terminal` on both unchanged main and the candidate. The source was not patched to work around the dev venv. ### Not run - Fresh GPU/model inference, a real CUDA layer-split OOM, or Windows/macOS execution. The Linux reaping regression is explicitly skipped elsewhere. - Please help validate on a CUDA layer split: encoder startup failure returns 503, the next image retries, recovery succeeds, and idle stop is logged when cache shrink was refused. This hardware check and the common CI prerequisite keep the PR in draft. - A new Python 3.11 CI environment was not installed on the dev host; GitHub uses 3.11, while the local checks use the existing 3.12.3 venv. - Native builds are not applicable to this Python/docs-only change. No performance or hardware-compatibility claim. ## Limits This fixes the HTTP failure/retry path. It does not add per-stage elastic caches or make a layer split free VRAM for the encoder. No duplicate #3590 implementation and no claim that its unmerged fix is already upstream. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:32:44 +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#4044
No description provided.