Repository navigation
[XPU] Support XPU devices mostly by unifying XPU, CUDA and other supported backends - #252
Merged
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Documentation | 13 minor |
| Security | 7 high |
🟢 Metrics 18 complexity
Metric Results Complexity 18
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Contributor
Author
|
Hey @bowen-bd, gentle ping to gauge your interest in handling the XPU backend alongside CUDA with this PR, while keeping the approach generic for HIP and other backends in the future |
Add Intel GPU (XPU) as a selectable torch backend alongside CUDA, MPS and CPU, so CHGNet runs on Intel Data Center GPU Max systems such as ALCF Aurora. `pynvml` was a mandatory dependency imported at module scope, so `import chgnet` failed on any machine without NVIDIA's management library. It only ranked GPUs by free memory, which `mem_get_info` already does on both CUDA and XPU, so the dependency is dropped rather than made optional. Indices now come from `device_count()`, which fixes two latent CUDA bugs: NVML ignored `CUDA_VISIBLE_DEVICES` and could name an unaddressable GPU, and an empty device list raised IndexError. `cuda_devices_sorted_by_free_mem` stays as an alias and `check_cuda_mem` keeps its name, so existing callers are unaffected. Ranking degrades to an unindexed device where free memory cannot be queried: `torch.xpu.mem_get_info` needs torch 2.6, and on multi-tile Intel GPUs the underlying SYCL query is per card rather than per tile.
Test `determine_device` backend precedence by monkeypatching each `is_available`, so CUDA/XPU/MPS/CPU selection is exercised on any runner. `test_gpu_devices_are_valid_torch_indices` asserts the returned indices match `device_count()`, which fails if a library that ignores the visible-device mask is reintroduced. Verified unmasked and under `ZE_AFFINITY_MASK=3,7`.
Two jobs, both gated on `workflow_dispatch` or an `xpu` pull request label, so repositories without Intel GPUs are unaffected and `test.yml` is untouched. `test-xpu-build` runs on `ubuntu-latest`: XPU torch ships from a separate index, so it installs that build with no GPU attached and checks device selection falls back to cpu. `test-xpu` runs the suite on a self-hosted runner labelled `intel-gpu`. A SYCL OpenCL-CPU runner cannot substitute, as torch filters `torch.xpu` to Level Zero GPU platforms only. Also document the supported devices in the README.
abagusetty
force-pushed
the
xpu-support
branch
from
September 3, 2026 18:43
2ec74ba to
abdc1a2
Compare
Collaborator
|
Thanks for the contribution! |
bowen-bd
enabled auto-merge (squash)
September 8, 2026 18:03
bowen-bd
disabled auto-merge
September 15, 2026 06:23
Contributor
Author
|
Great! Thanks so much for taking time @bowen-bd |
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.
Summary
Major changes:
pynvmldependency with more robusttorch.cuda.mem_get_infofor generalized supportChecklist