nemo_automodel.components.datasets.llm.dspark_cache
nemo_automodel.components.datasets.llm.dspark_cache
On-disk format and reader for DSpark offline target supervision.
The DSpark online recipe runs a frozen target model every step to capture the
intermediate target features used by the draft and the final hidden state used
for the TV / confidence losses. This module owns the disk format that lets a
precompute job write those tensors once and lets training stream them later via
recipe_args.cached_target_path without loading the target model.
Module Contents
Classes
Functions
Data
API
Bases: CachedTensorDataset
Read DSpark offline cache shards lazily.
Stack per-sample cache dicts into a batch.
Assemble the DSpark cache manifest.
Single source of the manifest schema: both precompute entry points call this, and
train_dspark validates cached training against these fields, so adding or
renaming a field here is the one place the contract changes.
Beyond the tensor-shaping target/cache settings, the manifest records the input identity of the run (dataset path/split, shuffle seed, masking settings, effective chat template): a rerun into an existing directory with a different input therefore fails the manifest-compatibility check instead of silently interleaving old and new supervision shard by shard.
Build a dataloader over a precomputed DSpark cache directory.
Convert one captured DSpark target batch into the on-disk cache tensors.
Shared by the single-process and distributed precompute entry points so both
producers emit byte-identical cache fields (CACHE_KEYS).
Reject a cache whose producer did not finish writing.
The precompute entry points write the manifest with complete: false
before the first shard and flip it to true only after every shard has
been written, so an interrupted (or still-running) precompute cannot be
consumed as a valid cache. Manifests written before the marker existed
have no complete field and are accepted.
Return the manifest keys whose values differ, ignoring bookkeeping fields.
format_version and the complete marker describe the on-disk state,
not the run configuration, so they never count as a mismatch.
Load and validate the DSpark cache manifest.
allow_incomplete is for the precompute producers themselves (compat
checks against a partially written directory); consumers keep the default
so an interrupted precompute is never read as a valid cache.
Load target weights and return module-like objects exposing .weight.
Return a stable identity for the tokenizer’s effective (post-override) chat template.
Persist the DSpark cache manifest.
Write one DSpark cache shard.
Persist target embedding and lm_head weights for target-free draft initialization.