Skip to content

fix non-standard literals causing failures in mlir modules - #5070

Merged
causten merged 5 commits into
developfrom
fix-mlir-nonstandard-literal
Jul 17, 2026
Merged

causten merged 5 commits into
developfrom
fix-mlir-nonstandard-literal

Conversation

@shivadbhavsar

Copy link
Copy Markdown
Contributor

Motivation

Found some while refactoring torch builders where non-standard literals are causing compile errors

Technical Details

Add similar standardization used in other lowering passes

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the GPU prepare_mlir lowering pass to normalize non-standard-strided literal instructions into standard (contiguous) literals so MLIR compilation doesn’t fail on transposed/strided constants.

Changes:

  • Add a matcher in gpu::prepare_mlir to rewrite non-standard, non-broadcast literals into standard literals via a contiguous const-fold.
  • Add a new GPU unit test covering normalization behavior and “unchanged” cases for already-standard and broadcast literals.

Reviewed changes

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

File Description
src/targets/gpu/prepare_mlir.cpp Adds a matcher to normalize non-standard literals prior to MLIR lowering.
test/gpu/prepare_mlir.cpp Adds GPU tests validating literal normalization/unchanged behavior.

Comment thread test/gpu/prepare_mlir.cpp
Comment thread test/gpu/prepare_mlir.cpp Outdated
Comment thread src/targets/gpu/prepare_mlir.cpp
@pfultz2

pfultz2 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Can you add a test to test/mlir.cpp as well?

@shivadbhavsar shivadbhavsar added bugfix Fixes a bug found in the code. simple small or simple changes labels Jul 15, 2026
@gh-app-migraphx-bot-pr-write

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

Copy link
Copy Markdown
Test Batch New Rate (b7d572) Old Rate (1a5bb6) Diff Status
torchvision-resnet50 64 3,265.02 3,265.81 -0.02%
torchvision-resnet50_fp16 64 7,547.45 7,548.56 -0.01%
torchvision-densenet121 32 2,483.47 2,481.85 0.07%
torchvision-densenet121_fp16 32 5,002.65 4,975.40 0.55%
torchvision-inceptionv3 32 2,059.41 2,060.05 -0.03%
torchvision-inceptionv3_fp16 32 4,411.64 4,414.40 -0.06%
cadene-inceptionv4 16 820.95 584.00 40.58% 🔆
cadene-resnext64x4 16 615.04 782.84 -21.43% 🔴
slim-mobilenet 64 8,339.29 7,190.62 15.97% 🔆
slim-nasnetalarge 64 226.86 222.84 1.80%
slim-resnet50v2 64 2,290.51 2,017.65 13.52% 🔆
bert-mrpc-onnx 8 1,169.34 1,168.85 0.04%
bert-mrpc-tf 1 487.84 487.56 0.06%
pytorch-examples-wlang-gru 1 282.26 477.33 -40.87% 🔴
pytorch-examples-wlang-lstm 1 388.45 387.83 0.16%
torchvision-resnet50_1 1 584.53 1,038.23 -43.70% 🔴
cadene-dpn92_1 1 444.93 449.51 -1.02%
cadene-resnext101_1 1 366.13 365.36 0.21%
onnx-taau-downsample 1 455.44 844.73 -46.08% 🔴
dlrm-criteoterabyte 1 32.41 17.44 85.83% 🔆
dlrm-criteoterabyte_fp16 1 33.69 31.21 7.95% 🔆
agentmodel 1 6,438.98 5,880.42 9.50% 🔆
unet_fp16 2 15.29 52.15 -70.68% 🔴
resnet50v1_fp16 1 1,451.72 1,385.99 4.74%
resnet50v1_int8 1 1,886.40 1,657.40 13.82% 🔆
bert_base_cased_fp16 64 1,084.74 1,022.83 6.05% 🔆
bert_large_uncased_fp16 32 124.28 339.30 -63.37% 🔴
bert_large_fp16 1 32.09 205.64 -84.40% 🔴
distilgpt2_fp16 16 438.66 2,086.12 -78.97% 🔴
yolov5s 1 76.09 560.85 -86.43% 🔴
tinyllama 1 19.71 45.80 -56.97% 🔴
vicuna-fastchat 1 44.22 44.03 0.45%
whisper-tiny-encoder 1 412.86 328.75 25.58% 🔆
whisper-tiny-decoder 1 408.06 214.20 90.50% 🔆
llama2_7b 1 2.56 14.70 -82.59% 🔴
qwen1.5-7b 1 3.11 23.49 -86.74% 🔴
phi3-3.8b 1 26.66 26.78 -0.41%
llama3-8b 1 21.75 21.70 0.21%
whisper-large-encoder 1 7.75 8.77 -11.60% 🔴
whisper-large-decoder 1 15.49 109.89 -85.90% 🔴
mistral-7b 1 12.69 23.65 -46.36% 🔴
FLUX.1-schnell 1 750.99 172.94 334.26% 🔆

Regressions detected 🔴

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

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

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx PASSED: MIGraphX meets tolerance
bert-mrpc-tf PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-gru PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-lstm PASSED: MIGraphX meets tolerance
dlrm-criteoterabyte PASSED: MIGraphX meets tolerance
agentmodel PASSED: MIGraphX meets tolerance
unet PASSED: MIGraphX meets tolerance
resnet50v1 PASSED: MIGraphX meets tolerance
bert_base_cased_fp16 PASSED: MIGraphX meets tolerance
bert_large_uncased_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
bert_large PASSED: MIGraphX meets tolerance
yolov5s PASSED: MIGraphX meets tolerance
tinyllama PASSED: MIGraphX meets tolerance
vicuna-fastchat PASSED: MIGraphX meets tolerance
whisper-tiny-encoder PASSED: MIGraphX meets tolerance
whisper-tiny-decoder PASSED: MIGraphX meets tolerance
distilgpt2_fp16 PASSED: MIGraphX meets tolerance
llama2_7b PASSED: MIGraphX meets tolerance
qwen1.5-7b PASSED: MIGraphX meets tolerance
phi3-3.8b PASSED: MIGraphX meets tolerance
llama3-8b PASSED: MIGraphX meets tolerance
whisper-large-encoder PASSED: MIGraphX meets tolerance
whisper-large-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

@CharlieL7 CharlieL7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@causten
causten merged commit b64099e into develop Jul 17, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug found in the code. simple small or simple changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants