def test_autocast_does_not_use_cuda_on_mps(precision):
    """Ensure Fabric.autocast on MPS does not fall back to CUDA when using (bf)16-mixed precision."""
    fabric = Fabric(accelerator="mps", precision=precision)
    fabric.launch()

    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        with fabric.autocast():
            pass

    for warning in w:
        assert "device_type of 'cuda'" not in str(warning.message)
Ensure Fabric.autocast on MPS does not fall back to CUDA when using (bf)16-mixed precision.
tests/tests_fabric/test_fabric.py