StateTree-Representation:讓 LLM 壓縮後仍保留 BF16 精度

StateTree 同時壓縮模型權重與 KV cache,減少記憶體佔用之餘,生成結果仍可逐 bit 對齊 BF16。

BF16 and statetree answering the same question side by side in vLLM; statetree finishes first with the identical answer

大型語言模型在長上下文或多請求場景,瓶頸往往不是算力,而是反覆讀取權重和 KV cache。StateTree 以約 12 bits 儲存原本 16-bit 的資料,屬於結合模型表示法與推理引擎的開源項目,處理的是記憶體流量、快取容量與生成速度之間的取捨。

它把每組權重表示成共享離散決策的 state tree,並以 fused CUDA kernels 直接在 vLLM 和 🤗 Transformers 中解碼;KV cache 則以每個 vLLM block 16 tokens、每個 KV head 四組 16 × 64 records 儲存。權重與 cached key/value 都能還原至 exact BF16 bits,不涉及 quantization、calibration 或精度換取壓縮率。

Qwen3-8B 在單張 A100-40GB、vLLM 0.32 的測試中,權重由 15.3 GiB 降至 12.8 GiB,KV cache 每 token 由 144 KiB 降至 112.5 KiB;同一 GPU 預算可容納 1.49 倍 tokens,batch 1 生成速度由 75.6 提升至 97.2 tok/s,完整回答快 1.10 至 1.28 倍。Decode attention 相對 FlashAttention-2 則達 1.21 至 2.46 倍,但結果會受 GPU、批次大小和上下文長度影響。

測試需要 NVIDIA sm_80 或更新架構、CUDA 12.6,以及項目列出的 PyTorch、vLLM 0.32 或 Transformers 5.0 環境;可先用 greedy generation、prefix-cache hit 和長 prompt chunk prefill 對比 BF16。teacher-forced top-1 token 一致率為 97.6% 至 99.8%,差異集中於近似機率的 token,適合重視容量和吞吐、又不能接受量化誤差的推理服務團隊。

  • 權重及 KV cache 均可逐 bit 還原至 BF16
  • 權重佔用減少 24%,KV cache 佔用減少 22%
  • 支援 vLLM fused kernels、paged blocks 和 prefix caching
  • 測試結果涵蓋小 batch、長上下文及多請求情境
  • 需要相容的 NVIDIA GPU、CUDA 與指定框架版本

項目主頁 · GitHub

Categories: 開源, 模型, Qwen, NVIDIA, 框架, Python, 推理引擎