Skip to content

Commit

Permalink
Make ROCm packaging stages to a single workflow (microsoft#21235)
Browse files Browse the repository at this point in the history
### Description
Make current ROCm packaging stages to a single workflow.
Reduce the possibility of all nightly packages can't be generated by one
failed stage



### Motivation and Context
Our plan is to reduce the complexity of the current zip-nuget pipeline
to improve the stability and performance of nightly packages generation.
ROCm packaging stages has no dependencies with other packaging jobs and
it's the most time-consuming route.
After this change, the most used CPU/CUDA/Mobile packaging workflow
duration can be reduced roughly from 3h20m to 2h30m.
  • Loading branch information
mszhanyi authored Jul 4, 2024
1 parent f39ee14 commit 30b6e82
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,6 @@ stages:
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}

- stage: Debug
dependsOn: Setup
jobs:
- job: D1
pool:
name: 'onnxruntime-Ubuntu2204-AMD-CPU'
variables:
MyVar: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']]
BuildDate: $[stageDependencies.Setup.Set_Variables.outputs['Set_Build_Date.BuildDate']]
BuildTime: $[stageDependencies.Setup.Set_Variables.outputs['Set_Build_Time.BuildTime']]
steps:
- checkout: none
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()
- bash: echo $(MyVar)
- bash: echo $(BuildTime)
- bash: echo $(BuildDate)
- template: templates/component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'

- template: stages/download-java-tools-stage.yml

- template: templates/c-api-cpu.yml
Expand Down Expand Up @@ -167,269 +145,6 @@ stages:
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

# ROCm
- stage: Linux_C_API_Packaging_ROCm_x64
dependsOn: []
jobs:
- job: Linux_C_API_Packaging_ROCm_x64
workspace:
clean: all
timeoutInMinutes: 240
pool: onnxruntime-Ubuntu2204-AMD-CPU
variables:
RocmVersion: '5.6'
RocmVersionPatchSuffix: ''
steps:
- checkout: self # due to checkout multiple repos, the root directory is $(Build.SourcesDirectory)/onnxruntime
submodules: recursive
- checkout: manylinux # due to checkout multiple repos, the root directory is $(Build.SourcesDirectory)/manylinux, for get-docker-image-steps.yml
submodules: false

# get-docker-image-steps.yml will move the $(Build.SourcesDirectory)/manylinux into $(Build.SourcesDirectory)/onnxruntime,
# then rename $(Build.SourcesDirectory)/onnxruntime as $(Build.SourcesDirectory)
- template: templates/get-docker-image-steps.yml
parameters:
Dockerfile: tools/ci_build/github/linux/docker/Dockerfile.manylinux2_28_rocm
Context: tools/ci_build/github/linux/docker
DockerBuildArgs: >-
--build-arg INSTALL_DEPS_EXTRA_ARGS=-tmur
--build-arg BUILD_UID=$(id -u)
--network=host --build-arg POLICY=manylinux_2_28 --build-arg PLATFORM=x86_64
--build-arg ROCM_VERSION=$(RocmVersion)$(RocmVersionPatchSuffix)
--build-arg DEVTOOLSET_ROOTPATH=/opt/rh/gcc-toolset-12/root
--build-arg PREPEND_PATH=/opt/rh/gcc-toolset-12/root/usr/bin:
--build-arg LD_LIBRARY_PATH_ARG=/opt/rh/gcc-toolset-12/root/usr/lib64:/opt/rh/gcc-toolset-12/root/usr/lib:/opt/rh/gcc-toolset-12/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-12/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib
Repository: onnxruntimetrainingrocmbuild-rocm$(RocmVersion)
CheckOutManyLinux: true

- template: templates/set-version-number-variables-step.yml

- task: Bash@3
displayName: 'Build'
inputs:
targetType: filePath
filePath: tools/ci_build/github/linux/build_rocm_c_api_package.sh
arguments: >-
-S $(Build.SourcesDirectory)
-B $(Build.BinariesDirectory)
-V $(RocmVersion)
-I onnxruntimetrainingrocmbuild-rocm$(RocmVersion)
-P python3.10
- script: |
set -e -x
mkdir $(Build.ArtifactStagingDirectory)/testdata
cp $(Build.BinariesDirectory)/Release/libcustom_op_library.so* $(Build.ArtifactStagingDirectory)/testdata
ls -al $(Build.ArtifactStagingDirectory)
displayName: 'Create Artifacts for CustomOp' # libcustom_op_library.so from cpu build is built with fp8, ROCm does not support it.
- template: templates/c-api-artifacts-package-and-publish-steps-posix.yml
parameters:
buildConfig: 'Release'
artifactName: 'onnxruntime-linux-x64-rocm-$(OnnxRuntimeVersion)'
artifactNameNoVersionString: 'onnxruntime-linux-x64-rocm'
libraryName: 'libonnxruntime.so.$(OnnxRuntimeVersion)'

- template: templates/component-governance-component-detection-steps.yml
parameters:
condition: 'succeeded'
- template: templates/clean-agent-build-directory-step.yml


- stage: NuGet_Packaging_ROCm
dependsOn:
- Setup
- Linux_C_API_Packaging_ROCm_x64
condition: succeeded()
jobs:
- job: NuGet_Packaging_ROCm
workspace:
clean: all
# we need to use a 2022 pool to create the nuget package with MAUI targets.
# VS2019 has no support for net6/MAUI and we need to use msbuild (from the VS install) to do the packing
pool: 'Onnxruntime-Win-CPU-2022'
variables:
breakCodesignValidationInjection: ${{ parameters.DoEsrp }}
ReleaseVersionSuffix: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']]
BuildDate : $[stageDependencies.Setup.Set_Variables.outputs['Set_Build_Date.BuildDate']]
BuildTime : $[stageDependencies.Setup.Set_Variables.outputs['Set_Build_Time.BuildTime']]

steps:
- checkout: self
submodules: true
fetchDepth: 1

- template: templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact - NuGet'
ArtifactName: 'onnxruntime-linux-x64-rocm'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact'
SpecificArtifact: ${{ parameters.specificArtifact }}
BuildId: ${{ parameters.BuildId }}

- task: PowerShell@2
displayName: 'Reconstruct Build Directory'
inputs:
targetType: inline
script: |
Get-ChildItem $(Build.BinariesDirectory)\nuget-artifact -Filter *.tgz | % {
# *.tar will be created after *.tgz is extracted
$cmd = "7z.exe x $($_.FullName) -y -o$(Build.BinariesDirectory)\nuget-artifact"
Write-Output $cmd
Invoke-Expression -Command $cmd
}
Get-ChildItem $(Build.BinariesDirectory)\nuget-artifact -Filter *.tar | % {
$cmd = "7z.exe x $($_.FullName) -y -o$(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\nuget-artifacts"
Write-Output $cmd
Invoke-Expression -Command $cmd
}
$ort_dirs = Get-ChildItem -Path $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\onnxruntime-* -Directory
foreach ($ort_dir in $ort_dirs)
{
$dirname = Split-Path -Path $ort_dir -Leaf
$dirname = $dirname.SubString(0, $dirname.LastIndexOf('-'))
Write-Output "Renaming $ort_dir to $dirname"
Rename-Item -Path $ort_dir -NewName $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\$dirname
}
Copy-Item -Path $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\onnxruntime-linux-x64-rocm\lib\* -Destination $(Build.BinariesDirectory)\RelWithDebInfo
- script: |
tree /F
workingDirectory: '$(Build.BinariesDirectory)'
displayName: 'Inspect Build Binaries Directory'
- script: |
mklink /D /J models C:\local\models
workingDirectory: '$(Build.BinariesDirectory)'
displayName: 'Create models link'
- task: NuGetToolInstaller@0
displayName: Use Nuget 6.10.x
inputs:
versionSpec: 6.10.x

- task: MSBuild@1
displayName: 'Restore NuGet Packages and create project.assets.json'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
platform: 'Any CPU'
configuration: RelWithDebInfo
msbuildArguments: '-t:restore -p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm"'
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- task: MSBuild@1
displayName: 'Build C# bindings'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
platform: 'Any CPU'
configuration: RelWithDebInfo
msbuildArguments: >
-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)"
-p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm"
-p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}
-p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)
-p:IsLinuxBuild=true
-p:IsWindowsBuild=false
-p:IsMacOSBuild=false
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- template: templates/win-esrp-dll.yml
parameters:
FolderPath: '$(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo'
DisplayName: 'ESRP - Sign C# dlls'
DoEsrp: ${{ parameters.DoEsrp }}

- task: UsePythonVersion@0
displayName: 'Use Python'
inputs:
versionSpec: 3.8

- task: MSBuild@1
displayName: 'Build Nuget Packages'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj'
configuration: RelWithDebInfo
platform: 'Any CPU'
msbuildArguments: >
-t:CreatePackage
-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)"
-p:OrtPackageId=Microsoft.ML.OnnxRuntime.ROCm
-p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}
-p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)
-p:CurrentTime=$(BuildTime)
-p:CurrentDate=$(BuildDate)
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- task: CopyFiles@2
displayName: 'Copy nuget packages to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo'
Contents: '*.snupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: CopyFiles@2
displayName: 'Copy nuget packages to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo'
Contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: CopyFiles@2
displayName: 'Copy nuget packages to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo'
Contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- template: templates/esrp_nuget.yml
parameters:
DisplayName: 'ESRP - sign NuGet package'
FolderPath: '$(Build.ArtifactStagingDirectory)'
DoEsrp: ${{ parameters.DoEsrp }}

- template: templates/validate-package.yml
parameters:
PackageType: 'nuget'
PackagePath: '$(Build.ArtifactStagingDirectory)'
PackageName: 'Microsoft.ML.OnnxRuntime.*nupkg'
PlatformsSupported: 'linux-x64'
VerifyNugetSigning: false

- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline NuGet Artifact'
inputs:
artifactName: 'drop-signed-nuget-ROCm'
targetPath: '$(Build.ArtifactStagingDirectory)'

- task: MSBuild@1
displayName: 'Clean C#'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
platform: 'Any CPU'
configuration: RelWithDebInfo
msbuildArguments: '-t:Clean -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.ROCm'
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- template: templates/component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'

- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()

- template: nuget/templates/test_linux.yml
parameters:
AgentPool: AMD-GPU
ArtifactSuffix: 'ROCm'
StageSuffix: 'ROCm'
NugetPackageName: 'Microsoft.ML.OnnxRuntime.ROCm'
SpecificArtifact: ${{ parameters.specificArtifact }}
CustomOpArtifactName: 'onnxruntime-linux-x64-rocm'
BuildId: ${{ parameters.BuildId }}

- template: nuget/templates/dml-vs-2022.yml
parameters:
Expand Down
5 changes: 0 additions & 5 deletions tools/ci_build/github/azure-pipelines/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ stages:
artifact: 'drop-signed-nuget-GPU'
- script: move "$(Pipeline.Workspace)\build\drop-signed-nuget-GPU\*" $(Build.BinariesDirectory)\nuget-artifact\final-package

- download: build
displayName: 'Download Pipeline Artifact - Signed NuGet ROCm Package'
artifact: 'drop-signed-nuget-ROCm'
- script: move "$(Pipeline.Workspace)\build\drop-signed-nuget-ROCm\*" $(Build.BinariesDirectory)\nuget-artifact\final-package

- download: build
displayName: 'Download Pipeline Artifact - Signed NuGet Qnn Package'
artifact: 'drop-signed-nuget-qnn'
Expand Down
Loading

0 comments on commit 30b6e82

Please sign in to comment.