Refactor GroupedLinear quantization dispatch - #3326
Conversation
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Greptile SummaryThe PR extracts GroupedLinear split-quantization and validation into a dedicated helper module while consolidating forward and backward split APIs.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code-triggered failures identified. The unified dispatch preserves the previous native, debug, hybrid, identity, fallback, bias-gradient, and CPU-offload branch behavior, while custom-generation validation remains retried after failed transitions. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
GL[GroupedLinear forward or backward] --> SQ[_grouped_quantization._split_quantize]
SQ --> N{Reference quantizer}
N -->|None| P[Cast and split tensors]
N -->|DebugQuantizer| D[Debug multi-tensor quantization]
N -->|HybridQuantizer| H[Rowwise and columnwise split quantization]
N -->|Native quantizer| B[Native split or bgrad quantization]
N -->|Custom or Identity| F[Python fallback or identity views]
B --> O[Per-expert outputs and optional dbiases]
D --> O
H --> O
F --> O
P --> O
Reviews (1): Last reviewed commit: "Refactor GroupedLinear quantization disp..." | Re-trigger Greptile |
|
/te-ci pytorch L1 |
| # | ||
| # See LICENSE for license information. | ||
|
|
||
| """Grouped split-quantization helpers used by :mod:`GroupedLinear`.""" |
There was a problem hiding this comment.
Can we rename this file to something like split quantization? It's not really a grouped quantization
| # tensors (like scales), but bulk allocation shares storage across all tensors, | ||
| # so if scales can't be offloaded, nothing in the group can be offloaded. | ||
| inputmats = _split_quantize( | ||
| inputmats, _ = _grouped_quantization._split_quantize( |
There was a problem hiding this comment.
Same comment for renaming
| else: | ||
| input_quantizer.set_usage(rowwise=False, columnwise=True) | ||
| inputmats = _split_quantize( | ||
| inputmats, _ = _grouped_quantization._split_quantize( |
zhongbozhu
left a comment
There was a problem hiding this comment.
overall LGTM, just have some questions
| ) | ||
| return outputs, dbiases | ||
|
|
||
| concrete_quantizers = cast(Sequence[Quantizer], quantizers) |
There was a problem hiding this comment.
why do we need this cast(Sequence[Quantizer], quantizers)? feels like some extra CPU overhead?
Description
Move grouped quantization helpers into a dedicated module and replace separate split APIs with one. Keeps quantizer validation at construction only for CustomRecipe while skipping validation for the built-in recipes.
Followup for #2817
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: