[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 15 commits into
Conversation
|
|
/te-ci pytorch |
70fe5a7 to
5049111
Compare
|
/te-ci pytorch |
|
@cspades, there is already a |
@ptrendx It can! I didn't know that was there. Apologies for the late reply have been working on other tasks. That being said, wanted to share that this max-reduce kind of works (vs. ModelOpt checkpoints, and I think Xiaokang did this with NVFP4 since that was the main topic of the issue): but can definitely merge/fold this into the calibrate API. Will report back. |
b830ba6 to
ac0df7a
Compare
92d2348 to
6e072e8
Compare
…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>
for more information, see https://pre-commit.ci
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>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
6e072e8 to
4ed3e2c
Compare
|
/te-ci pytorch |
Signed-off-by: Cory Ye <cye@nvidia.com>
for more information, see https://pre-commit.ci
|
/te-ci L1 pytorch |

Description
See issue for context: NVIDIA/Megatron-LM#5660
Related to: NVIDIA/Megatron-LM#6183
Quantizer.calibrate()API to support decayed calibration and model buffering.autocast(calibrating: bool, calibration_config: QuantizationCalibrationConfig)(both arguments, kept the older one for legacy / backwards compatibility with decay defaulting to 0) turns on the feature, and by default it is deactivated.calibratewill first look for calibration metadata according to the quantization recipe, but if that doesn't exist yet it will just take the non-quantizedTensorargument and compute its quantization metadata, since this is the original behavior ofcalibrate.calibratenow has implementations for all of the recipes that use FP32 global scaling factors, and the decayed calibration update is implemented in the base classQuantizer._update_calibration_value. It'll also buffer them automatically, which is a change in behavior but the extra buffering feature isn't a big deal for performance/memory (and frankly what's the point of storing calibration if we never export it), refer to my results below!f"{tensor_name}_tensor_{metadata_name}_{recipe}_te_ptq_calibrated"QuantizationCalibrationConfigonly has a single argument at the moment but in the future could hypothetically have way more, it's just that now we only buffer FP32 global scaling factors so it's simply justactivation_scale_decay.activation_scale_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)CustomRecipeandHybridQuantizer, which will error out), those are usually computed during inference or using more advanced calibration techniques.TEAutocastStateis another new data-class that may concern you since it changes the API ofget_autocast_stateandset_autocast_statewhich are public interfaces for the global quant state.QuantizationCalibrationConfigso I think now's a good time to stop returningtuples...Testing
Type of change
Checklist: