IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

nvfp4_kv_quantize_x8

def nvfp4_kv_quantize_x8(x: SIMD[.float32, 8], scale: Float32) -> UInt32

Quantizes eight values that share one scale to packed FP4 E2M1.

Each value is divided by scale (true division), then rounded by the hardware convert, which rounds half to even and saturates at 6. A magnitude that rounds to zero is stored as +0, never -0.

Constraints:

Requires NVIDIA GPU with SM100 or newer.

Args:

  • ​x (SIMD[.float32, 8]): Eight values, element 0 in the lowest nibble of the result.
  • ​scale (Float32): The group scale from nvfp4_kv_group_scale.

Returns:

UInt32: The eight E2M1 codes packed into one word.

Was this page helpful?