Skip to content

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

Copy link
Author

Choose a reason for hiding this comment

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

I have tested it on a system without Apps sdk and export is working fine.

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.

Copy link
Author

Choose a reason for hiding this comment

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

removed the class level variables storing the modules and updated the code.

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