nemo_automodel.components.models.inkling2.model
nemo_automodel.components.models.inkling2.model
Native FP32/BF16 Inkling2 text reference with explicit accumulation precision.
Module Contents
Classes
API
Bases: Module
One attention/MoE layer operating on explicit immutable depth state.
Expose the shared MoE CP setup hook without another parameter owner.
Advance a depth block, with a new block beginning after boundary attention.
Parameters:
Completed blocks and partial, each [batch, sequence, hidden].
Boolean tensor of shape [batch, sequence].
Integer tensor of shape [batch, sequence].
Returns: ResidualState
New state with tensors of shape [batch, sequence, hidden]; previous state is unchanged.
Initialize all layer parameters and buffers, including the common experts.
Bases: HFCheckpointingMixin, Module, MoEFSDPSyncMixin
Text implementation using eager or FlexAttention and common Torch experts.
This entry point consumes Inkling2TextConfig; the multimodal subclass inserts projected image features before the same decoder.
Describe carried residual history and token layout at a decoder cut.
Returns: torch.Tensor
Compute-dtype history [batch, sequence, sources, hidden] with completed
Validate contiguous global layer IDs and exclusive parameter ownership.
Apply the callable head, logit softcap and unused-vocabulary mask.
Parameters:
Compute-dtype tensor of shape [batch, sequence, hidden].
Returns: torch.Tensor
FP32 logits [batch, sequence, vocab]; unused vocabulary rows are
Recover differentiable residual views and per-microbatch token metadata.
Parameters:
Compute-dtype [batch, sequence, sources, hidden] residual history.
One int64 [batch, sequence, 2] layout tensor; neither input is mutated.
Returns: ResidualState
Residual state with views [batch, sequence, hidden], boolean validity
Run local layers; transport immutable depth state or apply final-stage modules.
Parameters:
Completed blocks and partial [batch, sequence, hidden].
Boolean token validity [batch, sequence].
Integer token positions [batch, sequence].
Skip final projection for ordinary selected-logit handling.
Returns: torch.Tensor | tuple[torch.Tensor, ...]
Non-final stage history/layout as documented by _pipeline_boundary_metas;
Assign embedding normalization and the final residual query to one owner.
Parameters:
Generated stage FQNs; caller lists are unchanged.
Empty for this native model’s top-level layers.
Backbone resolved by the shared splitter.
Returns: list[list[str]]
Copied FQN lists with embed_norm first and output_query last.
Return unshifted text logits; the shared loss path owns the target shift.
Parameters:
Integer tensor of shape [batch, global_sequence]. Inputs are packed or unpacked rows; the first stage slices them under CP after image splicing. On non-first pipeline stages, this is floating residual history [batch, sequence, sources, hidden] from _pipeline_boundary_metas.
Non-first-stage int64 [batch, sequence, 2] token layout. It carries authoritative positions/validity; repeated mask/position kwargs from the shared schedule are only consumed by the first stage.
Optional decoder-ready [batch, sequence, hidden] embeddings, with text embedding normalization already applied. Supported on the first stage only; token IDs still supply layout.
Optional tensor of shape [batch, sequence], one/true for real tokens. Document boundaries come from position resets, independently of padding.
Optional boolean tensor of shape [batch, local_sequence], true for padding, as supplied by the shared trainer. Combined with attention_mask on the first stage; later stages use the carried validity tensor.
Optional integer tensor of shape [batch, local_sequence], increasing by one within each document, restarting at zero for a new document.
Shared text-pipeline placeholders keyed by attention type. Only None entries are accepted; model-owned masks use validity and positions. Supplied dense masks with arbitrary leading dimensions are rejected.
Optional shared packer real lengths [batch, documents].
Corresponding padded lengths covering each physical row.
Zero for all positions, a positive tail length, or integer indices of shape [kept_sequence]. Used by the shared linear-loss path.
Include final hidden states for external loss; targets are already aligned by the caller and are never shifted here.
Returns: torch.Tensor | tuple[torch.Tensor, ...] | CausalLMOutputWithPast
FP32 logits of shape [batch, kept_sequence, vocab], softcapped before
Construct the text model, from a text or a released image/text configuration.
The constructor accepts both forms; this classmethod keeps the explicit entry point.
Return the untied token lookup; embed_norm is applied in forward.
Return the callable untied head for shared FSDP and output-loss setup.
Supply static shapes/dtypes to Automodel’s shared pipeline runtime.
Parameters:
Whether the runtime identifies this as logical stage zero.
Number of unpacked sequences per microbatch.
Global input sequence length, before additional CP padding.
Body compute dtype, independent of FP32 master storage.
Returns: tuple[torch.Tensor, ...]
First-stage inputs are global int64 [batch, sequence]. Other token
Initialize a fresh or materialized model without a checkpoint.
Prepare packed or unpacked CP labels/layout while retaining full inputs for image splicing.