[ET-VK][q8ta] Fix addmm arg indexing in QuantizedLinearMatch#17567
Open
SS-JIA wants to merge 6 commits intogh/SS-JIA/441/basefrom
Open
[ET-VK][q8ta] Fix addmm arg indexing in QuantizedLinearMatch#17567SS-JIA wants to merge 6 commits intogh/SS-JIA/441/basefrom
SS-JIA wants to merge 6 commits intogh/SS-JIA/441/basefrom
Conversation
QuantizedLinearMatch always used args[1] for the weight and args[0] for the input, which is correct for mm(input, weight) and linear(input, weight, bias?) but wrong for addmm(bias, input, weight) where the weight is at args[2] and the input is at args[1]. This was exposed by a torchao change (D69887498) that added Linear+BatchNorm fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously had none, causing them to decompose to addmm instead of mm in the edge dialect. The pattern matcher then read the input's per-tensor dequantize scale (a float literal) as if it were the weight's per-channel scale (a Node), causing an assertion failure. The fix determines the correct arg indices based on whether the anchor node is addmm. The bias handling at args[0] for addmm was already correct. Authored-by: Claude Differential Revision: [D93768640](https://our.internmc.facebook.com/intern/diff/D93768640/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17567
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 162 PendingAs of commit 42103c0 with merge base 9a58ce8 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Feb 19, 2026
This PR needs a
|
manuelcandales
approved these changes
Feb 19, 2026
added 5 commits
February 20, 2026 15:58
QuantizedLinearMatch always used args[1] for the weight and args[0] for the input, which is correct for mm(input, weight) and linear(input, weight, bias?) but wrong for addmm(bias, input, weight) where the weight is at args[2] and the input is at args[1]. This was exposed by a torchao change (D69887498) that added Linear+BatchNorm fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously had none, causing them to decompose to addmm instead of mm in the edge dialect. The pattern matcher then read the input's per-tensor dequantize scale (a float literal) as if it were the weight's per-channel scale (a Node), causing an assertion failure. The fix determines the correct arg indices based on whether the anchor node is addmm. The bias handling at args[0] for addmm was already correct. Authored-by: Claude Differential Revision: [D93768640](https://our.internmc.facebook.com/intern/diff/D93768640/) [ghstack-poisoned]
QuantizedLinearMatch always used args[1] for the weight and args[0] for the input, which is correct for mm(input, weight) and linear(input, weight, bias?) but wrong for addmm(bias, input, weight) where the weight is at args[2] and the input is at args[1]. This was exposed by a torchao change (D69887498) that added Linear+BatchNorm fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously had none, causing them to decompose to addmm instead of mm in the edge dialect. The pattern matcher then read the input's per-tensor dequantize scale (a float literal) as if it were the weight's per-channel scale (a Node), causing an assertion failure. The fix determines the correct arg indices based on whether the anchor node is addmm. The bias handling at args[0] for addmm was already correct. Authored-by: Claude Differential Revision: [D93768640](https://our.internmc.facebook.com/intern/diff/D93768640/) [ghstack-poisoned]
QuantizedLinearMatch always used args[1] for the weight and args[0] for the input, which is correct for mm(input, weight) and linear(input, weight, bias?) but wrong for addmm(bias, input, weight) where the weight is at args[2] and the input is at args[1]. This was exposed by a torchao change (D69887498) that added Linear+BatchNorm fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously had none, causing them to decompose to addmm instead of mm in the edge dialect. The pattern matcher then read the input's per-tensor dequantize scale (a float literal) as if it were the weight's per-channel scale (a Node), causing an assertion failure. The fix determines the correct arg indices based on whether the anchor node is addmm. The bias handling at args[0] for addmm was already correct. Authored-by: Claude Differential Revision: [D93768640](https://our.internmc.facebook.com/intern/diff/D93768640/) [ghstack-poisoned]
QuantizedLinearMatch always used args[1] for the weight and args[0] for the input, which is correct for mm(input, weight) and linear(input, weight, bias?) but wrong for addmm(bias, input, weight) where the weight is at args[2] and the input is at args[1]. This was exposed by a torchao change (D69887498) that added Linear+BatchNorm fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously had none, causing them to decompose to addmm instead of mm in the edge dialect. The pattern matcher then read the input's per-tensor dequantize scale (a float literal) as if it were the weight's per-channel scale (a Node), causing an assertion failure. The fix determines the correct arg indices based on whether the anchor node is addmm. The bias handling at args[0] for addmm was already correct. Authored-by: Claude Differential Revision: [D93768640](https://our.internmc.facebook.com/intern/diff/D93768640/) [ghstack-poisoned]
QuantizedLinearMatch always used args[1] for the weight and args[0] for the input, which is correct for mm(input, weight) and linear(input, weight, bias?) but wrong for addmm(bias, input, weight) where the weight is at args[2] and the input is at args[1]. This was exposed by a torchao change (D69887498) that added Linear+BatchNorm fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously had none, causing them to decompose to addmm instead of mm in the edge dialect. The pattern matcher then read the input's per-tensor dequantize scale (a float literal) as if it were the weight's per-channel scale (a Node), causing an assertion failure. The fix determines the correct arg indices based on whether the anchor node is addmm. The bias handling at args[0] for addmm was already correct. Authored-by: Claude Differential Revision: [D93768640](https://our.internmc.facebook.com/intern/diff/D93768640/) [ghstack-poisoned]
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.
Stack from ghstack (oldest at bottom):
QuantizedLinearMatch always used args[1] for the weight and args[0] for the
input, which is correct for mm(input, weight) and linear(input, weight, bias?)
but wrong for addmm(bias, input, weight) where the weight is at args[2] and the
input is at args[1].
This was exposed by a torchao change (D69887498) that added Linear+BatchNorm
fusion to prepare_pt2e(). The fusion adds a bias to Linear nodes that previously
had none, causing them to decompose to addmm instead of mm in the edge dialect.
The pattern matcher then read the input's per-tensor dequantize scale (a float
literal) as if it were the weight's per-channel scale (a Node), causing an
assertion failure.
The fix determines the correct arg indices based on whether the anchor node is
addmm. The bias handling at args[0] for addmm was already correct.
Authored-by: Claude
Differential Revision: D93768640