pub struct Nf4Weight {
pub w_packed: Tensor,
pub absmax: Tensor,
pub n: usize,
pub k: usize,
pub block_size: usize,
}Expand description
A bitsandbytes-style NF4-quantized weight, materialized as the two
Tensor inputs that fuel_graph::NodeHandle::nf4_matmul
expects, plus the cached (n, k, block_size) geometry for the
matmul builder.
The two inputs are kept as separate Tensor fields rather
than bundled into a single tensor — that matches the fused op’s
3-input signature exactly. Self::matmul is the convenience
builder for the common case where the caller has an activations: Tensor and just wants the linear-layer output.
Fields§
§w_packed: TensorPacked weight bytes, shape [N, K/2] U8.
absmax: TensorPer-block absmax scales, shape [N, K/block_size] F32.
n: usizeOutput features (rows of the weight matrix).
k: usizeInput features (the K in (M, K) @ (K, N) → (M, N)).
block_size: usizeQuantization block size (typically 64 in bitsandbytes).
Implementations§
Source§impl Nf4Weight
impl Nf4Weight
Sourcepub fn matmul(&self, activations: &Tensor) -> Tensor
pub fn matmul(&self, activations: &Tensor) -> Tensor
Convenience: run activations @ dequant(weight) via the
fused fuel_graph::NodeHandle::nf4_matmul op. activations
must live on the same graph as self.w_packed and self.absmax;
the caller threads this by building activations from
self.w_packed.graph_tensor() (or any other tensor on the
same graph).
Output dtype matches activations’ dtype (F32 / F16 / BF16
— see fuel_graph::NodeHandle::nf4_matmul for the full
contract).
Auto Trait Implementations§
impl Freeze for Nf4Weight
impl RefUnwindSafe for Nf4Weight
impl Send for Nf4Weight
impl Sync for Nf4Weight
impl Unpin for Nf4Weight
impl UnsafeUnpin for Nf4Weight
impl UnwindSafe for Nf4Weight
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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