---
title: "Fine-tuning LLMs to 1.58bit: extreme quantization made easy"
description: "Existing LLMs can be fine-tuned into BitNet's 1.58-bit ternary format (-1, 0, 1) instead of pre-training from scratch, and a Llama3 8B fine-tuned this way on 100B tokens outperforms Llama 1 7B on MMLU."
url: "https://swe.quest/articles/fine-tuning-llms-to-1-58bit-extreme-quantization-made-easy-1f532a3df4c4d82f"
canonical: "https://huggingface.co/blog/1_58_llm_extreme_quantization"
source: "Hugging Face"
published: "2024-09-18"
difficulty: "hard"
kind: "Research"
reading_minutes: 28
tags: ["inference","model-training","llms"]
---

# Fine-tuning LLMs to 1.58bit: extreme quantization made easy

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-09-18, 28 min read, Research. Original: [https://huggingface.co/blog/1\_58\_llm\_extreme\_quantization](https://huggingface.co/blog/1_58_llm_extreme_quantization)

## Summary

Existing LLMs can be fine-tuned into BitNet's 1.58-bit ternary format (-1, 0, 1) instead of pre-training from scratch, and a Llama3 8B fine-tuned this way on 100B tokens outperforms Llama 1 7B on MMLU. Training uses BitLinear layers with absmean per-tensor weight quantization, absmax per-token 8-bit activation quantization, layer normalization before activation quantization, and a straight-through estimator implemented via detach(). Inference quantizes weights without rescaling and runs matrix multiplication through efficient kernels. The resulting models load in Transformers through a new 'bitnet' quantization method with no API changes, and pre-training experiments show layer normalization lowering validation perplexity from 6.3 to 5.9.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- LLM transformer architecture ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- neural network quantization ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- PyTorch training basics ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))

## Keywords

BitNet b1.58, BitLinear, Llama3 8B, Transformers, Nanotron, Straight-Through Estimator, HF1BitLLM

## Related posts

- [Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA](https://swe.quest/articles/making-llms-even-more-accessible-with-bitsandbytes-4-bit-quantization-and-qlora-7bc797d3e83b0ec6.md): Hugging Face · 2023-05-24 · Medium · 14 min read · Inference & serving, Model training, LLMs, Python
  bitsandbytes now integrates 4-bit quantization into Hugging Face transformers, letting most accelerate-loadable models (text, vision, multimodal) run in 4-bit and be fine-tuned via QLoRA, which backpropagates through a frozen 4-bit base model into LoRA adapters.
- [Falcon-Edge: A series of powerful, universal, fine-tunable 1.58bit language models.](https://swe.quest/articles/falcon-edge-a-series-of-powerful-universal-fine-tunable-1-58bit-language-models-3708dd89aa2b35cd.md): Hugging Face · 2025-05-15 · Hard · 9 min read · Model training, LLMs, Inference & serving, Python
  Falcon-Edge is a set of 1B and 3B ternary (1.58-bit) BitNet language models, in base and instruct variants, pre-trained on about 1.5T tokens with a WSD learning-rate schedule and reported competitive with similarly sized models on Hugging Face leaderboard benchmarks.
- [A Gentle Introduction to 8-bit Matrix Multiplication for transformers at scale using transformers, accelerate and bitsandbytes](https://swe.quest/articles/a-gentle-introduction-to-8-bit-matrix-multiplication-for-transformers-at-scale-af5b5f40a9067e95.md): Hugging Face · 2022-08-17 · Medium · 21 min read · Inference & serving, LLMs, Machine learning, Hardware
  LLM.int8() makes 8-bit inference of 175B-class transformers possible with no measurable quality loss.
- [Overview of natively supported quantization schemes in 🤗 Transformers](https://swe.quest/articles/overview-of-natively-supported-quantization-schemes-in-transformers-c1bfbebb9330add3.md): Hugging Face · 2023-09-12 · Medium · 9 min read · Inference & serving, Model training, LLMs, Performance engineering
  bitsandbytes and GPTQ (via auto-gptq), the two quantization schemes built into Transformers, trade off differently. bitsandbytes needs no calibration data, works on any model with nn.Linear layers across modalities, and lets LoRA adapters merge without degradation.
- [Smaller is better: Q8-Chat, an efficient generative AI experience on Xeon](https://swe.quest/articles/smaller-is-better-q8-chat-an-efficient-generative-ai-experience-on-xeon-67e9bd0a15445b38.md): Hugging Face · 2023-05-16 · Easy · 5 min read · Inference & serving, LLMs, Hardware
  SmoothQuant enables accurate 8-bit (INT8) post-training quantization of LLMs by mathematically shifting activation outliers into the weights, which makes Transformer layers quantization-friendly.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
