nemo_automodel.components.datasets.multimodal
nemo_automodel.components.datasets.multimodal
BAGEL-style multimodal data pipeline for packed three-group training.
Ports the subset of upstream BAGEL data needed to feed BAGEL training from
fully AM-native code: VLM SFT, T2I pretrain, and unified image editing. The
packed batch schema is shared by Stage 1 and Stage 2; whether VAE /
flow-matching tensors are consumed is controlled by the model stage.
Submodules
nemo_automodel.components.datasets.multimodal.collate_fnsnemo_automodel.components.datasets.multimodal.datasetsnemo_automodel.components.datasets.multimodal.distributed_iterablenemo_automodel.components.datasets.multimodal.interleavenemo_automodel.components.datasets.multimodal.loadernemo_automodel.components.datasets.multimodal.packingnemo_automodel.components.datasets.multimodal.parquet_utilsnemo_automodel.components.datasets.multimodal.transformsnemo_automodel.components.datasets.multimodal.utilsnemo_automodel.components.datasets.multimodal.video
Package Contents
Classes
Functions
Data
API
Declarative configuration for the packed BAGEL multimodal dataset.
Resolve one inline or YAML/JSON mapping without mutating config state.
Build and initialize the packed BAGEL dataset.
Parameters:
Runtime tokenizer used by the packed dataset.
Runtime BAGEL special-token mapping.
Global distributed rank used for source-data sharding.
Global distributed world size.
Dataloader worker count used to shard source files.
Ranked-training base seed used by worker-start reseeding.
Optional dataset resume state.
Returns: 'PackedDataset'
Initialized packed BAGEL iterable dataset.
Bases: IterableDataset
Base class for rank/worker-aware iterable datasets.
Owns a private rng used only to shuffle file paths deterministically
in set_epoch — NOT used for per-sample randomness. Per-sample
randomness still goes through the Python global random module (see
packing for the reseed hook).
Callable that returns a list of PIL frames for a given file path.
Full BAGEL image transform: resize + to_tensor + normalize.
Used for both ViT input (stride=14) and VAE input (stride=16, via
separate instances). stride is exposed as an attribute so the
dataset can compute patch counts without knowing the transform class.
Bases: DistributedIterableDataset
Builder mixin for interleaved image/text/video sequence plans.
Subclasses still provide __init__ + __iter__ + parse_row
(via ParquetStandardIterableDataset); this class only holds
the per-item append helpers used inside parse_row.
Bases: Module
Resize so longest/shortest edges stay within bounds and both edges are stride-divisible.
Parameters:
Maximum size for the longest edge.
Minimum size for the shortest edge.
Value both edges must be divisible by (ViT patch size).
Maximum total pixels for the full image.
Torchvision interpolation mode (default bicubic).
Whether to apply antialiasing.
Bases: IterableDataset
Greedy pack of samples drawn from weighted groups into token-budgeted batches.
The dataset reseeds at iterator start so AM sees a deterministic BAGEL-compatible packed-data stream regardless of earlier RNG consumption during model construction or checkpoint loading.
Bases: DistributedIterableDataset
Base class: iterate per-(file, row_group) across a list of parquet shards.
Subclasses override parse_row to turn one pandas row into the
dict schema consumed by .packing.PackedDataset.
Bases: DistributedIterableDataset
Iterable over conversation JSONL rows where each row may reference images.
Pass-through wrapper around one packed batch from PackedDataset.
Bases: DistributedIterableDataset
Iterable over a parquet-sharded (image, captions) text-to-image dataset.
Each parquet row is expected to carry:
image: raw image bytes.captions: JSON-encoded{key: caption}dict; one caption is sampled uniformly per row.
The yielded dict carries only one image tensor (the VAE input). Stage 1
models ignore the VAE branch; Stage 2 consumes it via the PackedDataset
vae_image branch + flow-matching loss. No VAE encoding happens in
the data pipeline — just tensor preparation.
Bases: InterleavedBaseIterableDataset, ParquetStandardIterableDataset
Image-editing dataset: (input, instruction, output) chains over parquet.
Row schema (upstream BAGEL seedxedit_multi + compatibles):
image_list: list of raw image bytes (at least 2).
instruction_list: list of lists; instruction_list[i] is a
set of equivalent phrasings for the edit that turns
image_list[i] into image_list[i+1].
Add BAGEL’s four special tokens to a Qwen2 tokenizer and return the ids.
Returns:
tuple (tokenizer, new_token_ids, num_new_tokens) where
Canonical name in AM’s collate-fn registry.
Return the BAGEL-style identity collate (wraps a single packed dict).
Return flattened 2D patch position IDs by direct grid extrapolation.
Return flattened 2D patch position IDs by interpolating to the max grid.
Return a flat list of parquet file paths sharded across ranks.
Directories are split across ranks via
chunk_size = ceil(num_dirs / world_size). Each rank lists its local
directories, repeats the file list to reach num_sampled_data_paths per
directory, then all-gathers across ranks so every rank ends up with the
same combined list.
Return a pyarrow filesystem for parquet_file_path.
pyarrow is imported lazily because not every AM install carries it,
and the import is only needed when an actually-parquet-backed dataset
(T2I, UnifiedEdit) is constructed.
Convert a sequence length into BAGEL’s per-sample loss weight.
Build a BAGEL packed dataset for Stage 1 or Stage 2 training.
grouped_datasets is the YAML dict produced by data/configs/*.yaml.
dataset_info is required and contains the concrete local paths for each
dataset named by grouped_datasets.
Returns the constructed PackedDataset instance. The caller is
still responsible for invoking set_epoch immediately before
DataLoader iteration (and for the pre-iter RNG reseed — see
PackedDataset.set_epoch docstring).
Patchify a CxHxW image tensor into (H/p * W/p, ppC).
Convert a PIL image to RGB, compositing transparent pixels on white.
Build a per-sample additive float mask honoring causal / full / noise splits.