Skip to content

Commit e9a7b5b

Browse files
authored
Merge pull request #3 from SharpAI/sync/upstream-latest
πŸ”„ Auto-Sync: Upstream changes from ml-explore/mlx-swift
2 parents d712f06 + bab7dc6 commit e9a7b5b

243 files changed

Lines changed: 19520 additions & 21149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Auto Release Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag-and-release:
13+
name: Create SemVer Tag and Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Essential for retrieving all tags to calculate the next semver bump
20+
21+
- name: Calculate release version (b<commit_count>)
22+
id: tag_version
23+
run: |
24+
COMMIT_COUNT=$(git rev-list --count HEAD)
25+
TAG_NAME="b${COMMIT_COUNT}"
26+
echo "Calculated tag: $TAG_NAME"
27+
echo "new_tag=$TAG_NAME" >> $GITHUB_OUTPUT
28+
29+
# Create and push the tag manually
30+
git tag $TAG_NAME
31+
git push origin $TAG_NAME
32+
33+
- name: Create GitHub Release
34+
uses: softprops/action-gh-release@v2
35+
with:
36+
tag_name: ${{ steps.tag_version.outputs.new_tag }}
37+
name: Release ${{ steps.tag_version.outputs.new_tag }}
38+
body: "Automated release based on commit count ${{ steps.tag_version.outputs.new_tag }}"
39+
generate_release_notes: true
40+
41+
- name: Trigger SwiftLM Dependency Bump
42+
uses: actions/github-script@v6
43+
env:
44+
PR_TOKEN: ${{ secrets.SWIFTLM_PR_TOKEN || secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
45+
with:
46+
github-token: ${{ env.PR_TOKEN }}
47+
script: |
48+
try {
49+
await github.rest.repos.createDispatchEvent({
50+
owner: 'SharpAI',
51+
repo: 'SwiftLM',
52+
event_type: 'dependency_bump',
53+
client_payload: {
54+
source_repo: context.repo.repo,
55+
new_tag: '${{ steps.tag_version.outputs.new_tag }}'
56+
}
57+
});
58+
console.log("Successfully dispatched dependency_bump event to SharpAI/SwiftLM");
59+
} catch (error) {
60+
console.log("Dispatch failed. Ensure SWIFTLM_PR_TOKEN is set in repository secrets with repo scoping.", error);
61+
}

β€Ž.github/workflows/downstream_integration.ymlβ€Ž

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
repository: SharpAI/SwiftLM
2323
path: SwiftLM
2424
token: ${{ secrets.GITHUB_TOKEN }}
25+
submodules: recursive
2526

2627
- name: Install Metal Toolchain
2728
run: xcodebuild -downloadComponent MetalToolchain || true
@@ -37,21 +38,26 @@ jobs:
3738
swift package edit mlx-swift --path $GITHUB_WORKSPACE/mlx-swift-pr
3839
working-directory: SwiftLM
3940

41+
- name: Install MLX Metal library
42+
run: |
43+
python3 -m venv /tmp/mlx_venv
44+
/tmp/mlx_venv/bin/pip install --quiet mlx
45+
METALLIB=$(echo /tmp/mlx_venv/lib/python*/site-packages/mlx/lib/mlx.metallib)
46+
# Make it available system-wide for all subsequent steps
47+
sudo cp "$METALLIB" /usr/local/lib/mlx.metallib || true
48+
echo "MLX_METAL_LIB=$METALLIB" >> $GITHUB_ENV
49+
4050
- name: Build SwiftLM
4151
run: swift build --build-tests
4252
working-directory: SwiftLM
4353

44-
- name: Install MLX Metal library
54+
- name: Copy Metal library to build outputs
4555
run: |
46-
python3 -m venv /tmp/mlx_venv
47-
/tmp/mlx_venv/bin/pip install --quiet mlx
48-
METALLIB=/tmp/mlx_venv/lib/python*/site-packages/mlx/lib/mlx.metallib
56+
METALLIB="$MLX_METAL_LIB"
4957
# Copy to all locations the test runner and linked bundles may search
50-
cp $METALLIB SwiftLM/.build/debug/ || true
51-
find SwiftLM/.build -name "*.xctest" -exec cp $METALLIB {}/Contents/MacOS/ \; 2>/dev/null || true
52-
find SwiftLM/.build -type d \( -name "debug" -o -name "release" \) -exec cp $METALLIB {}/ \; 2>/dev/null || true
53-
# Also copy beside test binaries directly
54-
find SwiftLM/.build -name "*Tests" -type f -exec sh -c 'cp '$METALLIB' "$(dirname {})"/' \; 2>/dev/null || true
58+
find SwiftLM/.build -type d \( -name "debug" -o -name "release" \) -exec cp "$METALLIB" {}/ \; 2>/dev/null || true
59+
find SwiftLM/.build -name "*.xctest" -exec cp "$METALLIB" {}/Contents/MacOS/ \; 2>/dev/null || true
60+
find SwiftLM/.build -name "*Tests" -type f -exec sh -c 'cp "'"$METALLIB"'" "$(dirname ${1})/"' _ {} \; 2>/dev/null || true
5561
5662
- name: Run SwiftLM Integration Tests
5763
run: swift test --parallel --skip-build
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: SwiftLM Integration Tests
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
integration-test:
7+
name: Build & Test SwiftLM
8+
runs-on: macos-15
9+
steps:
10+
- name: Checkout mlx-swift (this repository)
11+
uses: actions/checkout@v4
12+
with:
13+
path: mlx-swift
14+
submodules: recursive
15+
16+
- name: Checkout SwiftLM
17+
uses: actions/checkout@v4
18+
with:
19+
repository: SharpAI/SwiftLM
20+
path: SwiftLM
21+
submodules: recursive
22+
23+
- name: Redirect Dependencies to Local Form
24+
run: |
25+
# Point SwiftLM to the local checkout of mlx-swift PR branch
26+
sed -i '' -E 's|\.package\(url: "https://github.com/SharpAI/mlx-swift\.git".*|\.package(path: "../mlx-swift"),|' SwiftLM/Package.swift
27+
sed -i '' -E 's|\.package\(url: "https://github.com/ml-explore/mlx-swift\.git".*|\.package(path: "../mlx-swift"),|' SwiftLM/Package.swift
28+
29+
# Point the inner mlx-swift-lm submodule to the local checkout of mlx-swift PR branch
30+
sed -i '' -E 's|\.package\(url: "https://github.com/SharpAI/mlx-swift\.git".*|\.package(path: "../../mlx-swift"),|' SwiftLM/mlx-swift-lm/Package.swift
31+
sed -i '' -E 's|\.package\(url: "https://github.com/ml-explore/mlx-swift\.git".*|\.package(path: "../../mlx-swift"),|' SwiftLM/mlx-swift-lm/Package.swift
32+
33+
- name: Build SwiftLM
34+
run: |
35+
cd SwiftLM
36+
swift build -c release
37+
38+
- name: Install MLX Metal library (matching pinned version)
39+
run: |
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
49+
else
50+
/tmp/mlx_venv/bin/pip install --quiet mlx
51+
fi
52+
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+
58+
- name: Run Speculative Decoding Tests
59+
run: |
60+
cd SwiftLM
61+
bash tests/test-speculative-eval.sh
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: πŸ”„ Auto-Sync Upstream
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * *' # Every day at 4:00 AM UTC
6+
workflow_dispatch: # Enable manual triggers
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
sync:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Configure Git
22+
run: |
23+
git config user.name "github-actions[bot]"
24+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
25+
26+
- name: Add Upstream Remote
27+
run: git remote add upstream https://github.com/ml-explore/mlx-swift.git
28+
29+
- name: Fetch Upstream
30+
run: git fetch upstream
31+
32+
- name: Create or Update Sync Branch
33+
run: |
34+
git checkout -B sync/upstream-latest
35+
git reset --hard upstream/main
36+
git push -f origin sync/upstream-latest
37+
38+
- name: Create Pull Request to Main
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
gh pr create --base main --head sync/upstream-latest \
43+
--title "πŸ”„ Auto-Sync: Apple Upstream Repository" \
44+
--body "Automated PR to synchronize SharpAI fork with Apple mlx-swift upstream repository. Please review merge conflicts (if any) and verify CI pipelines." || echo "PR already exists or no changes"

β€ŽCMakeLists.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ endif()
3030
FetchContent_Declare(
3131
mlx-c
3232
GIT_REPOSITORY "https://github.com/ml-explore/mlx-c.git"
33-
GIT_TAG "v0.5.0")
33+
GIT_TAG "v0.6.0")
3434
FetchContent_MakeAvailable(mlx-c)
3535

3636
# swift-numerics

0 commit comments

Comments
Β (0)