nncf icon indicating copy to clipboard operation
nncf copied to clipboard

Pruning support for chunk ops

Open sooahleex opened this issue 3 years ago • 4 comments

Changes

  • Add layer attribute and functions for chunk/split ops
  • mask propagation for split/chunk ops

Reason for changes

  • To support pruning for chunk operation in HRNet
  • Support both split and chunk operation

Related tickets

86694

Tests

TODO

sooahleex avatar Aug 05 '22 05:08 sooahleex

@daniil-lyakhov This is the draft version

sooahleex avatar Aug 05 '22 05:08 sooahleex

@sooahleex, thank you for your contribution!

Please don't forget to update correspondent nncf tensorflow part as well

daniil-lyakhov avatar Aug 05 '22 08:08 daniil-lyakhov

Please add tests to torch/pruning/filter_pruning/test_algo.py

daniil-lyakhov avatar Aug 11 '22 08:08 daniil-lyakhov

Please add tests to torch/pruning/filter_pruning/test_algo.py

@daniil-lyakhov I added more cases for split/chunk models in tests/torch/pruning/helpers.py. ex. image

sooahleex avatar Aug 12 '22 10:08 sooahleex

run pytorch pre-commit tests

sooahleex avatar Aug 16 '22 09:08 sooahleex

General comment:

Masks matching by input shapes is implicit method of matching, I suggest you to

  1. Explicitly have SymbolicMask (in case op has one ouput edge) or {Nodename: SymbolicMask} (in case op has several output edges) as value kept in node.data['output_mask']
  2. Use get_input_masks everywhere to get input masks for node resolving all dependencies inside this util function

daniil-lyakhov avatar Aug 17 '22 14:08 daniil-lyakhov

I wonder how the algorithm will work when chunk axis doesn't match channel axis, according to which pruning occurs. What will happen with pruning mask and propagation algorithm? I think it makes sense to cover in tests.

ljaljushkin avatar Aug 19 '22 12:08 ljaljushkin

@sooahleex, to test this please update test_model_pruning_analysis.py with model/models which have split operations described in previous comment

daniil-lyakhov avatar Aug 19 '22 13:08 daniil-lyakhov

I fix the error which occurred due to PR.

sooahleex avatar Aug 26 '22 08:08 sooahleex

@ljaljushkin I added the axis=-1 case through SplitModel in tests/torch/pruning/helpers.py. Also, in this case, axis will not be set as -1 but be 3. It is the same logic of the axis setting in the concat method. If you think the current model is not enough, please let me know how to check it more.

sooahleex avatar Aug 26 '22 11:08 sooahleex

run pytorch pre-commit tests

sooahleex avatar Aug 30 '22 13:08 sooahleex

I added the case of Split->Reshape model and Identity split case as corner cases. Split->Reshape model splitreshapemodel Identity Split model identitysplitmodel

sooahleex avatar Aug 31 '22 05:08 sooahleex

We will cover the reshape check in the different pr related to 90584 ticket. For that ticket and pr, some tests in this pr will be updated for _is_not_mixing_dim.

sooahleex avatar Sep 01 '22 05:09 sooahleex

We will cover the reshape check in the different pr related to 90584 ticket. For that ticket and pr, some tests in this pr will be updated for _is_not_mixing_dim.

Related to 90976 ticket, the 90584 ticket is not related to this PR

daniil-lyakhov avatar Sep 01 '22 08:09 daniil-lyakhov

Have started sota eval (torch 56 and tf 87) jobs from nightly validation to make sure it doesn't break anything.

ljaljushkin avatar Sep 01 '22 09:09 ljaljushkin

sota eval tf 89 jobs for nightly validation passed.

sooahleex avatar Sep 05 '22 09:09 sooahleex

@ljaljushkin, can we merge it?

daniil-lyakhov avatar Sep 05 '22 11:09 daniil-lyakhov

@ljaljushkin, can we merge it?

SOTA eval for TF and PT is OK, except some known issues that are not related to the PR. Unfortunately, pre-commit for Pytorch is red due to some infrastructure issue. I'd not merge until we make sure it's passing.

ljaljushkin avatar Sep 05 '22 13:09 ljaljushkin

run pytorch pre-commit tests

daniil-lyakhov avatar Sep 05 '22 14:09 daniil-lyakhov

Pre-commit for PyTorch is not working due to infra issue. We've reported it to CI team. Have to wait until it's fixed and green

ljaljushkin avatar Sep 05 '22 14:09 ljaljushkin

run pytorch pre-commit tests

ljaljushkin avatar Sep 05 '22 14:09 ljaljushkin