Overview
AirLLM is an open-source Python library that shrinks the GPU memory an LLM needs at inference time. Instead of holding the whole model in VRAM, it splits the checkpoint into per-layer shards on disk and loads only the layer it is currently computing. Because the VRAM requirement then tracks the size of a single layer rather than the whole model, the project reports running a 70B model on one 4GB card, Llama 3.1 405B on about 8GB, and DeepSeek-V3 (671B) on about 12GB. For sparse Mixture-of-Experts models it streams one expert at a time, which is how it reports fitting Kimi K3 under 4GB.
The trade is memory for time: every layer is read from disk on each forward pass, so throughput is far below a GPU that holds the whole model. AirLLM is therefore aimed at people who want to run, inspect or experiment with a model their hardware could not otherwise load at all — a single hobbyist card, a laptop, or a Colab notebook — rather than at production serving, where vLLM, SGLang or TensorRT-LLM belong.
It is deliberately a thin layer over the Hugging Face ecosystem. You pass a Hugging Face repo id (or a local path) to a single `AutoModel.from_pretrained` call and then use `generate` as you would with Transformers, so most existing inference code needs almost no change. The project also ships an optional block-wise weight compression mode and supports Apple Silicon through MLX.
What it does
- Layer-by-layer loading: only one transformer layer sits on the GPU at a time, so VRAM scales with layer size, not model size
- Per-expert streaming for sparse MoE models, loading only the experts a token actually routes to
- One `AutoModel.from_pretrained` entry point that auto-detects the architecture and accepts any Hugging Face repo id or local path
- Optional 4-bit or 8-bit block-wise weight compression, which the project reports as up to a 3x inference speed-up because less data is read from disk
- Works on Apple Silicon via MLX, and supports CPU inference as well as NVIDIA GPUs
- Configuration hooks for profiling, custom shard paths, gated-model tokens, prefetching, and deleting the original checkpoint to save disk
Getting started
AirLLM installs as a single pip package. On first run it decomposes the model and saves it layer-wise, so make sure the Hugging Face cache directory has enough free disk space.
Install the package
AirLLM is on PyPI.
pip install airllmLoad a model and generate
Pass a Hugging Face repo id to AutoModel, then tokenize and call generate exactly as you would with a normal Transformers model. The same one line works for far larger checkpoints.
from airllm import AutoModel
MAX_LENGTH = 128
model = AutoModel.from_pretrained("Qwen/Qwen3-32B")
# go bigger with the exact same one line:
# model = AutoModel.from_pretrained("deepseek-ai/DeepSeek-V3") # 671B, runs in ~12GB
input_tokens = model.tokenizer(
["What is the capital of United States?"],
return_tensors="pt",
return_attention_mask=False,
truncation=True,
max_length=MAX_LENGTH,
padding=False,
)
generation_output = model.generate(
input_tokens["input_ids"].cuda(),
max_new_tokens=20,
use_cache=True,
return_dict_in_generate=True,
)
print(model.tokenizer.decode(generation_output.sequences[0]))Turn on compression for more speed
Install bitsandbytes, then pass compression='4bit' (or '8bit') when loading. This quantizes only the weights, which is what the disk-loading bottleneck depends on.
pip install -U bitsandbytes airllmConfigure the run
from_pretrained also accepts profiling_mode to print time consumption, layer_shards_saving_path to put the split model elsewhere, hf_token for gated repos, prefetching to overlap loading with compute, and delete_original to drop the downloaded checkpoint and save about half the disk space.
model = AutoModel.from_pretrained(
"garage-bAInd/Platypus2-70B-instruct",
compression="4bit",
)Run it on a Mac
On Apple Silicon the code is the same; install mlx and torch first. Only Apple Silicon is supported — Intel Macs are not.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Reach for it when you want to run a model that is far too large for your GPU and can accept slow generation in exchange
- Use it to smoke-test or inspect the outputs of a frontier open-weight model on one consumer card before renting multi-GPU hardware
- Good for notebook and Colab experiments where the alternative is not running the model at all
- Skip it for production serving — a throughput engine such as vLLM or SGLang with enough VRAM will be orders of magnitude faster
How AirLLM compares
AirLLM alongside other open-source local runtimes tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Ollama | ★ 179k | A developer-friendly tool that downloads and runs local LLMs from the terminal with a built-in OpenAI-compatible API. |
| llama.cpp | ★ 125k | A C/C++ inference engine that runs LLMs in the GGUF format on CPUs, Apple Silicon, and GPUs with low memory use. |
| GPT4All | ★ 77.4k | GPT4All is a free desktop app and Python client that runs large language models locally on your own computer, with no API calls or GPU required. |
| LocalAI | ★ 48.6k | A self-hosted server that exposes an OpenAI-compatible API for running text, vision, voice, and image models on local hardware. |
| Jan | ★ 44.1k | An open-source desktop app that runs LLMs fully offline as a ChatGPT-style assistant on your own computer. |
| AirLLM | ★ 32.3k | Run 70B and larger models on a single small GPU by streaming one layer at a time |
| llamafile | ★ 25.7k | A Mozilla project that packages a model and its runtime into one executable file you can copy and run on any OS. |
| MLC LLM | ★ 23.1k | A machine-learning compiler that builds and runs LLMs across browsers, phones, and desktops using TVM-based code generation. |