-
Notifications
You must be signed in to change notification settings - Fork 332
[BugFix] fix torch MPS check #1021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I discovered that in PyTorch versions below 2.4, there's no torch.mps.is_available() interface, only torch.backends.mps.is_available(). To support older PyTorch versions, we need to modify this interface.
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
WalkthroughUpdated MPS availability detection in tilelang/utils/device.py to use torch.backends.mps.is_available() instead of torch.mps.is_available(), affecting the IS_MPS flag used by get_current_device. No changes to CUDA handling or return value logic. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tilelang/utils/device.py (1)
4-4: LGTM! Correct fix for PyTorch version compatibility.Using
torch.backends.mps.is_available()is the right approach as it's the stable API available since PyTorch 1.12 (when MPS support was introduced), whereastorch.mps.is_available()was only added in PyTorch 2.4. This change ensures backward compatibility while maintaining forward compatibility.Optionally, consider adding a brief comment explaining the API choice for future maintainers:
+# Use torch.backends.mps for compatibility with PyTorch < 2.4 IS_MPS = torch.backends.mps.is_available()
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tilelang/utils/device.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-test-metal
|
Currently torch's mps backend rely on api since 2.7. Refactor to support lower version is planned but I don't have specific time yet. One solution is to add something like |
|
@oraluben Thank you for your response. I understand now. I will close this PR and look forward to the refactoring! |
I discovered that in PyTorch versions below 2.4, there's no torch.mps.is_available() interface, only torch.backends.mps.is_available(). To support older PyTorch versions, we need to modify this interface.
Summary by CodeRabbit