Skip to content
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

Set config.set_bits params' default values as None. #659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions aqt/jax/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ def set_absmax_calib_scale(cfg: DotGeneral, scale: float):

def set_bits(
cfg: DotGeneral,
fwd_lhs_bit: Union[int, None, fp8_numerics.FP8Dtype],
fwd_rhs_bit: Union[int, None, fp8_numerics.FP8Dtype],
dlhs_lhs_bit: Union[int, None, fp8_numerics.FP8Dtype],
dlhs_rhs_bit: Union[int, None, fp8_numerics.FP8Dtype],
drhs_lhs_bit: Union[int, None, fp8_numerics.FP8Dtype],
drhs_rhs_bit: Union[int, None, fp8_numerics.FP8Dtype],
fwd_lhs_bit: Union[int, None, fp8_numerics.FP8Dtype] = None,
fwd_rhs_bit: Union[int, None, fp8_numerics.FP8Dtype] = None,
dlhs_lhs_bit: Union[int, None, fp8_numerics.FP8Dtype] = None,
dlhs_rhs_bit: Union[int, None, fp8_numerics.FP8Dtype] = None,
drhs_lhs_bit: Union[int, None, fp8_numerics.FP8Dtype] = None,
drhs_rhs_bit: Union[int, None, fp8_numerics.FP8Dtype] = None,
) -> DotGeneral:
"""Set quantization bits for dot_general config."""

Expand Down Expand Up @@ -613,20 +613,13 @@ def config_fwd_fp8(fwd_bits: fp8_numerics.FP8Dtype = 'e4m3') -> DotGeneral:
cfg,
fwd_lhs_bit=fwd_bits,
fwd_rhs_bit=fwd_bits,
dlhs_lhs_bit=None,
dlhs_rhs_bit=None,
drhs_lhs_bit=None,
drhs_rhs_bit=None,
)
set_stochastic_rounding(cfg, False, False, 'jax.uniform')
assert cfg.fwd.local_aqt is None, 'local_aqt is not yet supported in fwd.'
return cfg


def set_fwd_calibration(
cfg: DotGeneral,
calibration_factory
) -> DotGeneral:
def set_fwd_calibration(cfg: DotGeneral, calibration_factory) -> DotGeneral:
"""Updates aqt_cfg for static range calibration."""
assert isinstance(
cfg.fwd.dg_quantizer, aqt_dot_general.DefaultDotGeneralQuantizer
Expand Down
4 changes: 0 additions & 4 deletions aqt/jax/v2/examples/cnn/serve_ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ def run(train_ds: dict[str, jax.Array], test_ds: dict[str, jax.Array]) -> None:
aqt_cfg,
fwd_lhs_bit=None if _WEIGHT_ONLY.value else 8,
fwd_rhs_bit=8,
dlhs_lhs_bit=None,
dlhs_rhs_bit=None,
drhs_lhs_bit=None,
drhs_rhs_bit=None,
)
loss = aqt_utils.serve_quantized(
cnn_model.CNN, test_ds, aqt_cfg, state.model_vars, act_calibrated=False
Expand Down