-
Notifications
You must be signed in to change notification settings - Fork 2
feat: load the model once and keep it loaded #82
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
Conversation
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.
Pull Request Overview
This PR refactors the translation service from using a context manager pattern to a persistent model loading approach, improving performance by loading the model once at thread initialization rather than for each translation request.
Key changes:
- Introduced
load_model()method to initialize tokenizer and translator as instance attributes - Removed the
translate_contextcontext manager and its resource cleanup logic - Modified
translate()to use persistentself.tokenizerandself.translatorinstead of context manager resources
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/main.py | Adds call to service.load_model() in the task fetch thread to initialize the model before processing tasks |
| lib/Service.py | Refactors from context manager pattern to persistent model loading with new load_model() method and updated translate() method to use instance attributes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
oleksandr-nc
left a comment
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.
this PR needs to be rebased after a fix for ROCM PR
I was hoping merging this first would have solved this but probably not. |
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
a157e0e to
d676939
Compare
oleksandr-nc
left a comment
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.
changes looks ok (but did not test this, hopes it works good)
|
works on my machine (TM) |
No description provided.