-
Notifications
You must be signed in to change notification settings - Fork 613
[PyTorch] Introduce semantic quantizer roles #2620
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
base: main
Are you sure you want to change the base?
Conversation
…ipe state Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
for more information, see https://pre-commit.ci
Greptile SummaryIntroduces semantic quantizer roles (e.g., Key Changes:
Architecture: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Module as Module/Op
participant RecipeState
participant CustomRecipeState
participant QFactory as Quantizer Factory
Note over User,QFactory: Initialization Phase
User->>Module: Create module with autocast(recipe=CustomRecipe(qfactory))
Module->>Module: get_quantizer_roles(fwd=True)
Note right of Module: Returns ["input:linear", "weight:linear", "output:linear"]
Module->>RecipeState: RecipeState.create(recipe, mode="forward", num_quantizers=3, roles=roles)
RecipeState->>CustomRecipeState: __init__(recipe, mode, num_quantizers)
RecipeState->>CustomRecipeState: state.roles = roles
RecipeState-->>Module: CustomRecipeState instance
Note over User,QFactory: Quantizer Creation Phase
Module->>CustomRecipeState: make_quantizers()
CustomRecipeState->>CustomRecipeState: Validate len(roles) == num_quantizers
loop For each role in roles
CustomRecipeState->>QFactory: qfactory("input:linear")
QFactory-->>CustomRecipeState: Quantizer instance
CustomRecipeState->>QFactory: qfactory("weight:linear")
QFactory-->>CustomRecipeState: Quantizer instance
CustomRecipeState->>QFactory: qfactory("output:linear")
QFactory-->>CustomRecipeState: Quantizer instance
end
CustomRecipeState-->>Module: List of quantizers
Note over User,QFactory: Backward Pass (similar flow)
Module->>Module: get_quantizer_roles(fwd=False)
Note right of Module: Returns ["grad_output:linear", "grad_input:linear"]
Module->>RecipeState: RecipeState.create(recipe, mode="backward", num_quantizers=2, roles=roles)
|
Greptile's behavior is changing!From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
|
|
Description
Introducing semantic quantizer roles, e.g.
input:linear,grad_output:layernorm_linear.Emitted by module/op and used through
RecipeState.create(., roles=..), so that right quantizers can be constructed without relying on index in a list.Now used only by
CustomRecipe, but can be extended to all recipes.Also extendable to arbitrary operations, e.g.
qkv:dpaands:dpa(scores) for attention.Type of change
Changes
Please list the changes introduced in this PR:
Checklist: