Skip to content

Update MemoryPlanning Verifier to only assume model has user input if it has at least one tensor input #10617

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

Conversation

jhelsby
Copy link
Contributor

@jhelsby jhelsby commented May 1, 2025

Fixes #10522

Summary

MemoryPlanning verifier currently blows up if all the user inputs are prims. #10522 suggested:

We need to improve the logic of the _do_user_inputs_exist to probably just return false if all the inputs are prims.

This PR implements this suggestion, with accompanying unit tests. _do_user_inputs_exist now returns True if it has at least one tensor input, and False otherwise.

Test plan

Added unit tests to test_memory_planning.py and ran them with

pytest exir/tests/test_memory_planning.py::test_memory_planning.py

Please note you must comment out the line 69 from /pytest.ini for this to work:

--ignore=exir/tests/test_memory_planning.py

On my machine, I also had to comment out line 60 from test_memory_planning.py for the test to run without errors.

torch.ops.load_library("//executorch/kernels/portable:custom_ops_generated_lib")

[The tests I wrote aren't dependent on this library.]

Copy link

pytorch-bot bot commented May 1, 2025

🔗 Helpful Links

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

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:

❌ 1 New Failure

As of commit 8a87967 with merge base 9d899c9 (image):

NEW FAILURE - The following job has 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 1, 2025
Copy link

pytorch-bot bot commented May 1, 2025

Didn't find following labels among repository labels: Release notes: exir

@jhelsby
Copy link
Contributor Author

jhelsby commented May 1, 2025

@pytorchbot label "release notes: exir"

@pytorch-bot pytorch-bot bot added the release notes: exir Changes to any dialects and passes on these dialects, such as memory planning label May 1, 2025
@digantdesai digantdesai marked this pull request as ready for review May 9, 2025 13:38
@digantdesai
Copy link
Contributor

Started CI (Need to do for new, external contributions). Rebase please.

Also marked it as Ready to signal reviewers that it's, well, ready for a review. Thanks for the contribution. Welcome to Executorch 😊

@jhelsby
Copy link
Contributor Author

jhelsby commented May 9, 2025

Thank you, I just rebased. I also fixed the linting issues which the CI tests identified.

[Sorry, I messed this up, hence the subsequent force-push.]

… it has at least one tensor input

MemoryPlanning verifier currently blows up if all the user inputs are prims.
This change means its helper function _do_user_inputs_exist returns
false
if all its inputs are prims. It only returns true if at least one
input is a tensor.
@jhelsby jhelsby force-pushed the bugfix/memoryplanningverifier/douserinputsexist-noprims branch from fbb360a to 19371e3 Compare May 9, 2025 18:49
@digantdesai
Copy link
Contributor

cc @JacobSzwejbka can you take a look? 🙏

@larryliu0820
Copy link
Contributor

@JacobSzwejbka gentle ping

Copy link
Contributor

@JacobSzwejbka JacobSzwejbka left a comment

Choose a reason for hiding this comment

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

I dont see any obvious issue with the code, the all red ci though made me think it was still under iteration.

@jhelsby jhelsby requested a review from JacobSzwejbka June 26, 2025 18:24
@jhelsby
Copy link
Contributor Author

jhelsby commented Jun 26, 2025

Many thanks for looking at this @JacobSzwejbka. Is there anything I can do now to help get this PR closed?

@larryliu0820
Copy link
Contributor

Kicked off CI jobs.

@larryliu0820
Copy link
Contributor

I don't think there's any other comment so approving

@jhelsby
Copy link
Contributor Author

jhelsby commented Jun 26, 2025

I'm so sorry @larryliu0820, I accidentally merged the branch which seems to have stopped the running workflows. Could you please kick off the CI jobs again?

@jhelsby
Copy link
Contributor Author

jhelsby commented Jun 26, 2025

Please correct me if I'm wrong, but I believe the failing check (pull / android / run-emulator (pull_request)) is unrelated to my change. It seems to be failing in other PRs too. For example:

#12010

has the same failed check here, with the same failure output:

FAILURES!!!
Tests run: 17,  Failures: 16

What is the best way to proceed to get this merged?

@larryliu0820

@larryliu0820
Copy link
Contributor

Yeah unrelated. Merging. Thanks for the PR!

@larryliu0820 larryliu0820 merged commit 375e4fe into pytorch:main Jun 26, 2025
95 of 96 checks passed
@jhelsby
Copy link
Contributor Author

jhelsby commented Jun 26, 2025

Fantastic, thank you so much for your help and patience throughout! This was my first code contribution to a major open-source project. 😄

@jhelsby jhelsby deleted the bugfix/memoryplanningverifier/douserinputsexist-noprims branch June 26, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: exir Changes to any dialects and passes on these dialects, such as memory planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[exir] MemoryPlanning Verifier assumes that if a model has a user input it has at least 1 tensor input.
6 participants