{
  "id": "pytorch/ddp-bucket-view-error",
  "signature": "RuntimeError: BucketView has wrong size: expected X, got Y. This could be due to mismatched model parameters across ranks.",
  "signature_zh": "RuntimeError: BucketView 大小错误：预期 X，得到 Y。这可能是由于不同 rank 上的模型参数不匹配所致。",
  "regex": "BucketView has wrong size: expected \\d+, got \\d+",
  "domain": "pytorch",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "In Distributed Data Parallel (DDP), the model parameters have different sizes or structures across different ranks, often because of inconsistent model initialization or different batch normalization configurations.",
  "root_cause_type": "generic",
  "root_cause_zh": "在分布式数据并行 (DDP) 中，不同 rank 上的模型参数大小或结构不同，通常是因为模型初始化不一致或批归一化配置不同。",
  "versions": [
    {
      "version": "1.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This doesn't fix the underlying parameter mismatch; it just changes the bucket size limit.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This can mask the issue but may lead to incorrect gradients if parameters are truly mismatched.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all ranks have the same model architecture and initialization. Use a consistent seed and load the same pretrained weights on all ranks before wrapping with DDP.",
      "success_rate": 0.85,
      "how": "Ensure all ranks have the same model architecture and initialization. Use a consistent seed and load the same pretrained weights on all ranks before wrapping with DDP.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using SyncBatchNorm, ensure it is applied consistently across all ranks before DDP wrapping.",
      "success_rate": 0.8,
      "how": "If using SyncBatchNorm, ensure it is applied consistently across all ranks before DDP wrapping.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure all ranks have the same model architecture and initialization. Use a consistent seed and load the same pretrained weights on all ranks before wrapping with DDP.",
    "If using SyncBatchNorm, ensure it is applied consistently across all ranks before DDP wrapping."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pytorch.org/docs/stable/distributed.html#distributed-data-parallel",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.78,
  "resolvable": "partial",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}