Last active
June 16, 2025 18:54
-
-
Save eddiebergman/1e11de0ddf2c78957109b9fec0cd540c to your computer and use it in GitHub Desktop.
Compiling `pytorch` for debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone [email protected]:pytorch/pytorch.git | |
cd pytorch | |
uv venv -p 3.13 | |
source .venv/bin/activate | |
uv pip install pyyaml setuptools pip | |
brew install cmake ninja ccache # ccache was recommended on first compile | |
python setup.py develop | |
# wait like 10 minutes (M4 Pro, all CPUS burning) |
And in lldb
lldb -- python -c "import torch; print(torch.sort(torch.randint(-50, 50, (512,), device='mps', dtype=torch.int64)))"
(lldb) breakpoint set --file Sort.mm --line 20
Breakpoint 2: where = libtorch_cpu.dylib`at::native::structured_sort_stable_out_mps::impl(at::Tensor const&, std::__1::optional<bool>, long long, bool, at::Tensor const&, at::Tensor const&) + 64 at Sort.mm:29:25, address = 0x000000032ec9a320
(lldb) run
Process 43489 launched: '/Users/eddiebergman/code/pytorch/.venv/bin/python' (arm64)
Process 43489 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
frame #0: 0x00000003089fe320 libtorch_cpu.dylib`at::native::structured_sort_stable_out_mps::impl(this=0x000000016fdfc970, self=0x000000016fdfde30, stable= Has Value=true , dim=-1, descending=false, values=0x000000016fdfc978, indices=0x000000016fdfc980) at Sort.mm:29:25
26 const Tensor& indices) {
27 using namespace mps;
28
-> 29 bool macOS13_3_plus = is_macos_13_or_newer(MacOSVersion::MACOS_VER_13_3_PLUS);
30 MPS_CHECK_INT64_OP_SUPPORTED(self, macOS13_3_plus, "sort_stable_out");
31
32 if (self.numel() == 0) {
Target 0: (python) stopped.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also some more found out later: https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md#make-no-op-build-fast