Repository navigation
Add per-attempt logs for managed SGLang - #19166
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
|
The The new The other reds on this PR (lint, rest, rest-2, frontend, Core zoo) come from its base being older than the fixes now on main. A rebase onto main should clear them. |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
[skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
…in (#19272) ## Problem `studio/frontend/tests/load-refusal-header.test.ts` fails on main in `Frontend unit tests`, so every open PR inherits it: ``` not ok - Images, Video and chat raise the refusal under its title, with the owner's settings link AssertionError: features/chat/hooks/use-chat-model-runtime.ts missing: ? modelMemorySettingsAction() : (engineSettingsAction(message) ?? logsAction); ``` ## Cause #19166 (per-attempt logs for managed SGLang) is correct. When a managed engine fails to load, the chat toast now offers that engine's own log first: ```ts const action = refusal ? modelMemorySettingsAction() : (managedLogsAction ?? engineSettingsAction(message) ?? logsAction); ``` A refusal still gets the owner's model memory settings link. The test pinned the whole non-refusal chain as one literal string, so adding an action at its head broke it. ## Fix That one literal is replaced with a structural check of what the test is about: - a refusal shows `modelMemorySettingsAction()`; - any other failure still falls back to `engineSettingsAction(message) ?? logsAction`. Actions ahead of those, like a managed engine's own log, are allowed. The Images, Video and chat pins for the refusal check and its title are unchanged. ## Verification - `load-refusal-header.test.ts`: 7 pass here. On main, 1 of them fails. - Making a refusal show `logsAction` fails the test. - Dropping `engineSettingsAction(message)` from the chain fails the test. - The `use-chat-model-runtime.ts` from before #19166 still passes.
## Problem `studio/backend/tests/test_log_bounds.py` fails on main in the backend `(Python 3.13, g-l)` shard. It also shows on staging runs, for example for #19113: ``` TestFamiliesAreBounded::test_every_python_written_family_prunes these log families are written but never pruned: sglang (sglang-*.log) TestFamiliesAreBounded::test_a_new_family_cannot_be_added_unnoticed new log families: sglang ``` ## Cause #19166 (per-attempt logs for managed SGLang) added the `sglang` family, and its logs are pruned: `ManagedEngineLog.open` calls `prune_log_dir(directory, f"{engine}-*.log", protect = path)` after opening each attempt's file. The guard could not see that, for two reasons: - it only reads `run.py`, `log_retention.py`, `llama_cpp.py` and `lemonade_server.py`; - it looks for the literal glob `sglang-*.log`, which an f-string never contains. The reviewed list also did not name the new family. So this is a guard gap, not unbounded logs. ## Fix - `managed_engine_log.py`: prune with the `pattern` it already reads from `MANAGED_ENGINE_LOG_FAMILIES`. It is the same value, but now the family table is the one place the glob is defined. - `test_log_bounds.py`: - managed engine families are proved by running the code. `test_a_managed_engine_log_prunes_its_family_on_open` is parametrised over `MANAGED_ENGINE_LOG_FAMILIES`. It fills a temp studio home with `DEFAULT_KEEP + 5` old logs and opens a new one, then checks: - exactly `DEFAULT_KEEP` remain; - the new handle is kept; - the oldest is gone. - the source scan skips these families instead of grepping for their glob; - `sglang` joins the reviewed list. A future managed engine still fails `test_a_new_family_cannot_be_added_unnoticed` until someone adds it there, and the behavioral test covers it automatically. ## Verification - `test_log_bounds.py` and `test_managed_engine_logs.py`: 17 passed. On main, 2 fail. - Sabotage: - replacing the `prune_log_dir` call with `pass` fails `test_a_managed_engine_log_prunes_its_family_on_open[sglang]`; - adding a `vllm` entry to `MANAGED_ENGINE_LOG_FAMILIES` fails `test_a_new_family_cannot_be_added_unnoticed`.
Depends on unslothai#19166. Review the [five-file vLLM diff](Imagineer99/unsloth@0a27ec2...a2c4c9e). Both PRs target upstream main, so GitHub also shows the shared SGLang changes here until the dependency lands. If unslothai#19166 is squash-merged, this branch will need a rebase. Enable per-attempt logging for managed vLLM using the shared capture and Settings viewer. Each process launch gets its own redacted log, including automatic retries for Mamba limits and drafter compatibility. A failure's **View logs** action keeps pointing to the corresponding attempt after a retry. ### Verification 29 backend checks passed and two were skipped. All 74 frontend checks and frontend type checking passed. Real vLLM runs exercised startup failure, successful retry, exact failed-log lookup, and unload on Windows using the private WSL guest and with Unsloth running inside WSL. macOS and AMD checks were simulated. Bare-metal Linux was not exercised. ### Screenshots Settings > Logs, with two SGLang and two vLLM attempt logs placed in the Studio home. Before (merge base), the picker lists only the server log. After, it groups the SGLang and vLLM attempts under their own headings.  --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
#19296) ## Problem `studio/backend/tests/test_managed_engine_readiness_poll.py` fails on main (6 of 9 tests) and on every PR based on it, for example #19284 and #19285, which do not touch Studio: ``` > child_env["WSL_UTF8"] = "1" E TypeError: 'NoneType' object does not support item assignment ``` ## Cause Two PRs merged within an hour of each other, each green on its own base: - #19167 added `vllm` to `MANAGED_ENGINE_LOG_FAMILIES`, so a vLLM start now captures logs and, on the WSL path, sets `child_env["WSL_UTF8"] = "1"` on the environment `_wsl_command` returns (the SGLang half of this came in #19166). - #19242 added this test file. Its `_wsl_command` stub returned `(command, None)`, and its base predated #19167, so vLLM did not capture logs there and the `None` was never touched. The code is right: the real `_wsl_command` always returns `wsl_host.guest_command(...)`, whose second element is the `wsl.exe` environment dict, and `test_managed_engine_logs.py` already stubs it with `dict(os.environ)`. The stub was the part that did not match the contract. ## Fix - The stub returns `dict(os.environ)`, the same shape the real launcher hands back. - The fixture sets `UNSLOTH_STUDIO_HOME` to `tmp_path`, since the vLLM start now opens a per-attempt log under the Studio home and the tests should not write into the real one. No product code changes. ## Verification - `tests/test_managed_engine_readiness_poll.py`: 9 passed (6 failed on main before the change). - Reverting only the stub's return value back to `None` brings back the same 6 failures. - `test_managed_engine_logs.py`, `test_engine_ports.py` and this file together: 50 passed; this file under `-n 4`, 3 repeats: 27 passed.
Managed SGLang startup failures can be hard to diagnose once a user retries. This change captures a separate runtime log for each launch attempt and makes View logs open that exact file in Settings, including after a later attempt succeeds.
Verification
214 backend and 69 frontend checks passed, along with frontend type checking. Real SGLang runs exercised startup failure, successful retry, lookup of the failed attempt, and unload on Windows using the private WSL guest and with Unsloth running inside WSL. macOS and AMD checks were simulated. Bare-metal Linux was not exercised.
This PR introduces the shared capture and Settings integration used by the dependent vLLM change.
Screenshots
Settings > Logs, with SGLang attempt logs placed in the Studio home. Before (merge base), the picker lists only server logs. After, the SGLang attempts appear under their own heading.