nemo_automodel.components.models.gpt_oss.model
nemo_automodel.components.models.gpt_oss.model
Module Contents
Classes
Data
API
Bases: Module
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Declare only this model’s bounded FA4 THD input path.
Request framework-owned raw token/label flattening for the FA4 path.
This requests CP1 batch conversion only, not context or pipeline parallelism. TE retains its existing backend-owned preparation.
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] or [tokens], which the decoder squeezes to [tokens]. Later pipeline stages pass hidden states of shape [batch, sequence, hidden] or [1, tokens, hidden].
Optional positions of shape [batch, sequence], or [1, tokens] for packed input; packed input without them is numbered 0 to tokens - 1 across the whole pack.
Optional padding mask of shape [batch, sequence], 1 at valid tokens and 0 at padding, for unpacked input; 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 passes cu_seqlens and
cu_seqlens_padded of shape [1, documents + 1], padded with -1000, and max_seqlen; it is
selected by qkv_format="thd" or by cu_seqlens with a batch of one.
Returns: CausalLMOutputWithPast
CausalLMOutputWithPast whose logits have shape [batch, kept, vocab], or [1, kept, vocab] for packed
Bases: Module
Run decoder layers, preparing private FA4 metadata once per model call.
Parameters:
Token IDs [batch, sequence] or physical THD IDs [1, tokens] (or [tokens]), squeezed to
[tokens] for the layers. THD offsets with a singleton batch select THD without qkv_format.
Optional positions with the same token layout.
Optional BSHD padding mask [batch, sequence].
Optional bool mask with the token layout of input_ids, True at physical THD padding.
Original THD offsets [documents + 1], maxima and layout; private FA4 offsets index compact valid tokens. Inputs are not mutated.
Returns: torch.Tensor
Hidden states [batch, sequence, hidden], or [1, physical_tokens, hidden] for THD input.