bridge.models.logit_dtype#

Compatibility helpers for MCore’s optional output-logit dtype API.

Module Contents#

Functions#

optional_dtype_kwarg

Return an optional dtype keyword when the installed constructor supports it.

logit_dtype_kwarg

Return a guarded logit_dtype constructor keyword.

output_dtype_kwarg

Return a guarded output_dtype constructor keyword.

Data#

API#

bridge.models.logit_dtype._SUPPORTED_LOGIT_DTYPES#

()

bridge.models.logit_dtype.optional_dtype_kwarg(
constructor: collections.abc.Callable[..., Any],
keyword: str,
dtype: torch.dtype | None,
) dict[str, torch.dtype]#

Return an optional dtype keyword when the installed constructor supports it.

Omitting a None value preserves the exact behavior of older MCore constructors. A configured value must never be silently dropped when the installed MCore predates the corresponding API.

Parameters:
  • constructor – Model or layer constructor that should receive the keyword.

  • keyword – Constructor keyword, either logit_dtype or output_dtype.

  • dtype – Requested output dtype, or None to preserve the input dtype.

Returns:

An empty mapping for the default behavior, otherwise the supported constructor keyword.

Raises:
  • ValueError – If the requested dtype is outside MCore’s supported contract.

  • RuntimeError – If the installed constructor does not support the keyword.

bridge.models.logit_dtype.logit_dtype_kwarg(
constructor: collections.abc.Callable[..., Any],
dtype: torch.dtype | None,
) dict[str, torch.dtype]#

Return a guarded logit_dtype constructor keyword.

bridge.models.logit_dtype.output_dtype_kwarg(
constructor: collections.abc.Callable[..., Any],
dtype: torch.dtype | None,
) dict[str, torch.dtype]#

Return a guarded output_dtype constructor keyword.

bridge.models.logit_dtype.__all__#

[‘logit_dtype_kwarg’, ‘optional_dtype_kwarg’, ‘output_dtype_kwarg’]