ComfyUI/tests
Tashdid Khan edd44a6874 fix: add CPU fallback for FP8 quantization on MPS (Apple Silicon)
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>
2026-02-09 21:21:31 -05:00
..
compare Fix and enforce no trailing whitespace. 2024-12-31 03:16:37 -05:00
execution feat: add cancelled filter to /jobs (#11680) 2026-01-08 21:57:36 -08:00
inference Fix progress update crossover between users (#9706) 2025-09-04 19:13:28 -04:00
__init__.py Ci quality workflows (#1423) 2023-09-18 23:18:06 -04:00
conftest.py Fix progress update crossover between users (#9706) 2025-09-04 19:13:28 -04:00
README.md Ci quality workflows (#1423) 2023-09-18 23:18:06 -04:00
test_fp8_mps.py fix: add CPU fallback for FP8 quantization on MPS (Apple Silicon) 2026-02-09 21:21:31 -05:00

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

  1. Run an inference test to save a directory of "ground truth" images
    pytest tests/inference --output_dir tests/inference/baseline
  1. Make code edits

  2. Run inference and quality comparison tests

pytest