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<'de> Deserialize<'de> for ScaleLayout
impl<'de> Deserialize<'de> for ScaleLayout
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ScaleLayout, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ScaleLayout, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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.
Source§impl Hash for ScaleLayout
impl Hash for ScaleLayout
Source§impl PartialEq for ScaleLayout
impl PartialEq for ScaleLayout
Source§impl Serialize for ScaleLayout
impl Serialize for ScaleLayout
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ScaleLayout
Auto Trait Implementations§
impl Freeze for ScaleLayout
impl RefUnwindSafe for ScaleLayout
impl Send for ScaleLayout
impl Sync for ScaleLayout
impl Unpin for ScaleLayout
impl UnsafeUnpin for ScaleLayout
impl UnwindSafe for ScaleLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more