pytorch - 💡(How to fix) Fix C++ compile error when indirect indexing a transposed tensor: transpose_mxn references a tmp variable defined inside of the loop [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#178521Fetched 2026-04-08 01:35:49
View on GitHub
Comments
1
Participants
1
Timeline
10
Reactions
0
Author
Participants
Timeline (top)
labeled ×3subscribed ×3mentioned ×2commented ×1

Error Message

torch._inductor.exc.InductorError: CppCompileError: C++ compile error

Command: g++ /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp -D TORCH_INDUCTOR_CPP_WRAPPER -D STANDALONE_TORCH_HEADER -D TORCH_INDUCTOR_PRECOMPILE_HEADERS -D C10_USING_CUSTOM_GENERATED_MACROS -D CPU_CAPABILITY_AVX512 -O3 -DNDEBUG -fno-trapping-math -funsafe-math-optimizations -ffinite-math-only -fno-signed-zeros -fno-math-errno -fno-finite-math-only -fno-unsafe-math-optimizations -ffp-contract=off -fexcess-precision=fast -fno-tree-loop-vectorize -march=native -shared -fPIC -Wall -std=c++20 -Wno-unused-variable -Wno-unknown-pragmas -pedantic -fopenmp -include /tmp/torchinductor_vscode/precompiled_headers/c3xvd7kstka6ykzeisqbnzxvjp6d2bfdoavpupkltqxvdeilk763.h -I/usr/include/python3.12 -I/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/include -I/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/include/torch/csrc/api/include -mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma -mavx512vnni -mavx512vl -o /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.so -ltorch -ltorch_cpu -ltorch_python -lgomp -L/usr/lib/x86_64-linux-gnu -L/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/lib

Output: /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp: In function ‘void kernel(const int64_t*, const float*, float*)’: /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp:16:142: error: ‘tmp5’ was not declared in this scope; did you mean ‘tmp9’? 16 | transpose_mxn<float,static_cast<int64_t>(16),static_cast<int64_t>(16),false>(in_ptr1 + static_cast<int64_t>(x0 + 16Ltmp5 + 32Lx1), static_cast<int64_t>(32L), tmp9, static_cast<int64_t>(16)); | ^~~~ | tmp9

Root Cause

The issue is that transpose_mxn call references tmp5 that is defined later inside of the loop. As far as I and my LLM can see, this happens because CppTile2DKernel.need_vec_transpose does not consider that index can be SymT.TMP that will be emitted inside of the inner loop (but maybe this issue can be solved on some other level).

Fix Action

Fix / Workaround

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): 128 On-line CPU(s) list: 0-127 Vendor ID: AuthenticAMD Model name: AMD EPYC 9355 32-Core Processor CPU family: 26 Model: 2 Thread(s) per core: 2 Core(s) per socket: 32 Socket(s): 2 Stepping: 1 Frequency boost: enabled CPU(s) scaling MHz: 108% CPU max MHz: 3550.0000 CPU min MHz: 1500.0000 BogoMIPS: 7099.78 Flags: 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 amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid 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 perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc amd_ibpb_ret arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca fsrm avx512_vp2intersect flush_l1d debug_swap Virtualization: AMD-V L1d cache: 3 MiB (64 instances) L1i cache: 2 MiB (64 instances) L2 cache: 64 MiB (64 instances) L3 cache: 512 MiB (16 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-31,64-95 NUMA node1 CPU(s): 32-63,96-127 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; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected

Code Example

import torch


def f(buf, idx):
    return buf[torch.arange(buf.shape[0]), idx, :]

buf = torch.randn(16, 2, 16).permute(2, 1, 0)
idx = torch.randint(0, 2, (16,))

torch.compile(f, backend="inductor")(buf, idx)

---

#include <torch/csrc/inductor/cpp_prefix.h>
extern "C"  void  kernel(const int64_t* in_ptr0,
                       const float* in_ptr1,
                       float* out_ptr0)
{
    {
        for(int64_t x0=static_cast<int64_t>(0L); x0<static_cast<int64_t>(16L); x0+=static_cast<int64_t>(16L))
        {
            for(int64_t x1=static_cast<int64_t>(0L); x1<static_cast<int64_t>(16L); x1+=static_cast<int64_t>(16L))
            {
                {
                    if(C10_LIKELY(x0 >= static_cast<int64_t>(0) && x0 < static_cast<int64_t>(16L) && x1 >= static_cast<int64_t>(0) && x1 < static_cast<int64_t>(16L)))
                    {
                        alignas(std::max(std::size_t(16), alignof(float))) float tmp9[16*16];
                        transpose_mxn<float,static_cast<int64_t>(16),static_cast<int64_t>(16),false>(in_ptr1 + static_cast<int64_t>(x0 + 16L*tmp5 + 32L*x1), static_cast<int64_t>(32L), tmp9, static_cast<int64_t>(16));
                        for (long x0_inner = 0; x0_inner < static_cast<int64_t>(16); x0_inner++)
                        {
                            auto tmp0 = in_ptr0[static_cast<int64_t>(x0 + x0_inner)];
                            auto tmp1 = 2L;
                            auto tmp2 = c10::convert<int64_t>(tmp1);
                            auto tmp3 = int64_t(tmp0 + tmp2);
                            auto tmp4 = tmp0 < 0;
                            auto tmp5 = tmp4 ? tmp3 : tmp0;
                            auto tmp6 = tmp5;
                            auto tmp7 = c10::convert<int64_t>(tmp6);
                            TORCH_CHECK((0 <= tmp7) & (tmp7 < 2L), "index out of bounds: 0 <= tmp7 < 2L");
                            auto tmp10 = at::vec::Vectorized<float>::loadu(tmp9 + static_cast<int64_t>(16L*x0_inner), static_cast<int64_t>(16));
                            tmp10.store(out_ptr0 + static_cast<int64_t>(x1 + 16L*x0 + 16L*x0_inner));
                        }
                    }
                }
            }
        }
    }
}
// ... python bindings are omitted

---

torch._inductor.exc.InductorError: CppCompileError: C++ compile error

Command:
g++ /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp -D TORCH_INDUCTOR_CPP_WRAPPER -D STANDALONE_TORCH_HEADER -D TORCH_INDUCTOR_PRECOMPILE_HEADERS -D C10_USING_CUSTOM_GENERATED_MACROS -D CPU_CAPABILITY_AVX512 -O3 -DNDEBUG -fno-trapping-math -funsafe-math-optimizations -ffinite-math-only -fno-signed-zeros -fno-math-errno -fno-finite-math-only -fno-unsafe-math-optimizations -ffp-contract=off -fexcess-precision=fast -fno-tree-loop-vectorize -march=native -shared -fPIC -Wall -std=c++20 -Wno-unused-variable -Wno-unknown-pragmas -pedantic -fopenmp -include /tmp/torchinductor_vscode/precompiled_headers/c3xvd7kstka6ykzeisqbnzxvjp6d2bfdoavpupkltqxvdeilk763.h -I/usr/include/python3.12 -I/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/include -I/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/include/torch/csrc/api/include -mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma -mavx512vnni -mavx512vl -o /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.so -ltorch -ltorch_cpu -ltorch_python -lgomp -L/usr/lib/x86_64-linux-gnu -L/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/lib

Output:
/tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp: In functionvoid kernel(const int64_t*, const float*, float*):
/tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp:16:142: error: ‘tmp5’ was not declared in this scope; did you mean ‘tmp9’?
   16 |                         transpose_mxn<float,static_cast<int64_t>(16),static_cast<int64_t>(16),false>(in_ptr1 + static_cast<int64_t>(x0 + 16L*tmp5 + 32L*x1), static_cast<int64_t>(32L), tmp9, static_cast<int64_t>(16));
      |                                                                                                                                              ^~~~
      |                                                                                                                                              tmp9

---

Collecting environment information...
PyTorch version: 2.12.0.dev20260326+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.4 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.39

Python version: 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.8.0-94-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA RTX PRO 6000 Blackwell Server Edition
Nvidia driver version: 580.105.08
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

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):                               128
On-line CPU(s) list:                  0-127
Vendor ID:                            AuthenticAMD
Model name:                           AMD EPYC 9355 32-Core Processor
CPU family:                           26
Model:                                2
Thread(s) per core:                   2
Core(s) per socket:                   32
Socket(s):                            2
Stepping:                             1
Frequency boost:                      enabled
CPU(s) scaling MHz:                   108%
CPU max MHz:                          3550.0000
CPU min MHz:                          1500.0000
BogoMIPS:                             7099.78
Flags:                                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 amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid 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 perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc amd_ibpb_ret arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca fsrm avx512_vp2intersect flush_l1d debug_swap
Virtualization:                       AMD-V
L1d cache:                            3 MiB (64 instances)
L1i cache:                            2 MiB (64 instances)
L2 cache:                             64 MiB (64 instances)
L3 cache:                             512 MiB (16 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-31,64-95
NUMA node1 CPU(s):                    32-63,96-127
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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Not affected

Versions of relevant libraries:
[pip3] numpy==2.4.3
[pip3] torch==2.12.0.dev20260326+cpu
[pip3] torchvision==0.26.0.dev20260326+cpu
[conda] Could not collect
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

See the following reproducer:

import torch


def f(buf, idx):
    return buf[torch.arange(buf.shape[0]), idx, :]

buf = torch.randn(16, 2, 16).permute(2, 1, 0)
idx = torch.randint(0, 2, (16,))

torch.compile(f, backend="inductor")(buf, idx)

This generates the following C++ code:

#include <torch/csrc/inductor/cpp_prefix.h>
extern "C"  void  kernel(const int64_t* in_ptr0,
                       const float* in_ptr1,
                       float* out_ptr0)
{
    {
        for(int64_t x0=static_cast<int64_t>(0L); x0<static_cast<int64_t>(16L); x0+=static_cast<int64_t>(16L))
        {
            for(int64_t x1=static_cast<int64_t>(0L); x1<static_cast<int64_t>(16L); x1+=static_cast<int64_t>(16L))
            {
                {
                    if(C10_LIKELY(x0 >= static_cast<int64_t>(0) && x0 < static_cast<int64_t>(16L) && x1 >= static_cast<int64_t>(0) && x1 < static_cast<int64_t>(16L)))
                    {
                        alignas(std::max(std::size_t(16), alignof(float))) float tmp9[16*16];
                        transpose_mxn<float,static_cast<int64_t>(16),static_cast<int64_t>(16),false>(in_ptr1 + static_cast<int64_t>(x0 + 16L*tmp5 + 32L*x1), static_cast<int64_t>(32L), tmp9, static_cast<int64_t>(16));
                        for (long x0_inner = 0; x0_inner < static_cast<int64_t>(16); x0_inner++)
                        {
                            auto tmp0 = in_ptr0[static_cast<int64_t>(x0 + x0_inner)];
                            auto tmp1 = 2L;
                            auto tmp2 = c10::convert<int64_t>(tmp1);
                            auto tmp3 = int64_t(tmp0 + tmp2);
                            auto tmp4 = tmp0 < 0;
                            auto tmp5 = tmp4 ? tmp3 : tmp0;
                            auto tmp6 = tmp5;
                            auto tmp7 = c10::convert<int64_t>(tmp6);
                            TORCH_CHECK((0 <= tmp7) & (tmp7 < 2L), "index out of bounds: 0 <= tmp7 < 2L");
                            auto tmp10 = at::vec::Vectorized<float>::loadu(tmp9 + static_cast<int64_t>(16L*x0_inner), static_cast<int64_t>(16));
                            tmp10.store(out_ptr0 + static_cast<int64_t>(x1 + 16L*x0 + 16L*x0_inner));
                        }
                    }
                }
            }
        }
    }
}
// ... python bindings are omitted

The issue is that transpose_mxn call references tmp5 that is defined later inside of the loop. As far as I and my LLM can see, this happens because CppTile2DKernel.need_vec_transpose does not consider that index can be SymT.TMP that will be emitted inside of the inner loop (but maybe this issue can be solved on some other level).

Error logs

torch._inductor.exc.InductorError: CppCompileError: C++ compile error

Command:
g++ /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp -D TORCH_INDUCTOR_CPP_WRAPPER -D STANDALONE_TORCH_HEADER -D TORCH_INDUCTOR_PRECOMPILE_HEADERS -D C10_USING_CUSTOM_GENERATED_MACROS -D CPU_CAPABILITY_AVX512 -O3 -DNDEBUG -fno-trapping-math -funsafe-math-optimizations -ffinite-math-only -fno-signed-zeros -fno-math-errno -fno-finite-math-only -fno-unsafe-math-optimizations -ffp-contract=off -fexcess-precision=fast -fno-tree-loop-vectorize -march=native -shared -fPIC -Wall -std=c++20 -Wno-unused-variable -Wno-unknown-pragmas -pedantic -fopenmp -include /tmp/torchinductor_vscode/precompiled_headers/c3xvd7kstka6ykzeisqbnzxvjp6d2bfdoavpupkltqxvdeilk763.h -I/usr/include/python3.12 -I/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/include -I/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/include/torch/csrc/api/include -mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma -mavx512vnni -mavx512vl -o /tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.so -ltorch -ltorch_cpu -ltorch_python -lgomp -L/usr/lib/x86_64-linux-gnu -L/workspaces/av/reproducer/venv-nightly/lib/python3.12/site-packages/torch/lib

Output:
/tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp: In function ‘void kernel(const int64_t*, const float*, float*)’:
/tmp/torchinductor_vscode/kc/ckcky6bnqwfoc7y6s4lk7fjtolr6dphcgenbfk36hlhkitkzh524.main.cpp:16:142: error: ‘tmp5’ was not declared in this scope; did you mean ‘tmp9’?
   16 |                         transpose_mxn<float,static_cast<int64_t>(16),static_cast<int64_t>(16),false>(in_ptr1 + static_cast<int64_t>(x0 + 16L*tmp5 + 32L*x1), static_cast<int64_t>(32L), tmp9, static_cast<int64_t>(16));
      |                                                                                                                                              ^~~~
      |                                                                                                                                              tmp9

Full log with a lot of not relevant warnings is attached as a file, as it is too big: reproduce.log

Versions

Collecting environment information...
PyTorch version: 2.12.0.dev20260326+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.4 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.39

Python version: 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.8.0-94-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA RTX PRO 6000 Blackwell Server Edition
Nvidia driver version: 580.105.08
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

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):                               128
On-line CPU(s) list:                  0-127
Vendor ID:                            AuthenticAMD
Model name:                           AMD EPYC 9355 32-Core Processor
CPU family:                           26
Model:                                2
Thread(s) per core:                   2
Core(s) per socket:                   32
Socket(s):                            2
Stepping:                             1
Frequency boost:                      enabled
CPU(s) scaling MHz:                   108%
CPU max MHz:                          3550.0000
CPU min MHz:                          1500.0000
BogoMIPS:                             7099.78
Flags:                                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 amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid 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 perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc amd_ibpb_ret arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq la57 rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca fsrm avx512_vp2intersect flush_l1d debug_swap
Virtualization:                       AMD-V
L1d cache:                            3 MiB (64 instances)
L1i cache:                            2 MiB (64 instances)
L2 cache:                             64 MiB (64 instances)
L3 cache:                             512 MiB (16 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-31,64-95
NUMA node1 CPU(s):                    32-63,96-127
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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Not affected

Versions of relevant libraries:
[pip3] numpy==2.4.3
[pip3] torch==2.12.0.dev20260326+cpu
[pip3] torchvision==0.26.0.dev20260326+cpu
[conda] Could not collect

Reproducible on stable torch versions as well.

cc @chauhang @penguinwu

extent analysis

Fix Plan

The issue arises from the transpose_mxn call referencing tmp5 before it's defined. To fix this, we need to ensure that tmp5 is defined before the transpose_mxn call.

Here are the steps to fix the issue:

  • Identify the line where tmp5 is used before its definition and refactor the code to define tmp5 before its usage.
  • Since tmp5 is defined inside the loop, we need to move the transpose_mxn call inside the loop as well.

Here's an example of how the corrected code might look:

for (long x0_inner = 0; x0_inner < static_cast<int64_t>(16); x0_inner++)
{
    auto tmp0 = in_ptr0[static_cast<int64_t>(x0 + x0_inner)];
    auto tmp1 = 2L;
    auto tmp2 = c10::convert<int64_t>(tmp1);
    auto tmp3 = int64_t(tmp0 + tmp2);
    auto tmp4 = tmp0 < 0;
    auto tmp5 = tmp4 ? tmp3 : tmp0; // tmp5 is defined here
    auto tmp6 = tmp5;
    auto tmp7 = c10::convert<int64_t>(tmp6);
    TORCH_CHECK((0 <= tmp7) & (tmp7 < 2L), "index out of bounds: 0 <= tmp7 < 2L");
    // Move the transpose_mxn call inside the loop
    alignas(std::max(std::size_t(16), alignof(float))) float tmp9[16*16];
    transpose_mxn<float,static_cast<int64_t>(16),static_cast<int64_t>(16),false>(in_ptr1 + static_cast<int64_t>(x0 + 16L*tmp5 + 32L*x1), static_cast<int64_t>(32L), tmp9, static_cast<int64_t>(16));
    auto tmp10 = at::vec::Vectorized<float>::loadu(tmp9 + static_cast<int64_t>(16L*x0_inner), static_cast<int64_t>(16));
    tmp10.store(out_ptr0 + static_cast<int64_t>(x1 + 16L*x0 + 16L*x0_inner));
}

Note that this is just an example and the actual fix may vary depending on the specific requirements of the code.

Verification

To verify that the fix worked, you can recompile the code and check for any errors. If the code compiles successfully, you can then test the functionality to ensure that it produces the expected results.

Extra Tips

  • Always ensure that variables are defined before they are used to avoid compilation errors.
  • When working with complex code, it's essential to break it down into smaller, manageable parts to identify and fix issues efficiently.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING