Repository: pytorch
Issue: Test in `test/test_overrides.py` failed with AssertionError
Labels: triaged,module: testing

### 🐛 Describe the bug

When developing on PR #134826, I built the pytorch from the source and ran the test in `test/test_overrides.py`. I got the output below with AssertionError:
```bash
$ python test/test_overrides.py
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F.
======================================================================
FAIL: test_warn_on_invalid_torch_function_tensor_subclass (__main__.TestTorchFunctionWarning)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tywang/Projects/pytorch/torch/testing/_internal/common_utils.py", line 3099, in wrapper
    method(*args, **kwargs)
  File "/home/tywang/Projects/pytorch/test/test_overrides.py", line 1165, in test_warn_on_invalid_torch_function_tensor_subclass
    torch.abs(b)
AssertionError: UserWarning not triggered

To execute this test, run the following from the base repo dir:
    python test/test_overrides.py TestTorchFunctionWarning.test_warn_on_invalid_torch_function_tensor_subclass

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

----------------------------------------------------------------------
Ran 1466 tests in 0.400s

FAILED (failures=1)
```

But if I run that single failed test, it will pass:
```bash
$ python test/test_overrides.py TestTorchFunctionWarning.test_warn_on_invalid_torch_function_tensor_subclass
.
----------------------------------------------------------------------
Ran 1 test in 0.146s

OK

```

### Versions

$ python ./torch/utils/collect_env.py 
Collecting environment information...
PyTorch version: 2.6.0a0+git0f84ba2
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Kali GNU/Linux Rolling (x86_64)
GCC version: (Debian 11.5.0-1) 11.5.0
Clang version: 16.0.6 (27+b1)
CMake version: version 3.31.1
Libc version: glibc-2.40

Python version: 3.9.20 | packaged by conda-forge | (main, Sep 30 2024, 17:49:10)  [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.10.9-amd64-x86_64-with-glibc2.40
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 535.216.01
cuDNN version: Probably one of the following:
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_adv.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_cnn.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_engines_precompiled.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_engines_runtime_compiled.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_graph.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_heuristic.so.9.3.0
/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_ops.so.9.3.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               20
On-line CPU(s) list:                  0-19
Vendor ID:                            GenuineIntel
Model name:                           12th Gen Intel(R) Core(TM) i7-12700K
CPU family:                           6
Model:                                151
Thread(s) per core:                   2
Core(s) per socket:                   12
Socket(s):                            1
Stepping:                             2
CPU(s) scaling MHz:                   95%
CPU max MHz:                          5000.0000
CPU min MHz:                          800.0000
BogoMIPS:                             7219.20
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            512 KiB (12 instances)
L1i cache:                            512 KiB (12 instances)
L2 cache:                             12 MiB (9 instances)
L3 cache:                             25 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-19
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: Mitigation; Clear Register File
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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] mypy==1.11.2
[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] pytorch-triton==3.1.0+cf34004b8a
[pip3] torch==2.6.0a0+git0f84ba2
[conda] magma-cuda121             2.6.1                         1    pytorch
[conda] mkl                       2025.0.0           h901ac74_941    conda-forge
[conda] mkl-include               2025.0.0           hf2ce2f3_941    conda-forge
[conda] numpy                     1.22.4                   pypi_0    pypi
[conda] optree                    0.13.0                   pypi_0    pypi
[conda] pytorch-triton            3.1.0+cf34004b8a          pypi_0    pypi
[conda] torch                     2.6.0a0+git0f84ba2           dev_0    <develop>