Skip to content

Include iteration_ in SGD optimizer serialization#26906

Closed
yf225 wants to merge 1 commit intopytorch:masterfrom
yf225:fix_sgd_serialization
Closed

Include iteration_ in SGD optimizer serialization#26906
yf225 wants to merge 1 commit intopytorch:masterfrom
yf225:fix_sgd_serialization

Conversation

@yf225
Copy link
Copy Markdown
Contributor

@yf225 yf225 commented Sep 26, 2019

This PR fixes #24192 by including the private field iteration_ in SGD optimizer serialization. Under the hood, iteration_ is serialized into an IValue, then stored in a JIT module as an attribute.

@yf225 yf225 requested a review from pbelevich September 26, 2019 18:39
@pytorchbot pytorchbot added the module: cpp Related to C++ API label Sep 26, 2019

/// Counts how often `step()` is called, for dampening.
size_t iteration_{0};
int64_t iteration_{0};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is changed from size_t to int64_t, because IValue doesn't support storing a size_t value.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@yf225 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@yf225 merged this pull request in 3acbcb9.

pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull request Nov 27, 2019
Summary:
This PR fixes pytorch#24192 by including the private field `iteration_` in SGD optimizer serialization. Under the hood, `iteration_` is serialized into an `IValue`, then stored in a JIT module as an attribute.
Pull Request resolved: pytorch#26906

Differential Revision: D17628359

Pulled By: yf225

fbshipit-source-id: beec1367459e973a1c9080dc86f502e4c7bc5ebd
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
This PR fixes pytorch#24192 by including the private field `iteration_` in SGD optimizer serialization. Under the hood, `iteration_` is serialized into an `IValue`, then stored in a JIT module as an attribute.
Pull Request resolved: pytorch#26906

Differential Revision: D17628359

Pulled By: yf225

fbshipit-source-id: beec1367459e973a1c9080dc86f502e4c7bc5ebd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpp Related to C++ API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to restore c++ SGD optimizer state completely if dampening != 0

5 participants