pub struct KdTrainer { /* private fields */ }Expand description
Quantization-Aware Knowledge Distillation trainer matching KDTrainer in utils/kd_utils.py.
Implementations§
Source§impl KdTrainer
impl KdTrainer
Sourcepub fn new(student: &mut CausalLm, config: TrainingConfig) -> Result<Self>
pub fn new(student: &mut CausalLm, config: TrainingConfig) -> Result<Self>
Prepare student for training (freezing exclude_from_grad) and initialize AdamW.
§Errors
Returns an error if no trainable parameters exist or optimizer creation fails.
Sourcepub fn parameter_stats(&self) -> ParameterStats
pub fn parameter_stats(&self) -> ParameterStats
Borrow parameter statistics logged at trainer initialization.
Sourcepub fn train(
&mut self,
student: &CausalLm,
teacher: &CausalLm,
token_blocks: &[Vec<u32>],
device: &Device,
) -> Result<TrainingSummary>
pub fn train( &mut self, student: &CausalLm, teacher: &CausalLm, token_blocks: &[Vec<u32>], device: &Device, ) -> Result<TrainingSummary>
Run knowledge distillation training on token_blocks (&[Vec<u32>]) against frozen teacher.
§Errors
Returns an error on invalid dataset/batch sizes, forward/backward failures, or I/O logging errors.
Sourcepub fn save_artifacts(
student: &CausalLm,
lb_cfg: &LittleBitConfig,
base_model_id: Option<&str>,
save_dir: &Path,
tokenizer_src: Option<&Path>,
) -> Result<()>
pub fn save_artifacts( student: &CausalLm, lb_cfg: &LittleBitConfig, base_model_id: Option<&str>, save_dir: &Path, tokenizer_src: Option<&Path>, ) -> Result<()>
Save final packed LittleBit checkpoint + tokenizer artifacts matching main.py::save_artifacts.
§Errors
Returns an error if saving config or safetensors fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for KdTrainer
impl !UnwindSafe for KdTrainer
impl Freeze for KdTrainer
impl Send for KdTrainer
impl Sync for KdTrainer
impl Unpin for KdTrainer
impl UnsafeUnpin for KdTrainer
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
Mutably borrows from an owned value. Read more
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,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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