Forward reduce_batch_size_fn in find_executable_batch_size decorator factory - #4166
Open
icn5381 wants to merge 1 commit into
Open
Forward reduce_batch_size_fn in find_executable_batch_size decorator factory#4166icn5381 wants to merge 1 commit into
icn5381 wants to merge 1 commit into
Conversation
…factory The parenthesized decorator form dropped the reduce_batch_size_fn argument when building its functools.partial, so a custom batch-size reducer was silently ignored and the default multiply-by-0.9 behavior was always used. The custom reducer is only reachable through this factory form, which made the parameter unusable despite being documented.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
find_executable_batch_size's parenthesized decorator form dropsreduce_batch_size_fnwhen building itsfunctools.partial, so a custom batch-size reducer is silently ignored and the default multiply-by-0.9 behavior always runs:Since the first positional parameter is the function itself, the factory form is the only way to pass a custom reducer — the parameter added in #3071 has been unusable, and it is documented in the docstring.
Fix
The
functools.partialnow forwardsreduce_batch_size_fnalongsidestarting_batch_size.Verification
test_custom_reduce_batch_size_fnasserts the custom reducer is called and its return value is used: fails onmain, passes with the fix.tests/test_memory_utils.py: 8 passed.