Skip to content

Loop subgraph support - #5103

Draft
weizhu12-amd wants to merge 2 commits into
developfrom
loop_support
Draft

Loop subgraph support#5103
weizhu12-amd wants to merge 2 commits into
developfrom
loop_support

Conversation

@weizhu12-amd

Copy link
Copy Markdown
Collaborator

Motivation

MIGraphX cannot run the YOLOv3 model because the model contains loop subgraphs. This PR resolves the parsing and compiling issues associated with this subgraph.

Technical Details

1, Handle duplicate loop subgraphs during parsing
YOLOv3 may contain duplicate loop subgraphs, causing a duplicate-key insertion into the subgraph map and resulting in a crash. Preserve the original parent subgraph during parsing and restore it after parsing is complete.

2, Insert copy and allocation instructions for identity IR
Loop operations are lowered to identity IR. Copy and allocation instructions need to be inserted between consecutive identity instructions. However, the current implementation skips this.
This change ensures that the required copy and allocation instructions are generated correctly for identity IR.

Changelog Category

Add a CHANGELOG.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

Follow the LLVM AI Tool Use Policy for contributions using AI.

YOLOv3 may contain duplicate loop subgraphs, causing a duplicate-key
insertion into the subgraph map and resulting in a crash.
Preserve the original parent subgraph during parsing and restore it
after parsing is complete.
@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jul 30, 2026

Copy link
Copy Markdown
Test Batch New Rate (4cca90) Old Rate (0c63af) Diff Status
torchvision-resnet50 64 3,266.36 3,266.06 0.01%
torchvision-resnet50_fp16 64 7,545.37 7,546.56 -0.02%
torchvision-densenet121 32 2,484.11 2,482.18 0.08%
torchvision-densenet121_fp16 32 5,010.03 4,976.34 0.68%
torchvision-inceptionv3 32 2,060.58 2,057.16 0.17%
torchvision-inceptionv3_fp16 32 4,416.28 4,415.87 0.01%
cadene-inceptionv4 16 nan 818.77 nan
cadene-resnext64x4 16 783.27 783.71 -0.06%
slim-mobilenet 64 8,388.23 8,356.38 0.38%
slim-nasnetalarge 64 nan 229.42 nan
slim-resnet50v2 64 3,180.60 3,185.54 -0.16%
bert-mrpc-onnx 8 1,169.69 1,167.46 0.19%
bert-mrpc-tf 1 496.02 486.41 1.97%
pytorch-examples-wlang-gru 1 476.54 480.59 -0.84%
pytorch-examples-wlang-lstm 1 378.71 390.19 -2.94%
torchvision-resnet50_1 1 1,040.89 1,037.04 0.37%
cadene-dpn92_1 1 444.89 475.84 -6.50% 🔴
cadene-resnext101_1 1 365.14 365.49 -0.09%
onnx-taau-downsample 1 842.01 843.97 -0.23%
dlrm-criteoterabyte 1 nan 32.42 nan
dlrm-criteoterabyte_fp16 1 nan 52.07 nan
agentmodel 1 9,344.31 9,645.99 -3.13%
unet_fp16 2 58.75 58.92 -0.28%
resnet50v1_fp16 1 1,372.04 1,412.17 -2.84%
resnet50v1_int8 1 nan 1,602.24 nan
bert_base_cased_fp16 64 1,097.40 1,098.36 -0.09%
bert_large_uncased_fp16 32 345.69 344.75 0.27%
bert_large_fp16 1 205.21 204.70 0.25%
distilgpt2_fp16 16 2,091.74 2,090.27 0.07%
yolov5s 1 nan 560.47 nan
tinyllama 1 nan 45.79 nan
vicuna-fastchat 1 44.15 44.12 0.07%
whisper-tiny-encoder 1 412.46 412.35 0.03%
whisper-tiny-decoder 1 409.09 413.51 -1.07%
llama2_7b 1 nan 20.84 nan
qwen1.5-7b 1 nan 23.52 nan
phi3-3.8b 1 nan 26.73 nan
llama3-8b 1 nan 21.66 nan
whisper-large-encoder 1 10.18 10.18 -0.07%
whisper-large-decoder 1 103.69 106.43 -2.58%
mistral-7b 1 nan 23.62 nan
FLUX.1-schnell 1 774.45 756.55 2.37%

Regressions detected 🔴

@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jul 30, 2026

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
bert-mrpc-tf ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
pytorch-examples-wlang-gru ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
pytorch-examples-wlang-lstm ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
dlrm-criteoterabyte ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
agentmodel ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
unet ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
resnet50v1 ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
bert_base_cased_fp16 ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
bert_large_uncased_fp16 ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
bert_large ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
yolov5s ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
tinyllama ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
vicuna-fastchat ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
whisper-tiny-encoder ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
whisper-tiny-decoder ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
distilgpt2_fp16 ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
llama2_7b ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
qwen1.5-7b ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
phi3-3.8b ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
llama3-8b ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
whisper-large-encoder ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
whisper-large-decoder ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
mistral-7b ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'
FLUX.1-schnell ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 27, in
import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5103      +/-   ##
===========================================
+ Coverage    92.90%   93.26%   +0.36%     
===========================================
  Files          603      623      +20     
  Lines        32526    32969     +443     
===========================================
+ Hits         30217    30746     +529     
+ Misses        2309     2223      -86     
Files with missing lines Coverage Δ
src/onnx/onnx_parser.cpp 88.31% <ø> (-0.03%) ⬇️
src/replace_allocate.cpp 98.89% <100.00%> (-1.11%) ⬇️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Loop operation is converted to identity IR. Copy and allocation
instructions need to be inserted between consecutive identity instructions.
However, the current implementation skips this.

This change ensures that the required copy and allocation instructions
are generated correctly for identity IR.
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