Repository navigation
Studio: honour Voice Settings Load into on cold STT API loads (#15280) - #15284
danielhanchen merged 19 commits into
Conversation
OpenAI /v1/audio/transcriptions omitted device, so a cold load used auto/GPU even when Settings said CPU RAM (unslothai#15280). Persist sttDevice server-side (like embedding device), use it from audio_device_default when UNSLOTH_AUDIO_DEVICE is unset, and accept an optional device form field on the OpenAI STT routes.
|
That test imports A couple of ways out:
The |
|
@codex review |
1 similar comment
|
@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 |
1 similar comment
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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]
# Conflicts: # studio/backend/core/inference/stt_ggml_sidecar.py # studio/backend/core/inference/stt_sidecar.py # studio/frontend/src/app/routes/__root.tsx
…oise is not amplified (#15381) ## Problem `Repo tests (CPU, gloo)` is red on main since #15326. Three tests fail locally and in CI (for example #15284): - `test_env_tp2_trainer_matches_one_process[sharded_16bit]` - `test_env_tp2_trainer_matches_one_process[full_load]` - `test_env_tp2_with_fsdp2_flag_and_no_dp_dimension` They fail like this: ``` comparison failed. Mismatched elements: 1 / 3: Max relative difference: 1.24e-05 Index | Obtained | Expected 2 | 0.3388126790523529 | 0.33881688117980957 +- 3.4e-06 ``` ## Product or test The test. I measured both arms (`tp = 2` against one process) step by step on main: | | step 1 | step 2 | step 3 | |---|---|---|---| | loss, relative gap | 0 | 0 | 0 | | grad norm, relative gap | 3.2e-7 | 1.6e-6 | 1.2e-5 | The worst LoRA tensor after the run (`layers.1.mlp.gate_proj.lora_B`) is 1.35e-4 off, while the rest sit near 2e-6. The losses match exactly and the first-step gap is fp32 reduction-order noise. The gap then grows about 10x per step, which is what `m / (sqrt(v) + eps)` does to near-zero LoRA gradients at the Trainer's default `adam_epsilon = 1e-8`. Changing only eps on both arms: | `adam_epsilon` | step-3 grad-norm gap | worst tensor | |---|---|---| | 1e-8 (default) | 1.24e-5 | 1.35e-4 | | 1e-5 | 5.3e-6 | 5.9e-6 | | 1e-4 | 9.4e-7 | 4.4e-7 | | 1e-3 | 1.2e-6 | 1.4e-7 | A tensor-parallel bug would not shrink with eps. This is the same effect #15264 fixed for the hand-written TP x FSDP2 loop. The new UNSLOTH_TP_SIZE Trainer tests share `_trainer_args`, which still used the default eps. ## Fix `_trainer_args` in `tests/test_tp_native_gloo.py`, used by both the native and the env-driven Trainer tests, now passes `adam_epsilon = _TRAINER_ADAM_EPS` (1e-4). A comment records the measurement. The tolerances (`rel = 1e-5` on grad norms, `rtol = 1e-4, atol = 1e-6` on the adapter state) are unchanged. ## Verification - `tests/test_tp_env_gloo.py` and `tests/test_tp_native_gloo.py` in full: 52 passed. On main, the three tests above fail. - Sabotage: with the backward all-reduce of the column-parallel input removed in `tp_native.py` (`return grad, None`), a real TP bug that leaves earlier layers with partial gradients, all three tests fail at `Max relative difference: 3.5e-4`, 35x over the tolerance. The looser eps does not hide a real TP error.
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
…ative Trainer runs back on the default (#15397) ## Problem #15381 set `adam_epsilon = 1e-4` in the shared `_trainer_args` of `tests/test_tp_native_gloo.py`. That fixed the three UNSLOTH_TP_SIZE Trainer tests in `test_tp_env_gloo.py`, but on the CI runners it broke the two native Trainer tests that use the same helper. Comparing the `gloo` shard before and after (both on current-main bases): | CI run | native `test_trainer_trains_a_tensor_parallel_model_like_one_process[1-2]` / `[2-2]` | `test_env_tp2_*` (3 tests) | |---|---|---| | #15284, base 975e864 (before #15381) | pass | fail | | #15386, base 0be4c5d (after #15381) | fail on `lora_A` state (`rtol = 1e-4, atol = 1e-6`) | pass | On this host both groups pass at both settings. The runners' CPUs round differently from this machine, and I could not emulate theirs here: `ATEN_CPU_CAPABILITY=avx2` aborts the spawned ranks with `buffer overflow detected`. So the CI table above is the evidence for which eps each group needs. The two groups differ in their adapters. The env tests use `init_lora_weights = False`, where every factor gets a real gradient from step 1; that is where the default eps amplifies reduction-order noise, as measured in #15381. The native tests use the default `B = 0` start, where `lora_A`'s gradients are tiny for the first steps. There, eps 1e-4 sits inside their range and moves `lora_A` differently on the two arms. ## Fix - `_trainer_args` goes back to AdamW's default eps, so the native Trainer tests run as they did when they passed on CI. - `test_tp_env_gloo.py` passes `adam_epsilon = 1e-4` only at its own training call, with the measurement and the reason in a comment. Tolerances are unchanged. ## Verification - `tests/test_tp_env_gloo.py` and `tests/test_tp_native_gloo.py`: 52 passed on this host. - This PR's own `Repo tests (CPU, gloo)` shard is the check on runner hardware. Both groups should pass there. ## Not covered here `test_tp2_x_fsdp2_dp2_matches_one_process[phi3-True-None]` also fails in both CI runs above, by 6.9e-5 to 7.7e-5 relative on grad norms (tolerance 1e-5), and passes on this host. It only became visible after #15355: before that, the `phi3` cases errored on the removed tiny model. It uses its own hand-written loop (eps 1e-6), not `_trainer_args`, so this change does not touch it.
… shards (#15400) ## Problem `tests/test_tp_native_gloo.py::test_tp2_x_fsdp2_dp2_matches_one_process[phi3-True-None]` fails in `Repo tests (CPU, gloo)` on every recent run, on the per-step grad norms (tolerance 1e-5): | CI run | step 1 | step 2 | step 3 | |---|---|---|---| | #15284 (job 121590971980) | 1.5e-6 | 3.6e-5 | 7.7e-5 | | #15386 (job 121637289351) | 1.5e-6 | 3.6e-5 | 6.9e-5 | It only became visible after #15355. Before that, every `phi3` case errored on the removed `trl-internal-testing/tiny-Phi3ForCausalLM`. On this host the same test passes inside 1e-5. ## Product or test The test. In the same run, the loss check (rel 1e-5) and the step-1 per-gradient check (`rtol = 1e-4, atol = 1e-6` on every LoRA gradient) both pass. Only the multi-step norms drift, and the gap grows each step from a 1.5e-6 start. That is reduction-order noise compounded by AdamW, which phi3's fused qkv and gate_up shards make larger than llama's. The runners' CPUs round differently from this host. A real tensor-parallel error does not hide behind the norms. With the backward all-reduce of the column-parallel input removed in `tp_native.py` (`return grad, None`), the phi3 case fails on the step-1 per-gradient check, before the norms are compared. ## Fix `_TP_FSDP2_NORM_REL = {"phi3": 2e-4}` sets the norm tolerance for phi3 only, with the CI measurements in a comment. Every other arch keeps 1e-5. The loss, per-gradient, mismatch and placement checks are unchanged for all arches. ## Verification - `test_tp2_x_fsdp2_dp2_matches_one_process`: all 5 parametrizations pass. - Sabotage: with the all-reduce removed, the phi3 case still fails. - ruff format and check are clean.
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
|
Review record for #15284, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#689. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. VerdictThe round did not reach a clean review on the mirror before it closed. This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it. |
Cold speech-to-text API requests ignored the CPU RAM choice in Voice Settings because the choice lived only in browser storage. This change saves the owner's choice on the server and applies it when an STT model loads without an explicit device.
Fixes #15280
The existing Voice Settings controls and loading flow are preserved. First-run migration uses an atomic conditional write, so an old browser preference cannot overwrite a newer explicit selection in another browser. The saved choice applies to all four STT sidecars; an explicit request device or
UNSLOTH_AUDIO_DEVICEretains precedence, and a request without a device keeps an already-resident model in place. Native audio and TTS keep their existing environment-only default. The OpenAI transcription and translation endpoints also accept an optionaldeviceform field.Validation:
assert 'cuda' == 'cpu'and passes on this branch. It uses synthetic GGUF metadata and a fake audio server; it verifies routing and server configuration rather than real model memory residency.The migration regression fails before the follow-up fix and passes afterward, in both backend and frontend tests. Cross-platform CI passes on Linux, Windows, and Apple Silicon macOS with torch installed: 89 backend and 10 frontend tests pass on each OS. The fixed-head fallback review is clean. The full Studio regression suite reports NO_REGRESSION on the current head, including remote Colab T4-HM inference/diffusion checks. Its report retains 19 confirmed flaky snapshots and one Hub visual flag with only three bottom image rows differing; the repeat has zero pixel difference. A separate broader CI parity job is inconclusive because its null control has no stable actions; remaining broad CI is still pending. Real Qwen3-ASR weights and their VRAM footprint have not been tested. No local GPU was used.
Screenshot from separate installs at merge base
f9cecc99dand fixed headf8ed0f31a. Both browsers selected CPU RAM first; the pictured fresh browsers show GPU when available before and CPU RAM after. No model weights are downloaded or loaded for this preference screenshot.