Skip to content

Commit

Permalink
Drop binarization algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
KodiaqQ committed Mar 7, 2024
1 parent 08e4833 commit 5ff671b
Show file tree
Hide file tree
Showing 38 changed files with 8 additions and 1,575 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ learning frameworks.
| :--- | :---: | :---: |
|[Quantization Aware Training](./docs/compression_algorithms/Quantization.md) | Supported | Supported |
|[Mixed-Precision Quantization](./docs/compression_algorithms/Quantization.md#mixed-precision-quantization) | Supported | Not supported |
|[Binarization](./docs/compression_algorithms/Binarization.md) | Supported | Not supported |
|[Sparsity](./docs/compression_algorithms/Sparsity.md) | Supported | Supported |
|[Filter pruning](./docs/compression_algorithms/Pruning.md) | Supported | Supported |
|[Movement pruning](./nncf/experimental/torch/sparsity/movement/MovementSparsity.md) | Experimental | Not supported |
Expand Down
3 changes: 0 additions & 3 deletions docs/Algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Each compression method receives its own hyperparameters that are organized as a
- Automatic bitwidth assignment based on HAWQ
- Automatic quantization parameter selection and activation quantizer setup based on HW config preset
- Automatic bitwidth assignment mode AutoQ, based on HAQ, a Deep Reinforcement Learning algorithm to select best mixed precision given quality metric and HW type.
- [Binarization](./compression_algorithms/Binarization.md)
- XNOR, DoReFa weight binarization
- Scale/threshold based per-channel activation binarization
- [Sparsity](./compression_algorithms/Sparsity.md)
- Magnitude sparsity
- Regularization-based (RB) sparsity
Expand Down
24 changes: 0 additions & 24 deletions docs/ModelZoo.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,6 @@ The applied quantization compression algorithms are divided into two broad categ
<td><a href="../examples/torch/classification/configs/quantization/mobilenet_v3_small_imagenet_int8.json">Config</a></td>
<td><a href="https://storage.openvinotoolkit.org/repositories/nncf/models/develop/torch/mobilenet_v3_small_imagenet_int8.pth">Download</a></td>
</tr>
<tr>
<td align="left">ResNet-18</td>
<td align="left">-</td>
<td>ImageNet</td>
<td>69.76</td>
<td><a href="../examples/torch/classification/configs/binarization/resnet18_imagenet.json">Config</a></td>
<td>-</td>
</tr>
<tr>
<td align="left">ResNet-18</td>
<td align="left">• Binarization: XNOR (weights), scale/threshold (activations)</td>
<td>ImageNet</td>
<td>61.67 (8.09)</td>
<td><a href="../examples/torch/classification/configs/binarization/resnet18_imagenet_binarization_xnor.json">Config</a></td>
<td><a href="https://storage.openvinotoolkit.org/repositories/nncf/models/develop/torch/resnet18_imagenet_binarization_xnor.pth">Download</a></td>
</tr>
<tr>
<td align="left">ResNet-18</td>
<td align="left">• Binarization: DoReFa (weights), scale/threshold (activations)</td>
<td>ImageNet</td>
<td>61.63 (8.13)</td>
<td><a href="../examples/torch/classification/configs/binarization/resnet18_imagenet_binarization_dorefa.json">Config</a></td>
<td><a href="https://storage.openvinotoolkit.org/repositories/nncf/models/develop/torch/resnet18_imagenet_binarization_dorefa.pth">Download</a></td>
</tr>
<tr>
<td align="left">ResNet-18</td>
<td align="left">• Filter pruning: 40%, magnitude criterion</td>
Expand Down
51 changes: 0 additions & 51 deletions docs/compression_algorithms/Binarization.md

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 2 additions & 3 deletions examples/torch/classification/staged_quantization_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from nncf.config.schemata.defaults import STAGED_QUANTIZATION_BASE_LR
from nncf.config.schemata.defaults import STAGED_QUANTIZATION_BASE_WD
from nncf.torch import create_compressed_model
from nncf.torch.binarization.algo import BinarizationController
from nncf.torch.checkpoint_loading import load_state
from nncf.torch.initialization import default_criterion_fn
from nncf.torch.initialization import register_default_init_args
Expand Down Expand Up @@ -186,9 +185,9 @@ def autoq_eval_fn(model, eval_loader):
if model_state_dict is not None:
load_state(model, model_state_dict, is_resume=True)

if not isinstance(compression_ctrl, (BinarizationController, QuantizationController)):
if not isinstance(compression_ctrl, QuantizationController):
raise nncf.InternalError(
"The stage quantization sample worker may only be run with the binarization and quantization algorithms!"
"The stage quantization sample worker may only be run with the quantization algorithms!"
)

model, _ = prepare_model_for_execution(model, config)
Expand Down
4 changes: 1 addition & 3 deletions examples/torch/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ def is_staged_quantization(config):
if isinstance(compression_config, list):
compression_config = compression_config[0]
algo_type = compression_config.get("algorithm")
if algo_type is not None and algo_type == "binarization":
return True
if algo_type == "quantization" and compression_config.get("params", {}):
if algo_type is not None and algo_type == "quantization" and compression_config.get("params", {}):
return True
return False

Expand Down
4 changes: 1 addition & 3 deletions examples/torch/object_detection/layers/modules/l2norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
from nncf.torch.utils import no_jit_trace


@register_module(
ignored_algorithms=["quantization", "binarization", "const_sparsity", "magnitude_sparsity", "rb_sparsity"]
)
@register_module(ignored_algorithms=["quantization", "const_sparsity", "magnitude_sparsity", "rb_sparsity"])
class L2Norm(nn.Module):
def __init__(self, n_channels, scale, eps, across_spatial=0, channel_shared=0):
super().__init__()
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions nncf/common/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ def filter_pruning(self) -> Optional[FilterPruningStatistics]:
"""
return self._storage.get("filter_pruning")

@property
def binarization(self) -> None:
raise NotImplementedError

def register(self, algorithm_name: str, stats: Statistics):
"""
Registers statistics for the algorithm.
Expand All @@ -108,7 +104,6 @@ def register(self, algorithm_name: str, stats: Statistics):
* const_sparsity
* quantization
* filter_pruning
* binarization

:param stats: Statistics of the algorithm.
"""
Expand All @@ -120,7 +115,6 @@ def register(self, algorithm_name: str, stats: Statistics):
"const_sparsity",
"quantization",
"filter_pruning",
"binarization",
]
if algorithm_name not in available_algorithms:
raise ValueError(
Expand Down
2 changes: 0 additions & 2 deletions nncf/config/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
EARLY_EXIT_TRAINING_MODE_NAME_IN_CONFIG = "early_exit"
EXPERIMENTAL_QUANTIZATION_ALGO_NAME_IN_CONFIG = "experimental_quantization"
BOOTSTRAP_NAS_ALGO_NAME_IN_CONFIG = "bootstrapNAS"
BINARIZATION_ALGO_NAME_IN_CONFIG = "binarization"
CONST_SPARSITY_ALGO_NAME_IN_CONFIG = "const_sparsity"
FILTER_PRUNING_ALGO_NAME_IN_CONFIG = "filter_pruning"
KNOWLEDGE_DISTILLATION_ALGO_NAME_IN_CONFIG = "knowledge_distillation"
Expand All @@ -32,5 +31,4 @@
RB_SPARSITY_ALGO_NAME_IN_CONFIG: "docs/compression_algorithms/Sparsity.md",
CONST_SPARSITY_ALGO_NAME_IN_CONFIG: "docs/compression_algorithms/Sparsity.md",
KNOWLEDGE_DISTILLATION_ALGO_NAME_IN_CONFIG: "docs/compression_algorithms/KnowledgeDistillation.md",
BINARIZATION_ALGO_NAME_IN_CONFIG: "docs/compression_algorithms/Binarization.md",
}
3 changes: 0 additions & 3 deletions nncf/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import jsonschema

from nncf.config.definitions import ALGO_NAME_VS_README_URL
from nncf.config.definitions import BINARIZATION_ALGO_NAME_IN_CONFIG
from nncf.config.definitions import CONST_SPARSITY_ALGO_NAME_IN_CONFIG
from nncf.config.definitions import FILTER_PRUNING_ALGO_NAME_IN_CONFIG
from nncf.config.definitions import KNOWLEDGE_DISTILLATION_ALGO_NAME_IN_CONFIG
Expand All @@ -25,7 +24,6 @@
from nncf.config.definitions import SCHEMA_VISUALIZATION_URL
from nncf.config.schemata.accuracy_aware import ACCURACY_AWARE_MODES_VS_SCHEMA
from nncf.config.schemata.accuracy_aware import ACCURACY_AWARE_TRAINING_SCHEMA
from nncf.config.schemata.algo.binarization import BINARIZATION_SCHEMA
from nncf.config.schemata.algo.const_sparsity import CONST_SPARSITY_SCHEMA
from nncf.config.schemata.algo.filter_pruning import FILTER_PRUNING_SCHEMA
from nncf.config.schemata.algo.knowledge_distillation import KNOWLEDGE_DISTILLATION_SCHEMA
Expand All @@ -50,7 +48,6 @@
RB_SPARSITY_ALGO_NAME_IN_CONFIG: RB_SPARSITY_SCHEMA,
KNOWLEDGE_DISTILLATION_ALGO_NAME_IN_CONFIG: KNOWLEDGE_DISTILLATION_SCHEMA,
CONST_SPARSITY_ALGO_NAME_IN_CONFIG: CONST_SPARSITY_SCHEMA,
BINARIZATION_ALGO_NAME_IN_CONFIG: BINARIZATION_SCHEMA,
**EXPERIMENTAL_REF_VS_ALGO_SCHEMA,
}

Expand Down
45 changes: 0 additions & 45 deletions nncf/config/schemata/algo/binarization.py

This file was deleted.

2 changes: 0 additions & 2 deletions nncf/config/schemata/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
STAGED_QUANTIZATION_BASE_LR = 1e-3
STAGED_QUANTIZATION_BASE_WD = 1e-5

BINARIZATION_MODE = "xnor"

PRUNING_INIT = 0.0
PRUNING_SCHEDULE = "exponential"
PRUNING_TARGET = 0.5
Expand Down
1 change: 0 additions & 1 deletion nncf/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@


# Required for correct COMPRESSION_ALGORITHMS registry functioning
from nncf.torch.binarization import algo as binarization_algo
from nncf.torch.quantization import algo as quantization_algo
from nncf.torch.sparsity.const import algo as const_sparsity_algo
from nncf.torch.sparsity.magnitude import algo as magnitude_sparsity_algo
Expand Down
10 changes: 0 additions & 10 deletions nncf/torch/binarization/__init__.py

This file was deleted.

Loading

0 comments on commit 5ff671b

Please sign in to comment.