pytorch / pytorch/executorch

insert_write_back_for_buffers_pass should inject copy_ nodes at the earliest possible spot.

Open
#7,345 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue module: exir triaged
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🐛 Describe the bug

Currently the pass injects all the 'copy_' nodes at the end of the graph. It should instead insert them immediately following the last usage of the thing being copied into the original mutable buffer. By waiting till the end we are arbitrarily extending the lifetime of those tensors potentially wasting a non trivial amount of space in the memory plan.

Versions

.

cc @angelayi

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 by locating the insert_write_back_for_buffers_pass entry point and inspect how it currently places copy_ nodes at the end of the graph. Trace the existing pass behavior and memory-plan impact, then verify that each copy_ node is inserted immediately after the last usage of the value copied into the original mutable buffer.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.