Gate CUDA fallback patch on non-CUDA PyTorch build, not active device type - #15
Merged
Conversation
- Add optional `device` param to safe_cuda_synchronize, safe_cuda_memory_reserved, and safe_cuda_memory_allocated to match the real torch.cuda API signatures - Replace bare `except Exception: pass` with specific (RuntimeError, AttributeError) catches and DEBUG-level logging in MPS fallback wrappers - Update _setup_cuda_fallback docstring to reflect runtime-device-based condition Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add CUDA fallback handling for non-CUDA builds
Fix CUDA fallback wrapper signatures and exception handling
Mar 16, 2026
Only apply torch.cuda.* monkey-patches when PyTorch was compiled without CUDA support (torch.version.cuda is None). CUDA-capable builds running on CPU due to driver issues now surface real errors instead of silently no-oping. Update docstring to explain the intent precisely. Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot
AI
changed the title
Fix CUDA fallback wrapper signatures and exception handling
Gate CUDA fallback patch on non-CUDA PyTorch build, not active device type
Mar 16, 2026
lmangani
marked this pull request as ready for review
March 16, 2026 01:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_setup_cuda_fallback()was patchingtorch.cuda.*wheneverDEVICE.type != "cuda", which also fires on CUDA-compiled PyTorch running on CPU (e.g., driver unavailable) — silently swallowing errors that should surface as real misconfiguration signals.Changes
backend/ltx2_server.py— Swap the outer guard from a device-type check to a build-time check:torch.version.cuda is Noneintent and why CUDA-capable builds are explicitly excluded.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.