[PR #2822] [Engine] Opt-in single-engine preemption for short requests #4282

Open
opened 2026-11-07 15:34:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2822
Author: @Zcg2021
Created: 10/16/2026
Status: 🔄 Open

Base: main ← Head: codex/solo-priority


📝 Commits (10+)

  • 636e745 feat(server): add opt-in cooperative priority for single-engine requests
  • b46002f docs(bench): make base Qwen validation primary for solo priority
  • 82a9de8 fix(server): retain restored prefixes before priority preemption
  • 99ab65f test(server): add reproducible multi-conversation priority soak
  • f01cb81 fix(server): preserve exception identity for script-launched priority streams
  • 4a44890 docs(bench): record original-model soak and corrected lifecycle validation
  • 35e4415 fix(server): adapt solo priority to beta queue lifecycle
  • f3063c1 fix(server): report admitted solo requests in terminal telemetry
  • 7fc67ec docs(bench): revalidate single-engine priority on 0.2.0-beta
  • 8155100 test(server): preserve declared-tool restriction through solo priority

📊 Changes

51 files changed (+11254 additions, -10 deletions)

View changed files

📝 README.md (+4 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-original/README.md (+145 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-original/results.json (+1302 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/README.md (+269 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/faults-after-requests.jsonl (+15 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/faults-before-requests.jsonl (+12 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/final-lifecycle-requests.jsonl (+15 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/native-timings.txt (+45 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/pilot-requests.jsonl (+24 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/results.json (+771 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/soak-requests.jsonl (+409 -0)
➕ bench/results/2026-10-16-solo-priority-qwen-soak/test-output.txt (+7 -0)
➕ bench/results/2026-10-16-solo-priority-rtx3090/README.md (+136 -0)
➕ bench/results/2026-10-16-solo-priority-rtx3090/make_fixture.py (+75 -0)
➕ bench/results/2026-10-16-solo-priority-rtx3090/results.json (+1021 -0)
➕ bench/results/2026-10-19-solo-priority-v020-beta/README.md (+186 -0)
➕ bench/results/2026-10-19-solo-priority-v020-beta/injected-engine-exit.json (+4 -0)
➕ bench/results/2026-10-19-solo-priority-v020-beta/lifecycle-after-engine-recovery.json (+17 -0)
➕ bench/results/2026-10-19-solo-priority-v020-beta/lifecycle-after-failure-delivery.json (+7 -0)
➕ bench/results/2026-10-19-solo-priority-v020-beta/lifecycle-after-requests.jsonl (+15 -0)

...and 31 more files

📄 Description

Problem and result

A short interactive request on a single native engine waits for a long response to finish. This experimental, opt-in Python scheduler lets a waiting higher-priority request interrupt and resume that response through the existing STOP/DONE protocol and conversation RAM cache. Only one native GEN runs at a time; it does not allocate batch slots or change defaults.

#2821; #2109 concerns batch admission rather than interruption of an already-running single-engine response. Maintainer scope agreement is still requested in #2821. This existing PR remains draft pending that discussion and hardware validation on the current base.

Approach

The scheduler drains all accepted tokens through DONE before changing ownership. Continuation uses original token IDs and keeps the original stream parser, UTF-8 decoder and tool-call identity alive. Minimum run time and waiting-age priority prevent short requests from indefinitely starving long work. Parked cancellation does not stop another owner; engine death fails affected streams.

The current rebase is onto main 870aedd9e1ebe1c91f94da93b59af17729f6c5c0 (0.2.8). README retains upstream's new layout. The rebase also preserves the new prefill_only argument when the normal generator is extracted into _generate_single; an uncorrected automatic merge raised NameError on an ordinary request. split_serve is explicitly rejected with solo_priority, because its proxy forwards single-engine attributes despite using two engines. Regression tests cover the default prefill-only protocol, invalid calls, split-mode rejection and logprob ownership across actual simulated preemption/resumption.

No native source, model, tokenizer or cache-format changes. Production Maya/Strata services and settings were not changed for this update.

Validation

Tested revision: 1e1b2672eb104d4b4c56020ba529feeaeffa2646, 2026-10-30. Pinned runtime requirements in isolated environments; protocol/streaming tests use fake engines, not real GPUs.

Passed:

  • macOS / Python 3.13.0: python -m unittest serve.test_solo_priority serve.test_logprobs serve.test_split -v: 73 tests, OK, 25.258 s. Covers interruption/resumption, queued/active/parked cancellation, engine death, UTF-8, tool arguments, usage, logprobs and split-serving compatibility.
  • macOS: python tools/minimal_server_smoke.py --report <new-absolute-path>: 51 tests, OK (4 skipped), 103.346 s.
  • Portable monitor CI: all four Linux/Windows × Python 3.10/3.11 jobs passed on the tested revision.
  • Ubuntu / Python 3.11: python -m unittest discover -s serve -p 'test_*.py': 1278 tests, OK (17 skipped), 424.214 s. Runtime smoke: 51 tests, OK (4 skipped), 106.664 s. CI on the tested commit.
  • git diff --check origin/main: passed.

Failed attempts:

  • Initial rebase preflight, before the compatibility fix: python -m unittest serve.test_solo_priority.Streaming.test_terminal_state_tracks_an_admitted_solo_request -v: 1 test, 1 error (NameError: name 'prefill_only' is not defined). Corrected in the tested revision; included in the passing focused suite above.

Not run:

  • Native CUDA/HIP/SYCL/Metal builds/execution, current real-model speed/quality comparisons or a new soak. No native source was modified. This update does not establish native performance or correctness on 0.2.8; active user services were left running.

Earlier hardware evidence (not rerun on this base)

  • 0.2.0-beta report, configuration and raw results: original non-abliterated Qwen IQ3_S, RTX 3090, Windows 11. Three flag-off/on pairs reduced median short TTFT from 20.523 to 0.610 s, with aggregate throughput 111.29 to 107.88 tok/s (-3.1%). The one-hour soak recorded 424 requests, 410 completions, 14 intentional cancellations and 290 preemptions, with no unexpected transport errors or validation failures. These are workload-specific historical measurements.
  • 0.2.2 report and raw data: same original model family and native CUDA lifecycle checks, including cancellation and tool round trips. The report retains failed attempts and upstream controls.

Limits

Cold/partial-cache-hit prefill and restoration can still delay short requests. Historical soak short TTFT reached 46.663 s while reading an unfinished long prefix; this is not a real-time latency guarantee. Restored partial prefill reaches its first generated token before yielding to avoid discarding the checkpoint. Images and checkpoint opt-outs are non-preemptible. Batch, replicas and split serving cannot be combined with this option. The feature stays off by default; no universal speedup or token-identical native sampling across separate runs is claimed.


🔄 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/2822 **Author:** [@Zcg2021](https://github.com/Zcg2021) **Created:** 10/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/solo-priority` --- ### 📝 Commits (10+) - [`636e745`](https://github.com/Niko1221/Strata/commit/636e745298222865fa5284c680635cc5d05a6f02) feat(server): add opt-in cooperative priority for single-engine requests - [`b46002f`](https://github.com/Niko1221/Strata/commit/b46002f5d6df142ed30d3d5aec7b491769603a7b) docs(bench): make base Qwen validation primary for solo priority - [`82a9de8`](https://github.com/Niko1221/Strata/commit/82a9de81b99afd92c56a1ca11f836fce925d2a32) fix(server): retain restored prefixes before priority preemption - [`99ab65f`](https://github.com/Niko1221/Strata/commit/99ab65f94257072dcde07c1176a0ef8de96275e2) test(server): add reproducible multi-conversation priority soak - [`f01cb81`](https://github.com/Niko1221/Strata/commit/f01cb81263883ae62331632b753795f5d89935c9) fix(server): preserve exception identity for script-launched priority streams - [`4a44890`](https://github.com/Niko1221/Strata/commit/4a44890e5a732d4a6e2b800c1fc56d7b67c86a94) docs(bench): record original-model soak and corrected lifecycle validation - [`35e4415`](https://github.com/Niko1221/Strata/commit/35e44150af91cd13753d33613295284b54c817e9) fix(server): adapt solo priority to beta queue lifecycle - [`f3063c1`](https://github.com/Niko1221/Strata/commit/f3063c10eba531017a1c27dd8db1fe1eb25d6dd4) fix(server): report admitted solo requests in terminal telemetry - [`7fc67ec`](https://github.com/Niko1221/Strata/commit/7fc67ecaabece5442bbd4410182f9bbf91f965f4) docs(bench): revalidate single-engine priority on 0.2.0-beta - [`8155100`](https://github.com/Niko1221/Strata/commit/815510047597086690dd41b1fcb3750399c6d1f4) test(server): preserve declared-tool restriction through solo priority ### 📊 Changes **51 files changed** (+11254 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+4 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-original/README.md` (+145 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-original/results.json` (+1302 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/README.md` (+269 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/faults-after-requests.jsonl` (+15 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/faults-before-requests.jsonl` (+12 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/final-lifecycle-requests.jsonl` (+15 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/native-timings.txt` (+45 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/pilot-requests.jsonl` (+24 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/results.json` (+771 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/soak-requests.jsonl` (+409 -0) ➕ `bench/results/2026-10-16-solo-priority-qwen-soak/test-output.txt` (+7 -0) ➕ `bench/results/2026-10-16-solo-priority-rtx3090/README.md` (+136 -0) ➕ `bench/results/2026-10-16-solo-priority-rtx3090/make_fixture.py` (+75 -0) ➕ `bench/results/2026-10-16-solo-priority-rtx3090/results.json` (+1021 -0) ➕ `bench/results/2026-10-19-solo-priority-v020-beta/README.md` (+186 -0) ➕ `bench/results/2026-10-19-solo-priority-v020-beta/injected-engine-exit.json` (+4 -0) ➕ `bench/results/2026-10-19-solo-priority-v020-beta/lifecycle-after-engine-recovery.json` (+17 -0) ➕ `bench/results/2026-10-19-solo-priority-v020-beta/lifecycle-after-failure-delivery.json` (+7 -0) ➕ `bench/results/2026-10-19-solo-priority-v020-beta/lifecycle-after-requests.jsonl` (+15 -0) _...and 31 more files_ </details> ### 📄 Description ## Problem and result A short interactive request on a single native engine waits for a long response to finish. This experimental, opt-in Python scheduler lets a waiting higher-priority request interrupt and resume that response through the existing STOP/DONE protocol and conversation RAM cache. Only one native GEN runs at a time; it does not allocate batch slots or change defaults. ## Related discussion #2821; #2109 concerns batch admission rather than interruption of an already-running single-engine response. Maintainer scope agreement is still requested in #2821. This existing PR remains **draft** pending that discussion and hardware validation on the current base. ## Approach The scheduler drains all accepted tokens through DONE before changing ownership. Continuation uses original token IDs and keeps the original stream parser, UTF-8 decoder and tool-call identity alive. Minimum run time and waiting-age priority prevent short requests from indefinitely starving long work. Parked cancellation does not stop another owner; engine death fails affected streams. The current rebase is onto main `870aedd9e1ebe1c91f94da93b59af17729f6c5c0` (0.2.8). README retains upstream's new layout. The rebase also preserves the new `prefill_only` argument when the normal generator is extracted into `_generate_single`; an uncorrected automatic merge raised `NameError` on an ordinary request. `split_serve` is explicitly rejected with `solo_priority`, because its proxy forwards single-engine attributes despite using two engines. Regression tests cover the default prefill-only protocol, invalid calls, split-mode rejection and logprob ownership across actual simulated preemption/resumption. No native source, model, tokenizer or cache-format changes. Production Maya/Strata services and settings were not changed for this update. ## Validation Tested revision: `1e1b2672eb104d4b4c56020ba529feeaeffa2646`, 2026-10-30. Pinned runtime requirements in isolated environments; protocol/streaming tests use fake engines, not real GPUs. **Passed:** - macOS / Python 3.13.0: `python -m unittest serve.test_solo_priority serve.test_logprobs serve.test_split -v`: **73 tests, OK**, 25.258 s. Covers interruption/resumption, queued/active/parked cancellation, engine death, UTF-8, tool arguments, usage, logprobs and split-serving compatibility. - macOS: `python tools/minimal_server_smoke.py --report <new-absolute-path>`: **51 tests, OK (4 skipped)**, 103.346 s. - [Portable monitor CI](https://github.com/Zcg2021/Strata/actions/runs/41139029727): all four Linux/Windows × Python 3.10/3.11 jobs passed on the tested revision. - Ubuntu / Python 3.11: `python -m unittest discover -s serve -p 'test_*.py'`: **1278 tests, OK (17 skipped)**, 424.214 s. Runtime smoke: **51 tests, OK (4 skipped)**, 106.664 s. [CI on the tested commit](https://github.com/Zcg2021/Strata/actions/runs/41139029769). - `git diff --check origin/main`: passed. **Failed attempts:** - Initial rebase preflight, before the compatibility fix: `python -m unittest serve.test_solo_priority.Streaming.test_terminal_state_tracks_an_admitted_solo_request -v`: 1 test, 1 error (`NameError: name 'prefill_only' is not defined`). Corrected in the tested revision; included in the passing focused suite above. **Not run:** - Native CUDA/HIP/SYCL/Metal builds/execution, current real-model speed/quality comparisons or a new soak. No native source was modified. This update does not establish native performance or correctness on 0.2.8; active user services were left running. ## Earlier hardware evidence (not rerun on this base) - [0.2.0-beta report, configuration and raw results](https://github.com/Zcg2021/Strata/blob/4312dd7aa7cc87b6a84e2b3a7363dbdff9afc372/bench/results/2026-10-19-solo-priority-v020-beta/README.md): original non-abliterated Qwen IQ3_S, RTX 3090, Windows 11. Three flag-off/on pairs reduced median short TTFT from 20.523 to 0.610 s, with aggregate throughput 111.29 to 107.88 tok/s (-3.1%). The one-hour soak recorded 424 requests, 410 completions, 14 intentional cancellations and 290 preemptions, with no unexpected transport errors or validation failures. These are workload-specific historical measurements. - [0.2.2 report and raw data](https://github.com/Zcg2021/Strata/blob/ee75d94e05360872e59d9533f3f1199e02f85c3b/bench/results/2026-10-22-solo-priority-v022/README.md): same original model family and native CUDA lifecycle checks, including cancellation and tool round trips. The report retains failed attempts and upstream controls. ## Limits Cold/partial-cache-hit prefill and restoration can still delay short requests. Historical soak short TTFT reached 46.663 s while reading an unfinished long prefix; this is not a real-time latency guarantee. Restored partial prefill reaches its first generated token before yielding to avoid discarding the checkpoint. Images and checkpoint opt-outs are non-preemptible. Batch, replicas and split serving cannot be combined with this option. The feature stays off by default; no universal speedup or token-identical native sampling across separate runs is claimed. --- <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#4282
No description provided.