llmcompressor.transformers.finetune.callbacks
Training callbacks for compression-aware fine-tuning workflows.
This module provides custom trainer callbacks that integrate compression session management with HuggingFace training loops. Handles precision control, training loop monitoring, and compression lifecycle events during model fine-tuning.
Classes:
-
DisableHalfPrecisionCallback
–TrainerCallback for disabling FP16 training before QAT training begins
-
TrainingLoopCallbacks
–TrainerCallback for triggering CompressionSession callbacks in the training loop.
DisableHalfPrecisionCallback
Bases: TrainerCallback
TrainerCallback for disabling FP16 training before QAT training begins
Parameters:
-
trainer
LLM Compressor trainer that will call back into this object
-
args
args to be passed to base TrainerCallback
-
kwargs
key word arguments to be passed to base TrainerCallback
Methods:
-
on_epoch_begin
–Event called at the beginning of an epoch.
-
qat_active
–:return: True if a quantization modifier is active in the current session
Source code in llmcompressor/transformers/finetune/callbacks.py
on_epoch_begin
Event called at the beginning of an epoch.
Source code in llmcompressor/transformers/finetune/callbacks.py
qat_active
Returns:
-
bool
–True if a quantization modifier is active in the current session
TrainingLoopCallbacks
Bases: TrainerCallback
TrainerCallback for triggering CompressionSession callbacks in the training loop. Used to update the model reference(for running with FSDP) and trigger the post- optim callbacks in each modifier.
Parameters:
-
trainer
LLM Compressor trainer that will call back into this object
-
args
args to be passed to base TrainerCallback
-
kwargs
key word arguments to be passed to base TrainerCallback
Methods:
-
on_step_end
–Event called at the end of a training step. If using gradient accumulation,
-
on_substep_end
–Event called at the end of an substep during gradient accumulation.
-
on_train_begin
–Event called at the beginning of training. Update the session reference to the
Source code in llmcompressor/transformers/finetune/callbacks.py
on_step_end
Event called at the end of a training step. If using gradient accumulation, one training step might take several inputs.
Triggers optimizer post_step and batch_end in the active CompressionSession
Source code in llmcompressor/transformers/finetune/callbacks.py
on_substep_end
Event called at the end of an substep during gradient accumulation.
Triggers optimizer post_step and batch_end in the active CompressionSession
Source code in llmcompressor/transformers/finetune/callbacks.py
on_train_begin
Event called at the beginning of training. Update the session reference to the model, as it will have changed to a wrapper if FSDP is enabled