# RuntimeError: MPS backend does not support float64. Falling back to float32. Please cast your tensors to float32 explicitly

- **ID:** `pytorch/mps-float64-fallback`
- **Domain:** pytorch
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Apple MPS (Metal Performance Shaders) backend lacks support for float64 (double precision) tensors, causing operations to fail or silently fall back to float32, which may lead to precision loss or type mismatches.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| torch>=1.12.0 | active | — | — |
| macOS>=12.3 | active | — | — |
| MPS>=1.0 | active | — | — |

## Workarounds

1. **Explicitly cast all input tensors to float32 before moving to MPS: tensor = tensor.float().to('mps'). For models, use model = model.float().to('mps').** (95% success)
   ```
   Explicitly cast all input tensors to float32 before moving to MPS: tensor = tensor.float().to('mps'). For models, use model = model.float().to('mps').
   ```
2. **Override the default dtype at the start of your script: torch.set_default_dtype(torch.float32). Also ensure all data loaders yield float32 tensors by adding a transform: transforms.ConvertImageDtype(torch.float32).** (90% success)
   ```
   Override the default dtype at the start of your script: torch.set_default_dtype(torch.float32). Also ensure all data loaders yield float32 tensors by adding a transform: transforms.ConvertImageDtype(torch.float32).
   ```

## Dead Ends

- **** — Tensors already created as float64 remain float64; only newly created tensors are affected. (60% fail)
- **** — Float16 may underflow or overflow in training, leading to NaN loss or convergence issues. (70% fail)
