Update cpuinfo and apply thread-safe deinitialization patch - #32300
Merged
Vineeth Chelur (crvineeth97) merged 16 commits intoSep 2, 2026
Merged
Conversation
added 7 commits
August 27, 2026 14:30
Copilot started reviewing on behalf of
Vineeth Chelur (crvineeth97)
August 31, 2026 16:26
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Updates cpuinfo and adds lifecycle patches to support thread-safe initialization, cleanup, and repeated DLL loading.
Changes:
- Updates cpuinfo and applies reference-counted deinitialization.
- Balances XNNPACK cpuinfo usage.
- Adds concurrency and DLL unload regression tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
onnxruntime/test/shared_lib/cpuinfo_refcount_test.cc |
Tests cpuinfo lifecycle concurrency. |
onnxruntime/test/shared_lib/cpuinfo_dlopen_test.cc |
Tests repeated DLL unloading and heap growth. |
cmake/vcpkg-ports/xnnpack/portfile.cmake |
Applies the XNNPACK lifecycle patch. |
cmake/vcpkg-ports/cpuinfo/portfile.cmake |
Updates and patches cpuinfo. |
cmake/patches/xnnpack/release_cpuinfo_after_hardware_config.patch |
Releases XNNPACK’s cpuinfo references. |
cmake/patches/cpuinfo/enable_deinit_refcounting.patch |
Implements synchronized, reference-counted cleanup. |
cmake/patches/.gitattributes |
Preserves mixed line endings in the cpuinfo patch. |
cmake/onnxruntime_unittests.cmake |
Registers the new tests. |
cmake/external/xnnpack.cmake |
Applies the XNNPACK patch for fetched sources. |
cmake/external/onnxruntime_external_deps.cmake |
Applies the cpuinfo patch for fetched sources. |
cmake/deps.txt |
Updates the pinned cpuinfo revision. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Vineeth Chelur (crvineeth97)
marked this pull request as ready for review
August 31, 2026 17:35
Copilot started reviewing on behalf of
Vineeth Chelur (crvineeth97)
September 1, 2026 01:42
View session
added 2 commits
August 31, 2026 20:01
Copilot started reviewing on behalf of
Vineeth Chelur (crvineeth97)
September 1, 2026 18:01
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Suppressed comments (1)
onnxruntime/test/shared_lib/cpuinfo_dlopen_test.cc:14
- The test implementation does not match the PR's stated coverage: it loads this custom test DLL once, rather than repeatedly loading/unloading
onnxruntime.dll, exercising XNNPACK, or measuring sustained process-heap growth. Either implement the described end-to-end loop or update the PR's Testing section so it does not claim coverage that this test does not provide.
HMODULE library = LoadLibraryW(ORT_CPUINFO_DLOPEN_TEST_LIBRARY);
eserscor
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pytorch/cpuinfofrom4628dc060ce4e82345dc166bbac875609db4ff69to66ee79c038d70dad9f08705b2c9b3e58f6d8f512, the latest commit on cpuinfomainas of August 27, 2026.The cpuinfo patch can be removed after pytorch/cpuinfo#400, including the ARM64 reinitialization fix, is merged and ORT updates to a revision containing it. The XNNPACK compatibility patch can be removed after the corresponding lifecycle fix is available upstream.
Motivation and Context
microsoft/onnxruntime#28245 integrated
cpuinfo_deinitialize()after pytorch/cpuinfo#387 added it upstream. That implementation was later reverted by pytorch/cpuinfo#411 because initialization and deinitialization were not safe for multiple consumers.Pinning the latest cpuinfo
mainwithout an ORT-side patch would therefore makecpuinfo_deinitialize()a no-op again. Carrying the corrected implementation keeps ORT independent of the pending upstream review while preserving safe cleanup during dynamic DLL unload.Testing
onnxruntime_cpuinfo_refcount_testcovers sequential consumers, concurrent consumers, and reinitialization after final release.main's pinned cpuinfo revision (4628dc060ce4e82345dc166bbac875609db4ff69) and passes against the patched revision (66ee79c038d70dad9f08705b2c9b3e58f6d8f512).onnxruntime_shared_lib_cpuinfo_dlopen_testloads a small DLL containing ORT'sCPUIDInfoand cpuinfo, captures a cpuinfo process-heap allocation, unloads the DLL, and verifies that allocation was released.