{
  "id": "pytorch/mps-scalar-type-mismatch",
  "signature": "RuntimeError: MPS backend out of memory (MPS backend does not support float64, falling back to float32)",
  "signature_zh": "RuntimeError：MPS后端内存不足（MPS后端不支持float64，回退到float32）",
  "regex": "MPS backend out of memory|MPS backend does not support float64",
  "domain": "pytorch",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "MPS (Metal Performance Shaders) backend on Apple Silicon does not support float64 (double precision) tensors, causing fallback or crash when operations require double precision.",
  "root_cause_type": "generic",
  "root_cause_zh": "Apple Silicon上的MPS（Metal Performance Shaders）后端不支持float64（双精度）张量，当操作需要双精度时会导致回退或崩溃。",
  "versions": [
    {
      "version": "torch>=2.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "macOS>=13.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MPS>=1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only affects memory allocation limits, not type support; float64 operations still fail.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "MPS hardware/driver inherently lacks float64 support; no software update can add it.",
      "fail_rate": 0.99,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Explicitly cast tensors to float32 before MPS operations: tensor = tensor.float()",
      "success_rate": 0.95,
      "how": "Explicitly cast tensors to float32 before MPS operations: tensor = tensor.float()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use CPU or CUDA backend for parts of model requiring float64, then move back: model.to('cpu').double()",
      "success_rate": 0.8,
      "how": "Use CPU or CUDA backend for parts of model requiring float64, then move back: model.to('cpu').double()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable MPS fallback: torch.set_default_dtype(torch.float32) and ensure all model parameters are float32",
      "success_rate": 0.9,
      "how": "Disable MPS fallback: torch.set_default_dtype(torch.float32) and ensure all model parameters are float32",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Explicitly cast tensors to float32 before MPS operations: tensor = tensor.float()",
    "Use CPU or CUDA backend for parts of model requiring float64, then move back: model.to('cpu').double()",
    "Disable MPS fallback: torch.set_default_dtype(torch.float32) and ensure all model parameters are float32"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pytorch.org/docs/stable/notes/mps.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-09-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}