pub struct AwqHostWeight {
pub weight: Arc<[u32]>,
pub zeros: Arc<[u32]>,
pub scales: Arc<[f16]>,
pub zeros_w: usize,
pub oc: usize,
pub ic: usize,
pub group_size: usize,
}Expand description
An AWQ linear weight as host buffers in the kernel layout, bound to no
graph: what a model’s weight set stores (WeightStorage::Awq) so the same
weights can be placed on any graph or device. The matmul builds its
constants on the activations’ graph.
Fields§
§weight: Arc<[u32]>[OC, IC/8] U32, sequential nibble order.
zeros: Arc<[u32]>[OC, zeros_w] U32.
scales: Arc<[f16]>[OC, 8 * zeros_w] F16.
zeros_w: usizeWords per zeros row.
oc: usizeOutput features.
ic: usizeInput features.
group_size: usizeQuantization group size (64 or 128).
Implementations§
Source§impl AwqHostWeight
impl AwqHostWeight
Sourcepub fn from_hf_buffers(
qweight: &[u32],
qzeros: &[u32],
scales: &[f16],
ic: usize,
oc: usize,
group_size: usize,
) -> Result<Self>
pub fn from_hf_buffers( qweight: &[u32], qzeros: &[u32], scales: &[f16], ic: usize, oc: usize, group_size: usize, ) -> Result<Self>
Repack HF-layout buffers (qweight [IC, OC/8], qzeros [IC/g, OC/8],
scales [IC/g, OC]) into the kernel layout.
Sourcepub fn load<'a>(
get: impl Fn(&str) -> Result<TensorView<'a>>,
prefix: &str,
ic: usize,
oc: usize,
group_size: usize,
) -> Result<Self>
pub fn load<'a>( get: impl Fn(&str) -> Result<TensorView<'a>>, prefix: &str, ic: usize, oc: usize, group_size: usize, ) -> Result<Self>
Read one WQLinear_GEMM layer ({prefix}.qweight/.qzeros/.scales)
through get, validating every dtype and shape against the geometry.
Sourcepub fn matmul(&self, activations: &Tensor, split_k_iters: i32) -> Result<Tensor>
pub fn matmul(&self, activations: &Tensor, split_k_iters: i32) -> Result<Tensor>
activations @ dequant(weight)ᵀ via the fused AWQ_MATMUL op, with the
weight constants built on activations’ graph. Output [..., M, OC] in
the activations’ dtype. split_k_iters must be positive (see
AwqWeight::matmul).
Trait Implementations§
Source§impl Clone for AwqHostWeight
impl Clone for AwqHostWeight
Auto Trait Implementations§
impl Freeze for AwqHostWeight
impl RefUnwindSafe for AwqHostWeight
impl Send for AwqHostWeight
impl Sync for AwqHostWeight
impl Unpin for AwqHostWeight
impl UnsafeUnpin for AwqHostWeight
impl UnwindSafe for AwqHostWeight
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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