Revert #168264 + Python-side LRU cache when native op schema is not supported#168269
Revert #168264 + Python-side LRU cache when native op schema is not supported#168269ezyang wants to merge 5 commits intogh/ezyang/3204/basefrom
Conversation
| py_op.ptr(), | ||
| args.ptr(), | ||
| kwargs.ptr()); | ||
| py::object sharding = checked_vectorcall( |
There was a problem hiding this comment.
review with ignore whitespace changes
|
you're working on a test case? |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/168269
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 41 PendingAs of commit 09b6fe1 with merge base d3ccb8f ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
yes. unfortunately claude didn't write a good test lol |
albanD
left a comment
There was a problem hiding this comment.
Needs a test to make sure we don't regress again.
SGTM once added
| checked_vectorcall( | ||
| sharding_propagator.attr("propagate").ptr(), | ||
| py_op_info.ptr()); | ||
| cached_sharding = py_op_info.attr(dtensor_interned_strings.output_sharding); |
There was a problem hiding this comment.
Should this be added to the c++ cache here to make subsequent calls faster?
There was a problem hiding this comment.
The problem is when opt_native_op_schema fails to be returned, the C++ actually just has no cache key to lookup against, so this really wouldn't help (we HAVE to go into the pytree path before we can compute the cache key).
| if (opt_native_op_schema.has_value()) { | ||
|
|
||
| // Use Python-side LRU cache when native cache is not available | ||
| if (!opt_native_op_schema.has_value()) { |
There was a problem hiding this comment.
Note the slow path will be triggered when input args contain List[Tensor] or contains symbolic shape.
|
@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 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (distributed, 3, 3, linux.rocm.gpu.gfx942.4) Details for Dev Infra teamRaised by workflow job |
|
The latest implementation is better, and has lots of comments, and I basically undid all the Claude code stuff. |
| kwargs.ptr(), | ||
| py_op_info.ptr()); | ||
| py_op_info.ptr(), | ||
| /*try_cache*/ !opt_native_op_schema.has_value() ? Py_True : Py_False); |
There was a problem hiding this comment.
iiuc 2 major changes since the last rev
- we now do the "if sharding is actually a tensor, return early" bit 100% of the time that we call into python, whereas previously we only did it on the 'slow path' and not on the 'fast path'
- we always call the 'slow path' entrypoint back to python, and added the caching logic into it (gated by try_cache) rather than having 2 callouts to python in c++
LGTM!
There was a problem hiding this comment.
if i were a better man, i'd have written tests for these cases lol
|
@pytorchbot merge -f "rebuild not necessary, previous commit is identical" |
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 |
…upported (#168269) This reverts #168264 but with a bugfix for the reason why it was reverted. Signed-off-by: Edward Z. Yang <ezyang@meta.com> Pull Request resolved: #168269 Approved by: https://github.com/wconstab, https://github.com/albanD, https://github.com/zpcore, https://github.com/malfet
Authored with claude code Signed-off-by: Edward Z. Yang <ezyang@meta.com> ghstack-source-id: dcebadd Pull-Request: pytorch/pytorch#168269
Authored with claude code Signed-off-by: Edward Z. Yang <ezyang@meta.com> ghstack-source-id: 5240429 Pull-Request: pytorch/pytorch#168269
Stack from ghstack (oldest at bottom):
This reverts #168264 but with a bugfix for the reason why it was reverted.
Signed-off-by: Edward Z. Yang ezyang@meta.com