pytorch / pytorch/TensorRT

🐛 [Bug] torch.ops.aten.remainder.Scalar seems not working with big int

Open
#3,230 3 comments 0 reactions 1 assignee View on GitHub

@apbose is already working on this.

Since Oct 13, 2024.

bug story: Operator Coverage & Converters
Dominant language
Python
Stars
3k
Forks
410
Avg merge
3d 18h
Merged PRs (30d)
78

Description

Bug Description

torch.ops.aten.remainder.Scalar seems to return fmod result when input number is big

To Reproduce

save it and run the script below

import torch
import torch.nn as nn

a = torch.tensor([[5950571286963681280]]).cuda()
example_args = (a,)


class ToyModel(nn.Module):
    def __init__(self):
        super(ToyModel, self).__init__()

    def forward(self, x):
        return torch.remainder(x, 196613)


model = ToyModel().eval().cuda()

with torch.no_grad():
    ep = torch.export.export(model, args=example_args)

from torch_tensorrt.dynamo._compiler import compile as dynamo_compile
from torch_tensorrt import logging as ts_logging

with ts_logging.debug():
    compiled = dynamo_compile(
        exported_program=ep,
        disable_tf32=True,
        inputs=example_args,
        min_block_size=1,
        debug=True,
    )

with torch.no_grad():
    print(compiled(*example_args))

Expected behavior

expected to return result like

tensor([[75722]], device='cuda:0')

however, the printed result is

tensor([[-120891]], device='cuda:0')

my full execution log is
remainder_error.log

Environment

Build information about Torch-TensorRT can be found by turning on debug messages

  • Torch-TensorRT Version (e.g. 1.0.0): 10.1.0
  • PyTorch Version (e.g. 1.0): 2.4.1+cu124
  • CPU Architecture: x86_64
  • OS (e.g., Linux): linux
  • How you installed PyTorch (conda, pip, libtorch, source): pip
  • Build command you used (if compiling from source):
  • Are you using local sources or building from archives:
  • Python version: 3.11.9
  • CUDA version: 12.6
  • GPU models and configuration: nvidia L4
  • Any other relevant information:

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.