Skip to content

fix(moe): gracefully catch safetensors I/O errors to prevent deadlock crashes #117

fix(moe): gracefully catch safetensors I/O errors to prevent deadlock crashes

fix(moe): gracefully catch safetensors I/O errors to prevent deadlock crashes #117

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-and-test:
name: Build and Test (macOS 15)
runs-on: macos-15
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Metal Toolchain
run: xcodebuild -downloadComponent MetalToolchain || true
- name: Cache Swift packages
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-v2-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-v2-
- name: Clear stale module cache
run: find .build -type d -name ModuleCache -exec rm -rf {} + 2>/dev/null || true
- name: Checkout SharpAI/mlx-swift
uses: actions/checkout@v4
with:
repository: SharpAI/mlx-swift
path: mlx-swift
- name: Redirect mlx-swift dependency to local checkout
run: |
sed -i '' -E 's|\.package\(path: "\.\./mlx-swift"\),|\.package(path: "./mlx-swift"),|' Package.swift
- name: Resolve dependencies
run: swift package resolve
- name: Build (Release)
run: swift build -c release -Xswiftc -enable-testing --build-tests
- name: Install MLX Metal library
run: |
python3 -m venv /tmp/mlx_venv
/tmp/mlx_venv/bin/pip install --quiet mlx
MLX_LIB=$(find /tmp/mlx_venv -name "mlx.metallib" | head -n 1)
# Copy to build root and release root
cp $MLX_LIB .build/release/ 2>/dev/null || true
cp $MLX_LIB ./ 2>/dev/null || true
# Find the xctest bundle's MacOS directory and put it right next to the test runner binary
find .build -type d -name "MacOS" -exec cp $MLX_LIB {}/ \; 2>/dev/null || true
# Also put it in Resources just in case
find .build -type d -name "Resources" -exec cp $MLX_LIB {}/ \; 2>/dev/null || true
# Aggressive: put it next to any executable in the release dir
find .build -type f -executable -exec cp $MLX_LIB $(dirname "{}")/ \; 2>/dev/null || true
- name: Run Library Tests (Metal Accelerated)
run: swift test -c release --skip-build
- name: Gemma 4 PLE Stabilization Gate
run: |
# Verify PLE signal stability with full kernel support
swift test -c release --filter Gemma4StabilizationTests --skip-build
- name: Speculative Decoding Protection Gate
run: |
# Ensure speculative decoding parity and cache integrity are never regressed
swift test -c release --filter SpeculativeDecodingTests --skip-build
- name: High-Rigor Architectural Parity (Gemma 4)
run: |
# Verify Gemma 4 Gated Residuals and PLE math integrity
swift test -c release --filter Gemma4Tests --skip-build
- name: Performance & Memory Ceiling Audit (8GB Target)
run: |
# Enforce 6GB RSS limit and throughput baselines
swift test -c release --filter PerformanceRegressionTests --skip-build
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: library-test-results
path: .build/artifacts/
retention-days: 7
integration-test:
name: Build & Test SwiftLM Integration
runs-on: macos-15
steps:
- name: Checkout mlx-swift-lm (this repository)
uses: actions/checkout@v4
with:
path: mlx-swift-lm
submodules: recursive
- name: Checkout SwiftLM
uses: actions/checkout@v4
with:
repository: SharpAI/SwiftLM
path: SwiftLM
submodules: recursive
- name: Redirect Dependencies to Local Form
run: |
cd SwiftLM
# Replace the local submodule with the actively checked out code
rm -rf mlx-swift-lm
cp -r ../mlx-swift-lm .
- name: Update mlx-swift submodule to latest main
run: |
cd SwiftLM/mlx-swift
git fetch origin main
git checkout origin/main
- name: Build SwiftLM
run: |
cd SwiftLM
swift build -c release
- name: Install MLX Metal library
run: |
cd SwiftLM
python3 -m venv /tmp/mlx_venv
/tmp/mlx_venv/bin/pip install --quiet mlx
MLX_LIB=$(find /tmp/mlx_venv -name "mlx.metallib" | head -n 1)
cp $MLX_LIB .build/release/ 2>/dev/null || true
- name: Run Speculative Decoding Tests
run: |
cd SwiftLM
bash tests/test-speculative-eval.sh