Repository navigation
fix(audio): importing the Whisper ASR module no longer loads torch - #4662
Conversation
Importing gaia.audio.whisper_asr pulled in torch at module load. On macOS torch's bundled libomp then sits beside faiss's, and memory recall refuses every faiss search for the rest of the process. In the unit suite a mocked-sounddevice test imported the module, so test_memory_turn_recall failed on the macOS smoke job for every PR. torch and whisper are now imported when a WhisperAsr is constructed, the only point that needs them. A subprocess test pins that the import stays torch-free.
|
Verdict: Approve Importing the Whisper speech-to-text module no longer loads torch as a side effect. That side effect broke memory recall for the rest of a macOS test run. torch and whisper are now imported only when someone actually creates a speech recognizer, so the user-facing behaviour is unchanged. A new test fails if the module ever starts loading torch again. The change is small and well targeted. I found no blocking issues. One thing to keep in mind: another audio test file still imports whisper at the top of the file. CI's macOS smoke environment doesn't install whisper, so CI is fine. On a dev machine that has the voice extras installed, though, a full local run can still load torch before the recall test runs. Real-world evidenceN/A: this is an internal import-timing change and its test. It touches no CLI, API, MCP or Agent UI surface, and no evidence bundle was produced. The verdict rests on static review plus the author's local macOS run described in the PR. 🔍 Technical detailsIssues found 🟢 Correctness checks
Strengths
|
…md#4662 amd#4585 now patches only the uninstall module's platform, and its autouse fixture never tree-kills a fake sidecar pid, which is the only path that ran taskkill. amd#4662 fixed the torch import that broke faiss recall on macOS, so the recall test no longer needs a skip. This PR keeps only the smoke-job timeouts.
) The macOS and Windows unit-test smoke jobs hit their 30-minute limit before the suite finishes, so even with every test fixed they can't go green. This raises the limits to fit a full run: 45 min on macOS (a full run takes ~33) and 60 on Windows (15 min reached 6,873 of ~18,000 tests). The test fixes this PR first carried now live elsewhere: the Windows `os.getuid` teardown and the sidecar taskkill in amd#4585, and the macOS recall failure in amd#4662 (merged; it removes the torch import at its root instead of skipping the test). Merge amd#4585 first; this PR no longer touches any test file, so the two don't conflict. ## Test plan - [ ] CI: after amd#4585, "Unit Tests (macOS smoke)" and "Unit Tests (Windows smoke)" run to the end inside the new limits - [x] Locally (macOS): `test_memory_turn_recall.py`, `test_agent_sidecar_manager.py`, `installer/test_uninstall_command.py` at main's versions: 148 passed, 4 skipped --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
…op (amd#4585) The Windows smoke job stops at the first failing test, so every fix so far has only revealed the next Windows-only failure. This clears all the ones known so far in one go so the job can finally reach the end. One is more than a Windows problem: the sidecar tests' fake process (pid 4242) reached the real tree-kill, so on Linux and macOS each run sent SIGTERM to whatever real process group held that id, and the error was swallowed. - **Uninstall shebang tests:** they fake Linux only inside the uninstall module, so pyfakefs teardown no longer calls `os.getuid` on Windows. Installer-leftover paths are built the way the platform prints them. - **Sidecar manager tests:** only real child processes reach the tree-kill (and so `taskkill` on Windows); `os.killpg`/`os.getpgid` fakes no longer error on Windows, where they don't exist. - **CLI refusal test:** the subprocess gets `USERPROFILE`/`SYSTEMROOT` (Windows finds its home and starts Python from them) and reads its output as UTF-8 (the refusal prints an emoji). - **Dev-anchor tests:** expected paths are built the way the platform prints them. - **Reap tests:** the two that assert a process-group kill skip on Windows, where the code deliberately skips that kill (a documented gap). Test-only change. Merge this before amd#4580, which now only raises the smoke-job timeouts. The macOS smoke failure was fixed by amd#4662. ## Test plan - [x] `pytest tests/unit/test_agent_sidecar_manager.py tests/unit/installer/test_uninstall_command.py tests/unit/test_cli_refusal_exit_codes.py tests/unit/test_daemon_cli_dev_anchor.py tests/unit/test_daemon_agents_routes.py tests/unit/test_project_map.py` on macOS after merging main: 298 passed, 4 skipped - [ ] `Unit Tests (Windows smoke)` gets past these files on this PR's run - [ ] With amd#4580 also merged, `Unit Tests (Windows smoke)` is green on main --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
Every open PR shows these two failures; this clears them. The macOS one is fixed here; the Windows one is fixed by #4585, so the smoke jobs go green once both merge.
test_memory_turn_recall: an audio test imported the Whisper ASR module, and that import loaded torch. Once torch is loaded, macOS has two OpenMP runtimes in the process (torch's and faiss's), so memory recall refuses every faiss search for the rest of the run. torch and whisper are now imported only when an ASR is actually created. The recall test runs and passes; it isn't skipped. ci(unit): give the macOS and Windows smoke jobs time to finish #4580 handles this failure by skipping the test, so drop that half of ci(unit): give the macOS and Windows smoke jobs time to finish #4580 when this merges.test_resolves_direct_shebang_posix: the test faked Linux by patchingsys.platformfor the whole process. pyfakefs teardown then took the POSIX path and calledos.getuid, which doesn't exist on Windows. test: clear the Windows-only failures behind the smoke job's first stop #4585 now patches only the uninstall module's view of the platform, so this PR doesn't touch it.The macOS failure dates from #4061 (Sep 28), which added the recall test after the torch-loading audio test from #3616. The smoke job runs with
-x, so earlier failures hid it until #4562 fixed those on Oct 2.Test plan
test_importing_whisper_asr_does_not_load_torchfails on main and passes heretest_memory_turn_recallincludedtest_memory_turn_recall.py