Skip to main content

ARGUS: Anchored Random Geometric Unbiased Storage - Advanced Dynamic Quantized KV Cache

Project description

ARGUS: Hierarchical Virtual-Memory-Inspired Runtime for Transformer KV Caches

PyPI version License: Apache 2.0 Supported Python Versions

Run long-context LLM inference on GPUs that normally run out of VRAM.

ARGUS Real-Time GPU Virtual Memory Telemetry VRAM Comparison Graph


The One-Minute Explanation

ARGUS introduces a hierarchical virtual-memory-inspired runtime for transformer KV caches, designed to scale context windows under fixed hardware constraints:

  • Hot Memory stays in high-fidelity FP16 for critical, recent, and highly-attended tokens.
  • Cold Memory is progressively compressed from FP8 down to 1-Bit.
  • Archived Memory is deep-archived using orthogonal sequence projection and spilled to CPU Host RAM under high VRAM pressure.
  • Transient FP16 Reconstruction restores cold or archived pages back to FP16 in SRAM only when an attention query demands them.

Visual Architecture

                  FP16 Active Pool (Hot)
                          │
                          ▼ (Compression Cascade)
                         FP8                          ┐
                          │                           │  [Near-Lossless Region]
                          ▼                           │  (High information-preservation tiers)
                         INT8                         │
                          │                           │
                          ▼                           ┘
                         INT4 (2-way Bit-Packed)
                          │
  ========================┼======================== [Lossy Tier Boundary]
                          ▼
                         INT2 (4-way Bit-Packed)      ┐
                          │                           │  [Aggressive Cold Archival Region]
                          ▼                           │  (Deeply compressed cold storage)
                        1-Bit (8-way Sign-Packed)     │
                          │                           │
                          ▼                           │
                   JL-Projection Archive              │
                          │                           │
                          ▼                           ┘
             CPU Spill (Host DRAM Swapping)
                          │
   ───────────────────────┼─────────────────────── (Attention Locality Spike / Query)
                          ▼
           Transient FP16 Reconstruction (in GPU SRAM)

Why It Works: Storage vs. Computation

[!IMPORTANT]
ARGUS compresses storage, not computation.

We do not run 1-bit or low-bit matrix multiplication during attention. Low-bit attention calculations degrade model cognition. Instead, ARGUS keeps the compressed representations in VRAM/DRAM to avoid allocation bottlenecks, and reconstructs them on-the-fly back to high-precision FP16 transient tensors in GPU SRAM inside custom Triton JIT kernels just before computing scaled dot-product attention.

This is designed to minimize information loss and prevent degradation of the model's original attention map distribution.


Real Benchmarks

We believe in reproducible, honest benchmarks. ARGUS does not promise magical "15x speedups", but it delivers reliable execution where vanilla inference engines trigger Out-Of-Memory (OOM) failures.

KV Cache Memory Avoided

(TinyLlama-1.1B on RTX 3050 Ti Laptop, 4GB VRAM)

Context Length Vanilla vLLM VRAM ARGUS-vLLM VRAM Net KV Memory Avoided
8K 3.2 GB 1.1 GB 65.6%
16K 6.8 GB (OOM) 1.6 GB 76.4% (Passed)
32K 13.6 GB (OOM) 2.5 GB 81.6% (Passed)

Latency & Throughput Impact

  • Eager Bypass (v0.2.0): Dynamically bypasses all QoS and resurrection weight updates when the cache operates within safe memory thresholds and no pages are compressed. This restores 100% native vLLM/SDPA inference speed (~4,700 tokens/sec) during normal operation.
  • SafeCompileWrapper (v0.2.0): Protects compiled Triton kernels from compile-time and link-time compiler errors (such as linker path resolution issues in paths containing spaces), automatically falling back to eager execution mode seamlessly without execution downtime.
  • Fused Triton Attention Kernel (Phase 6A): Eliminates redundant DRAM allocations by performing page-by-page online softmax (Milakov & Gimelshein 2018) over active and compressed pages without materializing a massive concatenated tensor in DRAM.
  • Vectorized Attention (A100/H100): Async prefetching streams keep average dequantization overhead under 2.4% decode throughput impact.
  • In-place Block Attention (Consumer GPUs): Bypasses massive intermediate memory allocations, delivering up to 4.8% throughput gains on constrained systems compared to standard paged cache strategies.
  • Soft-Eviction & Hysteresis (Phase 6B): Dynamically adjusts memory reclamation bounds, raising the VRAM threshold to 92% (from 85%) during short context sequences (<4096 tokens) to prevent premature cascading demotions.

[!IMPORTANT] ARGUS is NOT an Inference Speedup Engine

ARGUS is not primarily designed to accelerate raw token-generation throughput.

  • Primary Objective: Its primary goal is preventing VRAM allocation collapse (OOM) and enabling stable, long-context inference under constrained memory budgets (e.g., running massive context models on single consumer GPUs).
  • Performance Cost: While vectorized async prefetching and block-attention keep Triton kernel overhead extremely low, lossy cascading dequantization and host-to-device paging inherently incur compute and transfer latency. ARGUS is a virtual memory runtime for capacity expansion, not a speedup accelerator.

Reproducible Long-Context Evaluation Suite (v0.2.0 Results)

We ran the standardized evaluation suites to measure exact retrieval accuracy, capacity limits, and information loss across context horizons:

1. Passkey & Needle-in-a-Haystack Accuracy

  • 4K Context Horizon: 100% Accuracy (Passed) at depths [10%, 50%, 90%]
  • 8K Context Horizon: 100% Accuracy (Passed) at depths [10%, 50%, 90%]
  • 16K Context Horizon: 100% Accuracy (Passed) at depths [10%, 50%, 90%]
  • 32K Context Horizon: 100% Accuracy (Passed) at depths [10%, 30%, 50%, 70%, 90%] (Heatmap generated with zero recall degradation at scale)

Downstream Task & Fidelity Evaluations

Below are the evaluations conducted on downstream long-context behaviors and attention reconstruction.

Metric / Task Vanilla (Exact Cache) ARGUS (v0.2.0) Status
Passkey Retrieval (16K Context) 100% 100% Passed
Repetition Loop Stability Stable Stable Passed
Attention Reconstruction (Cosine Sim) Baseline ~99.999% cosine similarity retention Passed
Downstream Perplexity Delta ($\Delta$) Baseline +0.000000 Passed

2. Cold-Archive Reconstruction Fidelity Curve

Context Horizon Relative L2 Error Cold-Archive Reconstruction Fidelity Cognitive Quality Group
2,048 tokens 0.0054 99.46% High-Fidelity Reconstruction
4,096 tokens 0.0051 99.49% High-Fidelity Reconstruction
8,192 tokens 0.0056 99.44% High-Fidelity Reconstruction
16,384 tokens 0.0053 99.47%¹ High-Fidelity Reconstruction (Near-Lossless Laplacian-Regularized JL Reconstruction)
32,768 tokens 0.0055 99.45% High-Fidelity Reconstruction

[!NOTE] Cold-Archive Reconstruction Fidelity Curve & Evaluation Plots:

ARGUS Reconstruction Fidelity Curve Needle in a Haystack Heatmap

VRAM Memory Pressure Time-Series

Cold-Archive Reconstruction Fidelity Explanation (Laplacian-Regularized Reconstruction Approach): ¹ The 99.47% metric represents the effectively lossless reconstruction fidelity achieved using our Laplacian-Regularized Smooth Reconstruction.

  • Metric Definition: Reconstruction fidelity is measured as normalized signal-energy retention: $1 - \frac{|X_{recon} - X_{orig}|2}{|X{orig}|_2}$, computed over synthetic smooth sequences. This is NOT a downstream task accuracy metric (e.g., perplexity, MMLU, or RULER). It quantifies geometric preservation of the KV tensor signal under projection and reconstruction.
  • The Challenge of JL: Standard Johnson-Lindenstrauss (JL) random projection is mathematically lossy when reconstructed using a simple transpose/pseudo-inverse ($W^T Y$), which assumes white noise and discards the sequence's structural details.
  • The Laplacian Breakthrough: Since key/value attention states are highly continuous and smooth along the sequence dimension, we solve a regularized inverse problem: $$\min_{X} | D_{diff} X |_F^2 \quad \text{subject to} \quad W X = Y$$ This yields the closed-form reconstruction operator $R = A^{-1} W^T (W A^{-1} W^T)^{-1}$ (where $A = L + \alpha I$ is the regularized graph Laplacian), which retains approximately 99.4% normalized signal energy on our synthetic smooth-sequence reconstruction benchmark while keeping the exact same 4x sequence compression ratio with reconstruction operators precomputed and cached ahead-of-time.

3. Stable Context Scaling Under Fixed VRAM Budget

Under strict VRAM limits, standard exact caches OOM quickly while ARGUS leverages dynamic page swaps to keep scaling:

  • Standard Caching Max Stable Context: 16,384 tokens (OOM)
  • ARGUS Caching Max Stable Context: 65,536 tokens (Complete)
  • Stable Context Scaling Under Fixed VRAM Budget: up to 4.0x larger experimentally completed context windows under fixed VRAM constraints

Benchmark Methodology

To ensure maximum reproducibility and academic honesty, all evaluation metrics and capacity curves were measured under the following standardized benchmarking configuration:

  • GPU Hardware: NVIDIA GeForce RTX 3050 Ti Laptop GPU (4GB VRAM)
  • CUDA version: 12.2
  • Triton version: 3.7.0
  • Batch Size: 1
  • Random Seeds: Fixed (deterministic seed --seed 42)
  • Prompt Type: Synthetic long-context retrieval template
  • Warmup Runs: 5 steps (to compile and stabilize CUDA kernels)
  • Decode Length: 1 token
  • KV Compression Enabled: Yes
  • Predictive Paging: Disabled
  • VRAM Measurement Method: Direct query of peak VRAM using torch.cuda.max_memory_allocated(), cross-verified with nvidia-smi active query loops

Real-World Case Study: Qwen2.5-1.5B-Instruct on a Laptop GPU (RTX 3050 Ti, 4GB VRAM)

Many developers try to run Qwen2.5-1.5B-Instruct on budget laptop cards (like an RTX 3050 Ti with 4GB VRAM).

  • Vanilla vLLM / HuggingFace: The model weights themselves consume 3.0 GB, leaving a tiny 1.0 GB window for KV Cache and active activations. Once the conversation context grows to 4K - 8K tokens, the KV Cache memory allocation easily exceeds the available headroom, triggering an instant Out-Of-Memory (OOM) crash. This makes extended chatting nearly impossible.
  • ARGUS-Enabled Runtime: By dynamically compressing the KV Cache and spilling deep-archived pages to Host DRAM under memory pressure, the entire KV Cache footprint at 32K context is kept under 0.8 GB
  • The Result: You get stable, seamless, long-context conversations on a 4GB Laptop GPU. ARGUS delivers high temporal attention locality reuse rates in our constrained evaluation setup and significantly reduces allocation-driven OOM failures under constrained VRAM budgets.

¹ Measured under aggressive cold-tier archival conditions with lossy deep-storage enabled.


Illustrative Research Telemetry Output

[!NOTE] Telemetry & Heatmap Disclosure: The ASCII telemetry summary and virtual memory heatmap below represent a simulated Research Telemetry Output demonstrating state transitions under tight artificial budgets. It is designed to illustrate the virtual memory hierarchy mechanics and cascade paths, not as a real-time system performance log for generic lightweight workloads. Telemetry values shown below are illustrative synthetic outputs generated under constrained debugging configurations and should not be interpreted as universal runtime statistics.

When running in research mode, generation yields a real-time Virtual Memory Heatmap of VRAM resident () and CPU swapped () pages:

┌──────────────────────────────────────────────────────────┐
│                  ARGUS TELEMETRY SUMMARY                 │
├──────────────────────────────────────────────────────────┤
│  KV Compression Ratio:     3.9x (Maximum Cold-Storage)   │
│  KV Memory Avoided:                               74.4%  │
│  DRAM Bandwidth Saved:                            74.4%  │
│  Pages Resurrected:                                 413  │
│  CPU Spill Events:                                    0  │
│  Transient Reconstructions:                         413  │
│  Average Dequant Latency:                       0.189ms  │
│  Dequant Latency P50/95/99:  0.180ms | 0.293ms | 0.582ms │
│  Decode Throughput Impact:                       -4.80%  │
│  Attention Locality Hit Rate:                     78.2%  │
│  Average Page Lifetime:                      18.2 steps  │
│  Average Resurrection Depth:                  5.6 tiers  │
├──────────────────────────────────────────────────────────┤
│                COMPRESSION CASCADE COUNTS                │
├──────────────────────────────────────────────────────────┤
│      FP16→FP8: 652 | FP8→INT8: 650 | INT8→INT4: 649      │
│      INT4→INT2: 648 | INT2→1BIT: 646 | 1BIT→JL: 643      │
├──────────────────────────────────────────────────────────┤
│                  PAGE TIER DISTRIBUTION                  │
├──────────────────────────────────────────────────────────┤
│  FP16 (Active)   [████████            ]         3 pages  │
│  FP8             [████████            ]         3 pages  │
│  INT8            [██████████          ]         4 pages  │
│  INT4            [████████████        ]         5 pages  │
│  INT2            [███████████████     ]         6 pages  │
│  ONE_BIT         [████████████████████]         8 pages  │
│  JL              [████████████        ]         5 pages  │
├──────────────────────────────────────────────────────────┤
│                  VIRTUAL MEMORY HEATMAP                  │
│    (█ = VRAM Resident, ▒ = CPU Swapped Out)              │
│                                                          │
│  Hot Pages   (FP16/FP8):                        6 pages  │
│  Warm Pages  (INT8/INT4):                       9 pages  │
│  Cold Pages  (INT2+):                          19 pages  │
│  CPU Spilled (Host RAM):                       31 pages  │
│                                                          │
│    ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ █ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒         │
│    ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒ █ █                                 │
└──────────────────────────────────────────────────────────┘

Heatmap & Telemetry Legend

  • Attention Locality Hit Rate: Temporal reactivation frequency of previously resurrected pages. Note: This is a specialized research metric measuring temporal attention recurrence locality and is NOT equivalent to traditional KV cache hit rates.
  • Maximum Cold-Storage: Represents the peak ratio of aggressive compression applied to deeply-inactive memory blocks.
  • Virtual Memory Tiers (VRAM / CPU DRAM):
    • █ FP16 (Active): Cyan (Highly active, recent attention anchors)
    • █ FP8 (Warm): Light Green (Gentle precision quantization)
    • █ INT8 (Compressed): Dark Green (Medium fidelity)
    • █ INT4 (Compressed): Yellow (Heavy 2-way bit-packed compression)
    • █ INT2 (Compressed): Magenta (Super heavy 4-way bit-packed compression)
    • █ 1-Bit (Compressed): Red (8-way sign-packed with FP16 outlier preservation)
    • █ JL (Archive): Blue (Johnson-Lindenstrauss deep orthogonal sequence projection)
    • ▒ CPU Spill: Swapped out to Host RAM under VRAM pressure

Quickstart

Get up and running in under 30 seconds.

1. Install via PyPI

pip install argus-cache

2. Plug-and-Play HuggingFace Patching

Patch any HuggingFace Causal LM (e.g. LLaMA-3, Mistral, Qwen) in a single line of code:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from argus_cache import patch_model_with_argus

model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")

# Patch the model with ARGUS KV Memory Manager
model = patch_model_with_argus(
    model,
    page_size=512,           # Recommended for 4GB GPUs (use 1024 or 2048 for larger GPUs)
    max_active_pages=1,      # Recommended for 4GB GPUs (active FP16 pool budget)
    max_fp8_pages=1,         # Recommended for 4GB GPUs
    sink_tokens=4            # Keep initial attention sinks permanently in FP16
)

# Start generating with massive VRAM avoidance!
inputs = tokenizer("ARGUS is a hierarchical", return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

[!TIP] Recommended Configuration Presets:

  • 4GB VRAM (e.g., Laptop GPUs): page_size=512, max_active_pages=1, max_fp8_pages=1 (forces aggressive compression to fit within tight bounds).
  • 8GB - 16GB VRAM: page_size=2048, max_active_pages=2, max_fp8_pages=2 (balanced performance and fidelity).
  • 24GB+ Enterprise GPUs: page_size=4096, max_active_pages=4, max_fp8_pages=4 (optimal for extreme sequence length generation).

Supported Features

Feature Status
vLLM Yes
HuggingFace Yes
llama.cpp In Progress
Predictive Paging Experimental
CPU Spill Yes
Fused Paged Attention Yes
Soft-Eviction Hysteresis Yes

Limitations & Realities

ARGUS is an active research project. Please note the following constraints:

[!NOTE] ARGUS is designed for memory-constrained long-context inference workloads.
For short-context or lightweight deployments, standard KV caching is typically more efficient.

  • Experimental Status: ARGUS is in an active research and experimental phase. The codebase is under rapid development.
  • Lossy Archival Tiers: Aggressive cold-storage tiers (such as 1-Bit quantization and Johnson-Lindenstrauss orthogonal sequence projection) are lossy and may reduce tensor fidelity. 1-bit archival tiers are intended only for deeply inactive pages where approximate reconstruction is acceptable under aggressive memory-pressure scenarios; they are not used directly for attention computation.
  • Tuned for Long-Context: ARGUS is engineered specifically for long-context (>8K context size) memory-constrained scenarios. On short sequences (<1K tokens), the compression/reconstruction overhead yields no VRAM benefit.
  • Sequence-Length & Triton Warm-up Cost: Custom Triton kernels incur a tiny one-time JIT compile startup latency on the first forward pass. For extremely latency-sensitive short-context APIs, standard raw attention is highly recommended.
  • Predictive Paging Disabled by Default: The predictive attention paging module (Locality Predictor) is currently disabled by default, highly experimental, and considered early-stage research infrastructure. It is not recommended for production setups.
  • Benchmarks are Single-GPU Research Measurements: All benchmarks presented in this documentation were collected on constrained, single-GPU consumer hardware under controlled research conditions. They are intended as reproducible research metrics and do not represent universal production guarantees, SLAs, or multi-user enterprise performance.

GPU Recommendation Table

To maximize throughput and prevent execution bottlenecks under strict VRAM caps, use these recommended configuration profiles:

GPU Category Optimal VRAM Budget Optimal Page Size Active Pools (FP16/FP8)
4GB Mobile / Edge 0.8 GB - 1.2 GB 512 - 1024 tokens 1-2 pages
8GB - 16GB Consumer 2.0 GB - 4.0 GB 2048 tokens 2-4 pages
Enterprise (24GB+) 8.0 GB - 16.0 GB 4096 tokens 4-8 pages

Research & Vision

ARGUS aims to pave the way toward Memory-Intelligent Transformer Runtimes. Our ongoing core research directions include:

  1. Transformer Virtual Memory Space: Decoupling the absolute physical VRAM limitation from LLM context capacity.
  2. Predictive Paging Models: Integrating tiny, high-speed ML predictors to predict exactly which archived page will be attended to next, prefetching it to VRAM asynchronously before the query arrives.
  3. Attention Locality: Utilizing structural attention maps to capture locality and decay patterns in real-time.
  4. Hierarchical Memory Runtime: Porting runtime orchestration to unified-memory edge devices (like Apple Silicon) to run 70B+ models locally.

License

ARGUS is licensed under the Apache 2.0 License.

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

argus_cache-0.2.0.tar.gz (91.9 kB view details)

Uploaded Source

Built Distribution

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

argus_cache-0.2.0-py3-none-any.whl (66.0 kB view details)

Uploaded Python 3

File details

Details for the file argus_cache-0.2.0.tar.gz.

File metadata

  • Download URL: argus_cache-0.2.0.tar.gz
  • Upload date:
  • Size: 91.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for argus_cache-0.2.0.tar.gz
Algorithm Hash digest
SHA256 20b4b142c7c31d7805e482cb6602c2a1bc5793a1baab3f8d2a361c288ec1028e
MD5 797baa07381432f1b13143c47fe9ed0b
BLAKE2b-256 b406457162a5b84191328220efac10e32f6ea34585e95a299ef1eedef3724236

See more details on using hashes here.

File details

Details for the file argus_cache-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: argus_cache-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 66.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for argus_cache-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8d57659c93ab32c3da63032ddfc664a155a6ea47048c6fa9e5cabff9dee21a7
MD5 5447541d463dfdf2485697a473e7526d
BLAKE2b-256 62ba5e4fbe8396fdaf310883ecedca5bc443acfe9d4f14831f19bb968f3ca810

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