Skip to main content

wageubn

wageubn's pytorch implementation.

Notice

This repo is based on the same framework as tqt and focuses on inferrence only. Even the quantized error and gradient could be got from wageubn.function.errorquant and wageubn.function.gradquant, we will not use them. If they are essential for your training, please fork this repo and wrap the wageubn.function modules with it.

Now available at https://pypi.org/project/wageubn/0.1.0/.

Networks quantized via this package could be find at https://github.com/PannenetsF/QuantizationPool.

wageubn's modules

wageubn.function

function is a re-impletement of torch.nn.modules. Besides all the args used in the original function, a quantized function get 2 kind of optional arguments: bit_width and retrain.

bit_width has 2 type: weight/bias or activation.

If the retrain is True, the Module will be in Retrain Mode, with the log2_t trainable. Else, in Static Mode, the log2_t are determined by initialization and not trainable.

wageubn.config

Config the bitwidth via wageubn.config.Config and wageubn.config.network_config. wageubn.config.Config is a namedtuple and you can set bitwidth as its key.

With more consideration of hardware implement, the input and output of any module should be FIXED(or quantized). So there is a iostrict attribute to do this.

wageubn's problem

iostrict is one part as stated in last section. The paper uses directquant almost everywhere, which turns to a new problem: the given k is not the bitwidth of data. It's just the width of the decimal. As a result, I decide to add more attribute to control the module's real bitwidth real_* for each part.

Supplement

Where is the hardware-precision error, update and gradient?

In the PyTorch framework, it's not easy to do the real quantization now. We cannot get gradient for int-like data type, for example. And there are more essential problems like overflow (no matter how careful you are to make the quantization via float) or truncation error, unless the network could rewrite all operations in CUDA or C++. But it requires much more effort than I can afford now.

How to get the data width of a tensor?

In fact, wageubn does the simplest work: get the data, train and eval based on the given bit width. But how to get the bit width is not mentioned. So we can say, under a given bit width (like 8), we need manually find the fixed point's place for each operations or even each layer. Then I will turn to TQT to do more work.

Contributing

It will be great of you to make this project better! There is some ways to contribute!

  1. To start with, issues and feature request could let maintainers know what's wrong or anything essential to be added.
  2. If you use the package in you work/repo, just cite the repo and add a dependency note!
  3. You can add some function in torch.nn like HardTanh and feel free to open a pull request! The code style is simple as here.

Acknowledgment

The original papar could be find at Arxiv, Training high-performance and large-scale deep neural networks with full 8-bit integers.

Metadata

Release files for wageubn 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wageubn 1.2.0
File Size Uploaded Provenance Actions
wageubn-1.2.0.tar.gz 9.7 kB Without provenance Details for wageubn-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wageubn 1.2.0
File Interpreter ABI Platform Actions
wageubn-1.2.0-py3-none-any.whl Python 3 none any Details for wageubn-1.2.0-py3-none-any.whl

Total release size: 22.3 kB

Release files / wageubn-1.2.0.tar.gz

Download URL wageubn-1.2.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9667cb84e4eb11722437f3d680fbd0ab401cd1eb548134af7636cd91931a258b
BLAKE2b-256 checksum
How to use checksums
570a532c44e95f2862876450b734e33196e7df1e262bf035107c9d7a132fccd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20200622 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

Release files / wageubn-1.2.0-py3-none-any.whl

Download URL wageubn-1.2.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e29c1b18c8031e9622f6db64700f780d7b750d3cb1b591841cfcac167dcf1e2c
BLAKE2b-256 checksum
How to use checksums
0be6658cf286fa04e0bb4b84576ad60c26d05332de3646524c16828350dc93fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20200622 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

Security for wageubn 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page