Skip to content

FP8 block storage with BF16 computation ​

Use FP8 block storage to keep E4M3 checkpoint weights and FP32 block scales while computing with BF16 activations and general matrix multiplication (GEMM) operations.

Select the quantization mode ​

To use this format, select --quantization w8a16_fp8_block --dtype bfloat16 explicitly for an E4M3 checkpoint with FP32 128 × 128 block scales. Checkpoint metadata can use quant_method: fp8 or quant_method: w8a16_fp8_block; ordinary fp8 execution continues to use its existing activation policy.

If checkpoint quantization metadata is absent or null, TokenSpeed leaves the model unquantized. Configuration normalization and wrapped text-config extraction preserve that meaning. A model provider can explicitly declare the optional field as None.

Checkpoint tensor layout ​

For a weight with shape [N, K], each quantized matrix has the following tensors:

TensorData typeShape
.weightfloat8_e4m3fn[N, K]
.weight_scale_invfloat32[ceil(N / 128), ceil(K / 128)]

Expert storage adds the expert dimension. The modules_to_not_convert and ignored_layers fields retain mixed BF16 layers.

Weight decoding and GEMM behavior ​

The loader preserves codes and scales. Immediately before GEMM, the decoder multiplies the codes and scales in FP32 and rounds once to BF16. Activations and the selected GEMM remain BF16. TokenSpeed keeps neither a persistent decoded weight nor a regenerated encoding.

The linear method stores quantized weights, so fast paths that require an ordinary unquantized BF16 weight reject the linear method.

Execution constraints ​

The following constraints apply to kernel planning and selection:

  • Merged projections and tensor-parallel shards require block-aligned boundaries.
  • The numerical GEMM policy remains explicit through the existing kernel planner.
  • The rl-bitwise envelope requires a batch-invariant BF16 GEMM implementation. When none is registered for the device and shape, layer construction fails.
  • Mixture-of-experts (MoE) execution requires a registered kernel advertising w8a16_fp8_block. Unsupported backends fail selection.

Online updates and validation ​

Complete online updates must include both codes and scales. If you maintain a model that uses this format, validate loaded operands after a complete update and preserve canonical storage through memory release and resume.

The runtime tests cover dense reloads and numerical-policy admission. The shared kernel tests cover irregular shapes, expert batches beyond int32 element offsets, and graph replay with changed codes and scales on supported GPU vendors. Model providers own their numerical and lifecycle acceptance tests.

TokenSpeed documentation