Skip to content

Add support for directly passing symint to empty#79494

Closed
ezyang wants to merge 3 commits intogh/ezyang/1221/basefrom
gh/ezyang/1221/head
Closed

Add support for directly passing symint to empty#79494
ezyang wants to merge 3 commits intogh/ezyang/1221/basefrom
gh/ezyang/1221/head

Conversation

@ezyang
Copy link
Copy Markdown
Contributor

@ezyang ezyang commented Jun 14, 2022

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
@ezyang ezyang requested a review from bdhirsh as a code owner June 14, 2022 02:25
ezyang added a commit that referenced this pull request Jun 14, 2022
Signed-off-by: Edward Z. Yang <ezyangfb.com>

ghstack-source-id: 773c244
Pull Request resolved: #79494
@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented Jun 14, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

As of commit 64374ac (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


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.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

[ghstack-poisoned]
@ezyang ezyang requested review from Chillee, Krovatkin and eellison June 14, 2022 13:24
Signed-off-by: Edward Z. Yang <ezyangfb.com>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jun 14, 2022
Signed-off-by: Edward Z. Yang <ezyangfb.com>

ghstack-source-id: cc943e1
Pull Request resolved: #79494
Comment thread c10/core/SymInt.cpp
// TODO: technically we need to check that the classes match
if (!a) {
a = common->wrap(data_);
toSymInt(a); //
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.

debug code?

Copy link
Copy Markdown
Contributor

@Krovatkin Krovatkin Jun 14, 2022

Choose a reason for hiding this comment

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

toSymInt has a side-effect of persisting SymIntNodes into a SymIntTable, so a comment would probably help why we need to do this given that SymInt::toSymInt(a->add(b)); should have strong references to both a and b?

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 code is completely broken anyway; every time you convert SymbolicIntNode to SymInt the current code allocates a fresh table entry which is wrong

) {
auto device = device_or_default(device_opt);
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(device.type() == DeviceType::Meta);
// NB: because there is no SparseMeta (yet), non-strided layout is
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.

nit missing "not"

std::vector<SymInt> strides;
strides.resize(dim);

// TODO: Move this into TensorImpl
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.

Isn't that already? You have the empty_tensor_restride(MemoryFormat::Contiguous) that does this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: it does feel like we need a helper here.

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.

empty_tensor_restride doesn't operate on symbolic integers. I'm a little torn about whether or not to directly SymInt'ify it or maintain two separate versions; there's a lot of arithmetic operations going on and it would be better for them to be all unchecked

SparseCsrCPU, SparseCsrCUDA: empty_sparse_compressed
QuantizedCPU, QuantizedCUDA: empty_unknown_quantized

- func: empty.SymInt(SymInt[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor
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.

No overload conflict for this one?

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.

No, because of #79281

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 this is done under the hood.

Copy link
Copy Markdown
Contributor

@Krovatkin Krovatkin left a comment

Choose a reason for hiding this comment

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

:shipit:

std::vector<SymInt> strides;
strides.resize(dim);

// TODO: Move this into TensorImpl
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: it does feel like we need a helper here.

Comment thread c10/core/SymInt.cpp
// TODO: technically we need to check that the classes match
if (!a) {
a = common->wrap(data_);
toSymInt(a); //
Copy link
Copy Markdown
Contributor

@Krovatkin Krovatkin Jun 14, 2022

Choose a reason for hiding this comment

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

toSymInt has a side-effect of persisting SymIntNodes into a SymIntTable, so a comment would probably help why we need to do this given that SymInt::toSymInt(a->add(b)); should have strong references to both a and b?

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.

Will need some cleanup, but sounds ok.

@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Jun 14, 2022

@pytorchbot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@github-actions
Copy link
Copy Markdown
Contributor

Hey @ezyang.
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.

@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Jun 15, 2022

@pytorchbot revert

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 15, 2022

❌ 🤖 pytorchbot command failed:

@pytorchbot revert: error: the following arguments are required: -m/--message

usage: @pytorchbot revert -m MESSAGE
                          [-c {nosignal,ignoredsignal,landrace,weird,ghfirst}]

Try @pytorchbot help for more info.

@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Jun 15, 2022

@pytorchbot revert -m "conflicts with earlier diff that needs revert"

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Reverting PR 79494 failed due to Comment @pytorchbot revert -m "conflicts with earlier diff that needs revert" does not seem to be a valid revert command
Raised by https://github.com/pytorch/pytorch/actions/runs/2502654093

@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Jun 15, 2022

@pytorchbot revert -m "conflicts with earlier diff that needs revert" -c weird

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here

pytorchmergebot added a commit that referenced this pull request Jun 15, 2022
This reverts commit 05664a9.

Reverted #79494 on behalf of https://github.com/ezyang due to conflicts with earlier diff that needs revert
@facebook-github-bot facebook-github-bot deleted the gh/ezyang/1221/head branch June 18, 2022 14:17
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
Signed-off-by: Edward Z. Yang <ezyangfb.com>

Pull Request resolved: pytorch#79494

Approved by: https://github.com/albanD
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
This reverts commit 3d96708.

Reverted pytorch#79494 on behalf of https://github.com/ezyang due to conflicts with earlier diff that needs revert
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.

5 participants