{
  "schema_version": "1.0",
  "id": "T-517408318344",
  "url": "https://gpuatlas.top/articles/T-517408318344/",
  "title": "LLaMA-Factory 多卡训练，为什么每张卡都放了一整份模型？",
  "summary": "LLaMA-Factory多卡出现模型副本可能是数据并行预期行为，容量分片需检查实际策略及完整保存恢复。",
  "language": "zh-Hans",
  "category": {
    "id": "c-09",
    "name": "框架配置与故障",
    "url": "https://gpuatlas.top/categories/c-09/"
  },
  "topics": [
    {
      "id": "task-b96aecbcf0",
      "name": "多卡",
      "kind": "task",
      "description": "需要把模型拆到多张卡，还是各卡独立提供服务？查阅并行方式、通信初始化与利用率问题。",
      "url": "https://gpuatlas.top/topics/task-b96aecbcf0/"
    },
    {
      "id": "task-796e01d5af",
      "name": "训练",
      "kind": "task",
      "description": "模型训练时的资源占用与推理不同。查看优化器、激活值、并行策略和中断恢复相关问题。",
      "url": "https://gpuatlas.top/topics/task-796e01d5af/"
    }
  ],
  "body_text": "LLaMA-Factory多卡训练时每卡看起来都有整份模型，普通数据并行下可能正是预期行为。各进程保存副本、处理不同样本并同步梯度，多个设备参与不等于权重自动切成几段。\n\n先查启动日志和有效配置，确认DDP、FSDP、ZeRO或其他模型切分的实际方式。不同阶段的分片会涉及不同状态，不能看到每卡占用相近，就判断所有权重或优化器必然复制。\n\n若目标是让单卡放不下的模型训练，增加普通数据副本通常解决不了容量。需选择框架与模型、量化、适配器方法明确兼容的参数或状态分片，并考虑激活和临时聚合仍可能出现峰值。\n\n先完成真实长度的前向、反向与更新，记录每卡峰值和通信等待。有效批量只按实际数据并行副本计算，参与模型切分的卡不能一律当独立样本副本，改变策略后要重新核对。\n\n更多样本同时训练是吞吐目标，每卡保留副本可能符合预期；一张卡连模型都装不下则是容量问题，应检查实际启用的分片方式。选定策略后还要走完保存、恢复与导出，因为训练时分散的状态可能在这些阶段重新聚合。不要只为让显存图看起来更平均而更换并行方式。",
  "published_at": null,
  "modified_at": "2026-11-26T15:17:38.690397+00:00",
  "evidence": {
    "type": "documentation_and_conditional_estimates",
    "hardware_tested": false,
    "note": "资料解释与条件估算，非硬件实测。"
  },
  "sources": [
    {
      "id": "llamafactory",
      "url": "https://raw.githubusercontent.com/hiyouga/LLaMA-Factory/main/README.md",
      "retrieved_at": "2026-11-25T09:52:45.997121+00:00"
    },
    {
      "id": "torch-distributed",
      "url": "https://docs.pytorch.org/docs/2.15/distributed.html",
      "retrieved_at": "2026-11-25T10:16:15.738480+00:00"
    },
    {
      "id": "torch-fsdp",
      "url": "https://docs.pytorch.org/docs/2.15/fsdp.html",
      "retrieved_at": "2026-11-25T10:21:36.176985+00:00"
    },
    {
      "id": "deepspeed-zero",
      "url": "https://deepspeed.readthedocs.io/en/latest/zero3.html",
      "retrieved_at": "2026-11-25T10:21:36.176985+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-517408318344/",
    "json": "https://gpuatlas.top/data/articles/T-517408318344.json",
    "markdown": "https://gpuatlas.top/data/articles/T-517408318344.md"
  }
}
