Skip to content

feat(python): allow StreamingDataset to reuse a persisted permutation plan #4016

Open

Description

@sarwarbhuiyan

SDK

Python

Problem

StreamingDataset always constructs a new in-memory permutation in __init__:

# Build the permutation table once, deterministically.
builder = permutation_builder(table)
if filter is not None:
builder = builder.filter(filter)
if shuffle:
perm_seed = shuffle_seed + epoch * _EPOCH_PRIME
self._perm_table = builder.split_random(
fixed=num_splits, seed=perm_seed, clump_size=shuffle_clump_size
).execute()
else:
self._perm_table = builder.split_sequential(fixed=num_splits).execute()
# Contiguous block of global split indices assigned to this rank.
splits_per_rank = num_splits // world_size
rank_start = rank * splits_per_rank
self._rank_splits: list[int] = list(
range(rank_start, rank_start + splits_per_rank)
)

In a typical torchrun job, every rank therefore repeats the filtered row-ID scan, sort, shuffle, and plan materialization. A caller can persist a normal permutation table separately, including on local NVMe while the base table is in S3 or behind a query node, but StreamingDataset cannot consume it.

This adds startup work and client memory and makes it harder to reuse one reviewed training plan across ranks and later runs.

Desired behavior

Allow StreamingDataset to open a caller-supplied permutation table (or equivalent persisted plan handle) instead of always building a new one.

Acceptance criteria

  • Accept a prebuilt permutation table containing row_id and split_id for either a direct or remote base table.
  • Construction with a supplied plan performs no base-table planning scan.
  • All ranks can open the same immutable plan and receive the same split assignments as the current internally built path.
  • Validate the requested split count and reject incompatible plan metadata rather than silently rebuilding.
  • Permit the plan table and base table to use different connections, for example a local-NVMe plan with an s3:// base table.
  • Define worker serialization without requiring every spawned worker to materialize an independent Arrow copy of a large persisted plan.
  • Add direct and mocked-remote tests, including more than one rank and spawned DataLoader workers.

Out of scope

This issue is about reusing row order and split membership. It does not cache projected feature or audio bytes and does not define weighted sampling or duration batching.

Activity

  1. added
    enhancement
    Python
    needs-design
    on Aug 21, 2026
  2. Sravan1011 commented on Aug 25, 2026

    @Sravan1011
    Contributor

    @sarwarbhuiyan can I try this out ?

  3. sarwarbhuiyan commented on Aug 25, 2026

    @sarwarbhuiyan
    ContributorAuthor

    Sure try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pythonenhancementneeds-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions