{
  "id": "huggingface/mps-fp16-cast-error",
  "signature": "RuntimeError: Placeholder storage has not been allocated on MPS device",
  "signature_zh": "运行时错误：MPS设备上未分配占位符存储",
  "regex": "Placeholder storage has not been allocated on MPS device",
  "domain": "huggingface",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Model weights or tensors are being cast to float16 on Apple MPS backend which does not fully support FP16, causing allocation failure.",
  "root_cause_type": "generic",
  "root_cause_zh": "模型权重或张量在Apple MPS后端上被转换为float16，但MPS不完全支持FP16，导致分配失败。",
  "versions": [
    {
      "version": "transformers>=4.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "MPS backend has limited FP16 support; explicit FP16 casting triggers the error.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Half-precision conversion on MPS is not fully implemented and causes memory allocation errors.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Load model with torch_dtype=torch.float32 and use model.to('mps') without half precision.",
      "success_rate": 0.85,
      "how": "Load model with torch_dtype=torch.float32 and use model.to('mps') without half precision.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable MPS memory allocation optimization.",
      "success_rate": 0.7,
      "how": "Set environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable MPS memory allocation optimization.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use CPU fallback by setting device='cpu' and use float16 with CPU if memory is a concern.",
      "success_rate": 0.95,
      "how": "Use CPU fallback by setting device='cpu' and use float16 with CPU if memory is a concern.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Load model with torch_dtype=torch.float32 and use model.to('mps') without half precision.",
    "Set environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable MPS memory allocation optimization.",
    "Use CPU fallback by setting device='cpu' and use float16 with CPU if memory is a concern."
  ],
  "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}