Skip to content

Commit 42df073

Browse files
committed
fitcompress pruning method
1 parent b9e1323 commit 42df073

18 files changed

Lines changed: 174 additions & 34 deletions

src/pquant/configs/config_ap.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
pruning_parameters:
2-
disable_pruning_for_layers: # Disable pruning for these layers, even if enable_pruning is true
3-
-
2+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
43
enable_pruning: true
54
pruning_method: activation_pruning
6-
threshold: 0.15
5+
threshold: 0.2
76
threshold_decay: 0.
87
t_delta: 100
98
t_start_collecting_batch: 100

src/pquant/configs/config_autosparse.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ pruning_parameters:
33
alpha_reset_epoch: 90
44
autotune_epochs: 10
55
backward_sparsity: false
6-
disable_pruning_for_layers: # Disable pruning for these layers, even if enable_pruning is true
7-
-
6+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
87
enable_pruning: true
98
pruning_method: autosparse
109
threshold_decay: 0

src/pquant/configs/config_cs.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
pruning_parameters:
2-
disable_pruning_for_layers: # Disable pruning for these layers, even if enable_pruning is true
3-
-
2+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
43
enable_pruning: true
54
final_temp: 200
65
pruning_method: cs
76
threshold_decay: 1.0e-09
8-
threshold_init: 0
7+
threshold_init: 0.
98
quantization_parameters:
109
default_weight_keep_negatives: 1.
1110
default_weight_integer_bits: 0.

src/pquant/configs/config_dst.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pruning_parameters:
22
alpha: 5.0e-06
3-
disable_pruning_for_layers: # Disable pruning for these layers, even if enable_pruning is true
4-
-
3+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
54
enable_pruning: true
65
max_pruning_pct: 0.99
76
pruning_method: dst
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
pruning_parameters:
2+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
3+
enable_pruning: true
4+
threshold_decay: 0.
5+
pruning_method: fitcompress
6+
min_frac_bits: 2.
7+
quantization_parameters:
8+
default_weight_keep_negatives: 1.
9+
default_weight_integer_bits: 0.
10+
default_weight_fractional_bits: 7.
11+
default_data_keep_negatives: 0.
12+
default_data_integer_bits: 0.
13+
default_data_fractional_bits: 7.
14+
quantize_input: true
15+
quantize_output: false
16+
enable_quantization: true
17+
hgq_beta: 1e-5
18+
hgq_gamma: 0.0003
19+
hgq_heterogeneous: True
20+
layer_specific: []
21+
use_high_granularity_quantization: false
22+
use_real_tanh: false
23+
use_relu_multiplier: true
24+
use_symmetric_quantization: false
25+
overflow: SAT
26+
round_mode: RND
27+
fitcompress_parameters:
28+
enable_fitcompress : true
29+
optimize_quantization : true
30+
quantization_schedule : [7., 6., 5., 4.,3.]
31+
pruning_schedule : {start : 0, end : -2, steps : 40}
32+
compression_goal : 0.007
33+
optimize_pruning : true
34+
greedy_astar : true
35+
approximate : true
36+
f_lambda : 1
37+
training_parameters:
38+
epochs: 200
39+
fine_tuning_epochs: 0
40+
pretraining_epochs: 100
41+
pruning_first: false
42+
rewind: never
43+
rounds: 1
44+
save_weights_epoch: -1
45+
batch_size: 256
46+
cosine_tmax: 200
47+
gamma: 0.1
48+
l2_decay: 0.0001
49+
label_smoothing: 0.0
50+
lr: 0.1
51+
lr_schedule: cosine
52+
milestones:
53+
- -1
54+
- -1
55+
momentum: 0.9
56+
optimizer: adam
57+
plot_frequency: 100

src/pquant/configs/config_mdmm.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
pruning_parameters:
44
pruning_method: mdmm
55
enable_pruning: true
6-
disable_pruning_for_layers:
7-
-
6+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
87
constraint_type: "Equality"
98
target_value: 0.0
109
metric_type: "UnstructuredSparsity"

src/pquant/configs/config_pdp.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pruning_parameters:
2-
disable_pruning_for_layers: # Disable pruning for these layers, even if enable_pruning is true
3-
-
2+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
43
enable_pruning: true
54
epsilon: 0.015
65
pruning_method: pdp
@@ -24,13 +23,14 @@ quantization_parameters:
2423
layer_specific: []
2524
use_high_granularity_quantization: false
2625
use_real_tanh: false
27-
use_relu_multiplier: true
28-
use_symmetric_quantization: false
26+
use_relu_multiplier: false
27+
overflow: SAT
28+
round_mode: RND
2929
fitcompress_parameters:
3030
enable_fitcompress : false
3131
optimize_quantization : true
3232
quantization_schedule : [7.,4.,3.,2.,1.]
33-
pruning_schedule : {start : 0, end : -3, steps : 40}
33+
pruning_schedule : {start : 0, end : -2, steps : 40}
3434
compression_goal : 0.10
3535
optimize_pruning : true
3636
greedy_astar : true
@@ -39,7 +39,7 @@ fitcompress_parameters:
3939
training_parameters:
4040
epochs: 100
4141
fine_tuning_epochs: 20
42-
pretraining_epochs: 20
42+
pretraining_epochs: 1
4343
pruning_first: false
4444
rewind: never
4545
rounds: 1

src/pquant/configs/config_wanda.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pruning_parameters:
22
calculate_pruning_budget: True
3-
disable_pruning_for_layers: # Disable pruning for these layers, even if enable_pruning is true
4-
-
3+
disable_pruning_for_layers: [] # Disable pruning for these layers, even if enable_pruning is true
54
enable_pruning: true
65
M: null
76
N: null

src/pquant/core/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
AutoSparsePruningModel,
66
CSPruningModel,
77
DSTPruningModel,
8+
FITCompressPruningModel,
89
MDMMPruningModel,
910
PDPPruningModel,
1011
WandaPruningModel,
@@ -22,6 +23,7 @@
2223
PRUNING_MODEL_REGISTRY = {
2324
"cs": CSPruningModel,
2425
"dst": DSTPruningModel,
26+
"fitcompress": FITCompressPruningModel,
2527
"pdp": PDPPruningModel,
2628
"wanda": WandaPruningModel,
2729
"autosparse": AutoSparsePruningModel,
@@ -44,6 +46,7 @@
4446

4547
try:
4648
import mlflow
49+
4750
LOG_FUNCTIONS_REGISTRY = {
4851
"torch": mlflow.pytorch.log_model,
4952
"tensorflow": mlflow.tensorflow.log_model,

src/pquant/core/finetuning.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import yaml
1111
from pydantic import BaseModel, Field, field_validator
1212

13-
1413
from pquant.core import constants
1514
from pquant.data_models.finetuning_model import BaseFinetuningModel
1615
from pquant.data_models.fitcompress_model import BaseFitCompressModel
@@ -20,6 +19,7 @@
2019
BasePruningModel,
2120
CSPruningModel,
2221
DSTPruningModel,
22+
FITCompressPruningModel,
2323
MDMMPruningModel,
2424
PDPPruningModel,
2525
WandaPruningModel,
@@ -70,6 +70,7 @@ class TuningConfig(BaseModel):
7070
Union[
7171
CSPruningModel,
7272
DSTPruningModel,
73+
FITCompressPruningModel,
7374
PDPPruningModel,
7475
WandaPruningModel,
7576
AutoSparsePruningModel,
@@ -368,6 +369,13 @@ def dst_config():
368369
return TuningConfig.load_from_file(path)
369370

370371

372+
def fitcompress_config():
373+
yaml_name = "config_fitcompress.yaml"
374+
parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
375+
path = os.path.join(parent, "configs", yaml_name)
376+
return TuningConfig.load_from_file(path)
377+
378+
371379
def mdmm_config():
372380
yaml_name = "config_mdmm.yaml"
373381
parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

0 commit comments

Comments
 (0)