Skip to content

Qualcomm AI Engine Direct - Move QCOM_AXIS_ORDER pop into LayoutTransform pass - #21932

Open
paul1106 wants to merge 2 commits into
pytorch:mainfrom
CodeLinaro:dev1/boru/layoutTransform-refactor-v2
Open

Qualcomm AI Engine Direct - Move QCOM_AXIS_ORDER pop into LayoutTransform pass#21932
paul1106 wants to merge 2 commits into
pytorch:mainfrom
CodeLinaro:dev1/boru/layoutTransform-refactor-v2

Conversation

@paul1106

@paul1106 paul1106 commented Aug 19, 2026

Copy link
Copy Markdown

Context

This PR supersedes #21630.

The original PR was closed due to CLA issues.
This new PR is created from a new branch to track CLA status and continue the review process.

Please refer to #21630 for previous review comments and discussion.

Summary:

  • The pop of QCOM_AXIS_ORDER was previously done in
    QnnBackend._build_op_wrappers before calling
    transform_for_preprocess_pipeline. Moving it into
    LayoutTransform.call() when insert_permute=True keeps the cleanup
    logic co-located with the code that depends on it.

  • The pop is necessary because the delegated subgraph is created via
    deepcopy, which carries over the QCOM_AXIS_ORDER tags written by the
    to-edge LayoutTransform run. Without clearing them, is_transformed_node()
    returns True for every sensitive node in the
    main for-loop, causing all traversals to be skipped and no permute
    nodes to be inserted.

Test plan

python -m backends.qualcomm.tests.test_qnn_delegate TestQNNQuantizedOperator  --device ${SERIAL_NUM}   --soc_model ${SOC_MODEL}   --build_folder build-android   --executorch_root .

cc @cccclai @winskuo-quic @shewu-quic @haowhsu-quic @DannyYuyang-quic @cbilgin @abhinaykukkadapu @psiddh

…form pass

Summary:
      - The pop of QCOM_AXIS_ORDER was previously done in
      QnnBackend._build_op_wrappers before calling
      transform_for_preprocess_pipeline. Moving it into
      LayoutTransform.call() when insert_permute=True keeps the cleanup
      logic co-located with the code that depends on it.

      The pop is necessary because the delegated subgraph is created via
      deepcopy, which carries over the QCOM_AXIS_ORDER tags written by the
      to-edge LayoutTransform run. Without clearing them, is_transformed_node()
      returns True for every sensitive node in the
      main for-loop, causing all traversals to be skipped and no permute
      nodes to be inserted.
Copilot AI lite review requested due to automatic review settings August 19, 2026 03:35
@pytorch-bot

pytorch-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21932

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 13 Awaiting Approval

As of commit f701d62 with merge base b45e85d (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla

meta-cla Bot commented Aug 19, 2026

Copy link
Copy Markdown

Hi @paul1106!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR relocates cleanup of the QCOM_AXIS_ORDER node metadata from QnnBackend._build_op_wrappers into the LayoutTransform pass itself (specifically when insert_permute=True), so the metadata invalidation happens next to the logic that depends on it. This prevents inherited QCOM_AXIS_ORDER tags (carried via deepcopy) from making LayoutTransform.is_transformed_node() incorrectly treat all sensitive nodes as already-processed, which would otherwise suppress permute insertion during preprocessing.

Changes:

  • Remove the QCOM_AXIS_ORDER metadata pop from backends/qualcomm/qnn_preprocess.py preprocessing entrypoint.
  • Add a targeted QCOM_AXIS_ORDER metadata pop inside LayoutTransform.call() when running the permute-inserting mode (insert_permute=True).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backends/qualcomm/qnn_preprocess.py Removes early QCOM_AXIS_ORDER meta cleanup from _build_op_wrappers, delegating it to the pass that relies on it.
backends/qualcomm/_passes/layout_transform.py Clears inherited QCOM_AXIS_ORDER tags before the main sensitive-node traversal when insert_permute=True, ensuring permute insertion logic executes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paul1106

paul1106 commented Aug 19, 2026

Copy link
Copy Markdown
Author

This PR supersedes #21630.

The original PR was closed due to CLA issues.
This new PR is created from a new branch to track CLA status and continue the review process.

Please refer to #21630 for previous review comments and discussion.

…es_helper

The manual QCOM_AXIS_ORDER strip loop in PassPipeline.lower_preprocess_gm()
was added to mirror qnn_preprocess.py. Now that the pop is handled inside
LayoutTransform.call() when insert_permute=True, this block is dead code.

Generated with Claude Code
Copilot AI review requested due to automatic review settings August 19, 2026 06:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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.

2 participants