-
Notifications
You must be signed in to change notification settings - Fork 24.1k
feat: Add min, max ranges to mark_dynamic API #119737
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/119737
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Pending, 3 Unrelated FailuresAs of commit 8abdc26 with merge base 8fa6340 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Please seek CI approval before scheduling CIFlow labels |
@jansel - would you please review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit, though @ezyang should take a look here.
torch/_dynamo/decorators.py
Outdated
|
||
if isinstance(index, int): | ||
if not hasattr(t, "_dynamo_dynamic_indices"): | ||
t._dynamo_dynamic_indices = set() | ||
# TODO(voz): Should we bounds check? | ||
t._dynamo_dynamic_indices.add(index) | ||
t._dynamo_dynamic_indices.add((index, min, max)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider just making a little data structure for this, easier than indexing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I added _DimRange
dataclass now to access it via dim_range.min
etc. Please let me know if there's any other preference
torch/_dynamo/variables/builder.py
Outdated
if min_val == 2 and not max_val: | ||
constraint_dim = RelaxedUnspecConstraint(warn_only=False) | ||
else: | ||
constraint_dim = StrictMinMaxConstraint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little concerned about this going from Relaxed to Strict, the main question is whether or not export requires there are NO other constraints, or if it's just testing the value range. If it's just value range that should be alright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per my understanding (of this snippet and this file), it seems like it's just testing the value range.
This looks good but there are test failures, you know how to solve? |
Please seek CI approval before scheduling CIFlow labels |
Please seek CI approval before scheduling CIFlow labels |
holler if you need help fixing ci problems |
Please seek CI approval before scheduling CIFlow labels |
Yes. That would be very helpful.
|
I approved the CI for you |
seems like just silly ci errors right now |
It seems so. The error is as follows
As per your suggestion, I made a dataclass |
oh blah, this is annoying. Hmm... So, we can fix the proximal problem by introducing a _DimRange binding to CLOSURE_VARS in torch/_dynamo/guards.py. However, the failure here has made me realize that there is another annoying problem, which is that the issubset test is no longer the right thing to do in the presence of this extra information. To motivate this, the idea is that let's say you compile some code under the assumption that dim=1 is dynamic. If later you also mark dim=2 dynamic, the guard here will force a recompilation (so that we actually generate a dynamic kernel). If you remove the dim=1 marking, though, we don't recompile, because our dynamic kernel should work for your static case. There's a comment on this in guards.py at
This is all very delicate though and we are pretty inconsistent (I don't think we're guarding on mark static lol). So I feel maybe the easiest thing to do, is to just store the min/max range on a separate variable and file a bug for follow up on the guard problem. If you want to bash your way past this, though, then you not only need to do the subset test, but you also have to do some containment test on the ranges (a frame is valid to reuse if the new allowed range is a subset of the old). |
@pytorchbot label "release notes: dynamo" |
Thank you for all the help @ezyang |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
Signed-off-by: Edward Z. Yang <[email protected]>
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 3 checks: inductor / cuda12.1-py3.10-gcc9-sm86 / test (inductor_torchbench, 2, 2, linux.g5.4xlarge.nvidia.gpu), trunk / win-vs2019-cpu-py3 / test (default, 1, 3, windows.4xlarge.nonephemeral), trunk / win-vs2019-cpu-py3 / test (default, 3, 3, windows.4xlarge.nonephemeral) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 2 jobs have failed, first few of them are: .github/workflows/trunk.yml / win-vs2019-cpu-py3 / test (default, 1, 3, windows.4xlarge.nonephemeral), .github/workflows/trunk.yml / win-vs2019-cpu-py3 / test (default, 3, 3, windows.4xlarge.nonephemeral) Details for Dev Infra teamRaised by workflow job |
@ezyang The following failures on Windows seem unrelated. Any suggestions ?
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 4 checks: pull / linux-focal-cuda12.1-py3.10-gcc9-bazel-test / build-and-test (default, 1, 1, linux.4xlarge.nvidia.gpu), inductor / cuda12.1-py3.10-gcc9-sm86 / test (inductor_torchbench, 2, 2, linux.g5.4xlarge.nvidia.gpu), trunk / win-vs2019-cpu-py3 / test (default, 1, 3, windows.4xlarge.nonephemeral), trunk / win-vs2019-cpu-py3 / test (default, 3, 3, windows.4xlarge.nonephemeral) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Fixes #115137
This PR adds:
min
,max
values to create a bounded constraint on the dim.ConstraintViolationError
is triggered iftorch.compile
gets a input dimension out of bounds.cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @aakhundov @ezyang @msaroufim @wconstab @bdhirsh @anijain2305 @zou3519 @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4
cc: @narendasan