Skip to content

Update cpuinfo and apply thread-safe deinitialization patch - #32300

Draft
Vineeth Chelur (crvineeth97) wants to merge 9 commits into
microsoft:mainfrom
crvineeth97:update-cpuinfo-deinit-refcounting
Draft

Update cpuinfo and apply thread-safe deinitialization patch#32300
Vineeth Chelur (crvineeth97) wants to merge 9 commits into
microsoft:mainfrom
crvineeth97:update-cpuinfo-deinit-refcounting

Conversation

@crvineeth97

@crvineeth97 Vineeth Chelur (crvineeth97) commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Update pytorch/cpuinfo from 4628dc060ce4e82345dc166bbac875609db4ff69 to 66ee79c038d70dad9f08705b2c9b3e58f6d8f512, the latest commit on cpuinfo main as of August 27, 2026.
  • Carry the thread-safe, reference-counted initialization and deinitialization changes from pytorch/cpuinfo#400 as one shared ORT patch used by both FetchContent and vcpkg.
  • Reset Windows ARM64 cache-population state on each initialization so repeated DLL load/unload cycles cannot reuse stale cache indices.
  • Scope XNNPACK's cpuinfo references to hardware discovery so XNNPACK-enabled ORT builds do not retain unmatched references during DLL unload.

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 main without an ORT-side patch would therefore make cpuinfo_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_test covers sequential consumers, concurrent consumers, and reinitialization after final release.
  • Verified this test fails against ORT main's pinned cpuinfo revision (4628dc060ce4e82345dc166bbac875609db4ff69) and passes against the patched revision (66ee79c038d70dad9f08705b2c9b3e58f6d8f512).
  • onnxruntime_shared_lib_cpuinfo_dlopen_test repeatedly loads and unloads onnxruntime.dll, initializes cpuinfo through hardware discovery, exercises XNNPACK when enabled, and detects sustained Windows process-heap growth.
  • Verified the FetchContent patch sequences for the default, Linux, and Windows ARM64/ARM64EC paths, plus the vcpkg patch sequence, apply with zero rejected hunks.

@crvineeth97 Vineeth Chelur (crvineeth97) changed the title Update cpuinfo with thread-safe deinitialization Update cpuinfo and apply thread-safe deinitialization patch Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant