Repository navigation
fix(onnx-to-hip): resolve Neg in host slice extents - #1332
Merged
Merged
Conversation
SliceToHip sized a Slice whose start is -Shape(x)[k] by the full data dim, because resolveHostIndex did not walk through Neg. Qwen3.8's EngramGate padding slices attention_mask with start = -Shape(input_ids)[1]; at decode the inflated extent broadcast the hidden state from [B,1,...] to [B,total,...].
zz002
requested review from
CaymanYang,
amd-bqiao,
amd-mingw,
asparkhi,
edelaye,
fhanuman,
qianglin-amd,
sambanerxilinxamd and
wcy123
as code owners
October 26, 2026 11:03
|
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: 7915 - Commit: |
Binary sizesBaseline: run 40294400486 -
MorphiZen EP Performance Results
EPContext Export Performance
EPContext Import Performance
OGA Benchmark Results
OGA Wheel Smoke (Python benchmark_e2e.py)
VLM Benchmark Results
Run: 7915 - Commit: |
amd-mingw
approved these changes
Oct 27, 2026
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.
Summary
SliceToHipnow computes the true extent of a Slice whose start is-Shape(x)[k], instead of falling back to the data dim upper bound.Related issue or design
None
Why
resolveHostIndexdid not walk throughNeg, so such a start failed to resolve and the extent fell back to the data dim. A graph that keeps the last S columns of the attention mask,Slice(attention_mask, -Shape(input_ids)[1], INT64_MAX), and gates a[B, S, ...]tensor with it viaWherethen gets a[B, total]mask at decode;Wherebroadcasts the[B, 1, ...]operand to[B, total, ...]and every downstream op sees the wrong sequence length. Prefill (S == total) hides it.What
resolveHostIndexresolvesonnx.Negandhip.negas0 - x. Both spellings are accepted for the same reason as Sub/Add/Mul: the greedy driver does not order this pattern against the producer rewrites.Test plan
test_slice.mlirtests 17 (ONNX spelling) and 18 (hip.negspelling); full LIT suite passestest_shape_ops.py::TestSlice::test_slice_mask_tail_by_sequence_lengthfor (S, total) = (1, 20), (3, 12), (7, 7) matches CPU EP exactly; the two decode cases fail without the fixNotes for reviewers
None