nemo_automodel.shared.tied_weights
nemo_automodel.shared.tied_weights
Module Contents
Classes
Functions
API
Bases: enum.Enum
Which tie_word_embeddings settings a model class supports.
Declared as the tie_word_embeddings_support class attribute on every
registered model class and consulted by the model construction guard.
Return a module by FQN after applying wrapper-prefix normalization.
Strip wrapper-specific prefixes from a parameter name.
Return whether two tensors alias the same local storage.
Parameters:
Tensor of arbitrary shape, or a DTensor whose local tensor should be compared.
Tensor with the same logical role as left. Its shape is not
constrained here because callers validate shape compatibility.
Returns: bool
True when both local tensors have the same storage pointer and offset.
Ensure a local tied LM head actually aliases the input embedding.
Hugging Face tie_weights() is attempted first so model-specific tying
rules remain authoritative. Direct assignment is the fallback for wrapped
models where the generic method no longer reaches the local pair.
Parameters:
Model or pipeline stage to inspect and update.
Returns: bool
True if the local lm_head and input embedding are tied after the
Resolve the tie_word_embeddings flag that actually controls LM-head tying.
Hugging Face ties lm_head based on the top-level config flag. Full Omni
wrapper configs do not expose that flag directly, so they fall back to
thinker_config. Other wrappers without a top-level flag fall back to
text_config.
Parameters:
Model config exposing the relevant tying flag.
Returns: bool
The controlling tie_word_embeddings value.
Return the input embedding weight and normalized name if present.
Parameters:
Model to inspect.
Returns: torch.Tensor | None
The embedding weight tensor and its normalized FQN, or (None, None)
Return the first lm_head.weight parameter found on a model.
Parameters:
Model to inspect.
Returns: torch.Tensor | None
The parameter tensor and its normalized FQN, or (None, None) when
Return whether the current model partition has an actual tied LM head.
This is stricter than :func:is_tied_word_embeddings: pipeline stages often
retain a tied config flag without owning both tensors, and speculative draft
models can intentionally use different vocabulary sizes.
Parameters:
Model or pipeline stage to inspect.
Returns: bool
True when the local lm_head and input embedding both exist, have
Check whether the model’s word embeddings are tied.
A one-direction :class:TieSupport policy is authoritative. Only BOTH
models and undeclared Hugging Face models need their config flag resolved.
Parameters:
Model to inspect.
Returns: bool
True if the model’s word embeddings are tied, otherwise False.