10000 Correct torch.xpu.is_bf16_supported return False if no XPU detected by guangyey · Pull Request #152317 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Correct torch.xpu.is_bf16_supported return False if no XPU detected #152317

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

Closed
wants to merge 3 commits into from

Conversation

guangyey
Copy link
Collaborator
@guangyey guangyey commented Apr 28, 2025

Stack from ghstack (oldest at bottom):

Motivation

Fix #152301
When XPU is not available, calling torch.xpu.is_bf16_supported() still returns True, which is inconsistent with the expected behavior (should be False).

Solution

Align to other backend, adding including_emulation to torch.xpu.is_bf16_supported and,

  • return False if XPU is not available
  • return True if including_emulation is True
  • return torch.xpu.get_device_properties().has_bfloat16_conversions if including_emulation is False, it means if the device could generate SPIRV code for bf16.

cc @gujinghui @EikanWang @fengyuan14

Copy link
pytorch-bot bot commented Apr 28, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/152317

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 3 New Failures

As of commit bc97ddf with merge base 13dcf80 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

guangyey added a commit that referenced this pull request Apr 28, 2025
@@ -66,9 +66,14 @@ def is_available() -> bool:
return device_count() > 0


def is_bf16_supported():
def is_bf16_supported(including_emulation: bool = True):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

API align to other backend, refer to

def is_bf16_supported(including_emulation: bool = True):

Copy link
Collaborator
@EikanWang EikanWang Apr 28, 2025

Choose a reason for hiding this comment

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

@guangyey , why does XPU need to provide this optional parameter? Is there any case where one Intel GPU does not support BF16 native, while the Intel GPU software stack emulates BF16 for the Intel GPU?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In simple terms, eager mode depends on emulation, while graph mode requires native support to fully leverage performance optimization.

Copy link
Collaborator

Choose a reason for hiding this comment

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

guangyey added a commit that referenced this pull request Apr 28, 2025
@guangyey guangyey added keep-going Don't stop on first failure, keep running tests until the end ciflow/xpu Run XPU CI tasks module: xpu Intel XPU related issues labels Apr 28, 2025
@guangyey guangyey added release notes: xpu release notes category ciflow/trunk Trigger trunk jobs on your pull request labels Apr 28, 2025
Skylion007
Skylion007 previously approved these changes Apr 28, 2025
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey
Copy link
Collaborator Author
guangyey commented May 6, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@guangyey
Copy link
Collaborator Author
guangyey commented May 6, 2025

@pytorchbot rebase

@guangyey guangyey moved this to Approved in PyTorch Intel May 6, 2025
@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/guangyey/143/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/152317)

pytorchmergebot pushed a commit that referenced this pull request May 6, 2025
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: New commits were pushed while merging. Please rerun the merge command.

Details for Dev Infra team Raised by workflow job

@guangyey
Copy link
Collaborator Author
guangyey commented May 6, 2025

"The failures are irrelevant, we have issue a ticket to track them, refer to #152912"
@pytorchbot merge -i

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 3 checks: xpu / linux-jammy-xpu-2025.0-py3.9 / test (default, 2, 4, linux.idc.xpu), xpu / linux-jammy-xpu-2025.0-py3.9 / test (default, 3, 4, linux.idc.xpu), xpu / linux-jammy-xpu-2025.0-py3.9 / test (default, 1, 4, linux.idc.xpu)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks keep-going Don't stop on first failure, keep running tests until the end Merged module: xpu Intel XPU related issues open source release notes: xpu release notes category
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants
0