Skip to content

Studio: run audio.cpp on the GPU in chat-only Linux installs - #18168

Merged
danielhanchen merged 5 commits into
mainfrom
studio-audiocpp-chat-only-cuda-runtime
Nov 18, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
studio-audiocpp-chat-only-cuda-runtime

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Chat-only (no torch) Linux installs with an NVIDIA GPU run audio.cpp (text to speech, music, dictation) on the CPU, even after #17463 fixed the same problem for llama.cpp.

Why

The Linux audio.cpp CUDA bundles link libcudart, libcublas and libcufft and ship none of them. A full install borrows them from torch's nvidia-* wheels. A chat-only install has no torch, so _linux_cuda_runtime_available fails and resolve_for_request installs the CPU build. Since #17463 the llama.cpp step installs nvidia-cuda-runtime and nvidia-cublas, but nothing installs cuFFT, so audio.cpp still falls back:

audio.cpp: no CUDA 13 runtime (cudart, cuBLAS) for audio-v0.9.5-unsloth.1-bin-ubuntu-x64-cuda13.tar.gz; installing the CPU build

An existing chat-only install also never recovers: _record_fits_request only looks the GPU build up again when torch's runtime appears, and a chat-only install never gets torch, so every update answers "already matches" with the CPU build.

Change

  • resolve_for_request: when the chosen Linux CUDA bundle has no runtime and the env has no torch (Linux x86_64 only), install NVIDIA's wheels for that CUDA line first (nvidia-cuda-runtime, nvidia-cublas, nvidia-cufft, or the -cu12 names), then check again. Only if they are still missing does it install the CPU build, as today. Wheels that are already installed are left alone (uv no-ops them), and nothing is installed when the runtime is already present.
  • _record_fits_request: a chat-only CPU fallback recorded before this change is looked up once more on the next update, so existing installs move to the GPU build. The new install record carries cuda_runtime_wheels_tried, so a host where the wheels cannot install (offline, a blocked mirror) keeps answering "already matches" without a lookup on later runs, as it does today.
  • A kept CPU install (the resolver picked the same CPU asset again after the wheels failed) is marked too, and a CPU fallback that already tried the wheels does not try again when a newer audio.cpp release comes out. So a host whose package index is blocked pays for at most one attempt.
  • --print-asset only resolves and never installs wheels.

Hosts with torch, Windows (which downloads its own cudart archive), macOS, AMD and arm64 take exactly the same path as before. The download is the cuFFT wheel (about 157 MB plus nvjitlink) on top of what the llama.cpp step already installed, and only on chat-only Linux NVIDIA hosts.

Tests

Real run on a Colab T4 (driver 580, CUDA 13.0) with every libcudart, libcublas, libcublasLt and libcufft moved off the VM so only the driver is left (cuInit = 0, 1 device). Each arm is a torch-free venv that ran the llama.cpp installer first, as a chat-only install does, then the arm's audio.cpp installer:

Case audio.cpp bundle audiocpp_server --version libcufft.so.12
main ubuntu-x64-cpu-portable backends: cpu not linked (CPU build)
this PR ubuntu-x64-cuda13 backends: cpu,cuda venv nvidia/cu13/lib
existing CPU install, then this PR's installer (update) ubuntu-x64-cuda13 backends: cpu,cuda venv nvidia/cu13/lib
same, run again already matches, nothing downloaded backends: cpu,cuda venv nvidia/cu13/lib

tests/studio/install/test_install_audio_cpp_prebuilt_logic.py: 244 passed (20 new). With only the functional lines reverted (helpers kept), the behaviour tests fail: wheels installed and CUDA kept, CPU fallback when the wheels fail, an old CPU record looked up once, the record marked so reruns stay offline, a kept CPU install marked after a failed attempt, and no retry for a newer release.

Not covered: an offline rerun pinned to the installed release (UNSLOTH_AUDIO_CPP_TAG or --published-release-tag) on an old chat-only CPU install now looks the release up once instead of reusing it, and fails if the lookup is unavailable. That needs an explicit pin and no network at the same time, so it is left as is.

@danielhanchen danielhanchen self-assigned this Nov 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T15:52:17.028249Z 974b7b0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 0986c03991

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

danielhanchen added a commit to Etherll/unsloth that referenced this pull request Nov 17, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 17, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 974b7b0783

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

danielhanchen added a commit that referenced this pull request Nov 17, 2026
…s off (gloo-pp red since #18165) (#18184)

`Repo tests (CPU, gloo-pp)` fails on main since #18165 (seen on the
staging run of #18168, an audio.cpp installer change, and on #18165's
own run):

```
tests/test_pp_env_gloo.py: test_pp_env_layout_and_refusals
E   assert ('mixture-of-experts' in ((None or '')))
tests/test_pp_native_gloo.py: test_pp2_refusals
E   assert 'mixture-of-experts' in ((None or ''))
```

## Cause

#18165 changed what pipeline parallel accepts: a mixture-of-experts
model whose router aux loss pp does not carry between stages now splits
and trains with that loss off, and is refused only once the loss is
turned on (in the stage forward, and at Trainer init when TRL or the
config turns it on). Its new `tests/test_pp_moe_aux_off_gloo.py` covers
both halves, including
`test_pp2_uncarried_moe_with_aux_on_stays_refused`. The two older
refusal tests still expected every such load (OLMoE in
`test_pp2_refusals`, the tiny MoE in `test_pp_env_layout_and_refusals`,
both with the aux loss off by default) to be refused.

The behaviour change is intended; the tests predate it.

## Fix

Both assertions now expect the load to go through (`None`), with a
comment pointing at the aux-on refusal coverage in
`test_pp_moe_aux_off_gloo.py`. The other refusals in both tests (MLA,
tied trainable embeddings, unsupported trainer options, ...) are
unchanged.

## Verification

- main: both tests fail as above.
- this branch: the two tests plus `tests/test_pp_moe_aux_off_gloo.py`:
23 passed.
danielhanchen added a commit that referenced this pull request Nov 17, 2026
…indowsPath teardown errors) (#18191)

Studio's `m-r` shard can error at teardown on whichever test fakes
Windows when a WAL keeper was opened during it (seen on #18168, an
audio.cpp installer change):

```
_ ERROR at teardown of test_a_user_site_install_is_not_told_to_isolate_itself __
tests/conftest.py:758: in _isolate_wal_keepers
    rag_db.close_wal_keeper_for(path)
storage/rag_db.py:532: in close_wal_keeper_for
    resolved = Path(path).resolve()
E   pathlib._abc.UnsupportedOperation: cannot instantiate 'WindowsPath' on your system
```

## Cause

The autouse `_isolate_wal_keepers` fixture closes the WAL keepers a test
opened. Its teardown runs before that test's `monkeypatch` is undone
(another autouse fixture already requested `monkeypatch`, so it is torn
down later). About a dozen Studio tests fake Windows with
`monkeypatch.setattr(os, "name", "nt")`,
`test_reset_password_command.py` through its `windows` fixture among
them. If a keeper was opened during such a test (by that test or a
background thread from an earlier one), the cleanup's `Path(path)` is
built while `os.name` is still `"nt"`, so pathlib picks `WindowsPath`
and raises on Linux. Whether it happens depends on what else runs on the
worker.

`rag_db.close_wal_keeper_for` and the tests are fine; the cleanup ran
under the faked platform.

## Fix

`_isolate_wal_keepers` swaps the real `os.name` (captured when conftest
loads) back in for its cleanup and restores the test's value afterwards,
so the test's own monkeypatch undo still sees what it set.

New `test_conftest_teardown_real_os_name.py` fakes Windows and leaves a
keeper entry for the cleanup to close, which is the CI state.

## Verification

- main conftest: the new test errors at teardown with
`UnsupportedOperation` (the CI error).
- this branch: it passes; with `test_reset_password_command.py` and the
rag/studio DB and WAL tests, 301 passed.
@danielhanchen
danielhanchen merged commit a7ad590 into main Nov 18, 2026
@danielhanchen
danielhanchen deleted the studio-audiocpp-chat-only-cuda-runtime branch November 18, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant