Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for https://github.com/instructlab/training/issues/254 #273

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/instructlab/training/multipack_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_effective_samples_per_minibatch(num_tokens_per_gpu):
padding=True,
)
batches = sampler.generate_batches()
return len(dataset) / len(batches)
return len(dataset) / len(batches) if len(batches) > 0 else None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're hitting a scenario where Multipack generated no batches, then we need to either error out and have the calling function handle it (by falling back to DistributedDataSampler, or simply by preventing us from using multipack in the first place.

My recommendation here is to do this:

  • Raise an appropriate exception here (either RuntimeError or DivisionByZeroError)
  • Have the calling function check for this additional exception and fall back to the naive sampler


samples_per_gpu = samples_per_minibatch / num_gpus

Expand Down