Skip to content

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

Open
zz002 wants to merge 5 commits into
mainfrom
build/decouple-dml-migraphx
Open

build: make DirectML/MIGraphX optional for local hipep testing [do not merge]#2
zz002 wants to merge 5 commits into
mainfrom
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
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
@zz002
zz002 force-pushed the feat/hipep-backend branch from 0c962d8 to 577feb0 Compare July 8, 2026 01:43
@zz002
zz002 force-pushed the build/decouple-dml-migraphx branch 2 times, most recently from af39f35 to b9460ee Compare July 15, 2026 06:37
@zz002
zz002 changed the base branch from feat/hipep-backend to main July 15, 2026 06:38
aditya-dl and others added 4 commits July 15, 2026 13:54
…ntime#44)

* amdgpu EP: load hip backend only when present; rename profile llm->hipep

Two related fixes in the amdgpu (umbrella) EP hip-backend handling:

1. The hip (morphizen) backend is optional (built only with USE_HIP; a standard USE_AMDGPU build does not produce hip-backend.dll), but ProviderFactory loaded it unconditionally, so CreateEpFactories threw and the whole umbrella EP failed to register (EP_FAIL) even for directml/migraphx. Load it only when hip-backend.dll is present next to the module; a present-but-broken library still errors. Null-guard CreateHipBackend so selecting the hip profile without the backend fails cleanly.

2. Select the hip backend via profile=hipep (Profile::HipEp) instead of profile=llm, for consistency with the other backends selected by backend name (migraphx, directml). The numeric alias 5 is retained.

* amdgpu EP: rename profile hipep -> hip

Address review: drop "Ep" from the profile name so the backend is not exposed
as an execution provider. Profile::HipEp -> Profile::Hip, string "hipep" -> "hip"
(numeric alias 5 retained).

---------

Co-authored-by: tperry-amd <thomas.perry@amd.com>
…ime#45)

ComputeOutputIndex parsed the integer after the #output_ prefix assuming a plain digit, but MIGraphX names outputs #output_0 for index<10 and #output_:00056 (a colon then a zero-padded number) for index>=10 (see AMDMIGraphX param_utils.cpp param_name()). For the padded form the parse failed, the output parameter was never bound, and MIGraphX threw Parameter not found during hipGraph capture -- which happens on any model with >=10 outputs (all real LLM decode graphs: 1 logits + N KV cache). Skip a leading colon so both forms parse.

Co-authored-by: tperry-amd <thomas.perry@amd.com>
Co-authored-by: tperry-amd <thomas.perry@amd.com>
…ree (onnxruntime#46)

ProviderFactory::CreateAllocator cached a single Allocator and returned it for
both the default and host-accessible memory infos, so its Info() reported only
the default device. ORT registers one shared allocator per memory info and
unregisters them by that device, so the host-accessible one was never matched;
it lingered until ~Environment, after the factory had been freed, and its
deleter then called ReleaseAllocator on the freed factory (use-after-free at
teardown).

Return one Allocator per device memory type, each constructed with its own
memory_info so Info() reports the correct device and both can be unregistered
before the factory is destroyed. Both wrappers still delegate to the
currently-selected backend, so backend virtualization / dynamic switching is
unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Aditya Lohia <adityaslohia29@gmail.com>
@zz002
zz002 force-pushed the build/decouple-dml-migraphx branch from b9460ee to a1318ed Compare July 16, 2026 03:42
…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>
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