Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/win-cuda-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ jobs:
shell: pwsh
run: |
$resp = Invoke-RestMethod "${{ env.ORT_NIGHTLY_REST_API }}"
# Hold the CUDA build at ORT 1.26.0 because ORT-GPU 1.27 nupkgs link
# the CUDA 13 runtime, while this runner ships CUDA 12.8. Keep this
# pin aligned with the USE_CUDA branch in cmake/ortlib.cmake.
$ORT_NIGHTLY_VERSION = "1.26.0"
Write-Host "$ORT_NIGHTLY_VERSION"
"ORT_NIGHTLY_VERSION=$ORT_NIGHTLY_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
Expand Down
27 changes: 23 additions & 4 deletions .pipelines/stages/jobs/steps/integration-pytest-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ steps:
python -m pip install --upgrade pip
python -m pip install -r test\python\requirements.txt
python -m pip install pytest
python -m pip install onnxruntime-gpu==1.26.0
# CUDA: onnxruntime-gpu 1.27.0 links libcudart.so.13 (CUDA 13); CI runners
# ship CUDA 12.x. Hold CUDA on 1.26.0 until the CI image migrates.
# WebGPU: ORT 1.27 ships a MatMulNBitsMlpFusion transformer whose kernel
# only exists in plugin EP 0.2.0+. Pair ORT 1.27 with the 0.2.0.dev wheel
# from the ORT-Nightly Azure feed (not published to PyPI).
if ("${{ parameters.ep }}" -eq "cpu") {
python -m pip install onnxruntime-gpu==1.27.0
} elseif ("${{ parameters.ep }}" -eq "cuda") {
python -m pip install onnxruntime-gpu==1.26.0
} else {
python -m pip install onnxruntime==1.27.0
}
python -m pip install $wheel.FullName
if ("${{ parameters.ep }}" -eq "webgpu") {
python -m pip install onnxruntime-ep-webgpu==0.1.0
python -m pip install onnxruntime-ep-webgpu==0.2.0.dev20260611 `
--index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/
}
displayName: 'Install source-built wheel and test deps'
workingDirectory: '$(Build.Repository.LocalPath)'
Expand Down Expand Up @@ -75,6 +87,9 @@ steps:
PYTHON_EXE=/opt/python/cp312-cp312/bin/python3.12
\$PYTHON_EXE -m pip install -r test/python/requirements.txt
\$PYTHON_EXE -m pip install pytest
# onnxruntime-gpu 1.27.0 links libcudart.so.13 (CUDA 13). This CUDA
# container image ships CUDA 12.x, so the wheel fails to import.
# Hold at 1.26.0 until the image migrates to CUDA 13.
\$PYTHON_EXE -m pip install onnxruntime-gpu==1.26.0
\$PYTHON_EXE -m pip install /wheel/*.whl
nvidia-smi --query-gpu=name,compute_cap,driver_version,memory.total,memory.used,memory.free --format=csv
Expand Down Expand Up @@ -113,10 +128,14 @@ steps:
python -m pip install --upgrade pip
python -m pip install -r test/python/requirements.txt
python -m pip install pytest
python -m pip install onnxruntime==1.26.0
# WebGPU: ORT 1.27 ships a MatMulNBitsMlpFusion transformer whose kernel
# only exists in plugin EP 0.2.0+. Pair ORT 1.27 with the 0.2.0.dev wheel
# from the ORT-Nightly Azure feed (not published to PyPI).
python -m pip install onnxruntime==1.27.0
python -m pip install ${{ parameters.wheelDir }}/*.whl
if [ "${{ parameters.ep }}" = "webgpu" ]; then
python -m pip install onnxruntime-ep-webgpu==0.1.0
python -m pip install onnxruntime-ep-webgpu==0.2.0.dev20260611 \
--index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/
fi
displayName: 'Install source-built wheel and test deps'
workingDirectory: '$(Build.Repository.LocalPath)'
Expand Down
8 changes: 7 additions & 1 deletion cmake/ortlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if(ORT_HOME)
endif()
else()
# If ORT_HOME is not specified, download the onnxruntime headers and libraries from the nightly feed
set(ORT_VERSION "1.26.0")
set(ORT_VERSION "1.27.0")
Comment thread
baijumeswani marked this conversation as resolved.
Outdated
set(ORT_FEED_ORG_NAME "aiinfra")
set(ORT_FEED_PROJECT "2692857e-05ef-43b4-ba9c-ccf1c22c437c")
set(ORT_NIGHTLY_FEED_ID "7982ae20-ed19-4a35-a362-a96ac99897b7")
Expand All @@ -89,6 +89,12 @@ else()
set(ORT_VERSION "1.24.4")
set(ORT_PACKAGE_NAME "Microsoft.ML.OnnxRuntime.DirectML")
elseif(USE_CUDA)
# ORT-GPU 1.27 nupkgs link the CUDA 13 runtime (libcudart.so.13,
# libcublasLt.so.13). CI runners ship CUDA 12.x, so the provider .so
# fails to load. SessionReleaseCapturedGraph (the API 27 feature) is
# WebGPU-only, so holding CUDA at 1.26 does not lose functionality on
# the CUDA path. Drop this override once CI images migrate to CUDA 13.
set(ORT_VERSION "1.26.0")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(ORT_PACKAGE_NAME "Microsoft.ML.OnnxRuntime.Gpu.Linux")
elseif(WIN32)
Expand Down
23 changes: 22 additions & 1 deletion src/models/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ State::State(const GeneratorParams& params, const Model& model)
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, INT_MAX);
graph_id_ = std::to_string(dis(gen));
graph_id_value_ = dis(gen);
graph_id_ = std::to_string(graph_id_value_);
Comment thread
qjia7 marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -94,6 +95,7 @@ void State::Run(OrtSession& session, bool graph_capture_this_run) {
DurationTrace trace{"State::Run"};

if (params_->use_graph_capture) {
graph_capture_session_ = &session;
if (graph_capture_this_run) {
run_options_->AddConfigEntry("gpu_graph_id", graph_id_.c_str());
} else {
Expand Down Expand Up @@ -223,6 +225,25 @@ void State::SetActiveAdapter(Adapters* adapters, const std::string& adapter_name
}

State::~State() {
// Release captured graph resources in the EP.
// Note: the EP contract is to no-op when the id was never captured (e.g., when
// graph_capture_this_run was always false for this State). The call is wrapped
// in try/catch because destructors must not throw -- a throw during unwinding
// would call std::terminate.
#if ORT_API_VERSION >= 27
if (graph_capture_session_ && graph_id_value_ > 0) {
try {
graph_capture_session_->ReleaseCapturedGraph(graph_id_value_);
} catch (...) {
// Best-effort cleanup; swallow to keep the destructor non-throwing.
Comment thread
qjia7 marked this conversation as resolved.
if (g_log.enabled && g_log.ort_lib) {
Log("ort_lib") << "ReleaseCapturedGraph(id=" << graph_id_value_
<< ") failed: unknown exception" << std::endl;
}
}
}
#endif

Comment thread
qjia7 marked this conversation as resolved.
if (adapters_) {
for (const auto& adapter_name : adapter_names_) {
adapters_->ReleaseAdapter(adapter_name);
Expand Down
5 changes: 5 additions & 0 deletions src/models/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ struct State {

private:
std::string graph_id_{};
int graph_id_value_{0}; // integer form of graph_id_, used to avoid re-parsing in the destructor
// Session used for graph capture; not owned. Lifetime invariant: the OrtSession
// outlives this State because State is owned by Generator, and Generator is
// destroyed before the Model (and its session) that produced it.
OrtSession* graph_capture_session_{nullptr};
std::shared_ptr<Adapters> adapters_;
ExtraOutputs extra_outputs_;
};
Expand Down
4 changes: 4 additions & 0 deletions src/models/onnxruntime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,10 @@ struct OrtSession {

void SetEpDynamicOptions(_In_opt_ const char* const* keys, const char* const* values, size_t kv_len);

#if ORT_API_VERSION >= 27
Comment thread
qjia7 marked this conversation as resolved.
void ReleaseCapturedGraph(int graph_annotation_id); ///< Wraps OrtApi::SessionReleaseCapturedGraph (ORT 1.27+)
#endif

static void operator delete(void* p) { Ort::api->ReleaseSession(reinterpret_cast<OrtSession*>(p)); }
Ort::Abstract make_abstract;
};
Expand Down
6 changes: 6 additions & 0 deletions src/models/onnxruntime_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,12 @@ inline void OrtSession::SetEpDynamicOptions(const char* const* keys, const char*
Ort::ThrowOnError(Ort::api->SetEpDynamicOptions(this, keys, values, kv_len));
}

#if ORT_API_VERSION >= 27
inline void OrtSession::ReleaseCapturedGraph(int graph_annotation_id) {
Ort::ThrowOnError(Ort::api->SessionReleaseCapturedGraph(this, graph_annotation_id));
}
Comment thread
qjia7 marked this conversation as resolved.
#endif

inline std::string OrtModelMetadata::GetProducerName() const {
Ort::StringAllocator string_allocator;
Ort::ThrowOnError(Ort::api->ModelMetadataGetProducerName(this, &string_allocator, &string_allocator.out));
Expand Down
2 changes: 1 addition & 1 deletion test/python/cpu/ort/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
onnxruntime==1.26.0
onnxruntime==1.27.0
5 changes: 4 additions & 1 deletion test/python/cuda/ort/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
onnxruntime-gpu==1.26.0
# onnxruntime-gpu 1.27.0 links libcudart.so.13 (CUDA 13). CI runners
# currently ship CUDA 12.x, so the wheel fails to import. Hold the python
# pin at 1.26.0 until the CI image migrates to CUDA 13.
onnxruntime-gpu==1.26.0
Loading