nemo_automodel.components.datasets.loader
nemo_automodel.components.datasets.loader
Typed, data-parallel-aware dataloader construction.
- :class:
ParallelAwareDataloaderis a stateful, data-parallel-awareDataLoader: it shards anIterableDataset(or attaches a distributed / length-grouped sampler to a map-style dataset) for(dp_rank, dp_world_size)and inheritsStatefulDataLoaderfor per-rank checkpoint resume. - :class:
DataloaderConfigowns dataset, sampler, packing, and dataloader construction. Runtime-only objects such as tokenizers and the rank-ordering context are explicit :meth:DataloaderConfig.buildarguments.
Module Contents
Classes
Functions
Data
API
Dataset config whose build implementation performs collectives across all ranks.
Typed construction contract for a dataset-specific batch sampler.
Build a per-rank batch sampler for a materialized dataset.
Construction-time configuration for a tokenizer-aware collator class.
Instantiate the collator once with its runtime tokenizer or processor.
Parameters:
Runtime tokenizer or multimodal processor used by the collator.
Returns: CollateFn
Callable collator passed to the dataloader.
A typed dataset config + loader settings; :meth:build produces a :class:ParallelAwareDataloader.
dataset_config is a typed per-dataset config (for example ChatDatasetConfig or
GLUE_MRPCConfig); the dataset’s declarative arguments live there. Runtime dependencies are explicit
:meth:build arguments, while supported DataLoader settings are named fields on this config.
Whether dataset construction must bypass rank-zero-first ordering.
Materialize only the dataset inside the caller-provided ordering context.
Build the configured dataset, packing, sampler, collator, and stateful dataloader.
Parameters:
Rank within the data-parallel group.
Size of the data-parallel group.
Whether pipeline parallelism requires dropping incomplete batches.
Runtime tokenizer or multimodal processor for tokenizer-aware datasets and collators.
Optional caller-owned rank-ordering context used only while materializing the
dataset. Collective dataset builders should pass None.
Whether the model forward contract accepts THD seq_lens metadata.
Context-parallel world size used for packed-sequence divisibility.
Attention backend used by NEAT packing.
Optional recipe-owned wrapper around the resolved collator.
Returns: DataLoader
Stateful, data-parallel-aware dataloader.
Training schedule values required while materializing schedule-aware datasets.
Bases: PackingConfig
NEAT (bin-packed) packing paired with neat_packed_collater.
Pack with NEAT and configure the collator for the selected attention implementation.
Base config for sequence packing; None (no config) means no packing.
Subclasses (:class:ThdPackingConfig / :class:NeatPackingConfig) pick the packing strategy and the
matching collater. :meth:build returns (dataset, collate_fn) — the packed dataset and the
packing-specific collater. Construction-time knobs are the fields; runtime / model-derived values
(split / seed / supports_seq_lens / pad_token_id / cp_size / attn_implementation)
are :meth:build args.
Number of processes used to pre-tokenize an indexable dataset before packing.
Whether the dataset already contains packed samples and must not be repacked.
Materialize lazy tokenization in parallel when packing can consume the full dataset.
Pack dataset and return (dataset, collate_fn).
Bases: StatefulDataLoader
Stateful, data-parallel-aware DataLoader.
Routes a dataset to (dp_rank, dp_world_size): an IterableDataset is sharded (and optionally
buffer-shuffled); a map-style dataset gets the default distributed (or length-grouped) sampler with
batch_size and drop_last under PP. Inherits StatefulDataLoader for per-rank checkpoint resume.
Dataset config whose build contract has no runtime dependencies.
Build the configured dataset.
Bases: TokenizerDatasetConfig
Dataset config that additionally consumes the recipe training schedule.
Build the configured dataset with tokenizer and schedule dependencies.
Bases: PackingConfig
THD (flattened, seq_lens-based) packing; pairs with packed_sequence_thd_collater.
Requires a model whose forward accepts seq_lens — packing is skipped (with a warning) otherwise.
Pack with THD; returns (dataset, None) if the model does not accept seq_lens.
Dataset config whose build contract accepts a runtime tokenizer or processor.
Build the configured dataset with a runtime tokenizer or processor.
Fallback shim for a dataset _target_ that has no typed <Name>Config.
:func:make_dataset_config maps known datasets onto their typed config; the few
targets with no config yet (a handful of VLM make_* factories) land here instead. Wraps the target so
it satisfies the typed dataset build contract. Config resolution records whether the external target accepts
a tokenizer, and :meth:build forwards only that explicit runtime dependency.
Call the wrapped dataset target with its declared YAML arguments.
Parameters:
Runtime tokenizer or processor. It is forwarded only when the target explicitly declares
a tokenizer parameter; that compatibility decision is recorded once at config resolution.
Returns: object
Dataset object returned by the configured target.
Build the default map-style sampler (distributed, or length-grouped).
Resolve target via registry, a dotted import path, or pass it through unchanged.
target may be a key in registry (whose value is the object itself or a dotted path to it), a
dotted import path ("pkg.mod.attr"), or an already-resolved object (returned as-is). This backs the
make_* resolvers below so packing configs, collate fns and sampler factories share one lookup.
Set the multiprocessing start method to spawn if not already set.
Shard an IterableDataset across data-parallel ranks for unique samples.
Calls the dataset’s own shard or HuggingFace split_dataset_by_node.
Resolve a collate target into a batch callable or tokenizer-aware config.
target is a built-in collator key (for example "default"), a dotted import path, or an already
resolved callable. Collator classes become :class:CollatorConfig so :meth:DataloaderConfig.build
instantiates them once with the runtime tokenizer. Function kwargs remain partial-bound per batch.
Resolve a dataset _target_ to an object exposing a typed build method.
Exact legacy registrations map a pre-config dataset class or make_* factory onto its typed
<Name>Config without class-name dispatch. Misses fall back to the _target_ itself, so a target that
already names a config imports directly. Typed config fields are validated before construction; external
factories use :class:_LegacyDatasetConfig.
Resolve a packing-config target and construct it from kwargs (target=None → no packing).
target is either a built-in strategy key ("thd" / "neat") or a dotted import path to
a :class:PackingConfig subclass (e.g. "my_pkg.MyPackingConfig"). Strategy-specific fields from the
union-shaped packed_sequence YAML block are accepted and filtered for the selected strategy; unknown
fields are rejected instead of silently disappearing.