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))
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
uint8weight data of shape[.., rows, cols // 2]. - weight_scale (Tensor) – Per-block
float8_e8m0fnuscales 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.
- weight (Tensor) – Packed
block_size
Quantization block shape as (rows, cols).
local_shards
property local_shards: tuple[MXFP4Tensor, ...]
Per-device shards, pairing each weight shard with its scales.
mesh
property mesh: DeviceMesh
Device mesh of the packed weight tensor.
scale_dtype
Dtype of weight_scale.
shard()
shard(axis, mesh)
Co-shard weight/weight_scale along axis onto mesh.
-
Parameters:
-
- axis (int)
- mesh (DeviceMesh)
-
Return type:
storage_dtype
Dtype of the stored weight.
to()
to(target)
Returns a copy with weight and weight_scale on target.
-
Parameters:
-
target (Device | DeviceMesh | DeviceMapping)
-
Return type:
values_per_byte
Logical values held per stored weight element.
weight_scale
weight_scale: Tensor
zeros()
classmethod zeros(shape, *, block_size=(1, 32))
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.