Tutorials

The paper studies quantization of activations and floating-point values.

The article explains why activation quantization is difficult and how SmoothQuant and dynamic scaling help 8-bit transformer inference.

The paper studies quantization of activations and floating-point values.

Key Takeaways

  • Activation quantization is harder than weight quantization because activations are created at runtime, vary across tokens and layers, and may contain persistent outliers.
  • Static quantizers choose scales during calibration, while dynamic quantizers inspect tensors at runtime; dynamic per-token scaling is common in transformers but adds overhead.
  • SmoothQuant enables INT8 W8A8 by shifting activation outlier pressure into weights through an exact rescaling of linear layers, making activations easier to quantize.
  • vLLM LLM Compressor can build reusable INT8 W8A8 checkpoints, but compatibility depends on model format, vLLM version, and GPU; W8A8 should be benchmarked against W4A16 or BF16.
  • FP8 is a scaled floating-point quantization format with nonuniform value spacing, not merely a shorter integer or direct FP32 cast.

For teams deploying transformer inference, activation quantization is the harder half of the problem, and vLLM's LLM Compressor gives two reusable paths for it: INT8 W8A8 checkpoints smoothed by SmoothQuant and FP8 weight-and-activation checkpoints. The central difference is timing. Weights are fixed after training and can be quantized once before deployment. Activations are created during inference, depend on the input token, sequence position, and previous layers, and can change range from request to request. A few channels may also hold persistent outliers.

The paper studies quantization of activations and floating-point values.

Why Activation Quantization Is Harder Than Weight Quantization

Fixed weights have a simple quantization recipe: scale, zero point, and granularity. Activations use the same recipe, but the parameters must track values that do not exist until inference starts.

A static activation quantizer decides its scales during calibration. It avoids runtime cost, but it can clip an input whose range was not represented in the calibration set. A dynamic activation quantizer inspects the tensor at runtime. It follows each input more closely, but reduction and scaling become part of the inference path.

For a tensor shaped [batch, sequence, hidden], each vector along the last axis is one token. Reducing along that axis creates [batch, sequence, 1], one scale for all hidden features of that token. Since a linear layer reads these token vectors as matrix rows, the method is also called per-row quantization.

Dynamic per-token scaling is common in transformer activations because it tracks range shifts from token to token better than a single scale for the whole tensor. When signed symmetric INT8 is used, the zero point stays at zero rather than being recomputed for each token, which keeps the quantization and matrix-multiply math simpler. The cost is that every new activation tensor triggers an absolute-maximum reduction and scale calculation.

Outliers make the trade-off sharper. If the quantizer covers the full range, normal values get coarse steps. If it clips the range, normal values keep resolution but the outlier is damaged. The right choice depends on how the next weights consume that vector.

Ranges also change by layer and token. Static quantization predicts runtime ranges from calibration data and chooses scale and zero point in advance. Dynamic quantization skips fixed calibration ranges but pays runtime measurement overhead.

SmoothQuant Moves Outlier Difficulty Into Weights

W8A8 refers to INT8 weights and INT8 activations in matrix multiplication. On hardware with efficient integer matrix kernels, it can cut memory traffic and raise arithmetic throughput. Some operations, such as biases, normalization, residuals, or accumulators, may stay at higher precision. The name only describes bit widths; a separate workflow could target FP8 instead.

SmoothQuant shifts part of the activation quantization burden into weights. In a linear layer y = x W^T, choose a positive scale vector s over input channels, then rewrite the product as:

y = (x diag(s)^-1)(W diag(s))^T.

Before quantization, the rewrite is exact. Channels with large activation values are divided by larger scales, smoothing the activation range; the matching weight columns are multiplied by those same scales. Static weights usually handle that uneven range better because they can be quantized per channel.

This is not the same as AWQ. AWQ uses calibration activations to protect important weights in a weight-only format such as W4A16, while runtime activations remain in higher precision. SmoothQuant prepares both sides for W8A8: the stored weights are transformed, and the runtime activations become easier to quantize to INT8.

The example code checks this exact rescaling. That is not a full implementation: real SmoothQuant derives smooth_scale from weight magnitudes and calibration activations, folds scales into neighboring operations where possible, and quantizes the transformed tensors.

Building an INT8 W8A8 Checkpoint for vLLM

LLM Compressor, a library in the vLLM project, can create a reusable INT8 weight-and-activation checkpoint. The workflow is:

  1. Load the model using transformers.
  2. Apply SmoothQuant and INT8 W8A8 quantization through LLM Compressor.
  3. Save the result for vLLM. The checkpoint stores per-channel INT8 weights plus instructions for quantizing activations dynamically at inference time. It does not store activations, because they are generated and quantized token by token.
  4. Load the local checkpoint in vLLM. The W8A8 kernels can run without an extra quantization argument.
  5. Run a short generation to verify that the checkpoint loads and executes. A small model may answer poorly, so compare quantized output quality with the original model on representative evaluation prompts.

Compatibility is not automatic: the checkpoint format, model architecture, vLLM version, and GPU must all support the same W8A8 scheme. Current vLLM INT8 kernels target NVIDIA GPUs from Turing through Hopper. For Blackwell, use a supported FP8 path.

Do not assume W8A8 beats W4A16 or BF16. W8A8 can make strong use of integer matrix hardware, especially in prefill and larger batches. W4A16 reads fewer weight bytes and may fit small-batch decode better. Benchmark both phases.

FP8 Uses Floating-Point Spacing, Not Just Shorter Integers

FP8 quantization is not just an FP32 value with fewer bits. In a scaled FP8 scheme, divide the tensor by a scale, then round each result to a value that FP8 can represent:

q = cast_FP8(x/s); x-hat = s * cast_FP16_or_FP32(q).

The scale must be stored with the FP8 tensor or block so the runtime can decode it. FP8 is therefore a quantized format, not a plain cast to smaller storage.

Compared with affine INT8, FP8 values are not evenly spaced across a quantization group. The exponent creates nonuniform steps: small values near zero are represented with finer resolution, while larger values use wider steps. That covers more magnitudes, but rounding and overflow remain possible. Scaling moves the source values into the most useful region of the FP8 range, and it usually does not need an INT8-style zero-point shift.

FP8 is a family, not one layout. E4M3 uses four exponent bits and three significand bits; E5M2 uses five exponent bits and two significand bits. E4M3 favors precision, while E5M2 favors range. The available choice depends on hardware and inference engine. The label also does not say whether scales are per tensor or per block, or how they are computed and stored. FP4 works similarly but needs more aggressive scaling and suitable hardware.

LLM Compressor can convert a Hugging Face checkpoint into an FP8 checkpoint. Its FP8_DYNAMIC scheme rounds fixed weights to the nearest FP8 value and derives weight scales directly from the weight tensors. Activations do not exist at conversion time, so vLLM measures them later and computes per-token scales during inference. Because both operations can work without sample inputs, the basic workflow does not require calibration data.

The resulting compressed-tensors checkpoint contains FP8 weights and scales. Activations are still not stored; vLLM computes their scales and casts them to FP8 on each forward pass.

If activation outliers cause too much error, SmoothQuant can be added, making the conversion calibration-based. The complete script uses the same model and calibration dataset as the INT8 example and writes a separate FP8 checkpoint.

Load either FP8 checkpoint locally and run inference. The generated text only proves that the checkpoint executes; compare accuracy and throughput with the unquantized model before selecting a deployment format.

Current vLLM documentation lists NVIDIA Ada Lovelace, Hopper, and Blackwell GPUs, plus some AMD accelerators, for accelerated FP8 weight-and-activation inference. The exact route depends on GPU, FP8 layout, and quantization scheme, so check the current compatibility table for the target hardware.

Activation quantization can help matrix-heavy prefill, but runtime scaling may add cost in small-batch decode. Combining weight and activation quantization can shift the bottleneck to another operation, so profile the whole request instead of chasing isolated speedups.

Common Mistakes

  • Assuming W8A8 is automatically faster. Test prefill and decode; W4A16 or BF16 may win in small-batch decode.
  • Ignoring activation outliers. Use SmoothQuant when outliers create too much error, especially for FP8.
  • Looking for activations in the saved checkpoint. They are not stored; the runtime quantizes them per token.
  • Choosing a GPU outside the supported path. INT8 W8A8 targets Turing through Hopper; Blackwell should use a supported FP8 path; FP8 paths vary by GPU and layout.
  • Judging quality from one generation. Use representative evaluation prompts and compare with the original model.

Further Reading

  • PyTorch TorchAO documentation: Quantized Inference. This guide lists current per-token, per-row, per-tensor, and block-scaled activation configurations.
  • Guangxuan Xiao et al. (2022): SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models. This paper introduces mathematically equivalent smoothing for W8A8 inference.
  • vLLM documentation: INT8 W8A8 with LLM Compressor and vLLM. This guide covers calibration, conversion, compressed checkpoint saving, and inference.
  • Paulius Micikevicius et al. (2022): FP8 Formats for Deep Learning. This paper describes FP8 formats and scaling conventions for deep learning.
  • vLLM documentation: FP8 weight-and-activation quantization with LLM Compressor and vLLM. This guide covers dynamic FP8 conversion, checkpoint loading, and supported hardware.

Meta description: Learn how vLLM LLM Compressor turns Hugging Face models into INT8 W8A8 and FP8 checkpoints, manages activation outliers, and checks GPU support.

Tags: activation quantization, vLLM, LLM Compressor, SmoothQuant, FP8

Featured image: abstract friendly illustration of quantized matrix blocks and activation vectors, no real people, no logos, no text.

Comments (0)

  1. No comments yet. Be the first to share what worked for you.

Leave a comment

Comments are reviewed before they appear. Your email address is not published.