New Tool Radar

AI Concepts

How to Keep Sensitive Layers at Higher Precision When Quantizing the Rest of a Model

List the layers that break when quantized, keep them at full precision, quantize the rest, and check the mixed model on your test set.

Schematic with three steps: Find the sensitive layers first; Keep those layers at higher precision; Measure the mixed model on the test.

Not every layer survives quantization equally. Some layers, such as the output head or the embedding layer, carry errors that the rest of the model cannot correct, and quantizing them costs far more quality than quantizing an ordinary layer. Both GPTQ and bitsandbytes let you leave layers out: GPTQ has a modules_in_block_to_quantize list, where linear layers not listed stay unquantized, and bitsandbytes has llm_int8_skip_modules, used for example to skip lm_head modules that cause instability. Mixed precision is the fix: quantize the robust layers and spare the sensitive ones.

What you need

  • The model layer list, with names
  • A test set that shows quality loss clearly
  • The quantization method skip or include option for your library

Step 1: Find the sensitive layers first

Quantize the whole model once and measure quality, then quantize with one layer group spared at a time, or check the library documentation for layers known to be sensitive, such as lm_head. The layers whose sparing recovers the most quality are the sensitive ones.

Step 2: Keep those layers at higher precision

List the sensitive modules in the skip or include option, for example llm_int8_skip_modules for bitsandbytes or modules_in_block_to_quantize for GPTQ, so they stay at full precision while the rest is quantized.

Step 3: Measure the mixed model on the test set

Run the mixed-precision model on the same test set and compare it with the fully quantized model and the full-precision model. Keep the mix only when it recovers quality without blowing the memory budget.

Worked example: synthetic mixed precision test

The table below is a synthetic example. It shows the expected result of sparing sensitive layers; no model was quantized.

Setup Quality loss Memory saved
All layers 4-bit Large loss Most
lm_head spared Small loss Most
Embeddings spared Medium loss Most
All layers full precision No loss None

Expected result (UNTESTED). sparing the output head recovers most of the quality while keeping most of the memory saving. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Every spared layer costs memory, so sparing too many layers defeats the purpose of quantizing.
  • Which layers are sensitive depends on the model and the task, so test your own model.
  • Some methods can only load a pre-quantized checkpoint, so the skip list must be set when the checkpoint is made.
  • A skipped module still counts against the memory budget at full precision.

Sources

See all