Skip to content

Commit 8a205bd

Browse files
authored
Merge pull request #20 from dev
Dev to main
2 parents 6f43939 + e54222a commit 8a205bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+12193
-4822
lines changed

.github/workflows/sphinx-build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Documentation
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["dev"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: Setup Pages
33+
uses: actions/configure-pages@v3
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: '3.11'
37+
- name: Install dependencies
38+
run: |
39+
pip3 install ".[docs]"
40+
- name: Build
41+
run: |
42+
cd docs
43+
make html
44+
- name: Upload artifact
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: 'docs/_build/html'
48+
49+
# Deployment job
50+
deploy:
51+
environment:
52+
name: github-pages
53+
url: ${{ steps.deployment.outputs.page_url }}
54+
runs-on: ubuntu-latest
55+
needs: build
56+
steps:
57+
- name: Deploy to GitHub Pages
58+
id: deployment
59+
uses: actions/deploy-pages@v4

.readthedocs.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version, and other tools you might need
8+
build:
9+
os: ubuntu-24.04
10+
tools:
11+
python: "3.13"
12+
13+
# Build documentation in the "docs/" directory with Sphinx
14+
sphinx:
15+
configuration: docs/conf.py
16+
17+
# Optionally, but recommended,
18+
# declare the Python requirements required to build your documentation
19+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
20+
# python:
21+
# install:
22+
# - requirements: docs/requirements.txt
23+

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![alt text](docs/_static/pquant.png)
1+
![alt text](docs/source/_static/pquant_white_font.png)
22

33
## Prune and Quantize ML models
44
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.
@@ -9,13 +9,20 @@ To run the code, [HGQ2](https://github.com/calad0i/HGQ2) is also needed.
99
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.
1010
Both PyTorch and TensorFlow models are supported.
1111

12-
Layers that can be compressed: Conv2D and Linear layers, Tanh and ReLU activations for both TensorFlow and PyTorch. For PyTorch, also Conv1D.
12+
### Layers that can be compressed
1313

14-
![alt text](docs/_static/pquant_transform.png)
14+
* **PQConv*D**: Convolutional layers
15+
* **PQAvgPool*D**: Average pooling layers
16+
* **PQBatchNorm*D**: BatchNorm layers
17+
* **PQDense**: Linear layer
18+
* **PQActivation**: Activation layers (ReLU, Tanh)
1519

1620
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.
1721

1822

23+
![alt text](docs/source/_static/overview_pquant.png)
24+
25+
1926

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

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

3443

44+
For detailed documentation check this page: [PQuantML documentation](https://pquantml.readthedocs.io/en/latest/)
45+
46+
3547
### Authors
3648
- Roope Niemi (CERN)
3749
- Anastasiia Petrovych (CERN)

docs/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@sphinx-apidoc -f -o autodoc/ ../src/HGQ
21+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/_static/pquant.png

-27.1 KB
Binary file not shown.

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/pruning_methods.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

docs/quantization_parameters.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sphinx
2+
furo
3+
myst-parser
4+
sphinx_rtd_theme
5+
sphinx-autodoc-typehints

0 commit comments

Comments
 (0)