🤑 economize
Composable efficiency techniques for Hugging Face language models
economize makes text generation with Hugging Face causal language models faster and cheaper. It implements more
than 50 published efficiency techniques, from speculative decoding and early exit to pruning, quantization and
KV-cache compression, and attaches any combination of them to an unmodified transformers model with a single
function call.
- One interface for many methods. Drafters such as EAGLE-3 and Medusa, dynamic-depth methods, weight compression and KV-cache compression share the same configuration and decoding API.
- Free combination. Techniques can be stacked, for example 2:4 pruning, int4 quantization, activation sparsity and a drafter in one model. economize attaches them in a well-defined order.
- The base model stays intact. The model keeps its modules and its
forwardmethod, so it continues to work withgenerate, PEFT, the Hugging Face Hub and the rest of the ecosystem. - Fast, lossless decoding. Batches of prompts of different lengths, chains and draft trees, lossless speculative sampling, CUDA graphs and speculative speculative decoding over several GPUs.
- Training and serving. Drafters and other added components train with a built-in loop or with
transformers.Trainer, and export to vLLM and SGLang. - Extensible. New techniques, model families, verifiers and backends are added by registering a class, without changing the library.
Installation
pip install economize
economize requires Python 3.10 or later, PyTorch 2.4 or later and transformers 5.0 or later. The optional
integrations (PEFT, quantization kernels, training, evaluation, vLLM, SGLang) are extras, listed in
Getting started.
Quick start
A published EAGLE-3 head attached to its base model generates exactly the tokens of the base model, only faster:
import torch
import economize
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct", dtype=torch.bfloat16,
device_map="cuda")
model = economize.load(base, "yuhuili/EAGLE3-LLaMA3.1-Instruct-8B") # a Hub repository or a local folder
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
ids = tokenizer("The water cycle describes", return_tensors="pt").input_ids.cuda()
out = model.generate(ids, max_new_tokens=128)
print(tokenizer.decode(out[0]))
Several techniques combine in one call. Techniques that need calibration data receive it through calibration:
from economize.techniques.eagle3 import Eagle3Config
from economize.techniques.prune import PruneConfig
from economize.techniques.quant import QuantConfig
from economize.techniques.sparsity import TealConfig
model = economize.apply(
base,
PruneConfig(method="wanda", sparsity="2:4"), # 2:4 sparse weights
QuantConfig(format="int4", method="gptq", group_size=128), # int4 weights
TealConfig(sparsity=0.4), # activation sparsity
Eagle3Config(), # a drafter, trained with economize.train.fit
calibration=calibration_ids, # a LongTensor [N, S], an iterable of batches or a callable
)
The documentation covers installation, decoding options, training, serving, a tutorial for every technique and how to extend the library.
Supported techniques
| Family | Techniques |
|---|---|
| Drafters for speculative decoding | EAGLE-1/2, EAGLE-3, HASS, Medusa, Hydra, ReDrafter, DFlash, early exit and LayerSkip, Kangaroo, layer skipping (SWIFT), KnapSpec, separate draft models (also on another GPU), PARD, the Gemma-4 MTP assistant, prompt lookup, Lookahead, REST, SuffixDecoding, FR-Spec, MTP heads of DeepSeek-V3, GLM-4.5, MiMo and Qwen3.5, MagicDec and TriForce for long contexts |
| Dynamic depth | CALM, GateSkip, Mixture-of-Depths, FlexiDepth, SkipDecode, LoRA-Drop, FREE, DMTD, Hidden Transfer |
| Weights and activations | ShortGPT and SLEB, magnitude, Wanda and SparseGPT pruning with 2:4 sparsity, SliceGPT, FLAP width pruning, SVD-LLM, LittleBit, RTN, GPTQ and AWQ to int2-int8 or fp8 with Marlin, Machete, torchao or compressed-tensors kernels, rotations, draft-only quantization, TEAL, CATS and DejaVu activation sparsity |
| KV cache and attention | KIVI, FP8 KV cache, StreamingLLM, H2O and SnapKV eviction, DuoAttention, with fused attention kernels, Quest sparse decoding attention, MInference sparse prefill |
The techniques work on 46 model types, including dense, mixture-of-experts and hybrid attention/Mamba models. Techniques lists every technique with its registered name, its backends and the techniques it combines with.
Model zoo
Drafters trained with economize are published on the Hugging Face Hub in the collection economize drafters, for example:
| Checkpoint | Base model | Speedup |
|---|---|---|
flaitenberger/economize-eagle3-gemma-4-31B-it |
Gemma-4-31B-it | 1.94x |
flaitenberger/economize-eagle3-Ministral-3-8B-Instruct-2512 |
Ministral-3-8B-Instruct-2512 | 1.59x |
flaitenberger/economize-eagle3-Olmo-3-7B-Instruct |
Olmo-3-7B-Instruct | 1.55x |
The speedups are lossless, at batch size 1 on one H100, averaged over chat, code, math, summarization and long-context prompts. The model zoo lists every checkpoint with its speedup per task group, and Benchmarks compares economize with the published speedups of other checkpoints.
Limitations
Version 0.4 does not yet support dynamic draft trees or speculative speculative decoding on models with recurrent layers, trainable hook-based splits on tensor-parallel models (frozen ones are supported), or speculative speculative decoding on tensor-parallel models. Some techniques cannot yet be exported to vLLM, in which case the export raises an error that states the reason.
Development
pip install -e ".[dev]"
pytest # unit, technique, integration and oracle tests on the CPU
pytest -m gpu # batched decoding on a CUDA device
Contributing describes the checks and the design rules for contributions, and Extending how to add a technique, a model family or a backend.
Citation
If you use economize in your research, please cite it:
@software{laitenberger2026economize,
author = {Laitenberger, Filipe},
title = {economize: Composable Efficiency Techniques for Hugging Face Language Models},
year = {2026},
url = {https://github.com/Thiggel/economize},
version = {0.4.0}
}
Please also cite the papers of the techniques you use.
License
economize is released under the Apache License 2.0. See LICENSE for details.
Metadata
Release files for economize 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| economize-0.4.0.tar.gz | 2.4 MB | Without provenance | Details for economize-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| economize-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for economize-0.4.0-py3-none-any.whl |
Total release size: 3.8 MB
Release files / economize-0.4.0.tar.gz
| Download URL | economize-0.4.0.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
491eacd155032ebb72d4e6f39608da01f0563ae0c732a215f18569ce5083e8b3
|
|
BLAKE2b-256 checksum How to use checksums |
140a2945da16a8b5a5894a6c597668dc7bdac09b733aba0fe2e825cff11f260a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / economize-0.4.0-py3-none-any.whl
| Download URL | economize-0.4.0-py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7028009ef6d97305aa1ea770f79f2211c50ae693240590838469664040f19fe
|
|
BLAKE2b-256 checksum How to use checksums |
bf08699d511ebebb2248600f69121ae1b1f85ae6a832299c6e9c6302871f060f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for economize 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.