-
Notifications
You must be signed in to change notification settings - Fork 546
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
improve _optim_ckpt_wrapper so it is a drop in replacement of optimizer #2052
Comments
I've thought about this approach and I do like that it cleans up the recipe. But it adds some indirection and forces users to have to learn what the wrapper even does, and wouldn't it require all optimizers to be wrapped in this regardless of if they're using optimizer in bwd or not? |
I dont think so. The implementation would be something like this:
The idea is that, for example, when you call |
So the point is to avoid all conditions about |
@krammnic, yes! It litters our recipe in many places. It would make the code cleaner and easier to maintain. |
Our recipes are cluttered with logic that checks "if optim_in_bwd".
With a bit of engineering, we can make it a drop in replacement of optimizer, and avoid code like this:
That can be replaced with:
It may break things from time to time, but good testing should avoid errors hitting prod. For overly complex situations, e.g. checkpointing, we can still do if/else, but we definitely don't need every if/else that we have today: A total of 8.
The text was updated successfully, but these errors were encountered: