llmcompressor.metrics.logger
Contains code for loggers that help visualize the information from each modifier.
Classes:
-
BaseLogger–Base class that all modifier loggers must implement.
-
LambdaLogger–Logger that handles calling back to a lambda function with any logs.
-
LoggerManager–Wrapper around loggers that handles log scheduling and handing off logs to intended
-
PythonLogger–Modifier metrics that handles printing values into a python metrics instance.
-
SparsificationGroupLogger–Modifier metrics that handles outputting values to other supported systems.
-
TensorBoardLogger–Modifier metrics that handles outputting values into a TensorBoard log directory
-
WANDBLogger–Modifier metrics that handles outputting values to Weights and Biases.
BaseLogger
Bases: ABC
Base class that all modifier loggers must implement.
Parameters:
-
(namestr) –name given to the metrics, used for identification
-
(enabledbool, default:True) –True to log, False otherwise
Methods:
-
log_hyperparams–:param params: Each key-value pair in the dictionary is the name of the
-
log_scalar–:param tag: identifying tag to log the value with
-
log_scalars–:param tag: identifying tag to log the values with
-
log_string–:param tag: identifying tag to log the values with
-
save–:param file_path: path to a file to be saved
Attributes:
-
enabled(bool) –:return: True to log, False otherwise
-
name(str) –:return: name given to the metrics, used for identification
Source code in llmcompressor/metrics/logger.py
log_hyperparams
Parameters:
-
(paramsDict[str, float]) –Each key-value pair in the dictionary is the name of the hyper parameter and it's corresponding value.
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_scalar
log_scalar(
tag: str,
value: float,
step: Optional[int] = None,
wall_time: Optional[float] = None,
**kwargs,
) -> bool
Parameters:
-
(tagstr) –identifying tag to log the value with
-
(valuefloat) –value to save
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeOptional[float], default:None) –global wall time for when the value was taken
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_scalars
log_scalars(
tag: str,
values: Dict[str, float],
step: Optional[int] = None,
wall_time: Optional[float] = None,
**kwargs,
) -> bool
Parameters:
-
(tagstr) –identifying tag to log the values with
-
(valuesDict[str, float]) –values to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_string
log_string(
tag: str,
string: str,
step: Optional[int] = None,
wall_time: Optional[float] = None,
**kwargs,
) -> bool
Parameters:
-
(tagstr) –identifying tag to log the values with
-
–valuesvalues to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
save
Parameters:
-
(file_pathstr) –path to a file to be saved
-
–kwargsadditional arguments that a specific metrics might use
Returns:
-
bool–True if saved, False otherwise
Source code in llmcompressor/metrics/logger.py
LambdaLogger
LambdaLogger(
lambda_func: Callable[
[
Optional[str],
Optional[Union[float, str]],
Optional[Dict[str, float]],
Optional[int],
Optional[float],
Optional[int],
],
bool,
],
name: str = "lambda",
enabled: bool = True,
)
Bases: BaseLogger
Logger that handles calling back to a lambda function with any logs.
Parameters:
-
(lambda_funcCallable[[Optional[str], Optional[Union[float, str]], Optional[Dict[str, float]], Optional[int], Optional[float], Optional[int]], bool]) –the lambda function to call back into with any logs. The expected call sequence is (tag, value, values, step, wall_time) -> bool The return type is True if logged and False otherwise.
-
(namestr, default:'lambda') –name given to the metrics, used for identification; defaults to lambda
-
(enabledbool, default:True) –True to log, False otherwise
Methods:
-
log_hyperparams–:param params: Each key-value pair in the dictionary is the name of the
-
log_scalar–:param tag: identifying tag to log the value with
-
log_scalars–:param tag: identifying tag to log the values with
Attributes:
-
lambda_func(Callable[[Optional[str], Optional[Union[float, str]], Optional[Dict[str, float]], Optional[int], Optional[float], Optional[int]], bool]) –:return: the lambda function to call back into with any logs.
Source code in llmcompressor/metrics/logger.py
lambda_func property
lambda_func: Callable[
[
Optional[str],
Optional[Union[float, str]],
Optional[Dict[str, float]],
Optional[int],
Optional[float],
Optional[int],
],
bool,
]
Returns:
-
Callable[[Optional[str], Optional[Union[float, str]], Optional[Dict[str, float]], Optional[int], Optional[float], Optional[int]], bool]–the lambda function to call back into with any logs. The expected call sequence is (tag, value, values, step, wall_time)
log_hyperparams
Parameters:
-
(paramsDict) –Each key-value pair in the dictionary is the name of the hyper parameter and it's corresponding value.
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_scalar
log_scalar(
tag: str,
value: float,
step: Optional[int] = None,
wall_time: Optional[float] = None,
level: Optional[Union[int, str]] = None,
) -> bool
Parameters:
-
(tagstr) –identifying tag to log the value with
-
(valuefloat) –value to save
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeOptional[float], default:None) –global wall time for when the value was taken, defaults to time.time()
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_scalars
log_scalars(
tag: str,
values: Dict[str, float],
step: Optional[int] = None,
wall_time: Optional[float] = None,
level: Optional[Union[int, str]] = None,
) -> bool
Parameters:
-
(tagstr) –identifying tag to log the values with
-
(valuesDict[str, float]) –values to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken, defaults to time.time()
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
LoggerManager
LoggerManager(
loggers: Optional[List[BaseLogger]] = None,
log_frequency: Union[float, None] = 0.1,
log_python: bool = True,
name: str = "manager",
mode: LoggingModeType = "exact",
frequency_type: FrequencyType = "epoch",
)
Bases: ABC
Wrapper around loggers that handles log scheduling and handing off logs to intended loggers.
Parameters:
-
(loggersOptional[List[BaseLogger]], default:None) –list of loggers assigned to this manager
-
(log_frequencyUnion[float, None], default:0.1) –number of stes or fraction of steps to wait between logs
-
(modeLoggingModeType, default:'exact') –The logging mode to use, either "on_change" or "exact", "on_change" will log when the model has been updated since the last log, "exact" will log at the given frequency regardless of model updates. Defaults to "exact"
-
(frequency_typeFrequencyType, default:'epoch') –The frequency type to use, either "epoch", "step", or "batch" controls what the frequency manager is tracking, e.g. if the frequency type is "epoch", then the frequency manager will track the number of epochs that have passed since the last log, if the frequency type is "step", then the frequency manager will track the number of optimizer steps
Methods:
-
add_logger–add a BaseLogger implementation to the loggers of this manager
-
log_hyperparams–(Note: this method is deprecated and will be removed in a future version,
-
log_ready–Check if there is a metrics that is ready to accept a log
-
log_scalar–(Note: this method is deprecated and will be removed in a future version,
-
log_scalars–(Note: this method is deprecated and will be removed in a future version,
-
log_string–(Note: this method is deprecated and will be removed in a future version,
-
log_written–Update the frequency manager with the last log step written
-
model_updated–Update the frequency manager with the last model update step
-
save–:param file_path: path to a file to be saved
-
time–Context manager to log the time it takes to run the block of code
Attributes:
-
log_frequency(Union[str, float, None]) –:return: number of epochs or fraction of epochs to wait between logs
-
loggers(List[BaseLogger]) –:return: list of loggers assigned to this manager
-
name(str) –:return: name given to the metrics, used for identification
-
wandb(Optional[ModuleType]) –:return: wandb module if initialized
Source code in llmcompressor/metrics/logger.py
log_frequency property writable
Returns:
-
Union[str, float, None]–number of epochs or fraction of epochs to wait between logs
loggers property writable
Returns:
-
List[BaseLogger]–list of loggers assigned to this manager
wandb property
Returns:
-
Optional[ModuleType]–wandb module if initialized
add_logger
add a BaseLogger implementation to the loggers of this manager
Parameters:
-
(loggerBaseLogger) –metrics object to add
Source code in llmcompressor/metrics/logger.py
log_hyperparams
log_hyperparams(
params: Dict,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
(Note: this method is deprecated and will be removed in a future version, use LoggerManager().metric.log_hyperparams instead)
Parameters:
-
(paramsDict) –Each key-value pair in the dictionary is the name of the hyper parameter and it's corresponding value.
Source code in llmcompressor/metrics/logger.py
log_ready
Check if there is a metrics that is ready to accept a log
Parameters:
-
–current_log_stepcurrent step log is requested at
-
–last_log_steplast time a log was recorder for this object. (Deprecated)
-
(check_model_updatebool, default:False) –if True, will check if the model has been updated, if False, will only check the log frequency
Returns:
- –
True if a metrics is ready to accept a log.
Source code in llmcompressor/metrics/logger.py
log_scalar
log_scalar(
tag: str,
value: float,
step: Optional[int] = None,
wall_time: Optional[float] = None,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
(Note: this method is deprecated and will be removed in a future version, use LoggerManager().metric.log_scalar instead)
Parameters:
-
(tagstr) –identifying tag to log the value with
-
(valuefloat) –value to save
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeOptional[float], default:None) –global wall time for when the value was taken
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
- –
True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_scalars
log_scalars(
tag: str,
values: Dict[str, float],
step: Optional[int] = None,
wall_time: Optional[float] = None,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
(Note: this method is deprecated and will be removed in a future version, use LoggerManager().metric.log_scalars instead)
Parameters:
-
(tagstr) –identifying tag to log the values with
-
(valuesDict[str, float]) –values to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
- –
True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_string
log_string(
tag: str,
string: str,
step: Optional[int] = None,
wall_time: Optional[float] = None,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
(Note: this method is deprecated and will be removed in a future version, use LoggerManager().system.log_string instead)
Parameters:
-
(tagstr) –identifying tag to log the values with
-
–valuesvalues to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken
-
–kwargsadditional logging arguments to support Python and custom loggers
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
Returns:
- –
True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_written
Update the frequency manager with the last log step written
Parameters:
-
(stepLogStepType) –step that was last logged
model_updated
Update the frequency manager with the last model update step
Parameters:
-
(stepLogStepType) –step that was last logged
save
Parameters:
-
(file_pathstr) –path to a file to be saved
-
–kwargsadditional arguments that a specific metrics might use
Source code in llmcompressor/metrics/logger.py
time
Context manager to log the time it takes to run the block of code
Usage:
with LoggerManager().time("my_block"): time.sleep(1)
Parameters:
-
(tagOptional[str], default:None) –identifying tag to log the values with
Source code in llmcompressor/metrics/logger.py
LoggingWrapperBase
MetricLoggingWrapper
Bases: LoggingWrapperBase
Wraps utilities and convenience methods for logging metrics to the system
Methods:
-
add_scalar–Add a scalar value to the metrics
-
add_scalars–Adds multiple scalar values to the metrics
-
log–:param data: A dict of serializable python objects i.e
str, -
log_hyperparams–:param params: Each key-value pair in the dictionary is the name of the
-
log_scalar–:param tag: identifying tag to log the value with
-
log_scalars–:param tag: identifying tag to log the values with
Source code in llmcompressor/metrics/logger.py
add_scalar
add_scalar(
value,
tag: str = DEFAULT_TAG,
step: Optional[int] = None,
wall_time: Union[int, float, None] = None,
**kwargs,
)
Add a scalar value to the metrics
Parameters:
-
–valuevalue to log
-
(tagstr, default:DEFAULT_TAG) –tag to log the value with, defaults to DEFAULT_TAG
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeUnion[int, float, None], default:None) –global wall time for when the value was taken
-
–kwargsadditional logging arguments to to pass through to the metrics
Source code in llmcompressor/metrics/logger.py
add_scalars
add_scalars(
values: Dict[str, Any],
tag: str = DEFAULT_TAG,
step: Optional[int] = None,
wall_time: Union[int, float, None] = None,
**kwargs,
)
Adds multiple scalar values to the metrics
Parameters:
-
(valuesDict[str, Any]) –values to log, must be A dict of serializable python objects i.e
str,ints,floats,Tensors,dicts, etc -
(tagstr, default:DEFAULT_TAG) –tag to log the value with, defaults to DEFAULT_TAG
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeUnion[int, float, None], default:None) –global wall time for when the value was taken
-
–kwargsadditional logging arguments to to pass through to the metrics
Source code in llmcompressor/metrics/logger.py
log
log(
data: Dict[str, Any],
step: Optional[int] = None,
tag: Optional[str] = DEFAULT_TAG,
**kwargs,
) -> None
Parameters:
-
(dataDict[str, Any]) –A dict of serializable python objects i.e
str,ints,floats,Tensors,dicts, etc -
(stepOptional[int], default:None) –global step for when the values were taken
-
(tagOptional[str], default:DEFAULT_TAG) –identifying tag to log the values with, defaults to DEFAULT_TAG
-
–kwargsadditional logging arguments to support Python and custom loggers
Source code in llmcompressor/metrics/logger.py
log_hyperparams
log_hyperparams(
params: Dict,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
Parameters:
-
(paramsDict) –Each key-value pair in the dictionary is the name of the hyper parameter and it's corresponding value.
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
Source code in llmcompressor/metrics/logger.py
log_scalar
log_scalar(
tag: str,
value: float,
step: Optional[int] = None,
wall_time: Optional[float] = None,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
Parameters:
-
(tagstr) –identifying tag to log the value with
-
(valuefloat) –value to save
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeOptional[float], default:None) –global wall time for when the value was taken
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
- –
True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
log_scalars
log_scalars(
tag: str,
values: Dict[str, float],
step: Optional[int] = None,
wall_time: Optional[float] = None,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
Parameters:
-
(tagstr) –identifying tag to log the values with
-
(valuesDict[str, float]) –values to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
- –
True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
PythonLogger
Bases: LambdaLogger
Modifier metrics that handles printing values into a python metrics instance.
Parameters:
-
(namestr, default:'python') –name given to the metrics, used for identification; defaults to python
-
(enabledbool, default:True) –True to log, False otherwise
Methods:
-
log_string–:param tag: identifying tag to log the values with
Source code in llmcompressor/metrics/logger.py
log_string
log_string(
tag: Optional[str],
string: Optional[str],
step: Optional[int],
wall_time: Optional[float] = None,
level: Optional[Union[int, str]] = None,
) -> bool
Parameters:
-
(tagOptional[str]) –identifying tag to log the values with
-
(stringOptional[str]) –string to log
-
(stepOptional[int]) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken, defaults to time.time()
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
Returns:
-
bool–True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
SparsificationGroupLogger
SparsificationGroupLogger(
lambda_func: Optional[
Callable[
[
Optional[str],
Optional[float],
Optional[Dict[str, float]],
Optional[int],
Optional[float],
],
bool,
]
] = None,
python: bool = False,
python_log_level: Optional[Union[int, str]] = "INFO",
tensorboard: Optional[
Union[bool, str, SummaryWriter]
] = None,
wandb_: Optional[Union[bool, Dict]] = None,
name: str = "sparsification",
enabled: bool = True,
)
Bases: BaseLogger
Modifier metrics that handles outputting values to other supported systems. Supported ones include: - Python logging - Tensorboard - Weights and Biases - Lambda callback
All are optional and can be bulk disabled and enabled by this root.
Parameters:
-
(lambda_funcOptional[Callable[[Optional[str], Optional[float], Optional[Dict[str, float]], Optional[int], Optional[float]], bool]], default:None) –an optional lambda function to call back into with any logs. The expected call sequence is (tag, value, values, step, wall_time) -> bool The return type is True if logged and False otherwise.
-
(pythonbool, default:False) –an bool argument for logging to a python metrics. True to create a metrics instance, or False to not log anything
-
(python_log_levelOptional[Union[int, str]], default:'INFO') –if python, the level to log any incoming data at on the loguru.logger instance
-
(tensorboardOptional[Union[bool, str, SummaryWriter]], default:None) –an optional argument for logging to a tensorboard writer. May be a SummaryWriter instance to log to, a string representing the directory to create a new SummaryWriter to log to, True to create a new SummaryWriter, or non truthy to not log anything (False, None)
-
(wandb_Optional[Union[bool, Dict]], default:None) –an optional argument for logging to wandb. May be a dictionary to pass to the init call for wandb, True to log to wandb (will not call init), or non truthy to not log anything (False, None)
-
(namestr, default:'sparsification') –name given to the metrics, used for identification; defaults to sparsification
-
(enabledbool, default:True) –True to log, False otherwise
Methods:
-
enabled–:param value: True to log, False otherwise
-
log_hyperparams–:param params: Each key-value pair in the dictionary is the name of the
-
log_scalar–:param tag: identifying tag to log the value with
-
log_scalars–:param tag: identifying tag to log the values with
Attributes:
-
loggers(List[BaseLogger]) –:return: the created metrics sub instances for this metrics
Source code in llmcompressor/metrics/logger.py
loggers property
Returns:
-
List[BaseLogger]–the created metrics sub instances for this metrics
enabled
Parameters:
-
(valuebool) –True to log, False otherwise
log_hyperparams
Parameters:
-
(paramsDict) –Each key-value pair in the dictionary is the name of the hyper parameter and it's corresponding value.
Source code in llmcompressor/metrics/logger.py
log_scalar
log_scalar(
tag: str,
value: float,
step: Optional[int] = None,
wall_time: Optional[float] = None,
level: Optional[Union[int, str]] = None,
)
Parameters:
-
(tagstr) –identifying tag to log the value with
-
(valuefloat) –value to save
-
(stepOptional[int], default:None) –global step for when the value was taken
-
(wall_timeOptional[float], default:None) –global wall time for when the value was taken, defaults to time.time()
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
Source code in llmcompressor/metrics/logger.py
log_scalars
log_scalars(
tag: str,
values: Dict[str, float],
step: Optional[int] = None,
wall_time: Optional[float] = None,
level: Optional[Union[int, str]] = None,
)
Parameters:
-
(tagstr) –identifying tag to log the values with
-
(valuesDict[str, float]) –values to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken, defaults to time.time()
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
Source code in llmcompressor/metrics/logger.py
SystemLoggingWraper
Bases: LoggingWrapperBase
Wraps utilities and convenience methods for logging strings to the system
Methods:
-
critical–logs a string message with level CRITICAL on all
-
debug–logs a string message with level DEBUG on all
-
error–logs a string message with level ERROR on all
-
info–logs a string message with level INFO on all
-
log_string–:param tag: identifying tag to log the values with
-
warning–logs a string message with level WARNING on all
Source code in llmcompressor/metrics/logger.py
critical
logs a string message with level CRITICAL on all loggers that are enabled
Parameters:
-
–tagIdentifying tag to log the string with
-
–stringThe string to log
-
–argsadditional arguments to pass to the metrics, see
log_stringfor more details -
–kwargsadditional arguments to pass to the metrics, see
log_stringfor more details
Source code in llmcompressor/metrics/logger.py
debug
logs a string message with level DEBUG on all loggers that are enabled
Parameters:
-
–tagIdentifying tag to log the string with
-
–stringThe string to log
-
–argsadditional arguments to pass to the metrics, see
log_stringfor more details -
–kwargsadditional arguments to pass to the metrics, see
log_stringfor more details
Source code in llmcompressor/metrics/logger.py
error
logs a string message with level ERROR on all loggers that are enabled
Parameters:
-
–tagIdentifying tag to log the string with
-
–stringThe string to log
-
–argsadditional arguments to pass to the metrics, see
log_stringfor more details -
–kwargsadditional arguments to pass to the metrics, see
log_stringfor more details
Source code in llmcompressor/metrics/logger.py
info
logs a string message with level INFO on all loggers that are enabled
Parameters:
-
–tagIdentifying tag to log the string with
-
–stringThe string to log
-
–argsadditional arguments to pass to the metrics, see
log_stringfor more details -
–kwargsadditional arguments to pass to the metrics, see
log_stringfor more details
Source code in llmcompressor/metrics/logger.py
log_string
log_string(
tag: str,
string: str,
step: Optional[int] = None,
wall_time: Optional[float] = None,
log_types: Union[str, List[str]] = ALL_TOKEN,
level: Optional[Union[int, str]] = None,
)
Parameters:
-
(tagstr) –identifying tag to log the values with
-
–valuesvalues to save
-
(stepOptional[int], default:None) –global step for when the values were taken
-
(wall_timeOptional[float], default:None) –global wall time for when the values were taken
-
(levelOptional[Union[int, str]], default:None) –minimum severity level for the log message
-
–kwargsadditional logging arguments to support Python and custom loggers
Returns:
- –
True if logged, False otherwise.
Source code in llmcompressor/metrics/logger.py
warning
logs a string message with level WARNING on all loggers that are enabled
Parameters:
-
–tagIdentifying tag to log the string with
-
–stringThe string to log
-
–argsadditional arguments to pass to the metrics, see
log_stringfor more details -
–kwargsadditional arguments to pass to the metrics, see
log_stringfor more details
Source code in llmcompressor/metrics/logger.py
TensorBoardLogger
TensorBoardLogger(
log_path: str = None,
writer: SummaryWriter = None,
name: str = "tensorboard",
enabled: bool = True,
)
Bases: LambdaLogger
Modifier metrics that handles outputting values into a TensorBoard log directory for viewing in TensorBoard.
Parameters:
-
(log_pathstr, default:None) –the path to create a SummaryWriter at. writer must be None to use if not supplied (and writer is None), will create a TensorBoard dir in cwd
-
(writerSummaryWriter, default:None) –the writer to log results to, if none is given creates a new one at the log_path
-
(namestr, default:'tensorboard') –name given to the metrics, used for identification; defaults to tensorboard
-
(enabledbool, default:True) –True to log, False otherwise
Methods:
-
available–:return: True if tensorboard is available and installed, False, otherwise
Attributes:
-
writer(SummaryWriter) –:return: the writer to log results to,
Source code in llmcompressor/metrics/logger.py
writer property
Returns:
-
SummaryWriter–the writer to log results to, if none is given creates a new one at the log_path
available staticmethod
Returns:
-
bool–True if tensorboard is available and installed, False, otherwise
WANDBLogger
WANDBLogger(
init_kwargs: Optional[Dict] = None,
name: str = "wandb",
enabled: bool = True,
wandb_err: Optional[Exception] = wandb_err,
)
Bases: LambdaLogger
Modifier metrics that handles outputting values to Weights and Biases.
Parameters:
-
(init_kwargsOptional[Dict], default:None) –the args to call into wandb.init with; ex: wandb.init(**init_kwargs). If not supplied, then init will not be called
-
(namestr, default:'wandb') –name given to the metrics, used for identification; defaults to wandb
-
(enabledbool, default:True) –True to log, False otherwise
Methods:
-
available–:return: True if wandb is available and installed, False, otherwise
-
save–:param file_path: path to a file to be saved