Home / Engineering / How to Run 70B LLMs on a 4GB GPU with AirLLM

How to Run 70B LLMs on a 4GB GPU with AirLLM

The short version (TL;DR)

AirLLM is an open-source Python library. It runs very large language models on a GPU with as little as 4GB of VRAM. It keeps one layer of the model on the GPU at a time and reads the rest from disk. The README says a 70B model fits on a 4GB card without quantization. It lists Kimi K3 (2.8T) in under 4GB, Qwen3.8-Flash-Next (125B) in about 6GB, and DeepSeek-V3 (671B) in about 12GB.

We explain it with pictures and graphs: a layer diagram, a speed chart, and a quick decision guide for you.

The catch is speed. Every token is read from disk. The release notes measure Kimi K3 at 292 seconds per token. So it suits overnight batch jobs and experiments. Chat is too slow.

The project is lyogavin/airllm on GitHub. It uses the Apache 2.0 license and has close to 40k stars.

The problem: big models need big GPUs

A 70B model at 16-bit precision is about 140GB of weights. No consumer GPU holds that much. The usual fixes are a quantized copy, a rented GPU, or a paid API. AirLLM does something else. It keeps the full-precision weights and changes how they reach the GPU.

The fix: stream one layer at a time

AirLLM keeps one layer of the model on the GPU at a time. The VRAM you need depends on the size of one layer. The whole model stays on disk.

On the first run, AirLLM splits the downloaded model into one file per layer. When you generate text, it loads a layer, runs it, and frees it. Then it moves to the next layer. Mixture-of-experts models like Kimi K3 get one more trick. The README says AirLLM loads only the experts each token is routed to.

What it can run (and the VRAM it needs)

The README lists VRAM figures from about 1GB for 8B models up to 12GB for DeepSeek-V3. Table 1 collects them. The README says Qwen3.8-27B, Qwen3.8-Flash-Next, and Kimi K3 were measured on an RTX 3090, an RTX 4090, and an RTX 6000 Ada.

Table 1: Models and GPU VRAM listed in the AirLLM README
ModelSizeGPU VRAM
Qwen3 / Mistral / Phi8B~1 to 2 GB
Qwen3.8-27B (dense, vision)27B3.33 GB
Qwen3-30B / Mixtral (MoE)30 to 47B~1 to 3 GB
Llama 3.x (full precision)70B~4 GB
Qwen3.8-Flash-Next (MoE + PLE)~180B5.95 GB
Qwen3-235B (MoE)235B~3 GB
Llama 3.1405B~8 GB
DeepSeek-V3671B~12 GB
Kimi K32.8T3.72 GB

The README says it works with most popular open models through one AutoModel class. That includes Llama, Qwen, DeepSeek, Mistral, Mixtral, Phi, Gemma, ChatGLM, Baichuan, InternLM, and Yi.

Run it yourself right now (it’s easy)

Three steps take you from install to a first answer. Start with an 8B model. Check your setup before you commit disk space to a 70B download.

Step 1: Install AirLLM

Install the package from PyPI.

pip install airllm

Some models need extra packages. Qwen3.8-Flash-Next needs a recent transformers build. Kimi K3 needs compressed-tensors and flash-attn. Both are covered in the challenges section.

Step 2: Run your first model

Pass a Hugging Face repo ID or a local path to AutoModel.from_pretrained. Then generate text the way you would with any transformers model.

from airllm import AutoModel

MAX_LENGTH = 128
model = AutoModel.from_pretrained("Qwen/Qwen3-32B")

input_text = ['What is the capital of United States?']

input_tokens = model.tokenizer(input_text,
    return_tensors="pt",
    return_attention_mask=False,
    truncation=True,
    max_length=MAX_LENGTH,
    padding=False)

generation_output = model.generate(
    input_tokens['input_ids'].to(model.device),
    max_new_tokens=20,
    use_cache=True,
    return_dict_in_generate=True)

print(model.tokenizer.decode(generation_output.sequences[0]))

To go bigger, change only the model ID. The README uses Qwen/Qwen3-235B-A22B for the 235B model. It uses deepseek-ai/DeepSeek-V3 for the 671B one.

Gated models, such as Llama, need a Hugging Face token. Pass it with the hf_token argument.

Step 3: Speed it up with compression

AirLLM has an optional compression mode. It uses block-wise quantization. The README says it can speed up inference by up to 3x, with almost no accuracy loss. Install bitsandbytes, then pass the compression argument.

pip install -U bitsandbytes
model = AutoModel.from_pretrained("garage-bAInd/Platypus2-70B-instruct",
                                  compression='4bit')  # or '8bit'

Disk loading is the bottleneck. Smaller weights mean less to load. Only the weights get quantized. That makes accuracy easier to keep.

Bonus: fine-tune big models on a low-VRAM GPU

AirLLM can also fine-tune big models. The README says Qwen3.8-Flash-Next (125B) trains in under 6GB. Qwen3.8-27B trains in about 2GB at sequence length 512. The frozen base weights stream from disk one layer at a time. Only the LoRA adapters stay on the GPU. It runs on its own code path, separate from Hugging Face Trainer and bitsandbytes QLoRA.

Your data is a .jsonl file with one JSON object per line. The usual field is text. Prompt and completion pairs also work.

python air_llm/examples/train_qwen38_flash_next_lora.py \
  --data my_data.jsonl \
  --seq-len 512 \
  --epochs 1 \
  --save-adapter qwen38-flash-next-lora.pt

For the 27B dense model, use train_qwen38_lora.py instead. Add --steps N for a quick test run.

The challenges: speed, disk space, and requirements

A 4GB GPU covers the VRAM. The load moves to your disk and your system RAM.

Speed. Every token passes through all the layers. Every layer is read from disk. The README says disk loading is the bottleneck. That is why it offers compression. The Kimi K3 release notes give one figure: 292 seconds per token on an RTX 6000 Ada. The next section has more numbers. A fast NVMe drive matters more than a faster GPU. Test on your own hardware first.

Disk space. The first run splits the model into layer files. You need room for both copies. The README suggests delete_original=True to remove the original download. If you see a MetadataIncompleteBuffer error, the README’s first guess is a full disk.

Extra requirements. The biggest models have their own conditions. Table 2 lists them.

Table 2: Extra requirements for specific models
ModelDisk and RAMSoftware
Qwen3.8-27BNot statedtransformers 5.8 or newer
Qwen3.8-Flash-Next~360GB checkpoint disk, 64GB host RAMtransformers build with qwen4_exp, installed from GitHub
Kimi K3Not statedcompressed-tensors, flash-attn, CUDA 12 build of torch, transformers 4.56.x

macOS. It runs on Apple silicon only. For now it supports only Llama-style models, such as Llama and Mistral.

Is it worth it? What critics and forums say

Most of the pushback is about speed. Nobody disputes the memory claim. The Hacker News thread reached 232 points and 84 comments. Reviews and commenters agree that a 70B model runs in about 4GB of VRAM. They say it is too slow for most people. Table 3 collects the speeds people report.

Table 3: Speeds reported for AirLLM and alternatives
SetupSpeedBasis
AirLLM, Kimi K3, RTX 6000 Ada 48GB292 s/token, plus 900 s one-time initMeasured, AirLLM v3.1.0 release notes
AirLLM, 70B fp16, Gen4 NVMe, cold~20 s/tokenCalculated from 141GB of weights at ~7GB/s (RunAIHome)
AirLLM, 70B, 4-bit compression, warm cache~0.3 tokens/sOne hands-on test, as cited by RunAIHome
AirLLM, 70B on a MacBook~14 s/tokenCommunity reports, as cited by DEV Community
llama.cpp, 70B Q4_K_M held in 64GB RAM2 to 4 tokens/sEstimate from RunAIHome
llama.cpp, quantized 70B on an RTX 40908 to 15 tokens/sFigure cited by DEV Community

The maintainer’s own number. The K3 release notes call 292 seconds per token disk-bound. A 100-token reply would take a little over eight hours. Several Hacker News commenters first read it as tokens per second. One commenter ran the cost. They assumed 100 watts and Moonshot’s published API prices. They found the local run costs about 80 times more than the API. Those are their assumptions.

Faster alternatives exist. Reviewers point to llama.cpp with a quantized model. RunAIHome says it is 10 to 50 times faster than AirLLM when the model fits in RAM. One Hacker News commenter asked what AirLLM adds over that setup. These ratios come from blog estimates. Treat them as rough.

RAM sets your speed. The operating system caches layers once they are read. Later passes read from memory. That is why reports differ so much between a 16GB machine and a 128GB machine. RunAIHome’s view is that AirLLM only feels usable on machines with enough RAM that you may not have needed it.

The “no quantization” claim has fine print. The speedup in Step 3 comes from 4-bit or 8-bit compression. That is quantization. You pick full precision or the faster mode.

Disk wear is disputed. DEV Community warns that constant full-model reads are not what consumer drives were built for. RunAIHome says endurance ratings count writes. On that view, reads are safe and the wear happens once, when the shards are written. I could not verify either claim. Check your own drive’s rating.

Project quality. A few Hacker News commenters called the documentation thin. Some worried about long-term maintenance. The release page shows regular releases. The latest is v4.0.0 on 5 September.

Where critics still see value. The same sources agree on some uses. Those are overnight batch jobs, full-precision evaluation, and data that can’t leave your machine. DEV Community cites one reported benchmark. Batching 50 prompts cut the cost from 35 to 5.3 seconds per token. The layer loading is shared across the batch. I could not trace that figure to its source.

The takeaway

AirLLM trades speed for reach. Models that once needed a cluster now run on one consumer card. That suits experiments, evaluation, and fine-tuning. For fast answers, use a multi-GPU setup.

If you have a spare GPU and a fast SSD, install it and run an 8B model first. Then raise the model size. See where your disk becomes the limit.

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *