-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor _replace_linear_8da4w #451
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/451
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 2d4f772 with merge base dee13e1 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks great overall, just a few small nits!
torchao/quantization/GPTQ.py
Outdated
if copy_weights and child.weight.device != torch.device("meta"): | ||
new_linear.weight = child.weight | ||
return new_linear | ||
#setattr(module, name, new_linear) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete the commented out code (this one and the block comment in 923)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
can you add a summary to talk about the context for the change? |
please make sure to fill in Summary and Test Plan, like: #389 |
Summary: Test Plan: |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! @jerryzh168 any other comments?
if _check_linear_int4_k(child.in_features, groupsize) or padding_allowed: | ||
new_linear = linear_class( | ||
|
||
#import the util function here to avoid circular dependency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please add a space between # and import
#import the util function here to avoid circular dependency | ||
from torchao.quantization.quant_api import _replace_with_custom_fn_if_matches_filter | ||
|
||
def filter_fn(child: torch.nn.Module, cur_fqn:str) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing cur_fqn: str
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing all the comments
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
@huydhn @clee2000 @jerryzh168 is it deliberate that we can no longer merge PRs manually now? Was this to enable ghstack? I'm not sure the tradeoff was worth it since most contributors are not using ghstack I deliberately removed requirements to have the branch be up to date and authorized merging for anyone who is a maintainer and that makes merging contributor code simpler. Right now I'm just waiting on the bot to merge something that should be merged immediately The required checks now don't have any tests either? The required checks are only some internal FB checks EDIT: This seems to be an unrelated bug with branch protection rules internally, am following up |
I'm not sure what happened, ghstack changes are not going to affect normal landing I think, this is unexpected. @huydhn do you know what is happening here? |
* refactor _replace_linear_8da4w * clean up version ---------
Summary:
Reimplement the _replace_linear_8da4w function using the more general util function _replace_with_custom_fn_if_matches_filter from torchao.quantization.quant_api to reduce code duplication of similar logic.
Test Plan:
python test/quantization/test_quant_api.py
python test/quantization/test_quant_primitives.py