KEMBAR78
Force specialization on INT_LIST by ezyang · Pull Request #111216 · pytorch/pytorch · GitHub
Skip to content

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Oct 13, 2023

Stack from ghstack (oldest at bottom):

Follow up on #95479

Fixes #111198

Fixes #111197

Fixes #111188

Fixes #111201

Fixes #111202

I can also do this for some other types, will do this stacked on top.

Signed-off-by: Edward Z. Yang ezyang@meta.com

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng

Follow up on #95479

Fixes #111198

I can also do this for some other types, will do this stacked on top.

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

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 13, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/111216

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit fc3b971 with merge base 6aa91c8 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@ezyang ezyang requested a review from jon-chuang October 13, 2023 17:48
@ezyang ezyang added ciflow/trunk Trigger trunk jobs on your pull request ciflow/inductor labels Oct 13, 2023
@albanD albanD removed their request for review October 13, 2023 17:55
Follow up on #95479

Fixes #111198

Fixes #111197

Fixes #111188

I can also do this for some other types, will do this stacked on top.

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

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng

[ghstack-poisoned]
Follow up on #95479

Fixes #111198

Fixes #111197

Fixes #111188

I can also do this for some other types, will do this stacked on top.

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

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng

[ghstack-poisoned]
}
} else if (torch::is_symint(py::handle(obj))) {
res[idx] = py::cast<c10::SymInt>(py::handle(obj))
.guard_int(__FILE__, __LINE__);
Copy link
Contributor

Choose a reason for hiding this comment

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

More for my own understanding: instead of silently specializing whenever we plumb a symint to an op who's schema specifies int[], wouldn't it be better to just change all of our schemas to take in SymInt[]? (and until then, raising an error makes it easier to identify and fix the places where this happens?)

One reason the guards here are kinda painful is that (I don't think) we get cpp stacktraces in the guard provenance tracking, so it won't be immediately clear to people who sees guards that the guards are coming from our unfixed schemas.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh unless this change is purely for BC reasons - in theory we could change all aten schemas today, but I guess for custom ops, we used to specialize by default whereas now (without this PR) we now error by default on custom op schemas that take in int[].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So what we specifically are guarding against here is when Dynamo thinks an int is dynamic (most commonly because dynamic=True) but it actually is something like dim= and cannot possibly be dynamic.

I think modifying the schemas would not be the right thing to do, because there isn't any situation we will actually support dynamism for real, so it is wasted work. In the early days, we errored instead of specializing to make it easier to catch missing symints in schema, but we now have good logging and good coverage so it is more important to avoid erroring eg as in the linked issues

Copy link
Collaborator

Choose a reason for hiding this comment

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

lgtm

Follow up on #95479

Fixes #111198

Fixes #111197

Fixes #111188

I can also do this for some other types, will do this stacked on top.

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

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Oct 19, 2023
Fixes #111200

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

Pull Request resolved: #111219
Approved by: https://github.com/Skylion007, https://github.com/bdhirsh
ghstack dependencies: #111216
pytorchmergebot pushed a commit that referenced this pull request Oct 22, 2023
…ntlist (#111642)

Fixes #104812.

As of #111216, the python arg parser will now guard and cast symints from dynamo into ints when it is forced to (e.g. when we pass a symint to an op that only accepts ints).

But the python arg parser also has logic to try to coerce ints into int[] - we need the same logic for symint -> int[].

Pull Request resolved: #111642
Approved by: https://github.com/ezyang, https://github.com/albanD
ghstack dependencies: #111553
@facebook-github-bot facebook-github-bot deleted the gh/ezyang/2388/head branch October 22, 2023 14:23
xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Nov 7, 2023
Follow up on pytorch#95479

Fixes pytorch#111198

Fixes pytorch#111197

Fixes pytorch#111188

Fixes pytorch#111201

Fixes pytorch#111202

I can also do this for some other types, will do this stacked on top.

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

Pull Request resolved: pytorch#111216
Approved by: https://github.com/voznesenskym
xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Nov 7, 2023
Fixes pytorch#111200

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

Pull Request resolved: pytorch#111219
Approved by: https://github.com/Skylion007, https://github.com/bdhirsh
ghstack dependencies: pytorch#111216
xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Nov 7, 2023
…ntlist (pytorch#111642)

Fixes pytorch#104812.

As of pytorch#111216, the python arg parser will now guard and cast symints from dynamo into ints when it is forced to (e.g. when we pass a symint to an op that only accepts ints).

But the python arg parser also has logic to try to coerce ints into int[] - we need the same logic for symint -> int[].

Pull Request resolved: pytorch#111642
Approved by: https://github.com/ezyang, https://github.com/albanD
ghstack dependencies: pytorch#111553
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
…ntlist (pytorch#111642)

Fixes pytorch#104812.

As of pytorch#111216, the python arg parser will now guard and cast symints from dynamo into ints when it is forced to (e.g. when we pass a symint to an op that only accepts ints).

But the python arg parser also has logic to try to coerce ints into int[] - we need the same logic for symint -> int[].

Pull Request resolved: pytorch#111642
Approved by: https://github.com/ezyang, https://github.com/albanD
ghstack dependencies: pytorch#111553
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: dynamo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants