Dyluhn commited on
Commit
5872633
·
verified ·
1 Parent(s): 6649dc3

Model card: banner, summary and the paper's results; links to the data repository

Browse files
Files changed (2) hide show
  1. README.md +90 -32
  2. assets/ridgefill-banner.webp +0 -0
README.md CHANGED
@@ -5,49 +5,79 @@ tags:
5
  - ridgefill
6
  - llama.cpp
7
  - gguf
 
8
  - prefill-acceleration
9
  - llama-3.1
10
  ---
11
 
12
- # Llama-3.1-8B-Instruct RidgeFill Projector (split 12)
 
 
 
 
 
 
 
 
 
 
13
 
14
  Built with Llama.
15
 
16
- Per-layer linear maps for RidgeFill in the llama.cpp fork
17
- [Approximate-Science/llama.cpp-ridgefill](https://github.com/Approximate-Science/llama.cpp-ridgefill).
18
- RidgeFill is a training-free prefill accelerator. Layers 0–11 run for every prompt token. For prompt tokens before
19
- the exact tail, the projector predicts the inputs of layers 12–31 from the layer-12 hidden state, and only those
20
- layers' K/V cache rows are computed from the prediction. The tail and generation run every layer.
21
 
22
- By Dylan Johnston and tcclaviger. Cite with DOI [10.5281/zenodo.23179168](https://doi.org/10.5281/zenodo.23179168).
23
- The maps are fitted on Llama 3.1 hidden states and are distributed under the Llama 3.1 Community License
24
- (`LICENSE`, `USE_POLICY.md`).
25
 
26
  ## Files
27
- | File | Maps | Bytes | SHA256 |
 
28
  |---|---|---|---|
29
- | llama-3.1-8b-instruct-s12-bf16.gguf | bf16 | 671,419,904 | 83b893b7da619dbf280071f6d5a7e2fb1655eef4b7b5f288a90003d3c612fd34 |
30
- | llama-3.1-8b-instruct-s12-q8_0.gguf | q8_0 | 356,847,104 | 625cffeb57d7a26659f720bd05931cbaa6cd0ef526f93bb3d77623cb452797a9 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- Fit (from the GGUF metadata): ridge λ 0.03, 834,541 rows from 71 documents, base model revision 4699cc75
33
- (`unsloth/Llama-3.1-8B-Instruct`). The q8_0 file measures the same as bf16 within noise (table below).
34
- Works with any quantization of the model (F16, Q8_0, Q4_K_M measured).
35
 
36
- ## Use
37
  ```sh
38
  hf download TheCacheIsALie/Llama-3.1-8B-Instruct-RidgeFill-Projector llama-3.1-8b-instruct-s12-q8_0.gguf --local-dir models
39
  llama-server -m Llama-3.1-8B-Instruct-Q4_K_M.gguf -c 32768 -ngl 99 -fa on \
40
  --ridgefill models/llama-3.1-8b-instruct-s12-q8_0.gguf --ridgefill-tail 8192
41
  ```
42
- Build the fork as described in its
43
- [RIDGEFILL.md](https://github.com/Approximate-Science/llama.cpp-ridgefill/blob/main/RIDGEFILL.md).
44
- Tail length sets the tradeoff: a tail of about a quarter of the prompt held the tail NLL loss to
45
- 0.20–0.26 nats at 8K–32K in the measurements below. The S1, lexical and question-attention selection modes of
46
- the Qwen3.8-27B port do not apply to this model; only the plain fill with an exact tail does.
47
 
48
- ## Measured
49
- One RTX 4090 24 GB, CUDA 12.4, flash attention on, `-b 2048 -ub 512`, F16 KV cache, fork commit fa8061c4b,
50
- wikitext-2 test text. Stock = the same build without `--ridgefill`. Tail T = 4096 unless stated.
 
 
 
 
 
51
 
52
  Prompt processing, `llama-bench -p N -n 0 -r 3`, speedup over stock:
53
 
@@ -56,14 +86,14 @@ Prompt processing, `llama-bench -p N -n 0 -r 3`, speedup over stock:
56
  | F16 | 1.26× | 1.51× | 1.74× |
57
  | Q4_K_M | 1.26× | 1.52× | 1.73× |
58
 
59
- TTFT through `llama-server`, Q4_K_M, mean of 3 prompts, seconds (stock → RidgeFill): 8K 0.77 → 0.60;
60
  16K 1.73 → 1.14; 32K 4.30 → 2.47. Generation speed (tg128) is the same with and without RidgeFill.
61
 
62
- Tail NLL (mean NLL of the last 4095 tokens of each window, nats/token, stock → RidgeFill), Q4_K_M:
63
 
64
  | Prompt | T = 4096 | T = 8192 | T = 16384 |
65
  |---|---|---|---|
66
- | 8K (35 windows), stock 1.846 | 2.031 | — | — |
67
  | 16K (17 windows), stock 1.811 | 2.047 (1.52×) | 1.927 (1.27×) | nothing filled |
68
  | 32K (8 windows), stock 1.843 | 2.681 (1.73×) | 2.050 (1.52×) | 1.938 (1.23×) |
69
 
@@ -73,16 +103,44 @@ Tail NLL (mean NLL of the last 4095 tokens of each window, nats/token, stock →
73
  |---|---|---|---|
74
  | F16 | 6.1775 → 7.5485 | 5.8588 → 7.0083 | 6.7350 → 7.8851 |
75
  | Q4_K_M | 6.3350 → 7.6229 | 6.0108 → 7.0517 | 6.9105 → 7.9416 |
76
- | F16, q8_0 projector | 6.1775 → 7.5446 | 5.8588 → 7.0046 | 6.7350 → 7.8886 |
77
 
78
- Needle in a haystack (wikitext-2 haystack, synthetic needle, depths 10–90%, 4 needles per depth and length, greedy,
79
  T = 4096), needles found:
80
 
81
  | Arm | 8K | 16K | 32K | Needles inside the filled region |
82
  |---|---|---|---|---|
83
- | F16 stock | 20/20 | 20/20 | 20/20 | — |
84
  | F16 RidgeFill | 19/20 | 15/20 | 15/20 | 35/44 |
85
- | Q4_K_M stock | 20/20 | 20/20 | 20/20 | — |
86
  | Q4_K_M RidgeFill | 18/20 | 17/20 | 14/20 | 34/44 |
87
 
88
- Output is not identical to stock llama.cpp.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  - ridgefill
6
  - llama.cpp
7
  - gguf
8
+ - safetensors
9
  - prefill-acceleration
10
  - llama-3.1
11
  ---
12
 
13
+ <p align="center"><img src="https://huggingface.co/TheCacheIsALie/Llama-3.1-8B-Instruct-RidgeFill-Projector/resolve/main/assets/ridgefill-banner.webp" width="100%" alt="RidgeFill"></p>
14
+
15
+ <p align="center"><b>RidgeFill maps for Llama-3.1-8B-Instruct: the reference study's maps at four split depths.</b></p>
16
+ <p align="center"><b>Fitted once in closed form. 39.7 more filled-region RULER points than the identity fill at the same split.</b></p>
17
+
18
+ <p align="center">
19
+ <a href="https://github.com/Approximate-Science/ridgefill-data">Data and code</a> ·
20
+ <a href="https://huggingface.co/TheCacheIsALie">All maps</a> ·
21
+ <a href="https://github.com/Approximate-Science/llama.cpp-ridgefill">llama.cpp fork</a> ·
22
+ <a href="#citation">Citation</a>
23
+ </p>
24
 
25
  Built with Llama.
26
 
27
+ ## What this is
 
 
 
 
28
 
29
+ The ridge maps of the RidgeFill paper's reference study for Llama-3.1-8B-Instruct (`unsloth/Llama-3.1-8B-Instruct`,
30
+ revision 4699cc75), plus the split-12 maps converted to GGUF for the [llama.cpp fork](https://github.com/Approximate-Science/llama.cpp-ridgefill). The maps are fitted on
31
+ Llama 3.1 hidden states and are distributed under the Llama 3.1 Community License (`LICENSE`, `USE_POLICY.md`).
32
 
33
  ## Files
34
+
35
+ | File | Split | Bytes | SHA256 |
36
  |---|---|---|---|
37
+ | `safetensors/llama-3.1-8b-instruct-sweep-s8.safetensors` | 8 of 32 | 805,505,392 | `911b01565af665931c1e2cb01dd6fc6a7951f120117e1327281245c51a75b335` |
38
+ | `safetensors/llama-3.1-8b-instruct-sweep-s12.safetensors` | 12 of 32 (primary) | 671,254,560 | `89bf425556ca2ab5455b2ab76b686e2a29b1bdf9716bb882cb902f2bd6c18008` |
39
+ | `safetensors/llama-3.1-8b-instruct-sweep-s16.safetensors` | 16 of 32 | 537,003,728 | `b076e73dc8c852f7bb27b37bc1b13cbac2bf6e9db769d095cf046b88de80358e` |
40
+ | `safetensors/llama-3.1-8b-instruct-sweep-s20.safetensors` | 20 of 32 | 402,752,888 | `086afd8767eaf4d207968ca9a4572151d21f710e02c7734b084c9c9eeeeb1212` |
41
+ | `llama-3.1-8b-instruct-s12-bf16.gguf` | 12 of 32, bf16 | 671,419,904 | `83b893b7da619dbf280071f6d5a7e2fb1655eef4b7b5f288a90003d3c612fd34` |
42
+ | `llama-3.1-8b-instruct-s12-q8_0.gguf` | 12 of 32, Q8_0 | 356,847,104 | `625cffeb57d7a26659f720bd05931cbaa6cd0ef526f93bb3d77623cb452797a9` |
43
+
44
+ The safetensors files are the bf16 maps the paper's runs loaded, in the reference implementation (`code/kva` in the
45
+ [data repository](https://github.com/Approximate-Science/ridgefill-data)). They were fitted in closed form on 834,541 rows from 71 calibration documents with λ = 0.03.
46
+
47
+ ## Which split
48
+
49
+ Llama-3.1-8B has no key normalization, and its fill error sits in the keys. At split 12 (3/8 depth) the fitted fill's
50
+ added loss on novel tokens is larger than the identity fill's, +1.006 against +0.505 nats; at split 16 and 20 it is far
51
+ smaller, +0.085 and +0.030 against +0.563 and +0.406. For loss, use split 16 or deeper. At split 12, attention-selected
52
+ exact rows remove the failure and restore retrieval. The GGUF files in this repository are split 12.
53
+
54
+ ## Results
55
+
56
+ From the paper's reference study, with a 4,096-token exact tail.
57
+
58
+ | Measure | Value |
59
+ |---|---|
60
+ | Filled-region RULER, RidgeFill − identity fill, split 12 (216 samples, 8K to 64K) | +39.7 [+32.6, +46.5] points |
61
+ | Filled-region RULER, RidgeFill + attention-selected rows − exact, split 12 | +0.2 points, lower bound −1.38 (non-inferior at 2 points) |
62
+ | Novel-token loss vs exact, split 16 | +0.085 nats (identity fill +0.563) |
63
+ | Released SwiftKV checkpoint − RidgeFill, novel-token loss, split 16 | +0.010 [−0.004, +0.025] nats |
64
 
65
+ ## Use in llama.cpp
 
 
66
 
 
67
  ```sh
68
  hf download TheCacheIsALie/Llama-3.1-8B-Instruct-RidgeFill-Projector llama-3.1-8b-instruct-s12-q8_0.gguf --local-dir models
69
  llama-server -m Llama-3.1-8B-Instruct-Q4_K_M.gguf -c 32768 -ngl 99 -fa on \
70
  --ridgefill models/llama-3.1-8b-instruct-s12-q8_0.gguf --ridgefill-tail 8192
71
  ```
 
 
 
 
 
72
 
73
+ Build the fork as described in its [RIDGEFILL.md](https://github.com/Approximate-Science/llama.cpp-ridgefill/blob/main/RIDGEFILL.md). Only the plain fill with an exact
74
+ tail applies to this model; the selection modes of the Qwen3.8-27B port do not.
75
+
76
+ ## Measured in llama.cpp
77
+
78
+ Earlier measurements of the split-12 GGUF, separate from the paper. One RTX 4090 24 GB, CUDA 12.4, flash attention on,
79
+ `-b 2048 -ub 512`, F16 KV cache, fork commit fa8061c4b, wikitext-2 test text. Stock is the same build without
80
+ `--ridgefill`. Tail T = 4096 unless stated.
81
 
82
  Prompt processing, `llama-bench -p N -n 0 -r 3`, speedup over stock:
83
 
 
86
  | F16 | 1.26× | 1.51× | 1.74× |
87
  | Q4_K_M | 1.26× | 1.52× | 1.73× |
88
 
89
+ Time to first token through `llama-server`, Q4_K_M, mean of 3 prompts, seconds (stock → RidgeFill): 8K 0.77 → 0.60;
90
  16K 1.73 → 1.14; 32K 4.30 → 2.47. Generation speed (tg128) is the same with and without RidgeFill.
91
 
92
+ Tail NLL (mean NLL of the last 4,095 tokens of each window, nats per token, stock → RidgeFill), Q4_K_M:
93
 
94
  | Prompt | T = 4096 | T = 8192 | T = 16384 |
95
  |---|---|---|---|
96
+ | 8K (35 windows), stock 1.846 | 2.031 | n/a | n/a |
97
  | 16K (17 windows), stock 1.811 | 2.047 (1.52×) | 1.927 (1.27×) | nothing filled |
98
  | 32K (8 windows), stock 1.843 | 2.681 (1.73×) | 2.050 (1.52×) | 1.938 (1.23×) |
99
 
 
103
  |---|---|---|---|
104
  | F16 | 6.1775 → 7.5485 | 5.8588 → 7.0083 | 6.7350 → 7.8851 |
105
  | Q4_K_M | 6.3350 → 7.6229 | 6.0108 → 7.0517 | 6.9105 → 7.9416 |
106
+ | F16, Q8_0 maps | 6.1775 → 7.5446 | 5.8588 → 7.0046 | 6.7350 → 7.8886 |
107
 
108
+ Needle in a haystack (wikitext-2 haystack, synthetic needle, depths 10 to 90 %, 4 needles per depth and length, greedy,
109
  T = 4096), needles found:
110
 
111
  | Arm | 8K | 16K | 32K | Needles inside the filled region |
112
  |---|---|---|---|---|
113
+ | F16 stock | 20/20 | 20/20 | 20/20 | n/a |
114
  | F16 RidgeFill | 19/20 | 15/20 | 15/20 | 35/44 |
115
+ | Q4_K_M stock | 20/20 | 20/20 | 20/20 | n/a |
116
  | Q4_K_M RidgeFill | 18/20 | 17/20 | 14/20 | 34/44 |
117
 
118
+ ## How RidgeFill works
119
+
120
+ <p align="center"><img src="https://raw.githubusercontent.com/Approximate-Science/ridgefill-data/v1.1/figures/fig_fill_vs_kva.png" width="85%" alt="Two ways to fill a late layer's cache from a middle layer's state: trained key and value heads, and RidgeFill's closed-form map to the layer's input"></p>
121
+
122
+ The lower layers run exactly up to a split. For every prompt row except the exact ones, a ridge map per later layer
123
+ predicts that layer's input from the split layer's state, and the layer writes its cache from the prediction (b)
124
+ instead of running in full: its own key and value projections run unchanged, and on a Gated DeltaNet layer so does
125
+ its state update. The maps are fitted once, in closed form, from one pass over calibration text. The last few thousand
126
+ prompt tokens, any selected exact rows and every decoding step run the full model. Nothing is trained and no token is
127
+ dropped. The design comes from DeepSeek-V4.1-Flash, where the projection is trained into the model; (a) is kishida's
128
+ Q3-8B-KVA-Projector, which retrofitted it onto Qwen3-8B with trained key and value heads.
129
+
130
+ ## Citation
131
+
132
+ The paper, *RidgeFill: Training-Free Late-Layer Cache Fill for Faster Prefill* by Dylan Johnston and tcclaviger, is in
133
+ preparation. Until it is out, cite the data release:
134
+
135
+ ```bibtex
136
+ @misc{johnston2026ridgefilldata,
137
+ author = {Johnston, Dylan and {tcclaviger}},
138
+ title = {{RidgeFill}: data and code for ``Training-Free Late-Layer Cache Fill for Faster Prefill''},
139
+ year = {2026},
140
+ version = {1.1},
141
+ url = {https://github.com/Approximate-Science/ridgefill-data}
142
+ }
143
+ ```
144
+
145
+ An earlier technical note is archived at [doi:10.5281/zenodo.23179168](https://doi.org/10.5281/zenodo.23179168). The
146
+ paper replaces some of its numbers; `SUPERSEDED.md` in the data repository lists which.
assets/ridgefill-banner.webp ADDED