Quacomm AI Engine Direct - Enable FCB feature to Qualcomm HTP - #22521
Quacomm AI Engine Direct - Enable FCB feature to Qualcomm HTP#22521quic-boyuc wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22521
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit b873d9b with merge base c9eee94 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
7de3f79 to
62c95d8
Compare
|
Hi @psiddh, This draft PR supports FCB in QNN ExecuTorch. It is currently under internal review, and we will send it to the community ASAP. |
@quic-boyuc Thanks for all the hard-work. This is great! Also in terms qnn libs that should be present , do we have any limitations in terms of native QNN libs ? (what libs needs to be present on device, since the .pte now supports multiple architectures) |
a0edc1c to
c6ebe28
Compare
Thanks! Yes, this is the phase 1 solution, and PTE contains multiple context binaries for specified multi-SoC.
No additional lib needs to be introduced. Just note that this applies with qnn version 2.48+. We will create another PR to uplevel qnn version in community. |
|
Few conflicts on the PR.. pls resolve. Thanks |
|
Few more questions. the single.pte part is clear... but how abt other artifacts. Readutils.py:321-326, the host/DSP libraries are still staged per HTP arch: unsigned/libQnnHtpV{htp_arch}Skel.so # DSP So for the target set in demo, SM8750 (v79), SM8850 (v81) , afaict. is 1 .pte + 4 Stub/Skel pairs, plus libQnnHtp.so and libQnnSystem.so. Could you confirm or correct that? Specifically:
Thinking aloud here with an example: with a concrete 3-arch example (v73 / v75 / v79). Today we build one bundle per arch : bundle A: model.pte (v73) + libQnnHtpV73Stub.so + libQnnHtpV73Skel.so + libQnnHtp.so + libQnnSystem.so With FCB the model side collapses: 1x model.pte (contexts for v73 + v75 + v79)
did I get this right ?? |
Adds offline FCB export for shipping one ExecuTorch artifact containing QNN HTP
contexts for multiple known Snapdragon SoCs. Requires QNN SDK >= 2.48.
User-facing API
- `generate_qnn_executorch_compiler_spec()` now accepts paired lists:
`soc_model=[...]` and `backend_options=[...]`.
- Supplying two or more distinct HTP targets enables FCB; scalar inputs retain
the existing single-SoC behavior.
- Adds `fcb_reference_weight_sharing=True` by default. It shares referenced
weights while host AOT appends target contexts to the FCB DLC.
- `QnnQuantizer` and `make_quantizer()` accept FCB target lists and validate
against the least-capable requested HTP architecture.
- FCB rejects online preparation, non-HTP targets, mismatched target/options
lists, duplicate SoCs, and DLBC when reference-weight sharing is enabled.
Architecture
- Extends the QNN compiler-spec schema with paired FCB target records and
reference-weight-sharing configuration.
- Creates and caches one QNN manager per `(backend type, SoC)` during lowering.
- Validates operator support against every requested target.
- Reuses the same AOT op-wrapper graph sequentially for each target; graph
registration state is reset after every compile, including failures.
- Adds Python adaptor operations to create an FCB DLC, append each compiled
context, retrieve its bytes, and free the DLC.
- Uses QNN system DLC APIs at runtime to locate the compatible HTP context and
deserialize its graph metadata.
- Adds compiler-spec and manager-lifecycle coverage plus FCB ResNet50 and
multi-SoC weight-sharing examples.
c6ebe28 to
b873d9b
Compare
For AOT compilation, the Skel and Stub libraries are not required. At runtime, the required artifacts depend on the target SoC. You only need to provide the corresponding Stub/Skel pair for the HTP architecture of the device you're running on, together with libQnnHtp.so and libQnnSystem.so, which is the same flow as the existing single-SoC deployment. So, for example, if the application is running on an SM8750 (v79), only the v79 Stub/Skel pair is needed. If it is running on an SM8850 (v81), only the v81 Stub/Skel pair is needed. They can share the same pte with FCB.
Same as the current flow. FCB does not change the Stub/Skel binaries. The runtime still uses the Stub/Skel pair corresponding to the target device's HTP architecture.
It is based on the SoC(s) specified during AOT compilation, not solely on the HTP architecture.
No. FCB does not introduce any new runtime dependency on DLC APIs. The FCB APIs are provided through libQnnSystem.so, which is already a dependency in the existing flow. Since libQnnSystem.so is already required and used today, no additional libraries are needed when enabling FCB.
Yes. For Phase 1, FCB does not change the Stub/Skel requirements.
Yes, that's correct. With FCB, the model side collapses into a single .pte that can contain contexts for multiple target SoCs/HTP architectures. The Stub/Skel requirement remains unchanged and is still determined by the device on which the application is running. At runtime, you use the Stub/Skel pair corresponding to the target device's HTP architecture, together with libQnnHtp.so and libQnnSystem.so. |
QNN Flexible Context Binary (FCB) multi-SoC HTP support
Adds offline FCB export for shipping one ExecuTorch artifact containing QNN HTP
contexts for multiple known Snapdragon SoCs. Requires QNN SDK >= 2.48.
User-facing API
generate_qnn_executorch_compiler_spec()now accepts paired lists:soc_model=[...]andbackend_options=[...].the existing single-SoC behavior.
fcb_reference_weight_sharing=Trueby default. It shares referencedweights while host AOT appends target contexts to the FCB DLC.
QnnQuantizerandmake_quantizer()accept FCB target lists and validateagainst the least-capable requested HTP architecture.
lists, duplicate SoCs, and DLBC when reference-weight sharing is enabled.
Architecture
reference-weight-sharing configuration.
(backend type, SoC)during lowering.registration state is reset after every compile, including failures.
context, retrieve its bytes, and free the DLC.
deserialize its graph metadata.
multi-SoC weight-sharing examples.
Usage
Build the Android runner: