-
Notifications
You must be signed in to change notification settings - Fork 519
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
Decomposition of aten.pixel_shuffle with static input shape #2550
Conversation
@vivekkhandelwal1 I have an e2e test case working, but only for static shapes (see my comment above). I am not sure what to do about the dynamic shape case, is my thought that torch->linalg for aten.view is limited, and that's why I'm having problems? More generally, I'd like to understand dynamic shapes end-to-end in torch-mlir, any pointers? |
Hi @newling, the support for dynamic shapes in Torch-MLIR is limited, especially for view-like ops. I think, for now, you can follow either of the below two paths: For the Also, unfortunately, there is no documentation for the dynamic shapes in Torch-MLIR. It's just that ops in Torch-MLIR broadly fall into one or a combination of the below four categories: You can go through some of the op lowerings for view-like ops to understand the functioning or dynamic-shape support in Torch-MLIR. |
Thanks for these information gems @vivekkhandelwal1 I am tempted to go with option 1 (just support static) for now, and leave comments in the code about what the issues currently are with dynamic shapes, and what possible remedies there are (like go directly to linalg, or maybe extend lowering of reshape). Hopefully the use cases that @qedawkins has in mind are static. |
If it's required for Llama-2 then the use case would probably be dynamic. But @qedawkins can comment more on this, |
Ah no, this mostly shows up in vision models, and I would guess most of the time we would see static dims for the ones that are actually shuffled. There might be some dynamic outer/batch like dims though. |
805d502
to
e16f13e
Compare
e16f13e
to
a2fe7af
Compare
Ok, so I've got it supporting just static shapes. I've left a comment in the code about why, and possible next steps. I don't seem to be able to add reviewers, and I also need approval to start the workflows. How I get these permissions? |
Good question. IIRC there is a process to be added to the repo after you have landed a commit, but I don't know if the process has changed. |
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.
Mostly looks good, thanks for the patch! It has been a while since I've worked in depth with these decompositions and there might be some helpers already in place to help simplify code in a few places (looking for another reviewer who might know).
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 left the comments that still need addressing as unresolved. Mainly some comment cleanup and missing shape/dtype refinement functions (sorry for the segmented review).
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.
LGTM! Thanks for pushing this through
I think some linting check wants you to run
|
Thanks for the help @qedawkins!
Yeah, that was a very useful diagnostic message from CI 😍 |
@qedawkins would you mind kickstarting CI? It was failing with an "unexpected pass" failure, so I added the 2 tests to projects/pt1/e2e_testing/xfail_sets.py (a bit of a shot in the dark) General question: Is there a simple way to run all the tests locally, with a single command? |
There are some notes on testing here: https://github.com/llvm/torch-mlir/blob/main/docs/development.md#testing |
There isn't much material about updating xfail_sets.py... but I'm optimistic I've got it right now (added to LTC_XFAIL_SET). Can you please restart the workflow @qedawkins ? |
Sorry about needing approval each time to run the CI :( |
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.
Some small requests
.../pt1/python/torch_mlir/dialects/torch/importer/jit_ir/build_tools/abstract_interp_lib_gen.py
Outdated
Show resolved
Hide resolved
(Merging because it looks like Ramiro's concerns were addressed and there is no PR blocker in place) |
For static tests (that is when the shape is know) for example:
The e2e passes. But only if the replacement op's return type is set as undefined (optional shape and type must be explicitly made unset), otherwise there's a error about the function return type.
For dynamic cases, for example if the above is replaced with
There is a failure to lower to linalg from torch ("view op explicitly labelled as illegal"). This seems to be because the support for lowering from torch to linalg with dynamic shapes is limited.