Skip to content

Bug: is_torch_xla_version() checks function truthiness instead of _torch_xla_available flag #14641

Description

@Ricardo-M-L

Describe the bug

is_torch_xla_version() in src/diffusers/utils/import_utils.py guards with if not is_torch_xla_available — but is_torch_xla_available is the function defined in the same module, not the cached boolean. A function object is always truthy, so the guard never short-circuits when torch_xla is absent.

When torch_xla is not installed, parse(_torch_xla_version) then operates on an invalid/empty version string instead of returning False.

Expected behavior

The guard should check the module-level boolean _torch_xla_available:

if not _torch_xla_available:
    return False

Found while auditing version checks in import_utils. Fix incoming in PR #14513.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions