Skip to content

Conversation

@mergennachin
Copy link
Contributor

Summary:
The test was failing because it used hardcoded indices values[0] and
values[11] to check memory sharing, but the graph structure changed and
these indices no longer refer to the expected tensors.

values[0] is now the user input x (offset 336), not the mutable buffer.
The mutable buffer before/after copy_ is at different indices ([6] and [11]).

Fixed by replacing the brittle hardcoded index check with a dynamic approach
that collects all tensor allocations by their (memory_id, offset) and verifies
that at least one memory location is shared between multiple values.

Authored with Claude Code.

Differential Revision: D90892051

Summary:
The test was failing because it used hardcoded indices `values[0]` and
`values[11]` to check memory sharing, but the graph structure changed and
these indices no longer refer to the expected tensors.

`values[0]` is now the user input `x` (offset 336), not the mutable buffer.
The mutable buffer before/after copy_ is at different indices ([6] and [11]).

Fixed by replacing the brittle hardcoded index check with a dynamic approach
that collects all tensor allocations by their (memory_id, offset) and verifies
that at least one memory location is shared between multiple values.

Authored with Claude Code.

Differential Revision: D90892051
Copilot AI review requested due to automatic review settings January 16, 2026 22:10
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 16, 2026

🔗 Helpful Links

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

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 3 Cancelled Jobs

As of commit 8e0d116 with merge base b46f6b5 (image):

NEW FAILURE - The following job has failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

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 Jan 16, 2026
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Jan 16, 2026

@mergennachin has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90892051.

@github-actions
Copy link

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.

@mergennachin mergennachin requested a review from rascani January 16, 2026 22:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a flaky test that was using hardcoded indices to verify memory sharing in the test_mutation_not_double_allocated test. The hardcoded approach broke when the internal graph structure changed.

Changes:

  • Replaced hardcoded index checks (values[0] and values[11]) with a dynamic approach that collects all tensor allocations
  • Introduced a more robust verification that checks for any shared memory allocations rather than checking specific indices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +687 to 691
self.assertGreater(
len(shared_allocations),
0,
"Expected at least one shared memory allocation for mutable buffer",
)
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The new test is too weak compared to the original. While it checks that some memory is shared, it doesn't verify that the specific mutable buffer is shared between the input and output of copy_. The test now passes even if unrelated tensors happen to share memory. Consider verifying that at least one shared allocation contains exactly 2 values (the before/after of copy_), or check that the shared memory size matches the expected mutable buffer size.

Copilot uses AI. Check for mistakes.
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants