nemo_automodel.components.models.inkling2.context_parallel
nemo_automodel.components.models.inkling2.context_parallel
Contiguous Inkling2 context shards, differentiable KV and convolution halos.
Module Contents
Functions
Data
API
Prepend causal history to masked [batch, local_sequence, channels].
Parameters:
This rank’s shard [batch, local_sequence, channels] with invalid positions already zeroed.
One-dimensional CP mesh; None or a single rank pads with zeros only.
Convolution taps; width - 1 history positions are prepended.
Returns: torch.Tensor
New [batch, local_sequence + width - 1, channels] tensor. Rank zero and positions
Gather equal-length [batch, local_sequence, …] tensors in CP rank order.
Parameters:
This rank’s shard [batch, local_sequence, …]; every rank supplies the same shape and dtype.
One-dimensional CP mesh; None or a single rank returns the input itself.
Route gradients back to each shard’s source rank.
Returns: torch.Tensor
[batch, global_sequence, …] with the shards concatenated in rank order, newly
Return a sharder for packed or unpacked global [batch, sequence] text/image inputs.
IDs, image masks and images remain global for per-microbatch image splicing inside forward. Labels, positions and padding become local. The shared recipes own target alignment and loss normalization; no weights are touched.
Normalize shared THD packs to document positions and validity, in place.
The shared packer supplies real/padded lengths [batch, documents], padded with -1000. Padding is determined from those lengths, never from token IDs: a real EOS remains valid even when the tokenizer also uses it as PAD.
Parameters:
Mutable mapping with input_ids [batch, sequence], seq_lens and seq_lens_padded [batch, documents], optional position_ids and labels [batch, sequence]. Replaces metadata with boolean padding_mask and integer position_ids [batch, sequence]; token IDs and labels are unchanged.
Require unit increments inside documents and zero at a new document.
A contiguous CP shard may begin partway through a document. Later resets explicitly identify new documents; a gap cannot silently resume an old one.
Parameters:
Boolean validity [batch, sequence].
Integer logical positions [batch, sequence]. The first real span may start at a nonzero offset, including after left padding.