Skip to content

Commit 4133f7f

Browse files
author
pytorchbot
committed
2025-12-05 nightly release (2196694)
1 parent 6be694e commit 4133f7f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

torchdata/nodes/adapters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ def reset(self, initial_state: Optional[Dict[str, Any]] = None):
123123
if initial_state is not None:
124124
self._num_yielded = initial_state[self.NUM_YIELDED_KEY]
125125
self.epoch = initial_state[self.EPOCH_KEY]
126+
if hasattr(self.sampler, "set_epoch"):
127+
# Always first set epoch, even if sampler is Stateful. Some Stateful
128+
# samplers may have some specific handling to overwrite this.
129+
self.sampler.set_epoch(self.epoch)
126130
if isinstance(self.sampler, Stateful):
127131
self.sampler.load_state_dict(initial_state[self.SAMPLER_KEY])
128132
self._it = iter(self.sampler) # type: ignore [assignment]
129133
else:
130-
if hasattr(self.sampler, "set_epoch"):
131-
self.sampler.set_epoch(self.epoch)
132134
self._it = iter(self.sampler)
133135
for i in range(self._num_yielded):
134136
try:

0 commit comments

Comments
 (0)