Repository: pytorch
Issue: [ARM] - test_quantized_module.py test_lstm_api fails on Aarch64
Labels: oncall: quantization,module: arm

### 🐛 Describe the bug

We are seeing test_lstm_api in test_quantized_module.py fail on Aarch64.  It is currently not enabled in CI - we would like to enable this.

This happens due to change of input dimensions here -https://github.com/pytorch/pytorch/blob/92b9da1fc2b0a834f54f4d97fd4a2402f47bce07/test/quantization/core/test_quantized_module.py#L1758

causes cache miss and implementation falls back to default_lowp_kind. 

```
AIL: test_lstm_api (__main__.TestDynamicQuantizedModule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 2979, in wrapper
    method(*args, **kwargs)
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_quantized.py", line 171, in test_fn
    for qengine in supported_qengines:
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/hypothesis/core.py", line 1145, in wrapped_test
    raise the_error_hypothesis_found
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_quantized.py", line 174, in test_fn
    qfunction(*args, **kwargs)
  File "/var/lib/jenkins/workspace/test/quantization/core/test_quantized_module.py", line 1760, in test_lstm_api
    self.check_eager_serialization(cell_dq, ref_dq, [x])
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_quantization.py", line 674, in check_eager_serialization
    check_outputs(ref_out, load_out)
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_quantization.py", line 667, in check_outputs
    self.assertEqual(ref_out[0], load_out[0])
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 3885, in assertEqual
    raise error_metas.pop()[0].to_error(
AssertionError: Tensor-likes are not close!

Mismatched elements: 1400 / 1400 (100.0%)
Greatest absolute difference: 1.1401878595352173 at index (8, 18, 6) (up to 1e-05 allowed)
Greatest relative difference: 5944.72802734375 at index (4, 4, 6) (up to 1.3e-06 allowed)

To execute this test, run the following from the base repo dir:
    python test/quantization/core/test_quantized_module.py TestDynamicQuantizedModule.test_lstm_api

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

----------------------------------------------------------------------
Ran 46 tests in 45.840s

FAILED (failures=1, skipped=4)
```


Fixed in https://github.com/pytorch/pytorch/pull/135058

### Versions

jenkins@73bf36410487:~/workspace$ python3 collect_env.py
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
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: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

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.5.1
[conda] No relevant packages

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