Repository: pytorch
Issue: Inconsistent `padding_value` rounding decision when using `torch.nn.utils.rnn.pad_sequence` under torch.compile and eager
Labels: module: nn,triaged,module: type promotion,oncall: pt2,module: inductor

### 🐛 Describe the bug

I think this is caused by the inconsistent type casting between torch.compile and eager. 
When `sequences` is a mixed of complex and integer tensors, pad_sequence under torch.compile mode will directly round `padding_value` to 0 but eager mode will keep `padding_value` as -0.7. See below code for details:

```python
import torch

class RNNPadSequence(torch.nn.Module):
  def forward(self, sequences, padding_value=0.):
    return torch.nn.utils.rnn.pad_sequence(sequences, padding_value=padding_value)

model = RNNPadSequence()
compiled = torch.compile(model)

sequences = [torch.tensor([0, 0.4+0.j]), torch.tensor([0], dtype=torch.int32)]
padding_value = -0.7

print(model(sequences,padding_value=padding_value))
'''
tensor([[ 0.0000+0.j,  0.0000+0.j],
        [ 0.4000+0.j, -0.7000+0.j]])
'''
print(compiled(sequences,padding_value=padding_value))
'''
tensor([[0.0000+0.j, 0.0000+0.j],
        [0.4000+0.j, 0.0000+0.j]])
'''
```

Here are two interesting details:
1. If I set the sequences to `[torch.tensor([0.4+0.j]), torch.tensor([0], dtype=torch.int32)]`, both mode will round the padding_value to 0 and output:

```
tensor([[0.4000+0.j, 0.0000+0.j]])
```

2. If I set the first tensor of `sequences` to `float` instead of `complex` (for example, set the sequence to `[torch.tensor([0.4]), torch.tensor([0], dtype=torch.int32)]`), eager mode will work as normal but torch.compile mode will raises the following error:

```
raise BackendCompilerFailed(self.compiler_fn, e) from e
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
LoweringException: AssertionError:
  target: aten.select_scatter.default
  args[0]: TensorBox(StorageBox(
    Pointwise(
      'cpu',
      torch.float32,
      def inner_fn(index):
          i0, i1 = index
          tmp0 = ops.index_expr(i1, torch.int32)
          tmp1 = ops.index_expr(0, torch.int32)
          tmp2 = tmp0 == tmp1
          tmp3 = ops.load(arg0_1, i0)
          tmp4 = ops.constant(-0.7, torch.float32)
          tmp5 = ops.where(tmp2, tmp3, tmp4)
          return tmp5
      ,
      ranges=[2, 2],
      origin_node=select_scatter_default,
      origins=OrderedSet([select_scatter_default, full_default])
    )
  ))
  args[1]: TensorBox(StorageBox(
    Pointwise(
      'cpu',
      torch.int32,
      def inner_fn(index):
          i0 = index
          tmp0 = ops.index_expr(i0, torch.int64)
          tmp1 = ops.index_expr(1, torch.int64)
          tmp2 = tmp0 < tmp1
          tmp3 = ops.load(arg1_1, 0)
          tmp4 = ops.masked(tmp2, tmp3, 0)
          return tmp4
      ,
      ranges=[2],
      origin_node=constant_pad_nd_1,
      origins=OrderedSet([constant_pad_nd_1])
    )
  ))
  args[2]: 1
  args[3]: 1

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information
```


### Versions

[pip3] numpy==1.26.2
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] optree==0.13.1
[pip3] torch==2.5.1
[pip3] triton==3.1.0
[conda] numpy 1.26.2 pypi_0 pypi
[conda] nvidia-cublas-cu12 12.4.5.8 pypi_0 pypi
[conda] nvidia-cuda-cupti-cu12 12.4.127 pypi_0 pypi
[conda] nvidia-cuda-nvrtc-cu12 12.4.127 pypi_0 pypi
[conda] nvidia-cuda-runtime-cu12 12.4.127 pypi_0 pypi
[conda] nvidia-cudnn-cu12 9.1.0.70 pypi_0 pypi
[conda] nvidia-cufft-cu12 11.2.1.3 pypi_0 pypi
[conda] nvidia-curand-cu12 10.3.5.147 pypi_0 pypi
[conda] nvidia-cusolver-cu12 11.6.1.9 pypi_0 pypi
[conda] nvidia-cusparse-cu12 12.3.1.170 pypi_0 pypi
[conda] nvidia-nccl-cu12 2.21.5 pypi_0 pypi
[conda] nvidia-nvjitlink-cu12 12.4.127 pypi_0 pypi
[conda] nvidia-nvtx-cu12 12.4.127 pypi_0 pypi
[conda] optree 0.13.1 pypi_0 pypi
[conda] torch 2.5.1 pypi_0 pypi
[conda] triton 3.1.0 pypi_0 pypi

cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @nairbv @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @aakhundov @ezyang @anjali411 @dylanbespalko @nikitaved