Pruning and Quantization of ML models
Project description
Prune and Quantize ML models
PQuant is a library for training compressed machine learning models, developed at CERN as part of the Next Generation Triggers project.
Installation via pip: pip install pquant-ml.
With TensorFlow pip install pquant-ml[tensorflow].
With PyTorch pip install pquant-ml[torch].
PQuant replaces the layers and activations it finds with a Compressed (in the case of layers) or Quantized (in the case of activations) variant. These automatically handle the quantization of the weights, biases and activations, and the pruning of the weights. Both PyTorch and TensorFlow models are supported.
Layers that can be compressed
- PQConv*D: Convolutional layers
- PQAvgPool*D: Average pooling layers
- PQBatchNorm*D: BatchNorm layers
- PQDense: Linear layer
- PQActivation: Activation layers (ReLU, Tanh)
The various pruning methods have different training steps, such as a pre-training step and fine-tuning step. PQuant provides a training function, where the user provides the functions to train and validate an epoch, and PQuant handles the training while triggering the different training steps.
Example
Example notebook can be found here. It handles the
- Creation of a torch model and data loaders.
- Creation of the training and validation functions.
- Loading a default pruning configuration of a pruning method.
- Using the configuration, the model, and the training and validation functions, call the training function of PQuant to train and compress the model.
- Creating a custom quantization and pruning configuration for a given model (disable pruning for some layers, different quantization bitwidths for different layers).
- Direct layers usage and layers replacement approaches.
- Usage of fine-tuning platform.
Pruning methods
A description of the pruning methods and their hyperparameters can be found here.
Quantization parameters
A description of the quantization parameters can be found here.
For detailed documentation check this page: PQuantML documentation
Authors
- Roope Niemi (CERN)
- Anastasiia Petrovych (CERN)
- Arghya Das (Purdue University)
- Enrico Lupi (CERN)
- Chang Sun (Caltech)
- Dimitrios Danopoulos (CERN)
- Marlon Joshua Helbing
- Mia Liu (Purdue University)
- Michael Kagan (SLAC National Accelerator Laboratory)
- Vladimir Loncar (CERN)
- Maurizio Pierini (CERN)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pquant_ml-0.0.6.tar.gz.
File metadata
- Download URL: pquant_ml-0.0.6.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8fc31d9781b0f9c291b58c03608ba07dba9f4ef55f2d1ead4c7a98687137a71
|
|
| MD5 |
bd55844aee155a5ff78690a49a3a0000
|
|
| BLAKE2b-256 |
ce3315ba6f035b6bc0eb11d3c2e381864e5f9ffbb8f529f42dfe042384e69982
|
Provenance
The following attestation bundles were made for pquant_ml-0.0.6.tar.gz:
Publisher:
python-publish.yml on nroope/PQuant
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pquant_ml-0.0.6.tar.gz -
Subject digest:
d8fc31d9781b0f9c291b58c03608ba07dba9f4ef55f2d1ead4c7a98687137a71 - Sigstore transparency entry: 1161096358
- Sigstore integration time:
-
Permalink:
nroope/PQuant@11054d001c6f5aa8c75c3fc3f48d491ffe5141a8 -
Branch / Tag:
refs/tags/v0.0.6 - Owner: https://github.com/nroope
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@11054d001c6f5aa8c75c3fc3f48d491ffe5141a8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pquant_ml-0.0.6-py3-none-any.whl.
File metadata
- Download URL: pquant_ml-0.0.6-py3-none-any.whl
- Upload date:
- Size: 92.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
877ce7719944d388eee2224aa1d4e5117b1f89077c3e3aa4fbea5c4711db6e83
|
|
| MD5 |
d15d06c3e3c8e1b63462de8ce2d232dd
|
|
| BLAKE2b-256 |
4b2bd8c19f1fc71c74381f69545efe4713ff14d8457772628f23fad4c691d257
|
Provenance
The following attestation bundles were made for pquant_ml-0.0.6-py3-none-any.whl:
Publisher:
python-publish.yml on nroope/PQuant
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pquant_ml-0.0.6-py3-none-any.whl -
Subject digest:
877ce7719944d388eee2224aa1d4e5117b1f89077c3e3aa4fbea5c4711db6e83 - Sigstore transparency entry: 1161096427
- Sigstore integration time:
-
Permalink:
nroope/PQuant@11054d001c6f5aa8c75c3fc3f48d491ffe5141a8 -
Branch / Tag:
refs/tags/v0.0.6 - Owner: https://github.com/nroope
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@11054d001c6f5aa8c75c3fc3f48d491ffe5141a8 -
Trigger Event:
release
-
Statement type: