[UlyssesSPDataLoaderAdapter] fix iterator reset (#7472)

Fixes https://github.com/snowflakedb/ArcticTraining/issues/254 - to
support multi-epoch training with `UlyssesSPDataLoaderAdapter`.

Thanks to @yanrui27 for the fix

Signed-off-by: Stas Bekman <stas@stason.org>
Co-authored-by: Rui Yan <49115835+yanrui27@users.noreply.github.com>
This commit is contained in:
Stas Bekman
2025-08-11 13:45:10 -07:00
committed by GitHub
parent a12de38db6
commit d75196a098

View File

@ -497,8 +497,12 @@ class UlyssesSPDataLoaderAdapter:
return self.micro_batches.pop(0)
def refill(self):
# this will raise StopIteration when empty
batch = next(self.iter)
# reset the iterator if StopIteration arrives, and re-raise it to allow multiple epochs to run
try:
batch = next(self.iter)
except StopIteration:
self.iter = iter(self.dl)
raise StopIteration
micro_batches = defaultdict(dict)
# XXX: replace with more efficient all-to-all?