Repository navigation
Qualcomm AI Engine Direct - Allow selective graph loading from multi-graph context - #25189
quic-xiyushi wants to merge 1 commit into
Conversation
|
Hi @quic-xiyushi! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
|
|
@pytorchbot label "release notes: qualcomm" |
This change was authored by Iftekhar Chowdhury (@iftekhar-hc).
Summary
This PR adds a new runtime option,
qnn_runtime_load_method_graph_only(bool). When it is set,initpassesQNN_CONTEXT_CONFIG_ENABLE_GRAPHS={method_name}, so only the loaded method's graph is deserialized from a multi-graph context binary.QNN_PROPERTY_CONTEXT_SUPPORT_CONFIG_ENABLE_GRAPHS(also guarded at compile time).(signature, allocator)key from Isolate cached delegates by Module lifetime (#24462) #24462 by adding a graph name. A context holding every graph is stored with an empty name and serves every method of the Module. A method-only context is stored under its method's name and serves only that method. The existing refcounting and spill-fill groups are unchanged.update_spill_fill_sizewith a list of programs only updated the last program's delegates.QnnDlcManager::Destroy()now frees its logger before the backend implementation is released.--load_method_graph_onlysets the option.--preload_method_indexloads another method, with its own planned memory but the main method's allocator, before the main one.--destroy_preload_after_loadkeeps that method alive until the main one is loaded. This covers destroying a spill-fill group owner while a member is still alive, and destroying the method that created a shared cached delegate.With weight sharing, each method loaded this way keeps its own copy of the shared weights, so the option only helps when one method is resident at a time.
Test results (QNN SDK 2.46.0, on device)
test_qnn_delegate.py(SM8850): 13/13 passed.test_qnn_backend_runtime_option_load_method_graph_only(new)test_qnn_backend_runtime_option_load_method_graph_only_single_graph(new)test_qnn_backend_runtime_option_load_method_graph_only_reload(new)test_qnn_backend_multi_graphstest_qnn_backend_multi_contextstest_qnn_backend_multi_contexts_compositetest_qnn_backend_spill_fill_buffer_size..._load_method_graph_only: only the selected graph is loaded...._single_graph: falls back to the full context...._reload, with multi-context and spill-fill, has four variants:graph_bloads (2 groups);graph_bhits the delegate cache (1 group, shared delegate outlives its creator);graph_bloads (2 groups);graph_bis alive (1 group).Rework (
tests/rework/htp/feature/v{81,79}/test.py -k "load_method_graph_only or multi_graph"): 3/3 passed with 6/6 subtests on both SM8850 and SM8750. The newtest_load_method_graph_onlyruns the same multi-graph, single-graph, group-owner and shared-delegate cases as named subtests, and is skipped on x86.QnnExecuTorchBackendTest(C++): 11/11 passed, including the newFullContextServesEveryMethodandMethodOnlyContextServesOnlyItsMethod.lintrunner -a: no lint issues.