Skip to content

BeeLlama v0.4.6 + KVMem 256K Context (Blackwell sm_120)

Latest

Choose a tag to compare

@Andgihat Andgihat released this 27 Oct 12:49

BeeLlama v0.4.6 + KVMem (Context 256K on 16GB VRAM)

Native integration of the KVMem virtual working set engine into BeeLlama (branch beellama-kvmem), fully compiled with MSVC 2022 and CUDA 12.8 for NVIDIA Blackwell (sm_120a-real).

Key Highlights

  • 256K Context on 16GB VRAM: Streams up to 262,144 tokens in Host RAM (pinned DDR5) while keeping a dynamic active working set (36K budget + 16K reserve) on GPU via PCIe.
  • Blackwell GDN Fix: Solves the warp reduction bug in gated_delta_net.cu (lanes_per_col) and pointer offset guard (keep_rs = K > 1), eliminating logits corruption for Qwen3.8 hybrid models on RTX 50-series GPUs.
  • Cache Compression:
    • q4_0 / q8_0 with Hadamard rotation in KVMem (start-kvmem-256k.bat) — halves GPU VRAM working set without quality degradation.
    • kvarn6 (6-bit variable precision) native attention (start-beellama-kvarn6.bat) for GPU-only 65K-96K context.
  • Multi-Token Prediction (MTP): Built-in draft head support achieving ~76% draft acceptance and 36-40 tokens/sec decoding speed.
  • Session Management (--kvmem-sessions 1): Binds server to 1 active session, automatically evicting completed runs and preventing memory accumulation across repeated benchmarks.

Empirical Long-Context Verification (250K+ Tokens on RTX 5060 Ti 16GB)

Hardware: RTX 5060 Ti 16GB, AMD Ryzen 7 7700, 32GB DDR5.
Model: Qwen3.8-27B-UD-Q3_K_XL.gguf (-c 262144 -b 2048 -ub 1024 --kvmem-budget 36864 --kvmem-sink-tokens 12288 --kvmem-recent-tokens 1024 --kvmem-sessions 1 -ctk q4_0 -ctv q4_0).

1. Full 21-Needle NIAH Benchmark (258,827 Tokens, 0% to 100% Depths)

  • Result: 21 out of 21 found (100.0% Recall).
  • Contrast with low-budget (12K) configurations: When running with insufficient budget (e.g. 12K budget / 3K dynamic headroom), Page-Softmax is starved and suffers blind spots at depths 5%–30% and 60%–70% (52.4% score). With our recommended 36.8K budget (23.5K dynamic headroom), every depth achieves 100% PASS.
  • Prefix Caching: Query 01 prefills the 258K document once (742s); queries 02 to 21 reuse the cached prefix and return in ~12.0s average wall time.

2. RULER Long-Context Benchmark Suite (251,776 Tokens)

NVIDIA RULER evaluation suite evaluating multi-point retrieval, reasoning, and aggregation across 251,776 tokens:

Task ID Task Category Target Description Score Recall
RULER-MK-4 Multi-Key Retrieval 4 distinct orders (CYGNUS, VEGA, SIRIUS, POLARIS) at depths 12%–88% 4 / 4 100.0%
RULER-MK-8 Multi-Key Retrieval 8 distinct orders across depths 12% to 94% extracted in a single pass (22.8s) 8 / 8 100.0%
RULER-MV-4 Multi-Value Retrieval 4 unique clearance passcodes (HYP-XXXX) assigned to Project Hyperion 4 / 4 100.0%
RULER-VT-5 Variable Tracking 5-hop assignment tracing: $\text{ALPHA} (6784) \to \text{BETA} \to \text{GAMMA} \to \text{DELTA} \to \text{OMEGA}$ 1 / 1 100.0%
RULER-AGG-4 Aggregation & Computation Extract 4 climate readings for Station Arctic-7 and calculate their exact sum ($14+22+19+25 = 80$) 5 / 5 100.0%
TOTAL All 5 Categories Comprehensive Context Fidelity 22 / 22 100.0%
  • Multi-Hop Proof: In RULER-VT-5, the model successfully identified all 5 assignment sections (Section 290, 620, 1008, 1434, 1764) and traced VAR_OMEGA = 6784.
  • Peak VRAM: Kept strictly at ~14.5 GB VRAM with zero OOM errors throughout the entire test.

3. Extreme 503,523 Tokens (0.5M Context) Benchmark

Evaluation across half a million tokens (2,831,907 characters) on RTX 5060 Ti 16GB (-c 524288):

  • Result: 4 out of 4 passed (100.0% Recall).
    • Needle at 50% (~250k tokens deep): CHRONOS-7714 (PASS)
    • Needle at 95% (~480k tokens deep): HYPERION-8836 (PASS, 16.75s via prefix cache)
    • Needle at 10% (~50k tokens deep): TITAN-9481 (PASS, 14.82s via prefix cache)
    • Multi-Key Synthesis: All 5 projects simultaneously retrieved and structured in 19.01s (PASS).
  • RAM Footprint: ~10.2 GB pinned Host DDR5 RAM.
  • VRAM Footprint: 15.4 GB on a single 16GB GPU. Zero OOM errors.

4. KLD & Logit Divergence Benchmark (Wikitext-2 vs. FP16 Baseline)

KLD evaluated with llama-perplexity across 8K, 16K, and 32K context lengths against full FP16 baseline logits:

  • q8_0 KV Cache: Mean KLD is ~0.00072, Max KLD < 0.089, and Same top p is 98.5% - 98.9% with negligible $\Delta \text{PPL} \approx +0.003$.
  • q4_0 KV Cache: Mean KLD is ~0.0028, Max KLD is bounded at 0.407, and Same top p is 97.4% - 97.9% with $\Delta \text{PPL} \approx +0.014$.
  • Flat Error Curve: Zero runaway error accumulation across context expansion from 8K to 32K.

Included in this Release

  • llama-kvmem-server.exe (independent 256K server with bundled Web UI)
  • llama-server.exe (BeeLlama server with native KVarN / SWA / MTP)
  • ggml-cuda.dll (compiled for Blackwell sm_120a) + optimized CPU backend DLLs
  • Ready-to-run .bat scripts (start-kvmem-256k.bat, start-beellama-kvarn6.bat)
  • Complete Web UI assets (share/kvmem/ui)