fix(matmul-lowering): use extractMemRefDataPtr for offset-correct pointers - #626
Draft
kirankumarmatam-amd wants to merge 2 commits into
Draft
fix(matmul-lowering): use extractMemRefDataPtr for offset-correct pointers#626kirankumarmatam-amd wants to merge 2 commits into
kirankumarmatam-amd wants to merge 2 commits into
Conversation
…nters Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for opening a PR! This project follows LLVM's incremental-development and AI-tool-use Before requesting review, please check that:
Reviewers are assigned through |
L2 Accuracy Results (EP vs CPU)
Threshold: 0.01 | Run: 3531 - Commit: |
MorphiZen EP Performance Results
EPContext Export Performance
EPContext Import Performance
OGA Benchmark Results
OGA Wheel Smoke (Python benchmark_e2e.py)
Run: 3531 - Commit: |
Replace the verbose comment with a concise invariant statement, drop the "(Bug 4 in gnpu-onnx-flow)" reference (project-internal, opaque to hip-ep reviewers), and remove the noise annotation on the shape variable declarations. 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.
Problem
MatmulOpLoweringusedextractContiguousMemRefPtrwhich returns onlyalignedPtrfrom the memref descriptor, ignoring theoffsetfield.When
onnx.Splitproduces Q/K/V slices viamemref.subview, each slicecarries a non-zero offset into the parent buffer.
extractContiguousMemRefPtrreturned the parent buffer's base address for all three, so Q and V MatMuls
silently read K's data instead of their own — reducing end-to-end model
accuracy to ~0.36 cosine on Qwen 7B VLM (gfx1151).
Fix
Switch A, B, and output to
extractMemRefDataPtr, which computesalignedPtr + GEP(offset)— the GEP advances byoffsetelements,correctly accounting for element size:
Testing
Verified on gfx1151 (Strix Halo, Windows D3D12 HMM): cosine similarity
for Qwen 7B VLM restored to ~1.0 after this fix.