{
  "schema_version": "1.0",
  "id": "T-3c9fb9f32a18",
  "url": "https://gpuatlas.top/articles/T-3c9fb9f32a18/",
  "title": "Gemma 4 12B 微调时想保留长文本，哪些设置最占显存？",
  "summary": "Gemma 4 12B长文训练先核有效答案和实际模态，再按基础驻留、激活及微批量定位，256K不是反向训练保证。",
  "language": "zh-Hans",
  "category": {
    "id": "c-18",
    "name": "模型微调",
    "url": "https://gpuatlas.top/categories/c-18/"
  },
  "topics": [
    {
      "id": "model-bf587b53c1",
      "name": "Gemma 4",
      "kind": "model",
      "description": "这里整理已有 Gemma 4 相关文章的配置问题；实际使用前，需核对文章所指版本、来源与框架支持。",
      "url": "https://gpuatlas.top/topics/model-bf587b53c1/"
    },
    {
      "id": "task-e33d9598da",
      "name": "微调",
      "kind": "task",
      "description": "让模型适应自己的任务，从训练方式、样本和显存预算入手，最后验证适配器是否真正起效。",
      "url": "https://gpuatlas.top/topics/task-e33d9598da/"
    },
    {
      "id": "task-a7bab8d8aa",
      "name": "长文本",
      "kind": "task",
      "description": "长文本训练会增加哪些中间开销？查看序列长度与 batch 的取舍，避免只按模型权重估算显存。",
      "url": "https://gpuatlas.top/topics/task-a7bab8d8aa/"
    }
  ],
  "body_text": "先检查处理后样本和损失范围，再选择长度。Gemma 4 12B Unified的256K推理能力不等于训练能承受同样序列，静态加载参考也没有覆盖反向激活和训练状态。\n\n模板、历史、回答、截断、填充和打包都要核对，保留材料时确认关键答案仍在。图像或音频样本保存处理设置，无独立编码器不等于模态处理和激活没有成本，文本token相同不代表工作量相同。\n\n明确格式、冻结范围、目标模块、rank与精度，QAT发布不自动证明当前低位训练路径可用。先核前向、反向和保存支持，用真实长样本完成更新，观察各阶段峰值。\n\n如果基础驻留已不足，先核支持的精度和布局；如果反向才超预算，再比较微批量、长度组织与检查点。梯度累积不消除单条长样本需求，重计算与分片通信都要计入完整时间。\n\n选择长度时，用一份未参与训练的长材料核对关键答案是否仍在输入中，再检查恢复后的回答；涉及图像或音频时，也要保留原素材和处理设置。若文本token相同但峰值不同，先对照模态输入，避免将处理条件变化误认为长文本配置的收益。",
  "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": "gemma4-card",
      "url": "https://raw.githubusercontent.com/google-gemma/docs/main/docs/models/gemma-4/model-card.md",
      "retrieved_at": "2026-11-25T11:31:21.126309+00:00"
    },
    {
      "id": "gemma4-official",
      "url": "https://raw.githubusercontent.com/google-gemma/docs/main/docs/models/gemma-4/index.md",
      "retrieved_at": "2026-11-25T11:31:21.126309+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"
    },
    {
      "id": "llamafactory-data-args",
      "url": "https://raw.githubusercontent.com/hiyouga/LLaMA-Factory/main/src/llamafactory/hparams/data_args.py",
      "retrieved_at": "2026-11-25T11:04:14.292936+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-3c9fb9f32a18/",
    "json": "https://gpuatlas.top/data/articles/T-3c9fb9f32a18.json",
    "markdown": "https://gpuatlas.top/data/articles/T-3c9fb9f32a18.md"
  }
}
