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

[DO NOT MERGE] per-token dynamic observer #24

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

bfineran
Copy link
Member

@bfineran bfineran commented Apr 17, 2024

This PR adds support for per-token dynamic observers. These observer find a scale and zero point for each group of values against a given token dimension.

TODO:
Unit testing

@bfineran bfineran self-assigned this Apr 17, 2024
@Observer.register("per_token", alias="per_token_dynamic")
class PerTokenObserver(Observer):
"""
Values targted for a dyanmic observer do not require calibration,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spelling

__all__ = ["PerTokenObserver"]


@Observer.register("per_token", alias="per_token_dynamic")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are per token observers always dynamic?

Copy link
Contributor

@Satrat Satrat left a comment

Choose a reason for hiding this comment

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

One thing I'm unclear on is how this is going to appear in the quantization config. Will it be a new strategy like tensor/channel/group?

@bfineran bfineran changed the title [WIP] per-token dynamic observer [DO NOT MERGE] per-token dynamic observer Apr 25, 2024
@bfineran
Copy link
Member Author

@horheynm let's redo this PR as a quant arg strategy instead of an Observer

:return: tuple of scale and zero point derived from the observed tensor
"""
# reduce every dimension except token dimension
reduce_dims = [idx for idx in range(observed.dim()) if idx != self.axis]
Copy link
Member Author

Choose a reason for hiding this comment

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

should not reduce along batch as well

Base automatically changed from dynamic-quant to main April 25, 2024 18:24
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.

None yet

3 participants