-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Editing issue with pickle def with lambda function #23869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening a PR! Let's make the helper function private.
src/transformers/optimization.py
Outdated
@@ -32,6 +32,21 @@ | |||
logger = logging.get_logger(__name__) | |||
|
|||
|
|||
def get_constant_lambda(_=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_constant_lambda(_=None): | |
def _get_constant_lambda(current_step): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/transformers/optimization.py
Outdated
""" | ||
Return 1, independent from args. | ||
|
||
Args: | ||
_ ( *optional*, defaults to None): | ||
Placeholder to argument, used to consistency with args in LambdaLR | ||
|
||
Return: | ||
1 : int - constant lambda for constant scheduler | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a documentation for a private function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete it.
src/transformers/optimization.py
Outdated
@@ -46,7 +61,7 @@ def get_constant_schedule(optimizer: Optimizer, last_epoch: int = -1): | |||
`torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule. | |||
""" | |||
|
|||
return LambdaLR(optimizer, lambda _: 1, last_epoch=last_epoch) | |||
return LambdaLR(optimizer, get_constant_lambda, last_epoch=last_epoch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return LambdaLR(optimizer, get_constant_lambda, last_epoch=last_epoch) | |
return LambdaLR(optimizer, _get_constant_lambda, last_epoch=last_epoch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done refactoring based on function name
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* Editing issue with pickle def with lambda function * fix type * Made helper function private * delete tab --------- Co-authored-by: georgebredis <[email protected]>
* Editing issue with pickle def with lambda function * fix type * Made helper function private * delete tab --------- Co-authored-by: georgebredis <[email protected]>
* Editing issue with pickle def with lambda function * fix type * Made helper function private * delete tab --------- Co-authored-by: georgebredis <[email protected]>
What does this PR do?
In this PR, I address the problem of pickling the constant LR scheduler, which fails during the process (potentially during multi-GPU training, as observed in my case) due to the presence of a lambda function within it.
Fixes #23865 (issue)