Skip to content

[QNN:Feature] Auto ADSP_LIBRARY_PATH setup and device creation fallback#4584

Open
lanling-47 wants to merge 1 commit into
alibaba:masterfrom
lanling-47:qnn/backend-robustness
Open

[QNN:Feature] Auto ADSP_LIBRARY_PATH setup and device creation fallback#4584
lanling-47 wants to merge 1 commit into
alibaba:masterfrom
lanling-47:qnn/backend-robustness

Conversation

@lanling-47

Copy link
Copy Markdown
Contributor

Summary

Robustness improvements for QNN HTP backend initialization to handle diverse device configurations gracefully.

Changes

1. Auto ADSP_LIBRARY_PATH Setup

  • Detect libQnnHtp.so location at runtime via dladdr
  • Set ADSP_LIBRARY_PATH to prioritize app-bundled skel libraries over system ones
  • Prevents "Skel lib id mismatch" errors caused by stub/skel version conflicts between app-bundled QNN SDK and system-preinstalled libraries

2. Device Creation Fallback

  • When default deviceCreate fails, exhaustively try multiple SOC/Arch/SignedPD combinations:
    • SM8750 (Snapdragon 8 Elite) / HTP v79
    • SM8650 (Snapdragon 8 Gen 3) / HTP v75
    • Both signed and unsigned process domain variants
  • Continue without device handle rather than aborting entirely

3. Runtime Creation Safety

  • Check logHandle and backendHandle are non-null before creating QnnRuntime
  • Warn (but proceed) if deviceHandle is null

4. Minor Cleanup

  • Rename gContext.QnnInterfacegContext.interface for clarity
  • Use __fp16 directly instead of mnn_qnn_fp16_t wrapper
  • CMakeLists: fallback to bundled 3rdParty/ directory for QNN SDK headers when QNN_SDK_ROOT is not set

Testing

Tested on Snapdragon 8 Gen 3 and Snapdragon 8 Elite devices. Verified that ADSP path auto-detection resolves skel mismatch issues and device fallback works when default config fails.

Robustness improvements for QNN HTP backend initialization:

1. Auto ADSP_LIBRARY_PATH:
   - Detect libQnnHtp.so location at runtime via dladdr
   - Set ADSP_LIBRARY_PATH to prioritize app-bundled skel libraries
   - Prevents 'Skel lib id mismatch' errors from system/stub
     version conflicts

2. Device creation fallback:
   - When default deviceCreate fails, try multiple SOC/Arch/SignedPD
     combinations (SM8750/v79, SM8650/v75, signed/unsigned PD)
   - Continue without device handle rather than aborting entirely

3. Runtime creation safety:
   - Check logHandle and backendHandle are non-null before creating
     QnnRuntime
   - Warn (but proceed) if deviceHandle is null

4. Minor cleanup:
   - Rename gContext.QnnInterface -> gContext.interface for clarity
   - Use __fp16 directly instead of mnn_qnn_fp16_t wrapper
   - CMakeLists: fallback to bundled 3rdParty/ for QNN SDK headers
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.

1 participant