nemo_automodel.components.speculative.dflash.cached_data
nemo_automodel.components.speculative.dflash.cached_data
Read the unshifted tensor rows produced by SpecForge’s DFlash visual scoring capture.
Module Contents
Classes
Functions
Data
API
Bases: CachedDFlashRow
A right-padded batch of cache rows, with each row treated as one document.
Settings for a cache-backed DFlash dataloader.
Build a cache reader and its CPU dataloader.
Parameters:
Exact teacher model ID or path recorded at capture.
Decoder layer indices in hidden-state concatenation order.
Width of one teacher layer.
Size of the teacher’s output vocabulary.
DFlash block size, including the unmasked anchor token.
Token used for the masked draft positions.
In-vocabulary token used to pad uneven batches.
Shard samples across the default process group.
Returns: DataLoader[CachedDFlashRow]
Dataloader yielding right-padded CPU batches as defined by
Bases: Dataset[CachedDFlashRow]
Read one SpecForge .ckpt per item, in lexicographic filename order.
A manifest.json identifies the capture and its settings. Setup reads the
manifest and enumerates the files. Tensors are read and validated on demand.
The trainer determines full-block anchor eligibility after batching.
Load an unshifted record on CPU.
Parameters:
Index into the sorted checkpoint files.
Returns: CachedDFlashRow
Int64 input_ids and binary loss_mask of shape [sequence].
Return the number of cached rows.
Bases: typing.TypedDict
One unpadded record with token ids, assistant mask and optional scores of shape [sequence], and target hidden states of shape [sequence, layers * hidden].
Batch right-padded rows, keeping their original sequence boundaries.
Parameters:
Cache records with input_ids, loss_mask, and optional
visual_score of shape [sequence] and hidden_states of shape
[sequence, layers * hidden]. Sequences can have different lengths.
Valid vocabulary ID used for padding input ids.
Returns: CachedDFlashBatch
input_ids, loss_mask, attention_mask, position_ids,