bridge.training.utils.config_utils#
Module Contents#
Classes#
Bridge config container that lets composite HF configs construct their children. |
Functions#
Preserve runtime GTP sizes in constructor fields before sanitizing configs. |
|
Create a finalized Bridge DDP config for external model construction. |
Data#
API#
- bridge.training.utils.config_utils.logger#
‘getLogger(…)’
- bridge.training.utils.config_utils._materialize_gtp_weight_shards(
- value: Any,
- _memo: dict[int, Any] | None = None,
Preserve runtime GTP sizes in constructor fields before sanitizing configs.
- class bridge.training.utils.config_utils._ConfigContainerBase#
Bases:
megatron.training.config.container.ConfigContainerBaseBridge config container that lets composite HF configs construct their children.
Nested
PreTrainedConfigvalues are emitted as plain mappings because their parent config owns child construction. Other dataclasses retain MCore’s recursive_target_serialization.Megatron Core serializes container sections with module-level helpers that do not dispatch to subclass hooks, so Bridge owns the traversal: every section and nested value goes through :meth:
_convert_value_to_dict.- to_dict(
- **section_overrides: Mapping[str, Any],
Convert the container to a dictionary through Bridge’s value conversion.
- Parameters:
**section_overrides – Map a section name to field values that replace the section’s own values in the result, as in Megatron Core.
- Returns:
Dictionary representation of this config with an importable
_target_.
- classmethod _overlay_section(
- name: str,
- section: Any,
- overrides: Mapping[str, Any],
Return the serialized
sectionwithoverridesin place of its own field values.
- classmethod _convert_value_to_dict(value: Any) Any#
- classmethod _convert_generic_value_to_dict(value: Any) Any#
Recursively convert containers, dataclasses and collections.
Nested values go back through :meth:
_convert_value_to_dictso Bridge-specific conversions apply at any depth.
- classmethod _convert_recipe_config_to_dict(
- value: megatron.core.quantization.quant_config.RecipeConfig,
Convert an MCore quantization recipe to an instantiable mapping.
- classmethod _convert_recipe_matcher_to_dict(
- matcher: megatron.core.quantization.quant_config.Matcher,
Convert a quantization recipe matcher to an instantiable mapping.
- classmethod _convert_pretrained_config_to_dict(
- value: transformers.PreTrainedConfig,
- *,
- include_target: bool,
- classmethod _convert_pretrained_config_value_to_dict(
- value: Any,
- bridge.training.utils.config_utils.create_ddp_config(
- wrap_with_ddp: bool = True,
- use_distributed_optimizer: bool = True,
- use_megatron_fsdp: bool = False,
- overrides: Mapping[str, object] | None = None,
- finalize: bool = True,
Create a finalized Bridge DDP config for external model construction.