Repository navigation
Conversation
…10% instead of 50%
|
Indeed that might be a better default even it might take longer to find the wanted batch size. It would be best also to allow users to pass their own function either with the hook you proposed or fix |
S1ro1
left a comment
There was a problem hiding this comment.
This sounds okay, however don't we want to enforce some limits on the batch size? I.e. be a power of 2, resp. be divisible by 2. Having random batch size isn't very good from a performance standpoint and GPUs in general might struggle with this on some tasks.
True I had that concern as well but looking at different posts, i'm not sure if this is always is the case. Also, the user can also specify a batch size that is not a power of 2 even if this is not generally the case. |
|
I'm on board with the discussion, and agree that further considerations might be necessary. I will be all for:
As they say in that wandb blog:
I believe that both could speed up initial model experimentation, but that probably for a real production training run, both should be avoided. |
I do agree with what you say, however I think main purpose of this, is to have a sensible default. Though given some research I've done and link Marc sent, I haven't found strong evidence for power-of-2/even batch size. With this, I think it's okay to merge and keep this as you suggest. Would you also be interested in creating the mechanism for own heuristics/functions since you started this already? |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Can you fix the tests also since the default changed ? @AmitMY |
|
Fixed the tests that seem relevant. One test failed because of an old torch version it seems, and works on my machine. Can you approve again so we check it passes on github actions? |
|
@bot /style |
|
Style fixes have been applied. View the workflow run here. |
|
I'll recreate the PR as the github ci is broken on this PR |
What does this PR do?
1 / Problem
find_executable_batch_size()currently halves the batch after every OOM.Example: request 128, real limit 100 → old loop jumps straight to 64 -- 36 % throughput lost.
On heterogeneous clusters (T4 ↔ V100 ↔ A100 ↔ H100) users can’t predict the limit in advance.
The escape hatch,
reduce_batch_size_fn, is practically unusable:Trainer, so you can’t pass a custom function.fn() → int— it receives no context (not even the failing batch size), so writing a smart policy is impossible.2 / Fix (this PR)
×0.5fallback with a gentler×0.9loop. Keep shaving 10% until it fits.3 / Why not rely on
reduce_batch_size_fn?4 / Future hook proposal
Accelerator.5 / Risk
bs=1OOMs is unchanged (fast failure).6 / Bottom line
Changing one constant rescues 15–45 % of wasted GPU capacity for heterogeneous clusters users today, while paving the way for a clean plug-in story tomorrow.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?