Repository navigation
Commit 9036d84
authored
Qualcomm AI Engine Direct - Fix a QNN crash on AMD (pytorch#22543)
### 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](pytorch#22395), 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
pytorch#22542.1 parent af6454e commit 9036d84
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
0 commit comments