Repository navigation
Showcase Bypassing MPS "Invalid buffer size" limit to run MiniMax H3 locally on 16GB M4 #4542
Closed
devraj88
started this conversation in
Show and tell
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I’ve been testing the limits of Apple's unified memory architecture for local omni-modal generation, specifically scaling self-attention matrices for massive open-weight video models like MiniMax H3 and LTX-2.3.
When pushing high-resolution upscaling in ComfyUI on a 16GB Mac Mini M4, the pipeline consistently hits Apple's contiguous memory allocation limit (preventing matrices from expanding past the ~16.66 GiB cap on larger machines), triggering a RuntimeError: Invalid buffer size and forcing a kernel panic.
The Workaround:
By explicitly overriding the memory allocation behavior before launching the pipeline:
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
This successfully forces PyTorch to bypass the hard Metal allocation limit. The continuous VRAM requirement safely overflows directly into the Mac's SSD swap space. Using this custom swap management, I was able to generate 15 seconds of native 2K video with perfectly synced stereo audio in a single pass on a constrained 16GB machine without panicking the kernel.
I recorded a short visual demo of the sampler and PyTorch memory outputs running the bypass here to verify the execution proof: https://youtube.com/shorts/JXFWwQ1Vhu0?si=QxYXXNyipQz3BDnf
Would love to hear if the MLX team is looking into native optimizations for these large continuous buffer allocations in future updates.
All reactions