Repository navigation
Qualcomm AI Engine Direct - Adding QNN LPAI island hint via load-time backend options, persistent-binary query, SW6100 registration - #25852
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25852
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: qualcomm" |
|
Thanks, a per-load option read in My main concern is that, as written, this runs in DRAM. The context gets |
|
Please add on-device evidence of what it changes (outputs, memory, latency with and without |
… backend options, persistent-binary query, aspen registration
Thanks for the review @mohankumarkumar. You're right that as written this won't execute in island, this PR only sets I've updated the description to more accurately reflect the pr's content. It adds the per-load option and its propagation into the cache key, so the follow-up memory-type option can use the same path. It also adds the persistent-binary capability query, the If you'd prefer I not merge the option before it has effect on execution, do let me know. |
On-device evidence: SAR2230P, QAIRT 2.52,
I've also updated the description with these results, for reference. |
db06197 to
53dddcb
Compare
Summary
This PR adds the enablement plumbing for LPAI island mode. It does not make execution run in island. It applies the island context config, but
LpaiGraphis unchanged: scratch and persistent memory keep their DDR allocation and memory type, and execute still goes throughlibQnnLpai.so'sgraphExecute. The device log showsLPI lib not loaded. Using non-island eaih managerwith and without the hint. What island execution still needs is listed under "What is still needed" below.A per-session island hint is added as the ExecuTorch load-time backend option
qnn_runtime_lpai_enable_island(bool, default off), passed inLoadBackendOptionsMaptoload_methodand read ininit. A missing key means off; a non-bool value fails the load withInvalidArgument. When set, the LPAI context is created withQNN_LPAI_CONTEXT_SET_CFG_ENABLE_ISLANDfor all graphs in the context. Before this change the config was applied only on the FastRPC path, where island cannot happen, and never in Direct Mode. It is now applied on both paths, and only when requested. Existing FastRPC users therefore no longer get it by default, which is harmless.The delegate cache key now includes the load-time runtime specs (
QnnRuntimeSpecs), so loads of the same .pte with different specs get separate QNN contexts. The follow-up memory-placement option will be added as another field and becomes part of the key automatically.On Hexagon,
QNN_CONTEXT_CONFIG_PERSISTENT_BINARYis now set from theQNN_LPAI_BACKEND_GET_PROP_REQUIRE_PERSISTENT_BINARYbackend property instead of being hardcoded. The query needs QNN API 2.37 or newer; if it is unavailable or fails, it falls back to "required".LpaiContext::MakeConfignow reserves its config vector before taking pointers into it; without this, emitting a custom config on Hexagon could leave a dangling pointer.SW6100 is registered as an LPAI v6 target.
The Direct Mode harness gains a
load_with_optionsIDL entry point with aLOAD_FLAG_*bitmask and a runner flag--lpai_enable_island. The existingloadentry point is kept and is equivalent toload_with_optionswith flags 0.What is still needed for execution in island (follow-up PRs, see roadmap):
Suggested review order:
QnnExecuTorch.h(key),QnnRuntimeSpecs.h(new),QnnExecuTorchBackend.{h,cpp}(spec read and cache key),QnnBackendFactory.{h,cpp},QnnManager.{h,cpp},runtime/backends/CMakeLists.txt.QnnContextCommon.h(protectedGetImplementation()/GetBackend()accessors),LpaiContextCustomConfig.h,lpai/target/LpaiContextCustomConfig.cpp,LpaiContext.{h,cpp}, plus thebackendGetPropertyshim inQnnFunctionInterface.handQnnSdkCompatibility.h.qnn_executorch.idl,qnn_executorch_imp.cpp,QnnExecuTorchIdlWrapper.{h,cpp},qnn_executor_direct_runner.cpp.qc_schema.py,utils.py,test_lpai_soc.py,QnnExecuTorchBackendTest.cpp.Roadmap (LPAI island mode)
This PR is one step in a series to let the QNN LPAI backend run inference in island mode in Direct Mode (ExecuTorch running on the aDSP):
QnnRuntimeSpecs), so all buffers used during execution can be island-resident.load_with_optionshere.Static PD load validation, which real island entry requires, is tracked separately.
Test plan
On SAR2230P with QAIRT 2.52, in a dynamic signed user PD on the aDSP (
--domain_id 0), not a static PD:test_qnn_backend_adaptive_avg_pool2dpasses on Direct Mode, FastRPC LPAI and HTP.--lpai_enable_island, FARF confirms the island config is requested and QNN accepts it at context creation. Execution still uses the non-island path (LPI lib not loaded. Using non-island eaih manager), and output is bit-identical with and without the flag.--domain_id 0), 100 iterations ×2 per case: outputs are bit-identical. Mean execute is 3.43 ms in both cases. Scratch (50,304 B) and persistent (2,524 B) stay DDR. DSP heap differs by 28 B at load.test_lpai_soc.pypasses on the host.IsolatesIslandHintsWithIdenticalSignaturestest is in the Buck targetqnn_delegate_cache_testand has not been run locally.The non-bool rejection path and SW6100 hardware are not tested yet.
This PR was authored with AI assistance.