Repository: pytorch
Issue: dose "model.so" sharing model's weight with AOT inductor benchmark solutions
Labels: triaged,oncall: pt2,module: aotinductor

### 🐛 Describe the bug

When I run benchmark based on https://pytorch.org/docs/main/torch.compiler_aot_inductor.html, the performance are impacted by the number of process I launched which is not expected

### My model
```
class TwoLayerNet(nn.Module):
    def __init__(self, input_size, hidden_size, output_size):
        super(TwoLayerNet, self).__init__()
        self.fc1 = nn.Linear(input_size, hidden_size)
        self.fc2 = nn.Linear(hidden_size, output_size)

    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x
```


### Repro

https://github.com/zhuhaozhe/Misc/tree/main/aoti-bench-repro

```
bash bench.sh
```
I tested on a system with 6 numa nodes, each numa nodes have 40 cores.
When I only launch 1 process on 1 numanodes:
```
Output:
Throughput: 2.50268e+06
taskset -c 0-39 ./aoti-dir-0/aoti_example 
```
When I only launch 6 process on 6 numanodes:
```
Throughput: 2.3512e+06
Throughput: 2.29224e+06
Throughput: 1.99369e+06
Throughput: 1.95372e+06
Throughput: 1.40744e+06
Throughput: 1.36502e+06
taskset -c 0-39 ./aoti-dir-0/aoti_example  & taskset -c 40-79 ./aoti-dir-1/aoti_example  & taskset -c 80-119 ./aoti-dir-2/aoti_example  & taskset -c 120-159 ./aoti-dir-3/aoti_example  & taskset -c 160-199 ./aoti-dir-4/aoti_example  & taskset -c 200-239 ./aoti-dir-5/aoti_example 
```
The fastest process is nearly 1.73x of the slowest process.
I wander whether it is caused by these process is loading same `model.so` so they impact each others and is there some approach to avoid it?
 - Except to copied model.so, I tried but have not observed differences. Not sure whether the OS still can optimize it since they are exactly same Dynamic-Link Library


```
# bench.sh
export LD_PRELOAD=/localdisk1/haozhe/miniforge3/envs/dlrm/lib/libtcmalloc.so:/localdisk1/haozhe/miniforge3/envs/dlrm/lib/libiomp5.so
python compile_bench.py 6 40 2>&1 | tee 6_40.log
python compile_bench.py 5 40 2>&1 | tee 5_40.log
python compile_bench.py 4 40 2>&1 | tee 4_40.log
python compile_bench.py 3 40 2>&1 | tee 3_40.log
python compile_bench.py 2 40 2>&1 | tee 2_40.log
python compile_bench.py 1 40 2>&1 | tee 1_40.log

```



### Versions

```
python3 collect_env.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 24366  100 24366    0     0  10204      0  0:00:02  0:00:02 --:--:-- 10207
Collecting environment information...
PyTorch version: 2.6.0a0+gitf16e080
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.30.5
Libc version: glibc-2.35

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-5.15.0-125-generic-x86_64-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:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        52 bits physical, 57 bits virtual
Byte Order:                           Little Endian
CPU(s):                               372
On-line CPU(s) list:                  0-371
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) 6984P-C
CPU family:                           6
Model:                                173
Thread(s) per core:                   2
Core(s) per socket:                   93
Socket(s):                            2
Stepping:                             1
CPU max MHz:                          3900.0000
CPU min MHz:                          800.0000
BogoMIPS:                             4400.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 tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            8.7 MiB (186 instances)
L1i cache:                            11.6 MiB (186 instances)
L2 cache:                             372 MiB (186 instances)
L3 cache:                             1008 MiB (2 instances)
NUMA node(s):                         6
NUMA node0 CPU(s):                    0-30,186-216
NUMA node1 CPU(s):                    31-61,217-247
NUMA node2 CPU(s):                    62-92,248-278
NUMA node3 CPU(s):                    93-123,279-309
NUMA node4 CPU(s):                    124-154,310-340
NUMA node5 CPU(s):                    155-185,341-371
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 and seccomp
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS Not affected; BHI BHI_DIS_S
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] intel_extension_for_pytorch==2.6.0+git1e2711c
[pip3] mypy-extensions==1.0.0
[pip3] numpy==2.0.2
[pip3] optree==0.13.1
[pip3] torch==2.6.0a0+gitf16e080
[pip3] torchmetrics==0.11.0
[pip3] torchrec==0.3.2
[pip3] torchsnapshot==0.1.0
[conda] intel-extension-for-pytorch 2.6.0+git1e2711c           dev_0    <develop>
[conda] mkl-include               2025.0.0                 pypi_0    pypi
[conda] mkl-static                2025.0.0                 pypi_0    pypi
[conda] numpy                     2.0.2                    pypi_0    pypi
[conda] optree                    0.13.1                   pypi_0    pypi
[conda] torch                     2.6.0a0+gitf16e080           dev_0    <develop>
[conda] torchmetrics              0.11.0                   pypi_0    pypi
[conda] torchrec                  0.3.2                    pypi_0    pypi
[conda] torchsnapshot             0.1.0                    pypi_0    pypi
```

cc @chauhang @penguinwu @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4 @desertfire @chenyang78