Skip to content

Commit

Permalink
[FEATURE] add quant algo Learned Step Size Quantization (#346)
Browse files Browse the repository at this point in the history
* update

* Fix a bug in make_divisible. (#333)

fix bug in make_divisible

Co-authored-by: liukai <[email protected]>

* [Fix] Fix counter mapping bug (#331)

* fix counter mapping bug

* move judgment into get_counter_type & update UT

* [Docs]Add MMYOLO projects link (#334)

* [Doc] fix typos in en/usr_guides (#299)

* Update README.md

* Update README_zh-CN.md

Co-authored-by: Sheffield <[email protected]>

* [Features]Support `MethodInputsRecorder` and `FunctionInputsRecorder` (#320)

* support MethodInputsRecorder and FunctionInputsRecorder

* fix bugs that the model can not be pickled

* WIP: add pytest for ema model

* fix bugs in recorder and delivery when ema_hook is used

* don't register the DummyDataset

* fix pytest

* updated

* retina loss & predict & tesnor DONE

* [Feature] Add deit-base (#332)

* WIP: support deit

* WIP: add deithead

* WIP: fix checkpoint hook

* fix data preprocessor

* fix cfg

* WIP: add readme

* reset single_teacher_distill

* add metafile

* add model to model-index

* fix configs and readme

* [Feature]Feature map visualization (#293)

* WIP: vis

* WIP: add visualization

* WIP: add visualization hook

* WIP: support razor visualizer

* WIP

* WIP: wrap draw_featmap

* support feature map visualization

* add a demo image for visualization

* fix typos

* change eps to 1e-6

* add pytest for visualization

* fix vis hook

* fix arguments' name

* fix img path

* support draw inference results

* add visualization doc

* fix figure url

* move files

Co-authored-by: weihan cao <HIT-cwh>

* [Feature] Add kd examples (#305)

* support kd for mbv2 and shufflenetv2

* WIP: fix ckpt path

* WIP: fix kd r34-r18

* add metafile

* fix metafile

* delete

* [Doc] add documents about pruning. (#313)

* init

* update user guide

* update images

* update

* update How to prune your model

* update how_to_use_config_tool_of_pruning.md

* update doc

* move location

* update

* update

* update

* add mutablechannels.md

* add references

Co-authored-by: liukai <[email protected]>
Co-authored-by: jacky <[email protected]>

* [Feature] PyTorch version of `PKD: General Distillation Framework for Object Detectors via Pearson Correlation Coefficient`. (#304)

* add pkd

* add pytest for pkd

* fix cfg

* WIP: support fcos3d

* WIP: support fcos3d pkd

* support mmdet3d

* fix cfgs

* change eps to 1e-6 and add some comments

* fix docstring

* fix cfg

* add assert

* add type hint

* WIP: add readme and metafile

* fix readme

* update metafiles and readme

* fix metafile

* fix pipeline figure

* for RFC

* Customed FX initialize

* add UT init

* [Refactor] Refactor Mutables and Mutators (#324)

* refactor mutables

* update load fix subnet

* add DumpChosen Typehint

* adapt UTs

* fix lint

* Add GroupMixin to ChannelMutator (temporarily)

* fix type hints

* add GroupMixin doc-string

* modified by comments

* fix type hits

* update subnet format

* fix channel group bugs and add UTs

* fix doc string

* fix comments

* refactor diff module forward

* fix error in channel mutator doc

* fix comments

Co-authored-by: liukai <[email protected]>

* [Fix] Update readme (#341)

* update kl readme

* update dsnas readme

* fix url

* Bump version to 1.0.0rc1 (#338)

update version

* init demo

* add customer_tracer

* add quantizer

* add fake_quant, loop, config

* remove CPatcher in custome_tracer

* demo_try

* init version

* modified base.py

* pre-rebase

* wip of adaround series

* adaround experiment

* trasfer to s2

* update api

* point at sub_reconstruction

* pre-checkout

* export onnx

* add customtracer

* fix lint

* move custom tracer

* fix import

* TDO: UTs

* Successfully RUN

* update loop

* update loop docstrings

* update quantizer docstrings

* update qscheme docstrings

* update qobserver docstrings

* update tracer docstrings

* update UTs init

* update UTs init

* fix review comments

* fix CI

* fix UTs

* update torch requirements

Co-authored-by: huangpengsheng <[email protected]>
Co-authored-by: LKJacky <[email protected]>
Co-authored-by: liukai <[email protected]>
Co-authored-by: Yang Gao <[email protected]>
Co-authored-by: kitecats <[email protected]>
Co-authored-by: Sheffield <[email protected]>
Co-authored-by: whcao <[email protected]>
Co-authored-by: jacky <[email protected]>
Co-authored-by: pppppM <[email protected]>
Co-authored-by: humu789 <[email protected]>
  • Loading branch information
11 people committed Apr 17, 2023
1 parent 677434e commit 85ed93e
Show file tree
Hide file tree
Showing 51 changed files with 3,116 additions and 67 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,6 @@ jobs:
python-version: [3.7]
torch: [1.6.0, 1.7.0, 1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0]
include:
- torch: 1.6.0
torch_version: 1.6
torchvision: 0.7.0
- torch: 1.7.0
torch_version: 1.7
torchvision: 0.8.1
- torch: 1.7.0
torch_version: 1.7
torchvision: 0.8.1
python-version: 3.8
- torch: 1.8.0
torch_version: 1.8
torchvision: 0.9.0
- torch: 1.8.0
torch_version: 1.8
torchvision: 0.9.0
python-version: 3.8
- torch: 1.9.0
torch_version: 1.9
torchvision: 0.10.0
- torch: 1.9.0
torch_version: 1.9
torchvision: 0.10.0
python-version: 3.8
- torch: 1.10.0
torch_version: 1.10
torchvision: 0.11.0
- torch: 1.10.0
torch_version: 1.10
torchvision: 0.11.0
python-version: 3.8
- torch: 1.11.0
torch_version: 1.11
torchvision: 0.12.0
- torch: 1.11.0
torch_version: 1.11
torchvision: 0.12.0
python-version: 3.8
- torch: 1.12.0
torch_version: 1.12
torchvision: 0.13.0
Expand Down
47 changes: 47 additions & 0 deletions configs/quantization/ptq/adaround.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
_base_ = ['mmcls::resnet/resnet18_8xb32_in1k.py']

test_cfg = dict(
_delete_=True,
type='mmrazor.PTQLoop',
dataloader=_base_.test_dataloader,
evaluator=_base_.test_evaluator,
calibrate_dataloader=_base_.train_dataloader,
batch_num=32,
# reconstruction_cfg=dict(
# pattern='layer',
# loss=dict(
# type='mmrazor.AdaRoundLoss',
# iters=20000
# )
# )
)

model = dict(
_delete_=True,
type='mmrazor.GeneralQuant',
architecture=_base_.model,
quantizer=dict(
type='mmrazor.CustomQuantizer',
is_qat=False,
skipped_methods=[
'mmcls.models.heads.ClsHead._get_loss',
'mmcls.models.heads.ClsHead._get_predictions'
],
qconfig=dict(
qtype='affine',
w_observer=dict(type='mmrazor.MSEObserver'),
a_observer=dict(type='mmrazor.EMAMSEObserver'),
w_fake_quant=dict(type='mmrazor.AdaRoundFakeQuantize'),
a_fake_quant=dict(type='mmrazor.FakeQuantize'),
w_qscheme=dict(
bit=2,
is_symmetry=False,
is_per_channel=True,
is_pot_scale=False,
),
a_qscheme=dict(
bit=4,
is_symmetry=False,
is_per_channel=False,
is_pot_scale=False),
)))
1 change: 1 addition & 0 deletions configs/quantization/ptq/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_base_ = ['mmcls::resnet/resnet18_8xb32_in1k.py']
1 change: 1 addition & 0 deletions configs/quantization/qat/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_base_ = ['./lsq_resnet50_8xb16_cifar10.py']
37 changes: 37 additions & 0 deletions configs/quantization/qat/lsq_resnet50_8xb16_cifar10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
_base_ = ['mmcls::resnet/resnet18_8xb16_cifar10.py']

train_cfg = dict(
_delete_=True,
type='mmrazor.QATEpochBasedLoop',
max_epochs=_base_.train_cfg.max_epochs,
)

model = dict(
_delete_=True,
_scope_='mmrazor',
type='GeneralQuant',
architecture={{_base_.model}},
quantizer=dict(
type='TensorRTQuantizer',
skipped_methods=[
'mmcls.models.heads.ClsHead._get_loss',
'mmcls.models.heads.ClsHead._get_predictions'
],
qconfig=dict(
qtype='affine',
w_observer=dict(type='mmrazor.MinMaxObserver'),
a_observer=dict(type='mmrazor.EMAMinMaxObserver'),
w_fake_quant=dict(type='mmrazor.LearnableFakeQuantize'),
a_fake_quant=dict(type='mmrazor.LearnableFakeQuantize'),
w_qscheme=dict(
bit=2,
is_symmetry=False,
is_per_channel=True,
is_pot_scale=False,
),
a_qscheme=dict(
bit=4,
is_symmetry=False,
is_per_channel=False,
is_pot_scale=False),
)))
4 changes: 3 additions & 1 deletion mmrazor/engine/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .distill_val_loop import SelfDistillValLoop, SingleTeacherDistillValLoop
from .evolution_search_loop import EvolutionSearchLoop
from .iteprune_val_loop import ItePruneValLoop
from .quantization_loops import PTQLoop, QATEpochBasedLoop
from .slimmable_val_loop import SlimmableValLoop
from .subnet_sampler_loop import GreedySamplerTrainLoop
from .subnet_val_loop import SubnetValLoop
Expand All @@ -12,5 +13,6 @@
'SingleTeacherDistillValLoop', 'DartsEpochBasedTrainLoop',
'DartsIterBasedTrainLoop', 'SlimmableValLoop', 'EvolutionSearchLoop',
'GreedySamplerTrainLoop', 'SubnetValLoop', 'SelfDistillValLoop',
'ItePruneValLoop', 'AutoSlimGreedySearchLoop'
'ItePruneValLoop', 'AutoSlimGreedySearchLoop', 'PTQLoop',
'QATEpochBasedLoop'
]
Loading

0 comments on commit 85ed93e

Please sign in to comment.