Skip to content

[AMD] Add sd15 support for VitisAI.#2359

Open
liujij wants to merge 19 commits intomicrosoft:mainfrom
liujij:feat-sd-models
Open

[AMD] Add sd15 support for VitisAI.#2359
liujij wants to merge 19 commits intomicrosoft:mainfrom
liujij:feat-sd-models

Conversation

@liujij
Copy link
Copy Markdown

@liujij liujij commented Mar 17, 2026

Describe your changes

This PR adds optimized Stable Diffusion model generation support for the Vitis AI Execution Provider.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

(Optional) Issue link

Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Fixed
@liujij
Copy link
Copy Markdown
Author

liujij commented Mar 26, 2026

@microsoft-github-policy-service agree company="AMD"

@liujij liujij changed the title [feat] add sd15 supported for NPU. [feat] add sd15 supported with VitisAI EP. Mar 26, 2026
@liujij liujij changed the title [feat] add sd15 supported with VitisAI EP. [feat] Add sd15 supported for vitisai. Mar 26, 2026
@liujij liujij changed the title [feat] Add sd15 supported for vitisai. [feat] Add sd15 supported for VitisAI. Mar 26, 2026
@liujij liujij changed the title [feat] Add sd15 supported for VitisAI. [feat] Add sd15 support for VitisAI. Mar 26, 2026
@liujij liujij changed the title [feat] Add sd15 support for VitisAI. [AMD] Add sd15 support for VitisAI. Mar 27, 2026
@xiaoyu-work
Copy link
Copy Markdown
Collaborator

@liujij can you please add unit tests for this pass, and fix the format issue? We are planning to release new Olive version this Friday and this PR will be included in the new release

Copilot AI review requested due to automatic review settings May 7, 2026 02:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Olive ONNX pass to generate AMD Vitis AI NPU-ready Stable Diffusion (SD 1.5) submodels from an ONNX input, and registers the pass in the package pass registry so it can be invoked via standard Olive workflows.

Changes:

  • Introduce VitisGenerateModelSD pass to run Vitis model_generate in sd mode and produce an ONNX artifact for downstream passes.
  • Add config parameters for model_type and optional resolutions.
  • Register VitisGenerateModelSD in olive_config.json so Olive can import and run it.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py New Vitis AI pass that wraps model_generate for SD submodel generation and normalizes output to model.onnx.
olive/olive_config.json Registers the new pass module in Olive’s built-in pass catalog.

Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Outdated
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Outdated
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Outdated
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py Outdated
Comment thread olive/passes/onnx/vitis_ai/vitis_generate_model_sd.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@VishalX
Copy link
Copy Markdown
Contributor

VishalX commented May 7, 2026

@devang-ml can you please review this?

@liujij
Copy link
Copy Markdown
Author

liujij commented May 8, 2026

Hi @devang-ml / @xieofxie / @xiaoyu-work , This PR adds optimized Stable Diffusion model generation support for the Vitis AI Execution Provider. I’ve resolved all format issue and added unit tests. Could you please help review this PR? If everything looks good, could you kindly help merge it? Thanks!

devang-ml
devang-ml previously approved these changes May 8, 2026
@@ -0,0 +1,252 @@
# -------------------------------------------------------------------------
saved_mods = {k: sys.modules.pop(k) for k in list(sys.modules) if k == "model_generate" or k.startswith("model_generate.")}
real_import = builtins.__import__

def guarded_import(name, globals=None, locals=None, fromlist=(), level=0):
saved_mods = {k: sys.modules.pop(k) for k in list(sys.modules) if k == "model_generate" or k.startswith("model_generate.")}
real_import = builtins.__import__

def guarded_import(name, globals=None, locals=None, fromlist=(), level=0):
saved_mods = {k: sys.modules.pop(k) for k in list(sys.modules) if k == "model_generate" or k.startswith("model_generate.")}
real_import = builtins.__import__

def guarded_import(name, globals=None, locals=None, fromlist=(), level=0):
saved_mods = {k: sys.modules.pop(k) for k in list(sys.modules) if k == "model_generate" or k.startswith("model_generate.")}
real_import = builtins.__import__

def guarded_import(name, globals=None, locals=None, fromlist=(), level=0):
(tmp_path / "b.onnx").write_bytes(b"y")
p = _make_pass()
h = SimpleNamespace(model_path=str(tmp_path))
with pytest.raises(ValueError, match="Multiple .onnx model files found"):
p = _make_pass()
h = SimpleNamespace(model_path=str(tmp_path))
with pytest.raises(ValueError, match="Multiple .onnx model files found"):
p._resolve_onnx_input_path(h)
def test_resolve_onnx_input_path_dir_no_onnx_raises(tmp_path):
p = _make_pass()
h = SimpleNamespace(model_path=str(tmp_path))
with pytest.raises(FileNotFoundError, match="No .onnx file found"):
p = _make_pass()
h = SimpleNamespace(model_path=str(tmp_path))
with pytest.raises(FileNotFoundError, match="No .onnx file found"):
p._resolve_onnx_input_path(h)
missing = tmp_path / "nope"
h = SimpleNamespace(model_path=str(missing))
with pytest.raises(FileNotFoundError, match="Model path does not exist"):
p._resolve_onnx_input_path(h)
@liujij liujij requested a review from devang-ml May 9, 2026 06:25
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.

6 participants