Add MPS (Apple Silicon) support - #155
Open
imperatormk wants to merge 1 commit into
Open
Conversation
- Device detection: CUDA > MPS > CPU fallback - NF4 quantization via mps-bitsandbytes (~20GB -> ~5GB) - MPS flash attention via mps-flash-attn - Float32 precision for RoPE, CFG, VAE decode on MPS - Lazy loading for memory-constrained devices - T5 encoder freed after encoding CLI flags: - --quantize: enable NF4 quantization - --attention-mode: override attention (flash/mps_flash/sdpa/sage) Scripts: - scripts/quantize_dit.py: quantize Genmo DiT - scripts/quantize_diffusers_transformer.py: quantize Diffusers transformer Misc: - moviepy 2.x compatibility - ffmpeg fast path for video encoding - ray import guard for multi-GPU mode
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.
Fixes #74
Summary
Full MPS (Apple Silicon) support for Mochi video generation - no more "Torch not compiled with CUDA enabled" errors or black/noisy outputs.
MPS Compatibility Fixes
The core issue was CUDA-specific code paths and precision problems on MPS:
mps_flashmode, SDPA fallback works on MPStorch.cuda.*calls to not crash on MPSMemory Optimizations
--quantizeflagOptional Dependencies
For additional features, install these MPS-optimized packages:
CLI Flags
--quantize- NF4 4-bit quantization (requires mps-bitsandbytes)--attention-mode- override:flash,mps_flash,sdpa,sageScripts
scripts/quantize_dit.py- pre-quantize Genmo DiTscripts/quantize_diffusers_transformer.py- pre-quantize DiffusersUsage