Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/128052
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 605eee3 with merge base e8670f6 ( UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
Summary: Dynamo lifts all symexprs that appear in the inputs to top level which means that we do not need to look at guards that contain symexprs that do not appear in the inputs. Prune them. Test Plan: added two new tests Differential Revision: D58200476
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
| @@ -904,6 +905,7 @@ def _save_graph( | |||
| shape_env = FxGraphCache._get_shape_env() | |||
| assert shape_env is not None | |||
| symints = FxGraphCache._filter_backed_symints(example_inputs) | |||
There was a problem hiding this comment.
So, what's the plan for unbacked symints allocated in forwards that end up as inputs to the backwards graph?
There was a problem hiding this comment.
Hmm.. good point. Do you have any thought about this? Do we need to lift them in dynamo?
There was a problem hiding this comment.
On #126251 @masnesral claims that unbacked symints cant affect guards
There was a problem hiding this comment.
Curiosity question: can runtime asserts be associated with the backward graph today? Or do they only show up in forward (if they show up in backward, do include them directly inside the backward graph as fx nodes?)
| for g in self.guards: | ||
| if all(str(s) in symints for s in g.expr.free_symbols): | ||
| guards.append(g) | ||
| self.guards = guards |
There was a problem hiding this comment.
Hmmm it's not clear to me why this is correct. Say we have this code:
@torch.compile
def f(x, val):
if val > 5:
return x.sin()
else:
return x.cos()
x = torch.randn(2)
out1 = f(x, 6)
out2 = f(x, 4)
We need to dynamo to fail a guard for s0 > 5 on the second invocation of f. But... if I understand correctly, won't this change in-place mutate the ShapeEnv and delete that guard (while inductor is compiling), before dynamo has a chance to grab all relevant guards from the ShapeEnv and codegen them?
There was a problem hiding this comment.
@bdhirsh and i looked at this example with dynamic=True and it appears to not fit the cache at all and ends up in a fresh compile
| assert shape_env is not None | ||
|
|
||
| symints = FxGraphCache._filter_backed_symints(example_inputs) | ||
| shape_env.drop_non_input_symint_guards(symints) |
There was a problem hiding this comment.
@ezyang can you verify its safe to manipulate the existing shape env? My high-level understanding from @bdhirsh is that dynamo will still evaluate these guards after inductor is finished doing its thing. If it is safe to remove this category of guards, why don't we remove them unconditionally before we start inducting rather than putting the manipulation in the cache path?
There was a problem hiding this comment.
No, you definitely cannot start dropping guards from the shape env lol
There was a problem hiding this comment.
Fixed this on a previous version of the PR
Summary: Dynamo lifts all symexprs that appear in the inputs to top level which means that we do not need to look at guards that contain symexprs that do not appear in the inputs. Prune them. Test Plan: added two new tests Differential Revision: D58200476
4d1b3a8 to
f38f3f4
Compare
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
| ) | ||
|
|
||
| self.guards: List[ShapeGuard] = [] | ||
| self.input_guards: List[ShapeGuard] = [] |
There was a problem hiding this comment.
i ended up separating these because symbolic shape recording pass validation was failing otherwise
There was a problem hiding this comment.
This seems like a dorky way to do this. One superficial complaint is that ShapeEnv is not Inductor specific, and yet we have named this thing "input guards", what the heck is an input guard?
For me, an intuitive code organization is that I want some way to call produce_guards with an explicit guards list, rather than using the guards that is accumulated directly on the ShapeEnv. That seems like a very modest change and doesn't require adding an extra field on ShapeEnv.
You need to make sure to not run translation validation on this produce_guards call either, as it will fail (and for good reason). TV should only run when you don't explicitly pass in guards to produce.
f38f3f4 to
19d9ab6
Compare
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
Summary: Dynamo lifts all symexprs that appear in the inputs to top level which means that we do not need to look at guards that contain symexprs that do not appear in the inputs. Prune them. Test Plan: added two new tests Differential Revision: D58200476
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
masnesral
left a comment
There was a problem hiding this comment.
Looks correct based on discussions, but I still don't understand everything about guards so I'll defer to @ezyang about the overall soundness.
One thing that makes me nervous is that we're using a different set of guards for the cache than elsewhere. So if we've made a mistake and these guards are too lax, it's going to be very confusing and hard to debug. It would seem better, for example, if we could distinguish those guards added by inductor -- then use them directly in the cache rather than filtering from this single list based on criteria that I'm not sure are codified. But I presume that distinguishing the inductor-added guards would be a large refactor?
312ce62 to
26d82c8
Compare
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
Summary: Dynamo lifts all symexprs that appear in the inputs to top level which means that we do not need to look at guards that contain symexprs that do not appear in the inputs. Prune them. Test Plan: added two new tests Reviewed By: masnesral Differential Revision: D58200476
|
This pull request was exported from Phabricator. Differential Revision: D58200476 |
|
@pytorchbot merge -f 'Landed internally' (Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally) |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like #128052 has fixed that issue, so we can enable for torchbench. [ghstack-poisoned]
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like #128052 has fixed that issue, so we can enable for torchbench. Pull Request resolved: #128239 Approved by: https://github.com/oulgen
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like pytorch/pytorch#128052 has fixed that issue, so we can enable for torchbench. X-link: pytorch/pytorch#128239 Approved by: https://github.com/oulgen Reviewed By: clee2000 Differential Revision: D58394057 Pulled By: masnesral fbshipit-source-id: 58a226babdcd04a3bb14118e7a555558c56bc9ef
…ench" Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like #128052 has fixed that issue, so we can enable for torchbench. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang [ghstack-poisoned]
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like #128052 has fixed that issue, so we can enable for torchbench. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang [ghstack-poisoned]
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like #128052 has fixed that issue, so we can enable for torchbench. Pull Request resolved: #128239 Approved by: https://github.com/oulgen
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like pytorch/pytorch#128052 has fixed that issue, so we can enable for torchbench. X-link: pytorch/pytorch#128239 Approved by: https://github.com/oulgen Reviewed By: clee2000 Differential Revision: D58501160 Pulled By: masnesral fbshipit-source-id: b7ceeecbf632671059a07e17851d4301c79945ec
Summary: Dynamo lifts all symexprs that appear in the inputs to top level which means that we do not need to look at guards that contain symexprs that do not appear in the inputs. Prune them. Test Plan: added two new tests Differential Revision: D58200476 Pull Request resolved: pytorch#128052 Approved by: https://github.com/ezyang, https://github.com/masnesral
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like pytorch#128052 has fixed that issue, so we can enable for torchbench. Pull Request resolved: pytorch#128239 Approved by: https://github.com/oulgen
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like pytorch#128052 has fixed that issue, so we can enable for torchbench. Pull Request resolved: pytorch#128239 Approved by: https://github.com/oulgen
Summary: We've already enabled for timm and huggingface, but we had failures saving cache entries for moco. It looks like pytorch#128052 has fixed that issue, so we can enable for torchbench. Pull Request resolved: pytorch#128239 Approved by: https://github.com/oulgen
Summary: Dynamo lifts all symexprs that appear in the inputs to top level which means that we do not need to look at guards that contain symexprs that do not appear in the inputs. Prune them.
Test Plan: added two new tests
Differential Revision: D58200476
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang