Skip to content

Fix GPU Hang in Gemma4 and add metrics #89

Fix GPU Hang in Gemma4 and add metrics

Fix GPU Hang in Gemma4 and add metrics #89

name: Downstream Integration Test
on:
pull_request:
branches: [ main ]
jobs:
test-swiftlm-umbrella:
name: Test with SwiftLM (Umbrella Repo)
runs-on: macos-15
timeout-minutes: 40
steps:
- name: Checkout PR branch (mlx-swift-lm)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout SwiftLM (Parent Repo)
uses: actions/checkout@v4
with:
repository: SharpAI/SwiftLM
path: SwiftLM
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
- name: Point SwiftLM to this PR's mlx-swift-lm
# SwiftLM uses `.package(path: "./mlx-swift-lm")` so we replace that
# directory with the current PR checkout directly.
run: |
# Remove the pinned subdir and copy our PR checkout instead of symlinking to avoid git submodule errors
rm -rf SwiftLM/mlx-swift-lm
# Copy everything except SwiftLM itself if we are in the root
mkdir -p SwiftLM/mlx-swift-lm
find . -mindepth 1 -maxdepth 1 ! -name "SwiftLM" -exec cp -r {} SwiftLM/mlx-swift-lm/ \;
- name: Update mlx-swift submodule to latest main
# SwiftLM's mlx-swift submodule pin may lag behind main.
# Pull latest so new APIs are available for the build.
run: |
cd SwiftLM/mlx-swift
git fetch origin main
git checkout origin/main
- name: Install Metal Toolchain
run: xcodebuild -downloadComponent MetalToolchain || true
- name: Cache Swift packages
uses: actions/cache@v4
with:
path: SwiftLM/.build
key: ${{ runner.os }}-swiftlm-spm-${{ hashFiles('SwiftLM/Package.resolved') }}
restore-keys: ${{ runner.os }}-swiftlm-spm-
- name: Resolve Dependencies
run: swift package resolve
working-directory: SwiftLM
- name: Install MLX Metal library
run: |
python3 -m venv /tmp/mlx_venv
/tmp/mlx_venv/bin/pip install --quiet mlx
METALLIB=$(echo /tmp/mlx_venv/lib/python*/site-packages/mlx/lib/mlx.metallib)
# Make it available system-wide for all subsequent steps
sudo cp "$METALLIB" /usr/local/lib/mlx.metallib || true
echo "MLX_METAL_LIB=$METALLIB" >> $GITHUB_ENV
- name: Build SwiftLM
run: swift build --build-tests
working-directory: SwiftLM
- name: Copy Metal library to build outputs
run: |
METALLIB="$MLX_METAL_LIB"
# Copy to all locations the test runner and linked bundles may search
find SwiftLM/.build -type d \( -name "debug" -o -name "release" \) -exec cp "$METALLIB" {}/ \; 2>/dev/null || true
find SwiftLM/.build -name "*.xctest" -exec cp "$METALLIB" {}/Contents/MacOS/ \; 2>/dev/null || true
find SwiftLM/.build -name "*Tests" -type f -exec sh -c 'cp "'"$METALLIB"'" "$(dirname ${1})/"' _ {} \; 2>/dev/null || true
- name: Run SwiftLM Integration Tests
run: swift test --parallel --skip-build
working-directory: SwiftLM