Skip to main content

AMASS: decode-time sparse KV-cache attention for vLLM (quad page-score selector + DRAM value tier)

Project description

AMASS

Decode-time sparse KV-cache attention for vLLM. AMASS keeps LLM decoding fast and memory-light at long context by attending, at every decode step, to only the pages that actually carry attention mass: a compact per-page score selects a small working set (typically 5 to 10 percent of the KV cache), and a sparse paged-attention kernel reads just those pages. Prefill is untouched, so time-to-first-token is unchanged.

License note (provisional). This release is distributed under Apache-2.0 as a placeholder pending final confirmation by the authors. See LICENSE.

What is in the box

AMASS has two parts that share one selection core:

  1. The quad selector (Stage A). A quadratic, Gaussian-MGF page score built from a tiny per-page summary. "quad" drops the per-key coordinates and stores only r' eigenvalues per page, which shrinks the resident selector state by 3.28x (from 15.6 percent down to 4.7 percent of the KV cache; measured 1201 MiB vs 3943 MiB) while remaining accurate enough to pick the right pages.
  2. The DRAM value tier (Stage B). A pinned, device-mapped host-DRAM pool for the value cache, with a bounded resident hot buffer plus staging pool. Only the ~5 percent quad summary and the pages actually called each step stay in VRAM; the rest of V (or K+V) lives in host memory.

Two variants, one algorithm

Variant KV residency The play
AMASS-fast K+V resident in VRAM speed
AMASS-mem V (mem-v) or K+V (mem-kv) offloaded to DRAM; only the quad summary + called pages resident memory + speed

Install

pip install amass-kv

The import name is amass:

import amass
print(amass.__version__)

amass-kv declares torch and triton as its runtime dependencies. vLLM is an optional extra (see Dependencies); install AMASS into your existing vLLM environment, or pull a compatible engine with:

pip install "amass-kv[vllm]"     # engine + plugin
pip install "amass-kv[all]"      # + transformers (bench) + pyyaml (yaml configs)

Requires Python >= 3.10 and an NVIDIA GPU. The hot-path CUDA kernels are compiled once at first use via torch.utils.cpp_extension (targeting Hopper, sm_90a); the reference Triton kernels are the automatic fallback.

Quickstart

AMASS installs as a vLLM general plugin, so once the wheel is present vLLM auto-registers it at engine startup with no code change: AMASS patches itself in wherever vLLM would have chosen the FlashAttention backend. Configuration is a single AmassConfig, sourced from the AMASS_CONFIG environment variable (an inline JSON string, or a path to a JSON/YAML file):

# Run any vLLM entry point (serve / offline) with AMASS active.
export AMASS_CONFIG='{"variant": "fast", "coverage": 0.95}'
vllm serve meta-llama/Llama-3.1-8B-Instruct

# The memory play: offload V to DRAM, keep K resident.
export AMASS_CONFIG='{"variant": "mem-v", "coverage": 0.95}'

# Turn AMASS off (stock FlashAttention / FullKV reference line):
export AMASS_DISABLE=1

Key AmassConfig fields: variant (fast / mem-v / mem-kv), coverage (adaptive per-head nucleus coverage over exact page masses; default 0.95) or budget (a fixed selected-page fraction), score (quad default, or the r8 low-rank fallback), and use_cuda (hand-CUDA hot path vs Triton reference).

Headline results (measured)

  • 3.28x smaller selector state. The quad summary is 4.7 percent of the KV cache vs 15.6 percent for the low-rank r8 baseline (1201 vs 3943 MiB measured), with a cheaper tail-free hot-path kernel.
  • Near-lossless on LongBench. quad at a 5 percent per-step budget lands within noise of FullKV (LongBench-v1 delta about -0.22 for quad vs -0.38 for r8 at the same budget; about -0.29 at coverage 0.95 across 14 subsets).
  • Faster in the regime that matters. AMASS-fast beats dense FlashAttention-3 in the long-context, high-batch decode regime by up to about 2x, and is at parity at batch size 1 (the hot path is bandwidth-bound and only pulls ahead once the dense KV read dominates). It does not claim >=2x everywhere.
  • 76 to 92 percent VRAM saved in the mem variant, by holding only the quad summary plus the called pages resident and serving the rest of V from DRAM.

Numbers are per-kernel and end-to-end reproducible with amass-bench (below). See the paper for the full protocol, benchmarks (RULER, LongBench v1/v2, SCBench, a reasoning suite), and ablations.

  • Paper: see the project page linked in this repository.

Benchmarking: amass-bench

The wheel ships a benchmarker so the latency claims are reproducible on any Hopper box with one command:

amass-bench kernels --quick    # per-kernel: r8_score / topb / decode, CUDA vs Triton vs dense-FA
amass-bench e2e --ctx 16384    # end-to-end decode-step TPOT in a real vLLM run
amass-bench all --json out.json
python -m amass.bench kernels  # identical to the console entry point

amass-bench e2e needs the bench + vllm extras (it tokenizes a real model and spins up an engine). Timing is CUDA-event based with warmup and medians, and reports both eager and CUDA-graph-replay speedups plus an HBM roofline for the bandwidth-bound score kernel. Full flag reference: amass-bench --help.

Dependencies

Dependency Why How it is declared
torch tensors + runtime CUDA (load_inline) kernels hard (>=2.4)
triton reference / fallback kernels hard (>=3.0)
vllm plugin host + attention backend extra [vllm] (>=0.8)
transformers amass-bench e2e tokenizer (lazy import) extra [bench]
pyyaml YAML AMASS_CONFIG files (JSON needs no dep) extra [yaml]

numpy is not a direct dependency: nothing under amass/ imports it; it arrives transitively through torch. vLLM is an extra rather than a hard floor because it is a heavy, CUDA-ABI-sensitive wheel that production deployments pin themselves, and a hard floor could silently upgrade a pinned engine.

License

Apache-2.0 (provisional; see the note at the top). See LICENSE for the full text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amass_kv-0.1.0.tar.gz (153.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amass_kv-0.1.0-py3-none-any.whl (170.1 kB view details)

Uploaded Python 3

File details

Details for the file amass_kv-0.1.0.tar.gz.

File metadata

  • Download URL: amass_kv-0.1.0.tar.gz
  • Upload date:
  • Size: 153.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for amass_kv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d4d5674901fe33afd03197ef272a5e87424acf98cb19593d743f8d45781c07de
MD5 5739b60cffc3f7b704522b53f8caa937
BLAKE2b-256 ca0368525543eaf9d06597bd935a88f7183f8f143cbe14f02dfb2e1686e3fae5

See more details on using hashes here.

File details

Details for the file amass_kv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: amass_kv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 170.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for amass_kv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea4d91844a9929cdc05812e5f343169d743d1dfaf38fdf1f04154787a49f94b
MD5 62cf358917189558d51a8d15ba0f56c5
BLAKE2b-256 e8580b3afa091d07b42515077511cce094096c9e7430df158c2679b89d9bf6d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page