StatefulRandomSampler#
- class StatefulRandomSampler(data_source: Sized, *, shuffle: bool = True, seed: int = 0, epoch: int = 0, num_replicas: int = 1, rank: int = 0, drop_last: bool = False)[source]#
Bases:
Sampler[int]Rank-aware map-style sampler with checkpointable epoch and position.
- load_state_dict(state_dict: dict[str, object], *, strict: bool = True) None[source]#
Restore sampler state, validating dataset length and replica count.
- set_epoch(epoch: int, *, reset_position: bool = True) None[source]#
Change epoch seed and optionally rewind to the start of that order.
- set_position(position: int) None[source]#
Clamp and set the next index position within the current order.
- property remaining: int#
Number of indices left before this rank exhausts the epoch.