Home / Guide / Performance
Performance

AirLLM Compression Explained: 4-Bit and 8-Bit Modes Without the Guesswork

Understand AirLLM compression: how block-wise 4-bit and 8-bit weight quantization works, when to use it, how it affects quality and how to enable it safely.

AirLLM Compression Explained: 4-Bit and 8-Bit Modes Without the Guesswork

Compression is the most effective single setting for improving AirLLM's throughput, yet it is often misunderstood. Some users avoid it, fearing poor answers; others assume it changes how much GPU memory is needed. This guide explains exactly what AirLLM compression does, how it differs from conventional quantization and how to decide between 4-bit, 8-bit and no compression at all.

Why compression matters more for AirLLM

In most local AI tools, quantization exists to make a model fit into memory. AirLLM already solves the memory problem by streaming layers, so its reason for compression is different: disk throughput. Every generated token requires reading every layer from storage. If the stored layers are half or a quarter of their original size, there is half or a quarter as much data to read, and generation speeds up accordingly. The project reports up to a threefold improvement with compression enabled.

How block-wise weight quantization works

A layer's weights are normally stored as 16-bit floating-point numbers. Quantization represents them with fewer bits. Block-wise quantization divides the weights into small blocks and stores each block with its own scaling factor. Because each block is scaled on its own, unusual values in one block do not distort the rest, which preserves accuracy far better than a single global scale.

AirLLM applies this only to the weights. Activations, the intermediate values passed between layers, remain in higher precision. Many aggressive quantization schemes compress both, which is where most accuracy loss comes from. Keeping activations intact is why AirLLM's compression has a modest effect on quality.

Choosing a mode

ModeApprox. shard sizeSpeedQualityBest for
None (16-bit)100%BaselineOriginalBenchmarks and reference output
8-bitAbout 50%FasterNear-originalMost everyday work
4-bitAbout 25–30%FastestSlightly reducedLarge models, slow drives, batch jobs

For most people, 8-bit is the sensible default. Choose 4-bit when storage is slow or the model is very large, and choose no compression when you need to reproduce the exact behaviour of the original model.

Enabling compression

pip install -U bitsandbytes airllm
from airllm import AutoModel

model = AutoModel.from_pretrained(
    "meta-llama/Llama-3.1-70B-Instruct",
    compression="8bit",            # or "4bit"
    hf_token="YOUR_HF_TOKEN",
    layer_shards_saving_path="D:/airllm_cache",
)

On the first run with a new compression setting, AirLLM prepares compressed shards. Later runs reuse them.

Disk space planning

During preparation, the original download, any existing uncompressed shards and the new compressed shards may all exist at once. For a 70B model, budget roughly 140 GB for the original weights plus 35 to 70 GB for compressed shards. If space is tight, set delete_original=True once you are confident in your setup, and remove shard folders for settings you no longer use.

Testing quality yourself

Rather than relying on general claims, compare modes on tasks you care about:

  1. Write ten representative prompts from your real work.
  2. Run them with 8-bit and 4-bit compression using identical settings.
  3. Review the answers side by side, ideally without knowing which is which.
  4. Adopt the fastest mode whose answers you are satisfied with.

Fixing the random seed and using greedy decoding makes comparisons fairer, because sampling randomness will not mask genuine differences.

Compression and FP8 models

Recent AirLLM versions support models published natively in FP8, such as DeepSeek-V3. These checkpoints are already 8-bit, so the files are smaller from the start. Additional compression on top of an FP8 model is generally unnecessary; check the README for the recommended configuration for each family.

Common questions and problems

  • "bitsandbytes not found": install it in the same virtual environment as airllm.
  • Compressed run is not faster: confirm the shards are on fast storage and that the operating system is not already serving them from RAM cache, which hides the difference.
  • Unusual answers in 4-bit: try 8-bit; some smaller models are more sensitive to 4-bit weights.
  • GPU memory unchanged: expected. Compression mainly speeds up loading; AirLLM already keeps VRAM use low.

Quality versus speed in real tasks

The effect of compression depends heavily on the task. Summarisation, classification, translation of everyday text and straightforward question answering are usually robust; most people cannot tell 8-bit from the original, and 4-bit differences are minor. Tasks that demand precise reasoning over many steps, exact arithmetic, or careful code generation are more sensitive, and 4-bit weights may occasionally produce a different answer. Larger models generally tolerate compression better than smaller ones, because their knowledge is spread across more parameters. That is convenient, since large models are also where compression helps speed most.

A practical evaluation template

Prompt categoryExampleWhat to look for
SummarySummarise a two-page reportKey points retained, no invented facts
ReasoningA multi-step word problemCorrect final answer and logical steps
CodeWrite a small function with testsCode runs and tests pass
StyleRewrite a paragraph formallyTone, grammar and fluency

Score each answer simply, for example acceptable or not acceptable, and compare totals across modes. Even ten prompts per category give a clear picture.

Storage arithmetic for compressed shards

A 16-bit parameter occupies two bytes. Eight-bit storage uses one byte plus a small overhead for block scales, and four-bit storage uses half a byte plus overhead. For a 70B model, that means roughly 140 GB uncompressed, a little over 70 GB at 8-bit and somewhat under 40 GB at 4-bit. Because time per token is proportional to the bytes read, these numbers translate almost directly into speed. They also matter for capacity planning: a 1 TB drive can hold several compressed 70B models, but only a handful uncompressed.

  • First experiments: 4-bit, for the quickest feedback.
  • Everyday work: 8-bit, for near-original quality.
  • Published results or audits: no compression, for reference fidelity.

A practical AirLLM compression trial

Choose three or four prompts that represent what you actually intend to do. For a document workflow, use a short summary, an extraction with a fixed set of fields and a question that requires evidence from several paragraphs. For a programming workflow, include a small change you can verify with a test. Prompts with a known answer make it easier to spot subtle differences. Use the same checkpoint and chat template for each compression mode, and keep the output limit and decoding settings constant.

Create separate locations for the sharded copies if your configuration allows it. This makes it easier to identify which weights were prepared for which run. Check disk space before each conversion, particularly if original weights and several sharded copies share a drive. Record how long the first preparation takes and how much space the resulting files use. Conversion is a setup cost, so keep that figure separate from the time taken to answer a prompt once the model is ready.

Run each prompt at least twice after the initial load. Take notes on time to first token, time to finish and the peak memory visible to your monitoring tool. Include output format in your quality review. An answer can read well while dropping a required field or inventing a value that should have been left blank. For code, verify the behaviour with the same test for all modes. If the model uses sampling, compare several runs before attributing a difference to compression.

Choose the configuration that meets your quality and timing requirements together. An eight bit run may offer enough space savings for a workflow with strict output rules. Four bit weights can be worth testing when storage reads dominate and you need the smallest practical footprint. Compare the result with uncompressed weights on a smaller supported checkpoint if keeping all three versions of the full model is impractical. Save the model revision, AirLLM version and compression setting alongside your measurements.

When you change the backend, update the checkpoint or move to a different computer, repeat the simplest part of the trial. Compression support varies by backend and model, and a setting that worked on one machine can fail during setup on another. Retain the first successful configuration as a reproducible baseline. That gives you a way to distinguish an incompatibility from the ordinary variability of generated text. Review the current implementation notes before using compression on a model that already ships in a specialised weight format.

Frequently asked questions

It stores each layer weights in 8-bit or 4-bit form instead of 16-bit. Smaller shards are read from disk faster, which is the main bottleneck, so generation speeds up noticeably.

Slightly. AirLLM compresses only the weights using block-wise quantization and keeps activations at higher precision, so the loss is usually small. 8-bit is almost indistinguishable from the original; 4-bit shows minor differences on demanding tasks.

Compression relies on the bitsandbytes library. Install it with pip install -U bitsandbytes before setting the compression argument.

Yes. Compressed shards are stored differently, so AirLLM prepares a separate set of shards for each compression setting. Keep enough free disk space for this.

Conclusion

AirLLM compression is less about fitting models into memory and more about reducing the data your drive must deliver for every token. Block-wise weight quantization keeps quality loss small, 8-bit offers an excellent default, and 4-bit gives the greatest speed for very large models. Test both on your own prompts, plan disk space carefully and you will gain substantial speed at little cost. For broader tuning advice, read our AirLLM speed guide.