Skip to content
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

Remove Automatic Memory Optimization Attribute From Model #176

Merged
merged 24 commits into from Nov 27, 2020

Conversation

mali-git
Copy link
Member

@mali-git mali-git commented Nov 26, 2020

Automatic memory optimization is performed by the TrainingLoop/Evaluator. Therefore, in this PR, we define the automatic memory optimization flag as an attribute of these objects.

@@ -719,7 +718,6 @@ class TestNTNHighMemory(_BaseNTNTest):

model_kwargs = {
'num_slices': 2,
'automatic_memory_optimization': False,
}
Copy link
Member

Choose a reason for hiding this comment

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

Now, TestNTNLowMemory = TestNTNHighMemory?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 364d9e3.

Copy link
Member

Choose a reason for hiding this comment

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

don't forget to explicitly set the evaluator's automatic_memory_optimization

Copy link
Member

Choose a reason for hiding this comment

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

Now i'm wondering if/how these should get passed through to the CLI, which tests the whole pipeline

Copy link
Member

Choose a reason for hiding this comment

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

I solved this in b973e7c, but now I'm wondering if it makes sense to store this as a boolean in instances of the Evaluator class, or rather to just make it an argument to the Evaluator.evaluate() function. This is the last thing I'd like to discuss before finishing/merging this PR (besides passing CI ;))

Copy link
Member Author

@mali-git mali-git Nov 27, 2020

Choose a reason for hiding this comment

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

I was also thinking about it, and in the initial commits, we defined amo as a function argument of Evaluator.evaluate(), and TrainingLoop.train(). But when defining the EarlyStopper, we need to pass the information to the Evaluator, too, so that we might need to define amo as an attribute of the EarlyStopper. Therefore, I prefer to define it directly as an attribute of the Evaluator/TrainingLoop

Copy link
Member

Choose a reason for hiding this comment

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

I think it is something which you either want to have for the whole training / evaluation or not; so it won't change for multiple calls of the evaluate method, which is why storing it as state of the evaluator seems fine for me.

Copy link
Member

Choose a reason for hiding this comment

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

Okay then everything is good as it stands

Copy link
Member

@mberr mberr left a comment

Choose a reason for hiding this comment

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

Really nice to get rid of the Model.__init__'s automatic_memory_optimization forwards to the base class. 🙂

tests/test_training.py Outdated Show resolved Hide resolved
tests/test_training.py Outdated Show resolved Hide resolved
Copy link
Member

@cthoyt cthoyt left a comment

Choose a reason for hiding this comment

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

Excellent idea, @mali-git. Please see my comments - most are related to making sure that both the training loop and evaluator's automatic memory optimization is set explicitly now that it doesn't inherit from the model, as well as the usage of subclasses' super().__init__() to forward variables rather than setting in the subclass

tests/test_evaluators.py Outdated Show resolved Hide resolved
Copy link
Member

@cthoyt cthoyt left a comment

Choose a reason for hiding this comment

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

Push (feelin good on a Wednesday)

@mali-git mali-git merged commit 9191dbb into master Nov 27, 2020
@mali-git mali-git deleted the remove_amo_from_model branch November 27, 2020 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants