pub struct BitNetConfig {
pub group_size: usize,
pub activation_bits: u8,
pub per_token_activation: bool,
pub use_rms_norm: bool,
pub eps: f32,
pub enable_ste: bool,
}Expand description
Configuration for BitNet b1.58 quantization.
BitNet uses:
- Ternary weights: {-1, 0, +1} via AbsMean quantization
- INT8 activations: Per-token AbsMax scaling
§Reference
“The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits” https://arxiv.org/abs/2402.17764
Fields§
§group_size: usizeGroup size for weight quantization. Weights are quantized in groups, each with its own scale. Typical values: 64, 128, 256.
activation_bits: u8Number of bits for activation quantization. BitNet b1.58 uses 8 bits (INT8).
per_token_activation: boolWhether to use per-token activation scaling. If true, each token gets its own scale factor. If false, uses per-tensor scaling.
use_rms_norm: boolWhether to apply RMS normalization before quantization.
eps: f32Epsilon for numerical stability in normalization.
enable_ste: boolWhether to enable Straight-Through Estimator for training.
Implementations§
Source§impl BitNetConfig
impl BitNetConfig
Sourcepub fn inference() -> Self
pub fn inference() -> Self
Create configuration optimized for inference.
Disables training-specific features like STE.
Sourcepub fn training() -> Self
pub fn training() -> Self
Create configuration for training.
Enables STE for gradient estimation through quantization.
Sourcepub const fn with_group_size(self, group_size: usize) -> Self
pub const fn with_group_size(self, group_size: usize) -> Self
Set the group size for weight quantization.
Sourcepub const fn with_activation_bits(self, bits: u8) -> Self
pub const fn with_activation_bits(self, bits: u8) -> Self
Set the activation bit width.
Sourcepub const fn with_per_token_activation(self, enabled: bool) -> Self
pub const fn with_per_token_activation(self, enabled: bool) -> Self
Enable or disable per-token activation scaling.
Sourcepub const fn with_rms_norm(self, enabled: bool) -> Self
pub const fn with_rms_norm(self, enabled: bool) -> Self
Enable or disable RMS normalization.
Trait Implementations§
Source§impl Clone for BitNetConfig
impl Clone for BitNetConfig
Source§fn clone(&self) -> BitNetConfig
fn clone(&self) -> BitNetConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BitNetConfig
impl Debug for BitNetConfig
Source§impl Default for BitNetConfig
impl Default for BitNetConfig
Source§impl<'de> Deserialize<'de> for BitNetConfig
impl<'de> Deserialize<'de> for BitNetConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BitNetConfig
impl RefUnwindSafe for BitNetConfig
impl Send for BitNetConfig
impl Sync for BitNetConfig
impl Unpin for BitNetConfig
impl UnsafeUnpin for BitNetConfig
impl UnwindSafe for BitNetConfig
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>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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