Skip to content
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

Reduced the number of graph rebuilds #2011

Merged
merged 5 commits into from
Aug 4, 2023

Conversation

alexsu52
Copy link
Contributor

@alexsu52 alexsu52 commented Jul 28, 2023

Changes

Extended the signature of algorithm methods by NNCFGraph. This changes shows quantization speed-up in 2.34x for "hf-internal-testing/tiny-random-GPTNeoXForCausalLM" model from optimum.

Reason for changes

Reduced the number of graph rebuilds

Related tickets

ref: 113245

Tests

N/A

@github-actions github-actions bot added NNCF PT Pull requests that updates NNCF PyTorch NNCF Common Pull request that updates NNCF Common experimental NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF ONNX Pull requests that updates NNCF ONNX NNCF PTQ Pull requests that updates NNCF PTQ labels Jul 28, 2023
@alexsu52 alexsu52 changed the title reduced the number of graphs rebuilt Reduced the number of graph rebuilds Jul 28, 2023
@alexsu52 alexsu52 marked this pull request as ready for review July 28, 2023 08:33
@alexsu52
Copy link
Contributor Author

run pylint pre-commit tests
run pytorch pre-commit tests
run tensorflow pre-commit tests
run openvino pre-commit tests
run onnx pre-commit tests

@andrey-churkin andrey-churkin self-requested a review July 28, 2023 12:36
@alexsu52 alexsu52 force-pushed the as/ptq_speedup branch 4 times, most recently from c724f9b to 2d1403e Compare July 28, 2023 14:58
@alexsu52 alexsu52 requested a review from KodiaqQ August 3, 2023 09:16
def apply(
self,
model: TModel,
graph: NNCFGraph,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should user create the graph to pass it? Should it use the NNCFGraphFactory factory to build it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the introduction of a simple API to create a model graph will be in a follow up PR.

@@ -484,10 +486,11 @@ def output_filter_func(point):
output_fp.extend(tensor_collector.get_statistics().mean_values)
return np.array(output_fp)

def get_statistic_points(self, model: TModel) -> StatisticPointsContainer:
def get_statistic_points(self, model: TModel, graph: NNCFGraph) -> StatisticPointsContainer:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next question is not related to these changes but I think it is important. Is the model parameter a quantized model or an initial one? The following code snippet makes one think that this model with quantizers

 model_copy = self._backend_entity.remove_fq_from_inputs(copy_model(model), graph)

In this case, I really don't understand how the PostTrainingQuantization.get_statistic_points() method works because it takes an initial model (not quantized). It makes sense to discuss this statement offline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! @KodiaqQ, could you answer on this comment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be true, the model here, for BC, is without quantizers, and remove_fq_from_inputs may be removed. But let's keep it for the next PRs because BC algo is not the main part of DQ.

@@ -189,13 +191,15 @@ def _create_statistics_aggregator(self, dataset: Dataset, backend: BackendType)
return PTStatisticsAggregator(dataset)
return None

def _apply(
def apply(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update PostTrainingQuantization.get_statistic_points() method as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. I updated PostTrainingQuantization.get_statistic_points() taking into account PR #2013, because PostTrainingQuantization.get_statistic_points() function has incorrect implementation anyway.

cc @daniil-lyakhov

@alexsu52 alexsu52 requested a review from a team as a code owner August 4, 2023 07:32
@alexsu52 alexsu52 merged commit 215718f into openvinotoolkit:develop Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental NNCF Common Pull request that updates NNCF Common NNCF ONNX Pull requests that updates NNCF ONNX NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF PT Pull requests that updates NNCF PyTorch NNCF PTQ Pull requests that updates NNCF PTQ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants