bridge.utils.activation_map#

Shared bidirectional mapping between activation function names and callables.

Used by:

  • omegaconf_utils for CLI override serialization/deserialization

  • ModelBridge for HuggingFace <-> Megatron activation conversion

Module Contents#

Functions#

callable_to_str

Convert a known activation callable to its short string name.

str_to_callable

Resolve an activation function name to its callable.

str_to_dtype

Resolve a dtype string to a torch.dtype.

Data#

API#

bridge.utils.activation_map.logger#

‘getLogger(…)’

bridge.utils.activation_map.ACTIVATION_FUNC_MAP: dict[str, Callable]#

None

bridge.utils.activation_map._ACTIVATION_FUNC_TO_STR: dict[int, str]#

None

bridge.utils.activation_map.callable_to_str(fn: Callable) str | None#

Convert a known activation callable to its short string name.

Returns None if the callable is not in the registry.

bridge.utils.activation_map.str_to_callable(name: str) Callable#

Resolve an activation function name to its callable.

Accepts short names ("silu"), fully-qualified names ("torch.nn.functional.silu"), or arbitrary dotted import paths.

Raises:

ValueError – If the name cannot be resolved.

bridge.utils.activation_map.DTYPE_MAP: dict[str, torch.dtype]#

None

bridge.utils.activation_map.str_to_dtype(name: str) torch.dtype#

Resolve a dtype string to a torch.dtype.

Accepts short names ("bf16"), canonical names ("bfloat16"), or fully-qualified names ("torch.bfloat16").

Raises:

ValueError – If the name cannot be resolved.