{
  "schema_version": "1.0",
  "id": "T-485dfd6b6468",
  "url": "https://gpuatlas.top/articles/T-485dfd6b6468/",
  "title": "FP16 和 BF16 占用差不多，跑模型该选哪个？",
  "summary": "FP16与BF16存储相近但范围和精度分配不同，应按模型、硬件及混合精度实现选择。",
  "language": "zh-Hans",
  "category": {
    "id": "c-03",
    "name": "量化与文件选择",
    "url": "https://gpuatlas.top/categories/c-03/"
  },
  "topics": [],
  "body_text": "FP16与BF16普通标量都为16位，权重容量常接近，数值范围和有效精度分配却不同，不能只因显存相近就完全互换。先看模型建议、设备与实际内核支持。\n\nBF16指数范围更宽，FP16有不同的精度和范围取舍。某些计算更易溢出，但训练稳定还取决于数据、学习率、优化器及混合精度策略，换类型不能保证修复所有NaN。\n\n框架能创建张量不代表设备高效执行全部相关运算，注意力、量化和其他组件也可能有类型条件。核对实际路径，旧扩展或回退不能用dtype标签掩盖。\n\n推理先用明确支持基线，固定任务、模板和输出比较质量、峰值及完整时间。训练出现非有限值时，定位最早层或步骤，连同梯度缩放、数据与更新检查，不只追求切成另一精度后不报错。\n\n使用4bit基础时，也要分别记下权重存储类型和实际计算类型，部分运算使用BF16或FP16并不矛盾。若只是做推理，核对原请求的答案和运行路径即可；若用于训练，还需完成一次更新并验证保存后能恢复。记录框架与内核，避免把一个dtype标签当成整个流程所有张量的类型。",
  "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": "torch-dtypes",
      "url": "https://docs.pytorch.org/docs/2.15/tensor_attributes.html",
      "retrieved_at": "2026-11-25T10:13:38.582093+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": "flashattention",
      "url": "https://raw.githubusercontent.com/Dao-AILab/flash-attention/main/README.md",
      "retrieved_at": "2026-11-25T10:07:29.175278+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-485dfd6b6468/",
    "json": "https://gpuatlas.top/data/articles/T-485dfd6b6468.json",
    "markdown": "https://gpuatlas.top/data/articles/T-485dfd6b6468.md"
  }
}
