nemo_automodel.components.models.inkling2.layers
nemo_automodel.components.models.inkling2.layers
Differentiable Inkling2 primitives and the common MoE integration.
Module Contents
Classes
Functions
API
Bases: Linear
Bias-free output projection with FP32 arithmetic and ordinary FSDP hooks.
Project through the module boundary so FSDP gathers its weight.
Parameters:
Tensor of shape […, hidden], with arbitrary leading dimensions.
Returns: torch.Tensor
FP32 tensor of shape […, vocab]. Weight storage may be FP32 or BF16.
Bases: MoE
Common Gate/GroupedExperts with Inkling2’s activation callable.
Bases: Module
Per-head L2 clipping, optionally preceded by learned per-channel scales.
Clip head vectors, then apply optional length scaling.
Parameters:
Tensor of shape [batch, sequence, heads, head_dim].
Optional FP32 tensor of shape [batch, sequence], applied after clipping.
Returns: torch.Tensor
Tensor of shape [batch, sequence, heads, head_dim], in x’s dtype.
Bases: Module
Callable FP32 owner for one set of depth-mixture queries.
Mix immutable depth state.
Parameters:
Completed and partial blocks, each [batch, sequence, hidden].
Returns: torch.Tensor
FP32 tensor of shape [queries, batch, sequence, hidden].
Immutable depth state; every tensor has shape [batch, sequence, hidden].
Completed depth blocks, including the initial embedding block.
Current incomplete block. Neither field is detached or mutated.
Bases: Module
Causal width-W convolution with static or token-generated per-head taps.
Apply convolution with exchanged CP history, zero document history and masked padding.
Parameters:
Tensor of shape [batch, sequence, channels].
Boolean tensor of shape [batch, sequence], true for real tokens.
Tensor of shape [batch, sequence, hidden] for dynamic taps.
Logical document positions [batch, sequence], including CP offsets. Taps cannot read before the current document start.
Returns: torch.Tensor
Tensor of shape [batch, sequence, channels], in x’s dtype; padding is zero.
Initialize every static and dynamic coefficient without checkpoint data.
Apply the interleaved capped activation, with routing before the down GEMM.
Parameters:
Tensor of shape [tokens, 2 * intermediate], interleaved gate/up.
Tensor of shape [tokens, 1], containing selected expert weights.
Positive gate tanh cap; sigmoid still receives the raw gate.
Positive up tanh cap.
Returns: torch.Tensor
Tensor of shape [tokens, intermediate], in gate_up’s dtype.
Mix depth sources independently at each token in FP32.
Parameters:
Completed blocks and partial, each [batch, sequence, hidden].
Tensor of shape [queries, hidden], with one or three pseudo-queries.
Normalize values as well as scoring keys.
Returns: torch.Tensor
Tensor of shape [queries, batch, sequence, hidden], without mutating state.