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 5 commits into
base: dev
Choose a base branch
from
Open

Fix LLM tests #1088

wants to merge 5 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.

requirements/requirements-llm.txt Outdated Show resolved Hide resolved
"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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can have a dict that pulls out different reference accuracy based on transformer version? It might get annoying in the long run to keep track of everything, but it could also help catch regression that we might have initially attributed to "numbers have changed"

src/brevitas/nn/quant_mha.py Outdated Show resolved Hide resolved
@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
@nickfraser
Copy link
Collaborator

I think only @Giuseppe5's comment needs to be addressed, otherwise this can be merged IMO.

@Giuseppe5
Copy link
Collaborator

There's a bunch of test failing on the extended test suite @pablomlago

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