flashinfer.quantization.encode_csf_scales

flashinfer.quantization.encode_csf_scales(scales: Tensor) → CsfScales

Compress block-scale matrices into CSF slabs.

A row’s base is the lowest start among the 16-value windows that cover the most of its bytes, the rule of CSF checkpoints, so encoding a checkpoint’s decoded scales gives back its nvfp4_csf_fixed and nvfp4_csf_exceptions streams.

Parameters:

scales (torch.Tensor) – Contiguous CUDA [rows, cols] or [num_matrices, rows, cols] block scales in a one-byte dtype such as float8_e4m3fn, with rows a multiple of 16, cols even and rows * cols <= 2**24.

Returns:

The compressed scales. Sizing the exceptions reads their count back to the host, so encoding cannot run under CUDA graph capture.

Return type:

CsfScales