Skip to content

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

Merged
larryliu0820 merged 3 commits into
pytorch:mainfrom
jhelsby:bugfix/memoryplanningverifier/douserinputsexist-noprims
Jun 26, 2025
Merged

Update MemoryPlanning Verifier to only assume model has user input if it has at least one tensor input#10617
larryliu0820 merged 3 commits into
pytorch:mainfrom
jhelsby:bugfix/memoryplanningverifier/douserinputsexist-noprims

Conversation

@jhelsby

@jhelsby jhelsby commented May 1, 2025

Copy link
Copy Markdown
Contributor

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.]

@pytorch-bot

pytorch-bot Bot commented May 1, 2025

Copy link
Copy Markdown

🔗 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
@pytorch-bot

pytorch-bot Bot commented May 1, 2025

Copy link
Copy Markdown

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

@jhelsby

jhelsby commented May 1, 2025

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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

jhelsby commented May 9, 2025

Copy link
Copy Markdown
Contributor Author

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.
@digantdesai

Copy link
Copy Markdown
Contributor

cc @JacobSzwejbka can you take a look? 🙏

@larryliu0820

Copy link
Copy Markdown
Contributor

@JacobSzwejbka gentle ping

@JacobSzwejbka JacobSzwejbka left a comment

Copy link
Copy Markdown
Contributor

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

jhelsby commented Jun 26, 2025

Copy link
Copy Markdown
Contributor Author

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

@larryliu0820

Copy link
Copy Markdown
Contributor

Kicked off CI jobs.

@larryliu0820

Copy link
Copy Markdown
Contributor

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

@jhelsby

jhelsby commented Jun 26, 2025

Copy link
Copy Markdown
Contributor Author

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

jhelsby commented Jun 26, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

jhelsby commented Jun 26, 2025

Copy link
Copy Markdown
Contributor Author

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