[PTQ] Store FP32 global scaling factors (absmax or scale_inv) for all quantized activations and weights. - #3296
[PTQ] Store FP32 global scaling factors (absmax or scale_inv) for all quantized activations and weights.#3296cspades wants to merge 5 commits into
Conversation
Greptile SummaryThe PR adds opt-in, nonpersistent PTQ calibration metadata buffers across Transformer Engine’s quantized PyTorch modules.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the LayerNormMLP path now accumulates both activation inputs separately from weights, and unsupported custom quantizers are safely skipped by calibration buffering. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Quantized module forward] --> B[Identify quantization recipe]
B --> C{Global FP32 metadata available?}
C -->|No| D[Skip calibration buffering]
C -->|Yes| E[Read activation and weight metadata]
E --> F[Apply decaying maximum to activations]
E --> G[Retain current weight metadata]
F --> H[Register nonpersistent module buffers]
G --> H
Reviews (2): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
|
/te-ci pytorch |
…nference. Signed-off-by: Cory Ye <cye@nvidia.com>
Signed-off-by: Cory Ye <cye@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Cory Ye <cye@nvidia.com>
70fe5a7 to
5049111
Compare
for more information, see https://pre-commit.ci
|
/te-ci pytorch |
|
@cspades, there is already a |
| elif recipe == "nvfp4": | ||
| metadata_name = "amax" | ||
| metadata = getattr(tensor, "_amax_rowwise", None) | ||
| elif recipe == "nvfp4_rowwise": | ||
| metadata_name = "amax_rowwise" | ||
| metadata = getattr(tensor, "_amax_rowwise", None) |
There was a problem hiding this comment.
Those should probably be merged into one.
Description
See issue for context: NVIDIA/Megatron-LM#5660
Related to: NVIDIA/Megatron-LM#6183
f"{tensor_name}_tensor_{metadata_name}_{recipe}_te_ptq_calibrated"buffer_quantized_scaling_factorsturns on the feature, and by default it is deactivated.quantized_scaling_factor_buffering_decaycontrols the decay of past max-accumulated activation scaling factors when your model or dataset is in-flight during training. Intends to capture steady-state maxima.New AbsMax = Max(Old AbsMax * Decay, Observed AbsMax)CustomRecipe), those are usually computed during inference or using more advanced calibration techniques.Testing
Type of change
Checklist: