mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-17 07:05:12 +08:00
MPS does not support float8_e4m3fn/float8_e5m2 dtypes. When FP8-quantized models (FLUX, SD3.5, Wan 2.2, LTX-Video) are loaded on Apple Silicon, the quantization step crashes with: TypeError: Trying to convert Float8_e4m3fn to the MPS backend but it does not have support for that dtype. This adds device-aware fallbacks that move tensors to CPU for the FP8 quantization step only. The rest of inference remains on MPS. Three code paths are patched: - comfy/float.py: stochastic_rounding() — also fixes the secondary "Placeholder storage has not been allocated on MPS device!" error caused by torch.Generator being bound to MPS. - comfy/float.py: stochastic_round_quantize_nvfp4*() — these create float8_e4m3fn block scales internally. - comfy/quant_ops.py: _TensorCoreFP8LayoutBase.quantize() — the ck.quantize_per_tensor_fp8 path also fails on MPS. Fixes: #6995, #9255, #11626, #11817 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| compare | ||
| execution | ||
| inference | ||
| __init__.py | ||
| conftest.py | ||
| README.md | ||
| test_fp8_mps.py | ||
Automated Testing
Running tests locally
Additional requirements for running tests:
pip install pytest
pip install websocket-client==1.6.1
opencv-python==4.6.0.66
scikit-image==0.21.0
Run inference tests:
pytest tests/inference
Quality regression test
Compares images in 2 directories to ensure they are the same
- Run an inference test to save a directory of "ground truth" images
pytest tests/inference --output_dir tests/inference/baseline
-
Make code edits
-
Run inference and quality comparison tests
pytest