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

Feature/auto batch size find #426

Merged
merged 3 commits into from
Oct 3, 2024
Merged

Conversation

benjijamorris
Copy link
Contributor

What does this PR do?

The auto batch size finder increases the batch size by powers of 2 (starting with batch-size=1) by setting the datamodule's batch_size attribute. This PR allows just the dataframe datamodule (I think the only one used by the plugin) to respond to its batch_size attribute being changed. In order to do this, we store the initial batch size (set to 1) and check for changes to the batch size to update the train dataloaders.

Before submitting

  • Did you make sure title is self-explanatory and the description concisely explains the PR?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you test your PR locally with pytest command?
  • Did you run pre-commit hooks with pre-commit run -a command?

Did you have fun?

Make sure you had fun coding 🙃

@@ -93,6 +100,10 @@ def train(cfg: DictConfig, data=None) -> Tuple[dict, dict]:
log.info("Logging hyperparameters!")
utils.log_hyperparameters(object_dict)

if use_batch_tuner:

Choose a reason for hiding this comment

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

This seems related to the new block up starting on line 62 - could it go up there for readability? Could they also be a single condition (it seems they are logically bound?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I have it split up because the data arguments need to be changed if the batch size tuner is used, but then the actual batch tuning requires an initialized datamodule. I can rearrange things to make them a little closer, but that might be purely aesthetic as they can't be fully grouped.

Copy link

@hughes036 hughes036 left a comment

Choose a reason for hiding this comment

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

I would weight my review low not having much context.

Is a new kwarg is added by this change? It would be good to see some unit test coverage for that but only if a suit exists already.

@benjijamorris
Copy link
Contributor Author

No new kwarg is added - just changing the default value of an existing kwarg.

Copy link
Member

@ritvikvasan ritvikvasan left a comment

Choose a reason for hiding this comment

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

Super useful! Definitely annoying to try to find the largest batch size that fits memory

@benjijamorris benjijamorris merged commit d285e66 into main Oct 3, 2024
4 of 6 checks passed
@benjijamorris benjijamorris deleted the feature/auto_batch_size_find branch October 3, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants