Skip to content

Conversation

malfet
Copy link
Contributor

@malfet malfet commented Feb 8, 2025

By appending -frecord-sources -gline-tables-only to the compilation command

Helpful when debugging shaders compiled into libtorch

Test plan: Run
python ../tools/build_with_debinfo.py ../aten/src/ATen/native/mps/kernels/UpSample.metal ../aten/src/ATen/native/mps/operations/UpSample.mm
And then run following to capture shader and check that it contains debug info

import torch
import os
os.environ["MTL_CAPTURE_ENABLED"]="1"
inp = torch.rand(size=(6, 3, 10, 20), device="mps", dtype=torch.float32)
with torch.mps.profiler.metal_capture("bilinear2d"):
    out = torch.nn.functional.interpolate(x, scale_factor=(1.7,0.9), mode="bilinear")
image

Helpful when debugging shaders compiled into libtorch
@malfet malfet requested a review from dcci February 8, 2025 21:48
@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Feb 8, 2025
Copy link

pytorch-bot bot commented Feb 8, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 9 Pending

As of commit 54ea90f with merge base 92b7e61 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@malfet malfet requested a review from albanD February 8, 2025 21:48
line = line.replace("-O2", "-g").replace("-O3", "-g")
# Build Metal shaders with debug infomation
if "xcrun metal " in line and "-frecord-sources" not in line:
line += " -frecord-sources -gline-tables-only"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I wonder why we're passing -gline-tables-only rather than -g0 or -g1 -- I assume we don't care about frame variables and other info for now (in particular for profiling).

@malfet
Copy link
Contributor Author

malfet commented Feb 8, 2025

@pytorchbot merge -f "Lint is green"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the malfet-patch-12 branch March 11, 2025 02:09
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.

3 participants