bridge.models.logit_dtype#
Compatibility helpers for MCore’s optional output-logit dtype API.
Module Contents#
Functions#
Return an optional dtype keyword when the installed constructor supports it. |
|
Return a guarded |
|
Return a guarded |
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,
Return an optional dtype keyword when the installed constructor supports it.
Omitting a
Nonevalue 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_dtypeoroutput_dtype.dtype – Requested output dtype, or
Noneto 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,
Return a guarded
logit_dtypeconstructor keyword.
- bridge.models.logit_dtype.output_dtype_kwarg(
- constructor: collections.abc.Callable[..., Any],
- dtype: torch.dtype | None,
Return a guarded
output_dtypeconstructor keyword.
- bridge.models.logit_dtype.__all__#
[‘logit_dtype_kwarg’, ‘optional_dtype_kwarg’, ‘output_dtype_kwarg’]