Skip to content

Commit c3c316e

Browse files
solderzzcclaude
andcommitted
fix: wire up Gemma4MTPBench target + repair regressed mlx-swift-lm/mlx-swift submodule pins
mlx-swift-lm was uncommitted-pinned backward past the commit that introduced DualModelMTP/MTPTokenIterator/Gemma4AssistantModel, breaking Gemma4MTPBench and forcing MTP speculative decoding to be commented out in InferenceEngine.swift as a workaround. Repointing both submodules to their current origin/main tips (mlx-swift-lm past the merged DSA stage-2 PR #61, mlx-swift past the matching MLXFast.fromFp8 addition) restores those types and lets the benchmark build again — no source workaround needed. Also adds scripts/bootstrap_local_tests.sh, which mirrors CI's "Install MLX Metal library" step (pip install mlx, copy its bundled metallib into every built .xctest bundle) so `swift test` is runnable locally without the manual cmake+make dance. Addresses the Tier 3 item in #128. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 71ccdfd commit c3c316e

3 files changed

Lines changed: 48 additions & 2 deletions

File tree

‎Package.swift‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ let package = Package(
99
.library(name: "DFlash", targets: ["DFlash"]),
1010
.executable(name: "SwiftLM", targets: ["SwiftLM"]),
1111
.executable(name: "SwiftBuddy", targets: ["SwiftBuddy"]),
12-
.executable(name: "DFlashKernelBench", targets: ["DFlashKernelBench"])
12+
.executable(name: "DFlashKernelBench", targets: ["DFlashKernelBench"]),
13+
.executable(name: "Gemma4MTPBench", targets: ["Gemma4MTPBench"])
1314
],
1415
dependencies: [
1516
// Local Apple MLX Swift fork for C++ extensions
@@ -53,6 +54,18 @@ let package = Package(
5354
],
5455
path: "Sources/DFlashKernelBench"
5556
),
57+
// ── Gemma4 MTP Speculative Decoding Benchmark ───────────────
58+
.executableTarget(
59+
name: "Gemma4MTPBench",
60+
dependencies: [
61+
"MLXInferenceCore",
62+
.product(name: "MLX", package: "mlx-swift"),
63+
.product(name: "MLXLLM", package: "mlx-swift-lm"),
64+
.product(name: "MLXLMCommon", package: "mlx-swift-lm"),
65+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
66+
],
67+
path: "Sources/Gemma4MTPBench"
68+
),
5669
// ── STFT Audio Profiling Testing Script (macOS only) ───────────
5770
.executableTarget(
5871
name: "SwiftLMTestSTFT",

‎scripts/bootstrap_local_tests.sh‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Makes `swift test` runnable locally without CI's help.
3+
#
4+
# A bare `swift test` aborts with "Failed to load the default metallib"
5+
# because Package.swift links MLX but nothing on a local machine ever builds
6+
# or installs mlx.metallib. CI works around this in .github/workflows/ci.yml
7+
# ("Install MLX Metal library" step) by pip-installing the `mlx` wheel and
8+
# copying its bundled metallib into every built .xctest bundle. This script
9+
# does the same thing locally.
10+
set -eo pipefail
11+
12+
VENV_DIR="${MLX_METALLIB_VENV:-/tmp/swiftlm_mlx_venv}"
13+
14+
echo "=> Building test harness (swift build --build-tests)..."
15+
swift build --build-tests
16+
17+
echo "=> Installing MLX Metal library..."
18+
if [ ! -d "$VENV_DIR" ]; then
19+
python3 -m venv "$VENV_DIR"
20+
fi
21+
"$VENV_DIR/bin/pip" install --quiet --upgrade mlx
22+
23+
METALLIB=$(find "$VENV_DIR" -name "mlx.metallib" | head -1)
24+
if [ -z "$METALLIB" ]; then
25+
echo "error: mlx.metallib not found after pip install mlx" >&2
26+
exit 1
27+
fi
28+
29+
cp "$METALLIB" .build/debug/ 2>/dev/null || true
30+
cp "$METALLIB" .build/release/ 2>/dev/null || true
31+
find .build -type d -name "MacOS" -exec cp "$METALLIB" {}/ \;
32+
33+
echo "=> Done. Run tests with: swift test --skip-build"

0 commit comments

Comments
 (0)