Skip to content

Conversation

@mergennachin
Copy link
Contributor

Summary:
The PerModelModeCleanup and GlobalModeCleanup tests were failing because they
compared raw xnn_workspace_t pointers to verify cleanup behavior. However,
memory allocators commonly reuse addresses after deallocation - when
xnn_release_workspace frees memory and xnn_create_workspace immediately
allocates the same size, the allocator may return the same address.

This fix:

  1. Adds a unique instance ID (uint64_t) to XNNWorkspace using an atomic counter
  2. Adds an id() method to retrieve this unique ID
  3. Modifies both cleanup tests to compare IDs instead of raw pointers

This correctly verifies that new workspace objects are created after cleanup,
regardless of memory address reuse by the allocator.

Differential Revision: D90897333

Copilot AI review requested due to automatic review settings January 16, 2026 23:13
@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/16675

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

❌ 2 Cancelled Jobs, 6 Unrelated Failures

As of commit 9591f72 with merge base d305410 (image):

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

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was 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 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 D90897333.

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

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 PR fixes failing workspace manager cleanup tests by introducing unique instance IDs to distinguish between workspace objects, solving the issue where memory allocators reuse addresses after deallocation.

Changes:

  • Added a unique ID mechanism to XNNWorkspace using an atomic counter
  • Modified cleanup tests to compare workspace IDs instead of raw pointers
  • Added explanatory comments documenting why ID comparison is used

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
backends/xnnpack/runtime/XNNWorkspace.h Added atomic counter for unique IDs, id() getter method, and id_ member variable to XNNWorkspace class
backends/xnnpack/test/runtime/test_workspace_manager.cpp Updated PerModelModeCleanup and GlobalModeCleanup tests to compare workspace IDs instead of raw pointers

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

mergennachin added a commit to mergennachin/executorch-1 that referenced this pull request Jan 16, 2026
…raw pointers (pytorch#16675)

Summary:

The PerModelModeCleanup and GlobalModeCleanup tests were failing because they
compared raw xnn_workspace_t pointers to verify cleanup behavior. However,
memory allocators commonly reuse addresses after deallocation - when
xnn_release_workspace frees memory and xnn_create_workspace immediately
allocates the same size, the allocator may return the same address.

This fix:
1. Adds a unique instance ID (uint64_t) to XNNWorkspace using an atomic counter
2. Adds an id() method to retrieve this unique ID
3. Modifies both cleanup tests to compare IDs instead of raw pointers

This correctly verifies that new workspace objects are created after cleanup,
regardless of memory address reuse by the allocator.

Differential Revision: D90897333
…raw pointers (pytorch#16675)

Summary:

The PerModelModeCleanup and GlobalModeCleanup tests were failing because they
compared raw xnn_workspace_t pointers to verify cleanup behavior. However,
memory allocators commonly reuse addresses after deallocation - when
xnn_release_workspace frees memory and xnn_create_workspace immediately
allocates the same size, the allocator may return the same address.

This fix:
1. Adds a unique instance ID (uint64_t) to XNNWorkspace using an atomic counter
2. Adds an id() method to retrieve this unique ID
3. Modifies both cleanup tests to compare IDs instead of raw pointers

This correctly verifies that new workspace objects are created after cleanup,
regardless of memory address reuse by the allocator.

Differential Revision: D90897333
Copilot AI review requested due to automatic review settings January 16, 2026 23:45
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


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

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