pytorch / pytorch/executorch

Input mutation leaves an extra output in the final execution plan.

Open
#11,870 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🐛 Describe the bug

If a model contains user input mutation I would expect it to behave similar to buffer mutation.

This means that after export and to_edge there will be an extra output added with the OutputKind == User_Input_Mutation.

However this should be cleaned up before making it to the final emitted artifact. When the copy_ node is inserted in the insert_write_back_for_buffers_pass.py we need to also remove the user input mutation output.

I suspect whats happened is the pass was written before input mutation was supported by torch.export, and now it happens to correctly insert the copy_ (yay!) but does not properly clean up the IO.

Versions

.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in insert_write_back_for_buffers_pass.py and trace the export-to_edge flow for models with user input mutation. Reproduce the final execution plan and inspect the OutputKind == User_Input_Mutation output after the copy_ node is inserted. Done means the final emitted artifact no longer contains that extra output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.