Skip to content

Change set_learning_rate_tensor #3945

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

Closed
wants to merge 1 commit into from

Conversation

spcyppt
Copy link
Contributor

@spcyppt spcyppt commented Apr 8, 2025

Summary:
The change in D71010630 breaks aps_models/examples/dlrm/tutorials:test_kernel_apf_dlrm_with_basic_training_demo, which potentially breaks apf_dlrm bento kernel.

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor []] is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

See Full error log

TBE has a method to set learning rate, i.e., set_learning_rate(lr) where lr is the learning rate value to be set.

D71010630 removes optimizer_args.learning_rate (float) and introduces self.learning_rate_tensor (tensor). Hence setting learning rate value means changing the value of the leanring_rate_tensor. We changed this by using tensor._fill(lr).

However, this seems to break bento kernel which is built from APF code, which causes issues when an in-place operation occurs i.e., tensor._fill(lr).

The workaround is to create a new tensor to avoid the in-place operation. The change passes the test

https://www.internalfb.com/intern/testinfra/testconsole/testrun/3659174972188704/

Reviewed By: sryap, nautsimon

Differential Revision: D72617537

Summary:
The change in D71010630 breaks `aps_models/examples/dlrm/tutorials:test_kernel_apf_dlrm_with_basic_training_demo`, which potentially breaks `apf_dlrm` bento kernel. 

```
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor []] is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
```
See [Full error log](https://www.internalfb.com/intern/everpaste/?handle=GHmNRBnyyiCXTVkCAP28ClWARWwPbswMAAAz)

TBE has a method to set learning rate, i.e., `set_learning_rate(lr)` where `lr` is the learning rate value to be set.

D71010630 removes `optimizer_args.learning_rate` (float) and introduces `self.learning_rate_tensor` (tensor). Hence setting learning rate value means changing the value of the `leanring_rate_tensor`. We changed this by using `tensor._fill(lr)`.

However, this seems to break bento kernel which is built from APF code, which causes issues when an in-place operation occurs i.e.,  `tensor._fill(lr)`.


The workaround is to create a new tensor to avoid the in-place operation. The change passes the test

https://www.internalfb.com/intern/testinfra/testconsole/testrun/3659174972188704/

Reviewed By: sryap, nautsimon

Differential Revision: D72617537
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D72617537

Copy link

netlify bot commented Apr 8, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit 1716b8e
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/67f4c60b5c2de300082eadf7
😎 Deploy Preview https://deploy-preview-3945--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 7bb8db2.

q10 pushed a commit to q10/FBGEMM that referenced this pull request Apr 10, 2025
Summary:
Pull Request resolved: facebookresearch/FBGEMM#1030

X-link: pytorch#3945

The change in D71010630 breaks `aps_models/examples/dlrm/tutorials:test_kernel_apf_dlrm_with_basic_training_demo`, which potentially breaks `apf_dlrm` bento kernel.

```
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor []] is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
```
See [Full error log](https://www.internalfb.com/intern/everpaste/?handle=GHmNRBnyyiCXTVkCAP28ClWARWwPbswMAAAz)

TBE has a method to set learning rate, i.e., `set_learning_rate(lr)` where `lr` is the learning rate value to be set.

D71010630 removes `optimizer_args.learning_rate` (float) and introduces `self.learning_rate_tensor` (tensor). Hence setting learning rate value means changing the value of the `leanring_rate_tensor`. We changed this by using `tensor._fill(lr)`.

However, this seems to break bento kernel which is built from APF code, which causes issues when an in-place operation occurs i.e.,  `tensor._fill(lr)`.

The workaround is to create a new tensor to avoid the in-place operation. The change passes the test

https://www.internalfb.com/intern/testinfra/testconsole/testrun/3659174972188704/

Reviewed By: sryap, nautsimon

Differential Revision: D72617537

fbshipit-source-id: d3b84e872e6b68d7c2a7da5b1380e3d355393c94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants