llmcompressor.core.helpers
Helper functions for core compression operations.
Provides utility functions for logging model information and state management during compression workflows. Includes functionality for conditional logging and parameter tracking.
Functions:
-
log_model_info
–Log model level info to the metrics
-
should_log_model_info
–Check if we should log model level info
log_model_info
Log model level info to the metrics Relies on state.model
having a loggable_items
method that returns a generator of tuples of the loggable item name and value. Also relies on state.loggers
being a LoggerManager
instance.
Parameters:
-
state
State
) –The current state of sparsification
-
current_log_step
The current log step to log model info at
Source code in llmcompressor/core/helpers.py
should_log_model_info
should_log_model_info(
model: Any,
loggers: LoggerManager,
current_log_step: float,
last_log_step: Optional[float] = None,
) -> bool
Check if we should log model level info Criteria: - model has a loggable_items method - state has a metrics manager - metrics manager is ready to log based on cadence and last log epoch
Parameters:
-
model
Any
) –The model whose info we want to log
-
loggers
LoggerManager
) –The metrics manager to log to
-
current_log_step
float
) –The current epoch
-
last_log_step
Optional[float]
, default:None
) –The last step we logged model info at
Returns:
-
bool
–True if we should log model level info, False otherwise