Skip to navigation

nemo_automodel.components.models.hy_mt2

View as Markdown

Submodules

Package Contents

Classes

NameDescription
HyMT2ForCausalLMHy-MT2-30B-A3B causal-LM wrapper.

API

class nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM(
config: typing.Any,
kwargs = {}
)

Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin

Hy-MT2-30B-A3B causal-LM wrapper.

Mixes in MoEFSDPSyncMixin so EP / FSDP2 expert-gradient sync works out of the box (set distributed.ep_size in the YAML; must divide num_experts=128). The HFCheckpointingMixin provides from_pretrained / save_pretrained over the HF safetensors layout.

_enable_lm_head_fp32
_keep_in_fp32_modules_strict
= ['mlp.gate.e_score_correction_bias']
backend
= backend or BackendConfig()
lm_head
model
state_dict_adapter
tie_word_embeddings_support
TieSupport = TieSupport.UNTIED_ONLY
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.forward(
input_ids: torch.Tensor,
position_ids: torch.Tensor | None = None,
attention_mask: torch.Tensor | None = None,
padding_mask: torch.Tensor | None = None,
logits_to_keep: typing.Union[int, torch.Tensor] = 0,
output_hidden_states: bool | None = None,
attn_kwargs: typing.Any = {}
) -> transformers.modeling_outputs.CausalLMOutputWithPast

Forward pass returning CausalLMOutputWithPast.

Parameters:

input_ids
torch.Tensor

Token IDs. BSHD: [B, S]; THD: [1, T] (squeezed internally).

position_ids
torch.Tensor | NoneDefaults to None

Optional position indices.

attention_mask
torch.Tensor | NoneDefaults to None

Optional 2D padding mask.

padding_mask
torch.Tensor | NoneDefaults to None

Optional padding mask used by the THD squeeze helper.

logits_to_keep
Union[int, torch.Tensor]Defaults to 0

If 0 (default) compute logits for all positions; if > 0 only compute logits for the last logits_to_keep positions (avoids materialising the full logit matrix during generation / enables fused-linear cross-entropy in training).

output_hidden_states
bool | NoneDefaults to None

Whether to return the final hidden states (the input to lm_head) on the output. Defaults to the config flag.

**attn_kwargs
AnyDefaults to {}

Additional attention kwargs forwarded to the base model (e.g. qkv_format, cu_seqlens, CP kwargs).

Returns: CausalLMOutputWithPast

class:~transformers.modeling_outputs.CausalLMOutputWithPast with

nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.from_config(
config: typing.Any,
kwargs = {}
)
classmethod
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.from_pretrained(
pretrained_model_name_or_path: str,
model_args = (),
kwargs = {}
)
classmethod
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.get_input_embeddings()
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.get_output_embeddings()
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.initialize_weights(
buffer_device: torch.device | None = None,
dtype: torch.dtype = torch.bfloat16
) -> None
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.set_input_embeddings(
value
)
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.set_output_embeddings(
new_embeddings
)
nemo_automodel.components.models.hy_mt2.model.HyMT2ForCausalLM.update_moe_gate_bias() -> None