-
Notifications
You must be signed in to change notification settings - Fork 43
feat: Add option to pass QAICInferenceSession to TextGeneration #356
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: quic-shagun <[email protected]>
) -> None: | ||
self._ctx_len = ctx_len | ||
self._write_io_dir = write_io_dir | ||
self.is_tlm = is_tlm | ||
|
||
# Load QPC | ||
self._session = QAICInferenceSession(qpc_path, device_id, enable_debug_logs=enable_debug_logs) | ||
self._session = ( | ||
session if session else QAICInferenceSession(qpc_path, device_id, enable_debug_logs=enable_debug_logs) |
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.
Can we store this session somewhere while creating it, so we fetch it from the path directly, somewhat like we do for qpc?
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.
I don't understand, session is an object of QAICInferenceSession. I need to pass it as a parameter. How can I get it from a path?
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.
I mean user would not be able to pass this object, so make we make use of object created this time and not have it as a param. Maybe we can make QAICInferenceSession
like a singleton class something like below:
class QAICInferenceSession:
session = None
def __new__(cls, *args, **kwargs):
if not cls.session:
cls.session= super(QAICInferenceSession, cls).__new__(cls)
return `cls.session
@@ -322,6 +322,8 @@ def cloud_ai_100_exec_kv( | |||
automation=False, | |||
prompt_to_lora_id_mapping: Optional[List[int]] = None, | |||
is_tlm: bool = False, | |||
session: Optional[QAICInferenceSession] = None, |
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.
Can we add this same param in latency_stats_bertstyle
function as well so we don't need to create new session there also.
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.
Will add
Every time cloud_ai_100_exec_kv is called, a QAICInferenceSession gets created and the model is loaded. This makes the entire execution very slow from an application point of view.
This PR gives the user the option to create a session once and send it to the TextGeneration class to be reused for every call.