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

Move DelayWrapper logic to Proxy #1023

Open
Giuseppe5 opened this issue Sep 10, 2024 · 2 comments
Open

Move DelayWrapper logic to Proxy #1023

Giuseppe5 opened this issue Sep 10, 2024 · 2 comments
Labels
core Anything related to core operators good first issue Good for newcomers refactoring

Comments

@Giuseppe5
Copy link
Collaborator

Giuseppe5 commented Sep 10, 2024

Currently it's handled at the lowest level of integer quantization, but I argue it's not very intuitive.
When a quantizer is called, it should always quantize. Then the proxy will decide whether to return the original float value (having still called the quantizer and accumulated statics/computed gradients) or the quantized value.

Pro:

  • More clear behaviour of the quantizer (will come in handy later when dealing with real quantization (opposite to fake quantization )
  • Support for DelayWrapper for all QuantDtype in one go
  • Proxy is still the ultimate controller over QuantTensor vs Tensor (and not the quantizer)

Cons:

  • Proxy might get messy in the future, keep track
  • Perform small, useless computation for a few iterations
@Giuseppe5 Giuseppe5 added good first issue Good for newcomers refactoring core Anything related to core operators labels Sep 10, 2024
@aditya-167
Copy link

Hi I would like to work on this.. I am new to brevitas

@Giuseppe5
Copy link
Collaborator Author

Hello,
Thanks for offering!
Although the general idea is relatively clear in my mind, there are some technical details about the implementation that I still need to figure out and discuss with @nickfraser. We'll keep this thread up-to-date when there are news.

vishwamartur added a commit to vishwamartur/brevitas that referenced this issue Nov 3, 2024
Related to Xilinx#1023

Move `DelayWrapper` logic to Proxy classes.

* Add `DelayWrapper` instantiation in the `WeightQuantProxyFromInjectorBase` class in `src/brevitas/proxy/parameter_quant.py`.
* Modify the `forward` method in `WeightQuantProxyFromInjectorBase` to use `DelayWrapper` to decide the return value.
* Remove `DelayWrapper` instantiation and usage from the `IntQuant` and `DecoupledIntQuant` classes in `src/brevitas/core/quant/int_base.py`.
* Add tests in `tests/brevitas/proxy/test_proxy.py` to ensure the new behavior of `DelayWrapper` in the proxy classes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Anything related to core operators good first issue Good for newcomers refactoring
Projects
None yet
Development

No branches or pull requests

2 participants