nemo_automodel.components.models.ernie4_5
nemo_automodel.components.models.ernie4_5
Submodules
nemo_automodel.components.models.ernie4_5.modelnemo_automodel.components.models.ernie4_5.rope_utilsnemo_automodel.components.models.ernie4_5.state_dict_adapter
Package Contents
Classes
API
Bases: HFCheckpointingMixin, Module
Dense ERNIE 4.5 causal language model.
Run the decoder and project the kept positions to vocabulary logits.
Parameters:
Token IDs of shape [batch, sequence], or packed (THD) IDs of shape [1, tokens].
Optional positions of shape [batch, sequence], or [1, tokens] for packed input, which requires them.
Optional Tensor of shape [batch, sequence], 1 at valid tokens and 0 at padding, or, with SDPA, a dense mask of shape [batch, 1, sequence, sequence]; packed input ignores it.
Optional bool Tensor of shape [batch, sequence], or [1, tokens] when packed, true at padding; the dense layers do not use it.
0 keeps every position, a positive int keeps the last N positions, and an integer
Tensor of shape [kept] keeps those positions.
Whether the output carries the final hidden states; None reads
config.output_hidden_states.
Backend metadata for the decoder. Packed input sets qkv_format="thd" and passes
int32 cu_seqlens and cu_seqlens_padded of shape [1, documents + 1], padded with -1000, and
max_seqlen.
Returns: CausalLMOutputWithPast
CausalLMOutputWithPast whose logits have shape [batch, kept, vocab], or [1, kept, vocab] for packed
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
ERNIE 4.5 MoE causal language model with AutoModel EP support.
Run the decoder and project the kept positions to vocabulary logits.
Parameters:
Token IDs of shape [batch, sequence], or packed (THD) IDs of shape [1, tokens].
Optional positions of shape [batch, sequence], or [1, tokens] for packed input, which requires them.
Optional Tensor of shape [batch, sequence], 1 at valid tokens and 0 at padding, or, with SDPA and an explicit padding_mask, a dense mask of shape [batch, 1, sequence, sequence]; packed input ignores it.
Optional bool Tensor of shape [batch, sequence], or [1, tokens] when packed, true at padding; when None, the MoE layers derive it from attention_mask.
0 keeps every position, a positive int keeps the last N positions, and an integer
Tensor of shape [kept] keeps those positions.
Whether the output carries the final hidden states; None reads
config.output_hidden_states.
Backend metadata for the decoder. Packed input sets qkv_format="thd" and passes
int32 cu_seqlens and cu_seqlens_padded of shape [1, documents + 1], padded with -1000, and
max_seqlen.
Returns: CausalLMOutputWithPast
CausalLMOutputWithPast whose logits have shape [batch, kept, vocab], or [1, kept, vocab] for packed
Return parallelism capabilities for a specific ERNIE-4.5 config.
ERNIE-4.5 ships in two flavors that share this class file but exercise different code paths:
baidu/ERNIE-4.5-21B-A3B-PT— MoE variant (this NeMo custom class).moe_num_experts > 0in the HF config. Demonstrated by examples/llm_finetune/ernie4_5/ernie4_5_21b_a3b_hellaswag.yaml (ep_size=8).baidu/ERNIE-4.5-0.3B-PT— dense variant. No expert config. Demonstrated by examples/llm_finetune/ernie4_5/ernie4_5_0p3b_hellaswag.yaml (tp/cp/pp/ep all 1).