Skip to content

Fix torch_logs recipe CPU fallback and device gate (#137285)#3924

Open
yyouretoast wants to merge 1 commit into
pytorch:mainfrom
yyouretoast:fix-torch-logs-137285
Open

Fix torch_logs recipe CPU fallback and device gate (#137285)#3924
yyouretoast wants to merge 1 commit into
pytorch:mainfrom
yyouretoast:fix-torch-logs-137285

Conversation

@yyouretoast

@yyouretoast yyouretoast commented Jun 17, 2026

Copy link
Copy Markdown

Fixes pytorch/pytorch#137285.

Currently, the torch_logs tutorial/recipe renders as "Skipped" on the PyTorch website because the documentation pipeline builds on CPU-only CI environments where torch.cuda.is_available() is False.

This PR addresses the issue by:

  1. Falling back to the CPU device when a CUDA device with compute capability >= 7.0 is unavailable.
  2. Checking if torch.compile is supported dynamically in the build environment using a lightweight compilation test (torch.compile(lambda x: x + 1)).
  3. Gracefully skipping execution using sys.exit(0) instead of throwing errors if the build environment lacks a C++ compiler.
  4. Keeping the recipe's cells de-indented at the top-level so Sphinx-Gallery renders them as individual, step-by-step interactive code blocks on the website.

Testing

  • Verified locally that the script exits with 0 when torch.compile is unsupported.
  • Verified that fallback logic correctly selects the device and does not fail the execution flow.

@pytorch-bot

pytorch-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 4 Awaiting Approval

As of commit 038eaa5 with merge base 3cdec7b (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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

@meta-cla meta-cla Bot added the cla signed label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs are little bit outdated for torch logs

1 participant