Skip to content

removed platform sdk dependency #540

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

smedhe
Copy link

@smedhe smedhe commented Aug 19, 2025

This PR updates QEff to support QPC generation on systems without the Platform SDK by refactoring the module loading behavior. Users can now compile models and generate QPCs using QEff with only the Apps SDK installed.

Background: Previously, both Apps SDK and Platform SDK were required to compile and generate QPCs using QEff. The goal is to allow QPC generation with only the Apps SDK installed for systems without Ultra cards.
Changes:
Refactored init.py and generation/cloud_infer.py to use lazy loading via importlib for qaicrt and aicapi.
This ensures that Platform SDK-dependent modules are only loaded when explicitly needed, avoiding import errors during initialization and QPC generation.

Copy link
Contributor

@quic-akuruvil quic-akuruvil left a comment

Choose a reason for hiding this comment

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

Please provide a full description of the significance/purpose of this PR.

Signed-off-by: Sharvari Medhe <[email protected]>
Copy link
Contributor

@ochougul ochougul left a comment

Choose a reason for hiding this comment

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

Please test this on a system where apps sdk is not installed the expected behaviour is
if sdk is not installed , qeff works till export, and fails at compile, execute

Comment on lines +24 to +30
if QAICInferenceSession._qaicrt is None:
try:
QAICInferenceSession._qaicrt = importlib.import_module("qaicrt")
except ImportError:
sys.path.append(f"/opt/qti-aic/dev/lib/{platform.machine()}")
QAICInferenceSession._qaicrt = importlib.import_module("qaicrt")
return QAICInferenceSession._qaicrt
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not required to check if the model is already loaded or not.
Python automatically does this.
https://stackoverflow.com/questions/19077381/what-happens-when-a-module-is-imported-twice#:~:text=Nothing%2C%20if%20a%20module%20has,modules%20).

Comment on lines +34 to +40
if QAICInferenceSession._aicapi is None:
try:
QAICInferenceSession._aicapi = importlib.import_module("QAicApi_pb2")
except ImportError:
sys.path.append("/opt/qti-aic/dev/python")
QAICInferenceSession._aicapi = importlib.import_module("QAicApi_pb2")
return QAICInferenceSession._aicapi
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Comment on lines +19 to +20
_qaicrt = None
_aicapi = None
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a good practice to have a module as a class variable. When you remove the dependency of checking if the module in already imported, this is not required.

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