Repository: pytorch
Issue: [ARM] multiple test failures in TestQuantizedConv on Aarch64
Labels: oncall: quantization,module: tests,module: arm

### 🐛 Describe the bug

After enabling 'test_quantization" we consistently see 2 test failures on all Aarch64 platforms.

**TestQuantizedConv.test_qconv2d_relu** and **TestQuantizedConv.test_qconv2d**

```
The failure output is 
AssertionError: 
Arrays are not almost equal to 0 decimals
X: tensor([[[[0.0000, 0.0000, 2.4028,  ..., 0.0000, 0.0000, 3.6042],
... contd..
       size=(1, 54, 10, 7), dtype=torch.quint8,
       quantization_scheme=torch.per_tensor_affine, scale=1.2014017519687867,
       zero_point=0), W: tensor([[[[ 0.0000]],
.... contd...
       quantization_scheme=torch.per_tensor_affine, scale=0.32774215094962955,
       zero_point=0), b: None, strides: (1, 1),
            pads: (0, 0), o_pads: None, dilations: (1, 1),
            groups: 27, y_s: 4.200000005809841, y_zp: 0
Mismatched elements: 23 / 9450 (0.243%)
Max absolute difference: 255
Max relative difference: 255.
 x: array([[[[0, 0, 0, ..., 0, 1, 1],
         [0, 1, 0, ..., 0, 1, 0],
         [0, 0, 0, ..., 1, 1, 0],...
 y: array([[[[0, 0, 0, ..., 0, 0, 0],
         [0, 0, 0, ..., 0, 0, 0],
         [0, 0, 0, ..., 0, 0, 0],...

To execute this test, run the following from the base repo dir:
    python test/quantization/core/test_quantized_op.py TestQuantizedConv.test_qconv2d

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

The assertion is here 
https://github.com/pytorch/pytorch/blob/main/test/quantization/core/test_quantized_op.py#L5182

These tests use hypothesis library and the error doesn't happen for all input combinations, but below is an example of some inputs to test_qconv2d which cause this issue.

```
    W_scale=[1.3],
    W_zero_point=[0],
    X_scale=1.2,
    X_zero_point=0,
    Y_scale=1,
    Y_zero_point=0,
    batch_size=1,
    dilation=1,
    groups=27,
    height=10,
    input_channels_per_group=2,
    kernel_h=1,
    kernel_w=1,
    output_channels_per_group=5,
    pad_h=0,
    pad_w=0,
    stride_h=1,
    stride_w=1,
    width=7):
```

This makes it difficult to reproduce since hypothesis fixes the seed only when CI=1.  Also, the line above
`python test/quantization/core/test_quantized_op.py TestQuantizedConv.test_qconv2d` doesn't work, as 'test_quantized_op.py' doesn't have `an if __name__ == "__main__" `entrypoint. 

I have traced the source of the bug to ideep/oneDNN, but raising this issue here as a reference and to keep track of the fix.



### Versions

Collecting environment information...
PyTorch version: 2.7.0a0+git2e42be0
Is debug build: True
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (aarch64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.31.2
Libc version: glibc-2.35

Python version: 3.10.16 | packaged by conda-forge | (main, Dec  5 2024, 14:08:42) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.8.0-1021-aws-aarch64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                         aarch64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
CPU(s):                               48
On-line CPU(s) list:                  0-47
Vendor ID:                            ARM
Model:                                1
Thread(s) per core:                   1
Core(s) per cluster:                  48
Socket(s):                            -
Cluster(s):                           1
Stepping:                             r1p1
BogoMIPS:                             2100.00
Flags:                                fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm ssbs paca pacg dcpodp svei8mm svebf16 i8mm bf16 dgh rng
L1d cache:                            3 MiB (48 instances)
L1i cache:                            3 MiB (48 instances)
L2 cache:                             48 MiB (48 instances)
L3 cache:                             32 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-47
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; CSV2, BHB
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] mypy==1.13.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.22.4
[pip3] onnx==1.17.0
[pip3] onnxscript==0.1.0.dev20240817
[pip3] optree==0.13.0
[pip3] torch==2.7.0a0+git2e42be0
[conda] No relevant packages

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel @msaroufim @mruberry @ZainRizvi @malfet @snadampal @milpuz01