Skip to content

Conversation

@0phoff
Copy link
Contributor

@0phoff 0phoff commented Jul 27, 2018

I opened an issue explaining some of my frustrations with the current state of schedulers.
While most points that I raised in that issue need to be discussed more thoroughly before being implemented, there are some that are not so difficult to fix.

This PR changes the way the LambdaLR scheduler gets serialized:

The lr_lambda functions are only saved if the are callable objects (which can be stateful).
There is no point in saving functions/lambdas as you need their definition before unpickling and they are stateless.

This has the big advantage that the scheduler is serializable, even if you use lambda functions or locally defined functions (aka a function in a function).

Does this functionality need any unit tests?

@fmassa
Copy link
Member

fmassa commented Jul 27, 2018

Adding a test would be great!

@soumith
Copy link
Contributor

soumith commented Jul 27, 2018

this looks good. add a smoke test and this is good to go.

0phoff added 2 commits July 30, 2018 11:20
The lr_lambda functions are only saved if the are callable objects (which can be stateful).
There is no point in saving functions/lambdas as you need their definition before unpickling.
@0phoff 0phoff force-pushed the serialize_lambdalr branch from 797864f to 66d924b Compare July 30, 2018 09:20
@0phoff
Copy link
Contributor Author

0phoff commented Jul 30, 2018

@fmassa, @soumith I added 2 unit tests, which (de)serialize the LambdaLRScheduler with a function and with a callable object.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary:
I opened an issue explaining some of my frustrations with the current state of schedulers.
While most points that I raised in [that issue](pytorch#8741 (comment)) need to be discussed more thoroughly before being implemented, there are some that are not so difficult to fix.

This PR changes the way the LambdaLR scheduler gets serialized:
> The lr_lambda functions are only saved if the are callable objects (which can be stateful).
> There is no point in saving functions/lambdas as you need their definition before unpickling and they are stateless.

This has the big advantage that the scheduler is serializable, even if you use lambda functions or locally defined functions (aka a function in a function).

Does this functionality need any unit tests?
Pull Request resolved: pytorch#9927

Differential Revision: D9055505

Pulled By: soumith

fbshipit-source-id: 6c1cec588beedd098ec7d2bce6a9add27f29e48f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants