Skip to content

Commit 44a5533

Browse files
author
Aegis AI Assistant
committed
ci: fix metallib install - use pinned Python mlx wheel instead of broken xcrun metal approach
1 parent e4e9168 commit 44a5533

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

‎.github/workflows/swiftlm_integration.yml‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,26 @@ jobs:
3535
cd SwiftLM
3636
swift build -c release
3737
38-
- name: Compile MLX Metal library from source
38+
- name: Install MLX Metal library (matching pinned version)
3939
run: |
40-
KERNELS_DIR="mlx-swift/Source/Cmlx/mlx/mlx/backend/metal/kernels"
41-
OUT_DIR="SwiftLM/.build/release"
42-
mkdir -p /tmp/mlx_air
43-
44-
# Compile every .metal file to .air
45-
find "$KERNELS_DIR" -name "*.metal" | while read f; do
46-
name=$(basename "$f" .metal)
47-
xcrun metal -sdk macosx \
48-
-I "mlx-swift/Source/Cmlx/mlx/mlx/backend/metal/kernels" \
49-
-c "$f" -o "/tmp/mlx_air/${name}.air" 2>/dev/null || true
50-
done
51-
52-
# Link all .air files into mlx.metallib
53-
AIR_FILES=$(find /tmp/mlx_air -name "*.air")
54-
if [ -n "$AIR_FILES" ]; then
55-
xcrun metallib $AIR_FILES -o "$OUT_DIR/mlx.metallib"
56-
echo "Built mlx.metallib -> $OUT_DIR/mlx.metallib"
40+
# Extract the exact mlx-swift version pinned in SwiftLM/Package.swift
41+
# and install the matching Python mlx wheel — it ships the same metallib
42+
PINNED=$(grep -E 'mlx-swift.*exact:' SwiftLM/Package.swift | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"' | head -1)
43+
echo "SwiftLM pins mlx-swift at: ${PINNED:-latest}"
44+
45+
python3 -m venv /tmp/mlx_venv
46+
if [ -n "$PINNED" ]; then
47+
/tmp/mlx_venv/bin/pip install --quiet "mlx==$PINNED" || \
48+
/tmp/mlx_venv/bin/pip install --quiet mlx # fallback to latest
5749
else
58-
echo "ERROR: No .air files produced — Metal compilation failed"
59-
exit 1
50+
/tmp/mlx_venv/bin/pip install --quiet mlx
6051
fi
6152
53+
MLX_LIB=$(find /tmp/mlx_venv -name "mlx.metallib" | head -1)
54+
echo "Found metallib: $MLX_LIB"
55+
cp "$MLX_LIB" SwiftLM/.build/release/mlx.metallib
56+
echo "Installed mlx.metallib -> SwiftLM/.build/release/"
57+
6258
- name: Run Speculative Decoding Tests
6359
run: |
6460
cd SwiftLM

0 commit comments

Comments
 (0)