Repository navigation
Studio: cut polled-probe cost and release memory sooner - #14595
Conversation
|
@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. 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 security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
1 similar comment
|
@codex review |
…blished [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
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". |
… test (order-dependent red) (#18867) ## Summary `studio/backend/tests/test_warm_window_review_fixes.py::test_an_absent_torch_is_still_just_absent` fails whenever torch has not been imported earlier in the process. It failed on the staging cross-platform leg for #18727 (ubuntu-latest), and it fails on `main` when the file runs on its own: ``` AssertionError: a --no-torch install would be reported as a detection failure assert 'stale' is None + where 'stale' = <module 'utils.hardware.hardware'>.TORCH_IMPORT_ERROR ``` `_has_torch()` (since #14595) remembers a failed import for the current detection epoch: while `TORCH_IMPORT_ERROR` is set, `_TORCH_IMPORT_FAILED_EPOCH == DETECTION_EPOCH` and torch is not in `sys.modules`, it returns `False` without trying again. The code is right. The tests are wrong: `test_a_broken_torch_install_is_not_reported_as_a_host_without_a_gpu`, just above, records a failure (setting both globals) and then restores only `TORCH_IMPORT_ERROR`. The epoch it leaves behind makes the next `_has_torch()` short-circuit, so the absent-torch test never reaches the import it checks. In the full CI run some earlier test has usually imported torch, which disables the short-circuit, so this has been order dependent rather than always red. ## Fix An autouse fixture in that file sets `TORCH_IMPORT_ERROR` and `_TORCH_IMPORT_FAILED_EPOCH` to `None` through `monkeypatch`, so every test starts with no cached failure and both are restored afterwards. No production code changes. ## Testing - `studio/backend/tests/test_warm_window_review_fixes.py` on its own: 100 passed (`main`: 1 failed, the test above).
What changes for users
Backend-only. Less work per
/api/systempoll and per training poll, fewer stalls of the server's event loop, steadier readings, and memory freed sooner.Lag and CPU
/api/systemre-ran the Vulkan device probe (a new interpreter plus a VkInstance) about every 10 s while the Live Monitor or Settings > Resources was open, alongside generation on the same GPU. The inventory is now cached for 30 s for display reads only. Fit, placement,refresh_memory, model loads and GPU memory events still read fresh, and an empty result is never cached.asynchandlers; they now run in a worker thread, so a busy database can't freeze chat streaming.More accurate readings
psutil.cpu_percent(None)measures since the previous call from anyone, so it read 0.0 right after start and jumped around when several pollers interleaved. It is now primed at startup and sampled at most once per second.Noneon failure. On an M3 Max: utilization 0-9%, temperature ~54 C, power 0-0.2 W at idle.memory.process_tree_used_mbthat also counts child processes (llama-server, the training worker).process_used_mbis unchanged.Memory
Smaller
gpu_power_wreleases its previous sample, and with/api/systemnow reading it too, two threads could free it twice.How it was verified
tests/test_polled_probe_costs.py(14 tests) covers each change with mocked subprocess, psutil and time, plus new cases intest_training_history_delete.pyandtest_data_recipe_seed.py. 222 pass across the new and closest existing files.ruff checkis clean.refresh_memory=truetakes about 108 ms.test_gpu_selection,test_memory_estimate,test_video_backendandtest_startup_defers_torch. They fail identically on an unmodified checkout on macOS and are unrelated to this change.Not tested here