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

Add support asymmetric fake-quantization to AQTv2. #675

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Jul 23, 2024

Add support asymmetric fake-quantization to AQTv2.

Integration of native quantization with biases will require computing the cross terms. See #725

Itemized changes:

  • Add IntAsymmetric to handle asymmetric integer numerics.
    • this class forgoes some of the more research-y parameters present on IntSymmetric.
  • Add MinMaxCalibration to calculate the scale and bias for asymmetric quantization.

I additionally tested this change by training MNIST models using flax_e2e_model. With symmetric quantization the model fails to converge for config.config_v4(fwd_bits=2, dlhs_bits=None, drhs_bits=None) (due to NaN losses). With asymmetric quantization the model converges even with config.config_v4(fwd_bits=2, dlhs_bits=2, drhs_bits=4).

@copybara-service copybara-service bot force-pushed the test_651580879 branch 4 times, most recently from 0071d1a to 33de2e9 Compare July 23, 2024 19:23
@copybara-service copybara-service bot force-pushed the test_651580879 branch 2 times, most recently from ef818dc to cef287a Compare August 29, 2024 23:29
@copybara-service copybara-service bot force-pushed the test_651580879 branch 9 times, most recently from b066596 to 4694998 Compare September 23, 2024 22:50
Integration of native quantization with biases will require computing the cross terms. See [#725](#725)

Itemized changes:

- Add `IntAsymmetric` to handle asymmetric integer numerics.
  - this class forgoes some of the more research-y parameters present on `IntSymmetric`.
- Add `MinMaxCalibration` to calculate the scale and bias for asymmetric quantization.

I additionally tested this change by training MNIST models using `flax_e2e_model`. With symmetric quantization the model fails to converge for `config.config_v4(fwd_bits=2, dlhs_bits=None, drhs_bits=None)` (due to `NaN` losses). With asymmetric quantization the model converges even with `config.config_v4(fwd_bits=2, dlhs_bits=2, drhs_bits=4)`.

PiperOrigin-RevId: 651580879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant