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

Optimizer torch optimizer performance #482

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

haifeng-jin
Copy link
Collaborator

@haifeng-jin haifeng-jin commented Jul 14, 2023

Reimplemented SGD optimizer for torch backend with the torch parallel functions.
It process all the variables in parallel.
Before this PR, if executed eagerly, the variables would be updated in series.

Copy link
Member

@fchollet fchollet 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 the PR!

keras_core/backend/torch/optimizers/sgd.py Outdated Show resolved Hide resolved
keras_core/backend/torch/optimizers/sgd.py Outdated Show resolved Hide resolved
keras_core/backend/torch/optimizer.py Outdated Show resolved Hide resolved
keras_core/backend/torch/optimizers/sgd.py Outdated Show resolved Hide resolved
@@ -21,7 +21,7 @@ def test_config(self):
def test_single_step(self):
optimizer = SGD(learning_rate=0.5)
self.assertEqual(len(optimizer.variables), 2)
grads = np.array([1.0, 6.0, 7.0, 2.0])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we need to support np.array for apply_gradients? @fchollet

Copy link
Member

Choose a reason for hiding this comment

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

No we don't.

@haifeng-jin haifeng-jin changed the title [WIP] Optimizer torch optimizer performance Optimizer torch optimizer performance Jul 17, 2023
Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@fchollet fchollet merged commit 01a0326 into keras-team:main Jul 17, 2023
5 checks passed
@haifeng-jin haifeng-jin deleted the benchmark branch July 17, 2023 23:08
adi-kmt pushed a commit to adi-kmt/keras-core that referenced this pull request Jul 21, 2023
* add torch optimizers

* addressing comments

---------

Co-authored-by: Haifeng Jin <[email protected]>
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.

2 participants