Skip to content
Merged
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
10 changes: 5 additions & 5 deletions backends/qualcomm/quantizer/qconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def get_16a8w_qnn_qat_config(
act_observer=MovingAverageMinMaxObserver,
) -> QuantizationConfig:
extra_args: Dict[str, Any] = {"eps": 2**-20}
act_fake_quant_ctr = FakeQuantize.with_args(
act_fake_quant_ctr = FusedMovingAvgObsFakeQuantize.with_args(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between FakeQuantize and FusedMovingAvgObsFakeQuantize

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FusedMovingAvgObsFakeQuantize - as the name suggests, has a combined op for FakeQuantize and MovingAvgObserver which makes it faster than two separate ops: FakeQuantize and MovingAvgObserver.

dtype=torch.int32,
quant_min=torch.iinfo(torch.uint16).min,
quant_max=torch.iinfo(torch.uint16).max,
Expand Down Expand Up @@ -398,7 +398,7 @@ def get_ptq_per_block_quant_config(
def get_8a8w_qnn_qat_config(
act_symmetric: bool = False, act_observer=MovingAverageMinMaxObserver
) -> QuantizationConfig:
act_fake_quant_ctr = FakeQuantize.with_args(
act_fake_quant_ctr = FusedMovingAvgObsFakeQuantize.with_args(
dtype=torch.uint8,
qscheme=(
torch.per_tensor_symmetric if act_symmetric else torch.per_tensor_affine
Expand Down Expand Up @@ -458,7 +458,7 @@ def get_8a8w_qnn_qat_config(
def get_16a4w_qnn_qat_config(
act_observer=MovingAverageMinMaxObserver,
) -> QuantizationConfig:
act_fake_quant_ctr = FakeQuantize.with_args(
act_fake_quant_ctr = FusedMovingAvgObsFakeQuantize.with_args(
dtype=torch.int32,
quant_min=torch.iinfo(torch.uint16).min,
quant_max=torch.iinfo(torch.uint16).max,
Expand Down Expand Up @@ -541,7 +541,7 @@ def get_qat_per_channel_quant_config(
# If zero_point is 128, htp can do optimizations.
# If we keep quant_min and quant_max none, observer will default use 128 as zero_point.
# If we provide uint8 quant_min/max, it will use 127 as zero_point, which is undesired.
act_fake_quant_ctr = FakeQuantize.with_args(
act_fake_quant_ctr = FusedMovingAvgObsFakeQuantize.with_args(
dtype=torch.int32 if act_dtype == torch.uint16 else act_dtype,
qscheme=torch.per_tensor_symmetric,
observer=act_observer,
Expand All @@ -553,7 +553,7 @@ def get_qat_per_channel_quant_config(
observer_or_fake_quant_ctr=act_fake_quant_ctr,
)
else:
act_fake_quant_ctr = FakeQuantize.with_args(
act_fake_quant_ctr = FusedMovingAvgObsFakeQuantize.with_args(
dtype=torch.int32 if act_dtype == torch.uint16 else act_dtype,
quant_min=torch.iinfo(act_dtype).min,
quant_max=torch.iinfo(act_dtype).max,
Expand Down
Loading