🐛 Describe the bug
When enabling the experimental Inductor pass efficient_conv_bn_eval_fx_passes, compiling an FX graph containing a simple torch.nn.functional.batch_norm call fails with an assertion inside efficient_conv_bn_eval_graph_transform_inlined.
The failure occurs because the pass assumes that batch_norm always has 8 positional arguments, but FX graphs may contain the valid 3-argument form:
F.batch_norm(input, running_mean, running_var)
The pass matches the pattern (CallFunctionVarArgs(batch_norm)), passes the extra_check, and then unconditionally asserts len(bn_node.args) == 8, causing a backend crash.
- I'm not sure if this is a bug or it should be something that I need be aware of.
Reproduced Code
from torch.fx import Graph, GraphModule
import torch
from torch._inductor import config as inductor_config
inductor_config.efficient_conv_bn_eval_fx_passes = True
inductor_config.freezing = False # just to be safe for this pass
graph = Graph()
# Create input placeholders
inp = graph.placeholder("input")
mean = graph.placeholder("mean")
var = graph.placeholder("var")
# Create a call_function node for addition
z = graph.call_function(torch.nn.functional.batch_norm, args = (inp, mean, var))
# Create output node
graph.output(z)
# Wrap in a GraphModule
gm = GraphModule({}, graph)
print(gm)
pycode = graph.python_code('self')
print("Transformed python code: ")
print(pycode.src)
gm_compiled = torch.compile(gm, backend = 'inductor')
inp = torch.randn(4, 4) # or cpu
mean = torch.randn(4, )
var = torch.randn(4, )
out = gm_compiled(inp, mean, var)
print(out)
Observed behavior
AssertionError:
File torch/_inductor/fx_passes/efficient_conv_bn_eval.py", line 151, in efficient_conv_bn_eval_graph_transform_inlined
assert len(bn_node.args) == 8
File ".../efficient_conv_bn_eval.py", line 151, in efficient_conv_bn_eval_graph_transform_inlined
assert len(bn_node.args) == 8
BackendCompilerFailed: backend='inductor' raised: AssertionError
Versions
Collecting environment information...
PyTorch version: 2.10.0a0+git694592a
Is debug build: False
CUDA used to build PyTorch: 12.9
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.3 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: 18.1.3 (1ubuntu1)
CMake version: version 4.1.2
Libc version: glibc-2.39
Python version: 3.12.12 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 20:16:04) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.14.0-35-generic-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 12.9.86
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 5090
Nvidia driver version: 575.57.08
cuDNN version: Could not collect
Is XPU available: False
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): 24
On-line CPU(s) list: 0-23
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) Ultra 9 285K
CPU family: 6
Model: 198
Thread(s) per core: 1
Core(s) per socket: 24
Socket(s): 1
Stepping: 2
CPU(s) scaling MHz: 23%
CPU max MHz: 6500.0000
CPU min MHz: 800.0000
BogoMIPS: 7372.80
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 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni lam wbnoinvd 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 bus_lock_detect movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 768 KiB (20 instances)
L1i cache: 1.3 MiB (20 instances)
L2 cache: 40 MiB (12 instances)
L3 cache: 36 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-23
Vulnerability Gather data sampling: Not affected
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: 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; PBRSB-eIBRS Not affected; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Mitigation; IBPB before exit to userspace
Versions of relevant libraries:
[pip3] intel-cmplr-lib-ur==2025.3.1
[pip3] intel-openmp==2025.3.1
[pip3] mkl-include==2025.3.0
[pip3] mkl-static==2025.3.0
[pip3] numpy==2.3.5
[pip3] onemkl-license==2025.3.0
[pip3] optree==0.18.0
[pip3] pytorch-triton==3.5.1+gitbfeb0668
[pip3] tbb==2022.3.0
[pip3] tbb-devel==2022.3.0
[pip3] tcmlib==1.4.1
[pip3] torch==2.10.0a0+git694592a
[pip3] umf==1.0.2
[conda] intel-cmplr-lib-ur 2025.3.1 pypi_0 pypi
[conda] intel-openmp 2025.3.1 pypi_0 pypi
[conda] mkl-include 2025.3.0 pypi_0 pypi
[conda] mkl-static 2025.3.0 pypi_0 pypi
[conda] numpy 2.3.5 pypi_0 pypi
[conda] onemkl-license 2025.3.0 pypi_0 pypi
[conda] optree 0.18.0 pypi_0 pypi
[conda] pytorch-triton 3.5.1+gitbfeb0668 pypi_0 pypi
[conda] tbb 2022.3.0 pypi_0 pypi
[conda] tbb-devel 2022.3.0 pypi_0 pypi
[conda] tcmlib 1.4.1 pypi_0 pypi
[conda] torch 2.10.0a0+git694592a pypi_0 pypi
[conda] umf 1.0.2 pypi_0 pypi
cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @aakhundov @coconutruben @jataylo
🐛 Describe the bug
When enabling the experimental Inductor pass efficient_conv_bn_eval_fx_passes, compiling an FX graph containing a simple torch.nn.functional.batch_norm call fails with an assertion inside efficient_conv_bn_eval_graph_transform_inlined.
The failure occurs because the pass assumes that batch_norm always has 8 positional arguments, but FX graphs may contain the valid 3-argument form:
The pass matches the pattern (CallFunctionVarArgs(batch_norm)), passes the extra_check, and then unconditionally asserts len(bn_node.args) == 8, causing a backend crash.
Reproduced Code
Observed behavior
Versions
Collecting environment information...
PyTorch version: 2.10.0a0+git694592a
Is debug build: False
CUDA used to build PyTorch: 12.9
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.3 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: 18.1.3 (1ubuntu1)
CMake version: version 4.1.2
Libc version: glibc-2.39
Python version: 3.12.12 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 20:16:04) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.14.0-35-generic-x86_64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 12.9.86
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 5090
Nvidia driver version: 575.57.08
cuDNN version: Could not collect
Is XPU available: False
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): 24
On-line CPU(s) list: 0-23
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) Ultra 9 285K
CPU family: 6
Model: 198
Thread(s) per core: 1
Core(s) per socket: 24
Socket(s): 1
Stepping: 2
CPU(s) scaling MHz: 23%
CPU max MHz: 6500.0000
CPU min MHz: 800.0000
BogoMIPS: 7372.80
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 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni lam wbnoinvd 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 bus_lock_detect movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 768 KiB (20 instances)
L1i cache: 1.3 MiB (20 instances)
L2 cache: 40 MiB (12 instances)
L3 cache: 36 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-23
Vulnerability Gather data sampling: Not affected
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: 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; PBRSB-eIBRS Not affected; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Mitigation; IBPB before exit to userspace
Versions of relevant libraries:
[pip3] intel-cmplr-lib-ur==2025.3.1
[pip3] intel-openmp==2025.3.1
[pip3] mkl-include==2025.3.0
[pip3] mkl-static==2025.3.0
[pip3] numpy==2.3.5
[pip3] onemkl-license==2025.3.0
[pip3] optree==0.18.0
[pip3] pytorch-triton==3.5.1+gitbfeb0668
[pip3] tbb==2022.3.0
[pip3] tbb-devel==2022.3.0
[pip3] tcmlib==1.4.1
[pip3] torch==2.10.0a0+git694592a
[pip3] umf==1.0.2
[conda] intel-cmplr-lib-ur 2025.3.1 pypi_0 pypi
[conda] intel-openmp 2025.3.1 pypi_0 pypi
[conda] mkl-include 2025.3.0 pypi_0 pypi
[conda] mkl-static 2025.3.0 pypi_0 pypi
[conda] numpy 2.3.5 pypi_0 pypi
[conda] onemkl-license 2025.3.0 pypi_0 pypi
[conda] optree 0.18.0 pypi_0 pypi
[conda] pytorch-triton 3.5.1+gitbfeb0668 pypi_0 pypi
[conda] tbb 2022.3.0 pypi_0 pypi
[conda] tbb-devel 2022.3.0 pypi_0 pypi
[conda] tcmlib 1.4.1 pypi_0 pypi
[conda] torch 2.10.0a0+git694592a pypi_0 pypi
[conda] umf 1.0.2 pypi_0 pypi
cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @aakhundov @coconutruben @jataylo