Repository: pytorch
Issue: _pack_padded_sequence fails in dynamo due to requiring a non-fake 2nd argument
Labels: module: performance,triaged,oncall: pt2,module: dynamo,mlperf

### 🐛 Describe the bug

`_pack_padded_sequence()` op takes a 2nd argument as a tensor of integers. The current implementation fails in dynamo when trying to `get_fake_value()`, because the 2nd argument is converted to a fake tensor.

Repro:
```python
import torch
import torch._dynamo

def fn(x, seq_lens):
    return torch.nn.utils.rnn.pack_padded_sequence(x, seq_lens.tolist(), batch_first=True)

args = [torch.rand((4, 4, 4)), torch.ones([4], dtype=torch.int64)]

fn(*args)
fn_opt = torch._dynamo.optimize("eager")(fn)
fn_opt(*args)
```

Stacktrace:
```python
$ python repro_pack.py
Traceback (most recent call last):
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 1078, in run_node
    return node.target(*args, **kwargs)
  File "/scratch/dberard/dynamo38/pytorch/torch/nn/utils/rnn.py", line 263, in pack_padded_sequence
    _VF._pack_padded_sequence(input, lengths, batch_first)
  File "/scratch/dberard/dynamo38/pytorch/torch/_subclasses/fake_tensor.py", line 916, in __torch_dispatch__
    r = func(*args, **kwargs)
  File "/scratch/dberard/dynamo38/pytorch/torch/_ops.py", line 284, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: 'lengths' argument should be a 1D CPU int64 tensor, but got 1D meta Long tensor

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 1037, in get_fake_value
    return wrap_fake_exception(
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 714, in wrap_fake_exception
    return fn()
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 1038, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 1090, in run_node
    raise RuntimeError(
RuntimeError: Failed running call_function <function pack_padded_sequence at 0x7f86cc82c0d0>(*(FakeTensor(FakeTensor(..., device='meta', size=(4, 4, 4)), cpu), [1, 1, 1, 1]), **{'batch_
first': True}):
'lengths' argument should be a 1D CPU int64 tensor, but got 1D meta Long tensor
(scroll up for backtrace)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "repro_pack.py", line 11, in <module>
    fn_opt(*args)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/eval_frame.py", line 212, in _fn
    return fn(*args, **kwargs)
  File "repro_pack.py", line 5, in fn
    return torch.nn.utils.rnn.pack_padded_sequence(x, seq_lens.tolist(), batch_first=True)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/eval_frame.py", line 333, in catch_errors
    return callback(frame, cache_size, hooks)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/convert_frame.py", line 480, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/convert_frame.py", line 103, in _fn
    return fn(*args, **kwargs)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 94, in time_wrapper
    r = func(*args, **kwargs)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/convert_frame.py", line 339, in _convert_frame_assert
    return _compile(
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/convert_frame.py", line 400, in _compile
    out_code = transform_code_object(code, transform)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/bytecode_transformation.py", line 341, in transform_code_object
    transformations(instructions, code_options)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/convert_frame.py", line 387, in transform
    tracer.run()
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/symbolic_convert.py", line 1684, in run
    super().run()
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/symbolic_convert.py", line 538, in run
    and self.step()
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/symbolic_convert.py", line 501, in step
    getattr(self, inst.opname)(inst)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/symbolic_convert.py", line 307, in wrapper
    return inner_fn(self, inst)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/symbolic_convert.py", line 1015, in CALL_FUNCTION_KW
    self.call_function(fn, args, kwargs)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/symbolic_convert.py", line 435, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/variables/torch.py", line 470, in call_function
    tensor_variable = wrap_fx_proxy(
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/variables/builder.py", line 731, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/variables/builder.py", line 766, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/scratch/dberard/dynamo38/pytorch/torch/_dynamo/utils.py", line 1057, in get_fake_value
    raise TorchRuntimeError() from e
torch._dynamo.exc.TorchRuntimeError:

from user code:
   File "repro_pack.py", line 5, in <graph break in fn>
    return torch.nn.utils.rnn.pack_padded_sequence(x, seq_lens.tolist(), batch_first=True)

Set torch._dynamo.config.verbose=True for more information


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True
```

Failure occurs here: https://github.com/pytorch/pytorch/blob/32e9b29ce92604908bbe6f73796aa17e82b4462f/aten/src/ATen/native/PackedSequence.cpp#L25

### Error logs

_No response_

### Minified repro

_No response_

cc @ezyang @msaroufim @wconstab @bdhirsh @anijain2305 @zou3519 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng @soumith @ngimel