Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Wheel and NuGet packaging on macOS x64 & arm64 #841

Merged
merged 59 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b769831
Init
skyline75489 Aug 20, 2024
34e98f9
choice
skyline75489 Aug 20, 2024
1d1447d
Fix
skyline75489 Aug 20, 2024
b70a977
Rename
skyline75489 Aug 20, 2024
14fe5b5
Pool
skyline75489 Aug 20, 2024
a5af4e3
Well...
skyline75489 Aug 20, 2024
21aad54
zip
skyline75489 Aug 20, 2024
dbfe071
arch
skyline75489 Aug 20, 2024
da8894a
x86_64
skyline75489 Aug 20, 2024
1c4690f
Working dir
skyline75489 Aug 20, 2024
1122deb
Slash
skyline75489 Aug 20, 2024
41ea799
Unused
skyline75489 Aug 20, 2024
e9093c6
python wheel host platform
skyline75489 Aug 20, 2024
8672a21
deployment target
skyline75489 Aug 20, 2024
c723333
package.cmake
skyline75489 Aug 20, 2024
18c906c
matrix
skyline75489 Aug 20, 2024
44b5aa3
Guardian not available on macOS
skyline75489 Aug 21, 2024
5065c66
CredScan not available on macOS
skyline75489 Aug 21, 2024
a3c01c6
Merge branch 'main' into jialli/osx-whell
skyline75489 Aug 22, 2024
ac5635e
macOS nuget
skyline75489 Aug 22, 2024
3831ffa
parameter
skyline75489 Aug 22, 2024
980f74f
parameter value
skyline75489 Aug 22, 2024
cb0a7a0
parameter
skyline75489 Aug 22, 2024
75c3d41
condition
skyline75489 Aug 22, 2024
035d610
pool
skyline75489 Aug 22, 2024
fb867dc
publish
skyline75489 Aug 22, 2024
23b9b98
nuget
skyline75489 Aug 22, 2024
e632c1e
syntax
skyline75489 Aug 22, 2024
cfe1948
validation pipeline
skyline75489 Aug 22, 2024
80459fd
validation pipeline
skyline75489 Aug 22, 2024
140d60c
It's all x64 mac
skyline75489 Aug 22, 2024
32802f4
debugging
skyline75489 Aug 22, 2024
04f1423
dlopen on mac
skyline75489 Aug 22, 2024
74238e7
dlopen on mac
skyline75489 Aug 22, 2024
0d7ec64
min_length
skyline75489 Aug 22, 2024
1e2947c
Clean up
skyline75489 Aug 27, 2024
f6ade19
macos arm64 test on GHA
skyline75489 Aug 27, 2024
4e6f31d
Try fix macos arm64 test on GHA
skyline75489 Aug 27, 2024
eaeace8
User site-packages are not visible in this virtualenv
skyline75489 Aug 27, 2024
425a3af
requirements-macos.txt
skyline75489 Aug 27, 2024
4e9f2fe
Pip
skyline75489 Aug 27, 2024
5760c7d
Unused
skyline75489 Aug 27, 2024
fd0258c
Unused
skyline75489 Aug 27, 2024
1bc6aac
enable dylib only on python
skyline75489 Sep 2, 2024
5f799d4
compiler definition
skyline75489 Sep 2, 2024
2a627cf
invert
skyline75489 Sep 2, 2024
7c88037
Merge branch 'main' into jialli/osx-whell
skyline75489 Sep 2, 2024
12abaa7
fix
skyline75489 Sep 5, 2024
b89d9bc
find dylib on macos
skyline75489 Sep 5, 2024
286db1b
Merge branch 'main' into jialli/osx-whell
skyline75489 Sep 5, 2024
7d40b30
pass ort_lib_path using envvar
skyline75489 Sep 5, 2024
9bd4f8b
starts_with not available
skyline75489 Sep 5, 2024
cd4bdac
fix
skyline75489 Sep 5, 2024
63df69a
Fix so loading on linux
skyline75489 Sep 5, 2024
0fbefbe
[skip ci] validation pipeline
skyline75489 Sep 5, 2024
2a3cbbd
mac os dotnet test on GHA
skyline75489 Sep 5, 2024
3798372
mac os dotnet test on GHA
skyline75489 Sep 5, 2024
7c918fe
Merge branch 'main' into jialli/osx-whell
skyline75489 Sep 11, 2024
ce7f701
Review
skyline75489 Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/linux-cpu-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,28 @@ jobs:
run: |
rm -rf ort

- name: Verify Build Artifacts
if: always()
continue-on-error: true
run: |
ls -l ${{ github.workspace }}/build/cpu

# 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: |
export ORTGENAI_LOG_ORT_LIB=1
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/"

- name: Verify Build Artifacts
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved
if: always()
continue-on-error: true
run: |
ls -l ${{ github.workspace }}/build/cpu

- name: Run tests
run: |
set -e -x
export ORTGENAI_LOG_ORT_LIB=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build/cpu/
./build/cpu/test/unit_tests
2 changes: 1 addition & 1 deletion .github/workflows/linux-gpu-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ jobs:
--rm \
--volume /data/ortgenai_pytorch_models:/data/ortgenai_pytorch_models \
--volume $GITHUB_WORKSPACE:/ort_genai_src \
-w /ort_genai_src onnxruntimecudabuildx64 bash -c "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/ort_genai_src/build/cuda/ /ort_genai_src/build/cuda/test/unit_tests"
-w /ort_genai_src onnxruntimecudabuildx64 bash -c "ORTGENAI_LOG_ORT_LIB=1 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/ort_genai_src/build/cuda/ /ort_genai_src/build/cuda/test/unit_tests"
40 changes: 29 additions & 11 deletions .github/workflows/mac-cpu-arm64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
ORT_PACKAGE_NAME: "Microsoft.ML.OnnxRuntime"
jobs:
mac-cpu-arm64-build:
runs-on: macos-latest
runs-on: macos-latest # arm64
steps:
- name: Checkout OnnxRuntime GenAI repo
uses: actions/checkout@v4
Expand All @@ -36,26 +36,44 @@ jobs:
mv ${{ env.ORT_PACKAGE_NAME }}/build/native/include ort/
mv ${{ env.ORT_PACKAGE_NAME }}/runtimes/osx-arm64/native/* ort/lib/


- name: Configure CMake
run: |
cmake --preset macos_cpu_release
cmake --preset macos_arm64_cpu_release

- name: Build with CMake
run: |
cmake --build --preset macos_cpu_release --parallel
cmake --build --preset macos_arm64_cpu_release --parallel
continue-on-error: false

- 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/requirements-macos.txt
python3 -m pip install build/cpu/osx-arm64/wheel/onnxruntime_genai*.whl
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved

- 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

- name: Upload Build Artifacts
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/upload-artifact@v3
with:
name: onnxruntime-genai-mac-cpu-arm64
path: ${{ github.workspace }}/build/**/*.a
ls -l ${{ github.workspace }}/build/cpu/osx-arm64

# 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 ORTGENAI_LOG_ORT_LIB=1
python3 test/python/test_onnxruntime_genai.py --cwd test/python --test_models test/test_models

- 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/test/unit_tests
8 changes: 8 additions & 0 deletions .pipelines/nuget-publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ parameters:
type: boolean
default: true

- name: enable_macos_cpu
displayName: 'Whether MacOS CPU package is built.'
type: boolean
default: true

- name: ort_version
displayName: 'OnnxRuntime version'
type: string
Expand Down Expand Up @@ -83,6 +88,7 @@ stages:
enable_linux_cuda: ${{ parameters.enable_linux_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
enable_win_arm64: ${{ parameters.enable_win_arm64 }}
enable_macos_cpu: ${{ parameters.enable_macos_cpu }}
ort_version: ${{ parameters.ort_version }}
ort_cuda_version: ${{ parameters.ort_cuda_version }}
ort_dml_version: ${{ parameters.ort_dml_version }}
Expand All @@ -97,6 +103,7 @@ stages:
enable_linux_cuda: ${{ parameters.enable_linux_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
enable_win_arm64: ${{ parameters.enable_win_arm64 }}
enable_macos_cpu: ${{ parameters.enable_macos_cpu }}
ort_version: ${{ parameters.ort_version }}
ort_cuda_version: ${{ parameters.ort_cuda_version }}
ort_dml_version: ${{ parameters.ort_dml_version }}
Expand All @@ -111,6 +118,7 @@ stages:
enable_linux_cuda: ${{ parameters.enable_linux_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
enable_win_arm64: ${{ parameters.enable_win_arm64 }}
enable_macos_cpu: ${{ parameters.enable_macos_cpu }}
ort_version: ${{ parameters.ort_version }}
ort_cuda_version: ${{ parameters.ort_cuda_version }}
ort_dml_version: ${{ parameters.ort_dml_version }}
Expand Down
7 changes: 7 additions & 0 deletions .pipelines/pypl-publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ parameters:
type: boolean
default: true

- name: enable_macos_cpu
displayName: 'Whether MacOS CPU package is built.'
type: boolean
default: true

- name: ort_version
displayName: 'OnnxRuntime version'
type: string
Expand Down Expand Up @@ -97,6 +102,7 @@ stages:
enable_win_cuda: ${{ parameters.enable_win_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
enable_win_arm64_cpu: ${{ parameters.enable_win_arm64_cpu }}
enable_macos_cpu: ${{ parameters.enable_macos_cpu }}
ort_version: ${{ parameters.ort_version }}
ort_cuda_118_version: ${{ parameters.ort_cuda_118_version }}
ort_cuda_122_version: ${{ parameters.ort_cuda_122_version }}
Expand All @@ -113,6 +119,7 @@ stages:
enable_win_cuda: ${{ parameters.enable_win_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
enable_win_arm64_cpu: ${{ parameters.enable_win_arm64_cpu }}
enable_macos_cpu: ${{ parameters.enable_macos_cpu }}
ort_version: ${{ parameters.ort_version }}
ort_cuda_118_version: ${{ parameters.ort_cuda_118_version }}
ort_cuda_122_version: ${{ parameters.ort_cuda_122_version }}
Expand Down
21 changes: 20 additions & 1 deletion .pipelines/stages/capi-packaging-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ parameters:
type: boolean
- name: enable_linux_cuda
type: boolean
- name: enable_macos_cpu
type: boolean
- name: ort_version
type: string
- name: ort_cuda_version
Expand Down Expand Up @@ -91,4 +93,21 @@ stages:
ep: 'cuda'
ort_version: ${{ parameters.ort_cuda_version }}
os: 'linux'
build_config: ${{ parameters.build_config }}
build_config: ${{ parameters.build_config }}

- ${{ if eq(parameters.enable_macos_cpu, true) }}:
- template: jobs/capi-packaging-job.yml
parameters:
arch: 'x64'
ep: 'cpu'
ort_version: ${{ parameters.ort_version }}
os: 'osx'
build_config: ${{ parameters.build_config }}

- template: jobs/capi-packaging-job.yml
parameters:
arch: 'arm64'
ep: 'cpu'
ort_version: ${{ parameters.ort_version }}
os: 'osx'
build_config: ${{ parameters.build_config }}
13 changes: 13 additions & 0 deletions .pipelines/stages/jobs/capi-packaging-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ parameters:
values:
- 'linux'
- 'win'
- 'osx'
- name: build_config
type: string
default: 'release'
Expand All @@ -33,6 +34,10 @@ jobs:
pool: 'onnxruntime-genai-windows-vs-2022-arm64'
${{ else }}:
pool: 'onnxruntime-Win-CPU-2022'
${{ if eq(parameters.os, 'osx') }}:
pool:
vmImage: 'macOS-latest'

timeoutInMinutes: 180
# set variables here to be used in the template and steps
variables:
Expand Down Expand Up @@ -130,4 +135,12 @@ jobs:
ep: ${{ parameters.ep }}
build_config: ${{ parameters.build_config }}

- ${{ if eq(parameters.os, 'osx') }}:
- template: steps/capi-macos-step.yml
parameters:
target: 'onnxruntime-genai'
arch: ${{ parameters.arch }}
ep: ${{ parameters.ep }}
build_config: ${{ parameters.build_config }}

- template: steps/compliant-and-cleanup-step.yml
17 changes: 17 additions & 0 deletions .pipelines/stages/jobs/nuget-packaging-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ parameters:
type: boolean
default: false

- name: enable_macos_cpu
displayName: 'Whether MacOS CPU package is built.'
type: boolean
default: false

- name: ort_version
type: string

Expand Down Expand Up @@ -130,6 +135,18 @@ jobs:
ArtifactName: onnxruntime-genai-linux-cuda-x64-capi
TargetPath: '$(Build.BinariesDirectory)/artifact-downloads'

- ${{ if eq(parameters.enable_macos_cpu, true) }}:
- template: steps/utils/flex-download-pipeline-artifact.yml
parameters:
StepName: 'Download osx-cpu-x64 capi Artifacts'
ArtifactName: onnxruntime-genai-osx-cpu-x64-capi
TargetPath: '$(Build.BinariesDirectory)/artifact-downloads'
- template: steps/utils/flex-download-pipeline-artifact.yml
parameters:
StepName: 'Download osx-cpu-arm64 capi Artifacts'
ArtifactName: onnxruntime-genai-osx-cpu-arm64-capi
TargetPath: '$(Build.BinariesDirectory)/artifact-downloads'

- checkout: self
path: onnxruntime-genai
clean: true
Expand Down
7 changes: 6 additions & 1 deletion .pipelines/stages/jobs/nuget-validation-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ parameters:
values:
- 'linux'
- 'win'
- 'osx'
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved

jobs:
- job: nuget_${{ parameters.os }}_${{ parameters.ep }}_${{ parameters.arch }}_validation
Expand All @@ -43,6 +44,9 @@ jobs:
pool: 'onnxruntime-genai-windows-vs-2022-arm64'
${{ else }}:
pool: 'onnxruntime-Win-CPU-2022'
${{ if eq(parameters.os, 'osx') }}:
pool:
vmImage: 'macOS-latest'

timeoutInMinutes: 180
# set variables here to be used in the template and steps
Expand Down Expand Up @@ -158,14 +162,15 @@ jobs:
env:
NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS: 180
NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS: 180
- ${{ elseif eq(parameters.os, 'linux') }}:
- ${{ elseif or(eq(parameters.os, 'linux'), eq(parameters.os, 'osx')) }}:
- bash: |
dotnet --info
cp $(Build.BinariesDirectory)/nuget/* examples/csharp/HelloPhi/
cd examples/csharp/HelloPhi
mv models/$(prebuild_phi3_mini_model_folder) models/phi-3
dotnet restore -r $(os)-$(arch) /property:Configuration=$(csproj_configuration) --source https://api.nuget.org/v3/index.json --source https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json --source $PWD --disable-parallel --verbosity detailed
dotnet build ./HelloPhi.csproj -r $(os)-$(arch) /property:Configuration=$(csproj_configuration) --no-restore --self-contained
ls -l ./bin/$(csproj_configuration)/net6.0/$(os)-$(arch)/
displayName: 'Perform dotnet restore & build'
workingDirectory: '$(Build.Repository.LocalPath)'
env:
Expand Down
16 changes: 15 additions & 1 deletion .pipelines/stages/jobs/py-packaging-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ parameters:
values:
- 'linux'
- 'win'
- 'osx'
- name: build_config
type: string
default: 'release'
Expand All @@ -37,9 +38,12 @@ jobs:
pool: 'onnxruntime-genai-windows-vs-2022-arm64'
${{ else }}:
pool: 'onnxruntime-Win-CPU-2022'
${{ if eq(parameters.os, 'osx') }}:
pool:
vmImage: 'macOS-latest'

strategy:
${{ if eq(parameters.arch, 'arm64') }}:
${{ if and(eq(parameters.os, 'win'), eq(parameters.arch, 'arm64')) }}: # Older Python versions don't have official win-arm64 build.
matrix:
Python311:
PyDotVer: '3.11'
Expand Down Expand Up @@ -73,6 +77,8 @@ jobs:
- name: skipComponentGovernanceDetection
${{ if eq(parameters.os, 'linux') }}:
value: true
${{ if eq(parameters.os, 'osx') }}:
value: true
${{ if eq(parameters.os, 'win') }}:
value: false
- name: arch
Expand Down Expand Up @@ -179,5 +185,13 @@ jobs:
ep: ${{ parameters.ep }}
build_config: ${{ parameters.build_config }}

- ${{ if eq(parameters.os, 'osx') }}:
- template: steps/capi-macos-step.yml
parameters:
target: 'python'
arch: ${{ parameters.arch }}
ep: ${{ parameters.ep }}
build_config: ${{ parameters.build_config }}

- template: steps/compliant-and-cleanup-step.yml

Loading