diff --git a/build.sh b/build.sh index 715861f..8cf89ac 100755 --- a/build.sh +++ b/build.sh @@ -51,7 +51,9 @@ else exit 1 fi METALLIB_BUILD_DIR=".build/metallib_build" -METALLIB_DEST=".build/arm64-apple-macosx/release" +# Ask SwiftPM for the real bin dir: Swift 6.4+ builds into .build/out/Products/Release +# instead of .build/arm64-apple-macosx/release. +METALLIB_DEST="$(swift build -c release --show-bin-path)" rm -rf "$METALLIB_BUILD_DIR" mkdir -p "$METALLIB_BUILD_DIR" @@ -77,25 +79,19 @@ fi popd > /dev/null -# Copy the freshly built metallib next to the binary, explicitly naming it default.metallib for mlx-c +# Copy the freshly built metallib next to the binary. MLX loads a colocated +# mlx.metallib before anything else, so that name guarantees the full kernel set +# wins over the partial default.metallib SwiftPM puts in mlx-swift_Cmlx.bundle. +# default.metallib is kept for mlx-c. mkdir -p "$METALLIB_DEST" -if [ -f "$METALLIB_BUILD_DIR/lib/mlx.metallib" ]; then - cp "$METALLIB_BUILD_DIR/lib/mlx.metallib" "$METALLIB_DEST/default.metallib" - echo "✅ Built and copied default.metallib to $METALLIB_DEST/" -elif [ -f "$METALLIB_BUILD_DIR/mlx.metallib" ]; then - cp "$METALLIB_BUILD_DIR/mlx.metallib" "$METALLIB_DEST/default.metallib" - echo "✅ Built and copied default.metallib to $METALLIB_DEST/" -else - # Search for it anywhere in the build dir - BUILT=$(find "$METALLIB_BUILD_DIR" -name "mlx.metallib" | head -1) - if [ -n "$BUILT" ]; then - cp "$BUILT" "$METALLIB_DEST/default.metallib" - echo "✅ Built and copied default.metallib to $METALLIB_DEST/" - else - echo "❌ Failed to build mlx.metallib. Check cmake output above." - exit 1 - fi +BUILT=$(find "$METALLIB_BUILD_DIR" -name "mlx.metallib" | head -1) +if [ -z "$BUILT" ]; then + echo "❌ Failed to build mlx.metallib. Check cmake output above." + exit 1 fi +cp "$BUILT" "$METALLIB_DEST/mlx.metallib" +cp "$BUILT" "$METALLIB_DEST/default.metallib" +echo "✅ Built and copied mlx.metallib + default.metallib to $METALLIB_DEST/" # --- 4. Build SwiftLM --- echo "" @@ -105,6 +101,6 @@ swift build -c release echo "" echo "==============================================" echo "✅ Build complete!" -echo " Binary: .build/release/SwiftLM" +echo " Binary: $METALLIB_DEST/SwiftLM" echo " Metallib: $METALLIB_DEST/mlx.metallib" echo "==============================================" diff --git a/mlx-swift b/mlx-swift index 5639a6d..cbb6a09 160000 --- a/mlx-swift +++ b/mlx-swift @@ -1 +1 @@ -Subproject commit 5639a6d9e6a7ab785e102d88d741879f529fce56 +Subproject commit cbb6a097eaf174a8b18e4e2467e56b4b71ff0011 diff --git a/run_benchmark.sh b/run_benchmark.sh index 9a8f396..a89948d 100755 --- a/run_benchmark.sh +++ b/run_benchmark.sh @@ -86,7 +86,7 @@ print_server_log() { fi } -export METAL_LIBRARY_PATH="$(pwd)/.build/arm64-apple-macosx/release" +export METAL_LIBRARY_PATH="$(cd .build/release 2>/dev/null && pwd -P)" if [ -n "${SUITE_OPT:-}" ]; then # Sub-process invocation from automated matrix — skip interactive menu @@ -302,9 +302,8 @@ if { [ "$suite_opt" == "5" ] || [ "$suite_opt" == "6" ]; } && [[ "$FULL_MODEL" = fi # Quick sanity check -if [ -f ".build/arm64-apple-macosx/release/SwiftLM" ]; then - BIN=".build/arm64-apple-macosx/release/SwiftLM" -elif [ -f ".build/release/SwiftLM" ]; then +# .build/release is a symlink to the real bin dir on every SwiftPM layout +if [ -f ".build/release/SwiftLM" ]; then BIN=".build/release/SwiftLM" else echo "⚠️ SwiftLM release binary not found! Please compile the project by running ./build.sh first." diff --git a/scripts/profiling/mtp_bench.py b/scripts/profiling/mtp_bench.py index 2055ce2..0d88589 100644 --- a/scripts/profiling/mtp_bench.py +++ b/scripts/profiling/mtp_bench.py @@ -30,7 +30,7 @@ import urllib.request import urllib.error -SWIFTLM_PATH = ".build/arm64-apple-macosx/release/SwiftLM" +SWIFTLM_PATH = ".build/release/SwiftLM" PORT = 5430 CONFIGS = [ diff --git a/scripts/profiling/profile_runner.py b/scripts/profiling/profile_runner.py index 7a9ed33..44ff2b1 100755 --- a/scripts/profiling/profile_runner.py +++ b/scripts/profiling/profile_runner.py @@ -16,7 +16,7 @@ {"name": "MTP + TurboQuant", "flags": ["--stream-experts", "--mtp", "--num-mtp-tokens", "4", "--turbo-kv"]}, ] -SWIFTLM_PATH = ".build/arm64-apple-macosx/release/SwiftLM" +SWIFTLM_PATH = ".build/release/SwiftLM" def get_physical_ram_gb(): try: diff --git a/scripts/profiling/profile_speculative.py b/scripts/profiling/profile_speculative.py index cc3c91a..6c09724 100644 --- a/scripts/profiling/profile_speculative.py +++ b/scripts/profiling/profile_speculative.py @@ -1,6 +1,6 @@ import subprocess, time, json, urllib.request, os, signal -SWIFTLM_PATH = ".build/arm64-apple-macosx/release/SwiftLM" +SWIFTLM_PATH = ".build/release/SwiftLM" MAIN_MODEL = "mlx-community/gemma-4-26b-a4b-it-4bit" DRAFT_MODEL = "mlx-community/gemma-4-e4b-it-4bit" diff --git a/tests/SwiftBuddyTests/AudioTests.swift b/tests/SwiftBuddyTests/AudioTests.swift index 304075c..bd64e07 100644 --- a/tests/SwiftBuddyTests/AudioTests.swift +++ b/tests/SwiftBuddyTests/AudioTests.swift @@ -12,7 +12,7 @@ final class AudioTests: XCTestCase { .deletingLastPathComponent() // SwiftLM let debugExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/debug/SwiftLM") - let releaseExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/release/SwiftLM") + let releaseExecutableURL = projectRoot.appendingPathComponent(".build/release/SwiftLM") let executableURL = FileManager.default.fileExists(atPath: debugExecutableURL.path) ? debugExecutableURL diff --git a/tests/SwiftBuddyTests/VLMTests.swift b/tests/SwiftBuddyTests/VLMTests.swift index d65df3f..0e4c829 100644 --- a/tests/SwiftBuddyTests/VLMTests.swift +++ b/tests/SwiftBuddyTests/VLMTests.swift @@ -43,7 +43,7 @@ final class VLMTests: XCTestCase { .deletingLastPathComponent() let debugExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/debug/SwiftLM") - let releaseExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/release/SwiftLM") + let releaseExecutableURL = projectRoot.appendingPathComponent(".build/release/SwiftLM") let executableURL = FileManager.default.fileExists(atPath: debugExecutableURL.path) ? debugExecutableURL : releaseExecutableURL