Skip to content

nexuml.data.loaders.dali_multimodal

nexuml.data.loaders.dali_multimodal

General DALI pipeline helpers for keyed TensorDict outputs.

KeyedDaliIterator

Bases: DALIGenericIterator

DALI iterator that returns (x, y) TensorDict pairs keyed semantically.

ExternalSampleIterator

External source iterator backed by a dataset's __getitem__.

WebDatasetComponentSpec dataclass

Component specification for a WebDataset tar shard.

external_source_pipeline

external_source_pipeline(
    external_source: Iterable, *, num_outputs: int
) -> Any

Build a DALI pipeline backed by an external Python source.

Returns:

Type Description
Any

A single DALI output node when num_outputs == 1,

Any

otherwise a tuple of output nodes.

audio_file_pipeline

audio_file_pipeline(
    *,
    files: list[str],
    target_sr: int,
    mono: bool,
    num_samples: int | None,
    shuffle: bool,
    shard_id: int,
    num_shards: int,
    layout: str | None,
) -> Any

Build a DALI pipeline that decodes audio files from paths.

Returns:

Type Description
Any

Tuple of decoded audio tensor and integer file-index label.

image_file_pipeline

image_file_pipeline(
    *,
    files: list[str],
    shuffle: bool,
    shard_id: int,
    num_shards: int,
    layout: str | None,
) -> Any

Build a DALI pipeline that decodes image files from paths.

Returns:

Type Description
Any

Tuple of decoded image tensor and integer file-index label.

text_file_pipeline

text_file_pipeline(
    *,
    files: list[str],
    shuffle: bool,
    shard_id: int,
    num_shards: int,
) -> Any

Build a DALI pipeline that reads text files as byte strings.

Returns:

Type Description
Any

Tuple of text byte tensor and integer file-index label.

video_file_pipeline

video_file_pipeline(
    *,
    files: list[str],
    shuffle: bool,
    shard_id: int,
    num_shards: int,
    sequence_length: int,
    layout: str | None,
    reader_device: str,
) -> Any

Build a DALI pipeline that decodes video files from paths.

Returns:

Type Description
Any

Tuple of decoded video tensor and integer file-index label.

numpy_file_pipeline

numpy_file_pipeline(
    *,
    files: list[str],
    shuffle: bool,
    shard_id: int,
    num_shards: int,
) -> Any

Build a DALI pipeline that loads numpy array files from paths.

Returns:

Type Description
Any

Tuple of loaded numpy data tensor and integer file-index label.

webdataset_pipeline

webdataset_pipeline(
    *,
    paths: list[str],
    index_paths: list[str] | None,
    shuffle: bool,
    shard_id: int,
    num_shards: int,
    components: list[WebDatasetComponentSpec],
) -> Any

Build a DALI pipeline that reads a WebDataset tar archive.

Returns:

Type Description
Any

Tuple of decoded tensors, one per component.

Raises:

Type Description
ValueError

If a component encoding is unsupported.

build_external_source_loader

build_external_source_loader(
    *,
    dataset: Any,
    x_keys: Sequence[str],
    y_keys: Sequence[str],
    batch_size: int,
    num_threads: int,
    prefetch_factor: int | None,
    shuffle: bool,
    local_rank: int,
    global_rank: int,
    world_size: int,
) -> KeyedDaliIterator

Build a DALI external-source loader from a Python iterable.

Returns:

Type Description
KeyedDaliIterator

A KeyedDaliIterator yielding (x, y) TensorDict pairs.

build_native_file_loader

build_native_file_loader(
    *,
    kind: str,
    files: list[str],
    x_key: str,
    metadata_labels: TensorDict | None,
    batch_size: int,
    num_threads: int,
    prefetch_factor: int | None,
    shuffle: bool,
    local_rank: int,
    global_rank: int,
    world_size: int,
    sample_layout: str | None = None,
    sample_rate: int = 16000,
    sequence_length: int | None = None,
) -> KeyedDaliIterator

Build a DALI native file loader for the given modality.

Returns:

Type Description
KeyedDaliIterator

A KeyedDaliIterator yielding (x, y) TensorDict pairs.

Raises:

Type Description
ValueError

If kind is unsupported or video lacks a sequence length.

build_webdataset_loader

build_webdataset_loader(
    *,
    shard_paths: list[str],
    index_paths: list[str] | None,
    x_keys: Sequence[str],
    y_keys: Sequence[str],
    metadata_labels: TensorDict | None,
    batch_size: int,
    num_threads: int,
    prefetch_factor: int | None,
    shuffle: bool,
    local_rank: int,
    global_rank: int,
    world_size: int,
    components: list[WebDatasetComponentSpec],
) -> KeyedDaliIterator

Build a DALI WebDataset loader from tar archive paths.

Returns:

Type Description
KeyedDaliIterator

A KeyedDaliIterator yielding (x, y) TensorDict pairs.