bridge.training.utils.log_utils#

Module Contents#

Classes#

_RankZeroInfoFilter

Emit repeated external informational messages on rank zero only.

Functions#

setup_logging

Set up logging level and filters for the application.

safe_serialize

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.Filter

Emit 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,
) → None#

Set up logging level and filters for the application.

Thin wrapper around :func:megatron.training.utils.log_utils.setup_logging that also honors the legacy Bridge env var MEGATRON_BRIDGE_LOGGING_LEVEL by promoting it to MEGATRON_LOGGING_LEVEL when the latter is unset.

Logging Level Precedence (matches MLM):

  1. logging_level argument

  2. Env var MEGATRON_LOGGING_LEVEL (or legacy MEGATRON_BRIDGE_LOGGING_LEVEL)

  3. 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).