diff --git a/.github/workflows/mac-cpu-arm64-build.yml b/.github/workflows/mac-cpu-arm64-build.yml
deleted file mode 100644
index d32f1506d9..0000000000
--- a/.github/workflows/mac-cpu-arm64-build.yml
+++ /dev/null
@@ -1,203 +0,0 @@
-name: "MacOS CPU ARM64 Build"
-on:
- workflow_dispatch:
- push:
- branches:
- - main
- - rel-*
- pull_request:
-concurrency:
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
- cancel-in-progress: true
-env:
- ORT_NIGHTLY_REST_API: "https://feeds.dev.azure.com/aiinfra/PublicPackages/_apis/packaging/Feeds/ORT-Nightly/packages?packageNameQuery=Microsoft.ML.OnnxRuntime&api-version=6.0-preview.1"
- ORT_NIGHTLY_SOURCE: "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json"
- ORT_PACKAGE_NAME: "Microsoft.ML.OnnxRuntime"
-jobs:
- mac-cpu-arm64-build:
- runs-on: macos-latest # arm64
- steps:
- - name: Checkout OnnxRuntime GenAI repo
- uses: actions/checkout@v5
- with:
- submodules: true
-
- - uses: microsoft/onnxruntime-github-actions/setup-build-tools@v0.0.8
- with:
- vcpkg-version: '2025.06.13'
- vcpkg-hash: '735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc'
- cmake-version: '3.31.8'
- cmake-hash: '99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8'
- add-cmake-to-path: 'true'
- disable-terrapin: 'true'
-
- - uses: actions/setup-python@v6
- with:
- python-version: '3.12.x'
-
- - name: Setup Java 17
- uses: actions/setup-java@v5
- with:
- java-version: '17'
- distribution: 'temurin'
- cache: 'gradle'
-
- - name: Setup Gradle
- uses: gradle/actions/setup-gradle@v3
- with:
- gradle-version: '8.6'
-
- - name: Setup .NET 9.0
- uses: actions/setup-dotnet@v5
- with:
- dotnet-version: '9.0.x'
- dotnet-quality: 'ga'
-
- - name: Create global.json to lock .NET SDK version
- run: |
- echo '{
- "sdk": {
- "version": "9.0.306",
- "rollForward": "latestFeature"
- }
- }' > global.json
- cat global.json
-
- - name: Verify .NET version
- run: |
- dotnet --version
- dotnet --list-sdks
-
- - name: Get the Latest OnnxRuntime Nightly Version
- run: |
- ORT_NIGHTLY_VERSION=$(curl -s "${{ env.ORT_NIGHTLY_REST_API }}" | jq -r '.value[0].versions[0].normalizedVersion')
- echo "$ORT_NIGHTLY_VERSION"
- echo "ORT_NIGHTLY_VERSION=$ORT_NIGHTLY_VERSION" >> $GITHUB_ENV
- - name: Download OnnxRuntime Nightly
- run: |
- dotnet new console
- dotnet add package ${{ env.ORT_PACKAGE_NAME }} --version ${{ env.ORT_NIGHTLY_VERSION }} --source ${{ env.ORT_NIGHTLY_SOURCE }} --package-directory .
-
- - name: Extract OnnxRuntime library and header files
- run: |
- mkdir -p ort/lib
- mv ${{ env.ORT_PACKAGE_NAME }}/${{ env.ORT_NIGHTLY_VERSION }}/build/native/include ort/
- mv ${{ env.ORT_PACKAGE_NAME }}/${{ env.ORT_NIGHTLY_VERSION }}/runtimes/osx-arm64/native/* ort/lib/
-
- - name: Install Rust Toolchain
- run: |
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- source "$HOME/.cargo/env"
- rustup install 1.86.0
- rustup override set 1.86.0
- rustup component add rust-src
- rustup show active-toolchain
-
- - name: Restore ccache
- uses: actions/cache@v4
- with:
- path: ${{ github.workspace }}/.ccache
- key: ccache-macos-arm64-${{ hashFiles('**/CMakePresets.json', '**/CMakeLists.txt') }}
- restore-keys: |
- ccache-macos-arm64-
-
- - name: Install and configure ccache
- run: |
- brew install ccache
- ccache --set-config cache_dir=${{ github.workspace }}/.ccache
- ccache --set-config max_size=2G
- ccache --zero-stats
-
- - name: Configure CMake
- run: |
- export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d. -f1,2)
- export RUSTFLAGS='-C link-arg=-Wl,-undefined,dynamic_lookup -C link-arg=-Wl,-no_dead_strip_inits_and_terms'
- export CCACHE_DIR=${{ github.workspace }}/.ccache
- cmake --preset macos_arm64_cpu_release -DENABLE_JAVA=ON -DUSE_GUIDANCE=ON \
- -DCMAKE_C_COMPILER_LAUNCHER=ccache \
- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-
- - name: Build with CMake
- run: |
- export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d. -f1,2)
- export RUSTFLAGS='-C link-arg=-Wl,-undefined,dynamic_lookup -C link-arg=-Wl,-no_dead_strip_inits_and_terms'
- export CCACHE_DIR=${{ github.workspace }}/.ccache
- cmake --build --preset macos_arm64_cpu_release --parallel
- cmake --build --preset macos_arm64_cpu_release --target PyPackageBuild
- ccache --show-stats
- continue-on-error: false
-
- - name: Build the C Examples
- run: |
- set -e -x
- cmake -S examples/c -B examples/c/build \
- -DMODEL_QA=ON -DMODEL_CHAT=ON -DMODEL_MM=ON -DWHISPER=ON -DNEMOTRON_SPEECH=ON \
- -DORT_INCLUDE_DIR=$GITHUB_WORKSPACE/build/cpu/osx-arm64/_deps/ortlib-src/build/native/include \
- -DORT_LIB_DIR=$GITHUB_WORKSPACE/build/cpu/osx-arm64/_deps/ortlib-src/runtimes/osx-arm64/native \
- -DOGA_INCLUDE_DIR=$GITHUB_WORKSPACE/src \
- -DOGA_LIB_DIR=$GITHUB_WORKSPACE/build/cpu/osx-arm64
- cmake --build examples/c/build --config Release
-
- - name: Install the Python wheel and test dependencies
- run: |
- python3 -m venv genai-macos-venv
- source genai-macos-venv/bin/activate
- python3 -m pip install -r test/python/requirements.txt
- python3 -m pip install -r test/python/macos/torch/requirements.txt
- python3 -m pip install -r test/python/macos/ort/requirements.txt
- python3 -m pip install build/cpu/osx-arm64/wheel/onnxruntime_genai*.whl --no-deps
-
- - name: Run the Java tests
- run: |
- set -e -x
- ctest --test-dir build/cpu/osx-arm64/src/java --build-config Release --verbose --timeout 10800
-
- - name: Remove the ort lib and header files
- run: |
- rm -rf ort
-
- - name: Verify Build Artifacts
- if: always()
- continue-on-error: true
- run: |
- ls -l ${{ github.workspace }}/build/cpu/osx-arm64
- ls -l ${{ github.workspace }}/build/cpu/osx-arm64/wheel
-
- # This will also download all the test models to the test/test_models directory
- # These models are used by the python tests as well as C#, C++ and others.
- - name: Run the Python tests
- run: |
- source genai-macos-venv/bin/activate
- export HF_TOKEN="12345"
- export ORTGENAI_LOG_ORT_LIB=1
- python3 -m pip install requests
- python3 test/python/test_onnxruntime_genai.py --cwd test/python --test_models test/test_models
-
- - name: Build the C# API and Run the C# Tests
- run: |
- export ORTGENAI_LOG_ORT_LIB=1
- cd test/csharp
- dotnet test /p:Configuration=Release /p:NativeBuildOutputDir="../../build/cpu/osx-arm64" --verbosity normal
-
- - name: Build the C# Examples
- run: |
- export ORTGENAI_LOG_ORT_LIB=1
- cd examples/csharp/ModelChat
- dotnet build -c Release
- cd ../ModelMM
- dotnet build -c Release
-
- - name: Test the C# LLM Example with Tool Calling
- run: |
- export ORTGENAI_LOG_ORT_LIB=1
- python3 test/python/special_tokens.py -p test/test_models/qwen-2.5-0.5b/int4/cpu/tokenizer.json -s "" -e ""
- ./examples/csharp/ModelChat/bin/Release/net8.0/ModelChat -m test/test_models/qwen-2.5-0.5b/int4/cpu/ -e cpu --response_format lark_grammar --tools_file test/test_models/tool-definitions/weather.json --tool_call_start "" --tool_call_end "" --user_prompt "What is the weather in Redmond, WA?" --tool_output --non_interactive --verbose
-
- - name: Run tests
- run: |
- set -e -x
- export ORTGENAI_LOG_ORT_LIB=1
- export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GITHUB_WORKSPACE/build/cpu/osx-arm64
- ./build/cpu/osx-arm64/unit_tests
-
\ No newline at end of file
diff --git a/.pipelines/mac-cpu-arm64-build.yml b/.pipelines/mac-cpu-arm64-build.yml
new file mode 100644
index 0000000000..13777f68d1
--- /dev/null
+++ b/.pipelines/mac-cpu-arm64-build.yml
@@ -0,0 +1,247 @@
+trigger:
+ branches:
+ include:
+ - main
+ - rel-*
+ paths:
+ exclude:
+ - docs/**
+ - README.md
+ - CONTRIBUTING.md
+ - BUILD.md
+
+pr:
+ branches:
+ include:
+ - main
+ - rel-*
+ paths:
+ exclude:
+ - docs/**
+ - README.md
+ - CONTRIBUTING.md
+ - BUILD.md
+
+variables:
+ ORT_NIGHTLY_REST_API: 'https://feeds.dev.azure.com/aiinfra/PublicPackages/_apis/packaging/Feeds/ORT-Nightly/packages?packageNameQuery=Microsoft.ML.OnnxRuntime&api-version=6.0-preview.1'
+ ORT_NIGHTLY_SOURCE: 'https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json'
+ ORT_PACKAGE_NAME: 'Microsoft.ML.OnnxRuntime'
+
+jobs:
+- job: mac_cpu_arm64_build
+ displayName: 'MacOS CPU ARM64 Build'
+ timeoutInMinutes: 180
+ pool:
+ name: AcesShared
+ os: macOS
+ demands:
+ - ImageOverride -equals ACES_VM_SharedPool_Sequoia
+
+ workspace:
+ clean: all
+
+ steps:
+ - checkout: self
+ clean: true
+ submodules: recursive
+
+ - task: UsePythonVersion@0
+ displayName: 'Use Python 3.12'
+ inputs:
+ versionSpec: '3.12'
+ addToPath: true
+ architecture: 'arm64'
+
+ - bash: |
+ set -e -x
+ brew update --quiet
+ brew install --quiet cmake gradle ccache jq
+ # Temurin is distributed as a Homebrew cask, not a formula.
+ brew install --quiet --cask temurin@17
+ # Resolve JAVA_HOME for the freshly installed JDK 17.
+ JAVA_HOME="$(/usr/libexec/java_home -v 17)"
+ echo "JAVA_HOME=$JAVA_HOME"
+ echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME"
+ echo "##vso[task.prependpath]$JAVA_HOME/bin"
+ "$JAVA_HOME/bin/java" -version
+ cmake --version
+ gradle --version | head -n 5
+ ccache --version | head -n 1
+ displayName: 'Install build tools (Java 17 Temurin, cmake, gradle, ccache, jq)'
+
+ - task: UseDotNet@2
+ displayName: 'Setup .NET 8.0'
+ inputs:
+ packageType: 'sdk'
+ version: '8.0.x'
+
+ - task: UseDotNet@2
+ displayName: 'Setup .NET 9.0'
+ inputs:
+ packageType: 'sdk'
+ version: '9.0.x'
+
+ - bash: |
+ set -e -x
+ dotnet --version
+ dotnet --list-sdks
+ displayName: 'Verify .NET SDKs'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ ORT_NIGHTLY_VERSION=$(curl -s "$(ORT_NIGHTLY_REST_API)" | jq -r '.value[0].versions[0].normalizedVersion')
+ echo "$ORT_NIGHTLY_VERSION"
+ echo "##vso[task.setvariable variable=ORT_NIGHTLY_VERSION]$ORT_NIGHTLY_VERSION"
+ displayName: 'Get the latest OnnxRuntime nightly version'
+
+ - bash: |
+ set -e -x
+ dotnet new console
+ dotnet add package $(ORT_PACKAGE_NAME) --version $(ORT_NIGHTLY_VERSION) --source $(ORT_NIGHTLY_SOURCE) --package-directory .
+ displayName: 'Download OnnxRuntime nightly'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ mkdir -p ort/lib
+ mv $(ORT_PACKAGE_NAME)/$(ORT_NIGHTLY_VERSION)/build/native/include ort/
+ mv $(ORT_PACKAGE_NAME)/$(ORT_NIGHTLY_VERSION)/runtimes/osx-arm64/native/* ort/lib/
+ displayName: 'Extract OnnxRuntime library and header files'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+ echo '##vso[task.prependpath]$(HOME)/.cargo/bin'
+ source "$HOME/.cargo/env"
+ rustup install 1.86.0
+ rustup override set 1.86.0
+ rustup component add rust-src
+ rustup show active-toolchain
+ displayName: 'Install Rust toolchain'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - task: Cache@2
+ displayName: 'Restore ccache'
+ inputs:
+ key: 'ccache | macos-arm64 | "$(Agent.OS)" | **/CMakePresets.json, **/CMakeLists.txt'
+ restoreKeys: |
+ ccache | macos-arm64 | "$(Agent.OS)"
+ ccache | macos-arm64
+ path: '$(Build.SourcesDirectory)/.ccache'
+
+ - bash: |
+ set -e -x
+ ccache --set-config cache_dir=$(Build.SourcesDirectory)/.ccache
+ ccache --set-config max_size=2G
+ ccache --zero-stats
+ displayName: 'Configure ccache'
+
+ - bash: |
+ set -e -x
+ export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d. -f1,2)
+ export RUSTFLAGS='-C link-arg=-Wl,-undefined,dynamic_lookup -C link-arg=-Wl,-no_dead_strip_inits_and_terms'
+ export CCACHE_DIR=$(Build.SourcesDirectory)/.ccache
+ cmake --preset macos_arm64_cpu_release -DENABLE_JAVA=ON -DUSE_GUIDANCE=ON \
+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
+ displayName: 'Configure CMake'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d. -f1,2)
+ export RUSTFLAGS='-C link-arg=-Wl,-undefined,dynamic_lookup -C link-arg=-Wl,-no_dead_strip_inits_and_terms'
+ export CCACHE_DIR=$(Build.SourcesDirectory)/.ccache
+ cmake --build --preset macos_arm64_cpu_release --parallel
+ cmake --build --preset macos_arm64_cpu_release --target PyPackageBuild
+ ccache --show-stats
+ displayName: 'Build with CMake'
+ workingDirectory: '$(Build.SourcesDirectory)'
+ continueOnError: false
+
+ - bash: |
+ set -e -x
+ cmake -S examples/c -B examples/c/build \
+ -DMODEL_QA=ON -DMODEL_CHAT=ON -DMODEL_MM=ON -DWHISPER=ON -DNEMOTRON_SPEECH=ON \
+ -DORT_INCLUDE_DIR=$(Build.SourcesDirectory)/build/cpu/osx-arm64/_deps/ortlib-src/build/native/include \
+ -DORT_LIB_DIR=$(Build.SourcesDirectory)/build/cpu/osx-arm64/_deps/ortlib-src/runtimes/osx-arm64/native \
+ -DOGA_INCLUDE_DIR=$(Build.SourcesDirectory)/src \
+ -DOGA_LIB_DIR=$(Build.SourcesDirectory)/build/cpu/osx-arm64
+ cmake --build examples/c/build --config Release
+ displayName: 'Build the C examples'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ python3 -m venv genai-macos-venv
+ source genai-macos-venv/bin/activate
+ python3 -m pip install -r test/python/requirements.txt
+ python3 -m pip install -r test/python/macos/torch/requirements.txt
+ python3 -m pip install -r test/python/macos/ort/requirements.txt
+ python3 -m pip install build/cpu/osx-arm64/wheel/onnxruntime_genai*.whl --no-deps
+ displayName: 'Install the Python wheel and test dependencies'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ ctest --test-dir build/cpu/osx-arm64/src/java --build-config Release --verbose --timeout 10800
+ displayName: 'Run the Java tests'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ rm -rf ort
+ displayName: 'Remove the ort lib and header files'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ ls -l $(Build.SourcesDirectory)/build/cpu/osx-arm64
+ ls -l $(Build.SourcesDirectory)/build/cpu/osx-arm64/wheel
+ displayName: 'Verify build artifacts'
+ condition: always()
+ continueOnError: true
+
+ - bash: |
+ set -e -x
+ source genai-macos-venv/bin/activate
+ export ORTGENAI_LOG_ORT_LIB=1
+ python3 -m pip install requests
+ python3 test/python/test_onnxruntime_genai.py --cwd test/python --test_models test/test_models
+ displayName: 'Run the Python tests'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ export ORTGENAI_LOG_ORT_LIB=1
+ cd test/csharp
+ dotnet test /p:Configuration=Release /p:NativeBuildOutputDir="../../build/cpu/osx-arm64" --verbosity normal
+ displayName: 'Build the C# API and run the C# tests'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ export ORTGENAI_LOG_ORT_LIB=1
+ cd examples/csharp/ModelChat
+ dotnet build -c Release
+ cd ../ModelMM
+ dotnet build -c Release
+ displayName: 'Build the C# examples'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ export ORTGENAI_LOG_ORT_LIB=1
+ python3 test/python/special_tokens.py -p test/test_models/qwen-2.5-0.5b/int4/cpu/tokenizer.json -s "" -e ""
+ ./examples/csharp/ModelChat/bin/Release/net8.0/ModelChat -m test/test_models/qwen-2.5-0.5b/int4/cpu/ -e cpu --response_format lark_grammar --tools_file test/test_models/tool-definitions/weather.json --tool_call_start "" --tool_call_end "" --user_prompt "What is the weather in Redmond, WA?" --tool_output --non_interactive --verbose
+ displayName: 'Test the C# LLM example with tool calling'
+ workingDirectory: '$(Build.SourcesDirectory)'
+
+ - bash: |
+ set -e -x
+ export ORTGENAI_LOG_ORT_LIB=1
+ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(Build.SourcesDirectory)/build/cpu/osx-arm64
+ ./build/cpu/osx-arm64/unit_tests
+ displayName: 'Run unit tests'
+ workingDirectory: '$(Build.SourcesDirectory)'