Repository: pytorch
Issue: Assigning the weight of the torch.nn.Embedding object to other variables and then performing subsequent operations on it will cause unstable training
Labels: needs reproduction,module: nn,triaged

### 🐛 Describe the bug

def __init__(xxx，xxx）：
    self.ent_embed = torch.nn.Embedding(self.p.num_ent, self.p.embed_dim, padding_idx=None)
     xavier_normal_(self.ent_embed.weight)
def forward(xxx，xxx，xxx):
     entity = self.ent_embed.weight
     sub_entity = torch.index_select(entity, 0, sub).view(-1, 1, 10, 20)
     #some operations on sub_entity
     This operation will result in different training results each time.



### Versions

Collecting environment information...
PyTorch version: 1.13.1+cu116
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: version 3.23.1
Libc version: glibc-2.31

Python version: 3.9.18 (main, Sep 11 2023, 13:41:44)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-152-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3060
GPU 1: NVIDIA GeForce RTX 3060

Nvidia driver version: 535.183.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
架构：           x86_64
CPU 运行模式：   32-bit, 64-bit
字节序：         Little Endian
CPU:             24
在线 CPU 列表：  0-23
每个核的线程数： 2
每个座的核数：   12
座：             1
NUMA 节点：      1
厂商 ID：        AuthenticAMD
CPU 系列：       25
型号：           33
型号名称：       AMD Ryzen 9 5900X 12-Core Processor
步进：           0
CPU MHz：        3572.681
CPU 最大 MHz：   3700.0000
CPU 最小 MHz：   2200.0000
BogoMIPS：       7386.17
虚拟化：         AMD-V
L1d 缓存：       32K
L1i 缓存：       32K
L2 缓存：        512K
L3 缓存：        32768K
NUMA 节点0 CPU： 0-23
标记：           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid afmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] pytorch-lightning==1.9.4
[pip3] torch==1.13.1+cu116
[pip3] torchaudio==0.13.1+cu116
[pip3] torchmetrics==1.4.0
[pip3] torchvision==0.14.1+cu116
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] pytorch-lightning         1.9.4                    pypi_0    pypi
[conda] torch                     1.13.1+cu116             pypi_0    pypi
[conda] torchaudio                0.13.1+cu116             pypi_0    pypi
[conda] torchmetrics              1.4.0                    pypi_0    pypi
[conda] torchvision               0.14.1+cu116             pypi_0    pypi


cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki