nemo_automodel.components.models.deepseek_v41.packing
nemo_automodel.components.models.deepseek_v41.packing
One packed text layout for direct forwards and contiguous context parallelism.
Module Contents
Classes
Functions
API
Compression-aligned packed rows and reversible token coordinates.
Insert alignment padding without changing real token order.
Parameters:
Tensor of shape [batch, original_sequence, …], with arbitrary trailing axes.
Value for padding slots.
Returns: torch.Tensor
Independent tensor [batch, padded_sequence, …], preserving gradients of real tokens.
Restore caller coordinates, returning zeros at original padding slots.
Parameters:
Tensor of shape [batch, padded_sequence, …], with arbitrary trailing axes.
Returns: torch.Tensor
Independent tensor [batch, original_sequence, …] retaining real-token gradients.
Validate packed spans and align document starts for compression groups.
Parameters:
Integer real document lengths [batch, documents] or [documents] for batch one. Zero and -1000 entries denote absent documents.
Optional integer physical span lengths with the same shape. These include existing per-document padding; omitted means documents are directly concatenated.
Original [batch, sequence] dimensions.
Positive multiple for each document’s physical span.
Minimum aligned row length, used to retain a fixed pack budget.
Returns: PackedSequenceLayout
Layout whose tensor fields are documented by PackedSequenceLayout, on seq_lens.device.