-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/quantizer factory refactoring #1963
Draft
BloodAxe
wants to merge
62
commits into
master
Choose a base branch
from
feature/quantizer-factory-refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 45 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
e6bc8fe
OpenVINO
BloodAxe 246d59d
OpenVINO
BloodAxe e284b31
PTQ with QC
BloodAxe 05c38fa
OpenVINO
BloodAxe b27ce4d
quantize_with_accuracy_control
BloodAxe 83dd059
coco2017_yolo_nas_s_ptq_only
BloodAxe d33a1eb
coco2017_yolo_nas_s_ptq_only
BloodAxe 96f3049
coco2017_yolo_nas_s_ptq_only
BloodAxe f0536d4
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe e0e5c91
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe 08b829e
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe 93c507c
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe 10146bc
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe ec135ca
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe 2aba1cb
coco2017_yolo_nas_s_ptq_only_cpu
BloodAxe eb75e0f
Working PoC of export of quantized model
BloodAxe 240c0b1
PoC of the plugin-based exporter & quantizer
BloodAxe 792aaf5
PoC of the plugin-based exporter & quantizer
BloodAxe 22ead7b
Make TRT & Vino quantizers work for PTQ
BloodAxe faeaf70
Make TRT QAT work
BloodAxe 0a8b01d
Implementing export (WIP)
BloodAxe a2fd101
Update exporters API
BloodAxe 0f5f8ca
Update exporters API
BloodAxe 04e9230
Print only common metircs
BloodAxe a701f85
Print only common metircs
BloodAxe 72e590d
Tune QAT parameters
BloodAxe 7a42947
Split PTQ & QAT methods into two different classes
BloodAxe be785d9
Added doc
BloodAxe bc1741b
Fix qat using wrong model
BloodAxe fdc25cd
Update trainer
BloodAxe c5301d4
Fix YoloNAS Pose head support for OpenVINO PTQ
BloodAxe cb404ba
Bump up package version and remove OpenVINO deps
BloodAxe 6dd186d
Merge branch 'refs/heads/master' into feature/openvino-refactoring
BloodAxe 519cbe9
Merge branch 'refs/heads/master' into feature/openvino-refactoring
BloodAxe 173f00d
Remove openvino stuff
BloodAxe e8bb9aa
Remove openvino stuff
BloodAxe 63f6d3f
Remove openvino stuff
BloodAxe fa2eb86
Revert irrelevant stuff
BloodAxe 0d111e9
Revert irrelevant stuff
BloodAxe cbc670f
postprocessing_use_tensorrt_nms -> detection_postprocessing_use_tenso…
BloodAxe d708ae1
Revert src/super_gradients/modules/skip_connections.py
BloodAxe 24e1355
Remove irrelevant stuff
BloodAxe 6b7b19e
Update QATRecipeModificationCallback
BloodAxe 65f174c
Adding back ptq() and qat() methods
BloodAxe 54c8b58
Adding back ptq() and qat() methods
BloodAxe a8ab948
Force PTQ/QAT modes when called from corresponding methods and legacy…
BloodAxe 8854ab6
Improve output path handling of exported model
BloodAxe 58ff42b
Remove TODO
BloodAxe 4d14410
Remove leftover
BloodAxe 39416ae
Added missing max_batches docstring
BloodAxe 9d1fe2b
Update notebook
BloodAxe 77427bc
Added missing installation pf trt quantizer for
BloodAxe 20423af
Reoranize quantizers sub-package to allow lazy-install of pytorch-qua…
BloodAxe 8974d56
Fix tests
BloodAxe f89f9ba
Fix syntax error
BloodAxe 5836dae
Fix import
BloodAxe aa3264f
Fix import
BloodAxe be70f48
Fix import
BloodAxe 5ecefd1
Update docs in YAML files
BloodAxe a6cf4d3
Update notebook to use postprocessing_use_tensorrt_nms:bool instead o…
BloodAxe 0a3c076
Update notebook to use postprocessing_use_tensorrt_nms:bool instead o…
BloodAxe 8be4575
Fixing tests
BloodAxe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,744 changes: 85 additions & 1,659 deletions
1,744
notebooks/yolo_nas_custom_dataset_fine_tuning_with_qat.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from super_gradients.common.factories.base_factory import BaseFactory | ||
from super_gradients.common.registry.registry import ALL_EXPORTERS | ||
|
||
|
||
class ExporterFactory(BaseFactory): | ||
def __init__(self): | ||
super().__init__(ALL_EXPORTERS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from super_gradients.common.factories.base_factory import BaseFactory | ||
from super_gradients.common.registry.registry import ALL_QUANTIZER | ||
|
||
|
||
class QuantizerFactory(BaseFactory): | ||
def __init__(self): | ||
super().__init__(ALL_QUANTIZER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import abc | ||
|
||
|
||
class AbstractExporter(abc.ABC): | ||
""" | ||
An abstract class for exporting a model from ONNX representation to a specific framework. | ||
For instance, ONNX model can be exported to TFLite, OpenVINO or CoreML formats. | ||
This can be done by subclassing from this class and implementing the `export_from_onnx` method. | ||
""" | ||
|
||
@abc.abstractmethod | ||
def export_from_onnx(self, source_onnx: str, output_file: str) -> str: | ||
""" | ||
Exports a model from ONNX representation to an output file. | ||
A output filename extension and it's content should be determined by the subclass. | ||
:param source_onnx: Input ONNX model file path. | ||
:param output_file: Output file path of the exported model. | ||
:return: Output file path of the exported model. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .export_to_onnx import export_to_onnx | ||
|
||
__all__ = ["export_to_onnx"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import shutil | ||
|
||
from super_gradients.common.abstractions.abstract_logger import get_logger | ||
from super_gradients.common.registry.registry import register_exporter | ||
from super_gradients.conversion.abstract_exporter import AbstractExporter | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
@register_exporter() | ||
class ONNXExporter(AbstractExporter): | ||
def __init__(self): | ||
pass | ||
|
||
def export_from_onnx(self, source_onnx: str, output_file: str) -> str: | ||
shutil.copy(source_onnx, output_file) | ||
return output_file |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand the logic of this.
We said that SG will not export the TRT engine, or OpenVino engine. We export an onnx file (even if that file is framework specific)