bridge.training.utils.log_utils#

Module Contents#

Functions#

setup_logging

Set up logging level and filters for the application.

safe_serialize

Safely convert any object to a JSON-serializable type.

API#

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