feat: add experimental macOS MPS inference support - #36
Open
yuhai-china wants to merge 2 commits into
Open
Conversation
- Allow 'mps' as a valid device in device validator - Auto-detect device from _execution_device instead of hardcoding 'cuda' - Workaround MPS Graph assertion crash under @torch.no_grad() by temporarily enabling grad during DMD processing loop - Add type annotations for MPS across pipeline components Verified: Turbo T2I 512x512, 4-step DMD completed in ~10s on MPS. Reference: pytorch/pytorch issues #114532, #148194, #174861
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
Add experimental macOS MPS (Metal Performance Shaders) inference support for Boogu-Image, enabling inference on Apple Silicon Macs without CUDA.
Changes
Device Support
boogu/utils/validator_utils.py: Addmpsas a valid device argumentboogu/models/transformers/transformer_boogu.py: Detectmpsfor attention processor selectionboogu/pipelines/boogu/pipeline_boogu.py: Defaultdevicefrom_execution_deviceinstead of hardcoded"cuda"MPS Workaround
boogu/pipelines/boogu/pipeline_boogu_turbo.py: Workaround for PyTorch MPS backend bug where@torch.no_grad()triggers an MPSGraph assertion during the first transformer forward. Temporarily enabling gradient computation bypasses this bug.Verification
Device: Apple Silicon (MPS), macOS, PyTorch 2.11.0, Model: Boogu-Image-0.1-Turbo (4-step DMD)
Sample Outputs (512×512)
Compatibility