Skip to content

feat(hipep): add hipep-backend selected via profile=llm#23

Open
zz002 wants to merge 5 commits into
onnxruntime:mainfrom
zz002:feat/hipep-backend
Open

feat(hipep): add hipep-backend selected via profile=llm#23
zz002 wants to merge 5 commits into
onnxruntime:mainfrom
zz002:feat/hipep-backend

Conversation

@zz002

@zz002 zz002 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Add a hipep backend to the AMD GPU umbrella EP, selected via the profile=llm provider option.

  • src/hipep/ builds hipep-backend.dll, a thin OrtEpFactory shim (parallel to directml/migraphx) that loads the HIP EP DLL (hipep.dll), forwards CreateEpFactories, and returns its factory unchanged. Single factory only.
  • The umbrella loads hipep-backend alongside the other backends and routes profile=llm to it, passing no device (matching the DirectML/MIGraphX backends).

related OGA PR: microsoft/onnxruntime-genai#2194

zz002 and others added 3 commits June 16, 2026 21:28
Add the hipep backend to the AMD GPU umbrella EP: load the pre-built
hipep-backend plugin EP DLL as a third backend (alongside DirectML and
MIGraphX) and route to it when the user selects profile=llm.

- Profile::Llm parses "llm" / "3"; gpu_ep.cc routes profile=llm to
  ProviderFactory::CreateHipepBackend.
- ProviderFactory loads hipep-backend and forwards CreateEp / ReleaseEp to it,
  mirroring the DirectML/MIGraphX backend pattern. hipep is a pre-built plugin
  EP DLL loaded at runtime, so no ROCm SDK is required to build amdgpu-ep.
- CreateEp forwards the ORT-selected hardware device(s) + ep_metadata to the
  backend's CreateEp. Unlike DirectML/MIGraphX, hipep's CreateEp rejects
  num_devices == 0, so the umbrella must pass the selected device.

DirectML and MIGraphX paths are unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ctML/MIGraphX

The hipep backend no longer requires the umbrella to forward the ORT-selected
device: its CreateEp now tolerates a null device array / num_devices == 0
(ROCm/MorphiZen#234). Drop the devices/ep_metadata parameters from
ProviderFactory::CreateHipepBackend and the ExecutionProvider constructor and
pass nullptr/nullptr/0, so the hipep path matches the DirectML and MIGraphX
backends and the EP constructor keeps the same signature as the sibling EPs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add src/hipep parallel to directml/migraphx. It builds hipep-backend.dll, a thin pass-through OrtEpFactory that loads hipep.dll, forwards CreateEpFactories, and returns the HIP EP's factory unchanged so the AMD GPU umbrella forwards to it directly. ReleaseEpFactory forwards to the HIP EP and unloads the DLL. Only a single factory is supported.

Wired via a new USE_HIPEP option (forced on by USE_AMDGPU) and add_subdirectory(hipep).

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant

CLAassistant commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

CreateEpFactories can be invoked more than once (e.g. a real session plus the device-init session in OGA). The previous single-handle logic reloaded the DLL on each call (leaking the earlier handle) and unloaded it on the first ReleaseEpFactory while later factories were still live. Load on the first factory and unload only after the last is released; roll back the refcount if the load fails so a retry re-attempts it.

Co-authored-by: Cursor <cursoragent@cursor.com>

Co-authored-by: Cursor <cursoragent@cursor.com>
@apwojcik apwojcik requested review from KenLagos and apwojcik June 18, 2026 08:41

@apwojcik apwojcik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change hipep* to hipdnn* in the source directory name and the backend name as well? The backend name should not reveal that it is a standalone execution provider.

Comment thread src/amdgpu/gpu_factory.cc
namespace {
constexpr auto directmlBackend{LIBRARY_PREFIX ORT_TSTR("directml-backend") LIBRARY_SUFFIX};
constexpr auto migraphxBackend{LIBRARY_PREFIX ORT_TSTR("migraphx-backend") LIBRARY_SUFFIX};
constexpr auto hipepBackend{LIBRARY_PREFIX ORT_TSTR("hipep-backend") LIBRARY_SUFFIX};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, please use hipdnnBackend instead of hipepBackend

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you may use hipBackend if it has nothing to do with DNN or anything else, but please do not include ep in backend names.

Comment thread src/hipep/CMakeLists.txt
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

add_library(hipep-ep MODULE hipep_factory.cc)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use hipdnn-ep or hip-ep for the target name, not hipep.

Comment thread CMakeLists.txt
option(USE_AMDGPU "Build the AMD GPU Execution Provider" OFF)
option(USE_DML "Build the DirectML Execution Provider" OFF)
option(USE_MIGRAPHX "Build the MIGraphX Execution Provider" OFF)
option(USE_HIPEP "Build the HIP (morphizen) backend shim" OFF)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please USE_HIPDNN or USE_HIP

Comment thread CMakeLists.txt
if(USE_AMDGPU)
set(CACHE{USE_DML} TYPE BOOL FORCE VALUE ON)
set(CACHE{USE_MIGRAPHX} TYPE BOOL FORCE VALUE ON)
set(CACHE{USE_HIPEP} TYPE BOOL FORCE VALUE ON)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not include it in AMDGPU EP automatically yet. The HIPDNN backend has to be built on demand for now. Please reflect that in the source code. One has to be able to build AMDGPU EP without the HIP backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants