Skip to content

Toolchain: Block installation of prebuilt libtorch when enabling MKL#7525

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
Growl1234:develop
Jun 27, 2026
Merged

Toolchain: Block installation of prebuilt libtorch when enabling MKL#7525
mohanchen merged 2 commits into
deepmodeling:developfrom
Growl1234:develop

Conversation

@Growl1234

@Growl1234 Growl1234 commented Jun 26, 2026

Copy link
Copy Markdown

The prebuilt CPU libtorch package embeds and exports MKL implementation symbols, while the oneMKL configuration links against an external oneMKL runtime. These overlapping globally visible symbols can be interposed by the dynamic loader, resulting in an ill-conditioned mixed-MKL process and segmentation faults even in calculations that do not use libtorch functionality at all.

Users of oneMKL builds can still provide a compatible libtorch installation explicitly via --with-libtorch=system or --with-libtorch=<path>. A compatible libtorch should be built against the same external oneMKL stack rather than bundling a separate MKL implementation.

The CMake logic of the orders with MKL and Torch is invalid and thus removed, since this error happens due to symbol conflicts and can't be resolved by simply adjusting linking orders. The right order (BLAS before Torch) is preserved.

Copilot AI review requested due to automatic review settings June 26, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown

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 prevents the toolchain from automatically installing the prebuilt CPU libtorch package when MKL/oneMKL is enabled, to avoid runtime symbol interposition between libtorch’s bundled MKL symbols and an externally linked oneMKL runtime (which can lead to instability/segfaults even outside libtorch usage).

Changes:

  • Add a configuration guard that hard-errors if MATH_MODE=mkl and --with-libtorch requests the prebuilt installer (__INSTALL__).
  • Provide a clear remediation path in the error message: use --with-libtorch=system or --with-libtorch=<path> for a compatible externally-linked libtorch.

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

@QuantumMisaka QuantumMisaka self-assigned this Jun 26, 2026

@QuantumMisaka QuantumMisaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@mohanchen mohanchen added the Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS label Jun 27, 2026
@mohanchen mohanchen merged commit 5231beb into deepmodeling:develop Jun 27, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants