Repository: pytorch
Issue: `out=` dynamo support using `eager` (on CPU) backend.
Labels: triaged,oncall: pt2,module: dynamo

List of operations, whose `out=` variants are not consistent with eager (i.e. run with eager, but fail with dynamo). I have grouped them according to the error each of them raise.

_Note: ~I'm only using CPU, here. Using CUDA seems to generate a different list of operations.~ I have confirmed both CPU and CUDA result in the same set of operations._

**Output Not Contiguous**

- [ ] `cat`
- [ ] `cholesky`
- [ ] `cholesky_inverse`
- [ ] `cholesky_solve`
- [ ] `fft_fft2`
- [ ] `fft_fft`
- [ ] `fft_fftn`
- [ ] `fft_hfft2`
- [ ] `fft_hfft`
- [ ] `fft_hfftn`
- [ ] `fft_ifft2`
- [ ] `fft_ifft`
- [ ] `fft_ifftn`
- [ ] `fft_ihfft2`
- [ ] `fft_ihfft`
- [ ] `fft_ihfftn`
- [ ] `fft_irfft2`
- [ ] `fft_irfft`
- [ ] `fft_irfftn`
- [ ] `fft_rfft2`
- [ ] `fft_rfft`
- [ ] `fft_rfftn`
- [ ] `linalg_cholesky`
- [ ] `linalg_householder_product`
- [ ] `linalg_inv`
- [ ] `linalg_ldl_solve`
- [ ] `linalg_lu_solve`
- [ ] `linalg_matrix_power`
- [ ] `linalg_solve`
- [ ] `linalg_solve_triangular`
- [ ] `linalg_tensorinv`
- [ ] `lu_solve`
- [ ] `ormqr`

<details>
<summary>Error Example</summary>

```python
Traceback (most recent call last):
  File "examples/ops.py", line 134, in run
    f(input, args, kwargs, expected)
  File "torch/_dynamo/eval_frame.py", line 487, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 1350, in __call__
    return self._torchdynamo_orig_callable(
  File "torch/_dynamo/convert_frame.py", line 543, in __call__
    return _compile(
  File "torch/_dynamo/convert_frame.py", line 963, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "torch/_dynamo/convert_frame.py", line 694, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
  File "torch/_utils_internal.py", line 87, in wrapper_function
    return function(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 727, in _compile_inner
    out_code = transform_code_object(code, transform)
  File "torch/_dynamo/bytecode_transformation.py", line 1337, in transform_code_object
    transformations(instructions, code_options)
  File "torch/_dynamo/convert_frame.py", line 228, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 656, in transform
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 2794, in run
    super().run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 938, in call_function
    return self.call_method(tx, "__call__", args, kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 798, in call_method
    return UserMethodVariable(method, self, source=source).call_function(
  File "torch/_dynamo/variables/functions.py", line 401, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 340, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 112, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 849, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3009, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3137, in inline_call_
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/torch.py", line 1016, in call_function
    unimplemented(
  File "torch/_dynamo/exc.py", line 304, in unimplemented
    raise Unsupported(msg, case_name=case_name)
torch._dynamo.exc.Unsupported: out= op was called where output tensor was non-contiguous

from user code:
   File "examples/ops.py", line 129, in op_out
    return op(input, *args, **kwargs, out=out)
  File "torch/testing/_internal/opinfo/core.py", line 1169, in __call__
    return self.op(*args, **kwargs)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/testing/_internal/common_device_type.py", line 1140, in test_wrapper
    return test(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1371, in only_fn
    return fn(slf, *args, **kwargs)
  File "examples/ops.py", line 142, in test_dynamo_out
    raise RuntimeError(f"eager didn't fail, but dynamo did.") from dynamo_err
RuntimeError: eager didn't fail, but dynamo did.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/usr/local/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "torch/testing/_internal/common_utils.py", line 2983, in wrapper
    method(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 448, in instantiated_test
    result = test(self, **param_kwargs)
  File "torch/testing/_internal/common_utils.py", line 1530, in wrapper
    fn(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1152, in test_wrapper
    raise e_tracked from e
Exception: Caused by sample input at index 8: SampleInput(input=TensorList[Tensor[size=(2, 2, 2, 2), device="cpu", dtype=torch.float32, contiguous=False]], args=(1), kwargs={}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=8 python ops.py TestCommonCPU.test_dynamo_out_cat_cpu_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

</details>

**`DynamicOutputShapeException`**

- [ ] `linalg_lstsq`
- [ ] `masked_select`
- [ ] `nonzero`

<details>
<summary>Error Example</summary>

```python
Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
  File "torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1351, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 2017, in _dispatch_impl
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_impls.py", line 268, in dyn_shape
    raise DynamicOutputShapeException(func)
torch._subclasses.fake_tensor.DynamicOutputShapeException: aten.linalg_lstsq.out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 2069, in get_fake_value
    ret_val = wrap_fake_exception(
  File "torch/_dynamo/utils.py", line 1626, in wrap_fake_exception
    return fn()
  File "torch/_dynamo/utils.py", line 2070, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "torch/_dynamo/utils.py", line 2202, in run_node
    raise RuntimeError(make_error_message(e)).with_traceback(
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
  File "torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1351, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 2017, in _dispatch_impl
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_impls.py", line 268, in dyn_shape
    raise DynamicOutputShapeException(func)
RuntimeError: Failed running call_function <built-in function linalg_lstsq>(*(FakeTensor(..., size=(2, 3)), FakeTensor(..., size=(2, 3))), **{'driver': 'gels', 'out': (FakeTensor(..., size=(3, 3)), FakeTensor(..., size=(0,)), FakeTensor(..., size=(0,), dtype=torch.int64), FakeTensor(..., size=(0,)))}):
aten.linalg_lstsq.out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/ops.py", line 134, in run
    f(input, args, kwargs, expected)
  File "torch/_dynamo/eval_frame.py", line 487, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 1350, in __call__
    return self._torchdynamo_orig_callable(
  File "torch/_dynamo/convert_frame.py", line 543, in __call__
    return _compile(
  File "torch/_dynamo/convert_frame.py", line 963, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "torch/_dynamo/convert_frame.py", line 694, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
  File "torch/_utils_internal.py", line 87, in wrapper_function
    return function(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 727, in _compile_inner
    out_code = transform_code_object(code, transform)
  File "torch/_dynamo/bytecode_transformation.py", line 1337, in transform_code_object
    transformations(instructions, code_options)
  File "torch/_dynamo/convert_frame.py", line 228, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 656, in transform
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 2794, in run
    super().run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 938, in call_function
    return self.call_method(tx, "__call__", args, kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 798, in call_method
    return UserMethodVariable(method, self, source=source).call_function(
  File "torch/_dynamo/variables/functions.py", line 401, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 340, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 112, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 849, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3009, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3137, in inline_call_
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/torch.py", line 953, in call_function
    tensor_variable = wrap_fx_proxy(
  File "torch/_dynamo/variables/builder.py", line 2057, in wrap_fx_proxy
    return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)
  File "torch/_dynamo/variables/builder.py", line 2144, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx, allow_non_graph_fake=True)
  File "torch/_dynamo/utils.py", line 2095, in get_fake_value
    unimplemented(
  File "torch/_dynamo/exc.py", line 304, in unimplemented
    raise Unsupported(msg, case_name=case_name)
torch._dynamo.exc.Unsupported: dynamic shape operator: aten.linalg_lstsq.out; Operator does not have a meta kernel that supports dynamic output shapes, please report an issue to PyTorch

from user code:
   File "examples/ops.py", line 129, in op_out
    return op(input, *args, **kwargs, out=out)
  File "torch/testing/_internal/opinfo/core.py", line 1169, in __call__
    return self.op(*args, **kwargs)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/testing/_internal/common_device_type.py", line 1140, in test_wrapper
    return test(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1371, in only_fn
    return fn(slf, *args, **kwargs)
  File "examples/ops.py", line 142, in test_dynamo_out
    raise RuntimeError(f"eager didn't fail, but dynamo did.") from dynamo_err
RuntimeError: eager didn't fail, but dynamo did.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/usr/local/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "torch/testing/_internal/common_utils.py", line 2983, in wrapper
    method(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 448, in instantiated_test
    result = test(self, **param_kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1210, in dep_fn
    return fn(slf, *args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1210, in dep_fn
    return fn(slf, *args, **kwargs)
  File "torch/testing/_internal/common_utils.py", line 1530, in wrapper
    fn(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1152, in test_wrapper
    raise e_tracked from e
Exception: Caused by sample input at index 0: SampleInput(input=Tensor[size=(2, 3), device="cpu", dtype=torch.float32], args=TensorList[Tensor[size=(2, 3), device="cpu", dtype=torch.float32]], kwargs={'driver': "'gels'"}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 python ops.py TestCommonCPU.test_dynamo_out_linalg_lstsq_cpu_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

</details>

**`DataDependentOutputException`**

- [ ] `nanquantile`
- [ ] `quantile`

<details>
<summary>Error Example</summary>

```python
Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
  File "torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1351, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 2017, in _dispatch_impl
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_impls.py", line 517, in data_dep
    raise DataDependentOutputException(func)
torch._subclasses.fake_tensor.DataDependentOutputException: aten.equal.default

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 2069, in get_fake_value
    ret_val = wrap_fake_exception(
  File "torch/_dynamo/utils.py", line 1626, in wrap_fake_exception
    return fn()
  File "torch/_dynamo/utils.py", line 2070, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "torch/_dynamo/utils.py", line 2202, in run_node
    raise RuntimeError(make_error_message(e)).with_traceback(
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
  File "torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1351, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 2017, in _dispatch_impl
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "torch/_subclasses/fake_impls.py", line 517, in data_dep
    raise DataDependentOutputException(func)
RuntimeError: Failed running call_function <built-in method quantile of type object at 0x7f4c7bced0a0>(*(FakeTensor(..., size=()), 0.5), **{'out': FakeTensor(..., size=())}):
aten.equal.default

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/ops.py", line 134, in run
    f(input, args, kwargs, expected)
  File "torch/_dynamo/eval_frame.py", line 487, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 1350, in __call__
    return self._torchdynamo_orig_callable(
  File "torch/_dynamo/convert_frame.py", line 543, in __call__
    return _compile(
  File "torch/_dynamo/convert_frame.py", line 963, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "torch/_dynamo/convert_frame.py", line 694, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
  File "torch/_utils_internal.py", line 87, in wrapper_function
    return function(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 727, in _compile_inner
    out_code = transform_code_object(code, transform)
  File "torch/_dynamo/bytecode_transformation.py", line 1337, in transform_code_object
    transformations(instructions, code_options)
  File "torch/_dynamo/convert_frame.py", line 228, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 656, in transform
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 2794, in run
    super().run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 938, in call_function
    return self.call_method(tx, "__call__", args, kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 798, in call_method
    return UserMethodVariable(method, self, source=source).call_function(
  File "torch/_dynamo/variables/functions.py", line 401, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 340, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 112, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 849, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3009, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3137, in inline_call_
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/torch.py", line 953, in call_function
    tensor_variable = wrap_fx_proxy(
  File "torch/_dynamo/variables/builder.py", line 2057, in wrap_fx_proxy
    return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)
  File "torch/_dynamo/variables/builder.py", line 2144, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx, allow_non_graph_fake=True)
  File "torch/_dynamo/utils.py", line 2082, in get_fake_value
    unimplemented(
  File "torch/_dynamo/exc.py", line 304, in unimplemented
    raise Unsupported(msg, case_name=case_name)
torch._dynamo.exc.Unsupported: data dependent operator: aten.equal.default; to enable, set torch._dynamo.config.capture_scalar_outputs = True

from user code:
   File "examples/ops.py", line 129, in op_out
    return op(input, *args, **kwargs, out=out)
  File "torch/testing/_internal/opinfo/core.py", line 1169, in __call__
    return self.op(*args, **kwargs)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/testing/_internal/common_device_type.py", line 1140, in test_wrapper
    return test(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1371, in only_fn
    return fn(slf, *args, **kwargs)
  File "examples/ops.py", line 142, in test_dynamo_out
    raise RuntimeError(f"eager didn't fail, but dynamo did.") from dynamo_err
RuntimeError: eager didn't fail, but dynamo did.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/usr/local/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "torch/testing/_internal/common_utils.py", line 2983, in wrapper
    method(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 448, in instantiated_test
    result = test(self, **param_kwargs)
  File "torch/testing/_internal/common_utils.py", line 1530, in wrapper
    fn(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1152, in test_wrapper
    raise e_tracked from e
Exception: Caused by sample input at index 0: SampleInput(input=Tensor[size=(), device="cpu", dtype=torch.float32], args=(0.5), kwargs={}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 python ops.py TestCommonCPU.test_dynamo_out_quantile_cpu_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

</details>

**Other Operations**

- [ ] #137780

<details>
<summary>Error Traceback</summary>

```python
Traceback (most recent call last):
  File "examples/ops.py", line 134, in run
    f(input, args, kwargs, expected)
  File "torch/_dynamo/eval_frame.py", line 487, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 1350, in __call__
    return self._torchdynamo_orig_callable(
  File "torch/_dynamo/convert_frame.py", line 543, in __call__
    return _compile(
  File "torch/_dynamo/convert_frame.py", line 963, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "torch/_dynamo/convert_frame.py", line 694, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
  File "torch/_utils_internal.py", line 87, in wrapper_function
    return function(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 727, in _compile_inner
    out_code = transform_code_object(code, transform)
  File "torch/_dynamo/bytecode_transformation.py", line 1337, in transform_code_object
    transformations(instructions, code_options)
  File "torch/_dynamo/convert_frame.py", line 228, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 656, in transform
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 2794, in run
    super().run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 938, in call_function
    return self.call_method(tx, "__call__", args, kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 798, in call_method
    return UserMethodVariable(method, self, source=source).call_function(
  File "torch/_dynamo/variables/functions.py", line 401, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 340, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 112, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 849, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3009, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3137, in inline_call_
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/torch.py", line 953, in call_function
    tensor_variable = wrap_fx_proxy(
  File "torch/_dynamo/variables/builder.py", line 2057, in wrap_fx_proxy
    return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)
  File "torch/_dynamo/variables/builder.py", line 2144, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx, allow_non_graph_fake=True)
  File "torch/_dynamo/utils.py", line 2134, in get_fake_value
    raise TorchRuntimeError(str(e)).with_traceback(e.__traceback__) from None
  File "torch/_dynamo/utils.py", line 2069, in get_fake_value
    ret_val = wrap_fake_exception(
  File "torch/_dynamo/utils.py", line 1626, in wrap_fake_exception
    return fn()
  File "torch/_dynamo/utils.py", line 2070, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "torch/_dynamo/utils.py", line 2202, in run_node
    raise RuntimeError(make_error_message(e)).with_traceback(
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
torch._dynamo.exc.TorchRuntimeError: Failed running call_function <built-in method nanmean of type object at 0x7f7766ced0a0>(*(FakeTensor(..., size=()),), **{'out': FakeTensor(..., size=())}):
Cannot access data pointer of Tensor (e.g. FakeTensor, FunctionalTensor). If you're using torch.compile/export/fx, it is likely that we are erroneously tracing into a custom kernel. To fix this, please wrap the custom kernel into an opaque custom op. Please see the following for details: https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html

from user code:
   File "examples/ops.py", line 129, in op_out
    return op(input, *args, **kwargs, out=out)
  File "torch/testing/_internal/opinfo/core.py", line 1169, in __call__
    return self.op(*args, **kwargs)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/testing/_internal/common_device_type.py", line 1140, in test_wrapper
    return test(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1371, in only_fn
    return fn(slf, *args, **kwargs)
  File "examples/ops.py", line 142, in test_dynamo_out
    raise RuntimeError(f"eager didn't fail, but dynamo did.") from dynamo_err
RuntimeError: eager didn't fail, but dynamo did.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/lib/python3.10/unittest/case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "/usr/local/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
    method()
  File "torch/testing/_internal/common_utils.py", line 2983, in wrapper
    method(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 448, in instantiated_test
    result = test(self, **param_kwargs)
  File "torch/testing/_internal/common_utils.py", line 1530, in wrapper
    fn(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1152, in test_wrapper
    raise e_tracked from e
Exception: Caused by sample input at index 0: SampleInput(input=Tensor[size=(), device="cpu", dtype=torch.float32], args=(), kwargs={}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 python ops.py TestCommonCPU.test_dynamo_out_nanmean_cpu_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

</details>

- [ ] `triangular_solve`

<details>
<summary>Error Traceback</summary>

```python
Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
  File "torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1342, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 2047, in _dispatch_impl
    r = func(*args, **kwargs)
  File "torch/_ops.py", line 723, in __call__
    return self._op(*args, **kwargs)
  File "torch/_decomp/__init__.py", line 101, in _fn
    return f(*args, **kwargs, out=None if is_none else out_kwargs)
  File "torch/_prims_common/wrappers.py", line 289, in _fn
    result = fn(*args, **kwargs)
TypeError: triangular_solve_meta() got an unexpected keyword argument 'X'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/_dynamo/utils.py", line 2069, in get_fake_value
    ret_val = wrap_fake_exception(
  File "torch/_dynamo/utils.py", line 1626, in wrap_fake_exception
    return fn()
  File "torch/_dynamo/utils.py", line 2070, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "torch/_dynamo/utils.py", line 2202, in run_node
    raise RuntimeError(make_error_message(e)).with_traceback(
  File "torch/_dynamo/utils.py", line 2184, in run_node
    return node.target(*args, **kwargs)
  File "torch/utils/_stats.py", line 21, in wrapper
    return fn(*args, **kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1241, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1695, in dispatch
    return self._cached_dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 1342, in _cached_dispatch_impl
    output = self._dispatch_impl(func, types, args, kwargs)
  File "torch/_subclasses/fake_tensor.py", line 2047, in _dispatch_impl
    r = func(*args, **kwargs)
  File "torch/_ops.py", line 723, in __call__
    return self._op(*args, **kwargs)
  File "torch/_decomp/__init__.py", line 101, in _fn
    return f(*args, **kwargs, out=None if is_none else out_kwargs)
  File "torch/_prims_common/wrappers.py", line 289, in _fn
    result = fn(*args, **kwargs)
RuntimeError: Failed running call_function <built-in method triangular_solve of type object at 0x7f010dd740e0>(*(FakeTensor(..., siz
e=(5, 1)), FakeTensor(..., size=(5, 5))), **{'out': (FakeTensor(..., size=(5, 1)), FakeTensor(..., size=(5, 5)))}):
triangular_solve_meta() got an unexpected keyword argument 'X'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/ops.py", line 134, in run
    f(input, args, kwargs, expected)
  File "torch/_dynamo/eval_frame.py", line 487, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 1350, in __call__
    return self._torchdynamo_orig_callable(
  File "torch/_dynamo/convert_frame.py", line 543, in __call__
    return _compile(
  File "torch/_dynamo/convert_frame.py", line 963, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "torch/_dynamo/convert_frame.py", line 694, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
  File "torch/_utils_internal.py", line 87, in wrapper_function
    return function(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 727, in _compile_inner
    out_code = transform_code_object(code, transform)
  File "torch/_dynamo/bytecode_transformation.py", line 1337, in transform_code_object
    transformations(instructions, code_options)
  File "torch/_dynamo/convert_frame.py", line 228, in _fn
    return fn(*args, **kwargs)
  File "torch/_dynamo/convert_frame.py", line 656, in transform
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 2794, in run
    super().run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 938, in call_function
    return self.call_method(tx, "__call__", args, kwargs)
  File "torch/_dynamo/variables/user_defined.py", line 798, in call_method
    return UserMethodVariable(method, self, source=source).call_function(
  File "torch/_dynamo/variables/functions.py", line 401, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 340, in call_function
    return super().call_function(tx, args, kwargs)
  File "torch/_dynamo/variables/functions.py", line 112, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 849, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "torch/_dynamo/symbolic_convert.py", line 3009, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
    File "torch/_dynamo/symbolic_convert.py", line 3137, in inline_call_
    tracer.run()
  File "torch/_dynamo/symbolic_convert.py", line 996, in run
    while self.step():
  File "torch/_dynamo/symbolic_convert.py", line 908, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 614, in wrapper
    return inner_fn(self, inst)
  File "torch/_dynamo/symbolic_convert.py", line 1693, in CALL_FUNCTION_EX
    self.call_function(fn, argsvars.items, kwargsvars)
  File "torch/_dynamo/symbolic_convert.py", line 843, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "torch/_dynamo/variables/lazy.py", line 169, in realize_and_forward
    return getattr(self.realize(), name)(*args, **kwargs)
  File "torch/_dynamo/variables/torch.py", line 953, in call_function
    tensor_variable = wrap_fx_proxy(
  File "torch/_dynamo/variables/builder.py", line 2057, in wrap_fx_proxy
    return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)
  File "torch/_dynamo/variables/builder.py", line 2144, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx, allow_non_graph_fake=True)
  File "torch/_dynamo/utils.py", line 2132, in get_fake_value
    unimplemented(f"TypeError {node.target}: {cause}")
  File "torch/_dynamo/exc.py", line 304, in unimplemented
    raise Unsupported(msg, case_name=case_name)
torch._dynamo.exc.Unsupported: TypeError <built-in method triangular_solve of type object at 0x7f010dd740e0>: triangular_solve_meta() got an unexpected keyword argument 'X'

from user code:
   File "examples/ops.py", line 129, in op_out
    return op(input, *args, **kwargs, out=out)
  File "torch/testing/_internal/opinfo/core.py", line 1169, in __call__
    return self.op(*args, **kwargs)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "torch/testing/_internal/common_device_type.py", line 1140, in test_wrapper
    return test(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1371, in only_fn
    return fn(slf, *args, **kwargs)
  File "examples/ops.py", line 142, in test_dynamo_out
    raise RuntimeError(f"eager didn't fail, but dynamo did.") from dynamo_err
RuntimeError: eager didn't fail, but dynamo did.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/lib/python3.9/unittest/case.py", line 592, in run
    self._callTestMethod(testMethod)
  File "/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
    method()
  File "torch/testing/_internal/common_utils.py", line 2983, in wrapper
    method(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 448, in instantiated_test
    result = test(self, **param_kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1210, in dep_fn
    return fn(slf, *args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1210, in dep_fn
    return fn(slf, *args, **kwargs)
  File "torch/testing/_internal/common_utils.py", line 1530, in wrapper
    fn(*args, **kwargs)
  File "torch/testing/_internal/common_device_type.py", line 1152, in test_wrapper
    raise e_tracked from e
Exception: Caused by sample input at index 0: SampleInput(input=Tensor[size=(5, 1), device="cpu", dtype=torch.float32], args=TensorL
ist[Tensor[size=(5, 5), device="cpu", dtype=torch.float32]], kwargs={}, broadcasts_input=False, name='')

To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 python ops.py TestCommonCPU.test_dynamo_out_triangular_solve_cpu_float32

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
```

</details>

## Test Setup

In order to reproduce these results, besides the actual test below, we needed to make `wrapper_set_seed` function a no-op:

```
--- a/torch/testing/_internal/common_methods_invocations.py
+++ b/torch/testing/_internal/common_methods_invocations.py
@@ -40,8 +40,9 @@ from torch.testing._internal.common_utils import (
     GRADCHECK_NONDET_TOL, slowTest, TEST_WITH_SLOW,
     TEST_WITH_TORCHINDUCTOR
 )
-from torch.testing._utils import wrapper_set_seed
+# from torch.testing._utils import wrapper_set_seed
 
+import torch
 import torch._refs as refs  # noqa: F401
 import torch._refs.nn.functional
 import torch._refs.special
@@ -50,6 +51,9 @@ import torch._prims as prims  # noqa: F401
 from torch.utils import _pytree as pytree
 
 
+def wrapper_set_seed(op, *args, **kwargs):
+    return op(*args, **kwargs)
+
 from packaging import version
 
 from torch.testing._internal.opinfo.core import (  # noqa: F401
-- 
2.47.0
```

<details>
<summary>OpInfo Test</summary>

```python
import torch
import torch.utils._pytree as pytree
from torch.testing._internal.common_methods_invocations import op_db
from torch.testing._internal.common_device_type import ops, instantiate_device_type_tests, OpDTypes, onlyCUDA, onlyCPU
from torch.testing._internal.common_utils import TestCase, run_tests

class TestCommon(TestCase):

    @ops([op for op in op_db if op.supports_out], allowed_dtypes=(torch.float32,))
    def test_dynamo_out(self, device, dtype, op):
        torch._dynamo.config.capture_dynamic_output_shape_ops = True
        torch._dynamo.config.capture_scalar_outputs = True

        fullgraph = True
        backend = "eager"

        samples = list(op.sample_inputs(device, dtype))

        for i, sample in enumerate(samples):
            torch._dynamo.reset()
            input, args, kwargs = (sample.input, sample.args, sample.kwargs)

            # Run the functional version of the operation, using eager.
            try:
                expected = op(input, *args, **kwargs)

                if isinstance(expected, tuple):
                    expected = tuple(expected)
            except:
                # If that doesn't work out, go to the next sample.
                continue

            def op_out(input, args, kwargs, expected):
                # Create the output inside the compiled function, since resizing
                # graph inputs are not allowed.
                out = pytree.tree_map_only(torch.Tensor, lambda t: torch.empty_like(t), expected)
                return op(input, *args, **kwargs, out=out)

            def run(f):
                # Try running the operation, and return the raised error, if any.
                try:
                    f(input, args, kwargs, expected)
                except Exception as e:
                    return e

            eager_err = run(op_out)
            dynamo_err = run(torch.compile(op_out, backend=backend, fullgraph=fullgraph))

            if eager_err is None and dynamo_err is not None:
                raise RuntimeError(f"eager didn't fail, but dynamo did.") from dynamo_err
            elif eager_err is not None and dynamo_err is None:
                raise RuntimeError(f"eager failed, but dynamo didn't.") from eager_err

instantiate_device_type_tests(TestCommon, globals())

if __name__ == "__main__":
    run_tests()
```

</details>

### Versions

PyTorch version: 2.5.0a0+git7128504
Is debug build: True
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

cc @ezyang @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @rec