Newshot

Show HN: Vantage-V-AI – 带注意力汇的 2-bit 三值 KV 缓存

Translation(model translation, not the source's own text)

Vantage V-AI:有界内存流式引擎、2-bit 打包三进制 KV 缓存与 HDC 关联记忆

题图
题图

Vantage V-AI(v8.2.0)是一个开源的、有界内存的推理运行时和流式数据处理引擎,旨在解决 KV 缓存内存爆炸问题,并在 CPU、边缘设备和多 GPU 加速器上实现恒定复杂度的自回归生成。

  • 📄 技术报告(同行评审版):paper/VANTAGE_Paper_v8.2.pdf | LaTeX 源码
  • 🔬 任务质量基准测试:artifacts/benchmarks/task_quality_benchmark.json
  • ⚡ 多 GPU 端到端基准测试:artifacts/benchmarks/benchmark_gpu_kaggle_v8_2.json

🛡️ 作者身份、在先技术与知识产权声明

  • 主要作者与架构师:Nguyen Vo Anh Khoa (@khoadev-vn)
  • 官方仓库:https://github.com/khoadev-vn/VANTAGE-V-AI
  • 首次公开披露(在先技术):2026 年 11 月(Git 提交历史与加密时间戳)
  • 法律保护:基于 MIT 许可证授权。根据国际版权法与开源合规标准,对本代码库或其衍生作品的任何分发、再分发、嵌入或商业使用,均严格要求保留原始版权声明与作者署名:Copyright (c) 2026 Nguyen Vo Anh Khoa. All rights reserved.

        Copyright (c) 2026 Nguyen Vo Anh Khoa. All rights reserved.
      

⚡ 快速开始:两行代码即插即用集成

Vantage 可与任意 Hugging Face AutoModelForCausalLM 透明集成,无需修改现有的生成循环或模型定义:


        import vantage
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load any open-weight model (Meta Llama-3, Qwen-2.5, DeepSeek-R1, Mistral)
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-3B-Instruct", torch_dtype="auto", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-3B-Instruct")

# 1-Line Drop-in: bounds active attention window and anchors 4 sink tokens
vantage.enable(model, max_active_tokens=256, sink_tokens=4, quant_mode="fp8")

# Standard generation code runs unchanged with bounded attention memory!
inputs = tokenizer("The future of artificial intelligence depends on", return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=64)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
      

🖥️ 交互式终端演示

在终端中运行可视化流式监控演示:


        python vantage_demo.py
      

🔬 核心架构基础(v8.2.0)

  • 多 GPU 硬件实证验证(2× NVIDIA Tesla T4,Qwen2.5-3B-Instruct):在真实 CUDA 加速器上进行基准测试,模型参数分片分布于两块设备(cuda:0:1.85B 参数,cuda:1:1.23B 参数)。遵循 PyTorch 异步执行协议,通过 torch.cuda.synchronize(d) 在所有参与的 GPU 上实现严格的多设备同步。无损模式与动态 FP8 流式模式之间实现 100.0% 精确 Token 一致性(64/64 个 token 完全相同)。
  • 在真实 CUDA 加速器上进行基准测试,模型参数分片分布于两块设备(cuda:0:1.85B 参数,cuda:1:1.23B 参数)。
  • 遵循 PyTorch 异步执行协议,通过 torch.cuda.synchronize(d) 在所有参与的 GPU 上实现严格的多设备同步。
  • 无损模式与动态 FP8 流式模式之间实现 100.0% 精确 Token 一致性(64/64 个 token 完全相同)。
  • 任务质量与长上下文权衡(大海捞针与 PPL 稳定性):在 512 至 4,096 token 的上下文跨度上进行评估,事实性针分别置于不同深度(10% 至 90%)。带注意力汇(Attention Sinks)的平均检索一致性为 0.988,避免了在无汇滑动窗口中所观察到的严重 softmax 崩溃(PPL 散度 $> 1,467$)。
  • 在 512 至 4,096 token 的上下文跨度上进行评估,事实性针分别置于不同深度(10% 至 90%)。
  • 0.988 平均检索一致性,配合 Attention Sinks,防止了在无 sink 的滑动窗口中所观察到的严重 softmax 坍缩(PPL 散度 $> 1,467$)。
  • 2 比特打包三值表示(灵感来自 BitNet b1.58):将多头注意力的键和值量化为三值状态 ${-1, 0, +1}$,并使用逐张量动态均值缩放 $\gamma = \text{mean}(|X|)$。采用向量化 SIMD 打包(每个 uint8 字节 4 个元素 = 2.0 比特/元素),相比 FP16 实现 7.97 倍存储缩减。
  • 将多头注意力的键和值量化为三值状态 ${-1, 0, +1}$,并使用逐张量动态均值缩放 $\gamma = \text{mean}(|X|)$。
  • 采用向量化 SIMD 打包(每个 uint8 字节 4 个元素 = 2.0 比特/元素),相比 FP16 实现 7.97 倍存储缩减。
  • 带 Attention Sinks 的流式 KV-Cache(灵感来自 StreamingLLM):在块级分块卸载缓存(VantageStreamingCache)中集成初始 attention sink 保留(sink_tokens=4)。锚定初始 softmax 质量,防止长序列生成过程中的自回归轨迹坍缩。
  • 在块级分块卸载缓存(VantageStreamingCache)中集成初始 attention sink 保留(sink_tokens=4)。
  • 锚定初始 softmax 质量,防止长序列生成过程中的自回归轨迹坍缩。
  • 超维计算(HDC)关联记忆(core/memory.py):将稠密嵌入投影为 4,096 位二值超向量。硬件加速的按位 XOR + SIMD popcount 搜索(np.bitwise_count),在扰动下对 5,000 个合成向量实现 100% 的 1-NN 召回率。
  • 将稠密嵌入投影为 4,096 位二值超向量。
  • 硬件加速的按位 XOR + SIMD popcount 搜索(np.bitwise_count),在扰动下对 5,000 个合成向量实现 100% 的 1-NN 召回率。

📊 多 GPU 实证基准测试结果(v8.2.0)

在 2 块 NVIDIA Tesla T4 GPU(Turing 架构,计算能力 7.5,总显存 32 GB)上使用 Qwen/Qwen2.5-3B-Instruct 测试(FP16,提示:1024 tokens,生成:64 tokens,多设备同步):

缓存配置端到端墙钟时间CUDA 吞吐量GPU 0 显存与无损版本的成对一致性与完整上下文的匹配度
标准 Hugging Face 全注意力3.582 s17.87 tok/s6,842.0 MBN/A64/64(参考)
Vantage Streaming(W=128,Sink=4,无损)3.372 s18.98 tok/s6,842.0 MBN/A17/64(26.6%)
Vantage Streaming(W=256,无 Sink,无损)3.398 s18.83 tok/s6,842.0 MBN/A20/64(31.2%)
Vantage Streaming(W=256,Sink=4,无损)3.398 s18.83 tok/s6,842.0 MB参考17/64(26.6%)
Vantage Streaming(W=256,Sink=4,FP8)3.454 s18.53 tok/s6,842.0 MB64/64(100.0%)17/64(26.6%)
Vantage Streaming(W=512,Sink=4,无损)3.454 s18.53 tok/s6,842.0 MBN/A18/64(28.1%)

原始可验证 JSON 产物:artifacts/benchmarks/benchmark_gpu_kaggle_v8_2.json。

🎯 任务质量与困惑度稳定性(长上下文)

在不同上下文长度($N \in {512, 1024, 2048, 4096}$)上评估,以刻画上下文权衡:

上下文范围针放置位置VANTAGE(Sinks=4)滑动窗口(Sinks=0)
512 tokens10% - 90% 深度1.00(完美检索)0.88(退化)
1,024 tokens10% 深度(Sink 区域)1.00(锚点保留)0.35(Softmax 丢失)
1,024 tokens90% 深度(近期窗口)1.00(窗口保留)0.88(退化)
2,048 tokens多深度平均0.95(有界权衡)0.35(Softmax 坍缩)
困惑度(PPL)序列步长 = 2,048PPL = 10.04(稳定)PPL = 1,467.26(爆炸)

原始任务质量产物:artifacts/benchmarks/task_quality_benchmark.json。

📚 学术引用(BibTeX)


        @software{nguyen2026vantage,
  author       = {Nguyen, Vo Anh Khoa},
  title        = {{VANTAGE-V-AI: Bounded-Memory Streaming Engine, 2-Bit Packed Ternary KV-Cache and Associative Memory Runtime for Large Language Models}},
  year         = {2026},
  publisher    = {GitHub},
  journal      = {GitHub repository},
  howpublished = {\url{https://github.com/khoadev-vn/VANTAGE-V-AI}},
  version      = {8.2.0}
}
      

📄 许可证与合规

本项目采用 MIT 许可证 — 详情请参阅 LICENSE 文件。


        Copyright (c) 2026 Nguyen Vo Anh Khoa. All rights reserved.
      

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗