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

Fix accelerator in tests/test_train.py #595

Merged
merged 2 commits into from
Aug 24, 2023
Merged

Conversation

caplett
Copy link
Contributor

@caplett caplett commented Aug 18, 2023

Fix typo in test docstring.

What does this PR do?

The test reads like it should and is executed on CPU.
Now the test docstring is consistend.

Before submitting

  • Did you make sure title is self-explanatory and the description concisely explains the PR?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you test your PR locally with pytest command?
  • Did you run pre-commit hooks with pre-commit run -a command?

Did you have fun?

Indeed :)

Fix typo in test docstring.
@caplett
Copy link
Contributor Author

caplett commented Aug 18, 2023

After looking in the test again new questions came up.

It has 'RunIf(min_gpus=1)' and has 'gpu' in the function name.
At the same time it is executed on cpu and has 'pytest.mark.slow'.

For me this seems inconsistent.

Do i have a wrong understanding about whats happening here?

@@ -37,7 +37,7 @@ def test_train_fast_dev_run_gpu(cfg_train: DictConfig) -> None:
@RunIf(min_gpus=1)
@pytest.mark.slow
def test_train_epoch_gpu_amp(cfg_train: DictConfig) -> None:
"""Train 1 epoch on GPU with mixed-precision.
"""Train 1 epoch on CPU with mixed-precision.
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering @RunIf(min_gpus=1) and the name of the function being test_train_epoch_gpu_amp, I would assume that it would make more sense to instead change cfg_train.trainer.accelerator and set it to gpu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i would go with this reasoning as well.
I pushed a commit changing that.

What about the pytest.mark.slow decorator?
The test does not do a fast_dev_run like the gpu test before, but is still run on gpu an should be therfore somewhat fast.

Do you have any thoughts on that?

Copy link
Owner

Choose a reason for hiding this comment

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

My rule of thumb was to mark as slow everything that runs for full epoch or more. I guess this will be fast on gpu and mnist but might not if someone uses bigger dataset. Overall I don't think it's worth to think about this detail too much

    * use gpu instead of cpu
    * change docstring to represent usage of gpu
    * remove pytest.slow decorator
Copy link
Owner

@ashleve ashleve left a comment

Choose a reason for hiding this comment

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

Thanks for noticing this and fixing the inconsistency!

@ashleve ashleve merged commit 271972c into ashleve:main Aug 24, 2023
@ashleve ashleve changed the title Fix Typo in tests/test_train.py docstring Fix accelerator in tests/test_train.py docstring Aug 24, 2023
@ashleve ashleve changed the title Fix accelerator in tests/test_train.py docstring Fix accelerator in tests/test_train.py Aug 24, 2023
@ashleve ashleve added the bug Something isn't working label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants