# INT8 vs INT4 vs FP8

> How INT8, INT4 and FP8 store a model's numbers, what each costs in quality, and how to pick one for a real server, for your AI interview.

**In short:** INT8 and INT4 store each weight as a whole number, in 8 bits or 4 bits. FP8 stores it as an 8-bit floating-point number, whose steps grow with the size of the value. Fewer bits mean less memory and more quality risk, so pick one and test it on your own tasks.

AI and LLM interview question Q312, Inference, performance and cost. Advanced, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/int8-vs-int4-vs-fp8

## Say it in 30 seconds

INT8 and INT4 store each model weight as a whole number, using 8 bits or 4 bits. FP8 is a floating-point format, also 8 bits, whose steps grow with the size of the value, so it covers a wider range of sizes. INT8 is often the first try, with half the memory of 16-bit. INT4 saves more memory but loses more accuracy, so it needs the most testing. I pick the smallest format that passes our own tests, and I check the speed on the GPU we really use.

## Say it in 2 minutes

A model's weights are numbers held in memory, and models are usually loaded at 16 bits per weight. INT8 rounds each weight to one of 256 whole numbers, so it takes half the memory. INT4 uses only 16 whole numbers, so it takes a quarter. FP8 is different. It is a floating-point format, so its steps are uneven: fine near zero, wider for big values. That can suit a model with a few very large weights.

The price is quality. Rounding loses detail, and INT4 loses the most. A few large weights, called outliers, stretch the scale for the whole group, so with only 16 steps the smallest weights round to zero. Methods such as AWQ protect the most important weights, and the AWQ paper reports that protecting just 1% of them can greatly reduce quantization error. Speed also depends on the hardware. A smaller format only runs faster when the GPU has code that understands it.

On a real server I start with the sum. Take a made-up 70-billion-parameter model. At 16 bits its weights need about 140 GB, too big for two 48 GB GPUs. At 8 bits they need about 70 GB, which leaves room for the cache. So I try INT8 first and test it on our own policy questions. If the answers fall short at the same size, I try FP8. If memory is short, I try INT4 with AWQ and retest.

In the interview, name the bits, say what each costs in quality, and say you would test before shipping. FP8 is another 8-bit option, and its fast maths needs GPUs that support it.

## What are INT8, INT4 and FP8, in plain words?

A number format is a fixed set of bits used to store one number. A model's weights are its learned numbers, which people call parameters, so a 70-billion-parameter model has 70 billion of them. Models are usually loaded with 16 bits per weight, which is 2 bytes. The model runs on a GPU, a graphics chip built for large amounts of arithmetic, so the memory on that chip limits how big a model can be.

Shrinking a model this way is called quantisation. Each weight is rounded to the nearest value in a smaller set of values, which saves memory but loses some detail.

INT8 and INT4 are whole-number formats. Eight bits give 256 possible values, and four bits give 16. FP8 is a floating-point format that also uses 8 bits. A floating-point number is split into a sign, an exponent (the size) and a mantissa (the fine detail), so its steps grow as the value grows.

Think of a bank teller paying out cash. A teller with only $10 notes cannot pay $3 exactly, so small amounts get rounded. A teller who also has coins gets closer. INT8 and INT4 are tellers with evenly spaced notes, and INT4 has fewer note sizes than INT8. FP8 is a teller whose coin size grows with the amount, so small weights stay precise while very large ones get coarser steps. A model's weights are mostly small numbers with a few very large ones, so the teller you choose decides where the rounding error lands.

- **Quantisation:** Rounding each weight to a value that takes fewer bits, to save memory.
- **Bit:** One binary digit. Eight bits make a byte, and each extra bit doubles how many values fit.
- **Floating-point format:** A number stored as a sign, an exponent and a mantissa, so its steps grow with its size.
- **Outlier:** A weight far larger than the rest, which stretches the scale for its whole group.
- **Scale:** The number that turns stored whole numbers back into real weight values.

## How do the three formats differ?

The bit count sets how many values a format can hold. Two to the power of the bit count gives that number: two to the power 8 is 256, and two to the power 4 is 16. More bits means finer steps and less rounding error, but more memory.

FP8 comes in two layouts, and both use 8 bits. The FP8 paper defines them, and they trade precision against range:

> "two encodings - E4M3 (4-bit exponent and 3-bit mantissa) and E5M2 (5-bit exponent and 2-bit mantissa)" (Micikevicius and colleagues, FP8 paper, 2022)
>
> "We also examine FP8 post-training-quantization of language models trained using 16-bit formats that resisted fixed point int8 quantization." (Micikevicius and colleagues, FP8 paper, 2022)

E4M3 has more mantissa bits, so its steps are finer. E5M2 has more exponent bits, so it covers a wider range of sizes. The second line matters in an interview: some language models trained at 16 bits resisted INT8 rounding, and the paper looked at FP8 for exactly those models.

- **INT8: 256 even steps.** One byte per weight, so half the 16-bit memory. Often the first try, with less rounding error than INT4.
- **INT4: 16 even steps.** Half a byte per weight, a quarter of the 16-bit memory. It loses the most detail, so it needs outlier handling and the most testing.
- **FP8: 8-bit floating point.** One byte per weight, with uneven steps: fine near zero and wider for big values. Fast FP8 maths needs newer GPUs, such as NVIDIA's Hopper generation.

*Diagram, Three ways to store the same model: The same 16-bit model can be stored three ways. Each option goes through the same tests, and the smallest one that still passes is the one that ships. INT4 saves the most memory but carries the most rounding error.*
1. The model's weights are stored in each of the three formats.
2. Each build goes to the same test set.
3. The smallest build that passes ships.

Memory is the reason to bother. Hugging Face's Transformers library, a popular toolkit for running open models, gives the same arithmetic for an 8-billion-parameter model: about 16 GB for its weights at 16 bits, about 8 GB at 8 bits, and about 4 to 5 GB at 4 bits. The docs give a range for 4 bits, so plan with a margin above the pure arithmetic.

Memory is only part of the picture. Fewer bits cost some accuracy, and each method trades memory, speed and accuracy differently. Speed depends on the hardware. NVIDIA's Hopper architecture post says the H100 GPU adds FP8 Tensor Cores, which are parts of the chip built for fast matrix maths, to accelerate both AI training and inference.

## Why is INT4 harder than INT8?

Weights are not all alike. Most sit near zero, but a few are much larger. With 256 steps, INT8 can stretch its scale to cover the big ones and still keep most of the small ones. With 16 steps, one large weight stretches the scale so far that the smallest weights all round to zero. AWQ, a method that picks out the few weights that matter most and protects them, is one answer. Its paper reports that protecting just 1% of those weights can greatly reduce quantization error.

```python
# A made-up 8-billion-parameter model: weight memory at three precisions, using the same byte arithmetic.
PARAMS = 8_000_000_000
for name, bits in [("16-bit", 16), ("8-bit", 8), ("4-bit", 4)]:
    print(f"{name} weights: {PARAMS * bits / 8 / 1e9:.0f} GB")

# Round-trip one small weight list through INT8 and INT4. The 2.40 outlier sets the scale for the whole list.
def round_trip(weights, bits):
    top = 2 ** (bits - 1) - 1                     # 127 for INT8, 7 for INT4
    scale = max(abs(w) for w in weights) / top
    ints = [max(-top - 1, min(top, round(w / scale))) for w in weights]
    back = [q * scale for q in ints]
    return ints, max(abs(a - b) for a, b in zip(weights, back))

weights = [0.02, -0.31, 0.11, 2.40, -0.05, 0.24, -0.66, 0.08]
for bits in (8, 4):
    ints, err = round_trip(weights, bits)
    print(f"INT{bits} values: {ints}")
    print(f"INT{bits} largest error: {err:.4f}")
```

Output:

```text
16-bit weights: 16 GB
8-bit weights: 8 GB
4-bit weights: 4 GB
INT8 values: [1, -16, 6, 127, -3, 13, -35, 4]
INT8 largest error: 0.0076
INT4 values: [0, -1, 0, 7, 0, 1, -2, 0]
INT4 largest error: 0.1100
```

Read the output. In this made-up list, INT8 keeps every weight within 0.0076 of its true value. INT4 rounds the 0.11 weight to zero, so its largest error is 0.11. One outlier caused that, and it is the reason INT4 needs outlier-aware methods and the most testing.

> **Tip:** Asked whether 8-bit means only the weights, or the activations too (the numbers passed between layers as the model works), say which one. The names carry the answer: W8A16 is 8-bit weights with 16-bit activations, and W8A8 is 8-bit for both.

vLLM, an open-source server for running models, documents what happens when the kernel that is needed is missing. A kernel is the GPU code that runs one operation, such as a matrix multiply. The fallback keeps the 8-bit weights but runs the activations in 16 bits:

> "vLLM by default falls back to a weight-only kernel (Marlin, Humming, the CPU W8A16 kernels) that keeps the quantized weights but runs activations in 16-bit, so W8A8 runs as W8A16 and W4A4 as W4A16." (vLLM documentation)

vLLM also says this fallback is not the scheme the checkpoint was calibrated and benchmarked with, and it logs a warning. Check the server log, and test the answers again before you rely on it.

### How would you pick one for a real server?

Take a bank's internal HR policy assistant. It has to run on the bank's own servers. The setup here is made up: a 70-billion-parameter model on two GPUs with 48 GB each, so 96 GB of GPU memory in total. The answers must match the HR team's approved wording. Each chat also needs a cache, the memory that holds the text the model has already read.

*Diagram, Will the model fit on the GPUs?: The weights and the cache share the GPU memory. At 8 bits, the made-up 70-billion-parameter model's weights take about 70 GB, which leaves about 26 GB for the cache. If memory runs short, INT4 is the next try.*
1. The weights take about 70 GB at 8 bits.
2. The cache and working space come on top of them.
3. Both are added and compared with the GPU memory.
4. If it fits, INT8 is the first choice to test.
5. If it does not fit, try INT4 and test it again.

1. **Do the sum at 16 bits:** 70 billion weights at 2 bytes each is about 140 GB. That is more than the 96 GB of GPU memory, so 16 bits is out.
2. **Try INT8 first:** About 70 GB of weights leaves about 26 GB for the cache and working space. Long policy documents make the cache grow, so watch it.
3. **Test on real questions:** Run a few hundred past HR questions through the INT8 build, and compare the answers with the approved wording. If the answers fall short at the same size, FP8 is the next try, since it keeps the 8-bit size. Its fast maths needs newer GPUs. Time the answers on the bank's own GPUs too.
4. **If memory is short, try INT4:** INT4 halves the weights again, to about 35 GB, but it carries the most rounding error. Use a method built for 4-bit, such as AWQ, which protects the most important weights, and retest.

Smaller does not automatically mean faster. Speed depends on whether the GPU has code for that format, so measure it on the hardware you will really use.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Each format is a bit count: INT8 has 256 steps, INT4 has 16, FP8 is a float.
- [ ] Memory halves at each step down from 16 bits: 2 bytes, 1 byte, then half a byte.
- [ ] INT4 loses the most, and outliers are the reason.
- [ ] FP8 maths is fast only on GPUs with FP8 support, such as NVIDIA Hopper.
- [ ] Say which part is quantised: the weights only, or the activations too.
- [ ] Test on your own tasks, and measure speed on your own GPU.

**Common traps**

- Trap: "FP8 is just 8-bit integers, so it is the same as INT8." Better: FP8 is a floating-point format with uneven steps, so it covers a wide range of sizes. Its speed depends on GPU support.
- Trap: "4-bit is always the best choice, because it is the smallest." Better: Smallest is not automatically best. INT4 carries the most rounding error, so it needs the most testing.
- Trap: "Smaller always runs faster." Better: Speed depends on the GPU having code for that format. Measure it on the hardware you will use.

## Can you spot the wrong claim?

**Spot the wrong claim:** A release note for a new build has one wrong claim. Which one?

A. The INT8 build needs about half the weight memory of the 16-bit build.
B. The INT4 build needs about a quarter of the 16-bit weight memory, so it can ship without a quality test.
C. The INT4 build still needs its own test set, because 16 steps cost some accuracy.
D. FP8 maths is fast only on GPUs with FP8 support, so we check the GPU list before we promise speed.

**Answer:** B. Fewer bits always risk quality, so the INT4 build needs tests before it ships. The other three are correct: 8-bit halves the weights, 4-bit quarters them, and FP8 speed depends on the GPU.

**Quick check:** A bank's policy assistant runs a 70-billion-parameter model on servers with 96 GB of GPU memory. At 16 bits the weights do not fit. What is the sensible next step?

A. Store the weights in INT8, then test the answers against the approved wording
B. Store the weights in INT4 and ship it, since it is the smallest
C. Lower the temperature, which shrinks the weights
D. Make the system prompt shorter, which shrinks the weights

**Answer:** A. INT8 halves the weights to about 70 GB, which fits with room for the cache, and the tests catch quality loss. Temperature and the prompt do not change the size of the weights, and shipping INT4 untested skips the test step.

## Can you answer these from memory?

**Flash cards**

- **INT8 vs INT4?** 256 whole-number steps vs 16. INT4 saves more memory and loses more quality.
- **What is FP8?** An 8-bit floating-point format. Its steps grow with the size of the value.
- **E4M3 vs E5M2?** E4M3 has finer steps. E5M2 covers a wider range. Both use 8 bits.
- **Why is INT4 hard?** Outliers stretch the scale, so the smallest weights round to zero.
- **Memory at 16, 8 and 4 bits?** Each step halves it: 2 bytes, 1 byte, then half a byte per weight.
- **Does smaller mean faster?** Not always. Speed needs GPU code that supports that format.

## Likely follow-up questions

- Q311 What is quantization? https://designervenkat.online/interview/ai/what-is-quantization
- Q313 GPTQ, AWQ and GGUF in one line each? (full answer coming)
- Q320 Serving engines (vLLM, SGLang, TensorRT-LLM, llama.cpp)? (full answer coming)
- Q327 GPU basics: why does memory bandwidth limit decoding? (full answer coming)
- Q328 Does a 70B model fit on one 80GB GPU? (full answer coming)
