Skip to content

Add Swift port of V-JEPA2 with mlx-swift and camera apps #5

Add Swift port of V-JEPA2 with mlx-swift and camera apps

Add Swift port of V-JEPA2 with mlx-swift and camera apps #5

Workflow file for this run

name: Model Comparison Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache model weights
uses: actions/cache@v3
with:
path: weights
key: ${{ runner.os }}-model-weights-vitl-v1
restore-keys: |
${{ runner.os }}-model-weights-
- name: Cache MLX build
uses: actions/cache@v3
with:
path: ../mlx
key: ${{ runner.os }}-mlx-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-mlx-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build libblas-dev liblapack-dev liblapacke-dev libopenblas-dev gfortran
- name: Build and install MLX from source
run: |
cd ..
if [ ! -d "mlx" ]; then
git clone https://github.com/ml-explore/mlx.git
fi
cd mlx
pip install .
cd ../vjepa2-mlx
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
pip install -e .
- name: Clone and install vjepa2 repository
run: |
cd ..
if [ ! -d "vjepa2" ]; then
git clone https://github.com/facebookresearch/vjepa2.git
fi
cd vjepa2
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install -e .
- name: Run Python tests
run: |
pytest tests/test_model_comparison.py -v -s --tb=short
- name: Export test data for cross-language tests
run: |
python tests/export_test_data.py
swift-tests:
runs-on: macos-14 # macOS with Apple Silicon
needs: test # Run after Python tests to ensure test data is exported
steps:
- uses: actions/checkout@v4
- name: Set up Swift
uses: swift-actions/setup-swift@v1
with:
swift-version: "5.9"
- name: Set up Python (for test data export)
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install mlx mlx-lm numpy
pip install -e .
- name: Export test data
run: |
python tests/export_test_data.py
- name: Cache Swift packages
uses: actions/cache@v3
with:
path: swift/.build
key: ${{ runner.os }}-swift-${{ hashFiles('swift/Package.swift') }}
restore-keys: |
${{ runner.os }}-swift-
- name: Build Swift package
working-directory: swift
run: |
swift build -c release
- name: Run Swift unit tests
working-directory: swift
run: |
swift test --filter VJEPA2Tests
- name: Run cross-language tests
working-directory: swift
run: |
swift test --filter CrossLanguageTests