Skip to main content

ScaleLayout

Enum ScaleLayout 

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

Fields

§block: u32
§

Nvfp4

NVFP4: one FP8 E4M3 scale per group (16) elements along K, plus an optional per-tensor f32 global. Scale tensor is DType::U8.

Fields

§group: u32

Implementations§

Source§

impl ScaleLayout

Source

pub const fn mx() -> Self

OCP microscaling default (32-element blocks).

Source

pub fn nvfp4() -> Self

NVFP4 default (16-element groups).

Source

pub const fn scale_dtype(self) -> DType

Element dtype of the scale tensor for this layout.

Source

pub const fn block(self) -> u32

Number of consecutive elements sharing one scale (1 for per-tensor).

Source

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

Source§

fn clone(&self) -> ScaleLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ScaleLayout

Source§

impl Debug for ScaleLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ScaleLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ScaleLayout

Source§

impl FromStr for ScaleLayout

Source§

fn from_str(s: &str) -> Result<Self, Self::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.

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

impl Hash for ScaleLayout

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ScaleLayout

Source§

fn eq(&self, other: &ScaleLayout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ScaleLayout

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.