Support for Apple Silicon (Metal/MPS) - #357
Conversation
Apple Silicon-compatible fork created with Claude. Use Python 3.13 environment. This fork was created for use with a mps fork of Proteina-Complexa.
…n crash - Add CMake/ninja/scikit-build artifacts to .gitignore (.cmake/reply/, CMakeFiles/, CMakeCache.txt, build.ninja, .ninja_*, .skbuild-info.json, metal_air/, Makefile, cmake_install.cmake, pack_rotamers_*.pdb) - Untrack 108 previously-committed build artifacts via git rm --cached - Fix _cpp_lib.py: use glob to locate _C.so instead of importlib.util.find_spec (find_spec executes the .so init as a side effect, causing double-registration of TORCH_LIBRARY ops and a C++ abort on subsequent load_library calls); add sys.modules guard as additional safety Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Set KMP_DUPLICATE_LIB_OK=TRUE in execute_process calls that import torch so the duplicate-libomp crash no longer prevents resolving the conda torch cmake prefix path. Also auto-discover pybind11's cmake dir from the active Python environment the same way, replacing the need for a system-installed pybind11. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The KMP_DUPLICATE_LIB_OK=TRUE workaround was missing from the execute_process that fetches the torch version, causing an abort and an empty _TORCH_VERSION list → "list GET given empty list" errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merges 40 commits from uw-ipd/tmol (packer rewrite, ContextManager perf refactor, genbonded score term, coordinate constraints, PyTorch 2.13/C++20 support, CPU-only builds, new wheel matrix) into the MPS fork. Resolves 19 conflicting files plus several silent auto-merge issues found by rebuilding and testing: - CMakeLists.txt: combined upstream's generic CUDA/CPU detection with the MPS backend; fixed a latent bug where cartbonded/genbonded .cuda.cu files were unconditionally listed (breaks CPU-only builds). - Consolidated the standalone compiled_inverse_kin pybind module into the unified compiled_ops TORCH_LIBRARY (matching upstream's refactor); kept the MPS CPU-fallback wrapper in kinematics/compiled/__init__.py. - Added ContextManager& parameters throughout device_operations.mps.impl.hh and the kinematics/pack MPS dispatch copies to match upstream's ContextManager perf refactor (mgpu context reuse). - Added missing MPS instantiations and mps_to_dev() round-trips for the two score terms upstream added without MPS awareness (genbonded, hbond's gen_hbond_bases) - fixes a crash from concatenating a stray CPU-resident tensor with MPS tensors in whole-pose scoring. - Fixed _build_static_tails (scoring_module.py) crashing on MPS by building float64 tails only for devices that support float64. - Fixed a stray merge artifact in impose_rotamers.py referencing an undefined `assignment` variable left over from the old function signature. - Dropped the test_custom_op CMake target after upstream removed its source files. Verified: full CPU+MPS rebuild succeeds; all 23 dedicated MPS tests pass; broad CPU sweep across kinematics/pack/score/optimization/relax passes 515/544 non-deselected tests, with remaining failures confirmed pre-existing (PyTorch 2.11 gradcheck check_undefined_grad_support segfault, reproduced on pre-merge commit c70bc78) or requiring a CUDA build (upstream test extensions gated behind TMOL_HAS_CUDA). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This is not merge-ready against the current build matrix. Concrete blockers found in the audit: it accidentally renames/deletes tmol/kinematics/compiled/compiled_inverse_kin.py into a .cmake query file; commits .claude/settings.local.json, CMake query artifacts, and a generated tmol_primitives.metallib; changes the package repository URL to the contributor fork; enables MPS based on runtime hardware availability rather than an explicit tested build target; and has no current macOS MPS build/runtime lane. It also conflicts with the current CPU/CUDA and PyTorch 2.13/2.14 C++ standard/toolchain work. This needs a clean, narrowly scoped successor with generated artifacts excluded and three independent lanes: Linux CPU regression, Linux CUDA regression, and macOS arm64 MPS compile+forward/backward parity. |
This is an MPS fork I needed for a Proteina-Complexa fork running on Apple Silicon.
Florian