Skip to content

Conversation

@oscarandersson8218
Copy link
Collaborator

  • Add ArmPassManager that's responsible for pass handling.
  • Add RemoveClones-pass.
  • Add initial pass test.

Change-Id: I71e1e0787d0788a835a412c608ae75331fe65cc2

@pytorch-bot
Copy link

pytorch-bot bot commented May 27, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/3749

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 2 New Failures

As of commit a9c550b with merge base 074a81e (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 27, 2024
@oscarandersson8218 oscarandersson8218 added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label May 27, 2024
Comment on lines 51 to 47
permute_memory_to_nhwc=True,
quantize_io=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one way to do it. But why hide it from the user? I would just run them at the top level i.e.

...
e = to_edge()
e = helper_run_pass(e, pass_foo) # new method
e = partition(my_delegate_partitioner())
e = helper_run_pass(e, pass_bar)
...

In theory delegate specific passes should only run on the "partitioned" subgraph i.e. inside the preprocess() to make sure the graph you are mutating has no external side effect.

This is different, and I understand the rationale, and this is mutating the graph before the partitioning. I am not sure if we want to hide this mutation from the user.

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why hide it from the user?

The reasoning is that different compile_specs may require different passes and applying all the passes at the top level would leave all the responsibility on the end-user. With this pass manager, all the user needs to do is to configure the compile_spec and then the passes would be applied for "free".

On the second part I think it is fine that this specific pass (TagIOQuantPass) is hidden since it does not change the graph, it only makes sure that the delegate does not consume certain nodes. Pre-partition passes that does mutate the graph should probably not be hidden though as you say...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, you can still do it outside, I am not sure which one is better

e = helper_run_pass(e, pass, compile_spec)

@mergennachin - what do you think?

- Add ArmPassManager that's responsible for pass handling.
- Add RemoveClones-pass.
- Add initial pass test.

Change-Id: I71e1e0787d0788a835a412c608ae75331fe65cc2
Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
Change-Id: I5e8e868c49b9c4d3b365e2154430a286028d8dfc
Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
passes(exported_program.graph_module)
exported_program = ArmPassManager(
exported_program=exported_program
).transform_partition_pipeline(compile_spec=self.delegation_spec.compile_specs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps print a warning or something here?

from executorch.exir.pass_base import PassResult


class RemoveClone(ArmPass):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass suffix is commonly used

@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines 83 to 86
graph_module = ArmPassManager().transform_partition_pipeline(
graph_module=exported_program.graph_module,
compile_spec=self.delegation_spec.compile_specs,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not gonna work.

The invariant is that input and output ofpartitioner() should be the same, except a tag.

https://github.com/pytorch/executorch/blob/main/exir/backend/backend_api.py#L368-L371

As @digantdesai mentioned, this should be a user pass before calling to_backend(ArmPartitioner) for now.

We might introduce a first class citizen API for backend specific passes, but for now, we will ask users to add this one-line call to ArmPassManager()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally nothing has changed since #3056. The tag_io_quant_pass has been moved from one file to another. Also, that pass only annotates a tag.

If I understand you correctly, you simply want to remove this call from the partitioner? You don't want the PassManager to be changed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can merge this PR, which just sheds light on the structural issues with quantized IO, and continue the more structural discussions in a new Github ticket?

@oscarandersson8218 @robell @mergennachin @digantdesai

- Update README
- Suffix passes with Pass

Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
Change-Id: I32b5683ea373fe8d0706da1a004eca8f5478de3c
Change-Id: Ib7200c1eeb7ac2646f9177c1931ddac72919fd52
Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
Change-Id: I98f8b68361a05452cf100f67ec4479690bc8699d
Change-Id: I9b628ea6705ce6bc4f95479607594a31f6c52064
Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
Change-Id: I7eabfee97c52cdec81f12986f08b2ed590d5681a
@digantdesai
Copy link
Contributor

IIUC - with a9c550b - there is no use of ArmPassManager in Partition fn. While it unblocks this PR, we should still treat the underlying issue as a priority. I will try to follow up on this.

@digantdesai digantdesai requested a review from mergennachin July 12, 2024 21:58
@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@digantdesai merged this pull request in dd7fa6a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants