Repository navigation
Studio: do not download PyTorch Clef for an over-long decision request - #16509
Conversation
…he stop (#16525) ## Summary `studio/backend/tests/test_inference_worker_shutdown_exit.py::test_shutdown_exit_still_relays_the_mirrored_stderr_tail` (added in #16338) fails intermittently in `(Python 3.13, g-r)`. In the last 30 PRs it hit #16495, #16496, #16498, #16500 and #16509: ``` assert "the last line before shutdown" in result.stderr E assert 'the last line before shutdown' in '' ``` That is a real product bug, not a flaky test. The worker can drop its last stderr lines when it exits, which are the lines the parent reports when a worker dies. **Cause.** `_tail_sink_to_stderr`, the mirror pump thread, decided it was done from two separate steps: a read that came back empty, then a check that `stop` was set. If the pump is descheduled between those two steps, the worker writes its last lines to the sink and calls `stop_worker_stderr_mirror()` in the gap. The pump then sees "empty read, and stop is set", exits, and never relays them. I instrumented the stop sequence in a child that runs the test's exact script, 900 times on 24 threads. On a failing run: - the sink held all 1720 bytes at stop time; - the pump made exactly one read, which returned empty and was logged after the stop; - it emitted 0 bytes, and both threads ended cleanly within 4 ms. So nothing timed out and nothing was cut off; the lines were simply never read. ## Change `studio/backend/utils/worker_stderr.py`, `_tail_sink_to_stderr`: the pump records `stop.is_set()` before each read and only finishes on an empty read that began after the stop was set. Bytes written before `stop.set()` are therefore always read. Nothing else changes: the poll interval, compaction, the relay, the join timeouts, and what a live worker mirrors. `studio/backend/tests/test_inference_worker_shutdown_exit.py`: new `test_the_pump_reads_once_more_after_an_empty_read_that_raced_the_stop`. It drives the pump with a reader whose first read returns empty and sets `stop` in that same call, so the race is forced deterministically rather than left to scheduling. ## Testing | check | main | this branch | |---|---|---| | instrumented child, 300 / 600 / 900 parallel runs | 1 lost the whole tail in each batch | 0 of 900 | | new deterministic test | fails (`b'' == b'the last line before shutdown\n'`) | passes | | `test_shutdown_exit_still_relays_the_mirrored_stderr_tail`, `--count 40 -n 16` | 1 failed of 40 | 240 of 240 passed (`--count 80 -n 16`, three times) | - `test_inference_worker_shutdown_exit.py` and `test_inference_worker_stderr_tail.py`: 77 passed.
## Summary Since #16414 (`9a8b229714`), `Repo tests (CPU, rest-2)` has been failing on unrelated PRs. It reproduces on current main, and it hit #16540 and #16509 in runs created after #16531 merged: ``` tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding[2] E AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding, so they break on Windows as soon as that file gains a non-ASCII byte. Pass encoding = "utf-8": ['tests/test_multi_lora_scale_overflow_cpu.py:20: read_text()'] ``` The new test from #16414 parses `unsloth/kernels/multi_lora.py` with a bare `read_text()`. That is the same pattern #16531 fixed in `test_multi_lora_cold_compile_cpu.py`. The guard is right: on Windows, a bare read uses the locale code page, so this test would break as soon as the kernel file gains a non-ASCII character. The kernel change in #16414 is fine. ## Change `tests/test_multi_lora_scale_overflow_cpu.py` line 20: `read_text()` becomes `read_text(encoding = "utf-8")`. ## Testing - `tests/test_source_read_encoding.py`: - main: 1 failed, 15 passed (the case above); - this branch: passes. - This branch, `tests/test_source_read_encoding.py` plus `tests/test_multi_lora_scale_overflow_cpu.py`: 28 passed.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
With the Decision API on Auto, a request longer than the llama.cpp context fell back to PyTorch Clef without checking it was on disk. One long request could start a 19 to 55 GB download, evict llama.cpp, and leave PyTorch serving every later request.
The fallback now needs PyTorch Clef already downloaded. Otherwise the request gets the usual 422 and llama.cpp stays loaded. When it is downloaded, the fallback works as before.
A llama-server that does not serve decisions still falls back to PyTorch as before, including the download.