Qualcomm AI Engine Direct - Pass migration - part 1 - #20738
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20738
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 6af438b with merge base a1eee71 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
a81e2d9 to
c76c3cd
Compare
c76c3cd to
735df03
Compare
|
Hi @psiddh, |
|
@claude review |
|
Claude finished @psiddh's task in 2m 43s —— View job Claude Code Review — Pass migration part 1I focused on the four open review threads from @psiddh plus a couple of adjacent findings. Overall the migration direction is sound; the concerns raised are legitimate and I agree with most of them. 1.
|
|
@zhaoxul-qti can you take a look at the comments above ? |
Sorry, @zhaoxul-qti is currently OoO and should be back this week. He'll take a look at the comments and respond as soon as possible. Thanks for the review! |
735df03 to
fb0c8ee
Compare
|
Hi @psiddh, |
- Add `lift_constant_tensor_pass` after `EdgeProgramManager` completes the given passes. - Refactor the execution phase of Qualcomm‑specific passes and move to `to_edge_transform_and_lower`. - Introduce the `AnnotateGetAttr` pass to ensure quantization attributes are preserved for the `get_attr` node.
fb0c8ee to
6af438b
Compare
Summary
This is part 1 of a series whose goal is to deprecate
to_edge_transform_and_lower_to_qnnand migrate Qualcomm-specific passes from the export pipeline intoto_edge_transform_and_lower.The core change is in
exir/program/_program.py: after theEdgeProgramManagerfinishes runningtransform_passes, we now invokelift_constant_tensor_passon each method'sExportedProgram. Several QNN passes (CanonicalizeConv,ConvertLinearToConv2d, etc.) rewrite constant values and insert newget_attrnodes to store them. Without lifting, these mutated constants are not reflected back into theExportedProgram;lift_constant_tensor_passpromotes theget_attrnodes into placeholders so the modified constants are correctly propagated.Changes
exir/program/_program.py: runlift_constant_tensor_passover every method afteredge_manager.transform(transform_passes)completes.CanonicalizeConvandConvertLinearToConv2dout of the export pipeline (get_export_passes) and into the to-edge transform pipeline.AnnotateGetAttrto repopulateQCOM_QUANT_ATTRSforget_attrnodes. Passes such asI64toI32andLayoutTransformreconstruct theGraphModule(graph_module = super().call(graph_module).graph_module), which drops the quant attributes previously stored onget_attrnode metadata.Test plan
CanonicalizeConvTest cases:
TEST_MATRIX = {TestQNNFloatingPointOperator.test_qnn_backend_conv1d TestQNNFloatingPointOperator.test_qnn_conv1d_batch_norm TestQNNFloatingPointOperator.test_qnn_backend_conv2d TestQNNFloatingPointOperator.test_qnn_backend_conv3d_sequential TestQNNFloatingPointOperator.test_qnn_backend_conv_transpose1d TestQNNFloatingPointOperator.test_qnn_backend_conv_transpose2d TestQNNFloatingPointOperator.test_qnn_backend_conv_transpose3d TestQNNFloatingPointModel.test_qnn_backend_conv1d_relu_log_softmax TestQNNQuantizedOperator.test_qnn_backend_conv1d TestQNNQuantizedOperator.test_qnn_conv1d_batch_norm TestQNNQuantizedOperator.test_qnn_backend_conv2d TestQNNQuantizedOperator.test_qnn_backend_conv3d_sequential TestQNNQuantizedOperator.test_qnn_backend_conv_transpose1d TestQNNQuantizedOperator.test_qnn_backend_conv_transpose2d TestQNNQuantizedOperator.test_qnn_backend_conv_transpose3d TestQNNQuantizedModel.test_qnn_backend_conv1d_relu_log_softmax}Command:
python backends/qualcomm/tests/test_qnn_delegate.py ${TEST_MATRIX} --build_folder build-android/ --host ${HOST_NAME} --device ${DEVICE_ID} --soc_model ${SOC_ID} --seed 1126 --backend htppython -m pytest "backends/qualcomm/tests/rework/passes/test.py::test_canonicalize_conv[htp]" -vpython -m pytest "backends/qualcomm/tests/rework/passes/test.py::test_canonicalize_conv[lpai]" -vConvertLinearToConv2dTest cases:
TEST_MATRIX = {TestQNNFloatingPointOperator.test_qnn_backend_linear TestQNNFloatingPointOperator.test_qnn_backend_linear_to_conv2d TestQNNFloatingPointOperator.test_qnn_backend_linear_shared_weights TestQNNFloatingPointOperator.test_qnn_backend_linear_to_conv2d_shared_weights TestQNNQuantizedOperator.test_qnn_backend_linear TestQNNQuantizedOperator.test_qnn_backend_linear_to_conv2d TestQNNQuantizedOperator.test_qnn_backend_linear_shared_weights TestQNNQuantizedOperator.test_qnn_backend_linear_to_conv2d_shared_weights TestQNNQuantizedOperator.test_qnn_backend_linear_block TestQNNQuantizedOperator.test_qnn_backend_linear_to_conv2d_block TestQNNQuantizedOperator.test_qnn_backend_linear_qat}Command:
python backends/qualcomm/tests/test_qnn_delegate.py ${TEST_MATRIX} --build_folder build-android/ --host ${HOST_NAME} --device ${DEVICE_ID} --soc_model ${SOC_ID} --seed 1126 --backend htppython -m pytest "backends/qualcomm/tests/rework/passes/test.py::test_convert_linear_to_conv2d[htp]" -vpython -m pytest "backends/qualcomm/tests/rework/passes/test.py::test_convert_linear_to_conv2d[lpai]" -vpython -m pytest "backends/qualcomm/tests/rework/htp/op/v68/test.py::test_linear_shared_weights" -vAnnotateGetAttrCommand:
python -m pytest "backends/qualcomm/tests/rework/passes/test.py::test_annotate_get_attr" -v