Skip to content

Qualcomm AI Engine Direct - Fix a QNN crash on AMD - #22543

Open
qti-horodnic wants to merge 1 commit into
pytorch:mainfrom
CodeLinaro:amd_import_fix
Open

Qualcomm AI Engine Direct - Fix a QNN crash on AMD#22543
qti-horodnic wants to merge 1 commit into
pytorch:mainfrom
CodeLinaro:amd_import_fix

Conversation

@qti-horodnic

Copy link
Copy Markdown
Contributor

Summary

Fixed a crash on AMD hosts when PyTorch's global backend flags are frozen.

QnnQuantizer.__init__ calls disable_mkldnn_on_amd(), which assigns torch.backends.mkldnn.enabled = False. PyTorch forbids that assignment once disable_global_flags() has been called, which happens whenever torch.testing._internal.common_utils is imported — as the Qualcomm test suite does. The result is that constructing a quantizer on an AMD host fails with:

RuntimeError: not allowed to set torch.backends.mkldnn flags after disable_global_flags;
please use flags() context manager instead

The assignment is now guarded, so a frozen-flags environment leaves the existing MKLDNN setting in place instead of raising. Disabling MKLDNN is a workaround for AMD-host crashes, not a correctness requirement, so skipping it when the flag is locked is safe.

Note that this is a temporary workaround for an issue introduced in a previous pr, not a root-cause fix, I haven't validated that this change has not broken anything else.

Test plan

Ran the tests mentioned in the test plan section of #22542.

@pytorch-bot

pytorch-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures, 1 Unclassified Failure

As of commit 2053ea8 with merge base 843f77e (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

  • periodic (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 3, 2026
@qti-horodnic

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: qualcomm"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: qualcomm Changes to the Qualcomm backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants