Skip to content

build: make DirectML/MIGraphX optional for local hipep testing [do not merge]#2

Open
zz002 wants to merge 6 commits into
feat/hipep-backendfrom
build/decouple-dml-migraphx
Open

build: make DirectML/MIGraphX optional for local hipep testing [do not merge]#2
zz002 wants to merge 6 commits into
feat/hipep-backendfrom
build/decouple-dml-migraphx

Conversation

@zz002

@zz002 zz002 commented Jun 16, 2026

Copy link
Copy Markdown
Owner

⚠️ Do not merge - local build/test scaffolding

Stacked on #1. Makes DirectML/MIGraphX optional so the hipep backend can be built and run on a machine without a MIGraphX SDK. Kept as a separate, non-merging PR purely for local reproduction/testing of the profile=llm path. (Review the actual feature in #1.)

Why

amdgpu-ep hard-requires both DirectML and MIGraphX: USE_AMDGPU force-enables USE_DML / USE_MIGRAPHX, migraphx-ep runs find_package(migraphx REQUIRED), and ProviderFactory unconditionally LoadDynamicLibrarys both backend DLLs. So on a box without a MIGraphX SDK the umbrella neither configures, builds, nor loads.

What

  • USE_AMDGPU forces USE_DML / USE_MIGRAPHX OFF.
  • amdgpu-ep guards the migraphx-ep / directml-ep include directories behind USE_MIGRAPHX / USE_DML and passes USE_DML / USE_MIGRAPHX compile definitions.
  • gpu_factory.cc / gpu_ep.cc guard the DirectML and MIGraphX backend loads and profile branches behind #ifdef USE_DML / USE_MIGRAPHX. The hipep backend stays unconditional.

Local repro

build.bat --config Release --use_amdgpu --onnxrt_home <ort> ^
  --cmake_generator Ninja --update --build --parallel --compile_no_warning_as_error

DirectML and MIGraphX are off; hipep is built in. Place hipep-backend.dll (the hipdnn-ep / MorphiZen plugin EP DLL) next to amdgpu-ep, then run a model with provider option profile=llm. Used together with the hipdnn-ep factory fix ROCm/MorphiZen#234 this executes on gfx1151 via hipBLASLt.

@zz002 zz002 force-pushed the feat/rocm-llm-backend branch 2 times, most recently from ff40ecc to 01e7cb3 Compare June 17, 2026 01:39
@zz002 zz002 force-pushed the build/decouple-dml-migraphx branch from 1bd9c00 to 961411a Compare June 17, 2026 01:44
@zz002 zz002 force-pushed the feat/rocm-llm-backend branch 3 times, most recently from 2f32dad to e78f4b1 Compare June 17, 2026 02:25
@zz002 zz002 force-pushed the build/decouple-dml-migraphx branch from 961411a to 25d588d Compare June 17, 2026 02:32
@zz002 zz002 changed the title build: make DirectML/MIGraphX optional for local ROCm testing [do not merge] build: make DirectML/MIGraphX optional for local hipep testing [do not merge] Jun 17, 2026
@zz002 zz002 force-pushed the build/decouple-dml-migraphx branch 2 times, most recently from 55d9c6d to 19dc45a Compare June 17, 2026 10:21
zz002 and others added 5 commits June 24, 2026 05:35
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>
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>
Address PR review: the backend name must not contain "ep". Rename the
umbrella backend shim from hipep to hip (src/hip/, hip-ep target,
hip-backend.dll, USE_HIP option, and all C++ identifiers). The shim now
loads the HIP EP DLL as hipgpu (hipgpu.dll / libhipgpu.so), to be renamed
on the onnx-hipdnn-ep side in a follow-up.

Co-authored-by: Cursor <cursoragent@cursor.com>
@zz002 zz002 force-pushed the build/decouple-dml-migraphx branch from 19dc45a to 91c4fad Compare June 24, 2026 10:55
@zz002 zz002 force-pushed the feat/rocm-llm-backend branch from 4e9aa28 to 71c00fb Compare June 24, 2026 10:55
@zz002 zz002 force-pushed the build/decouple-dml-migraphx branch from 91c4fad to daa120c Compare June 24, 2026 10:59
@zz002 zz002 changed the base branch from feat/rocm-llm-backend to feat/hipep-backend June 24, 2026 11:01
…aphX SDK [do not merge]

NOT FOR MERGE - local build/test scaffolding, stacked on the hipep backend PR.

USE_AMDGPU normally force-enables USE_DML and USE_MIGRAPHX, migraphx-ep runs
find_package(migraphx REQUIRED), and ProviderFactory unconditionally loads the
DirectML and MIGraphX backend DLLs - so the umbrella can't build/run on a
machine without a MIGraphX SDK. Make DML/MIGraphX opt-in so the hipep
(profile=llm) path can be reproduced and tested locally:

- USE_AMDGPU forces USE_DML / USE_MIGRAPHX OFF.
- amdgpu-ep guards the migraphx-ep / directml-ep include directories behind
  USE_MIGRAPHX / USE_DML and passes USE_DML / USE_MIGRAPHX compile defs.
- gpu_factory.cc / gpu_ep.cc guard the DirectML and MIGraphX backend loads and
  profile branches behind #ifdef USE_DML / USE_MIGRAPHX (the hipep backend stays
  unconditional).

Local repro: build with --use_amdgpu, place hipep-backend.dll next to amdgpu-ep,
then run a model with provider option profile=llm.

Co-authored-by: Cursor <cursoragent@cursor.com>
@zz002 zz002 force-pushed the feat/hipep-backend branch from 0c962d8 to 577feb0 Compare July 8, 2026 01:43
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.

1 participant