Skip to content
FramesField
FIX 30 · COMFYUI & LOCAL GPU
raw .md ↗ Verified Dec 1, 2026

Fix ComfyUI macOS Apple Silicon MPS float64 Crashes

Direct Fix: Upgrade to PyTorch >=2.5 on macOS 14+, launch ComfyUI with PYTORCH_ENABLE_MPS_FALLBACK=1, --force-upcast-attention, and --preview-method none, swap slow emulated FP8 checkpoints for BF16 or GGUF Q4_K_M/Q6_K, and avoid setting MPS watermark to 0.0 on 16–24 GB Macs.
Exact Error / Visual Signature
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead. | RuntimeError: MPS backend out of memory (MPS allocated: ..., max allowed: ...)
OBSERVED SYMPTOM

Running ComfyUI on an Apple Silicon MacBook Pro or Mac Studio (M1, M2, M3, or M4) crashes mid-graph with an MPS float64 TypeError, hits "MPS backend out of memory" even with free Unified Memory remaining, produces black frames on M1/M2 chips, or crawls at 20+ seconds per step on FP8 models.

TECHNICAL ROOT CAUSE

Apple Metal Performance Shaders (MPS) lacks hardware float64 and NVIDIA FP8 Tensor Core instructions, enforces a strict wired Unified Memory cap (~66–75% of total RAM), and triggers silent CPU fallback bottlenecks or fp16 attention NaNs unless PyTorch >=2.5, MPS CPU fallback, and Metal-native dtypes (BF16/GGUF) are configured properly.

Copy-Paste Verified Fix

Apple Silicon (M1–M4) Tuned ComfyUI Launch Script & PyTorch MPS Health Check launch-comfyui-apple-silicon.sh
#!/usr/bin/env bash
set -euo pipefail

# 1. Verify native arm64 Python + PyTorch >=2.5 MPS acceleration (never Rosetta x86_64!)
ARCH="$(uname -m)"
if [ "$ARCH" != "arm64" ]; then
  echo "ERROR: Running under x86_64 Rosetta! Switch to native arm64 Homebrew Python." >&2
  exit 1
fi

python3 -c '
import torch
print("PyTorch:", torch.__version__, "| MPS built:", torch.backends.mps.is_built(), "| MPS available:", torch.backends.mps.is_available())
assert torch.backends.mps.is_available(), "MPS unavailable — upgrade macOS >=14 and reinstall arm64 torch!"
'

# 2. Auto-scale Unified Memory guardrails based on installed Mac RAM
TOTAL_GB="$(( $(sysctl -n hw.memsize) / 1073741824 ))"
export PYTORCH_ENABLE_MPS_FALLBACK=1

if [ "$TOTAL_GB" -ge 64 ]; then
  echo "Detected ${TOTAL_GB}GB Apple Silicon Mac -> enabling high-headroom BF16 MPS profile"
  export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.85
  python main.py --bf16-vae --preview-method none
else
  echo "Detected ${TOTAL_GB}GB Apple Silicon Mac -> enabling swap-safe --lowvram MPS profile"
  export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.75
  python main.py --lowvram --force-upcast-attention --preview-method none
fi

Before vs. After (Broken Pattern vs. Verified Fix)

Broken · Broken macOS Launch (No MPS Fallback + Emulated FP8 + Unsafe 0.0 Watermark on 16GB)
# Crashes on float64 ops, stalls on emulated FP8, freezes 16GB MacBook via SSD swap:
PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 python main.py --fp8_e4m3fn-unet
Verified · Verified Apple Silicon Launch (MPS Fallback + Safe Memory + Upcast Attention)
# Safe across M1/M2/M3/M4 (16GB–32GB Unified Memory):
export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.75
python main.py --lowvram --force-upcast-attention --preview-method none

# For 64GB–128GB M2/M3/M4 Max & Ultra (native BF16 weights, zero swap risk):
# PYTORCH_ENABLE_MPS_FALLBACK=1 python main.py --bf16-vae --preview-method none

Why this works: Enabling MPS fallback stops float64 crashes cleanly, capping watermark ratio at 0.75 protects macOS from swap lockups on 16–32 GB Macs, and avoiding CUDA-only FP8 flags eliminates software dequantization stalls.

Under the Hood

Why This Failure Happens in Real Pipelines

Apple Silicon GPUs execute PyTorch graphs through Metal Performance Shaders (mps) rather than CUDA. Metal hardware shaders intentionally omit 64-bit IEEE double precision (float64) because mobile and desktop GPUs optimize silicon area for FP32 and FP16/BF16 throughput. Whenever a custom node, video scheduler, or NumPy array (whose default dtype is float64) moves directly onto an mps tensor without explicit .float() casting, PyTorch aborts immediately with "MPS framework doesn't support float64". Exporting PYTORCH_ENABLE_MPS_FALLBACK=1 transparently routes unsupported float64 and niche ops to the Apple Silicon CPU cores without crashing the workflow.

A second macOS-specific wall is Unified Memory allocation versus macOS kernel stability. By default, PyTorch MPS caps GPU allocations well below total installed RAM so Finder and macOS WindowServer do not deadlock. Many forums blindly tell users to set PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0—on a 16 GB or 24 GB MacBook, disabling the watermark lets ComfyUI swallow all system RAM, freezing macOS into severe SSD swap thrashing. Only raise or disable the watermark on 64 GB–128 GB Mac Studio/MacBook Pro machines while keeping at least 16 GB free for macOS; on 16 GB–32 GB Macs, pair --lowvram with GGUF Q4_K_M/Q6_K weights instead.

Finally, Apple Silicon chips have zero native hardware FP8 (e4m3fn) matrix-multiply units. Loading an fp8_e4m3fn FLUX or Wan 2.2 file engineered for RTX 4090 cards forces PyTorch MPS into sluggish software dequantization overhead. On macOS 14+ with PyTorch 2.5+, native bfloat16 (on 32 GB–64 GB+ Macs) or Q4_K_M / Q6_K GGUF weights run significantly more predictably, and passing --force-upcast-attention eliminates FP16 attention blackouts on older M1/M2 GPUs. Be pragmatic about workloads too: M-series Macs excel at 4-step FLUX.1 Schnell stills (10–25 seconds), while 14B video diffusion still takes 10–25 minutes per 5s clip on MPS compared to under 60 seconds on a rented RTX 4090 or $0.25–$0.62 cloud video API.

Step-by-Step Resolution & Verification

  1. 01

    Verify you are running native arm64 Python and PyTorch 2.5 or newer

    Confirm uname -m prints arm64 (running ComfyUI inside an x86_64 Rosetta shell disables MPS completely) and upgrade PyTorch inside your ComfyUI venv so native bfloat16 and modern MPS kernels are active.

  2. 02

    Export PYTORCH_ENABLE_MPS_FALLBACK=1 and size watermark safely to your RAM

    Set PYTORCH_ENABLE_MPS_FALLBACK=1 to eliminate float64 TypeErrors immediately. Keep PYTORCH_MPS_HIGH_WATERMARK_RATIO at 0.75 with --lowvram on 16–32 GB Macs, reserving 0.85+ strictly for 64–128 GB Mac Studio/Pro systems.

  3. 03

    Swap emulated FP8 checkpoints to GGUF Q4_K_M/Q6_K or BF16 and disable live previews

    Avoid CUDA-targeted --fp8_e4m3fn-unet flags on Metal. Pass --preview-method none to eliminate costly per-step GPU-to-CPU sync pauses, and use --force-upcast-attention on M1/M2 machines if any image renders black.

Verification Check · Confirm Native arm64 PyTorch MPS Backend & Zero float64 Fallback Crash
PYTORCH_ENABLE_MPS_FALLBACK=1 python3 -c 'import platform, torch; x = torch.randn(4, 4, device="mps", dtype=torch.bfloat16); print("Arch:", platform.machine(), "| PyTorch:", torch.__version__, "| BF16 MPS OK:", x.device, x.dtype)'
Expected healthy output:
Arch: arm64 | PyTorch: 2.6.0 | BF16 MPS OK: mps:0 torch.bfloat16

How to Prevent This Error From Recurring

GUARDRAIL 01

Never install CUDA-only attention packs (xformers, triton, sageattention) on macOS

All three libraries depend on NVIDIA CUDA PTX kernels and either fail to compile on macOS or break ComfyUI Python dependencies during custom-node installation.

GUARDRAIL 02

Watch Activity Monitor Memory Pressure before raising MPS watermark ratios

Once macOS Memory Pressure turns yellow or red and Swap Used climbs above 4 GB, GPU render speed collapses by 5x–10x; dropping to a smaller GGUF quant is always faster than swapping to SSD.

GUARDRAIL 03

Use Apple Silicon for fast 4-step local stills and route heavy 14B video to cloud GPUs

FLUX.1 Schnell (4 steps) runs cleanly on 24–36 GB M-series Macs for rapid private concepting, while 121-frame Wan 2.2 or LTX-2 video batches stay dramatically faster on 24 GB+ NVIDIA hardware or metered APIs.

Troubleshooting FAQs

Why does ComfyUI say "MPS backend out of memory" on a 32 GB Mac when Activity Monitor shows free RAM?
macOS caps the maximum wired GPU memory allocation (typically ~66–75% of total Unified Memory) to protect OS responsiveness. Setting PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.75 alongside --lowvram keeps allocations inside the safe wired ceiling.
Can I raise the macOS wired GPU limit via sysctl on a 64 GB or 128 GB Mac Studio?
Advanced users on 64 GB–128 GB Macs sometimes raise iogpu.wired_limit_mb temporarily with sudo sysctl iogpu.wired_limit_mb=53248 (leaving at least 12–16 GB for macOS), though it resets on reboot and should never be over-allocated on 16–24 GB laptops.
Why is FLUX.1 Schnell so much more practical on a MacBook than FLUX.1 Dev or Wan 2.2?
FLUX.1 Schnell converges in just 4 Euler steps instead of 24–28 steps (a 6x speedup on Metal), delivering sharp Apache 2.0 commercial stills in 15–30 seconds on M2/M3/M4 Pro and Max chips.
Does PYTORCH_ENABLE_MPS_FALLBACK=1 slow down the whole render to CPU speed?
No. Heavy matrix multiplications, convolutions, and attention layers remain on the Metal GPU; only individual unsupported ops (such as a single float64 timestep schedule calculation) execute briefly on the CPU.
Should I use Draw Things or native MLX tools instead of ComfyUI on a 16 GB Mac?
For casual single-image generation on 16 GB Macs, native CoreML/Metal apps like Draw Things use less memory overhead. Keep ComfyUI when you need reproducible API JSON pipelines, exact node graphs, or shared team workflows.
Use this page in AI tools or notes
raw .md