-
Notifications
You must be signed in to change notification settings - Fork 624
[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 OverviewGreptile SummaryThis PR introduces semantic quantizer roles to TransformerEngine, replacing index-based quantizer identification with explicit role strings in the format Key changes:
The implementation is clean, well-structured, and includes proper validation at multiple levels. The role format change is breaking for Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Module as TransformerEngineModule
participant RecipeState
participant CustomRecipeState
participant QFactory as User Quantizer Factory
User->>Module: forward() with CustomRecipe
activate Module
Module->>Module: set_meta_tensor(fwd=True, recipe)
Module->>Module: get_quantizer_roles(fwd=True, num_quantizers)
Note over Module: Returns ["linear:input", "linear:weight", "linear:output"]
Module->>RecipeState: create(recipe, mode="forward", num_quantizers=3, roles)
activate RecipeState
RecipeState->>CustomRecipeState: __init__(recipe, mode, num_quantizers)
RecipeState->>CustomRecipeState: state.roles = roles
RecipeState-->>Module: recipe_state
deactivate RecipeState
Module->>CustomRecipeState: make_quantizers()
activate CustomRecipeState
CustomRecipeState->>CustomRecipeState: Validate roles exist and match num_quantizers
loop For each role
CustomRecipeState->>QFactory: qfactory(role="linear:input")
QFactory->>QFactory: Parse role (split on ":")
QFactory-->>CustomRecipeState: Quantizer instance
end
CustomRecipeState-->>Module: List of quantizers
deactivate CustomRecipeState
Module->>Module: Store quantizers in self.quantizers
Module->>Module: Execute forward pass with quantizers
deactivate Module
|
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". |
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No files reviewed, no comments
Description
Introducing semantic quantizer roles, e.g.
linear:input,layernorm_linear:grad_output.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.
dpa:qkvanddpa:s(scores) for attention.Type of change
Changes
Please list the changes introduced in this PR:
Checklist: