bridge.training.utils.log_utils#
Module Contents#
Classes#
Emit repeated external informational messages on rank zero only. |
Functions#
Set up logging level and filters for the application. |
|
Safely convert any object to a JSON-serializable type. |
Data#
API#
- bridge.training.utils.log_utils._REPEATED_EXTERNAL_LOGGERS#
(‘GroupedGemmQuantSm100’, ‘GroupedGemmDsreluSm100’, ‘GroupedGemmSreluSm100’, ‘GroupedGemmWgradSm100’…
- class bridge.training.utils.log_utils._RankZeroInfoFilter(name='')#
Bases:
logging.FilterEmit repeated external informational messages on rank zero only.
Initialization
Initialize a filter.
Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.
- filter(record: logging.LogRecord) bool#
- bridge.training.utils.log_utils._rank_zero_info_filter#
‘_RankZeroInfoFilter(…)’
- bridge.training.utils.log_utils.setup_logging(
- logging_level: int | None = None,
- filter_warning: bool = True,
- modules_to_filter: list[str] | None = None,
- set_level_for_all_loggers: bool = False,
Set up logging level and filters for the application.
Thin wrapper around :func:
megatron.training.utils.log_utils.setup_loggingthat also honors the legacy Bridge env varMEGATRON_BRIDGE_LOGGING_LEVELby promoting it toMEGATRON_LOGGING_LEVELwhen the latter is unset.Logging Level Precedence (matches MLM):
logging_levelargumentEnv var
MEGATRON_LOGGING_LEVEL(or legacyMEGATRON_BRIDGE_LOGGING_LEVEL)Default:
logging.INFO
- Parameters:
logging_level – The desired logging level (e.g., logging.INFO, logging.DEBUG).
filter_warning – If True, adds a filter to suppress WARNING level messages.
modules_to_filter – An optional list of module name prefixes to filter out.
set_level_for_all_loggers – If True, sets the logging level for all existing loggers. If False (default), only sets the level for the root logger and loggers starting with ‘megatron.bridge’.
- bridge.training.utils.log_utils.safe_serialize(obj) str#
Safely convert any object to a JSON-serializable type.
Handles objects with broken str or repr methods that return non-string types (e.g., PipelineParallelLayerLayout returns list).