Skip to content

fix set_data permitting requires_grad=True on integer tensor#78436

Closed
yuguo68 wants to merge 4 commits intogh/yuguo68/6/basefrom
gh/yuguo68/6/head
Closed

fix set_data permitting requires_grad=True on integer tensor#78436
yuguo68 wants to merge 4 commits intogh/yuguo68/6/basefrom
gh/yuguo68/6/head

Conversation

@yuguo68
Copy link
Copy Markdown
Contributor

@yuguo68 yuguo68 commented May 27, 2022

Stack from ghstack (oldest at bottom):

fix #76008

Differential Revision: D36800179

@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented May 27, 2022

🔗 Helpful links

❌ 1 New Failures

As of commit 4c022d6 (more details on the Dr. CI page):

Expand to see more
  • 1/1 failures introduced in this PR

🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages

See GitHub Actions build pull / linux-focal-py3.7-gcc7 / test (backwards_compat, 1, 1, linux.2xlarge) (1/1)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-06-01T01:32:33.1546821Z The PR is introduc...m to confirm whether this change is wanted or not.
2022-06-01T01:32:33.1527843Z processing existing schema:  text(__torch__.torch.classes.profiling.SourceRef _0) -> str _0
2022-06-01T01:32:33.1529380Z processing existing schema:  count(__torch__.torch.classes.profiling.InstructionStats _0) -> int _0
2022-06-01T01:32:33.1531142Z processing existing schema:  duration_ns(__torch__.torch.classes.profiling.InstructionStats _0) -> int _0
2022-06-01T01:32:33.1533050Z processing existing schema:  source(__torch__.torch.classes.profiling.SourceStats _0) -> __torch__.torch.classes.profiling.SourceRef _0
2022-06-01T01:32:33.1535710Z processing existing schema:  line_map(__torch__.torch.classes.profiling.SourceStats _0) -> Dict(int, __torch__.torch.classes.profiling.InstructionStats) _0
2022-06-01T01:32:33.1536589Z processing existing schema:  __init__(__torch__.torch.classes.profiling._ScriptProfile _0) -> NoneType _0
2022-06-01T01:32:33.1538444Z processing existing schema:  enable(__torch__.torch.classes.profiling._ScriptProfile _0) -> NoneType _0
2022-06-01T01:32:33.1540026Z processing existing schema:  disable(__torch__.torch.classes.profiling._ScriptProfile _0) -> NoneType _0
2022-06-01T01:32:33.1542697Z processing existing schema:  _dump_stats(__torch__.torch.classes.profiling._ScriptProfile _0) -> __torch__.torch.classes.profiling.SourceStats[] _0
2022-06-01T01:32:33.1543874Z processing existing schema:  __init__(__torch__.torch.classes.dist_rpc.WorkerInfo _0, str _1, int _2) -> NoneType _0
2022-06-01T01:32:33.1546821Z The PR is introducing backward incompatible changes to the operator library. Please contact PyTorch team to confirm whether this change is wanted or not. 
2022-06-01T01:32:33.1546856Z 
2022-06-01T01:32:33.1546991Z Broken ops: [
2022-06-01T01:32:33.1547396Z 	aten::special_laguerre_polynomial_l(Tensor x, Tensor n) -> Tensor
2022-06-01T01:32:33.1547785Z 	aten::special_laguerre_polynomial_l.out(Tensor x, Tensor n, *, Tensor(a!) out) -> Tensor(a!)
2022-06-01T01:32:33.1548324Z 	aten::special_laguerre_polynomial_l.n_scalar_out(Tensor x, Scalar n, *, Tensor(a!) out) -> Tensor(a!)
2022-06-01T01:32:33.1548661Z 	aten::special_laguerre_polynomial_l.x_scalar(Scalar x, Tensor n) -> Tensor
2022-06-01T01:32:33.1549142Z 	aten::special_laguerre_polynomial_l.x_scalar_out(Scalar x, Tensor n, *, Tensor(a!) out) -> Tensor(a!)
2022-06-01T01:32:33.1549491Z 	aten::special_laguerre_polynomial_l.n_scalar(Tensor x, Scalar n) -> Tensor
2022-06-01T01:32:33.1549823Z 	aten::special_hermite_polynomial_he(Tensor x, Tensor n) -> Tensor
2022-06-01T01:32:33.1550212Z 	aten::special_hermite_polynomial_he.out(Tensor x, Tensor n, *, Tensor(a!) out) -> Tensor(a!)

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@yuguo68 yuguo68 changed the title set data permits requires_grad=True on integer tensor fix set_data permitting requires_grad=True on integer tensor May 27, 2022
yuguo68 added a commit that referenced this pull request May 27, 2022
ghstack-source-id: 3edfc5d
Pull Request resolved: #78436
Copy link
Copy Markdown
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

That makes sense to me as a fix even though it is BC-breaking.
cc @soulitzer do you agree?

Comment thread test/test_torch.py
# Calls model with a LongTensor input but DoubleTensor weights
input = torch.randn(1, 1, 1, 6, dtype=torch.double)
weight = torch.zeros(1, 1, 1, 3, dtype=torch.long)
weight = torch.zeros(1, 1, 1, 3, dtype=torch.complex64)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why change this?

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.

Since torch.long does not support grad, with this PR, this test will fail at this assignment. However, the original test fails at out = model(input) with a dtype mismatch error.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ho right. That sounds good!

@albanD albanD added the module: bc-breaking Related to a BC-breaking change label May 31, 2022
Copy link
Copy Markdown
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM
I'll let @soulitzer take a look and merge if he's happy with this!

Copy link
Copy Markdown
Contributor

@soulitzer soulitzer 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 change! Just a small nit on the wording.

Comment thread torch/csrc/autograd/python_variable.cpp Outdated
@soulitzer
Copy link
Copy Markdown
Contributor

That makes sense to me as a fix even though it is BC-breaking.

Yup, SGTM as well

…ad=True on integer tensor"


fix #76008

[ghstack-poisoned]
yuguo68 added a commit that referenced this pull request Jun 1, 2022
ghstack-source-id: 1fc25ee
Pull Request resolved: #78436
@yuguo68
Copy link
Copy Markdown
Contributor Author

yuguo68 commented Jun 1, 2022

@yuguo68 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@soulitzer soulitzer left a comment

Choose a reason for hiding this comment

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

Thanks!

@soulitzer
Copy link
Copy Markdown
Contributor

@yuguo68 why did you import this, are there fb-only changes that need to be made?

@yuguo68
Copy link
Copy Markdown
Contributor Author

yuguo68 commented Jun 1, 2022

@yuguo68 why did you import this, are there fb-only changes that need to be made?

just want to check whether it causes internal test errors in advance, will use pytorchbot to merge.

@yuguo68
Copy link
Copy Markdown
Contributor Author

yuguo68 commented Jun 1, 2022

@pytorchbot merge this

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2022

Hey @yuguo68.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Jun 2, 2022
Summary:
Pull Request resolved: #78436

Approved by: https://github.com/albanD, https://github.com/soulitzer

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/efdb4192bc9620a9ef93fe2fc18969af42a2ebfb

Reviewed By: seemethere

Differential Revision: D36800179

Pulled By: yuguo68

fbshipit-source-id: e8a92d3e9412a462cff1cebf8e74f1e7213cdac6
@facebook-github-bot facebook-github-bot deleted the gh/yuguo68/6/head branch June 5, 2022 14:17
@soulitzer soulitzer added release notes: autograd release notes category topic: bc breaking topic category labels Jun 21, 2022
pytorchmergebot pushed a commit that referenced this pull request Jun 21, 2022
Fixes #79871

Make `module.cpp` tests respect change that was made in #78436 (no int types in autograd).

Note that there still a gap in Cmake test -- it's unclear why it didn't fail CI before.

As far as I can tell it should be executed, because it's included here https://github.com/pytorch/pytorch/blob/79507d2a9d06d4a3fb50eb21b30e08cc044776ce/test/cpp/api/CMakeLists.txt#L17:L17

Pull Request resolved: #79926
Approved by: https://github.com/soulitzer
facebook-github-bot pushed a commit that referenced this pull request Jun 22, 2022
Summary:
Fixes #79871

Make `module.cpp` tests respect change that was made in #78436 (no int types in autograd).

Note that there still a gap in Cmake test -- it's unclear why it didn't fail CI before.

As far as I can tell it should be executed, because it's included here https://github.com/pytorch/pytorch/blob/79507d2a9d06d4a3fb50eb21b30e08cc044776ce/test/cpp/api/CMakeLists.txt#L17:L17

Pull Request resolved: #79926
Approved by: https://github.com/soulitzer

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/a8b098859688a3f1993821eecc036be973a15605

Reviewed By: atalman

Differential Revision: D37333256

Pulled By: atalman

fbshipit-source-id: 0b914fbcc5da72fbadf0f3c2f6b6af1a198cf6fb
miladm pushed a commit to miladm/pytorch that referenced this pull request Jun 27, 2022
Fixes pytorch#79871

Make `module.cpp` tests respect change that was made in pytorch#78436 (no int types in autograd).

Note that there still a gap in Cmake test -- it's unclear why it didn't fail CI before.

As far as I can tell it should be executed, because it's included here https://github.com/pytorch/pytorch/blob/79507d2a9d06d4a3fb50eb21b30e08cc044776ce/test/cpp/api/CMakeLists.txt#L17:L17

Pull Request resolved: pytorch#79926
Approved by: https://github.com/soulitzer
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
Fixes pytorch#79871

Make `module.cpp` tests respect change that was made in pytorch#78436 (no int types in autograd).

Note that there still a gap in Cmake test -- it's unclear why it didn't fail CI before.

As far as I can tell it should be executed, because it's included here https://github.com/pytorch/pytorch/blob/e4a7ecafa61d9d9a7ac1f154264d6f5ccffe12bb/test/cpp/api/CMakeLists.txt#L17:L17

Pull Request resolved: pytorch#79926
Approved by: https://github.com/soulitzer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: bc-breaking Related to a BC-breaking change release notes: autograd release notes category topic: bc breaking topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants