Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: nexusquant
|
| 3 |
+
tags:
|
| 4 |
+
- kv-cache
|
| 5 |
+
- quantization
|
| 6 |
+
- e8-lattice
|
| 7 |
+
- llm
|
| 8 |
+
- inference
|
| 9 |
+
- compression
|
| 10 |
+
license: mit
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# NexusQuant: E8 Lattice KV Cache Compression
|
| 14 |
+
|
| 15 |
+
Training-free KV cache compression for LLM inference. Uses E8 lattice vector quantization + Hadamard rotation. Calibration-free.
|
| 16 |
+
|
| 17 |
+
## Headline
|
| 18 |
+
|
| 19 |
+
+0.276% wikitext PPL at 5.83x compression (Mistral-7B). NIAH retrieval preserved through 32K context. Validated on 9 architectures.
|
| 20 |
+
|
| 21 |
+
## Head-to-head (Llama-3.1-8B-Instruct, 4K, n=30)
|
| 22 |
+
|
| 23 |
+
| Method | bpe | NIAH |
|
| 24 |
+
|---|---|---|
|
| 25 |
+
| FP16 | 16.0 | 29/30 |
|
| 26 |
+
| TurboQuant 2-bit | 2.125 | 0/30 |
|
| 27 |
+
| NexusQuant K2V2 | 2.0 | **30/30** |
|
| 28 |
+
|
| 29 |
+
## Install
|
| 30 |
+
|
| 31 |
+
```
|
| 32 |
+
pip install nexusquant-kv
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from nexusquant import compress_kv_cache
|
| 39 |
+
|
| 40 |
+
with compress_kv_cache(model, mode="quant_only", bits=2):
|
| 41 |
+
output = model.generate(input_ids, max_new_tokens=200)
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Links
|
| 45 |
+
|
| 46 |
+
- [Live demo](https://huggingface.co/spaces/jmarquex/nexusquant-demo)
|
| 47 |
+
- [GitHub](https://github.com/jagmarques/nexusquant)
|
| 48 |
+
- [Paper PDF](https://github.com/jagmarques/nexusquant/blob/main/paper/nexusquant.pdf)
|
| 49 |
+
- [llama.cpp PR](https://github.com/ggml-org/llama.cpp/pull/25352)
|
| 50 |
+
- [vLLM PR](https://github.com/vllm-project/vllm/pull/47742)
|