Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ sphinx:
# python:
# install:
# - requirements: docs/requirements.txt

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
## 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.

Installation via pip: ```pip install pquant-ml```.
Installation via pip: ```pip install pquant-ml```.

With TensorFlow ```pip install pquant-ml[tensorflow]```.
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.
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

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ help:
# "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)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx
furo
myst-parser
sphinx_rtd_theme
sphinx
sphinx-autodoc-typehints
sphinx_rtd_theme
48 changes: 24 additions & 24 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ html body nav.wy-nav-top,
}

.wy-body-for-nav {
background-color: #ffffff !important;
background-color: #ffffff !important;
}

.wy-nav-content {
background-color: #ffffff !important;
max-width: 1200px !important;
max-width: 1200px !important;
}

.wy-side-nav-search {
Expand All @@ -71,19 +71,19 @@ html body nav.wy-nav-top,
}

.wy-nav-side {
background-color: #b30000 !important;
background-color: #b30000 !important;
}
.wy-menu-vertical a {
color: #ffffff !important;
color: #ffffff !important;
}

.wy-menu-vertical a:hover {
background-color: #990000 !important;
background-color: #990000 !important;
}

.wy-menu-vertical li.current > a,
.wy-menu-vertical li.toctree-l1.current > a {
background-color: #660000 !important;
background-color: #660000 !important;
color: #ffffff !important;
}

Expand All @@ -110,7 +110,7 @@ h1, h2, h3, h4, h5, h6 {
background-color: #ffffff !important;
}

.rst-content > .document > .toctree-wrapper,
.rst-content > .document > .toctree-wrapper,
.rst-content > .document > .section {
background-color: #ffffff !important;
}
Expand All @@ -121,7 +121,7 @@ h1, h2, h3, h4, h5, h6 {
}

.rst-content table th {
background-color: #ffe6e6 !important;
background-color: #ffe6e6 !important;
color: #b30000 !important;
}

Expand Down Expand Up @@ -158,7 +158,7 @@ h1, h2, h3, h4, h5, h6 {
color: #000000 !important;
padding: 8px !important;
margin: 12px !important;
width: calc(100% - 24px) !important;
width: calc(100% - 24px) !important;
box-sizing: border-box !important;
}

Expand All @@ -170,7 +170,7 @@ h1, h2, h3, h4, h5, h6 {

.wy-side-nav-search {
background-color: #ffffff !important;
padding: 20px 15px !important;
padding: 20px 15px !important;
border-bottom: 2px solid #b30000 !important;
}

Expand All @@ -184,19 +184,19 @@ h1, h2, h3, h4, h5, h6 {
}

.wy-side-nav-search .version-switch {
color: #b30000 !important;
color: #b30000 !important;
font-weight: 600 !important;
}

.wy-side-nav-search .version-switch :hover {
color: #990000 !important;
color: #990000 !important;
}

.wy-side-nav-search .fa-caret-down {
color: #b30000 !important;
}
.wy-side-nav-search select.version-switch {
color: #b30000 !important;
color: #b30000 !important;
background-color: #ffffff !important;
border: 2px solid #b30000 !important;
font-weight: 600 !important;
Expand All @@ -205,8 +205,8 @@ h1, h2, h3, h4, h5, h6 {
}

.wy-side-nav-search select.rtd-version-select {
color: #b30000 !important;
background-color: #ffffff !important;
color: #b30000 !important;
background-color: #ffffff !important;
border: 2px solid #b30000 !important;
font-weight: 600 !important;
padding: 6px !important;
Expand All @@ -223,16 +223,16 @@ h1, h2, h3, h4, h5, h6 {
}

.wy-side-nav-search input[type="search"] {
height: 100% !important;
width: 100% !important;
font-size: 18px !important;
padding: 10px 14px !important;
height: 100% !important;
width: 100% !important;
font-size: 18px !important;
padding: 10px 14px !important;
margin: 0 !important;
border-radius: 6px !important;
border: none !important;
box-shadow: none !important;
background: #ffffff !important;
color: #000000 !important;
border-radius: 6px !important;
border: none !important;
box-shadow: none !important;
background: #ffffff !important;
color: #000000 !important;
box-sizing: border-box !important;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@

html_css_files = [
'custom.css',
]
]
4 changes: 2 additions & 2 deletions docs/source/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ An example to install PyTorch with CUDA 13.0:
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu130
```
## Can I use MLflow locally?
Yes.
Yes.

PQuantML integrates with MLflow for experiment tracking and model logging and local usage is fully supported.


### Start local MLFlow UI:
### Start local MLFlow UI:
```python
mlflow ui --host 0.0.0.0 --port 5000
```
Expand Down
30 changes: 15 additions & 15 deletions docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def build_model(config):
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.dense1 = PQDense(config, 16, 64,
self.dense1 = PQDense(config, 16, 64,
in_quant_bits = (1, 3, 3))
self.relu = PQActivation(config, "relu")
self.dense2 = PQDense(config, 64, 32)
self.dense3 = PQDense(config, 32, 32)
self.dense4 = PQDense(config, 32, 5,
quantize_output=True,
self.dense4 = PQDense(config, 32, 5,
quantize_output=True,
out_quant_bits=(1, 3, 3))

def forward(self, x):
Expand Down Expand Up @@ -78,18 +78,18 @@ def build_model():
x = self.relu(self.dense3(x))
x = self.dense4(x)
return x


return Model()

# Convert to PQuantML-compressed model
model = add_compression_layers(model, config)
```

### Fine-Tuning with PQuantML
### Fine-Tuning with PQuantML
PQuantML provides an automated fine-tuning and hyperparameter-optimization workflow through the `TuningTask API`. This allows you to search for optimal pruning, quantization, and training parameters using your own training, validation, and objective functions.

```python
```python
from pquant.core.finetuning import TuningTask, TuningConfig

# Convert defined yaml file into the object
Expand Down Expand Up @@ -142,13 +142,13 @@ Training is handled through the `train_model(...)` wrapper:
```python
from pquant import train_model

trained_model = train_model(model = model,
config = config,
train_func = ...,
valid_func = ...,
trainloader = ...,
trained_model = train_model(model = model,
config = config,
train_func = ...,
valid_func = ...,
trainloader = ...,
device="cuda",
testloader = ...,
testloader = ...,
loss_func = loss_func,
optimizer = optimizer,
scheduler=scheduler
Expand All @@ -164,15 +164,15 @@ def build_model(config):
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.dense1 = PQDense(config, 16, 64,
self.dense1 = PQDense(config, 16, 64,
in_quant_bits = (1, 3, 3))
self.relu1 = PQActivation(config, "relu")
self.relu2 = PQActivation(config, "relu")
self.relu3 = PQActivation(config, "relu")
self.dense2 = PQDense(config, 64, 32)
self.dense3 = PQDense(config, 32, 32)
self.dense4 = PQDense(config, 32, 5,
quantize_output=True,
self.dense4 = PQDense(config, 32, 5,
quantize_output=True,
out_quant_bits=(1, 3, 3))

def forward(self, x):
Expand Down
10 changes: 5 additions & 5 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ PQuantML

Welcome to the official documentation for **PQuantML**, a hardware-aware model compression framework supporting:

- Joint pruning + quantization
- Layer-wise precision configuration
- Flexible training pipelines
- PyTorch and TensorFlow backends
- Joint pruning + quantization
- Layer-wise precision configuration
- Flexible training pipelines
- PyTorch and TensorFlow backends
- Integration with hardware-friendly toolchains (e.g., hls4ml)

PQuantML enables efficient deployment of compact neural networks on resource-constrained hardware such as FPGAs and embedded accelerators.
Expand Down Expand Up @@ -49,7 +49,7 @@ Contents

.. toctree::
:maxdepth: 2

status
install
getting_started
Expand Down
2 changes: 1 addition & 1 deletion docs/source/install.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation

Use `pip install pquant-ml` to install the latest version from PyPI. You will need an environment with `python>=3.10,<=3.12` installed.
Use `pip install pquant-ml` to install the latest version from PyPI. You will need an environment with `python>=3.10,<=3.12` installed.


```{warning}
Expand Down
4 changes: 1 addition & 3 deletions docs/source/status.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PQuantML Status

This page tracks the development status of PQuantML features
This page tracks the development status of PQuantML features

## Release: v1.0.0

Expand All @@ -13,5 +13,3 @@ This page tracks the development status of PQuantML features
| hls4ml integration | ✅ Complete | Works in v1.0.0 |
| FITCompress | 🚧 Partially implemented | Works through PyTorch only |
| Documentation | 🚧 Improving | Expanded daily |


Loading