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).

Python class

MXFP4Tensor

MXFP4Tensor​

class max.nn.common_layers.quant_tensor.MXFP4Tensor(*, weight, weight_scale, block_size=(1, 32))

source

Bases: _QuantizedWeight

MXFP4 (OCP microscaling) block-scaled quantized tensor.

Two e2m1 codes packed per uint8, with one power-of-two float8_e8m0fnu scale per 32-element block along K. Same two leaves as MXFP8Tensor; only the stored dtype and packing differ.

Parameters:

  • weight (Tensor) – Packed uint8 weight data of shape [.., rows, cols // 2].
  • weight_scale (Tensor) – Per-block float8_e8m0fnu scales of shape [.., ceil(rows / block_m), ceil(cols / block_k)]. The AMD matmul consumes this rank-2 layout directly.
  • block_size (tuple[int, int]) – Per-block size as (block_m, block_k); (1, 32) for MXFP4.

block_size​

property block_size: tuple[int, int]

source

Quantization block shape as (rows, cols).

local_shards​

property local_shards: tuple[MXFP4Tensor, ...]

source

Per-device shards, pairing each weight shard with its scales.

mesh​

property mesh: DeviceMesh

source

Device mesh of the packed weight tensor.

scale_dtype​

scale_dtype: ClassVar[DType] = 73

source

Dtype of weight_scale.

shard()​

shard(axis, mesh)

source

Co-shard weight/weight_scale along axis onto mesh.

Parameters:

Return type:

MXFP4Tensor

storage_dtype​

storage_dtype: ClassVar[DType] = 134

source

Dtype of the stored weight.

to()​

to(target)

source

Returns a copy with weight and weight_scale on target.

Parameters:

target (Device | DeviceMesh | DeviceMapping)

Return type:

MXFP4Tensor

values_per_byte​

values_per_byte: ClassVar[int] = 2

source

Logical values held per stored weight element.

weight_scale​

weight_scale: Tensor

source

zeros()​

classmethod zeros(shape, *, block_size=(1, 32))

source

Builds a zero-filled MXFP4Tensor of logical [.., rows, cols].

shape is unpacked; the packed weight leaf has half the trailing dimension. Leading dimensions are kept on both leaves.

Parameters:

Return type:

MXFP4Tensor