Skip to content
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

Fix LLM tests #1088

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Fix LLM tests #1088

wants to merge 4 commits into from

Conversation

pablomlago
Copy link
Contributor

Reason for this PR

See #1076.

Changes Made in this PR

Since transformers 4.46.0 (https://github.com/huggingface/transformers/releases/tag/v4.46.0), OPT attention mechanism relies, by default, on OPTSdpaAttention, thus resulting in the method replace_mha_with_quantizable_layers (https://github.com/pablomlago/brevitas/blob/master/src/brevitas_examples/llm/llm_quant/prepare_for_quantize.py#L11) not injecting the Brevitas layers.

Additionally, the signature of the forward function in OPTAttention was updated in transformers 4.46.0, thus requiring to update the signature of QuantMultiHeadAttention analogously, even if this attribute is not actually used.

Testing Summary

TODO

Risk Highlight

  • This PR includes code from another work (please detail).
  • This PR contains API-breaking changes.
  • This PR depends on work in another PR (please provide links/details).
  • This PR introduces new dependencies (please detail).
  • There are coverage gaps not covered by tests.
  • Documentation updates required in subsequent PR.

Checklist

  • Code comments added to any hard-to-understand areas, if applicable.
  • Changes generate no new warnings.
  • Updated any relevant tests, if applicable.
  • No conflicts with destination dev branch.
  • I reviewed my own code changes.
  • Initial CI/CD passing.
  • 1+ reviews given, and any review issues addressed and approved.
  • Post-review full CI/CD passing.

Copy link
Collaborator

@nickfraser nickfraser left a comment

Choose a reason for hiding this comment

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

Open question about new pattern for layer replacement.

@@ -1,3 +1,3 @@
# optimum-amd[brevitas] @ git+https://github.com/huggingface/optimum-amd.git@main
tqdm
transformers[sentencepiece]==4.45.2
transformers[sentencepiece]>=4.46.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have you bumped the version here? Does this no longer work with transformers<4.46.0?

Copy link
Contributor Author

@pablomlago pablomlago Nov 5, 2024

Choose a reason for hiding this comment

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

The tests would fail in 4.45.2.

"act_equalization": "layerwise",
"gptq": True,
"float_ppl": 31056.0, # 31274.05078125
"quant_ppl": 33056.0},]) # 33139.23046875},])
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do the numbers in the comments mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those were the numbers for transformers < 4.46.0. They need to be removed, but I wanted to get confirmation on the preferred way to go regarding the transformers version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks - can you add that to the comment?

@@ -602,7 +602,8 @@ def forward(
key_padding_mask: Optional[Tensor] = None,
need_weights: bool = True,
attn_mask: Optional[Tensor] = None,
average_attn_weights: bool = True) -> Tuple[Tensor, Optional[Tensor]]:
average_attn_weights: bool = True,
position_ids: Optional[Tensor] = None) -> Tuple[Tensor, Optional[Tensor]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do not modify this forward function. position_ids is not in PyTorch's MHA layer's forward function. If this is argument is ignored, then QuantizeOPTAttention should handle that.

@nickfraser nickfraser self-requested a review November 5, 2024 16:09
@Giuseppe5 Giuseppe5 added the next release PRs which should be merged for the next release label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next release PRs which should be merged for the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants