Skip to content

Fix missing function call in is_torch_xla_version#13549

Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix/is-torch-xla-available-missing-call
Open

Fix missing function call in is_torch_xla_version#13549
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix/is-torch-xla-available-missing-call

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a bug in is_torch_xla_version() where is_torch_xla_available (a function) is referenced without parentheses. This checks the truthiness of the function object itself (always True) rather than calling it, so the guard never triggers when torch_xla is unavailable.

The bug

# Before (bug): checks function object truthiness, always True
if not is_torch_xla_available:
    return False

# After (fix): uses the module-level variable, consistent with other version checkers
if not _torch_xla_available:
    return False

The fix uses _torch_xla_available (the module-level boolean) for consistency with is_transformers_version, is_accelerate_version, and all other is_*_version functions in the same file.

Who can review?

@yiyixuxu @DN6

`is_torch_xla_available` is a function but was referenced without
parentheses, checking the truthiness of the function object (always
True) instead of its return value. This means the guard never triggers
and the version comparison proceeds even when torch_xla is unavailable.

Use `_torch_xla_available` (the module-level variable) for consistency
with `is_transformers_version`, `is_accelerate_version`, and other
version checkers in the same file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added utils size/S PR with diff < 50 LOC labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR with diff < 50 LOC utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant