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

[feat] OSS flatten state dict #65

Merged
merged 7 commits into from
Sep 9, 2020
Merged

[feat] OSS flatten state dict #65

merged 7 commits into from
Sep 9, 2020

Conversation

blefaudeux
Copy link
Contributor

@blefaudeux blefaudeux commented Sep 4, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
  • Did you read the contributor guideline?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Changes the structure of the returned state dict with respect to the param_groups to make it closer to what a vanilla optimizer would return (un-shard them). Shard again when loading

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.

Did you have fun?

Make sure you had fun coding 🙃

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 4, 2020
@blefaudeux blefaudeux changed the title Oss flatten state dict [feat] OSS flatten state dict Sep 4, 2020
@blefaudeux
Copy link
Contributor Author

cc @mannatsingh

fairscale/optim/oss.py Outdated Show resolved Hide resolved
fairscale/optim/oss.py Outdated Show resolved Hide resolved
fairscale/optim/oss.py Outdated Show resolved Hide resolved
fairscale/optim/oss.py Outdated Show resolved Hide resolved
@@ -119,7 +119,7 @@ def closure():
print(f"[{dist.get_rank()}] : Mean speed: {mean:.2f} +/- {std:.2f}")

if use_oss and check_regression and dist.get_rank() == 0:
assert (mean - 3.0 * std) < reference_speed, "Speed regression detected"
assert (mean + 3.0 * std) > reference_speed, "Speed regression detected"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was wrong, fixed in another PR but might as well be fixed here (I was bumping into this locally)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(we want the speed to increase, not decrease.. the test initially made sense when comparing runtime, now that it compares frames per second higher is better)

parser.add_argument("--check_regression", action="store", default=True, type=bool)
parser.add_argument("--reference_speed", action="store", default=39.82, type=float)
parser.add_argument("--check_regression", action="store_true", default=False)
parser.add_argument("--reference_speed", action="store", default=32.32, type=float)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

39 was the default speed for SGD, I had changed that earlier to RMSProp when checking for the memory pressure, somehow this change was lost

@blefaudeux blefaudeux merged commit 4f59723 into master Sep 9, 2020
@blefaudeux blefaudeux deleted the oss_flatten_state_dict branch September 9, 2020 18:55
myleott pushed a commit that referenced this pull request Feb 22, 2021
* add unit test pack/unpack kwargs

* added two more corner cases

* more doc and more tests

* more corner cases

* formatting

* Update fairscale/utils/containers.py

Co-authored-by: Sam Shleifer <sshleifer@gmail.com>

* with pytest.raises is awesome

* addressed comment

* add tuple to be tested

Co-authored-by: Sam Shleifer <sshleifer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants