Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unexpected result from torch.xpu.is_bf16_supported() when XPU is unavailableΒ #152301

Closed
@defaultd661

Description

@defaultd661

πŸ› Describe the bug

When torch.xpu.is_available() returns False, calling torch.xpu.is_bf16_supported() still returns True, which is inconsistent with the expected behavior (should be False).

To Reproduce

import torch
def test_bug():
    print('torch.xpu.is_available() =', torch.xpu.is_available())
    if not torch.xpu.is_available():
        result = torch.xpu.is_bf16_supported()
        print('result =', result)

if __name__ == '__main__':
    test_bug()

Output

torch.xpu.is_available() = False
result = True

Versions

PyTorch version: 2.7.0+cu126
Is debug build: False
CUDA used to build PyTorch: 12.6
ROCM used to build PyTorch: N/A

cc @gujinghui @EikanWang @fengyuan14 @guangyey

Metadata

Metadata

Assignees

Labels

module: xpuIntel XPU related issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions