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

Apex with DataParallel fixes #1032

Merged
merged 7 commits into from Dec 14, 2020
Merged

Apex with DataParallel fixes #1032

merged 7 commits into from Dec 14, 2020

Conversation

and-kul
Copy link
Contributor

@and-kul and-kul commented Dec 13, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contribution guide?
  • Did you check the code style? catalyst-make-codestyle && catalyst-check-codestyle (pip install -U catalyst-codestyle).
  • Did you make sure to update the docs? We use Google format for all the methods and classes.
  • Did you check the docs with make check-docs?
  • Did you write any new necessary tests?
  • Did you check that your code passes the unit tests pytest . ?
  • Did you add your new functionality to the docs?
  • Did you update the CHANGELOG?

Description

  1. Allow apex for key-value model
  2. Allow apex+opt_level="O2"+DataParallel

Related Issue

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

@pep8speaks
Copy link

pep8speaks commented Dec 13, 2020

Hello @and-kul! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-12-14 17:39:18 UTC

Comment on lines +64 to +65
if isinstance(model, nn.Module):
model = nn.Sequential(model)
Copy link
Member

Choose a reason for hiding this comment

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

why are we checking the model for nn.Module, but cast it to nn.Sequential after that?

Comment on lines +69 to +70
model = torch.nn.DataParallel(model[0])
model = _patch_forward(model)
Copy link
Member

Choose a reason for hiding this comment

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

okay, that looks like really tricky solution

else tensor
)

model.forward = lambda *args, old_fwd=model.forward, input_caster=input_caster_lambda, output_caster=output_caster_lambda, **kwargs: apex.amp._initialize.applier(
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to use **kwargs with this hack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

@and-kul
Copy link
Contributor Author

and-kul commented Dec 14, 2020

Changelog is updated, codestyle is fixed

@Scitator Scitator merged commit 51428d7 into catalyst-team:master Dec 14, 2020
@and-kul and-kul deleted the apex_dp branch December 15, 2020 11:07
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