def amax_and_scale_update(fp8_meta: Dict[str, Any], fwd_update: bool) -> None:
    """Updates fp8 amaxes/scales for fwd | bwd."""
    fp8_meta_tensor_key = "scaling_fwd" if fwd_update else "scaling_bwd"
    fp8_max_key = "fp8_max_fwd" if fwd_update else "fp8_max_bwd"

    (
        fp8_meta[fp8_meta_tensor_key].amax_history,
        fp8_meta[fp8_meta_tensor_key].scale,
        fp8_meta[fp8_meta_tensor_key].scale_inv,
    ) = default_amax_and_scale_update(
        fp8_meta[fp8_meta_tensor_key].amax_history,
        fp8_meta[fp8_meta_tensor_key].scale,
        fp8_meta[fp8_max_key],
        fp8_meta["recipe"].margin,
        fp8_meta["recipe"].amax_compute_algo,
    )
Updates fp8 amaxes/scales for fwd | bwd.
intel_extension_for_pytorch/quantization/fp8/fp8.py