executorch icon indicating copy to clipboard operation
executorch copied to clipboard

Check tensor's dim order ambiguity in IR verifier

Open Gasoonjia opened this issue 9 months ago • 8 comments

Description

It is crucial to maintain dimensional order consistency (dim-order-unambiguity) for tensors within our computational graph. We have developed a tool to check this, as introduced in PR #9371. However, this tool has not yet been integrated into our dimension order verifier.

Action Required

Integrate the dim-order checking tool into the existing dimension order verifier located in the file: verifier.py.

cc @JacobSzwejbka @angelayi @digantdesai @larryliu0820

Gasoonjia avatar Apr 07 '25 21:04 Gasoonjia

This is good, thanks @Gasoonjia. Let's make sure if this is very noisy we can allow users to make forward progress by disabling it temporarily, kind of like draft mode for export.

digantdesai avatar Apr 07 '25 21:04 digantdesai

Hello, this seems like an interesting first problem to solve. Would I be able to take a shot at it? Also, not sure how to assign myself to the issue... If someone could help with that, it would be much appreciated.

patelvndn avatar Apr 14 '25 21:04 patelvndn

Thanks @patelvndn for your help! Have assigned you and please let me or @digantdesai know if anything we can help!

Gasoonjia avatar Apr 14 '25 22:04 Gasoonjia

I noticed a function to check a tensor's dim order ambiguity in PR#9371. Would it make sense to use the same function in verifier.py? Is this the tool the issue description is referring to?

patelvndn avatar Apr 16 '25 20:04 patelvndn

Yes assert_unambiguous_dim_order(https://github.com/pytorch/executorch/pull/9371/files#diff-e99d0611a6856d7bd793c25b5b6ddb0caa73d850aa6cd9c16de44e63f8fb44aeR109) is the utility function you can reuse in verifier.

Gasoonjia avatar Apr 16 '25 22:04 Gasoonjia

We may wrap this check around a specific dim_order_ops pass (instead of ExampleNoOp pass in that test) or we can literally run this for all/any passes by extending ExportPass, or something similar. The latter is the most conservative but can also be intrusive. Let's start with the former and then we will see if we need to extend this more.

digantdesai avatar Apr 21 '25 18:04 digantdesai

hey @patelvndn is the linked PR ready to be reviewed? Or still in draft?

Gasoonjia avatar Apr 23 '25 22:04 Gasoonjia

Hey @Gasoonjia, sorry for the late reply, I have my final exams this week. The PR is still in draft but I have been failing some label checks. I wanted to add in a few test cases (if applicable) as well. I added the check in the verifier.py file (in the PR draft) and that itself won't be changed.

patelvndn avatar Apr 24 '25 21:04 patelvndn

PR?

digantdesai avatar Apr 29 '25 19:04 digantdesai

PR is ready for review

patelvndn avatar Apr 30 '25 13:04 patelvndn