Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions xtuner/v1/datasets/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __iter__(self) -> Iterator[int]:

def __len__(self) -> int:
"""The number of samples in this rank."""
# TODO: not same with LengthGroupedSampler?
return self.num_samples - self.step

def set_epoch(self, epoch: int) -> None:
Expand Down Expand Up @@ -137,10 +138,11 @@ def load_state_dict(self, state_dict) -> None:
)

def get_state_dict(self, step: int):
self.step = step % self.total_size
# Attention! Do not set self.step here, or it will cause the next __iter__ to get less samples.
# self.step = step % self.total_size
return {
"epoch": self.epoch,
"step": self.step,
"step": step,
"world_size": self.world_size,
"shuffle": self.shuffle,
"round_up": self.round_up,
Expand Down Expand Up @@ -291,7 +293,8 @@ def get_state_dict(self, step: int):
Returns:
dict: The state of the sampler.
"""
self.step = step % self.total_size
# Attention! Do not set self.step here, or it will cause the next __iter__ to get less samples.
# self.step = step % self.total_size
return {
"epoch": self.epoch,
"step": self.step,
Expand Down
Loading