Skip to content

Conversation

whyvineet
Copy link

Fix #2547

@whyvineet
Copy link
Author

@whyvineet please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@whyvineet
Copy link
Author

Hey @justinchuby, can you review this?

@justinchuby
Copy link
Collaborator

@AyoubMDL would you be able to help review/critique? Thanks!

@whyvineet
Copy link
Author

@AyoubMDL I made the changes you suggested...

@justinchuby
Copy link
Collaborator

@whyvineet please allow reviewers to resolve comments so they get a chance to validate the changes. Thanks.

@whyvineet
Copy link
Author

@AyoubMDL I've made the changes you suggested, except for the last one... After getting further clarity, I'll start working on that as well...

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 93.93939% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.94%. Comparing base (f529292) to head (ce64fb7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...pt/rewriter/rules/common/_remove_zero_bias_test.py 92.94% 2 Missing and 4 partials ⚠️
...xscript/rewriter/rules/common/_remove_zero_bias.py 95.45% 1 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (f529292) and HEAD (ce64fb7). Click for more details.

HEAD has 21 uploads less than BASE
Flag BASE (f529292) HEAD (ce64fb7)
42 21
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2555      +/-   ##
==========================================
- Coverage   70.33%   63.94%   -6.39%     
==========================================
  Files         222      224       +2     
  Lines       26656    26786     +130     
  Branches     2666     2679      +13     
==========================================
- Hits        18748    17128    -1620     
- Misses       6992     8811    +1819     
+ Partials      916      847      -69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@whyvineet
Copy link
Author

@AyoubMDL, I have completed the modifications recommended by you...

Copy link
Contributor

@AyoubMDL AyoubMDL left a comment

Choose a reason for hiding this comment

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

Thanks ! some final remarks.

Comment on lines 24 to 25
original_inputs = list(node.inputs)
inputs_without_bias = original_inputs[:-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

With my suggestion on Gemm, you can remove this. And pass x, w as arguments to the rewrite

Copy link
Author

Choose a reason for hiding this comment

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

instead of hardcoding x and w parameters, the base class can dynamically handle any number of inputs by filtering out just the bias parameter ('b') and keeping everything else in the new changes made by me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can pass some attributes when testing to check that every info is correctly transferred (e.g. stride, transA...)

@whyvineet
Copy link
Author

@AyoubMDL, is there anything else I should update or improve?

inputs_without_bias = original_inputs[:-1]
# Filter out the bias parameter and keep all other inputs
inputs = []
for param_name, param_value in _.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

?

Copy link
Author

Choose a reason for hiding this comment

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

I understand now... There was just a misunderstanding on my part!

Copy link
Contributor

@AyoubMDL AyoubMDL left a comment

Choose a reason for hiding this comment

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

The implementation looks good to me. I'll let @justinchuby share additional comments

@whyvineet
Copy link
Author

The implementation looks good to me. I'll let @justinchuby share additional comments

Thanks for the guidance @AyoubMDL! And I don't know how I missed domain=node.domain from the last review... I removed it now!

@whyvineet
Copy link
Author

@justinchuby, can you explain why these checks are failing? I reviewed the logs but didn't gain much clarity...

)


def _apply_rule_and_check_optimization(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test is a little too complicated to maintain. Please check other tests in the directory and simplify.

@justinchuby
Copy link
Collaborator

The error is saying the Sequence[int] attributes are supposed to be tuples but the expected values are lists. You can check where you provide the expected outputs.

@justinchuby
Copy link
Collaborator

This line

onnxscript/rewriter/rules/common/_remove_zero_bias_test.py:76: in _apply_rule_and_check_optimization
assert actual_value == expected_value, (

self.v1.dtype = ir.DataType.BFLOAT16
self.v2 = ir.val(name="v2", shape=ir.Shape([2, 3, 4]))
self.v2.dtype = ir.DataType.BFLOAT16
self.v0 = ir.Value(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert. ir.val is a convenience function.

Copy link
Author

Choose a reason for hiding this comment

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

It was failing test cases... Okh I'll do so!

@justinchuby
Copy link
Collaborator

Please use judgement before applying AI edits, and please engage the reviewers if you have clarification questions. It is preferred if you understand what the edits should be before spending time doing them. Have a discussion and lay out your thought process before taking actions. Pure AI edits that don't help with addressing the issues raised in reviews and is a waste of everyone's time.

@whyvineet
Copy link
Author

Please use judgement before applying AI edits, and please engage the reviewers if you have clarification questions. It is preferred if you understand what the edits should be before spending time doing them. Have a discussion and lay out your thought process before taking actions. Pure AI edits that don't help with addressing the issues raised in reviews and is a waste of everyone's time.

I understand your point and will make sure to carefully consider the purpose of edits and engage reviewers before applying changes in future commits and PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Rewrite rule: Remove optional bias
3 participants