fix(workers): preserve Whisper GPU allocation from Ray resources - #496
Conversation
WhisperPool runs with num_gpus=0, so torch.cuda.is_available() is False in its process even on a GPU node, silently pinning WhisperActors to CPU. Decide the GPU request from Ray cluster resources instead, mirroring _marker_num_gpus.
📝 WalkthroughWalkthrough
ChangesWhisper GPU detection via Ray cluster resources
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
The bug
WhisperPoolsilently runs Whisper transcription on CPU even when the node has a GPU, making audio/video indexing far slower than it should be.Root cause
Same failure mode as the Marker GPU regression (#451 / #452), now in the Whisper path.
WhisperPoolis created withnum_gpus=0(it's just a dispatcher — seebootstrap.py). Ray therefore clearsCUDA_VISIBLE_DEVICESinside the pool actor's process, sotorch.cuda.is_available()returnsFalsethere even on a GPU node._whisper_num_gpus()asked that question from inside the pool actor before deciding how many GPUs to request for the realWhisperActorworkers:Because CUDA is hidden in the pool process, this returned
0, so theWhisperActors were scheduled withnum_gpus=0and loaded the model on CPU (device = "cuda" if torch.cuda.is_available() else "cpu"→cpu). Ray never reserved a GPU. The API still worked, so it looked like a performance issue rather than a misconfiguration.The wrong question was "can this pool actor see CUDA?" — it should be "does the Ray cluster have GPU capacity Whisper should request?"
The fix
_whisper_num_gpus()now decides from Ray cluster resources, mirroring_marker_num_gpus():<= 0→ stays on CPU (explicit opt-out preserved)0.25)torch.cuda.is_available()checkAdds a regression test covering the hidden-CUDA case plus the config-disabled and Ray-lookup-failure fallbacks.
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests