{
  "schema_version": "1.0",
  "id": "T-0ca8a9045321",
  "url": "https://gpuatlas.top/articles/T-0ca8a9045321/",
  "title": "给 Llama 3.1 8B 做 QLoRA，怎么估算自己显存够不够？",
  "summary": "Llama 3.1 8B QLoRA理想4GB只是名义基础权重，适配器状态、激活和实际长度决定完整训练预算。",
  "language": "zh-Hans",
  "category": {
    "id": "c-18",
    "name": "模型微调",
    "url": "https://gpuatlas.top/categories/c-18/"
  },
  "topics": [
    {
      "id": "model-c62822b7bd",
      "name": "Llama 3.1",
      "kind": "model",
      "description": "从 8B 等具体版本出发，检查不同显卡上的量化运行条件，随后再安排上下文与微调预算。",
      "url": "https://gpuatlas.top/topics/model-c62822b7bd/"
    }
  ],
  "body_text": "先固定Llama 3.1 8B Base或Instruct及低位训练路径。名义8B统一4bit原始数据约4GB，实际参数、元数据和未量化部分另核，不能作为总训练需求。\n\n低位基础通常冻结，目标适配器仍需参数、梯度和优化器状态，模块、rank与状态精度影响大小。反向激活和缓冲受长度、微批量与实现影响，不能跟随权重全部按4bit算。\n\n按支持流程准备模型并核实际可训练参数，用真实处理后样本完成前向、反向与更新。模板、历史、回答和损失范围都要检查，短样本加载成功不是长文训练验收。\n\n先区分基础驻留和反向压力，再分别比较精度布局、微批量、长度与检查点。梯度累积不让单条过长输入自动装下，分片、卸载、通信和重计算应加入完整时间，保存汇总也要观察。\n\n把候选配置跑到适配器保存，再在新进程里恢复Llama 3.1 8B。若用途是长文问答，就用未参与训练的材料核对回答与证据是否一致，同时留意通用题是否退步。这个结果连同量化、模块、rank和实际token数，才是选择显存方案的依据，不能套用另一张8B训练截图。",
  "published_at": null,
  "modified_at": "2026-11-26T15:00:32.276655+00:00",
  "evidence": {
    "type": "documentation_and_conditional_estimates",
    "hardware_tested": false,
    "note": "资料解释与条件估算，非硬件实测。"
  },
  "sources": [
    {
      "id": "llama31-card",
      "url": "https://raw.githubusercontent.com/meta-llama/llama-models/main/models/llama3_1/MODEL_CARD.md",
      "retrieved_at": "2026-11-25T11:28:43.769677+00:00"
    },
    {
      "id": "peft-quantization",
      "url": "https://raw.githubusercontent.com/huggingface/peft/main/docs/source/developer_guides/quantization.md",
      "retrieved_at": "2026-11-25T09:52:45.997121+00:00"
    },
    {
      "id": "transformers-training-memory",
      "url": "https://raw.githubusercontent.com/huggingface/transformers/main/docs/source/en/model_memory_anatomy.md",
      "retrieved_at": "2026-11-25T10:16:15.738480+00:00"
    },
    {
      "id": "torch-checkpoint",
      "url": "https://docs.pytorch.org/docs/2.15/checkpoint.html",
      "retrieved_at": "2026-11-25T10:16:15.738480+00:00"
    }
  ],
  "revision_note": "更新使用说明与操作示例；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-0ca8a9045321/",
    "json": "https://gpuatlas.top/data/articles/T-0ca8a9045321.json",
    "markdown": "https://gpuatlas.top/data/articles/T-0ca8a9045321.md"
  }
}
