arXiv:2607.15105cs.AI2026-07

HGA让小显存设备训练超长文本,16G显卡跑16K上下文。

Long-Context Fine-Tuning with Limited VRAM

  • 用分段反向传播+分层键值存储,只保留当前段在显存中。
  • 4-bit QLoRA下16G显卡支持16384长序列训练,峰值显存15.28G。
  • 适合显存有限但需处理长文档的场景,如本地部署与低成本微调。

参数高效微调可降低模型与优化器内存占用,但密集注意力仍使长序列训练成本高昂。本文结合分层全局注意力(HGA)、分段反向传播与分层键值存储:仅活跃段保留在显存中,旧键值对移至内存或NVMe;HGA为每个查询块加载固定数量的历史准确标记。在4位QLoRA与PG19数据集上,使用16GB Quadro RTX 5000显卡,密集训练在2048标记时可行,但4096标记失败;而采用HGA后可达到16384标记,峰值显存仅15.28GB。评估阶段同一适配器可处理131,072标记,显存随驻留块摘要缓慢增长,实际上限由内存与NVMe容量决定。在共享2048标记训练长度下,HGA与密集训练适配器分别获得2.7405与2.7383 nat(相同密集注意力读出),而原始模型为2.9541 nat。此时HGA训练已略快(217.75 vs. 207.02 tokens/s),且随着上下文增长,其吞吐比优势将进一步扩大,因HGA每标记保持恒定注意力历史量,而密集计算量随上下文线性增长。主质量与检索对比仍使用密集注意力,以确保权重学习可比性并兼容标准生成框架。HGA亦可用于检索与生成,优化生产级部署正在开发中。

原文摘要 · Abstract (English)

Parameter-efficient fine-tuning reduces model and optimizer memory, but dense attention still makes long training sequences expensive. We combine Hierarchical Global Attention (HGA) with segment-wise backpropagation and tiered KV storage. Only the active segment remains differentiable in VRAM; older KV is detached into RAM or NVMe, and HGA loads a bounded set of exact historical tokens for each query block. On Qwen3-8B with 4-bit QLoRA and PG19, dense training on a 16 GB Quadro RTX 5000 fits 2,048 tokens but fails at 4,096, whereas HGA reaches 16,384 tokens with 15.28 GB peak VRAM. Under evaluation the same adapter runs through 131,072 tokens on this card; VRAM is not constant but grows gently with the resident chunk summaries, so RAM and NVMe capacity set the practical limit beyond these lengths. At the shared 2K training length, HGA-trained and dense-trained adapters obtain 2.7405 and 2.7383 nat under the same dense-attention readout, while the stock model obtains 2.9541. At this boundary HGA training is already marginally faster (217.75 vs. 207.02 tokens/s), and the HGA-to-dense throughput ratio improves from 1K to 2K; because HGA keeps the attended historical set per token approximately constant while dense work per token grows, we expect this lead to widen as context grows. Dense attention is used for the main quality and retrieval comparisons so that they measure the learned weights and remain compatible with standard generation frameworks. HGA can also be used for retrieval and generation; an optimized production-grade serving implementation is under development.

长文本显存优化微调高效训练

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。