Skip to content

Reuse buffers in op handlers#20524

Open
metascroy wants to merge 1 commit into
mainfrom
reuse-temps
Open

Reuse buffers in op handlers#20524
metascroy wants to merge 1 commit into
mainfrom
reuse-temps

Conversation

@metascroy

Copy link
Copy Markdown
Contributor

This PR makes the MLX backend's compound op emitters reuse buffers in place so MLX can donate them, rewriting the batch_norm normalize chain and the sample gumbel/top-p chain to thread results through a small set of temp slots (out==in) instead of allocating a fresh temp per step, while keeping separate slots for multi-use values.

An audit of the remaining emitters/handlers (conv, pooling, gated-delta-rule, SDPA, quantized/gguf linear, and the C++ runtime handlers) confirmed they already reuse buffers or are inherently non-donating (views/fused kernels), so no further changes were needed.

@pytorch-bot

pytorch-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

✅ You can merge normally! (2 Unrelated Failures)

As of commit e7b94bf with merge base 7e0151e (image):

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@meta-cla meta-cla 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 Jun 26, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant