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

support stateful model #493

Merged
merged 84 commits into from
Jan 16, 2024
Merged

support stateful model #493

merged 84 commits into from
Jan 16, 2024

Conversation

eaidova
Copy link
Collaborator

@eaidova eaidova commented Dec 21, 2023

What does this PR do?

continue work on stateful models support based on #486

TO DO

@eaidova eaidova mentioned this pull request Dec 21, 2023
5 tasks
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@eaidova
Copy link
Collaborator Author

eaidova commented Dec 21, 2023

@echarlaix @AlexKoff88 please take a look, while @slyalin on vacation, I finished his PR with stateful models support

@eaidova eaidova requested a review from slyalin January 10, 2024 11:54
@slyalin
Copy link
Contributor

slyalin commented Jan 12, 2024

@echarlaix, we are ready to merge.

Copy link
Collaborator

@helena-intel helena-intel left a comment

Choose a reason for hiding this comment

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

I have a few typo fixes and small comments but none of them should block merging. We should also add this to documentation, but there is more documentation to be fixed before 2023.3 so that can be done in a separate PR. Thanks for the PR @eaidova !

optimum/exporters/openvino/model_patcher.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/stateful.py Outdated Show resolved Hide resolved
optimum/commands/export/openvino.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/convert.py Outdated Show resolved Hide resolved
# TODO: Implement stateful for ONNX path as well, not doing it right now because of lack of validation
logger.warn(
"[ WARNING ] Making stateful models is not supported when exporting to ONNX as an intermediate step. A stateless model will be exported instead. It may result in sub-optimal inference performance."
"Provide a model that can be converted to OpenVINO without fallback to ONNX conversion path."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"Provide a model that can be converted to OpenVINO without fallback to ONNX conversion path."
"Provide a model that can be converted to OpenVINO without fallback to ONNX conversion path."

I think most people will need to export the model they are exporting and "provide another model" is then not really helpful. In my experience, when export with PyTorch failed and ONNX was used instead, it was usually because of a technical issue, with optimum-intel or dependencies. So we could suggest to upgrade dependencies with pip install --upgrade --upgrade-strategy eager optimum[openvino] and maybe suggest to create an issue if exporting with PyTorch still fails?

optimum/exporters/openvino/stateful.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/__main__.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/__main__.py Outdated Show resolved Hide resolved
optimum/commands/export/openvino.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/__main__.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/__main__.py Outdated Show resolved Hide resolved
optimum/exporters/openvino/stateful.py Outdated Show resolved Hide resolved
tests/openvino/test_modeling.py Outdated Show resolved Hide resolved
tests/openvino/test_quantization.py Outdated Show resolved Hide resolved
tests/openvino/test_modeling.py Show resolved Hide resolved
@AlexKoff88
Copy link
Collaborator

@echarlaix, I think we are ready to merge

Copy link
Collaborator

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

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

Looks good thanks for the addition, can you confirm all tests are passing with openvino-nightly (or another version enabling stateful models) before we can merge ?

optimum/exporters/openvino/__main__.py Outdated Show resolved Hide resolved
@eaidova
Copy link
Collaborator Author

eaidova commented Jan 16, 2024

Looks good thanks for the addition, can you confirm all tests are passing with openvino-nightly (or another version enabling stateful models) before we can merge ?

I can confirm, I test this locally on my working machine

@helena-intel
Copy link
Collaborator

Looks good thanks for the addition, can you confirm all tests are passing with openvino-nightly (or another version enabling stateful models) before we can merge ?

I can confirm, I test this locally on my working machine

@eaidova Do the tests that fail with nightly here also pass for you locally with nightly/2023.3? https://github.com/huggingface/optimum-intel/actions/runs/7473712623/job/20526199806

FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_0_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_1_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_2_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_3_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int8_00_text_generation - AssertionError: 44 != 46
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int8_01_text_generation_with_past - AssertionError: 44 != 46
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int8_09_fill_mask - AssertionError: 68 != 70
FAILED tests/openvino/test_quantization.py::OVQuantizerTest::test_ovmodel_static_quantization_1 - AssertionError: 22 != 23
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_automodel_weight_compression_1 - AssertionError: 45 != 44
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_4bit_weight_compression_0 - AssertionError: 295 != 302
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_8bit_weight_compression_1 - AssertionError: 44 != 46
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_load_with_compressed_weights_00 - AssertionError: 44 != 46
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_load_with_compressed_weights_01 - AssertionError: 68 != 70

@eaidova
Copy link
Collaborator Author

eaidova commented Jan 16, 2024

Looks good thanks for the addition, can you confirm all tests are passing with openvino-nightly (or another version enabling stateful models) before we can merge ?

I can confirm, I test this locally on my working machine

@eaidova Do the tests that fail with nightly here also pass for you locally with nightly/2023.3? https://github.com/huggingface/optimum-intel/actions/runs/7473712623/job/20526199806

FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_0_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_1_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_2_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int4_3_text_generation_with_past - AssertionError: 295 != 302
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int8_00_text_generation - AssertionError: 44 != 46
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int8_01_text_generation_with_past - AssertionError: 44 != 46
FAILED tests/openvino/test_exporters_cli.py::OVCLIExportTestCase::test_exporters_cli_int8_09_fill_mask - AssertionError: 68 != 70
FAILED tests/openvino/test_quantization.py::OVQuantizerTest::test_ovmodel_static_quantization_1 - AssertionError: 22 != 23
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_automodel_weight_compression_1 - AssertionError: 45 != 44
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_4bit_weight_compression_0 - AssertionError: 295 != 302
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_8bit_weight_compression_1 - AssertionError: 44 != 46
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_load_with_compressed_weights_00 - AssertionError: 44 != 46
FAILED tests/openvino/test_quantization.py::OVWeightCompressionTest::test_ovmodel_load_with_compressed_weights_01 - AssertionError: 68 != 70

@helena-intel I mean all relevant tests passed. I do not take it into account as it reproducible without stateful models and does not related to my changes. it is probably related to difference model graph representation for quantization

@echarlaix
Copy link
Collaborator

OK perfect, thanks a lot for checking @helena-intel @eaidova

@echarlaix echarlaix merged commit 7f236c2 into huggingface:main Jan 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants