From cc961c5810cef22088b4db1a3577284286e47c57 Mon Sep 17 00:00:00 2001 From: Kellen Sun <66171946+kellen-sun@users.noreply.github.com> Date: Thu, 15 Jan 2026 21:37:34 -0500 Subject: [PATCH 1/6] Add CI workflow for testing on M1 Mac --- .github/workflows/main.yml | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..aeb8da1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ +name: CI Test + +on: + pull_request: + branches: [ "main" ] + push: + branches: [ "main" ] + +jobs: + test-apple-silicon: + name: Test on M1 Mac + # 'macos-14-xlarge' or 'macos-latest-xlarge' targets the M1 runners + runs-on: macos-14-xlarge + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' # Caches dependencies to speed up future runs + + - name: Install Build Dependencies + run: | + pip install --upgrade pip setuptools wheel cmake + + - name: Build Backend (CMake) + run: | + mkdir build + cd build + cmake .. + cmake --build . + + - name: Install Library + # Installs your library in editable mode + run: pip install -e . + + - name: Install Test Dependencies + run: pip install pytest torch torchvision torchaudio + + - name: Run Tests + run: | + pytest tests/ From 95442e2742a723c98633d35cc98905424f537e8b Mon Sep 17 00:00:00 2001 From: Kellen Sun <66171946+kellen-sun@users.noreply.github.com> Date: Thu, 15 Jan 2026 21:44:43 -0500 Subject: [PATCH 2/6] Change runner to macos-14 for M1 Mac tests --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aeb8da1..8b1479c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,9 +9,8 @@ on: jobs: test-apple-silicon: name: Test on M1 Mac - # 'macos-14-xlarge' or 'macos-latest-xlarge' targets the M1 runners - runs-on: macos-14-xlarge - + runs-on: macos-14 + steps: - name: Checkout repository uses: actions/checkout@v4 From b3b1aa4d29add4240e5ca8b0249970e13b87f0fb Mon Sep 17 00:00:00 2001 From: Kellen Sun <66171946+kellen-sun@users.noreply.github.com> Date: Thu, 15 Jan 2026 22:00:16 -0500 Subject: [PATCH 3/6] Update GitHub Actions workflow for Python setup Removed caching for pip and simplified test dependencies. --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b1479c..8b2f29e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.10' - cache: 'pip' # Caches dependencies to speed up future runs - name: Install Build Dependencies run: | @@ -37,7 +36,7 @@ jobs: run: pip install -e . - name: Install Test Dependencies - run: pip install pytest torch torchvision torchaudio + run: pip install pytest - name: Run Tests run: | From 418fc47c167a8387ff76ebf917e05c6b2528e8c9 Mon Sep 17 00:00:00 2001 From: Kellen Sun <66171946+kellen-sun@users.noreply.github.com> Date: Thu, 15 Jan 2026 22:02:36 -0500 Subject: [PATCH 4/6] Add pybind11 to build dependencies --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b2f29e..d8794c7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: - name: Install Build Dependencies run: | - pip install --upgrade pip setuptools wheel cmake + pip install --upgrade pip setuptools wheel cmake pybind11 - name: Build Backend (CMake) run: | From 65138a8a7a4952ec277d1172279f4f9f077d3560 Mon Sep 17 00:00:00 2001 From: Kellen Sun <66171946+kellen-sun@users.noreply.github.com> Date: Thu, 15 Jan 2026 22:07:33 -0500 Subject: [PATCH 5/6] Update CMake command to include pybind11 directory --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8794c7..8dc9a96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: run: | mkdir build cd build - cmake .. + cmake -Dpybind11_DIR=$(python -m pybind11 --cmakedir) .. cmake --build . - name: Install Library From b0b3bb55ede809c75a298f5cfa3b5deebbd856c3 Mon Sep 17 00:00:00 2001 From: Kellen Sun Date: Thu, 15 Jan 2026 22:16:06 -0500 Subject: [PATCH 6/6] apple stuffs --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aea68e1..d0fdbb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,18 @@ pybind11_add_module( cpp/src/metal_utils.mm ) +if(APPLE) + find_library(METAL_LIB Metal) + find_library(MPS_LIB MetalPerformanceShaders) + find_library(FOUNDATION_LIB Foundation) + + target_link_libraries(_backend PRIVATE + ${METAL_LIB} + ${MPS_LIB} + ${FOUNDATION_LIB} + ) +endif() + # Put output in python package set_target_properties(_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/py/Forge