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

Concurrency support using model clone #564

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

dtrawins
Copy link

@dtrawins dtrawins commented Feb 16, 2024

Support for execution with multi concurrency

  • Adding clone operation to model objects which creates new execution context without duplicating compiled_model and memory usage. It enables multi-concurrency in multithreaded applications.
  • request attribute is now deprecated - new attributes compiled_model and infer_request are added instead - they match OpenVINO objects
  • improved performance for decoder models by eliminating creating new requests for each inference

Before submitting

  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@dtrawins
Copy link
Author

This PR is a replacement for #519

@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.

self.request = core.compile_model(self.model, self.device, self.ov_config)
logger.info(f"Compiling the {self._model_name} to {self.device} with config {self.ov_config} ... ")
self.compiled_model = core.compile_model(self.model, self.device, self.ov_config)
self.request = self.compiled_model # Deprecated attribute, use compiled_model instead
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can there be a DeprecationWarning when people use self.request, so they know it's deprecated?

@@ -0,0 +1,2 @@
optimum-intel[openvino, nncf]"@git+https://github.com/huggingface/optimum-intel.git
transformers
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
transformers

transformers is a dependency of optimum-intel

return self

def forward(self, *args, **kwargs):
raise NotImplementedError

def clone(self):
self.compile()
model_cloned = self.__class__(self.model, config=self.config, compile=False, dynamic_shapes=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why dynamic_shapes=False?

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.

4 participants