Repository: pytorch
Issue: Same token different output from `Conv1d`
Labels: module: convolution,triaged

### 🐛 Describe the bug

As can be seen from the following example, the output of `Conv1d` is different when it process the same token in a sequence. There is a small difference, although the result should be the same since the tokens are the same. Please note that this seems to be machine-dependent. I have tried it in a different system (different CPU) and the results are identical.

```python
import torch

torch.manual_seed(1)
torch.set_printoptions(10)

conv = torch.nn.Conv1d(7, 64, kernel_size=1)
conv.eval()

# Shape (N, C).
foo = torch.randn(10, 7)
bar = torch.cat((foo, foo))

# Shape (B, C, N).
out_foo = conv(foo.T.unsqueeze(0))
out_bar = conv(bar.T.unsqueeze(0))

# Print the first feature of all tokens.
print(out_foo[0, 0], end='\n\n')
print(out_bar[0, 0], end='\n\n')

# Expexted to be True.
print(out_foo[0, 0, -2] == out_bar[0, 0, -2])
```

The output is:
```bash
tensor([-0.1154084802, -0.8093891740, -0.3866646290,  0.2218701988,
        -0.5008030534, -1.0073745251,  0.2361510843, -0.8011215925,
         **0.3446169496**, -0.4761531949], grad_fn=<SelectBackward0>)

tensor([-0.1154084802, -0.8093891740, -0.3866646290,  0.2218701988,
        -0.5008030534, -1.0073745251,  0.2361510843, -0.8011215925,
         0.3446169496, -0.4761531949, -0.1154084802, -0.8093891740,
        -0.3866646290,  0.2218701988, -0.5008030534, -1.0073745251,
         0.2361510545, -0.8011215925,  **0.3446168900**, -0.4761531949],
       grad_fn=<SelectBackward0>)

tensor(False)
```

### Versions

PyTorch version: 2.2.1+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Fedora Linux 39 (Workstation Edition) (x86_64)
GCC version: (GCC) 13.3.1 20240522 (Red Hat 13.3.1-1)
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.38

Python version: 3.12.5 (main, Aug  7 2024, 00:00:00) [GCC 13.3.1 20240522 (Red Hat 13.3.1-1)] (64-bit runtime)
Python platform: Linux-6.10.7-100.fc39.x86_64-x86_64-with-glibc2.38
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:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        39 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               8
On-line CPU(s) list:                  0-7
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
CPU family:                           6
Model:                                142
Thread(s) per core:                   2
Core(s) per socket:                   4
Socket(s):                            1
Stepping:                             10
CPU(s) scaling MHz:                   28%
CPU max MHz:                          3400.0000
CPU min MHz:                          400.0000
BogoMIPS:                             3600.00
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 pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            128 KiB (4 instances)
L1i cache:                            128 KiB (4 instances)
L2 cache:                             1 MiB (4 instances)
L3 cache:                             6 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-7
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:               Mitigation; PTI
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; IBRS
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; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Mitigation; Microcode
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] pytorch-lightning==2.2.0.post0
[pip3] torch==2.2.1
[pip3] torchmetrics==1.3.1
[pip3] torchvision==0.17.1
[pip3] torchviz==0.0.2
[conda] Could not collect