Repository navigation
Description
Disclosure: this issue text was drafted with an AI assistant and reviewed by me before posting, per the AI Usage Policy in CONTRIBUTING.md.
Prerequisites
- I searched existing issues. The Volta/sm_70 question is already tracked in Research: V100 Volta arch 70 support #121 — this is a different ask (format portability, see below).
- I am running the latest code — partially: I cloned
mainand read the KVarN implementation; I have not run inference yet (no Volta card in hand until Wednesday). - I reviewed Discussions — Discussions are disabled on this repository, so I am filing here.
Feature Description
Request: publish the KVarN record layout as a short format document, and if you are willing, a reference quantizer that can be used outside ggml.
What an external engine would need to reproduce the format bit-exactly:
- Record layout for
kvarn2/3/4/5/6/8at head dims 64/128/256/512 — payload packing and bit order, where the scale and zero-point live, alignment/padding rules. - The exact WHT — normalization convention, and where it is applied relative to RoPE (before/after), including how the query is rotated and the output rotated back.
- The Sinkhorn step as implemented — 16 iterations, row/column alternation order, epsilon and any guard values, and the single-incomplete-group semantics at
group_size = 128. - The sink/tail rules this fork adds on top of the paper — the tail floor of one full group, the prefix sink on non-sliding-window layers only.
Motivation
I run a bespoke Volta (sm_70) TP4 engine that cannot use ggml. Its KV cache today is int8 group-64 plus an FP16 scale per group, 8.25 bpv. Your ladder suggests kvarn5 (5.375 bpv) would buy roughly 1.5× the context at q8_0-class quality, and that is the only reason I am considering implementing KVarN at all.
Without a format spec, adopting it means reverse-engineering ggml/src/ggml-cuda/kvarn.cu (128 KB) plus src/llama-kv-cache-kvarn.cpp (140 KB). The failure mode of getting it slightly wrong is silently wrong attention rather than a crash, which makes it hard to justify. A two-page spec is the difference between "worth trying" and "not worth the risk".
Second reason: two engines that agree on the record layout can share KV state and benchmark each other on identical caches.
Possible Implementation
docs/kvarn-format.mdcovering the four items above, with a byte-layout table per bit width.- Optional but very useful: a tiny reference implementation (a Python script or a standalone
.cu) that takes a[128, head_dim]FP16 block plus a bit width and emits the record bytes, with one golden vector. External engines could then self-test against your output instead of guessing. - If you would rather not own this: I am willing to write
docs/kvarn-format.mdfrom the current code and submit it as a PR with AI disclosure, if you would review it for correctness.
What I can offer in return
A 4×V100-16G NVLink rig arrives Wednesday. I can run real-device sm_70 validation on the portable route and report prefill and decode numbers separately. #121 currently has a single 128K data point (253 s vs 11,480 s) and one "terrible results" confirmation, which is not enough to tell where the 45× gap comes from; I can produce a fuller table on 4 cards with the same model and context.
What I am not asking for
I am not asking you to port KVarN to another engine, and not asking for sm_70 optimization work — that is #121's scope. Only that the format be reproducible from the outside.
Activity