forked from microsoft/onnxruntime-genai
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (123 loc) · 5.81 KB
/
win-cpu-arm64-build.yml
File metadata and controls
146 lines (123 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: "Windows 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:
binaryDir: 'build/cpu/win-arm64'
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_PACKAGE_NAME: "Microsoft.ML.OnnxRuntime"
jobs:
windows-cpu-arm64-build:
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-genai-win11-arm64-cpu2"]
steps:
- name: Checkout OnnxRuntime GenAI repo
uses: actions/checkout@v5
with:
submodules: true
- uses: nuget/setup-nuget@v2
with:
nuget-version: '5.x'
- name: Set up Python 3.12 for ARM64
uses: actions/setup-python@v6
with:
python-version: '3.12'
architecture: 'arm64'
cache: 'pip'
- name: Setup Java 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
architecture: 'aarch64'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: '8.6'
- name: Download OnnxRuntime Nightly
shell: powershell
run: |
$resp = Invoke-RestMethod "${{ env.ORT_NIGHTLY_REST_API }}"
$ORT_NIGHTLY_VERSION = $resp.value[0].versions[0].normalizedVersion
Write-Host "$ORT_NIGHTLY_VERSION"
"ORT_NIGHTLY_VERSION=$ORT_NIGHTLY_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
nuget install ${{ env.ORT_PACKAGE_NAME }} -version $ORT_NIGHTLY_VERSION -x -NonInteractive
- run: Get-ChildItem ${{ env.ORT_PACKAGE_NAME }} -Recurse
continue-on-error: true
- name: Extract OnnxRuntime library and header files
run: |
mkdir ort/lib
move ${{ env.ORT_PACKAGE_NAME }}/build/native/include ort/
move ${{ env.ORT_PACKAGE_NAME }}/runtimes/win-arm64/native/* ort/lib/
- name: Install Rust Toolchain
run: |
$exePath = "$env:TEMP\rustup-init.exe"
(New-Object Net.WebClient).DownloadFile('https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe', $exePath)
& $exePath -y --default-toolchain=1.86.0
Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin"
- name: Install LLVM
run: |
choco install llvm --yes
Add-Content $env:GITHUB_PATH "C:\Program Files\LLVM\bin"
- name: Configure CMake
run: |
python -m pip install wheel requests
cmake --preset windows_arm64_cpu_release -DENABLE_JAVA=ON -DUSE_GUIDANCE=ON
- name: Build with CMake
run: |
cmake --build --preset windows_arm64_cpu_release --parallel
cmake --build --preset windows_arm64_cpu_release --target PyPackageBuild
- name: Build the C Examples
run: |
cmake -S examples\c -B examples\c\build `
-DMODEL_QA=ON -DMODEL_CHAT=ON -DMODEL_MM=ON -DWHISPER= -DNEMOTRON_SPEECH=ON `
"-DORT_INCLUDE_DIR=$env:GITHUB_WORKSPACE\$env:binaryDir\_deps\ortlib-src\build\native\include" `
"-DORT_LIB_DIR=$env:GITHUB_WORKSPACE\$env:binaryDir\_deps\ortlib-src\runtimes\win-arm64\native" `
"-DOGA_INCLUDE_DIR=$env:GITHUB_WORKSPACE\src" `
"-DOGA_LIB_DIR=$env:GITHUB_WORKSPACE\$env:binaryDir\Release"
cmake --build examples\c\build --config Release
- name: Install the Python Wheel and Test Dependencies
run: |
# Uninstalling LLVM/Clang as it is no longer required and causes issues with numpy installation
choco uninstall llvm --yes
python -m pip install -r test\python\requirements.txt --user
python -m pip install -r test\python\cpu\torch\requirements.txt --user
python -m pip install -r test\python\cpu\ort\requirements.txt --user
python -m pip install (Get-ChildItem ("$env:binaryDir\wheel\*.whl"))
- name: Run the Java tests
run: |
ctest --test-dir $env:binaryDir\src\java --build-config Release --verbose --timeout 10800
- name: Run the Python Tests
run: |
python 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: |
cd test\csharp
dotnet test /p:NativeBuildOutputDir="$env:GITHUB_WORKSPACE\$env:binaryDir\Release" /p:OrtLibDir="$env:GITHUB_WORKSPACE\ort\lib"
- name: Build the C# Examples
run: |
cd examples\csharp\ModelChat
dotnet build -c Release
cd ..\ModelMM
dotnet build -c Release
- name: Test the C# LLM Example with Tool Calling
run: |
python3 test\python\special_tokens.py -p test\test_models\qwen-2.5-0.5b\int4\cpu\tokenizer.json -s "<tool_call>" -e "</tool_call>"
.\examples\csharp\ModelChat\bin\Release\net8.0\ModelChat.exe -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>" --tool_call_end "</tool_call>" --user_prompt "What is the weather in Redmond, WA?" --tool_output --non_interactive --verbose
- name: Verify Build Artifacts
if: always()
continue-on-error: true
run: |
Get-ChildItem -Path $env:GITHUB_WORKSPACE\$env:binaryDir -Recurse
Get-ChildItem -Path $env:GITHUB_WORKSPACE\$env:binaryDir\test -Recurse
- name: Run tests
run: |-
copy $env:GITHUB_WORKSPACE\ort\lib\* .\$env:binaryDir\Release
& .\$env:binaryDir\Release\unit_tests.exe