Repository navigation
Description
问题描述 / Problem Description
长上下文 rollout 的 attention KV 缓存限制可用上下文和并发。基线为 BF16 KV;比较固定上下文、并发和模型下的非对称低比特存储。FP8 KV 和已关闭的 #536 是参考背景。
Long-context attention KV limits rollout context and concurrency. Compare asymmetric low-bit storage against BF16 KV at fixed context, concurrency and model. FP8 KV and closed #536 provide background.
期望内容或功能改进 / Expected Improvements or Features
-
增加可选 KIVI 路径:key 按 channel、value 按 token 量化,保存尺度及近期未量化 residual 窗口。
Add opt-in KIVI storage with per-channel keys, per-token values, scales and a recent unquantized residual window.
-
接入增量 decode、窗口转移、缓存 reset,并为不支持的 attention 提供明确回退。
Integrate incremental decode, window transitions and cache reset, with explicit fallback for unsupported attention.
-
保留真实 behavior-policy log-probabilities,验证缓存 attention 和元数据生命周期。
Preserve actual behavior-policy log-probabilities and validate cached attention and metadata lifetime.
-
对照 BF16 KV 的内存、吞吐、生成质量及训练原生 log-probability 差异。
Compare memory, throughput, generation quality and native training log-probability divergence against BF16 KV.
范围边界 / Scope boundaries
首期单卡、一个 dense attention 模型、独立请求缓存;不要求共享 prefix、循环状态量化或其他 issue。
Initially target one GPU, one dense-attention model and private per-request caches; prefix sharing, recurrent-state quantization and other issues are out of scope.
验收标准 / Acceptance Criteria
验收环境:Linux + CUDA;使用一个 AReno 已支持且能装入内存的小型纯文本 dense 模型。固定提交、模型 revision、随机种子、dtype、batch/context 和软件版本;基线与新路径各预热 2 步、测量至少 10 步。报告 allocated/reserved 峰值、步耗时;统一内存设备另报系统内存占用,避免把 CPU offload 当成总内存减少。当前尚无本任务实测收益,首个交付需记录基线。
Validation environment: Linux + CUDA, with one supported small text-only dense model that fits memory. Fix commit, model revision, seed, dtype, batch/context and software versions; warm up each path for two steps and measure at least ten. Report allocated/reserved peaks and step time; on unified-memory devices also report system memory usage rather than treating CPU offload as total-memory savings. No measured gains are claimed yet; establish the baseline in the first deliverable.
-
测试 1024/4096/8192 token 缓存及 residual 边界;反量化结果与独立实现一致,reset 后无泄漏。缓存 attention 与同一量化张量参考结果满足 BF16 atol=rtol=1e-2。
Test caches of 1024/4096/8192 tokens and residual boundaries; dequantization matches an independent implementation and reset leaks no storage. Cached attention matches a reference using the same quantized tensors within BF16 atol=rtol=1e-2.
-
长于 residual 窗口的 8192-token 用例,包含尺度和 residual 的缓存字节数低于 BF16;报告完整峰值(含反量化 workspace)、decode 吞吐和下述质量对照。
For an 8192-token case longer than the residual window, cache bytes including scales/residual are below BF16; report total peak including dequantization workspace, decode throughput and the quality comparison below.
公共 Trainer 端到端运行须包含更新和保存/恢复;报告训练过程原生 train/logp_abs_diff_mean,不得另算替代。涉及近似更新/压缩的路径(GaLore、激活压缩、KIVI),固定数据和预算跑至少 3 个种子:最终验证 loss 相对基线增幅≤2%;若采用 RL 验收,同时报告 reward 曲线,平均末段 reward 不低于基线超过 0.05(reward 归一化到 [0,1])。以上是待验证的验收目标,不是已取得的结果。核心测试和仓库 checks 必须通过。
The public Trainer end-to-end run must include updates and save/resume; report its native train/logp_abs_diff_mean, not a separately computed substitute. For approximate updates/compression (GaLore, activation compression and KIVI), use fixed data/budget and at least three seeds: final validation loss must increase by no more than 2% versus baseline; if RL is used for acceptance, also report reward curves and a mean final-window reward no more than 0.05 below baseline on a [0,1] reward scale. These are acceptance targets to validate, not achieved results. Core tests and repository checks must pass.
完成方式与交付物 / Submission Method and Deliverables
向 oss-camp2026 分支提交 PR;交付代码、自动化测试、使用说明,以及包含基线/对照原始日志、命令、配置和误差/内存/吞吐表的可复现报告。演示视频不作要求。
Open a PR against oss-camp2026; deliver code, automated tests, usage documentation and a reproducible report containing baseline/comparison raw logs, commands, configuration and numerical-error/memory/throughput tables. A demo video is not required.
参考资料与环境 / References and Environment
- AReno: https://github.com/inclusionAI/AReno
- 论文 / Paper: https://arxiv.org/abs/2402.02750
开发和验收环境见上述验收标准;各任务可独立实现,不互相依赖。
See the acceptance section for development and validation environments. Each task is independently implementable with no dependency on the other tasks.
是否支持多人并行认领 / Can Multiple Contributors Claim This Task in Parallel?
是,可按不同方向并行认领并增量合入。
Yes. Distinct directions may be claimed in parallel and merged incrementally.
并行认领范围 / Scope for Parallel Claims
可分别认领核心实现、数值正确性与回归测试、性能评测及文档。认领时请在评论区登记具体子任务、接口边界和预计交付物;同一范围避免重复认领,重叠部分先协商拆分,再分别提交 PR。活动认领仍按下方云燕平台流程完成。
Contributors may claim core implementation, numerical correctness and regression tests, or benchmarking and documentation. Register the subtask, interface boundaries and expected deliverables in the comments when claiming. Avoid duplicate scopes; agree on a split for overlapping work before submitting separate PRs. Complete the event claim through the Yunyan process below.
是否要求 AI 使用策略报告 / Is an AI Usage Strategy Report Required?
不要求。
Not required.
发布前确认 / Pre-Publication Checklist
- 我已确认任务边界清晰,且适合学生在活动周期内完成。 / I have confirmed that the task has clear boundaries and can be completed by students during the event.
- 我已提供基线或参考实现,并确认验收标准可量化、可复现。 / I have provided a baseline or reference implementation and confirmed that the acceptance criteria are measurable and reproducible.
- 我已在标题前缀后补充一句话任务描述。 / I have added a concise task description after the title prefix.
首项待活动维护者结合活动周期确认。 / The first item awaits event-maintainer confirmation against the event schedule.
认领方式 / How to Claim This Issue
本 Issue 为【2026 蚂蚁开源轻训营 · 高校行】专属 Issue,仅供已报名参与活动的同学认领。
【认领方式】在云燕平台注册并点击认领按钮即认领成功。
【活动报名】注册云燕平台并加入“蚂蚁开源轻训营”实验室,信息收集将仅用于活动登记和奖励发放。
This Issue is exclusively for the 2026 Ant Open Source Camp University Tour and may only be claimed by students who have registered for the event.
[How to Claim] Register on the Yunyan platform and click the claim button. The task is successfully claimed once the action is confirmed.
[Event Registration] Register on the Yunyan platform and join the "Ant Open Source Camp" lab. Collected information will be used only for event registration and reward distribution.
Activity
[-]feat: add KIVI-style asymmetric low-bit KV-cache storage[/-][+]【2026 开源轻训营专属 Issue】KIVI 低比特 KV 缓存 / KIVI Low-Bit KV Cache[/+]EricChan2028 commentedon Oct 29, 2026
认领 / Claim:核心实现 + 数值正确性与回归测试 + 性能评测与文档(全部三部分;如有同学希望分担评测部分,欢迎协商拆分)
Claiming all three parts: core implementation, numerical-correctness/regression tests, and benchmarking + docs (happy to split benchmarking if someone else wants it).
接口边界 / Interface (opt-in, default unchanged)
RuntimeConfig.kv_cache_dtype: "auto" | "kivi2" | "kivi4"(defaultauto= model dtype),kivi_group_size=32,kivi_residual_length=128(paper defaults), reachable from the SDK throughCudaConfig(runtime={...}). I would also add--kv-cache-dtype / --kivi-group-size / --kivi-residual-lengthtoareno trainandareno serve; since AGENTS.md asks to confirm CLI/SDK config surfaces first, please let me know if you prefer different names.areno/accel/kernels/: group quantize/pack, a fused flush + append for decode, and a split-K decode attention that dequantizes paged tiles in registers (no full-cache BF16 materialization), CUDA-graph capturable.交付物 / Deliverables
train/logp_abs_diff_mean, save/resume.环境 / Env: Linux, RTX PRO 5000 72GB (Blackwell sm_120), CUDA 12.8, PyTorch 2.8.
问题 / Questions
oss-camp2026is currently 23 commits behindmain(KV-cache and decode-graph code changed in between), and recent camp PRs targetmain. Could the branch be synced, or should the PR targetmain?areno trainhas no seed option. For the 3-seed protocol I plan to drive the stock GSPO trainer from a small harness inexamples/kivi/that setsSamplingParams.seedper step (dataset order fixed). Would you prefer an opt-in--seedforareno traininstead (as a separate PR)?A working prototype with the tests above is in progress; I will open a draft PR once the measurements are complete.
EricChan2028 commentedon Oct 30, 2026
进度更新 / Progress update
PR:#641(单个提交,基于
maine17794c)。可复现报告见 PR 中的examples/kivi/README.md(命令、配置、误差/内存/吞吐表),原始日志在 fork 的kivi-590-artifacts分支。train/logp_abs_diff_meanKIVI-4 达到全部验收目标。KIVI-2 在默认 R=128 时 RL reward 低于 0.05 的目标,R=512 时达标;报告中按此给出推荐配置。
想请维护者确认三点:
oss-camp2026目前停在 25f5fed,比main落后 23 个提交,本改动依赖main上的引擎代码。PR 暂时提到main;能否把oss-camp2026同步到main,或者以main为准?同步后我可以把 PR 改到oss-camp2026。areno train/areno serve增加--kv-cache-dtype/--kivi-group-size/--kivi-residual-length?目前通过 SDK 的CudaConfig(runtime={...})使用,areno serve暂时无法开启。logprobs - logprobs.detach()),rollout 被当作 on-policy,rollout log-prob 只用于指标。量化 rollout(如 KIVI-2)的偏差因此得不到校正,这正是 KIVI-2 在 R=128 时训练停滞的原因。是否需要我另开 issue,讨论一个默认关闭、基于 rollout log-prob 的截断重要性采样?English summary. PR #641 is a single commit on
maine17794c;examples/kivi/README.mdholds the reproducible report and the fork branchkivi-590-artifactsholds the raw logs. KIVI-4 meets every acceptance target (6 seeds: GSPO final-window reward +0.000, validation loss +0.20%). KIVI-2 misses the reward target with the default 128-token residual window (−0.097) and meets it with 512 tokens (−0.036). Questions: (1)oss-camp2026is 23 commits behindmainand this change builds onmain; could the branch be synced, or should camp PRs targetmain? (2) Should this PR add--kv-cache-dtype/--kivi-group-size/--kivi-residual-lengthtoareno trainandareno serve? (3) GSPO/GRPO treat rollouts as on-policy, so quantized-rollout drift is never corrected; would you like a separate issue on an opt-in truncated importance weight based on rollout log-probabilities?DoubleCore commentedon Nov 4, 2026
认领 / Claim:独立复现与回归验证(增量范围,与 @EricChan2028 的 PR #641 主线互补,不重复其实现)
看到 #641 已覆盖核心实现、数值正确性与性能评测。我认领的是第三方独立复现这一增量:
examples/kivi/README.md的步骤原样跑通,核对报告中的误差/内存/吞吐表;预计交付物:独立复现报告(含原始日志与命令)、边界回归测试 PR。
预计完成时间:5 个工作日内给出复现结论。
DoubleCore commentedon Nov 4, 2026
增量交付:独立参考实现 + CPU 边界回归
我在主线实现(#641)之外补了一份独立验证产物,不改动你们任何主线文件:
PR: #658 — 3 files, +738
areno/accel/kivi_reference.py— 按 issue 语义从零写的 KIVI 参考实现(key 按 channel 量化 / value 按 token 量化 / residual 窗口)tests/test_kivi_reference_cpu.py— 25 passed,覆盖 residual 窗口空/半满/满、cache reset、非法 attention 类型报错、与 BF16 基线的偏差上界docs/dev/kivi-reference-verification.rst— 与主线 PR 的语义对照点说明:这是 CPU 环境产物,未覆盖 CUDA 显存收益与真机吞吐,这一点已在报告里明确标注。若需要 GPU 实测数据,我这边可以补。
DoubleCore commentedon Nov 4, 2026
补充:已开增量 PR #658(KIVI 独立参考实现 + CPU 边界回归,25 passed)。不改动主线实现,仅作交叉验证。