Skip to content

Commit

Permalink
[ORT 1.18.1 Release] Cherry pick 1st round (#21105)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe your changes. -->



### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

---------

Co-authored-by: Jian Chen <[email protected]>
Co-authored-by: Yi Zhang <[email protected]>
Co-authored-by: Changming Sun <[email protected]>
Co-authored-by: Ye Wang <[email protected]>
Co-authored-by: Your Name <[email protected]>
  • Loading branch information
6 people committed Jun 20, 2024
1 parent 4573740 commit 91fb865
Show file tree
Hide file tree
Showing 129 changed files with 1,907 additions and 2,120 deletions.
23 changes: 16 additions & 7 deletions .pipelines/OneBranch.Nuget-WindowsAI-Pipeline.Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ extends:
$arm64_static_runtime_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm64_static_runtime_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm64_static_runtime_nuget_package))
[System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_static_runtime_nuget_package, $arm64_static_runtime_nupkg_unzipped_directory)
$x64_static_runtime_path_old = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-x64', '_native')
$x64_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x64', '_native', 'static')
Expand All @@ -185,7 +185,7 @@ extends:
$arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
$arm64_static_runtime_path_old = [System.IO.Path]::Combine($arm64_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
$arm64_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native', 'static')
$uap_build_path_old = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory, 'build', 'native')
$uap_build_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'build', 'uap10.0')
Expand Down Expand Up @@ -262,7 +262,7 @@ extends:
$x86_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
$arm64_runtime_path_old = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
$arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
New-Item -Path $x86_runtime_path_new -ItemType Directory
New-Item -Path $arm64_runtime_path_new -ItemType Directory
Expand Down Expand Up @@ -293,12 +293,21 @@ extends:
- script: |
dir $(Build.SourcesDirectory)\unzipped\runtimes\win-x64\_native
- task: EsrpCodeSigning@2
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: "Sign Nuget package"
inputs:
ConnectedServiceName: 'OnnxRuntime CodeSign 20190817'
ConnectedServiceName: 'OnnxrunTimeCodeSign_20240611'
AppRegistrationClientId: '53d54d02-978d-4305-8572-583cf6711c4f'
AppRegistrationTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
AuthAKVName: 'buildkeyvault'
AuthCertName: '53d54d02-SSL-AutoRotate'
AuthSignCertName: '53d54d02-978d-4305-8572-583cf6711c4f'

FolderPath: $(Build.ArtifactStagingDirectory)
Pattern: '*.nupkg'
SessionTimeout: 90
ServiceEndpointUrl: 'https://api.esrp.microsoft.com/api/v2'
MaxConcurrency: 25
signConfigType: inlineSignParams
inlineOperation: |
[
Expand All @@ -307,14 +316,14 @@ extends:
"operationSetCode": "NuGetSign",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
"toolVersion": "6.2.9304.0"
},
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
"toolVersion": "6.2.9304.0"
}
]
Expand Down
20 changes: 2 additions & 18 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 8)
message(FATAL_ERROR "GCC version must be greater than or equal to 8")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
message(FATAL_ERROR "GCC version must be greater than or equal to 9")
endif()

# Options
Expand Down Expand Up @@ -1294,12 +1294,6 @@ if (onnxruntime_USE_TVM)
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES tvm)
endif()

# needs to link with stdc++fs in Linux
if (UNIX AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
set(FS_STDLIB stdc++fs)
endif()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${FS_STDLIB})

# onnxruntime-extensions
if (onnxruntime_USE_EXTENSIONS)
include(extensions)
Expand Down Expand Up @@ -1468,16 +1462,6 @@ if (onnxruntime_USE_CUDA)
endif()
endif()

if (onnxruntime_USE_TENSORRT)
# needs to link with stdc++fs in Linux
if (UNIX)
if (NOT APPLE)
set(FS_STDLIB stdc++fs)
endif()
endif()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${FS_STDLIB})
endif()

if (onnxruntime_USE_MIGRAPHX)
if (WIN32)
message(FATAL_ERROR "MIGraphX does not support build in Windows!")
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime_providers_migraphx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
target_compile_options(onnxruntime_providers_migraphx PRIVATE -Wno-error=sign-compare)
set_property(TARGET onnxruntime_providers_migraphx APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
set_property(TARGET onnxruntime_providers_migraphx APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/migraphx/version_script.lds -Xlinker --gc-sections")
target_link_libraries(onnxruntime_providers_migraphx PRIVATE nsync::nsync_cpp stdc++fs)
target_link_libraries(onnxruntime_providers_migraphx PRIVATE nsync::nsync_cpp)

include(CheckLibraryExists)
check_library_exists(migraphx::c "migraphx_program_run_async" "/opt/rocm/migraphx/lib" HAS_STREAM_SYNC)
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime_providers_tensorrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
elseif(UNIX)
set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/tensorrt/version_script.lds -Xlinker --gc-sections")
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE nsync::nsync_cpp stdc++fs)
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE nsync::nsync_cpp)
elseif(WIN32)
set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/tensorrt/symbols.def")
else()
Expand Down
87 changes: 60 additions & 27 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'signing'
id 'jacoco'
id "com.diffplug.spotless" version "6.25.0"
id "net.linguica.maven-settings" version "0.5"
}

allprojects {
Expand All @@ -19,6 +20,12 @@ version = rootProject.file('../VERSION_NUMBER').text.trim()
def cmakeBuildDir = System.properties['cmakeBuildDir']
def useCUDA = System.properties['USE_CUDA']
def useROCM = System.properties['USE_ROCM']

def adoArtifact = project.findProperty('adoArtifact')
def adoAccessToken = project.findProperty('adoAccessToken')
// Only publish to ADO feed if all two properties are set
def publishToAdo = adoArtifact != null && adoAccessToken != null

boolean enableTrainingApis = (System.properties['ENABLE_TRAINING_APIS'] ?: "0") == "1"
def cmakeJavaDir = "${cmakeBuildDir}/java"
def cmakeNativeLibDir = "${cmakeJavaDir}/native-lib"
Expand All @@ -37,6 +44,11 @@ def trainingDescription = 'ONNX Runtime Training is a training and inference pac
'(Open Neural Network Exchange) models. This package is targeted for Learning on The Edge aka On-Device Training ' +
'See https://github.com/microsoft/onnxruntime-training-examples/tree/master/on_device_training for more details.'

// We need to have a custom settings.xml so codeql can bypass the need for settings.security.xml
mavenSettings {
userSettingsFileName = "${projectDir}/settings.xml"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -48,7 +60,8 @@ jar {
}

// Add explicit sources jar with pom file.
task sourcesJar(type: Jar, dependsOn: classes) {
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier = "sources"
from sourceSets.main.allSource
into("META-INF/maven/$project.group/$mavenArtifactId") {
Expand All @@ -58,7 +71,8 @@ task sourcesJar(type: Jar, dependsOn: classes) {
}

// Add explicit javadoc jar with pom file
task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = "javadoc"
from javadoc.destinationDir
into("META-INF/maven/$project.group/$mavenArtifactId") {
Expand All @@ -82,7 +96,7 @@ spotless {

compileJava {
dependsOn spotlessJava
options.compilerArgs += ["-h", "${project.buildDir}/headers/"]
options.compilerArgs += ["-h", "${layout.buildDirectory.get().toString()}/headers/"]
if (!JavaVersion.current().isJava8()) {
// Ensures only methods present in Java 8 are used
options.compilerArgs.addAll(['--release', '8'])
Expand Down Expand Up @@ -128,7 +142,7 @@ if (cmakeBuildDir != null) {
// generate tasks to be called from cmake

// Overwrite jar location
task allJar(type: Jar) {
tasks.register('allJar', Jar) {
manifest {
attributes('Automatic-Module-Name': project.group,
'Implementation-Title': 'onnxruntime',
Expand All @@ -143,23 +157,20 @@ if (cmakeBuildDir != null) {
from cmakeNativeLibDir
}

task cmakeBuild(type: Copy) {
from project.buildDir
tasks.register('cmakeBuild', Copy) {
from layout.buildDirectory.get()
include 'libs/**'
include 'docs/**'
into cmakeBuildOutputDir
dependsOn(allJar, sourcesJar, javadocJar, javadoc)
}
cmakeBuild.dependsOn allJar
cmakeBuild.dependsOn sourcesJar
cmakeBuild.dependsOn javadocJar
cmakeBuild.dependsOn javadoc

task cmakeCheck(type: Copy) {
from project.buildDir
tasks.register('cmakeCheck', Copy) {
from layout.buildDirectory.get()
include 'reports/**'
into cmakeBuildOutputDir
dependsOn(check)
}
cmakeCheck.dependsOn check
}

dependencies {
Expand Down Expand Up @@ -198,17 +209,22 @@ jacocoTestReport {
reports {
xml.required = true
csv.required = true
html.destination file("${buildDir}/jacocoHtml")
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}

publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = mavenArtifactId

from components.java
if(publishToAdo) {
artifactId = 'onnxruntime_gpu'
artifact (adoArtifact)
} else {
artifactId = mavenArtifactId
from components.java
}
version = project.version
pom {
name = enableTrainingApis ? 'onnxruntime-training' : 'onnx-runtime'
description = enableTrainingApis ? trainingDescription : defaultDescription
Expand Down Expand Up @@ -239,24 +255,41 @@ publishing {
}
}
repositories {
maven {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username mavenUser
password mavenPwd
if (publishToAdo) {
maven {
url "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/${System.getenv('ADOFeedName')}/maven/v1"
name System.getenv('ADOFeedName')
authentication {
basic(BasicAuthentication)
}
credentials {
username 'aiinfra'
password "${project.findProperty('adoAccessToken')}"
}
}
} else {
maven {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username mavenUser
password mavenPwd
}
}
}
}
}

// Generates a task signMavenPublication that will
// build all artifacts.
signing {
// Queries env vars:
// ORG_GRADLE_PROJECT_signingKey
// ORG_GRADLE_PROJECT_signingPassword but can be changed to properties
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
// Skip signing if no key is provided
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
sign publishing.publications.mavenAdo
}
}
9 changes: 9 additions & 0 deletions java/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!--The only purpose of this file is to let codeql bypass the need for settings.security.xml-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<!-- password is coming from cli -PadoAccessToken -->
</servers>
</settings>
9 changes: 9 additions & 0 deletions onnxruntime/contrib_ops/cuda/quantization/moe_quantization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ Status QMoE::ComputeInternal(OpKernelContext* context) const {
const Tensor* fc3_scales_optional = context->Input<Tensor>(9);
const Tensor* fc3_experts_bias_optional = context->Input<Tensor>(10);

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Mute "maybe used uninitialized" warning for MoEParameters.
#endif

MoEParameters moe_params;
MoEQuantType quant_type = MoEQuantType::UINT4;
ORT_RETURN_IF_ERROR(CheckInputs(moe_params, quant_type, input, router_probs, fc1_experts_weights,
Expand Down Expand Up @@ -135,6 +140,10 @@ Status QMoE::ComputeInternal(OpKernelContext* context) const {
reinterpret_cast<int*>(expert_for_source_row.get()), static_cast<int>(moe_params.num_rows),
static_cast<int>(moe_params.hidden_size), static_cast<int>(k_), Stream(context));

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

return Status::OK();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
#include <sstream>
#include <iostream>
#include <filesystem>
#include <experimental/filesystem>
#include "flatbuffers/idl.h"
#include "ort_trt_int8_cal_table.fbs.h"
#include <NvInferVersion.h>
#include "core/providers/cuda/cuda_pch.h"
#include "core/common/path_string.h"
#include "core/framework/murmurhash3.h"

namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;

namespace onnxruntime {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
optimum>=1.14.1
transformers>=4.33.2,<= 4.37.2
torch>=2.2.0
onnx>=1.14.0
onnx==1.16.0
datasets>=2.8.0
protobuf==3.20.2
psutil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
onnx>=1.15.0
onnx==1.16.0
transformers>=4.36.2
onnxscript>=0.1.0.dev20240126
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ soundfile
librosa
optimum
onnxruntime-extensions>=0.9.0
onnx>=1.15.0
onnx==1.16.0
protobuf==3.20.2
numpy==1.23.3
psutil
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def run(self):
"libcudart.so.11.0",
"libcudart.so.12",
"libcudnn.so.8",
"libcudnn.so.9",
"libcufft.so.10",
"libcufft.so.11",
"libcurand.so.10",
Expand Down
1 change: 1 addition & 0 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@ def generate_build_tree(
cuda_compile_flags_str = cuda_compile_flags_str + " " + compile_flag
if len(cuda_compile_flags_str) != 0:
cudaflags.append('-Xcompiler="%s"' % cuda_compile_flags_str)
cudaflags.append("-allow-unsupported-compiler")
elif is_linux() or is_macOS():
if is_linux():
ldflags = ["-Wl,-Bsymbolic-functions", "-Wl,-z,relro", "-Wl,-z,now", "-Wl,-z,noexecstack"]
Expand Down
Loading

0 comments on commit 91fb865

Please sign in to comment.