Skip to content

feat: support Intel GPUs in Array API testing #31650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

icfaust
Copy link
Contributor

@icfaust icfaust commented Jun 25, 2025

Following on from #27098 which added support for Apple's Metal devices, this will add the ability to run scikit-learn's array_api testing using Intel GPUs via PyTorch (named XPU devices). This enables scikit-learn to test on discrete and integrated GPUs using the Xe architecture, which was made possible with PyTorch since release 2.4.

It will first skip if the PyTorch version does not have xpu interfaces (indicating PyTorch < 2.4), and secondly will skip if a device is unavailable.

Copy link

github-actions bot commented Jun 25, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: ac4dcc1. Link to the linter CI: here

@icfaust icfaust changed the title feat: enable Intel GPU array_api testing feat: enable Intel GPU Array API testing Jun 25, 2025
@icfaust icfaust changed the title feat: enable Intel GPU Array API testing feat: support Intel GPUs in Array API testing Jun 25, 2025
@napetrov
Copy link
Contributor

@ogrisel - might be you will be interested in this

@betatim
Copy link
Member

betatim commented Jun 25, 2025

Thanks for this! One question about the pragma nocover - is this because we don't have Intel GPUs in any of our CI or because the default PyTorch we use doesn't contain support for it? Or a third reason? Basically, it would be nice to make use of it so that we can catch bugs/it doesn't bitrot.

@icfaust
Copy link
Contributor Author

icfaust commented Jun 25, 2025

Thanks for this! One question about the pragma nocover - is this because we don't have Intel CPUs in any of our CI or because the default PyTorch we use doesn't contain support for it? Or a third reason? Basically, it would be nice to make use of it so that we can catch bugs/it doesn't bitrot.

Great question, it truly stems from me not having done my homework right. I had included a branch for the case that a PyTorch < 2.4 was used for testing, where the later call to torch.xpu would definitely fail. Since the CI systems use 2.4.1+ (from the lock files as far as I see) Codecov complained to me that line 1349 in _testing.py from the PR was uncovered. I had followed the convention in the same function for cupy underneath, but a better solution would be to # nocover the if hasattr(xp, "xpu"): or remove that branch entirely, rather than block coverage for all of the xpu skip checks. I'm willing to go with either, let me know what you'd recommend @betatim

For the impact on sklearn: it will only introduce a lot of skipped tests as none of the runners (as far as I see) have any GPU hardware that would interface with integrated GPUs starting with Intel's Meteor Lake or any Intel discrete GPUs. This seems to also unfortunately be the case with the Apple PyTorch Metal branch (as shown on codecov). I'll add some screenshots of some functional array_api testing in our environments using an Intel Max GPU.

@betatim
Copy link
Member

betatim commented Jun 26, 2025

Thanks for the explanations! Let's keep it the way the cupy nocover is. The main reason I asked is that I looked at the MPS clause above which had no "nocover" and that made me wonder why it was needed here.

Fine for me to skip testing this in CI. It would have been nice to have it but not required. Getting "exotic" hardware for CI is hard work :D

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @icfaust. Looking forward to seeing some CI runners with integrated GPUs.

@ogrisel ogrisel merged commit 6ccb204 into scikit-learn:main Jun 26, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants