Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8c679eb
use relu multiplier by default, disable fitcompress by default
nroope Sep 25, 2025
38af523
Add hyperparameter optimisation
nastiapetrovych Oct 28, 2025
9e3c73c
initial PQBatchNorm for keras and torch. Initial input output quantiz…
nroope Sep 29, 2025
0167dea
add file that handles quantizer creation
nroope Sep 29, 2025
01d09b1
force cuda in qbatchnorm
nroope Sep 29, 2025
5f87f6d
no forcing cuda, but put model to device before example input
nroope Sep 29, 2025
5b91d07
add PQBatchNorm into default config
nroope Sep 29, 2025
145bcd3
separate i and f bits for input output quantizers, separate default k…
nroope Oct 13, 2025
4a0f0c4
fix QBatchNorm in keras
nroope Oct 13, 2025
64fede7
ebops calculations, refactoring quantizers to wrapper classes
nroope Oct 17, 2025
648d3a7
separate weight and data default quantization values
nroope Oct 28, 2025
a37e4f5
direct layer use torch
nroope Oct 29, 2025
ab73256
rebase dev
nroope Nov 3, 2025
2f58069
fix fitcompress pretraining boolean check for torch
nroope Nov 4, 2025
d6a729f
Separate torch activation layers from Keras, combine tanh and relu in…
nroope Nov 5, 2025
088e8e1
multiplier only for relu when not using hgq. Add custom quantization …
nroope Nov 7, 2025
e474f02
Direct Keras layers usage
nastiapetrovych Nov 18, 2025
7114f7b
some tests, bug fixes etc.
nroope Nov 21, 2025
975be74
rename compressed layers, import automatically based on keras backend…
nroope Nov 24, 2025
d445140
example notebook for jet tagger. Fix input quantization batch size fo…
nroope Nov 29, 2025
02923de
fix finetune import bug
nroope Nov 29, 2025
af45936
hard_tanh was missing from keras layer replacement, added it
nroope Dec 1, 2025
a1e84d1
Create ci.yml
nastiapetrovych Dec 8, 2025
2440bae
Trial documentation
nastiapetrovych Dec 8, 2025
3415120
Merge branch 'dev' of https://github.com/nroope/PQuant into dev
nastiapetrovych Dec 8, 2025
d07e0bb
Create .readthedocs.yaml
nastiapetrovych Dec 8, 2025
5d28a28
Add documentation page (#18)
nastiapetrovych Dec 15, 2025
ccae31d
Update README.md
nastiapetrovych Dec 15, 2025
52b418b
Update README.md
nastiapetrovych Dec 15, 2025
418020b
Add another logo otpion
nastiapetrovych Dec 15, 2025
de12da2
Update README.md
nastiapetrovych Dec 15, 2025
b43a7cc
Update README.md
nastiapetrovych Dec 15, 2025
c42efb3
Update README.md
nastiapetrovych Dec 15, 2025
d98d53c
FITCompress for all torch models, BatchNorm1d for Pytorch models, ebo…
nroope Dec 15, 2025
89d7eaf
make activation pruning a continuous method instead of a single one-shot
nroope Dec 15, 2025
b9e1323
Updated training config (#19)
nastiapetrovych Dec 15, 2025
42df073
fitcompress pruning method
nroope Dec 19, 2025
0b16701
optional dependencies, fix depthwise bug
nroope Dec 19, 2025
e54222a
Merge branch 'main' into dev
nroope Dec 19, 2025
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
59 changes: 59 additions & 0 deletions .github/workflows/sphinx-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Documentation

on:
# Runs on pushes targeting the default branch
push:
branches: ["dev"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip3 install ".[docs]"
- name: Build
run: |
cd docs
make html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/_build/html'

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
23 changes: 23 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version, and other tools you might need
build:
os: ubuntu-24.04
tools:
python: "3.13"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally, but recommended,
# declare the Python requirements required to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt

18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![alt text](docs/_static/pquant.png)
![alt text](docs/source/_static/pquant_white_font.png)

## 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](https://nextgentriggers.web.cern.ch/t13/) project.
Expand All @@ -9,13 +9,20 @@ To run the code, [HGQ2](https://github.com/calad0i/HGQ2) is also needed.
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: Conv2D and Linear layers, Tanh and ReLU activations for both TensorFlow and PyTorch. For PyTorch, also Conv1D.
### Layers that can be compressed

![alt text](docs/_static/pquant_transform.png)
* **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.


![alt text](docs/source/_static/overview_pquant.png)



### Example
Example notebook can be found [here](https://github.com/nroope/PQuant/tree/main/examples). It handles the
Expand All @@ -24,6 +31,8 @@ Example notebook can be found [here](https://github.com/nroope/PQuant/tree/main/
3. Loading a default pruning configuration of a pruning method.
4. Using the configuration, the model, and the training and validation functions, call the training function of PQuant to train and compress the model.
5. Creating a custom quantization and pruning configuration for a given model (disable pruning for some layers, different quantization bitwidths for different layers).
6. Direct layers usage and layers replacement approaches.
7. Usage of fine-tuning platform.

### Pruning methods
A description of the pruning methods and their hyperparameters can be found [here](docs/pruning_methods.md).
Expand All @@ -32,6 +41,9 @@ A description of the pruning methods and their hyperparameters can be found [her
A description of the quantization parameters can be found [here](docs/quantization_parameters.md).


For detailed documentation check this page: [PQuantML documentation](https://pquantml.readthedocs.io/en/latest/)


### Authors
- Roope Niemi (CERN)
- Anastasiia Petrovych (CERN)
Expand Down
21 changes: 21 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@sphinx-apidoc -f -o autodoc/ ../src/HGQ
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file removed docs/_static/pquant.png
Binary file not shown.
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
111 changes: 0 additions & 111 deletions docs/pruning_methods.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/quantization_parameters.md

This file was deleted.

5 changes: 5 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx
furo
myst-parser
sphinx_rtd_theme
sphinx-autodoc-typehints
Loading
Loading