8000 Internal Assertion Failure with Invalid Arguments in max_pool2d under TorchScript · Issue #155004 · pytorch/pytorch · GitHub
Internal Assertion Failure with Invalid Arguments in max_pool2d under TorchScript #155004
Open
@LiSsHhUuAaIi

Description

@LiSsHhUuAaIi

🐛 Describe the bug

When using torch.nn.functional.max_pool2d in a TorchScript-compiled model (@torch.jit.script_method), passing invalid arguments (like boolean values for padding) triggers an internal assertion failure (INTERNAL_ASSERT) instead of a proper error message. This behavior differs from non-JIT mode.

To Reproduce

import torch

class Model(torch.jit.ScriptModule):
    def __init__(self):
        super().__init__()
        self.kernel_size = 2
        self.stride = 2
        self.padding = False  # Invalid boolean instead of integer

    @torch.jit.script_method
    def forward(self, input):
        return torch.nn.functional.max_pool2d(input, kernel_size = self.kernel_size, stride=self.stride, padding=self.padding)

input = torch.rand([1, 1, 4, 4], dtype=torch.float32)

m = Model() # Triggers INTERNAL_ASSERT
m(input)

Error Message

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    m = Model()
  File "D:\Programs\Python\virtualenvs\torch_code-afvE469o\lib\site-packages\torch\jit\_script.py", line 323, in init_then_script
    ] = torch.jit._recursive.create_script_module(
  File "D:\Programs\Python\virtualenvs\torch_code-afvE469o\lib\site-packages\torch\jit\_recursive.py", line 556, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "D:\Programs\Python\virtualenvs\torch_code-afvE469o\lib\site-packages\torch\jit\_recursive.py", line 629, in create_script_module_impl
    create_methods_and_properties_from_stubs(
  File "D:\Programs\Python\virtualenvs\torch_code-afvE469o\lib\site-packages\torch\jit\_recursive.py", line 465, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(
RuntimeError: isIntList() INTERNAL ASSERT FAILED at "C:\\actions-runner\\_work\\pytorch\\pytorch\\pytorch\\aten\\src\\ATen/core/ivalue_inl.h":1983, please report a bug to PyTorch. Expected IntList but got Int

Versions

Collecting environment information...
PyTorch version: 2.7.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 11
GCC version: Could not collect
Clang version: Could not collect
CMake version: version 4.0.2
Libc version: N/A

Python version: 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.26100-SP0
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:
Name: AMD Ryzen 5 7500F 6-Core Processor
Manufacturer: AuthenticAMD
Family: 107
Architecture: 9
ProcessorType: 3
DeviceID: CPU0
CurrentClockSpeed: 3701
MaxClockSpeed: 3701
L2CacheSize: 6144
L2CacheSpeed: None
Revision: 24834

Versions of relevant libraries:
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.2.4
[pip3] nvidia-cuda-runtime-cu12==12.9.37
[pip3] > [pip3] onnx-coreml==1.3
[pip3] onnx-tf==1.10.0
[pip3] > [pip3] > [pip3] > [pip3] optree==0.15.0
[pip3] pytorch-lightning==2.5.1
[pip3] torch==2.7.0
[pip3] torch-directml==0.2.5.dev240914
[pip3] torch-geometric==2.6.1
[pip3] torch_scatter==2.1.2
[pip3] torch_tensorrt==2.7.0
[pip3] torchani==2.2.4
[pip3] torchao==0.11.0
[pip3] torchaudio==2.7.0
[pip3] torchdata==0.11.0
[pip3] torchfx==0.1.0
[pip3] torchmetrics==1.7.1
[pip3] torchrec==0.1.0
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.18.0
[pip3] torchvision==0.19.1
[pip3] torchviz==0.0.3
[pip3] torchx-nightly==2025.5.28
[pip3] vector-quantize-pytorch==1.22.16
[conda] Could not collect

cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel

Metadata

Metadata

Assignees

No one assigned

    Labels

    oncall: jitAdd this issue/PR to JIT oncall triage queue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0