Skip to content

fix(_is_mslk_available): guard against missing CUDA/ROCm runtime#4544

Open
space192 wants to merge 2 commits into
pytorch:mainfrom
space192:af/fallback-to-false
Open

fix(_is_mslk_available): guard against missing CUDA/ROCm runtime#4544
space192 wants to merge 2 commits into
pytorch:mainfrom
space192:af/fallback-to-false

Conversation

@space192

Copy link
Copy Markdown

Summary

_is_mslk_available() crashes with OSError when mslk is installed but no CUDA/ROCm runtime is present (e.g. CPU-only submission nodes).

The function is called at module level in torchao/quantization/quantize_/workflows/float8/float8_tensor.py, so the crash propagates through any transitive import chain that touches torchao — including transformers, vllm, etc. — even when the user never explicitly imports mslk or uses FP8.

Repro:

# On a CPU-only machine with mslk installed from the CUDA PyTorch index
python -c "import torchao"
# OSError: Could not load this library: .../mslk/mslk.so

Fix

Check torch.cuda.is_available() before attempting import mslk. This covers both CUDA and ROCm (HIP maps to the CUDA API surface). A warning is emitted so users know mslk was skipped and why.

Test plan

  • Verified on a CPU-only node: import torchao succeeds with a warning instead of crashing.
  • On GPU nodes: behavior is unchanged, mslk loads normally.

@pytorch-bot

pytorch-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 29, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/rocm

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rocm CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: rocm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant