fix: add Apple Silicon MPS support for device detection#58
Open
msgjsmj wants to merge 1 commit intodatalab-to:masterfrom
Open
fix: add Apple Silicon MPS support for device detection#58msgjsmj wants to merge 1 commit intodatalab-to:masterfrom
msgjsmj wants to merge 1 commit intodatalab-to:masterfrom
Conversation
The generate_hf function had hardcoded "cuda" device, causing AssertionError on non-NVIDIA systems. This change adds automatic device detection with the following priority: 1. TORCH_DEVICE setting (if configured) 2. model.device attribute (if available) 3. CUDA (if torch.cuda.is_available()) 4. MPS (if torch.backends.mps.is_available()) - Apple Silicon 5. CPU (fallback) This enables running chandra on Apple Silicon Macs with Metal acceleration via MPS backend. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9978015 to
419af07
Compare
|
Hi! Just curious about the state of this fix, any plans to release it soonish? Thanks a lot! |
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.
Summary
"cuda"device ingenerate_hf()function that causedAssertionError: Torch not compiled with CUDA enabledon non-NVIDIA systemsTORCH_DEVICEsetting →model.device→ CUDA → MPS → CPUProblem
When running
chandra-appon macOS with Apple Silicon (M1/M2/M3), the following error occurs:This is because
hf.py:36has hardcodedinputs.to("cuda").Solution
Replace hardcoded device with automatic detection that respects:
TORCH_DEVICEsettingTest Plan
chandra-app🤖 Generated with Claude Code