Profile
Back to NewsBack
GitHub Trending 6 min
Reader Mode
CURRENTF/SparseEngine: A sparse-first inference engine (SparseEngine).

CURRENTF/SparseEngine: A sparse-first inference engine (SparseEngine).

SparseEngine

Ask DeepWiki arXiv PDF

English | 简体中文

A sparse-first inference engine for long-context LLM serving.

Decode throughput at each method's largest measured batch Decode throughput improvement relative to vLLM Vanilla at matched concurrency

Selected results from the SparseEngine paper, with 128K input / 2K output. Qwen3-30B-A3B uses one H100 80GB GPU, and GLM-4.7-Flash uses two. Top: decode throughput at each system–method pair's largest measured batch. Bottom: throughput improvement relative to vLLM Vanilla at matched concurrency, with vLLM at 0%. Ours denotes SparseEngine.

Project Overview

SparseEngine is an inference framework built with sparsity as the first design principle. Instead of layering sparse methods on top of a conventional KV cache, it rethinks cache layout, controller flow, and kernels so that multiple sparse mechanisms can plug in cleanly.

Note: DeltaKV compressor training code is maintained separately in
CURRENTF/DeltaKV. This repository only
keeps the native DeltaKV inference implementation under src/sparseengine/;
it does not include DeltaKV training code or an HF reference implementation.

Key Runtime Principles

  • Runtime parameter names are identical across LLM(...), Config, JSON
configs, benchmark manifests, and internal consumers. Use sparse_method everywhere; legacy field aliases are not accepted.
  • Sparse method runtime state belongs in
src/sparseengine/engine/cache_manager/; attention.py should stay generic.
  • Prefill scheduling is method-specific and registry-owned. The source of
truth is src/sparseengine/method_registry.py, not benchmark scripts.
  • SparseEngine currently uses two prefill policies: all_chunked and the
special long_bs1full_short_batch policy.
  • long_bs1full_short_batch is only for methods that are registered to need a
complete long-prefill pass before their sparse/cache transformation. Long requests run as full prefill with batch size 1; short requests still use chunked batching.
  • Benchmark reports should record the sparse method, prefill policy, prefill
chunk size, prompt length, batch size, and any DeltaKV checkpoint.

Core Sparse Methods

SparseEngine supports physical eviction, logical masking, query-aware selection, and KV compression. The table below lists all registered cache/decode methods.

| Method | Type | Short Description | | --- | --- | --- | | vanilla | Dense baseline | Runs full attention and keeps the standard KV cache behavior for correctness and performance baselines. | | streamingllm / attention-sink | Physical eviction | Keeps fixed sink tokens plus a recent window, then physically evicts older tokens outside that policy. | | snapkv, pyramidkv | Physical eviction | Selects important historical tokens during prefill/finalization and stores only the retained KV tokens. | | h2o | Physical eviction | Maintains independent cumulative attention importance for every layer, then physically compacts each layer's KV rows using its own heavy-hitter selection plus a recent suffix. | | omnikv | Logical masking | Keeps tokens in storage but masks the attention read view so sparse layers attend only selected context. | | quest | Query-aware selection | Uses decode-time query-aware page selection while keeping prefill dense. | | retroinfer | Query-aware cluster retrieval | Experimental GPU-only method that keeps full KV on GPU, reads top clusters exactly, and estimates the next ranked clusters. | | deltakv / deltakv-* | Hybrid compression | Keeps a small full-precision pool and stores older context through DeltaKV compression or related ablations. | | kvzip | Physical eviction | Scores context reconstruction, then selects and compacts prompt KV after prefill, sharing retained token positions across layers and heads. | | rkv | Physical eviction | Scores attention importance and KV redundancy jointly, sharing token selection across layers and periodically compacting KV. | | skipkv | Selective KV storage | Compresses prompt KV with SnapKV, then skips or removes selected KV during generation based on non-execution markers or sentence redundancy. | | palu | Low-rank KV compression | Keeps all tokens using offline-calibrated low-rank K/V factors, with fused reconstruction during decode. | | kivi | KV quantization | Keeps all tokens with asymmetric integer quantization of K per channel and V per within-token channel group; currently experimental. | | turboquant | KV quantization | Keeps all tokens with fixed-seed orthogonal rotation and non-uniform scalar quantization of KV; currently experimental. | | fp8_kv | KV quantization | Keeps all tokens in E4M3, with separate dynamic K/V scales per token and KV head. |

Model, checkpoint, and runtime restrictions differ across methods; see Core Sparse Methods, Palu, and Quantized KV Cache.

Prefill acceleration is an independent axis: h2o_prefill compacts KV between prompt chunks, flashprefill_v2 sparsifies prefill attention computation, and omnikv_prefill selects cross-layer history during prefill. These are selected with prefill_sparse_method and combined with a compatible sparse_method for cache/decode behavior.

Read the method overview and integration rules in Core Sparse Methods.

Supported Models

| Model | Supported | | --- | :---: | | Qwen2.5 | ✅ | | Qwen3 | ✅ | | Qwen3MoE | ✅ | | Qwen3.5 / 3.6 / 3.8 | ✅ | | Qwen3.6 MoE | ✅ | | GLM-4.7-Flash | ✅ | | Gemma 4 Dense / MoE | ✅ | | Llama 3 / 3.1 | ✅ | | MiniMax M2.7 | ✅ |

See Supported Models for the precision, parallelism, and sparse-method compatibility matrices.

Native image and video inputs are enabled for listed checkpoints with enable_multimodal=True; audio is not yet supported. See the supported-model matrix for media coverage.

Documentation

| Topic | Link | | --- | --- | | Quick setup and minimal usage | Getting Started | | Model, precision, and parallelism support | Supported Models | | Sparse method taxonomy and extension rules | Core Sparse Methods | | Runtime architecture | Architecture | | Runtime parameter semantics | Runtime Parameter Semantics | | Benchmark commands | Benchmarks | | DeltaKV inference | DeltaKV | | Reproducibility checklist | Reproducibility |

The full documentation index is maintained in docs/en/README.md.

Quick Start

SparseEngine requires Python 3.10 or newer. The canonical CUDA 13 development environment uses Python 3.12. Default dependencies are declared in pyproject.toml.

Conda

conda create -n sparseengine-cu130-py312 python=3.12 -y
conda activate sparseengine-cu130-py312

python -m pip config --site set global.extra-index-url \ "https://download.pytorch.org/whl/cu130 https://flashinfer.ai/whl" python -m pip install "transformers==5.13.1" -e ".[cu130]" python -m pip check

uv

uv venv --python 3.12
source .venv/bin/activate

uv pip install -e ".[cu130]"

Use cu129 instead of cu130 for CUDA 12.9.

Additional dependencies

Install these packages after setting up the base environment if the conditions below apply.

FlashInfer JIT Cache is required if the CUDA toolkit headers are missing. With the headers installed, the cache is optional and reduces first-use compilation. See FlashInfer JIT cache installation for version-matched uv and Conda commands.

DeepEP V1 provides the NVLink MoE communication backend selected by moe_backend="deepepv1" and builds against the installed PyTorch/CUDA environment.

pip install --no-build-isolation -e ".[deepepv1]"

For the full dependency list and a minimal LLM(...) example, see Getting Started.

Benchmarks

Use scripts/benchmarks/bench_sparse_engine.py for throughput measurements and the benchmark/ entrypoints for LongBench, MathBench, SCBench, NIAH, and multimodal evaluations.

See Benchmarks for command examples and backend notes.

Contributing Sparse Methods

New sparse methods should keep persistent physical cache state in src/sparseengine/engine/cache_manager/, keep logical orchestration behind a SparseMethodRuntime, and keep src/sparseengine/layers/attention.py generic. See the sparse method runtime architecture.

Acknowledgements

This project is inspired by and/or references ideas and implementation techniques from:

  • LightLLM (ModelTC/LightLLM)
  • SGLang (sgl-project/sglang)
  • ShadowKV (ByteDance-Seed/ShadowKV)
  • nano-vllm (GeeeekExplorer/nano-vllm)

License

Apache License 2.0

Citation

@article{Hao2026SparseEngineSI,
  title={SparseEngine: Sparse-First Inference Engine},
  author={Jitai Hao and Quan-Sheng Gu and Qiang Huang and Jun Yu},
  journal={ArXiv},
  year={2026},
  volume={abs/2609.39068},
  url={https://api.semanticscholar.org/CorpusID:292486860}
}

If SparseEngine has helped you, please give it a Star on GitHub; it means a lot to us.

Chat with me