{
  "schema_version": "1.0",
  "id": "T-efd4e8eadefb",
  "url": "https://gpuatlas.top/articles/T-efd4e8eadefb/",
  "title": "12G 显存跑本地模型，怎么给长上下文留空间？",
  "summary": "12G长文没有统一上限，应按精确结构、权重精度与缓存联合预算，并核对真实任务证据。",
  "language": "zh-Hans",
  "category": {
    "id": "c-11",
    "name": "按显存找方案",
    "url": "https://gpuatlas.top/categories/c-11/"
  },
  "topics": [],
  "body_text": "12G显存跑长文，先选具体模型，再安排权重与缓存。同参数量可能有不同层数、KV头和混合状态，容量标签不对应统一token上限。\n\n以Qwen3 8B为条件例子，常规单序列16bit KV在16384 token约2.25GiB、32768约4.5GiB，权重、分页和缓冲未计。高位权重留下余量较少，低位可以减少部分驻留，但质量和实际执行支持需核对。\n\n权重量化与缓存量化分别记录，不自动都按4bit。固定文件与单请求，从短材料逐档增加，正文、模板、系统说明、历史与答案共同计token，不能只看上传文件字符数。\n\n分别记录加载、输入处理和生成峰值，框架预分配与动态状态分开解释，CPU参与加入主存和完整等待。缩短输出不一定解决输入处理压力，每次只改一项重跑原请求。\n\n遇到12G装不下的资料，可在任务允许时尝试检索或分段。先标出答案需要的证据，尤其是分处不同段落的关系，再用材料前、中、后的已知事实核对引用与遗漏。如果分段后无法串起关键关系，就要调整取材方式；只把最大长度调小，并不表示日常材料处理已经完成。",
  "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": "transformers-kv-cache",
      "url": "https://raw.githubusercontent.com/huggingface/transformers/main/docs/source/en/kv_cache.md",
      "retrieved_at": "2026-11-25T10:07:29.175278+00:00"
    },
    {
      "id": "qwen3-8b-config",
      "url": "https://huggingface.co/Qwen/Qwen3-8B/resolve/main/config.json",
      "retrieved_at": "2026-11-25T10:34:57.629275+00:00"
    },
    {
      "id": "vllm-memory",
      "url": "https://raw.githubusercontent.com/vllm-project/vllm/main/docs/configuration/conserving_memory.md",
      "retrieved_at": "2026-11-25T09:52:45.997121+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-efd4e8eadefb/",
    "json": "https://gpuatlas.top/data/articles/T-efd4e8eadefb.json",
    "markdown": "https://gpuatlas.top/data/articles/T-efd4e8eadefb.md"
  }
}
