Uploaded image for project: 'AI Platform Core Components'
  1. AI Platform Core Components
  2. AIPCC-7279

BatchNorm1d exhibits NaN outputs on GPU due to extreme input values causing numerical instability.

    • Icon: Story Story
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • None
    • PyTorch
    • None
    • PyTorch Sprint 18, PyTorch Sprint 19

          1. 🐛 Describe the bug
          1. code
            ```python
            DEVICE = 'cpu'
            device = DEVICE
            import torch
            from torch.nn import BatchNorm1d, LayerNorm
            torch.manual_seed(42)
            torch.cuda.manual_seed(42)
            input_tensor = torch.linspace(-1e+30, 1e+30, steps=4).reshape(2, 2).to(
            device)
            norm_layer = BatchNorm1d(2).to(device)

      output_bn = torch.alias_copy(norm_layer(input_tensor))

      print(output_bn)
      ```

          1. output
            ```
            cpu:
            tensor([[0., 0.],
            [0., 0.]], grad_fn=<AliasBackward0_copy>)

      gpu:
      tensor([[nan, nan],
      [nan, nan]], device='cuda:0', grad_fn=<AliasBackward0_copy>)

      ```

          1. Versions

      PyTorch version: 2.6.0+cu124
      Is debug build: False
      CUDA used to build PyTorch: 12.4
      ROCM used to build PyTorch: N/A

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

      Python version: 3.10.17 | packaged by conda-forge | (main, Apr 10 2025, 22:19:12) [GCC 13.3.0] (64-bit runtime)
      Python platform: Linux-6.8.12-2-pve-x86_64-with-glibc2.39
      Is CUDA available: True
      CUDA runtime version: Could not collect
      CUDA_MODULE_LOADING set to: LAZY
      GPU models and configuration: GPU 0: NVIDIA A800 80GB PCIe
      Nvidia driver version: 550.54.14
      cuDNN version: Could not collect
      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, 57 bits virtual
      Byte Order: Little Endian
      CPU(s): 128
      On-line CPU(s) list: 0-127
      Vendor ID: GenuineIntel
      Model name: Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz
      CPU family: 6
      Model: 106
      Thread(s) per core: 2
      Core(s) per socket: 32
      Socket(s): 2
      Stepping: 6
      CPU(s) scaling MHz: 100%
      CPU max MHz: 3400.0000
      CPU min MHz: 800.0000
      BogoMIPS: 5200.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 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 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow 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 wbnoinvd dtherm ida arat pln pts vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
      Virtualization: VT-x
      L1d cache: 3 MiB (64 instances)
      L1i cache: 2 MiB (64 instances)
      L2 cache: 80 MiB (64 instances)
      L3 cache: 96 MiB (2 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: Vulnerable: No microcode
      Vulnerability Itlb multihit: Not affected
      Vulnerability L1tf: Not affected
      Vulnerability Mds: Not affected
      Vulnerability Meltdown: Not affected
      Vulnerability Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT vulnerable
      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; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
      Vulnerability Srbds: Not affected
      Vulnerability Tsx async abort: Not affected

      Versions of relevant libraries:
      [pip3] numpy==1.26.4
      [pip3] torch==2.6.0
      [pip3] torchaudio==2.6.0
      [pip3] torchvision==0.21.0
      [pip3] triton==3.2.0
      [conda] numpy 1.26.4 pypi_0 pypi
      [conda] torch 2.6.0 pypi_0 pypi
      [conda] torchaudio 2.6.0 pypi_0 pypi
      [conda] torchvision 0.21.0 pypi_0 pypi
      [conda] triton 3.2.0 pypi_0 pypi

      cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki

              rh-ee-visgoyal Vishal Goyal
              rh-ee-visgoyal Vishal Goyal
              PyTorch Core
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: