experanto.utils.FastSessionDataLoader
- class FastSessionDataLoader(dataset, batch_size=1, shuffle=False, num_workers=0, pin_memory=False, drop_last=False, seed=None, **kwargs)[source]
Bases:
objectOptimized multi-session dataloader with state tracking.
Provides efficient data loading across multiple sessions with guarantees:
Each session appears exactly once before repeating
Epoch ends when the longest session is exhausted
Perfect alignment between sessions and batches is maintained
State is properly tracked and can be restored
- Parameters:
dataset (SessionConcatDataset) – Concatenated dataset with session tracking.
batch_size (int, default=1) – Number of samples per batch.
shuffle (bool, default=False) – Whether to shuffle samples within each session.
num_workers (int, default=0) – Number of worker processes for data loading.
pin_memory (bool, default=False) – Whether to pin memory for GPU transfer.
drop_last (bool, default=False) – Whether to drop incomplete batches.
seed (int, optional) – Random seed for reproducibility.
**kwargs – Additional arguments passed to underlying DataLoaders.
See also
SessionConcatDatasetDataset that tracks session membership.
LongCyclerSimpler alternative without state tracking.
Methods
__init__(dataset[, batch_size, shuffle, ...])Return the current state of the dataloader.
set_state(state)Restore the dataloader state.
- __init__(dataset, batch_size=1, shuffle=False, num_workers=0, pin_memory=False, drop_last=False, seed=None, **kwargs)[source]
- __iter__()[source]
Iterate through sessions, cycling through them until all are exhausted.
The iteration scheme ensures: 1. Each session appears exactly once in each cycle 2. Samples within a session are properly batched and optionally shuffled 3. The epoch ends when the longest session is exhausted