Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into Cjian/ado-zip
Browse files Browse the repository at this point in the history
# Conflicts:
#	.pipelines/nuget-publishing.yml
#	.pipelines/pypl-publishing.yml
#	.pipelines/stages/jobs/nuget-packaging-job.yml
#	.pipelines/stages/nuget-packaging-stage.yml
#	.pipelines/stages/py-packaging-stage.yml
  • Loading branch information
jchen351 committed Apr 29, 2024
2 parents 050f01f + a9fd326 commit 55c0b69
Show file tree
Hide file tree
Showing 21 changed files with 327 additions and 113 deletions.
12 changes: 11 additions & 1 deletion .pipelines/nuget-publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ parameters:
type: boolean
default: true

- name: enable_win_dml
displayName: 'Whether Windows DirectML package is built.'
type: boolean
default: true

- name: ort_version
displayName: 'OnnxRuntime version'
type: string
default: '1.17.3'

- name: ort_dml_version
displayName: 'OnnxRuntime DirectML version'
type: string
default: '1.18.0-dev-20240423-0527-c07b8d545d'

- name: cuda_version
displayName: 'CUDA version'
type: string
Expand All @@ -49,6 +58,7 @@ stages:
enable_win_cuda: ${{ parameters.enable_win_cuda }}
enable_linux_cpu: ${{ parameters.enable_linux_cpu }}
enable_linux_cuda: ${{ parameters.enable_linux_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
ort_version: ${{ parameters.ort_version }}
ort_dml_version: ${{ parameters.ort_dml_version }}
cuda_version: ${{ parameters.cuda_version }}

14 changes: 13 additions & 1 deletion .pipelines/pypl-publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ parameters:
- name: enable_win_cuda
displayName: 'Whether Windows CUDA package is built.'
type: boolean
default : true

- name: enable_win_dml
displayName: 'Whether Windows DirectML package is built.'
type: boolean
default: true

- name: enable_linux_cpu
Expand All @@ -24,6 +29,11 @@ parameters:
type: string
default: '1.17.3'

- name: ort_dml_version
displayName: 'OnnxRuntime DirectML version'
type: string
default: '1.18.0-dev-20240423-0527-c07b8d545d'

- name: cuda_version
displayName: 'CUDA version'
type: string
Expand All @@ -48,6 +58,8 @@ stages:
enable_linux_cuda: ${{ parameters.enable_linux_cuda }}
enable_win_cpu: ${{ parameters.enable_win_cpu }}
enable_win_cuda: ${{ parameters.enable_win_cuda }}
enable_win_dml: ${{ parameters.enable_win_dml }}
ort_version: ${{ parameters.ort_version }}
ort_dml_version: ${{ parameters.ort_dml_version }}
cuda_version: ${{ parameters.cuda_version }}

26 changes: 23 additions & 3 deletions .pipelines/stages/jobs/nuget-packaging-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
${{ if eq(parameters.os, 'linux') }}:
pool: 'onnxruntime-Ubuntu2204-AMD-CPU'
${{ if eq(parameters.os, 'win') }}:
pool: 'onnxruntime-Win-CPU-2022'
${{ if eq(parameters.ep, 'directml') }}:
pool: 'onnxruntime-Win2022-GPU-dml-A10'
${{ else }}:
pool: 'onnxruntime-Win-CPU-2022'
timeoutInMinutes: 180
# set variables here to be used in the template and steps
variables:
Expand All @@ -42,22 +45,39 @@ jobs:
- name: ort_filename
${{ if eq(parameters.ep, 'cpu') }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-${{ parameters.ort_version }}'
${{ else}}:
${{ elseif eq(parameters.ep, 'cuda') }}:
${{if eq(parameters.cuda_version, '11.8') }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-gpu-${{ parameters.ort_version }}'
${{ else }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-cuda12-${{ parameters.ort_version }}'
${{ elseif eq(parameters.ep, 'directml')}}:
value: 'Microsoft.ML.OnnxRuntime.DirectML.${{ parameters.ort_version }}'
${{ else }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-${{ parameters.ep}}-${{ parameters.ort_version }}'
- name: genai_nuget_ext
${{ if eq(parameters.ep, 'cpu') }}:
value: ''
${{ if eq(parameters.ep, 'cuda') }}:
value: '.Cuda'
${{ if eq(parameters.ep, 'directml') }}:
value: '.DirectML'
- name: ortHome
value: 'ort'

- name: dml_dir
value: 'Microsoft.AI.DirectML.1.14.1'
- name: dml_zip
value: 'Microsoft.AI.DirectML.1.14.1.zip'
- name: dml_url
value: "https://www.nuget.org/api/v2/package/Microsoft.AI.DirectML/1.14.1"
workspace:
clean: all
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: 3.10
addToPath: true
architecture: $(arch)

- ${{ if eq(parameters.os, 'linux') }}:
- template: steps/capi-linux-step.yml
parameters:
Expand Down
21 changes: 19 additions & 2 deletions .pipelines/stages/jobs/py-packaging-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
${{ if eq(parameters.os, 'linux') }}:
pool: 'onnxruntime-Ubuntu2204-AMD-CPU'
${{ if eq(parameters.os, 'win') }}:
pool: 'onnxruntime-Win-CPU-2022'
${{ if eq(parameters.ep, 'directml') }}:
pool: 'onnxruntime-Win2022-GPU-dml-A10'
${{ else }}:
pool: 'onnxruntime-Win-CPU-2022'

strategy:
matrix:
Python38:
Expand Down Expand Up @@ -65,11 +69,23 @@ jobs:
- name: ort_filename
${{ if eq(parameters.ep, 'cpu') }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-${{ parameters.ort_version }}'
${{ else}}:
${{ elseif eq(parameters.ep, 'cuda') }}:
${{if eq(parameters.cuda_version, '11.8') }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-gpu-${{ parameters.ort_version }}'
${{ else }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-cuda12-${{ parameters.ort_version }}'
${{ elseif eq(parameters.ep, 'directml')}}:
value: 'Microsoft.ML.OnnxRuntime.DirectML.${{ parameters.ort_version }}'
${{ else }}:
value: 'onnxruntime-${{ parameters.os }}-${{ parameters.arch }}-${{ parameters.ep}}-${{ parameters.ort_version }}'

- name: dml_dir
value: 'Microsoft.AI.DirectML.1.14.1'
- name: dml_zip
value: 'Microsoft.AI.DirectML.1.14.1.zip'
- name: dml_url
value: "https://www.nuget.org/api/v2/package/Microsoft.AI.DirectML/1.14.1"

steps:
- task: UsePythonVersion@0
inputs:
Expand All @@ -96,6 +112,7 @@ jobs:
- template: steps/capi-win-step.yml
parameters:
target: 'python'
ep: ${{ parameters.ep }}

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

2 changes: 1 addition & 1 deletion .pipelines/stages/jobs/steps/capi-linux-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ steps:
echo "arch=$(arch)"
echo "ep=$(ep)"
displayName: 'Print Parameters'

- template: utils/download-ort.yml
parameters:
archiveType: 'tgz'

- bash: |
set -e -x
az login --identity --username 63b63039-6328-442f-954b-5a64d124e5b4
Expand Down
16 changes: 15 additions & 1 deletion .pipelines/stages/jobs/steps/capi-win-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ parameters:
- name: target
type: string
default: 'onnxruntime-genai'
- name: ep
type: string
default: 'cpu'
steps:
- bash: |
echo "##[error]Error: ep and arch are not set"
Expand All @@ -28,10 +31,21 @@ steps:
echo "cuda_version=$(cuda_version)"
echo "target=${{ parameters.target }}"
displayName: 'Print Parameters'

- template: utils/download-ort.yml
parameters:
archiveType: 'zip'
ep: ${{ parameters.ep }}

- ${{ if eq(parameters.ep, 'directml') }}:
- powershell: |
Invoke-WebRequest -Uri $(dml_url) -OutFile $(dml_zip)
Expand-Archive $(dml_zip) -DestinationPath $(dml_dir)
Remove-Item -Path $(dml_zip)
Get-ChildItem -Recurse $(dml_dir)
mv $(dml_dir)\bin\x64-win\DirectML.dll ort\lib
mv $(dml_dir)\include\DirectML.h ort\include
workingDirectory: '$(Build.Repository.LocalPath)'
continueOnError: true
- powershell: |
azcopy.exe cp --recursive "https://lotusscus.blob.core.windows.net/models/cuda_sdk/v$(cuda_version)" 'cuda_sdk'
Expand Down
4 changes: 2 additions & 2 deletions .pipelines/stages/jobs/steps/nuget-win-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ steps:
DisplayName: 'ESRP - Sign C# dlls'
Pattern: '*OnnxRuntimeGenAI*.dll'
- powershell: |
$VERSION = '0.1.0-rc4'
$VERSION = '0.2.0-rc4'
nuget.exe pack Microsoft.ML.OnnxRuntimeGenAI.nuspec `
-Prop version=$VERSION `
-Prop genai_nuget_ext=$(genai_nuget_ext) `
-Prop configuration=$(buildConfig) `
-Prop buildPath=$(buildDir)
-Prop buildPath=$(buildDir) `
-Prop ortHome=$(ortHome)
nuget.exe pack Microsoft.ML.OnnxRuntimeGenAI.Managed.nuspec `
-Prop version=$VERSION `
Expand Down
1 change: 1 addition & 0 deletions .pipelines/stages/jobs/steps/utils/capi-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ steps:
SourceFolder: '$(Build.Repository.LocalPath)/src'
Contents: |
ort_genai_c.h
ort_genai.h
TargetFolder: '$(Build.ArtifactStagingDirectory)/$(artifactName)/include'

- task: CopyFiles@2
Expand Down
74 changes: 51 additions & 23 deletions .pipelines/stages/jobs/steps/utils/download-ort.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
parameters:
- name: archiveType
type: string
- name: ep
type: string
default: cpu
steps:
- bash: |
echo "##[error]Error: ort_version and ort_filename are not set"
exit 1
displayName: 'Check if variables ort_version and ort_filename are set'
condition: or( eq (variables['ort_version'], ''), eq (variables['ort_filename'], ''))

- task: DownloadGitHubRelease@0
inputs:
connection: 'GitHub - Release'
userRepository: 'microsoft/onnxruntime'
defaultVersionType: 'specificTag'
version: 'v$(ort_version)'
itemPattern: '$(ort_filename).${{ parameters.archiveType }}'
downloadPath: '$(Build.Repository.LocalPath)'
displayName: Download $(ort_filename)

- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.Repository.LocalPath)/$(ort_filename).${{ parameters.archiveType }}'
destinationFolder: '$(Build.Repository.LocalPath)'
cleanDestinationFolder: false
overwriteExistingFiles: true
displayName: Unzip OnnxRuntime

- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)/$(ort_filename)'
TargetFolder: '$(Build.Repository.LocalPath)/ort'
displayName: Copy OnnxRuntime to ort
#Special case for DML
- ${{ if ne(parameters.ep, 'directml') }}:
- task: DownloadGitHubRelease@0
inputs:
connection: 'GitHub - Release'
userRepository: 'microsoft/onnxruntime'
defaultVersionType: 'specificTag'
version: 'v$(ort_version)'
itemPattern: '$(ort_filename).${{ parameters.archiveType }}'
downloadPath: '$(Build.Repository.LocalPath)'
displayName: Download $(ort_filename)
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.Repository.LocalPath)/$(ort_filename).${{ parameters.archiveType }}'
destinationFolder: '$(Build.Repository.LocalPath)'
cleanDestinationFolder: false
overwriteExistingFiles: true
displayName: Unzip OnnxRuntime
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)/$(ort_filename)'
TargetFolder: '$(Build.Repository.LocalPath)/ort'
displayName: Copy OnnxRuntime to ort
- ${{ else }}:
- task: DownloadPackage@1
inputs:
packageType: 'nuget'
feed: '2692857e-05ef-43b4-ba9c-ccf1c22c437c/7982ae20-ed19-4a35-a362-a96ac99897b7'
definition: 'Microsoft.ML.OnnxRuntime.DirectML' # Can also be package name
version: '$(ort_version)'
extract: false
downloadPath: '$(Build.Repository.LocalPath)'
displayName: Download $(ort_filename)
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.Repository.LocalPath)/*.nupkg'
destinationFolder: '$(Build.Repository.LocalPath)/ort'
cleanDestinationFolder: false
overwriteExistingFiles: true
displayName: Unzip OnnxRuntime
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)/ort/runtimes/win-x64/native'
TargetFolder: '$(Build.Repository.LocalPath)/ort/lib'
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)/ort/build/native/include'
TargetFolder: '$(Build.Repository.LocalPath)/ort/include'

- task: DeleteFiles@1
inputs:
Expand Down
20 changes: 16 additions & 4 deletions .pipelines/stages/nuget-packaging-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ parameters:
type: boolean
- name: enable_win_cuda
type: boolean
- name: enable_win_dml
type: boolean
- name: enable_linux_cpu
type: boolean
- name: enable_linux_cuda
type: boolean
- name: ort_version
type: string
- name: ort_dml_version
type: string
- name: cuda_version
type: string
default: ''
Expand All @@ -24,7 +28,16 @@ stages:
ep: 'cpu'
ort_version: ${{ parameters.ort_version }}
os: 'win'


- ${{ if eq(parameters.enable_win_dml, true) }}:
- template: jobs/nuget-packaging-job.yml
parameters:
arch: 'x64'
ep: 'directml'
ort_version: ${{ parameters.ort_dml_version }}
os: 'win'
publish_to_ado_feed: ${{ parameters.publish_to_ado_feed }}

- ${{ if eq(parameters.enable_win_cuda, true) }}:
- template: jobs/nuget-packaging-job.yml
parameters:
Expand All @@ -33,15 +46,15 @@ stages:
ep: 'cuda'
ort_version: ${{ parameters.ort_version }}
os: 'win'

- ${{ if eq(parameters.enable_linux_cpu, true) }}:
- template: jobs/nuget-packaging-job.yml
parameters:
arch: 'x64'
ep: 'cpu'
ort_version: ${{ parameters.ort_version }}
os: 'linux'

- ${{ if eq(parameters.enable_linux_cuda, true) }}:
- template: jobs/nuget-packaging-job.yml
parameters:
Expand All @@ -50,4 +63,3 @@ stages:
ep: 'cuda'
ort_version: ${{ parameters.ort_version }}
os: 'linux'

Loading

0 comments on commit 55c0b69

Please sign in to comment.