Add D3D12 agility SDK dependency to fix crashes on long prompts - #612
Merged
Patrice Vignola (PatriceVignola) merged 3 commits intoJun 18, 2024
Merged
Conversation
Baiju Meswani (baijumeswani)
approved these changes
Jun 17, 2024
…into user/pavignol/add-d3d12-agility-sdk
Patrice Vignola (PatriceVignola)
deleted the
user/pavignol/add-d3d12-agility-sdk
branch
June 18, 2024 09:29
Baiju Meswani (baijumeswani)
pushed a commit
that referenced
this pull request
Jun 18, 2024
kunal-vaishnavi
pushed a commit
that referenced
this pull request
Jul 13, 2026
…tory cannot create a device (#2280) ### Problem `CreateDmlObjects` (`src/dml/dml_helpers.cpp`) tries the Agility SDK device factory first and **throws on any `CreateDevice` failure** instead of reaching the existing system-runtime fallback branch: ```cpp if (SUCCEEDED(D3D12GetInterface(...)) && SUCCEEDED(sdk_config->CreateDeviceFactory(614, module_path, ...))) { THROW_IF_FAILED(d3d12_factory->CreateDevice(...)); // throws — fallback below is unreachable } else { ... THROW_IF_FAILED(D3D12CreateDevice(...)); } ``` A known failure is `DXGI_ERROR_ALREADY_EXISTS` (0x887A0036): the process already holds a D3D12 device created with the system runtime — e.g. the XAML/WinUI compositor in a packaged app creates one at `Window.Activate()` — and devices from different D3D12 runtimes cannot coexist in one process. The plain `D3D12CreateDevice` branch handles exactly this situation, but is unreachable. Whether this bites is **OS-dependent**: if the in-box D3D12 is older than the requested SDK version (614), `CreateDeviceFactory` itself fails and the fallback runs — an OS update silently flips the branch and breaks `OgaCreateModel` in XAML hosts. ### Fix Treat a factory `CreateDevice` failure like a factory creation failure: log a warning with the HRESULT and fall back to `D3D12CreateDevice`. No regression for #612 (which introduced the Agility path): the new fallback only runs when the in-box runtime is >= the requested SDK version — i.e. the system runtime already contains the fixes the Agility dependency was added for. Related: #1054 (the pre-existing fallback branch for factory-creation failure). ### Validation (real hardware) Xbox Series S, Dev Mode UWP (OS 26100), ORT GenAI 0.13.2 DirectML + ORT 1.24.4, SmolLM2-360M INT4 (DML model built with the model builder): | Scenario | vanilla DLL | patched DLL | |---|---|---| | XAML app + DML EP | `887A0036` at `OgaCreateModel` (reproduced 3x) | loads in 886 ms, weights resident on GPU (315 MB), full decode (739 tokens) | | XAML app + CPU EP | works | works (67.2 tok/s, unchanged) | | Headless (no compositor) + DML EP | works via Agility path | works via Agility path | --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.