diff --git a/.github/backend-matrix.yml b/.github/backend-matrix.yml index 593e44cde..4cfc937ac 100644 --- a/.github/backend-matrix.yml +++ b/.github/backend-matrix.yml @@ -4990,6 +4990,10 @@ includeDarwin: tag-suffix: "-metal-darwin-arm64-sherpa-onnx" build-type: "metal" lang: "go" + - backend: "supertonic" + tag-suffix: "-metal-darwin-arm64-supertonic" + build-type: "metal" + lang: "go" - backend: "local-store" tag-suffix: "-metal-darwin-arm64-local-store" build-type: "metal" diff --git a/backend/go/supertonic/helper.go b/backend/go/supertonic/helper.go index 9f927d5d3..884077e75 100644 --- a/backend/go/supertonic/helper.go +++ b/backend/go/supertonic/helper.go @@ -16,6 +16,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strings" "time" "unicode" @@ -943,7 +944,13 @@ func InitializeONNXRuntime() error { } } if libPath == "" { - libPath = "/usr/local/lib/libonnxruntime.so" + // LocalAI: default to the platform-native shared library + // extension when nothing else is found (dyld vs ld.so). + if runtime.GOOS == "darwin" { + libPath = "/usr/local/lib/libonnxruntime.dylib" + } else { + libPath = "/usr/local/lib/libonnxruntime.so" + } } } ort.SetSharedLibraryPath(libPath) diff --git a/backend/go/supertonic/package.sh b/backend/go/supertonic/package.sh index 9e2a01625..678ca5ead 100755 --- a/backend/go/supertonic/package.sh +++ b/backend/go/supertonic/package.sh @@ -32,6 +32,10 @@ elif [ -f "/lib/ld-linux-aarch64.so.1" ]; then cp -arfLv /lib/aarch64-linux-gnu/libdl.so.2 $CURDIR/package/lib/libdl.so.2 cp -arfLv /lib/aarch64-linux-gnu/librt.so.1 $CURDIR/package/lib/librt.so.1 cp -arfLv /lib/aarch64-linux-gnu/libpthread.so.0 $CURDIR/package/lib/libpthread.so.0 +elif [ $(uname -s) = "Darwin" ]; then + # macOS: dyld resolves the bundled .dylib via DYLD_LIBRARY_PATH (set in + # run.sh); there is no ld.so loader nor glibc to bundle. + echo "Detected Darwin" else echo "Error: Could not detect architecture" exit 1 diff --git a/backend/go/supertonic/run.sh b/backend/go/supertonic/run.sh index 2dabf7eb3..683c52ab2 100755 --- a/backend/go/supertonic/run.sh +++ b/backend/go/supertonic/run.sh @@ -3,12 +3,19 @@ set -ex CURDIR=$(dirname "$(realpath $0)") -export LD_LIBRARY_PATH=$CURDIR/lib:$LD_LIBRARY_PATH -export ONNXRUNTIME_LIB_PATH=$CURDIR/lib/libonnxruntime.so +if [ "$(uname)" = "Darwin" ]; then + # macOS uses dyld: there is no ld.so loader, and the search path env + # var is DYLD_LIBRARY_PATH. ONNX Runtime ships as a .dylib here. + export DYLD_LIBRARY_PATH=$CURDIR/lib:$DYLD_LIBRARY_PATH + export ONNXRUNTIME_LIB_PATH=$CURDIR/lib/libonnxruntime.dylib +else + export LD_LIBRARY_PATH=$CURDIR/lib:$LD_LIBRARY_PATH + export ONNXRUNTIME_LIB_PATH=$CURDIR/lib/libonnxruntime.so -if [ -f $CURDIR/lib/ld.so ]; then - echo "Using lib/ld.so" - exec $CURDIR/lib/ld.so $CURDIR/supertonic "$@" + if [ -f $CURDIR/lib/ld.so ]; then + echo "Using lib/ld.so" + exec $CURDIR/lib/ld.so $CURDIR/supertonic "$@" + fi fi exec $CURDIR/supertonic "$@" diff --git a/backend/index.yaml b/backend/index.yaml index 3f61f7b4e..592c8fd6b 100644 --- a/backend/index.yaml +++ b/backend/index.yaml @@ -1569,6 +1569,7 @@ - TTS capabilities: default: "cpu-supertonic" + metal: "metal-supertonic" - !!merge <<: *neutts name: "neutts-development" capabilities: @@ -5484,6 +5485,7 @@ name: "supertonic-development" capabilities: default: "cpu-supertonic-development" + metal: "metal-supertonic-development" - !!merge <<: *supertonic name: "cpu-supertonic" uri: "quay.io/go-skynet/local-ai-backends:latest-cpu-supertonic" @@ -5494,3 +5496,13 @@ uri: "quay.io/go-skynet/local-ai-backends:master-cpu-supertonic" mirrors: - localai/localai-backends:master-cpu-supertonic +- !!merge <<: *supertonic + name: "metal-supertonic" + uri: "quay.io/go-skynet/local-ai-backends:latest-metal-darwin-arm64-supertonic" + mirrors: + - localai/localai-backends:latest-metal-darwin-arm64-supertonic +- !!merge <<: *supertonic + name: "metal-supertonic-development" + uri: "quay.io/go-skynet/local-ai-backends:master-metal-darwin-arm64-supertonic" + mirrors: + - localai/localai-backends:master-metal-darwin-arm64-supertonic