Skip to content

Commit 7f22ad5

Browse files
Add backend addapter for hpo platform and fixed serialization issue in pdp method (#31)
1 parent 44e268c commit 7f22ad5

14 files changed

Lines changed: 136 additions & 85 deletions

.readthedocs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ sphinx:
2020
# python:
2121
# install:
2222
# - requirements: docs/requirements.txt
23-

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
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.
55

6-
Installation via pip: ```pip install pquant-ml```.
6+
Installation via pip: ```pip install pquant-ml```.
77

8-
With TensorFlow ```pip install pquant-ml[tensorflow]```.
8+
With TensorFlow ```pip install pquant-ml[tensorflow]```.
99

1010
With PyTorch ```pip install pquant-ml[torch]```.
1111

12-
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.
13-
Both PyTorch and TensorFlow models are supported.
12+
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.
13+
Both PyTorch and TensorFlow models are supported.
1414

1515
### Layers that can be compressed
1616

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ help:
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
2020
@sphinx-apidoc -f -o autodoc/ ../src/HGQ
21-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/requirements.txt

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

docs/source/_static/custom.css

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ html body nav.wy-nav-top,
5151
}
5252

5353
.wy-body-for-nav {
54-
background-color: #ffffff !important;
54+
background-color: #ffffff !important;
5555
}
5656

5757
.wy-nav-content {
5858
background-color: #ffffff !important;
59-
max-width: 1200px !important;
59+
max-width: 1200px !important;
6060
}
6161

6262
.wy-side-nav-search {
@@ -71,19 +71,19 @@ html body nav.wy-nav-top,
7171
}
7272

7373
.wy-nav-side {
74-
background-color: #b30000 !important;
74+
background-color: #b30000 !important;
7575
}
7676
.wy-menu-vertical a {
77-
color: #ffffff !important;
77+
color: #ffffff !important;
7878
}
7979

8080
.wy-menu-vertical a:hover {
81-
background-color: #990000 !important;
81+
background-color: #990000 !important;
8282
}
8383

8484
.wy-menu-vertical li.current > a,
8585
.wy-menu-vertical li.toctree-l1.current > a {
86-
background-color: #660000 !important;
86+
background-color: #660000 !important;
8787
color: #ffffff !important;
8888
}
8989

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

113-
.rst-content > .document > .toctree-wrapper,
113+
.rst-content > .document > .toctree-wrapper,
114114
.rst-content > .document > .section {
115115
background-color: #ffffff !important;
116116
}
@@ -121,7 +121,7 @@ h1, h2, h3, h4, h5, h6 {
121121
}
122122

123123
.rst-content table th {
124-
background-color: #ffe6e6 !important;
124+
background-color: #ffe6e6 !important;
125125
color: #b30000 !important;
126126
}
127127

@@ -158,7 +158,7 @@ h1, h2, h3, h4, h5, h6 {
158158
color: #000000 !important;
159159
padding: 8px !important;
160160
margin: 12px !important;
161-
width: calc(100% - 24px) !important;
161+
width: calc(100% - 24px) !important;
162162
box-sizing: border-box !important;
163163
}
164164

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

171171
.wy-side-nav-search {
172172
background-color: #ffffff !important;
173-
padding: 20px 15px !important;
173+
padding: 20px 15px !important;
174174
border-bottom: 2px solid #b30000 !important;
175175
}
176176

@@ -184,19 +184,19 @@ h1, h2, h3, h4, h5, h6 {
184184
}
185185

186186
.wy-side-nav-search .version-switch {
187-
color: #b30000 !important;
187+
color: #b30000 !important;
188188
font-weight: 600 !important;
189189
}
190190

191191
.wy-side-nav-search .version-switch :hover {
192-
color: #990000 !important;
192+
color: #990000 !important;
193193
}
194194

195195
.wy-side-nav-search .fa-caret-down {
196196
color: #b30000 !important;
197197
}
198198
.wy-side-nav-search select.version-switch {
199-
color: #b30000 !important;
199+
color: #b30000 !important;
200200
background-color: #ffffff !important;
201201
border: 2px solid #b30000 !important;
202202
font-weight: 600 !important;
@@ -205,8 +205,8 @@ h1, h2, h3, h4, h5, h6 {
205205
}
206206

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

225225
.wy-side-nav-search input[type="search"] {
226-
height: 100% !important;
227-
width: 100% !important;
228-
font-size: 18px !important;
229-
padding: 10px 14px !important;
226+
height: 100% !important;
227+
width: 100% !important;
228+
font-size: 18px !important;
229+
padding: 10px 14px !important;
230230
margin: 0 !important;
231-
border-radius: 6px !important;
232-
border: none !important;
233-
box-shadow: none !important;
234-
background: #ffffff !important;
235-
color: #000000 !important;
231+
border-radius: 6px !important;
232+
border: none !important;
233+
box-shadow: none !important;
234+
background: #ffffff !important;
235+
color: #000000 !important;
236236
box-sizing: border-box !important;
237237
}
238238

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@
6767

6868
html_css_files = [
6969
'custom.css',
70-
]
70+
]

docs/source/faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ An example to install PyTorch with CUDA 13.0:
1212
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu130
1313
```
1414
## Can I use MLflow locally?
15-
Yes.
15+
Yes.
1616

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

1919

20-
### Start local MLFlow UI:
20+
### Start local MLFlow UI:
2121
```python
2222
mlflow ui --host 0.0.0.0 --port 5000
2323
```

docs/source/getting_started.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ def build_model(config):
3939
class Model(torch.nn.Module):
4040
def __init__(self):
4141
super().__init__()
42-
self.dense1 = PQDense(config, 16, 64,
42+
self.dense1 = PQDense(config, 16, 64,
4343
in_quant_bits = (1, 3, 3))
4444
self.relu = PQActivation(config, "relu")
4545
self.dense2 = PQDense(config, 64, 32)
4646
self.dense3 = PQDense(config, 32, 32)
47-
self.dense4 = PQDense(config, 32, 5,
48-
quantize_output=True,
47+
self.dense4 = PQDense(config, 32, 5,
48+
quantize_output=True,
4949
out_quant_bits=(1, 3, 3))
5050

5151
def forward(self, x):
@@ -78,18 +78,18 @@ def build_model():
7878
x = self.relu(self.dense3(x))
7979
x = self.dense4(x)
8080
return x
81-
81+
8282

8383
return Model()
8484

8585
# Convert to PQuantML-compressed model
8686
model = add_compression_layers(model, config)
8787
```
8888

89-
### Fine-Tuning with PQuantML
89+
### Fine-Tuning with PQuantML
9090
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.
9191

92-
```python
92+
```python
9393
from pquant.core.finetuning import TuningTask, TuningConfig
9494

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

145-
trained_model = train_model(model = model,
146-
config = config,
147-
train_func = ...,
148-
valid_func = ...,
149-
trainloader = ...,
145+
trained_model = train_model(model = model,
146+
config = config,
147+
train_func = ...,
148+
valid_func = ...,
149+
trainloader = ...,
150150
device="cuda",
151-
testloader = ...,
151+
testloader = ...,
152152
loss_func = loss_func,
153153
optimizer = optimizer,
154154
scheduler=scheduler
@@ -164,15 +164,15 @@ def build_model(config):
164164
class Model(torch.nn.Module):
165165
def __init__(self):
166166
super().__init__()
167-
self.dense1 = PQDense(config, 16, 64,
167+
self.dense1 = PQDense(config, 16, 64,
168168
in_quant_bits = (1, 3, 3))
169169
self.relu1 = PQActivation(config, "relu")
170170
self.relu2 = PQActivation(config, "relu")
171171
self.relu3 = PQActivation(config, "relu")
172172
self.dense2 = PQDense(config, 64, 32)
173173
self.dense3 = PQDense(config, 32, 32)
174-
self.dense4 = PQDense(config, 32, 5,
175-
quantize_output=True,
174+
self.dense4 = PQDense(config, 32, 5,
175+
quantize_output=True,
176176
out_quant_bits=(1, 3, 3))
177177

178178
def forward(self, x):

docs/source/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ PQuantML
1616

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

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

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

5050
.. toctree::
5151
:maxdepth: 2
52-
52+
5353
status
5454
install
5555
getting_started

docs/source/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Installation
22

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

55

66
```{warning}

0 commit comments

Comments
 (0)