Skip to content

Conversation

SkafteNicki
Copy link
Collaborator

@SkafteNicki SkafteNicki commented Sep 4, 2025

What does this PR do?

Fixes #21154
Fixes #20447
Fixes #20231
Fixes #20614

Adds two new arguments to batch size finder: margin which for mode="binsearch" will reduce the found batch size to int(found_batch_size * (1-margin)) to make sure there is some room for GPU allocation afterwards. The first 3 issues linked are different scenarios related to the fact that binsearch sometimes can find a batch size that just barely fits and then when training starts it crashes immediately because the found batch size does not fit in memory anymore.

The second argument added max_val is a simple way for users to specify a maximum batch size that can be found. One case for this arg is to make sure the algorithm does not search for a batch size larger than the dataset.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--21163.org.readthedocs.build/en/21163/

@SkafteNicki SkafteNicki added the feature Is an improvement or enhancement label Sep 4, 2025
@github-actions github-actions bot added pl Generic label for PyTorch Lightning package has conflicts labels Sep 4, 2025
@Borda
Copy link
Member

Borda commented Sep 8, 2025

@SkafteNicki, there are about 9 failing tests...

@SkafteNicki
Copy link
Collaborator Author

putting on hold until #21187 is merged

@SkafteNicki SkafteNicki marked this pull request as draft September 9, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement has conflicts pl Generic label for PyTorch Lightning package
Projects
None yet
2 participants