pub enum ScaleLayout {
PerTensor,
BlockMxE8M0 {
block: u32,
},
Nvfp4 {
group: u32,
},
}Expand description
How scale factors are laid out for an crate::op::Op::ScaledMatMul
operand. The reconstructed value of element i is
decode(code[i]) * scale(block_of(i)).
Variants§
PerTensor
One f32 amax scale for the whole operand (classic per-tensor FP8 GEMM).
BlockMxE8M0
OCP microscaling: one power-of-two E8M0 scale per block
consecutive elements along K (MXFP8 / MXFP6 / MXFP4). Scale tensor
is DType::U8 (E8M0 bytes).
Nvfp4
NVFP4: one FP8 E4M3 scale per group (16) elements along K, plus
an optional per-tensor f32 global. Scale tensor is DType::U8.
Implementations§
Source§impl ScaleLayout
impl ScaleLayout
Sourcepub const fn mx() -> ScaleLayout
pub const fn mx() -> ScaleLayout
OCP microscaling default (32-element blocks).
Sourcepub fn nvfp4() -> ScaleLayout
pub fn nvfp4() -> ScaleLayout
NVFP4 default (16-element groups).
Sourcepub const fn scale_dtype(self) -> DType
pub const fn scale_dtype(self) -> DType
Element dtype of the scale tensor for this layout.
Sourcepub const fn block(self) -> u32
pub const fn block(self) -> u32
Number of consecutive elements sharing one scale (1 for per-tensor).
Sourcepub const fn mode_block(self) -> (u32, u32)
pub const fn mode_block(self) -> (u32, u32)
(scale_mode, block) for GPU kernels (scaled_lowp_general.cu):
per-tensor=0, block-E8M0=1, NVFP4-E4M3=2.
Trait Implementations§
Source§impl Clone for ScaleLayout
impl Clone for ScaleLayout
Source§fn clone(&self) -> ScaleLayout
fn clone(&self) -> ScaleLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ScaleLayout
Source§impl Debug for ScaleLayout
impl Debug for ScaleLayout
Source§impl Display for ScaleLayout
impl Display for ScaleLayout
impl Eq for ScaleLayout
Source§impl FromStr for ScaleLayout
impl FromStr for ScaleLayout
Source§fn from_str(s: &str) -> Result<ScaleLayout, <ScaleLayout as FromStr>::Err>
fn from_str(s: &str) -> Result<ScaleLayout, <ScaleLayout as FromStr>::Err>
Parse a scale-layout name: "per_tensor", "mx" (32-element E8M0
microscaling), "nvfp4" (16-element E4M3), or an explicit block size
"mx/<block>" / "nvfp4/<group>". Mirrors Display round-trip.