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

Disable graph check while tracing #1103

Merged
merged 4 commits into from
Jan 14, 2025

Conversation

mvafin
Copy link
Contributor

@mvafin mvafin commented Jan 8, 2025

What does this PR do?

This is alternative to #1064. It will only work with openvino>=2025.0 (openvinotoolkit/openvino#28328)
By disabling checking graph after trace we reduce memory usage in diffusers.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@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 eaidova added the openvino-test Trigger OpenVINO slow tests label Jan 10, 2025
@@ -23,6 +23,7 @@
from transformers.generation import GenerationMixin
from transformers.utils import is_tf_available, is_torch_available

from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer if we used something like TorchScriptPythonWrapper or TorchScriptPythonModel, the decoder part doesn't make sense especially since we are using this wrapper on top of diffusers text_encoder/unet/transformer etc.
Will this wrapper ever change and do decoder-specific stuff ? if npt why does it have Decoder in its name.

Copy link
Contributor Author

@mvafin mvafin Jan 10, 2025

Choose a reason for hiding this comment

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

This is a "decoder" in a sense that it is used to decode the pytorch model. It is used in openvino as an abstraction to get the graph from the model. It is an internal class, but it can be used to provide such custom parameters for tracing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this naming does not have relation to decoder models, Decoder is internal component of openvino responsible for decoding of original framework model during conversion. All that time we use it internally inside convert_model, now it is created explicitly for resolving advanced conversion options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, we can rename it on import. Will TorchScriptPythonWrapper be a better name?

Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil Jan 12, 2025

Choose a reason for hiding this comment

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

oh okay, confusing name but okay for me if it's part of the openvino naming conventions.

Copy link
Collaborator

@AlexKoff88 AlexKoff88 Jan 13, 2025

Choose a reason for hiding this comment

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

@IlyasMoutawwakil, can we merge this then?

@mvafin
Copy link
Contributor Author

mvafin commented Jan 13, 2025

Per @eaidova ask I moved decoder import inside function, can be useful in case openvino was custom built without pytorch support

Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil left a comment

Choose a reason for hiding this comment

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

LGTM, can merge once tests pass.

@IlyasMoutawwakil IlyasMoutawwakil merged commit fe55db5 into huggingface:main Jan 14, 2025
28 checks passed
@mvafin mvafin deleted the mvafin/check_trace_off branch January 15, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openvino-test Trigger OpenVINO slow tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants