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

Support transformer models #16

Merged
merged 13 commits into from
Oct 17, 2023
Merged

Support transformer models #16

merged 13 commits into from
Oct 17, 2023

Conversation

dacorvo
Copy link
Collaborator

@dacorvo dacorvo commented Oct 17, 2023

This adds support for Transformer models:

  • quantize LayerNorm,
  • add QTensor dispatches for typical transformer operations (split/merge per-head),
  • add text-classification example (SST2).

Instead of raising an error, we dequantize before adding QTensor of
different scales.
This is required to support attention blocks that add activation tensors
from two different branches.
In attention blocks, the float output of the addition will in general be
immediately requantized by the next QLinear.
This adds two default unary dispatches:

- one for type-agnostic operations, where we can simply apply the
operation on the data withoput changing the scale,
- one for unuspported operations, where we dequantize to apply the
operation on float values.
@dacorvo dacorvo merged commit d76820c into main Oct 17, 2023
@dacorvo dacorvo deleted the support_transformer_models branch October 17, 2023 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant