참고
Go to the end to download the full example code.
torch.export Tutorial#
Author: William Wen, Zhengxu Chen, Angela Yi, Pian Pawakapan
경고
torch.export and its related features are in prototype status and are subject to backwards compatibility
breaking changes. This tutorial provides a snapshot of torch.export usage as of PyTorch 2.5.
torch.export() is the PyTorch 2.X way to export PyTorch models into
standardized model representations, intended
to be run on different (i.e. Python-less) environments. The official
documentation can be found here.
In this tutorial, you will learn how to use torch.export() to extract
ExportedProgram’s (i.e. single-graph representations) from PyTorch programs.
We also detail some considerations/modifications that you may need
to make in order to make your model compatible with torch.export.
Contents
Basic Usage#
torch.export extracts single-graph representations from PyTorch programs
by tracing the target function, given example inputs.
torch.export.export() is the main entry point for torch.export.
In this tutorial, torch.export and torch.export.export() are practically synonymous,
though torch.export generally refers to the PyTorch 2.X export process, and torch.export.export()
generally refers to the actual function call.
The signature of torch.export.export() is:
export(
mod: torch.nn.Module,
args: Tuple[Any, ...],
kwargs: Optional[Dict[str, Any]] = None,
*,
dynamic_shapes: Optional[Dict[str, Dict[int, Dim]]] = None
) -> ExportedProgram
torch.export.export() traces the tensor computation graph from calling mod(*args, **kwargs)
and wraps it in an ExportedProgram, which can be serialized or executed later with
different inputs. To execute the ExportedProgram we can call .module()
on it to return a torch.nn.Module which is callable, just like the
original program.
We will detail the dynamic_shapes argument later in the tutorial.
import torch
from torch.export import export
class MyModule(torch.nn.Module):
def __init__(self):
super().__init__()
self.lin = torch.nn.Linear(100, 10)
def forward(self, x, y):
return torch.nn.functional.relu(self.lin(x + y), inplace=True)
mod = MyModule()
exported_mod = export(mod, (torch.randn(8, 100), torch.randn(8, 100)))
print(type(exported_mod))
print(exported_mod.module()(torch.randn(8, 100), torch.randn(8, 100)))
<class 'torch.export.exported_program.ExportedProgram'>
tensor([[0.5697, 0.0000, 0.5520, 0.0000, 0.0000, 0.0000, 0.0000, 0.3805, 1.2986,
0.6166],
[0.0000, 0.0000, 0.0000, 0.7790, 0.0000, 1.6360, 0.0000, 0.0000, 0.0000,
0.0000],
[0.0000, 0.0000, 0.4730, 0.0000, 1.4367, 0.0000, 0.0000, 0.7210, 0.0000,
0.6131],
[0.0000, 0.0000, 0.0000, 0.3966, 0.6764, 0.0000, 0.4882, 0.0000, 0.7645,
0.6003],
[0.0000, 0.4958, 0.8105, 0.0000, 0.0000, 0.2007, 0.3920, 0.0000, 1.0997,
0.5876],
[0.4842, 1.1476, 0.6031, 0.0118, 1.2018, 0.1046, 0.0000, 0.0000, 0.2046,
0.2781],
[0.6158, 0.3322, 1.2286, 0.0853, 0.1356, 0.9100, 0.4171, 0.0000, 0.0000,
0.4035],
[0.0000, 0.1702, 1.0550, 0.0000, 1.3246, 0.1930, 0.0000, 0.0000, 0.0000,
0.0000]], grad_fn=<ReluBackward0>)
Let’s review some attributes of ExportedProgram that are of interest.
The graph attribute is an FX graph
traced from the function we exported, that is, the computation graph of all PyTorch operations.
The FX graph is in “ATen IR” meaning that it contains only “ATen-level” operations.
The graph_signature attribute gives a more detailed description of the
input and output nodes in the exported graph, describing which ones are
parameters, buffers, user inputs, or user outputs.
The range_constraints attributes will be covered later.
print(exported_mod)
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, p_lin_weight: "f32[10, 100]", p_lin_bias: "f32[10]", x: "f32[8, 100]", y: "f32[8, 100]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:71 in forward, code: return torch.nn.functional.relu(self.lin(x + y), inplace=True)
add: "f32[8, 100]" = torch.ops.aten.add.Tensor(x, y); x = y = None
# File: /opt/conda/lib/python3.11/site-packages/torch/nn/modules/linear.py:125 in forward, code: return F.linear(input, self.weight, self.bias)
linear: "f32[8, 10]" = torch.ops.aten.linear.default(add, p_lin_weight, p_lin_bias); add = p_lin_weight = p_lin_bias = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:71 in forward, code: return torch.nn.functional.relu(self.lin(x + y), inplace=True)
relu_: "f32[8, 10]" = torch.ops.aten.relu_.default(linear); linear = None
return (relu_,)
Graph signature:
# inputs
p_lin_weight: PARAMETER target='lin.weight'
p_lin_bias: PARAMETER target='lin.bias'
x: USER_INPUT
y: USER_INPUT
# outputs
relu_: USER_OUTPUT
Range constraints: {}
See the torch.export documentation
for more details.
Graph Breaks#
Although torch.export shares components with torch.compile,
the key limitation of torch.export, especially when compared to
torch.compile, is that it does not support graph breaks. This is because
handling graph breaks involves interpreting the unsupported operation with
default Python evaluation, which is incompatible with the export use case.
Therefore, in order to make your model code compatible with torch.export,
you will need to modify your code to remove graph breaks.
A graph break is necessary in cases such as:
data-dependent control flow
class Bad1(torch.nn.Module):
def forward(self, x):
if x.sum() > 0:
return torch.sin(x)
return torch.cos(x)
import traceback as tb
try:
export(Bad1(), (torch.randn(3, 3),))
except Exception:
tb.print_exc()
def forward(self, arg0_1: "f32[3, 3]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:116 in forward, code: if x.sum() > 0:
sum_1: "f32[]" = torch.ops.aten.sum.default(arg0_1); arg0_1 = None
gt: "b8[]" = torch.ops.aten.gt.Scalar(sum_1, 0); sum_1 = None
ne: "b8[]" = torch.ops.aten.ne.Scalar(gt, 0); gt = None
item: "Sym(Eq(u0, 1))" = torch.ops.aten.item.default(ne); ne = item = None
def forward(self, arg0_1: "f32[3, 3]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:116 in forward, code: if x.sum() > 0:
sum_1: "f32[]" = torch.ops.aten.sum.default(arg0_1); arg0_1 = None
gt: "b8[]" = torch.ops.aten.gt.Scalar(sum_1, 0); sum_1 = None
ne: "b8[]" = torch.ops.aten.ne.Scalar(gt, 0); gt = None
item: "Sym(Eq(u0, 1))" = torch.ops.aten.item.default(ne); ne = item = None
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 122, in <module>
export(Bad1(), (torch.randn(3, 3),))
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
^^^^^^^^^^^
File "<string>", line 1, in <lambda>
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 116, in forward
if x.sum() > 0:
^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 538, in guard_bool
r = self.evaluate()
^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
return self.shape_env.evaluate_sym_node(self, size_oblivious)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
return self.evaluate_expr(
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
return self._inner_evaluate_expr(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
return self._evaluate_expr(
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7570, in _evaluate_expr
raise self._make_data_dependent_error(
torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode: Could not guard on data-dependent expression Eq(u0, 1) (unhinted: Eq(u0, 1)). (Size-like symbols: none)
Caused by: (_export/non_strict_utils.py:1051 in __torch_function__)
For more information, run with TORCH_LOGS="dynamic"
For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
The following call raised this error:
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 116, in forward
if x.sum() > 0:
The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.
accessing tensor data with
.data
class Bad2(torch.nn.Module):
def forward(self, x):
x.data[0, 0] = 3
return x
try:
export(Bad2(), (torch.randn(3, 3),))
except Exception:
tb.print_exc()
calling unsupported functions (such as many built-in functions)
class Bad3(torch.nn.Module):
def forward(self, x):
x = x + 1
return x + id(x)
try:
export(Bad3(), (torch.randn(3, 3),))
except Exception:
tb.print_exc()
Non-Strict Export#
To trace the program, torch.export uses TorchDynamo by default, a byte
code analysis engine, to symbolically analyze the Python code and build a
graph based on the results. This analysis allows torch.export to provide
stronger guarantees about safety, but not all Python code is supported,
causing these graph breaks.
To address this issue, in PyTorch 2.3, we introduced a new mode of
exporting called non-strict mode, where we trace through the program using the
Python interpreter executing it exactly as it would in eager mode, allowing us
to skip over unsupported Python features. This is done through adding a
strict=False flag.
Looking at some of the previous examples which resulted in graph breaks:
Calling unsupported functions (such as many built-in functions) traces
through, but in this case, id(x) gets specialized as a constant integer in
the graph. This is because id(x) is not a tensor operation, so the
operation is not recorded in the graph.
class Bad3(torch.nn.Module):
def forward(self, x):
x = x + 1
return x + id(x)
bad3_nonstrict = export(Bad3(), (torch.randn(3, 3),), strict=False)
print(bad3_nonstrict)
print(bad3_nonstrict.module()(torch.ones(3, 3)))
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "f32[3, 3]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:179 in forward, code: x = x + 1
add: "f32[3, 3]" = torch.ops.aten.add.Tensor(x, 1); x = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:180 in forward, code: return x + id(x)
add_1: "f32[3, 3]" = torch.ops.aten.add.Tensor(add, 139699698668784); add = None
return (add_1,)
Graph signature:
# inputs
x: USER_INPUT
# outputs
add_1: USER_OUTPUT
Range constraints: {}
tensor([[1.3970e+14, 1.3970e+14, 1.3970e+14],
[1.3970e+14, 1.3970e+14, 1.3970e+14],
[1.3970e+14, 1.3970e+14, 1.3970e+14]])
However, there are still some features that require rewrites to the original module:
Control Flow Ops#
torch.export actually does support data-dependent control flow.
But these need to be expressed using control flow ops. For example,
we can fix the control flow example above using the cond op, like so:
class Bad1Fixed(torch.nn.Module):
def forward(self, x):
def true_fn(x):
return torch.sin(x)
def false_fn(x):
return torch.cos(x)
return torch.cond(x.sum() > 0, true_fn, false_fn, [x])
exported_bad1_fixed = export(Bad1Fixed(), (torch.randn(3, 3),))
print(exported_bad1_fixed)
print(exported_bad1_fixed.module()(torch.ones(3, 3)))
print(exported_bad1_fixed.module()(-torch.ones(3, 3)))
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "f32[3, 3]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:205 in forward, code: return torch.cond(x.sum() > 0, true_fn, false_fn, [x])
sum_1: "f32[]" = torch.ops.aten.sum.default(x)
gt: "b8[]" = torch.ops.aten.gt.Scalar(sum_1, 0); sum_1 = None
# File: <eval_with_key>.33:9 in forward, code: cond = torch.ops.higher_order.cond(l_args_0_, cond_true_0, cond_false_0, (l_args_3_0_,)); l_args_0_ = cond_true_0 = cond_false_0 = l_args_3_0_ = None
true_graph_0 = self.true_graph_0
false_graph_0 = self.false_graph_0
cond = torch.ops.higher_order.cond(gt, true_graph_0, false_graph_0, (x,)); gt = true_graph_0 = false_graph_0 = x = None
getitem: "f32[3, 3]" = cond[0]; cond = None
return (getitem,)
class true_graph_0(torch.nn.Module):
def forward(self, x: "f32[3, 3]"):
# File: <eval_with_key>.30:6 in forward, code: sin = torch.sin(l_args_3_0__1); l_args_3_0__1 = None
sin: "f32[3, 3]" = torch.ops.aten.sin.default(x); x = None
return (sin,)
class false_graph_0(torch.nn.Module):
def forward(self, x: "f32[3, 3]"):
# File: <eval_with_key>.31:6 in forward, code: cos = torch.cos(l_args_3_0__1); l_args_3_0__1 = None
cos: "f32[3, 3]" = torch.ops.aten.cos.default(x); x = None
return (cos,)
Graph signature:
# inputs
x: USER_INPUT
# outputs
getitem: USER_OUTPUT
Range constraints: {}
tensor([[0.8415, 0.8415, 0.8415],
[0.8415, 0.8415, 0.8415],
[0.8415, 0.8415, 0.8415]])
tensor([[0.5403, 0.5403, 0.5403],
[0.5403, 0.5403, 0.5403],
[0.5403, 0.5403, 0.5403]])
There are limitations to cond that one should be aware of:
The predicate (i.e.
x.sum() > 0) must result in a boolean or a single-element tensor.The operands (i.e.
[x]) must be tensors.The branch function (i.e.
true_fnandfalse_fn) signature must match with the operands and they must both return a single tensor with the same metadata (for example,dtype,shape, etc.).Branch functions cannot mutate input or global variables.
Branch functions cannot access closure variables, except for
selfif the function is defined in the scope of a method.
For more details about cond, check out the cond documentation.
We can also use map, which applies a function across the first dimension
of the first tensor argument.
from torch._higher_order_ops.map import map as torch_map
class MapModule(torch.nn.Module):
def forward(self, xs, y, z):
def body(x, y, z):
return x + y + z
return torch_map(body, xs, y, z)
inps = (torch.ones(6, 4), torch.tensor(5), torch.tensor(4))
exported_map_example = export(MapModule(), inps)
print(exported_map_example)
print(exported_map_example.module()(*inps))
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, xs: "f32[6, 4]", y: "i64[]", z: "i64[]"):
# File: <eval_with_key>.58:9 in forward, code: map_impl = torch.ops.higher_order.map_impl(map_body_0, [l_flat_xs_0_], [l_flat_args_0_, l_flat_args_1_]); map_body_0 = l_flat_xs_0_ = l_flat_args_0_ = l_flat_args_1_ = None
body_graph_0 = self.body_graph_0
map_impl = torch.ops.higher_order.map_impl(body_graph_0, [xs], [y, z]); body_graph_0 = xs = y = z = None
getitem: "f32[6, 4]" = map_impl[0]; map_impl = None
return (getitem,)
class body_graph_0(torch.nn.Module):
def forward(self, xs: "f32[4]", y: "i64[]", z: "i64[]"):
# File: <eval_with_key>.56:5 in forward, code: add = child.add(l_flat_args_0_); child = l_flat_args_0_ = None
add: "f32[4]" = torch.ops.aten.add.Tensor(xs, y); xs = y = None
# File: <eval_with_key>.56:6 in forward, code: add_1 = add.add(l_flat_args_1_); add = l_flat_args_1_ = None
add_1: "f32[4]" = torch.ops.aten.add.Tensor(add, z); add = z = None
return (add_1,)
Graph signature:
# inputs
xs: USER_INPUT
y: USER_INPUT
z: USER_INPUT
# outputs
getitem: USER_OUTPUT
Range constraints: {}
tensor([[10., 10., 10., 10.],
[10., 10., 10., 10.],
[10., 10., 10., 10.],
[10., 10., 10., 10.],
[10., 10., 10., 10.],
[10., 10., 10., 10.]])
Other control flow ops include while_loop, associative_scan, and
scan. For more documentation on each operator, please refer to
this page.
Constraints/Dynamic Shapes#
This section covers dynamic behavior and representation of exported programs. Dynamic behavior is subjective to the particular model being exported, so for the most part of this tutorial, we’ll focus on this particular toy model (with the resulting tensor shapes annotated):
class DynamicModel(torch.nn.Module):
def __init__(self):
super().__init__()
self.l = torch.nn.Linear(5, 3)
def forward(
self,
w: torch.Tensor, # [6, 5]
x: torch.Tensor, # [4]
y: torch.Tensor, # [8, 4]
z: torch.Tensor, # [32]
):
x0 = x + y # [8, 4]
x1 = self.l(w) # [6, 3]
x2 = x0.flatten() # [32]
x3 = x2 + z # [32]
return x1, x3
By default, torch.export produces a static program. One consequence of this is that at runtime,
the program won’t work on inputs with different shapes, even if they’re valid in eager mode.
w = torch.randn(6, 5)
x = torch.randn(4)
y = torch.randn(8, 4)
z = torch.randn(32)
model = DynamicModel()
ep = export(model, (w, x, y, z))
model(w, x, torch.randn(3, 4), torch.randn(12))
try:
ep.module()(w, x, torch.randn(3, 4), torch.randn(12))
except Exception:
tb.print_exc()
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 286, in <module>
ep.module()(w, x, torch.randn(3, 4), torch.randn(12))
File "/opt/conda/lib/python3.11/site-packages/torch/fx/graph_module.py", line 848, in call_wrapped
return self._wrapped_call(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/graph_module.py", line 424, in __call__
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/fx/graph_module.py", line 411, in __call__
return super(self.cls, obj).__call__(*args, **kwargs) # type: ignore[misc]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1879, in _call_impl
return inner()
^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1806, in inner
args_kwargs_result = hook(self, args, kwargs) # type: ignore[misc]
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_unlift.py", line 83, in _check_input_constraints_pre_hook
_check_input_constraints_for_graph(
File "/opt/conda/lib/python3.11/site-packages/torch/_export/utils.py", line 426, in _check_input_constraints_for_graph
_check_symint(
File "/opt/conda/lib/python3.11/site-packages/torch/_export/utils.py", line 390, in _check_symint
raise RuntimeError(
RuntimeError: Expected input at *args[2].shape[0] to be equal to 8, but got 3. If you meant for this dimension to be dynamic, please re-export and specify dynamic_shapes (e.g. with Dim.DYNAMIC)
Basic concepts: symbols and guards#
To enable dynamism, export() provides a dynamic_shapes argument. The easiest way to work with
dynamic shapes is using Dim.AUTO and looking at the program that’s returned. Dynamic behavior is specified
at a input dimension-level; for each input we can specify a tuple of values:
from torch.export.dynamic_shapes import Dim
dynamic_shapes = {
"w": (Dim.AUTO, Dim.AUTO),
"x": (Dim.AUTO,),
"y": (Dim.AUTO, Dim.AUTO),
"z": (Dim.AUTO,),
}
ep = export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
Before we look at the program that’s produced, let’s understand what specifying dynamic_shapes entails,
and how that interacts with export. For every input dimension where a Dim object is specified, a symbol is
allocated,
taking on a range of [2, inf] (why not [0, inf] or [1, inf]? we’ll explain later in the
0/1 specialization section).
Export then runs model tracing, looking at each operation that’s performed by the model. Each individual operation can emit
what’s called “guards”; basically boolean condition that are required to be true for the program to be valid.
When guards involve symbols allocated for input dimensions, the program contains restrictions on what input shapes are valid;
i.e. the program’s dynamic behavior. The symbolic shapes subsystem is the part responsible for taking in all the emitted guards
and producing a final program representation that adheres to all of these guards. Before we see this “final representation” in
an ExportedProgram, let’s look at the guards emitted by the toy model we’re tracing.
Here, each forward input tensor is annotated with the symbol allocated at the start of tracing:
class DynamicModel(torch.nn.Module):
def __init__(self):
super().__init__()
self.l = torch.nn.Linear(5, 3)
def forward(
self,
w: torch.Tensor, # [s0, s1]
x: torch.Tensor, # [s2]
y: torch.Tensor, # [s3, s4]
z: torch.Tensor, # [s5]
):
x0 = x + y # guard: s2 == s4
x1 = self.l(w) # guard: s1 == 5
x2 = x0.flatten() # no guard added here
x3 = x2 + z # guard: s3 * s4 == s5
return x1, x3
Let’s understand each of the operations and the emitted guards:
x0 = x + y: This is an element-wise add with broadcasting, sincexis a 1-d tensor andya 2-d tensor.xis broadcasted along the last dimension ofy, emitting the guards2 == s4.x1 = self.l(w): Callingnn.Linear()performs a matrix multiplication with model parameters. In export, parameters, buffers, and constants are considered program state, which is considered static, and so this is a matmul between a dynamic input (w: [s0, s1]), and a statically-shaped tensor. This emits the guards1 == 5.x2 = x0.flatten(): This call actually doesn’t emit any guards! (at least none relevant to input shapes)x3 = x2 + z:x2has shape[s3*s4]after flattening, and this element-wise add emitss3 * s4 == s5.
Writing all of these guards down and summarizing is almost like a mathematical proof, which is what the symbolic shapes subsystem tries to do! In summary, we can conclude that the program must have the following input shapes to be valid:
w: [s0, 5]x: [s2]y: [s3, s2]z: [s2*s3]
And when we do finally print out the exported program to see our result, those shapes are what we see annotated on the corresponding inputs:
print(ep)
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, p_l_weight: "f32[3, 5]", p_l_bias: "f32[3]", w: "f32[s15, 5]", x: "f32[s77]", y: "f32[s17, s77]", z: "f32[s17*s77]"):
#
sym_size_int_1 = torch.ops.aten.sym_size.int(w, 1)
sym_size_int_2: "Sym(s77)" = torch.ops.aten.sym_size.int(x, 0)
sym_size_int_3: "Sym(s17)" = torch.ops.aten.sym_size.int(y, 0)
sym_size_int_4: "Sym(s77)" = torch.ops.aten.sym_size.int(y, 1)
sym_size_int_5: "Sym(s17*s77)" = torch.ops.aten.sym_size.int(z, 0)
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:268 in forward, code: x0 = x + y # [8, 4]
add: "f32[s17, s77]" = torch.ops.aten.add.Tensor(x, y); x = y = None
#
eq: "Sym(True)" = sym_size_int_2 == sym_size_int_4; sym_size_int_4 = None
_assert_scalar_default = torch.ops.aten._assert_scalar.default(eq, "Runtime assertion failed for expression Eq(s77, s94) on node 'eq'"); eq = _assert_scalar_default = None
eq_1 = sym_size_int_1 == 5; sym_size_int_1 = None
_assert_scalar_default_1 = torch.ops.aten._assert_scalar.default(eq_1, "Runtime assertion failed for expression Eq(s21, 5) on node 'eq_1'"); eq_1 = _assert_scalar_default_1 = None
mul: "Sym(s17*s77)" = sym_size_int_3 * sym_size_int_2; sym_size_int_3 = sym_size_int_2 = None
eq_2: "Sym(True)" = mul == sym_size_int_5; mul = sym_size_int_5 = None
_assert_scalar_default_2 = torch.ops.aten._assert_scalar.default(eq_2, "Runtime assertion failed for expression Eq(s17*s77, s68) on node 'eq_2'"); eq_2 = _assert_scalar_default_2 = None
# File: /opt/conda/lib/python3.11/site-packages/torch/nn/modules/linear.py:125 in forward, code: return F.linear(input, self.weight, self.bias)
linear: "f32[s15, 3]" = torch.ops.aten.linear.default(w, p_l_weight, p_l_bias); w = p_l_weight = p_l_bias = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:270 in forward, code: x2 = x0.flatten() # [32]
flatten: "f32[s17*s77]" = torch.ops.aten.flatten.using_ints(add); add = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:271 in forward, code: x3 = x2 + z # [32]
add_1: "f32[s17*s77]" = torch.ops.aten.add.Tensor(flatten, z); flatten = z = None
return (linear, add_1)
Graph signature:
# inputs
p_l_weight: PARAMETER target='l.weight'
p_l_bias: PARAMETER target='l.bias'
w: USER_INPUT
x: USER_INPUT
y: USER_INPUT
z: USER_INPUT
# outputs
linear: USER_OUTPUT
add_1: USER_OUTPUT
Range constraints: {s15: VR[2, int_oo], s77: VR[2, int_oo], s17: VR[2, int_oo], s17*s77: VR[4, int_oo]}
Another feature to notice is the range_constraints field above, which contains a valid range for each symbol. This isn’t so interesting currently, since this export call doesn’t emit any guards related to symbol bounds and each base symbol has a generic bound, but this will come up later.
So far, because we’ve been exporting this toy model, this experience has not been representative of how hard it typically is to debug dynamic shapes guards & issues. In most cases it isn’t obvious what guards are being emitted, and which operations and parts of user code are responsible. For this toy model we pinpoint the exact lines, and the guards are rather intuitive.
In more complicated cases, a helpful first step is always to enable verbose logging. This can be done either with the environment
variable TORCH_LOGS="+dynamic", or interactively with torch._logging.set_logs(dynamic=10):
torch._logging.set_logs(dynamic=10)
ep = export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
I1004 00:19:47.195000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:19:47.196000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s15 = 6 for L['w'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s15" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.197000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s21 = 5 for L['w'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s21" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:19:47.197000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:19:47.199000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s77 = 4 for L['x'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s77" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.200000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s17 = 8 for L['y'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s17" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.200000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s94 = 4 for L['y'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s94" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.202000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s68 = 32 for L['z'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s68" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:19:47.205000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.206000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.206000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.207000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.208000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.208000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.209000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.209000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.210000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.210000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.212000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:19:47.213000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s77, s94) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s77, s94)"
I1004 00:19:47.214000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s77 (solve) VR[2, int_oo]
V1004 00:19:47.215000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:19:47.220000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s21, 5) [guard added] (_meta_registrations.py:2417 in meta_mm), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s21, 5)"
V1004 00:19:47.220000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I1004 00:19:47.221000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V1004 00:19:47.230000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(Eq(s17*s77, 1)) == False [statically known]
V1004 00:19:47.231000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:19:47.233000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s17*s77, s68) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s17*s77, s68)"
V1004 00:19:47.234000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[4, int_oo] (update)
I1004 00:19:47.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = s17*s77 (solve) VR[4, int_oo]
I1004 00:19:47.239000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:19:47.239000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s15 None
V1004 00:19:47.239000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 None
V1004 00:19:47.239000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s77 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V1004 00:19:47.240000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] s77 None
V1004 00:19:47.241000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] s77 None
V1004 00:19:47.241000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V1004 00:19:47.241000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:19:47.241000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] s17*s77 None
V1004 00:19:47.241000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V1004 00:19:47.241000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
V1004 00:19:47.249000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
V1004 00:19:47.254000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7461] eval 5 [trivial]
This spits out quite a handful, even with this simple toy model. The log lines here have been cut short at front and end to ignore unnecessary info, but looking through the logs we can see the lines relevant to what we described above; e.g. the allocation of symbols:
"""
create_symbol s0 = 6 for L['w'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)
create_symbol s1 = 5 for L['w'].size()[1] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)
runtime_assert True == True [statically known]
create_symbol s2 = 4 for L['x'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)
create_symbol s3 = 8 for L['y'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)
create_symbol s4 = 4 for L['y'].size()[1] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)
create_symbol s5 = 32 for L['z'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)
"""
"\ncreate_symbol s0 = 6 for L['w'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)\ncreate_symbol s1 = 5 for L['w'].size()[1] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)\nruntime_assert True == True [statically known]\ncreate_symbol s2 = 4 for L['x'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)\ncreate_symbol s3 = 8 for L['y'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)\ncreate_symbol s4 = 4 for L['y'].size()[1] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)\ncreate_symbol s5 = 32 for L['z'].size()[0] [2, int_oo] (_dynamo/variables/builder.py:2841 in <lambda>)\n"
The lines with create_symbol show when a new symbol has been allocated, and the logs also identify the tensor variable names and dimensions they’ve been allocated for. In other lines we can also see the guards emitted:
"""
runtime_assert Eq(s2, s4) [guard added] x0 = x + y # output shape: [8, 4] # dynamic_shapes_tutorial.py:16 in forward (_subclasses/fake_impls.py:845 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s2, s4)"
runtime_assert Eq(s1, 5) [guard added] x1 = self.l(w) # [6, 3] # dynamic_shapes_tutorial.py:17 in forward (_meta_registrations.py:2127 in meta_mm), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s1, 5)"
runtime_assert Eq(s2*s3, s5) [guard added] x3 = x2 + z # [32] # dynamic_shapes_tutorial.py:19 in forward (_subclasses/fake_impls.py:845 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s2*s3, s5)"
"""
'\nruntime_assert Eq(s2, s4) [guard added] x0 = x + y # output shape: [8, 4] # dynamic_shapes_tutorial.py:16 in forward (_subclasses/fake_impls.py:845 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s2, s4)"\nruntime_assert Eq(s1, 5) [guard added] x1 = self.l(w) # [6, 3] # dynamic_shapes_tutorial.py:17 in forward (_meta_registrations.py:2127 in meta_mm), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s1, 5)"\nruntime_assert Eq(s2*s3, s5) [guard added] x3 = x2 + z # [32] # dynamic_shapes_tutorial.py:19 in forward (_subclasses/fake_impls.py:845 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s2*s3, s5)"\n'
Next to the [guard added] messages, we also see the responsible user lines of code - luckily here the model is simple enough.
In many real-world cases it’s not so straightforward: high-level torch operations can have complicated fake-kernel implementations
or operator decompositions that complicate where and what guards are emitted. In such cases the best way to dig deeper and investigate
is to follow the logs’ suggestion, and re-run with environment variable TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="...", to further
attribute the guard of interest.
Dim.AUTO is just one of the available options for interacting with dynamic_shapes; as of writing this 2 other options are available:
Dim.DYNAMIC, and Dim.STATIC. Dim.STATIC simply marks a dimension static, while Dim.DYNAMIC is similar to Dim.AUTO in all
ways except one: it raises an error when specializing to a constant; this is designed to maintain dynamism. See for example what happens when a
static guard is emitted on a dynamically-marked dimension:
dynamic_shapes["w"] = (Dim.AUTO, Dim.DYNAMIC)
try:
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
except Exception:
tb.print_exc()
I1004 00:19:47.258000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:19:47.259000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s15 = 6 for L['w'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s15" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.259000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s21 = 5 for L['w'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s21" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:19:47.260000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:19:47.261000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s77 = 4 for L['x'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s77" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.262000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s17 = 8 for L['y'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s17" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.262000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s94 = 4 for L['y'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s94" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:19:47.264000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s68 = 32 for L['z'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s68" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:19:47.267000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.268000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.268000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.269000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.269000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.270000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.271000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.271000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.272000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.272000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:19:47.274000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:19:47.275000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s77, s94) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s77, s94)"
I1004 00:19:47.276000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s77 (solve) VR[2, int_oo]
V1004 00:19:47.277000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:19:47.281000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s21, 5) [guard added] (_meta_registrations.py:2417 in meta_mm), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s21, 5)"
V1004 00:19:47.282000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I1004 00:19:47.282000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V1004 00:19:47.292000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(Eq(s17*s77, 1)) == False [statically known]
V1004 00:19:47.293000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:19:47.295000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s17*s77, s68) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s17*s77, s68)"
V1004 00:19:47.296000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[4, int_oo] (update)
I1004 00:19:47.297000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = s17*s77 (solve) VR[4, int_oo]
I1004 00:19:47.300000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:19:47.301000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s15 None
V1004 00:19:47.301000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 RelaxedUnspecConstraint(warn_only=False)
V1004 00:20:20.110000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V1004 00:20:20.111000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V1004 00:20:20.112000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V1004 00:20:20.113000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s77 None
V1004 00:20:20.114000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V1004 00:20:20.114000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.115000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V1004 00:20:20.115000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] s77 None
V1004 00:20:20.116000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] s77 None
V1004 00:20:20.117000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V1004 00:20:20.117000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:20:20.118000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] s17*s77 None
V1004 00:20:20.119000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V1004 00:20:20.120000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
Traceback (most recent call last):
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 549, in produce_guards_and_solve_constraints
raise constraint_violation_error
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5932, in produce_guards_verbose
raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: Constraints violated (L['w'].size()[1])! For more information, run with TORCH_LOGS="+dynamic".
- You marked L['w'].size()[1] as dynamic but your code specialized it to be a constant (5). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 418, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 269, in forward
x1 = self.l(w) # [6, 3]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/linear.py", line 125, in forward
return F.linear(input, self.weight, self.bias)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2601, in _dispatch_impl
decomposition_table[func](*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "??", line 0, in at::_ops::linear::call(at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_decomp/decompositions.py", line 90, in inner
r = f(*tree_map(increase_prec, args), **tree_map(increase_prec, kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_decomp/decompositions.py", line 1462, in addmm
out = alpha * torch.mm(mat1, mat2)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "RegisterCompositeImplicitAutograd_0.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&), &at::(anonymous namespace)::(anonymous namespace)::wrapper_CompositeImplicitAutograd__linear>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "??", line 0, in at::native::linear(at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&)
File "??", line 0, in at::_ops::addmm::call(at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "", line 0, in c10::impl::BoxedKernelWrapper<at::Tensor (at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&), void>::call(c10::BoxedKernel const&, c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "VariableType_0.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&), &torch::autograd::VariableType::(anonymous namespace)::addmm>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "VariableType_0.cpp", line 0, in torch::autograd::VariableType::(anonymous namespace)::addmm(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "??", line 0, in at::_ops::addmm::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
r = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_torch_functions_1.cpp", line 0, in torch::autograd::THPVariable_mm(_object*, _object*, _object*)
File "??", line 0, in at::_ops::mm::call(at::Tensor const&, at::Tensor const&)
File "", line 0, in c10::impl::BoxedKernelWrapper<at::Tensor (at::Tensor const&, at::Tensor const&), void>::call(c10::BoxedKernel const&, c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, at::Tensor const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_meta_registrations.py", line 2417, in meta_mm
torch._check(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 418, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1800, in _export_to_aten_ir_make_fx
raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e)) # noqa: B904
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.UserError: Constraints violated (L['w'].size()[1])! For more information, run with TORCH_LOGS="+dynamic".
- You marked L['w'].size()[1] as dynamic but your code specialized it to be a constant (5). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 418, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 269, in forward
x1 = self.l(w) # [6, 3]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/linear.py", line 125, in forward
return F.linear(input, self.weight, self.bias)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2601, in _dispatch_impl
decomposition_table[func](*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_nn_functions.cpp", line 0, in torch::autograd::THPVariable_linear(_object*, _object*, _object*)
File "??", line 0, in at::_ops::linear::call(at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_decomp/decompositions.py", line 90, in inner
r = f(*tree_map(increase_prec, args), **tree_map(increase_prec, kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_decomp/decompositions.py", line 1462, in addmm
out = alpha * torch.mm(mat1, mat2)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "RegisterCompositeImplicitAutograd_0.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&), &at::(anonymous namespace)::(anonymous namespace)::wrapper_CompositeImplicitAutograd__linear>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "??", line 0, in at::native::linear(at::Tensor const&, at::Tensor const&, std::optional<at::Tensor> const&)
File "??", line 0, in at::_ops::addmm::call(at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "", line 0, in c10::impl::BoxedKernelWrapper<at::Tensor (at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&), void>::call(c10::BoxedKernel const&, c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "VariableType_0.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&), &torch::autograd::VariableType::(anonymous namespace)::addmm>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "VariableType_0.cpp", line 0, in torch::autograd::VariableType::(anonymous namespace)::addmm(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "??", line 0, in at::_ops::addmm::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::Scalar const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
r = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "python_torch_functions_1.cpp", line 0, in torch::autograd::THPVariable_mm(_object*, _object*, _object*)
File "??", line 0, in at::_ops::mm::call(at::Tensor const&, at::Tensor const&)
File "", line 0, in c10::impl::BoxedKernelWrapper<at::Tensor (at::Tensor const&, at::Tensor const&), void>::call(c10::BoxedKernel const&, c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor const&, at::Tensor const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_meta_registrations.py", line 2417, in meta_mm
torch._check(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.
Static guards also aren’t always inherent to the model; they can also come from user specifications. In fact, a common pitfall leading to shape
specializations is when the user specifies conflicting markers for equivalent dimensions; one dynamic and another static. The same error type is
raised when this is the case for x.shape[0] and y.shape[1]:
dynamic_shapes["w"] = (Dim.AUTO, Dim.AUTO)
dynamic_shapes["x"] = (Dim.STATIC,)
dynamic_shapes["y"] = (Dim.AUTO, Dim.DYNAMIC)
try:
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
except Exception:
tb.print_exc()
I1004 00:20:20.182000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.183000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s15 = 6 for L['w'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s15" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.184000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s21 = 5 for L['w'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s21" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:20:20.184000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.186000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s17 = 8 for L['y'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s17" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.187000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s94 = 4 for L['y'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s94" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.189000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s68 = 32 for L['z'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s68" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:20:20.194000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.194000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.195000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.196000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.197000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.197000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.198000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.198000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:20:20.203000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s94, 4) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s94, 4)"
V1004 00:20:20.204000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s94 = VR[4, 4] (update)
I1004 00:20:20.204000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = 4 (range_refined_to_singleton) VR[4, 4]
I1004 00:20:20.211000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s21, 5) [guard added] (_meta_registrations.py:2417 in meta_mm), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s21, 5)"
V1004 00:20:20.211000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I1004 00:20:20.212000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V1004 00:20:20.213000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.227000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(4*s17, s68) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(4*s17, s68)"
V1004 00:20:20.228000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[8, int_oo] (update)
I1004 00:20:20.230000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = 4*s17 (solve) VR[8, int_oo]
I1004 00:20:20.234000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.234000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s15 None
V1004 00:20:20.234000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 4 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.235000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V1004 00:20:20.236000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] 4 RelaxedUnspecConstraint(warn_only=False)
V1004 00:20:20.251000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 4 None
V1004 00:20:20.252000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V1004 00:20:20.252000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:20:20.252000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] 4*s17 None
V1004 00:20:20.253000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V1004 00:20:20.253000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
Traceback (most recent call last):
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 549, in produce_guards_and_solve_constraints
raise constraint_violation_error
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5932, in produce_guards_verbose
raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: Constraints violated (L['y'].size()[1])! For more information, run with TORCH_LOGS="+dynamic".
- You marked L['y'].size()[1] as dynamic but your code specialized it to be a constant (4). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 431, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 268, in forward
x0 = x + y # [8, 4]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5548, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/abstract.c", line 893, in binary_op1
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7420, in slot_nb_add
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in _object* torch::autograd::TypeError_to_NotImplemented_<&torch::autograd::THPVariable_add>(_object*, _object*, _object*)
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "??", line 0, in at::_ops::add_Tensor::call(at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "VariableType_2.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&), &torch::autograd::VariableType::(anonymous namespace)::add_Tensor>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "VariableType_2.cpp", line 0, in torch::autograd::VariableType::(anonymous namespace)::add_Tensor(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "??", line 0, in at::_ops::add_Tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 431, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1800, in _export_to_aten_ir_make_fx
raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e)) # noqa: B904
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.UserError: Constraints violated (L['y'].size()[1])! For more information, run with TORCH_LOGS="+dynamic".
- You marked L['y'].size()[1] as dynamic but your code specialized it to be a constant (4). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 431, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 268, in forward
x0 = x + y # [8, 4]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5548, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/abstract.c", line 893, in binary_op1
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7420, in slot_nb_add
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in _object* torch::autograd::TypeError_to_NotImplemented_<&torch::autograd::THPVariable_add>(_object*, _object*, _object*)
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "??", line 0, in at::_ops::add_Tensor::call(at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "VariableType_2.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&), &torch::autograd::VariableType::(anonymous namespace)::add_Tensor>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "VariableType_2.cpp", line 0, in torch::autograd::VariableType::(anonymous namespace)::add_Tensor(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "??", line 0, in at::_ops::add_Tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.
Here you might ask why export “specializes”, i.e. why we resolve this static/dynamic conflict by going with the static route. The answer is because
of the symbolic shapes system described above, of symbols and guards. When x.shape[0] is marked static, we don’t allocate a symbol, and compile
treating this shape as a concrete integer 4. A symbol is allocated for y.shape[1], and so we finally emit the guard s3 == 4, leading to
specialization.
One feature of export is that during tracing, statements like asserts, torch._check(), and if/else conditions will also emit guards.
See what happens when we augment the existing model with such statements:
class DynamicModel(torch.nn.Module):
def __init__(self):
super().__init__()
self.l = torch.nn.Linear(5, 3)
def forward(self, w, x, y, z):
assert w.shape[0] <= 512
torch._check(x.shape[0] >= 4)
if w.shape[0] == x.shape[0] + 2:
x0 = x + y
x1 = self.l(w)
x2 = x0.flatten()
x3 = x2 + z
return x1, x3
else:
return w
dynamic_shapes = {
"w": (Dim.AUTO, Dim.AUTO),
"x": (Dim.AUTO,),
"y": (Dim.AUTO, Dim.AUTO),
"z": (Dim.AUTO,),
}
try:
ep = export(DynamicModel(), (w, x, y, z), dynamic_shapes=dynamic_shapes)
except Exception:
tb.print_exc()
I1004 00:20:20.287000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.290000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s15 = 6 for L['w'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s15" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.290000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s21 = 5 for L['w'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s21" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:20:20.291000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.292000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s77 = 4 for L['x'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s77" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.293000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s17 = 8 for L['y'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s17" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.294000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s94 = 4 for L['y'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s94" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.295000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s68 = 32 for L['z'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s68" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:20:20.299000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.299000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.300000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.301000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.301000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.302000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.302000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.303000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.304000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.304000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:20:20.314000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] eval s15 <= 512 [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:450 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="s15 <= 512"
V1004 00:20:20.315000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s15 = VR[2, 512] (update)
I1004 00:20:20.320000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert s77 >= 4 [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:451 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="s77 >= 4"
V1004 00:20:20.321000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s77 = VR[4, int_oo] (update)
I1004 00:20:20.326000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] eval Eq(s15, s77 + 2) [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:452 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s15, s77 + 2)"
V1004 00:20:20.328000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s15 = VR[6, 512] (update)
V1004 00:20:20.330000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s77 = VR[4, 510] (update)
I1004 00:20:20.331000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s15 = s77 + 2 (solve) VR[6, 512]
V1004 00:20:20.333000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.335000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s77, s94) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s77, s94)"
V1004 00:20:20.336000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s94 = VR[4, 510] (update)
I1004 00:20:20.337000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s77 (solve) VR[4, 510]
V1004 00:20:20.340000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:20:20.346000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s21, 5) [guard added] (_meta_registrations.py:2417 in meta_mm), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s21, 5)"
V1004 00:20:20.347000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I1004 00:20:20.347000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V1004 00:20:20.359000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(Eq(s17*s77, 1)) == False [statically known]
V1004 00:20:20.361000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:20:20.369000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s17*s77, s68) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s17*s77, s68)"
V1004 00:20:20.369000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[8, int_oo] (update)
I1004 00:20:20.370000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = s17*s77 (solve) VR[8, int_oo]
I1004 00:20:20.375000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.375000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s77 + 2 None
V1004 00:20:20.375000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 None
V1004 00:20:20.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V1004 00:20:20.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V1004 00:20:20.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V1004 00:20:20.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s77 None
V1004 00:20:20.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V1004 00:20:20.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V1004 00:20:20.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] s77 None
V1004 00:20:20.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] s77 None
V1004 00:20:20.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V1004 00:20:20.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:20:20.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] s17*s77 None
V1004 00:20:20.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V1004 00:20:20.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
V1004 00:20:20.388000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert s77 >= 4 == True [statically known]
V1004 00:20:20.389000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
V1004 00:20:20.394000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7461] eval 5 [trivial]
Each of these statements emits an additional guard, and the exported program shows the changes; s0 is eliminated in favor of s2 + 2,
and s2 now contains lower and upper bounds, reflected in range_constraints.
For the if/else condition, you might ask why the True branch was taken, and why it wasn’t the w.shape[0] != x.shape[0] + 2 guard that
got emitted from tracing. The answer is that export is guided by the sample inputs provided by tracing, and specializes on the branches taken.
If different sample input shapes were provided that fail the if condition, export would trace and emit guards corresponding to the else branch.
Additionally, you might ask why we traced only the if branch, and if it’s possible to maintain control-flow in your program and keep both branches
alive. For that, refer to rewriting your model code following the Control Flow Ops section above.
0/1 specialization#
Since we’re talking about guards and specializations, it’s a good time to talk about the 0/1 specialization issue we brought up earlier. The bottom line is that export will specialize on sample input dimensions with value 0 or 1, because these shapes have trace-time properties that don’t generalize to other shapes. For example, size 1 tensors can broadcast while other sizes fail; and size 0 … . This just means that you should specify 0/1 sample inputs when you’d like your program to hardcode them, and non-0/1 sample inputs when dynamic behavior is desirable. See what happens at runtime when we export this linear layer:
ep = export(
torch.nn.Linear(4, 3),
(torch.randn(1, 4),),
dynamic_shapes={
"input": (Dim.AUTO, Dim.STATIC),
},
)
try:
ep.module()(torch.randn(2, 4))
except Exception:
tb.print_exc()
I1004 00:20:20.399000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.408000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.409000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].size()[0] 1 None
V1004 00:20:20.409000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].size()[1] 4 None
V1004 00:20:20.409000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].stride()[0] 4 None
V1004 00:20:20.409000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].stride()[1] 1 None
V1004 00:20:20.409000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].storage_offset() 0 None
W1004 00:20:20.411000 3670787 site-packages/torch/_export/non_strict_utils.py:580] dimension inputs['input'].shape[0] 0/1 specialized; Dim.AUTO was specified along with a sample input with hint = 1.
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 500, in <module>
ep.module()(torch.randn(2, 4))
File "/opt/conda/lib/python3.11/site-packages/torch/fx/graph_module.py", line 848, in call_wrapped
return self._wrapped_call(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/graph_module.py", line 424, in __call__
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/fx/graph_module.py", line 411, in __call__
return super(self.cls, obj).__call__(*args, **kwargs) # type: ignore[misc]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1879, in _call_impl
return inner()
^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1806, in inner
args_kwargs_result = hook(self, args, kwargs) # type: ignore[misc]
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_unlift.py", line 83, in _check_input_constraints_pre_hook
_check_input_constraints_for_graph(
File "/opt/conda/lib/python3.11/site-packages/torch/_export/utils.py", line 426, in _check_input_constraints_for_graph
_check_symint(
File "/opt/conda/lib/python3.11/site-packages/torch/_export/utils.py", line 390, in _check_symint
raise RuntimeError(
RuntimeError: Expected input at *args[0].shape[0] to be equal to 1, but got 2. If you meant for this dimension to be dynamic, please re-export and specify dynamic_shapes (e.g. with Dim.DYNAMIC)
Named Dims#
So far we’ve only been talking about 3 ways to specify dynamic shapes: Dim.AUTO, Dim.DYNAMIC, and Dim.STATIC. The attraction of these is the
low-friction user experience; all the guards emitted during model tracing are adhered to, and dynamic behavior like min/max ranges, relations, and static/dynamic
dimensions are automatically figured out underneath export. The dynamic shapes subsystem essentially acts as a “discovery” process, summarizing these guards
and presenting what export believes is the overall dynamic behavior of the program. The drawback of this design appears once the user has stronger expectations or
beliefs about the dynamic behavior of these models - maybe there is a strong desire on dynamism and specializations on particular dimensions are to be avoided at
all costs, or maybe we just want to catch changes in dynamic behavior with changes to the original model code, or possibly underlying decompositions or meta-kernels.
These changes won’t be detected and the export() call will most likely succeed, unless tests are in place that check the resulting ExportedProgram representation.
For such cases, our stance is to recommend the “traditional” way of specifying dynamic shapes, which longer-term users of export might be familiar with: named Dims:
dx = Dim("dx", min=4, max=256)
dh = Dim("dh", max=512)
dynamic_shapes = {
"x": (dx, None),
"y": (2 * dx, dh),
}
This style of dynamic shapes allows the user to specify what symbols are allocated for input dimensions, min/max bounds on those symbols, and places restrictions on the
dynamic behavior of the ExportedProgram produced; ConstraintViolation errors will be raised if model tracing emits guards that conflict with the relations or static/dynamic
specifications given. For example, in the above specification, the following is asserted:
x.shape[0]is to have range[4, 256], and related toy.shape[0]byy.shape[0] == 2 * x.shape[0].x.shape[1]is static.y.shape[1]has range[2, 512], and is unrelated to any other dimension.
In this design, we allow relations between dimensions to be specified with univariate linear expressions: A * dim + B can be specified for any dimension. This allows users
to specify more complex constraints like integer divisibility for dynamic dimensions:
dx = Dim("dx", min=4, max=512)
dynamic_shapes = {
"x": (4 * dx, None) # x.shape[0] has range [16, 2048], and is divisible by 4.
}
Constraint violations, suggested fixes#
One common issue with this specification style (before Dim.AUTO was introduced), is that the specification would often be mismatched with what was produced by model tracing.
That would lead to ConstraintViolation errors and export suggested fixes - see for example with this model & specification, where the model inherently requires equality between
dimensions 0 of x and y, and requires dimension 1 to be static.
class Foo(torch.nn.Module):
def forward(self, x, y):
w = x + y
return w + torch.ones(4)
dx, dy, d1 = torch.export.dims("dx", "dy", "d1")
try:
ep = export(
Foo(),
(torch.randn(6, 4), torch.randn(6, 4)),
dynamic_shapes={
"x": (dx, d1),
"y": (dy, d1),
},
)
except Exception:
tb.print_exc()
I1004 00:20:20.418000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.419000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s77 = 6 for L['x'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s77" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.421000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s27 = 4 for L['x'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s27" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:20:20.422000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.424000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s17 = 6 for L['y'].size()[0] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s17" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
I1004 00:20:20.424000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5110] create_symbol s94 = 4 for L['y'].size()[1] [2, int_oo] (_export/non_strict_utils.py:229 in fakify), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="s94" or to suppress this message run with TORCHDYNAMO_EXTENDED_ADVICE="0"
V1004 00:20:20.429000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.430000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.431000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.432000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.433000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.433000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V1004 00:20:20.435000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.437000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s27, s94) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s27, s94)"
I1004 00:20:20.438000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s27 (solve) VR[2, int_oo]
I1004 00:20:20.439000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s77, s17) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s77, s17)"
I1004 00:20:20.440000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s77 = s17 (solve) VR[2, int_oo]
V1004 00:20:20.442000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I1004 00:20:20.451000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert Eq(s27, 4) [guard added] (_subclasses/fake_impls.py:922 in infer_size), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s27, 4)"
V1004 00:20:20.451000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s27 = VR[4, 4] (update)
I1004 00:20:20.452000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s27 = 4 (range_refined_to_singleton) VR[4, 4]
I1004 00:20:20.456000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.456000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s94 = VR[4, 4] (update)
I1004 00:20:20.457000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = 4 (find) VR[4, 4]
V1004 00:20:20.457000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s17 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V1004 00:20:20.457000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 4 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V1004 00:20:20.459000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 4 None
V1004 00:20:20.459000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 1 None
V1004 00:20:20.460000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.460000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V1004 00:20:20.460000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] 4 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V1004 00:20:20.464000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 4 None
V1004 00:20:20.464000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V1004 00:20:20.464000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
Traceback (most recent call last):
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 549, in produce_guards_and_solve_constraints
raise constraint_violation_error
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5932, in produce_guards_verbose
raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: Constraints violated (d1, dy)! For more information, run with TORCH_LOGS="+dynamic".
- You marked d1 as dynamic but your code specialized it to be a constant (4). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 553, in forward
return w + torch.ones(4)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5548, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/abstract.c", line 893, in binary_op1
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7420, in slot_nb_add
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in _object* torch::autograd::TypeError_to_NotImplemented_<&torch::autograd::THPVariable_add>(_object*, _object*, _object*)
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "??", line 0, in at::_ops::add_Tensor::call(at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "VariableType_2.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&), &torch::autograd::VariableType::(anonymous namespace)::add_Tensor>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "VariableType_2.cpp", line 0, in torch::autograd::VariableType::(anonymous namespace)::add_Tensor(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "??", line 0, in at::_ops::add_Tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
- You marked d1 as dynamic but your code specialized it to be a constant (4). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5405, in produce_guards_verbose
expr1, expr2 = get_expression(src1), get_expression(src2) # type: ignore[]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5399, in get_expression
return symint.node.expr
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 189, in expr
return self.shape_env.replace(self._expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Objects/classobject.c", line 59, in method_vectorcall
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 3461, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6324, in replace
r = self._find(s)
File "/usr/local/src/conda/python-3.11.13/Objects/object.c", line 1368, in PyObject_GenericGetAttr
File "/usr/local/src/conda/python-3.11.13/Objects/object.c", line 1278, in _PyObject_GenericGetAttrWithDict
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 917, in infinite_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 917, in infinite_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6809, in _find
self._set_replacement(a, replaced, "find")
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
- The values of dy = L['y'].size()[0] and dx = L['x'].size()[0] must always be equal.
Suggested fixes:
d1 = 4
dy = dx
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1800, in _export_to_aten_ir_make_fx
raise UserError(UserErrorType.CONSTRAINT_VIOLATION, str(e)) # noqa: B904
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.UserError: Constraints violated (d1, dy)! For more information, run with TORCH_LOGS="+dynamic".
- You marked d1 as dynamic but your code specialized it to be a constant (4). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 553, in forward
return w + torch.ones(4)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5548, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/abstract.c", line 893, in binary_op1
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7420, in slot_nb_add
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in _object* torch::autograd::TypeError_to_NotImplemented_<&torch::autograd::THPVariable_add>(_object*, _object*, _object*)
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "", line 0, in torch::handle_torch_function(torch::PythonArgs&, _object*, _object*, _object*, _object*, char const*, char const*)
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/descrobject.c", line 364, in method_vectorcall_VARARGS_KEYWORDS
File "python_variable_methods.cpp", line 0, in torch::autograd::THPVariable_add(_object*, _object*, _object*)
File "??", line 0, in at::_ops::add_Tensor::call(at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7321, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "init.cpp", line 0, in pybind11::cpp_function::initialize<torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}, pybind11::object, pybind11::args const&, pybind11::kwargs const&>(torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}&&, pybind11::object (*)(pybind11::args const&, pybind11::kwargs const&))::{lambda(pybind11::detail::function_call&)#1}::_FUN(pybind11::detail::function_call&)
File "init.cpp", line 0, in torch::jit::initJITBindings(_object*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#2}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const::{lambda(pybind11::args const&, pybind11::kwargs const&)#1}::operator()(pybind11::args const&, pybind11::kwargs const&) const
File "??", line 0, in torch::jit::_get_operation_for_overload_or_packet(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, c10::Symbol, pybind11::args const&, pybind11::kwargs const&, bool, std::optional<c10::DispatchKey>)
File "??", line 0, in torch::jit::invokeOperatorFromPython(std::vector<std::shared_ptr<torch::jit::Operator>, std::allocator<std::shared_ptr<torch::jit::Operator> > > const&, pybind11::args const&, pybind11::kwargs const&, std::optional<c10::DispatchKey>)
File "register_c10_ops.cpp", line 0, in c10::Dispatcher::callBoxed(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const [clone .isra.0]
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in void c10::BoxedKernel::make_boxed_function<&(anonymous namespace)::pythonTLSSnapshotFallback>(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "VariableType_2.cpp", line 0, in c10::impl::make_boxed_from_unboxed_functor<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&), &torch::autograd::VariableType::(anonymous namespace)::add_Tensor>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&> >, false>::call(c10::OperatorKernel*, c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "VariableType_2.cpp", line 0, in torch::autograd::VariableType::(anonymous namespace)::add_Tensor(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "??", line 0, in at::_ops::add_Tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&, c10::Scalar const&)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::python_dispatcher(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "", line 0, in c10::OperatorHandle::callBoxedForDispatchKey(c10::DispatchKey, std::vector<c10::IValue, std::allocator<c10::IValue> >&) const
File "PythonFallbackKernel.cpp", line 0, in (anonymous namespace)::pythonFallback(c10::OperatorHandle const&, c10::DispatchKeySet, std::vector<c10::IValue, std::allocator<c10::IValue> >*)
File "PyInterpreter.cpp", line 0, in torch::detail::(anonymous namespace)::ConcretePyInterpreterVTable::dispatch(c10::OperatorHandle const&, std::vector<c10::IValue, std::allocator<c10::IValue> >*) const
File "??", line 0, in torch::handle_torch_function_no_python_arg_parser(c10::ArrayRef<_object*>, _object*, _object*, char const*, _object*, char const*, torch::TorchFunctionName)
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 627, in PyObject_CallMethod
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 1021, in bounded_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
- You marked d1 as dynamic but your code specialized it to be a constant (4). If you're using mark_dynamic, either remove it or use maybe_mark_dynamic. If you're using Dim.DYNAMIC, replace it with either Dim.STATIC or Dim.AUTO.
Framework stack:
File "/opt/conda/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
p.start()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 738, in Py_BytesMain
File "/usr/local/src/conda/python-3.11.13/Modules/main.c", line 360, in pymain_run_file_obj
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 79, in _PyRun_AnyFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 440, in _PyRun_SimpleFileObject
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1657, in pyrun_file
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1762, in run_mod
File "/usr/local/src/conda/python-3.11.13/Python/pythonrun.c", line 1741, in run_eval_code_obj
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4984, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 2790, in list___init___impl
File "/usr/local/src/conda/python-3.11.13/Objects/listobject.c", line 966, in list_extend
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 1103, in type_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/typeobject.c", line 7624, in slot_tp_call
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 482, in _PyObject_Call_Prepend
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 141, in _PyObject_FastCallDictTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 5091, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "/usr/local/src/conda/python-3.11.13/Python/bltinmodule.c", line 1077, in builtin_exec_impl
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 1148, in PyEval_EvalCode
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5405, in produce_guards_verbose
expr1, expr2 = get_expression(src1), get_expression(src2) # type: ignore[]
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 5399, in get_expression
return symint.node.expr
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 189, in expr
return self.shape_env.replace(self._expr)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 257, in _PyVectorcall_Call
File "/usr/local/src/conda/python-3.11.13/Objects/classobject.c", line 59, in method_vectorcall
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 3461, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6324, in replace
r = self._find(s)
File "/usr/local/src/conda/python-3.11.13/Objects/object.c", line 1368, in PyObject_GenericGetAttr
File "/usr/local/src/conda/python-3.11.13/Objects/object.c", line 1278, in _PyObject_GenericGetAttrWithDict
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_call.h", line 92, in _PyObject_VectorcallTstate
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 917, in infinite_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 343, in _PyObject_Call
File "/usr/local/src/conda/python-3.11.13/Modules/_functoolsmodule.c", line 917, in infinite_lru_cache_wrapper
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6809, in _find
self._set_replacement(a, replaced, "find")
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 7349, in do_call_core
File "/usr/local/src/conda/python-3.11.13/Include/internal/pycore_ceval.h", line 73, in _PyEval_EvalFrame
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "/usr/local/src/conda/python-3.11.13/Python/ceval.c", line 4769, in _PyEval_EvalFrameDefault
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "/usr/local/src/conda/python-3.11.13/Objects/call.c", line 214, in _PyObject_MakeTpCall
File "/usr/local/src/conda/python-3.11.13/Objects/methodobject.c", line 542, in cfunction_call
File "", line 0, in pybind11::cpp_function::dispatcher(_object*, _object*, _object*)
File "", line 0, in pybind11::cpp_function::initialize<std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback>, bool, bool, bool, pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v>(std::shared_ptr<torch::CapturedTraceback> (*&)(bool, bool, bool), std::shared_ptr<torch::CapturedTraceback> (*)(bool, bool, bool), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const
File "??", line 0, in torch::CapturedTraceback::gather(bool, bool, bool)
File "??", line 0, in torch::unwind::unwind()
- The values of dy = L['y'].size()[0] and dx = L['x'].size()[0] must always be equal.
Suggested fixes:
d1 = 4
dy = dx
The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.
The expectation with suggested fixes is that the user can interactively copy-paste the changes into their dynamic shapes specification, and successfully export afterwards.
Lastly, there’s couple nice-to-knows about the options for specification:
Noneis a good option for static behavior: -dynamic_shapes=None(default) exports with the entire model being static. - specifyingNoneat an input-level exports with all tensor dimensions static, and is also required for non-tensor inputs. - specifyingNoneat a dimension-level specializes that dimension, though this is deprecated in favor ofDim.STATIC.specifying per-dimension integer values also produces static behavior, and will additionally check that the provided sample input matches the specification.
These options are combined in the inputs & dynamic shapes spec below:
inputs = (
torch.randn(4, 4),
torch.randn(3, 3),
16,
False,
)
dynamic_shapes = {
"tensor_0": (Dim.AUTO, None),
"tensor_1": None,
"int_val": None,
"bool_val": None,
}
Data-dependent errors#
While trying to export models, you have may have encountered errors like “Could not guard on data-dependent expression”, or Could not extract specialized integer from data-dependent expression”.
These errors exist because torch.export() compiles programs using FakeTensors, which symbolically represent their real tensor counterparts. While these have equivalent symbolic properties
(e.g. sizes, strides, dtypes), they diverge in that FakeTensors do not contain any data values. While this avoids unnecessary memory usage and expensive computation, it does mean that export may be
unable to out-of-the-box compile parts of user code where compilation relies on data values. In short, if the compiler requires a concrete, data-dependent value in order to proceed, it will error out,
complaining that the value is not available.
Data-dependent values appear in many places, and common sources are calls like item(), tolist(), or torch.unbind() that extract scalar values from tensors.
How are these values represented in the exported program? In the Constraints/Dynamic Shapes
section, we talked about allocating symbols to represent dynamic input dimensions.
The same happens here: we allocate symbols for every data-dependent value that appears in the program. The important distinction is that these are “unbacked” symbols,
in contrast to the “backed” symbols allocated for input dimensions. The “backed/unbacked”
nomenclature refers to the presence/absence of a “hint” for the symbol: a concrete value backing the symbol, that can inform the compiler on how to proceed.
In the input shape symbol case (backed symbols), these hints are simply the sample input shapes provided, which explains why control-flow branching is determined by the sample input properties. For data-dependent values, the symbols are taken from FakeTensor “data” during tracing, and so the compiler doesn’t know the actual values (hints) that these symbols would take on.
Let’s see how these show up in exported programs:
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
b = y.tolist()
return b + [a]
inps = (
torch.tensor(1),
torch.tensor([2, 3]),
)
ep = export(Foo(), inps)
print(ep)
I1004 00:20:20.495000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.501000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.501000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I1004 00:20:20.506000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u1 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.506000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u1]
I1004 00:20:20.507000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u2 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.508000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u2]
I1004 00:20:20.509000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.510000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.510000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 2 None
V1004 00:20:20.510000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V1004 00:20:20.510000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "i64[]", y: "i64[2]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:618 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(x); x = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:619 in forward, code: b = y.tolist()
unbind = torch.ops.aten.unbind.int(y); y = None
getitem: "i64[]" = unbind[0]
getitem_1: "i64[]" = unbind[1]; unbind = None
item_1: "Sym(u1)" = torch.ops.aten.item.default(getitem); getitem = None
item_2: "Sym(u2)" = torch.ops.aten.item.default(getitem_1); getitem_1 = None
return (item_1, item_2, item)
Graph signature:
# inputs
x: USER_INPUT
y: USER_INPUT
# outputs
item_1: USER_OUTPUT
item_2: USER_OUTPUT
item: USER_OUTPUT
Range constraints: {u0: VR[-int_oo, int_oo], u1: VR[-int_oo, int_oo], u2: VR[-int_oo, int_oo]}
The result is that 3 unbacked symbols (notice they’re prefixed with “u”, instead of the usual “s” for input shape/backed symbols) are allocated and returned:
1 for the item() call, and 1 for each of the elements of y with the tolist() call.
Note from the range constraints field that these take on ranges of [-int_oo, int_oo], not the default [0, int_oo] range allocated to input shape symbols,
since we have no information on what these values are - they don’t represent sizes, so don’t necessarily have positive values.
Guards, torch._check()#
But the case above is easy to export, because the concrete values of these symbols aren’t used in any compiler decision-making; all that’s relevant is that the return values are unbacked symbols. The data-dependent errors highlighted in this section are cases like the following, where data-dependent guards are encountered:
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
if a // 2 >= 5:
return y + 2
else:
return y * 5
Here we actually need the “hint”, or the concrete value of a for the compiler to decide whether to trace return y + 2 or return y * 5 as the output.
Because we trace with FakeTensors, we don’t know what a // 2 >= 5 actually evaluates to, and export errors out with “Could not guard on data-dependent expression u0 // 2 >= 5 (unhinted)”.
So how do we export this toy model? Unlike torch.compile(), export requires full graph compilation, and we can’t just graph break on this. Here are some basic options:
Manual specialization: we could intervene by selecting the branch to trace, either by removing the control-flow code to contain only the specialized branch, or using
torch.compiler.is_compiling()to guard what’s traced at compile-time.torch.cond(): we could rewrite the control-flow code to usetorch.cond()so we don’t specialize on a branch.
While these options are valid, they have their pitfalls. Option 1 sometimes requires drastic, invasive rewrites of the model code to specialize, and torch.cond() is not a comprehensive system for handling data-dependent errors.
As we will see, there are data-dependent errors that do not involve control-flow.
The generally recommended approach is to start with torch._check() calls. While these give the impression of purely being assert statements, they are in fact a system of informing the compiler on properties of symbols.
While a torch._check() call does act as an assertion at runtime, when traced at compile-time, the checked expression is sent to the symbolic shapes subsystem for reasoning, and any symbol properties that follow from the expression being true,
are stored as symbol properties (provided it’s smart enough to infer those properties). So even if unbacked symbols don’t have hints, if we’re able to communicate properties that are generally true for these symbols via
torch._check() calls, we can potentially bypass data-dependent guards without rewriting the offending model code.
For example in the model above, inserting torch._check(a >= 10) would tell the compiler that y + 2 can always be returned, and torch._check(a == 4) tells it to return y * 5.
See what happens when we re-export this model.
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
torch._check(a >= 10)
torch._check(a <= 60)
if a // 2 >= 5:
return y + 2
else:
return y * 5
inps = (
torch.tensor(32),
torch.randn(4),
)
ep = export(Foo(), inps)
print(ep)
I1004 00:20:20.515000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.519000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.519000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I1004 00:20:20.521000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 >= 10 [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:673 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 >= 10"
V1004 00:20:20.522000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[10, int_oo] (update)
I1004 00:20:20.527000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 <= 60 [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:674 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 <= 60"
V1004 00:20:20.528000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[10, 60] (update)
V1004 00:20:20.534000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == True [statically known]
I1004 00:20:20.537000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.538000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.538000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 4 None
V1004 00:20:20.538000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V1004 00:20:20.538000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:20:20.539000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 10 == True [statically known]
V1004 00:20:20.540000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 <= 60 == True [statically known]
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "i64[]", y: "f32[4]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:672 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(x); x = None
ge_2: "Sym(u0 >= 10)" = item >= 10
_assert_scalar_default = torch.ops.aten._assert_scalar.default(ge_2, "Runtime assertion failed for expression u0 >= 10 on node 'ge_2'"); ge_2 = _assert_scalar_default = None
le_1: "Sym(u0 <= 60)" = item <= 60; item = None
_assert_scalar_default_1 = torch.ops.aten._assert_scalar.default(le_1, "Runtime assertion failed for expression u0 <= 60 on node 'le_1'"); le_1 = _assert_scalar_default_1 = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:676 in forward, code: return y + 2
add: "f32[4]" = torch.ops.aten.add.Tensor(y, 2); y = None
return (add,)
Graph signature:
# inputs
x: USER_INPUT
y: USER_INPUT
# outputs
add: USER_OUTPUT
Range constraints: {u0: VR[10, 60]}
Export succeeds, and note from the range constraints field that u0 takes on a range of [10, 60].
So what information do torch._check() calls actually communicate? This varies as the symbolic shapes subsystem gets smarter, but at a fundamental level, these are generally true:
Equality with non-data-dependent expressions:
torch._check()calls that communicate equalities likeu0 == s0 + 4oru0 == 5.Range refinement: calls that provide lower or upper bounds for symbols, like the above.
Some basic reasoning around more complicated expressions: inserting
torch._check(a < 4)will typically tell the compiler thata >= 4is false. Checks on complex expressions liketorch._check(a ** 2 - 3 * a <= 10)will typically get you past identical guards.
As mentioned previously, torch._check() calls have applicability outside of data-dependent control flow. For example, here’s a model where torch._check() insertion
prevails while manual specialization & torch.cond() do not:
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
return y[a]
inps = (
torch.tensor(32),
torch.randn(60),
)
try:
export(Foo(), inps)
except Exception:
tb.print_exc()
I1004 00:20:20.544000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.549000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.549000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] Data dependent variable 'u0' allocated at:
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/bin/sphinx-build", line 7, in <module>
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] sys.exit(main())
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make_main(argv)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make_mode.run_make_mode(argv[1:])
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make.run_generic_build(args[0])
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return build_main(args + opts)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._init_builder()
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self.events.emit('builder-inited')
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] results.append(listener.handler(self.app, *args))
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ) = generate_dir_rst(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] results = parallel(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] p.start()
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._popen = self._Popen(self)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _default_context.get_context().Process._Popen(process_obj)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return Popen(process_obj)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._launch(process_obj)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] code = process_obj._bootstrap(parent_sentinel=child_r)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self.run()
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._target(*self._args, **self._kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] result = func(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] output_blocks, time_elapsed = execute_script(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] execute_code_block(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] is_last_expr, mem_max = _exec_and_get_memory(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] mem_max, _ = call_memory(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return 0.0, func()
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] exec(self.code, self.fake_main.__dict__)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 709, in <module>
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] export(Foo(), inps)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _export(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ep = _export_for_training(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] export_artifact = export_func(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] aten_export_artifact = _to_aten_func( # type: ignore[operator]
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] gm, graph_signature = transform(_make_fx_helper)(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] gm = make_fx(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make_fx_tracer.trace(f, *args)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._trace_inner(f, *args)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] t = dispatch_trace(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return disable_fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] res = super().trace(root, concrete_args)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] (self.create_arg(fn(*args)),),
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] out = f(*tensors) # type:ignore[call-arg]
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "<string>", line 1, in <lambda>
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return tuple(flat_fn(*args))
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] tree_out = fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] out = mod(*args[params_len:], **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] tree_out = mod(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 701, in forward
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] a = x.item()
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return torch._library.utils.handle_dispatch_mode(
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return proxy_call(self, func, self.pre_dispatch, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] out = func(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._op(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self.dispatch(func, types, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._cached_dispatch_impl(func, types, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1474, in _cached_dispatch_impl
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._dispatch_impl(func, types, args, kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2687, in _dispatch_impl
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] op_impl_out = op_impl(self, func, *args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 163, in dispatch_to_op_implementations_dict
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return op_implementations_dict[func](fake_mode, func, *args, **kwargs)
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 425, in local_scalar_dense
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] r = fake_mode.shape_env.create_unbacked_symint()
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return retlog(fn(*args, **kwargs))
V1004 00:20:20.553000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519]
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] failed while attempting to run meta for aten.select.int
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] Traceback (most recent call last):
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] r = func(*args, **kwargs)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return self._op(*args, **kwargs)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/_meta_registrations.py", line 5545, in meta_select
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] guard_size_oblivious(-index > size) or guard_size_oblivious(index >= size)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 473, in guard_size_oblivious
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return expr.node.guard_size_oblivious("", 0)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 596, in guard_size_oblivious
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] r = self.evaluate(size_oblivious=True)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return self.shape_env.evaluate_sym_node(self, size_oblivious)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return self.evaluate_expr(
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return self._inner_evaluate_expr(
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return retlog(fn(*args, **kwargs))
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] return self._evaluate_expr(
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] ^^^^^^^^^^^^^^^^^^^^
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7570, in _evaluate_expr
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] raise self._make_data_dependent_error(
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode: Could not guard on data-dependent expression -u0 > 60 (unhinted: -u0 > 60). (Size-like symbols: none)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721]
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] Caused by: (_meta_registrations.py:5545 in meta_select)
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] For more information, run with TORCH_LOGS="dynamic"
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721]
E1004 00:20:20.557000 3670787 site-packages/torch/_subclasses/fake_tensor.py:2721] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
def forward(self, arg0_1: "i64[]", arg1_1: "f32[60]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:701 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(arg0_1); arg0_1 = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:702 in forward, code: return y[a]
select = torch.ops.aten.select.int(arg1_1, 0, item); arg1_1 = item = select = None
def forward(self, arg0_1: "i64[]", arg1_1: "f32[60]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:701 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(arg0_1); arg0_1 = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:702 in forward, code: return y[a]
select = torch.ops.aten.select.int(arg1_1, 0, item); arg1_1 = item = select = None
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 709, in <module>
export(Foo(), inps)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
^^^^^^^^^^^
File "<string>", line 1, in <lambda>
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 702, in forward
return y[a]
~^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1026, in run
t = _method(t, *_args)
^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
r = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_meta_registrations.py", line 5545, in meta_select
guard_size_oblivious(-index > size) or guard_size_oblivious(index >= size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 473, in guard_size_oblivious
return expr.node.guard_size_oblivious("", 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 596, in guard_size_oblivious
r = self.evaluate(size_oblivious=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
return self.shape_env.evaluate_sym_node(self, size_oblivious)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
return self.evaluate_expr(
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
return self._inner_evaluate_expr(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
return self._evaluate_expr(
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7570, in _evaluate_expr
raise self._make_data_dependent_error(
torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode: Could not guard on data-dependent expression -u0 > 60 (unhinted: -u0 > 60). (Size-like symbols: none)
Caused by: (_meta_registrations.py:5545 in meta_select)
For more information, run with TORCH_LOGS="dynamic"
For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
The following call raised this error:
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 702, in forward
return y[a]
To fix the error, insert one of the following checks before this call:
1. torch._check((-1)*a > 60)
2. torch._check((-1)*a <= 60)
(These suggested fixes were derived by replacing `u0` with a in -u0 > 60 and its negation.)
The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.
Here is a scenario where torch._check() insertion is required simply to prevent an operation from failing. The export call will fail with
“Could not guard on data-dependent expression -u0 > 60”, implying that the compiler doesn’t know if this is a valid indexing operation -
if the value of x is out-of-bounds for y or not. Here, manual specialization is too prohibitive, and torch.cond() has no place.
Instead, informing the compiler of u0’s range is sufficient:
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
torch._check(a >= 0)
torch._check(a < y.shape[0])
return y[a]
inps = (
torch.tensor(32),
torch.randn(60),
)
ep = export(Foo(), inps)
print(ep)
I1004 00:20:20.569000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.573000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.574000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I1004 00:20:20.575000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 >= 0 [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:722 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 >= 0"
V1004 00:20:20.575000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[0, int_oo] (update)
I1004 00:20:20.578000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 < 60 [guard added] (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:723 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 < 60"
V1004 00:20:20.579000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[0, 59] (update)
V1004 00:20:20.582000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(-u0 > 60) == False [statically known]
V1004 00:20:20.582000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(u0 >= 60) == False [statically known]
V1004 00:20:20.583000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == True [statically known]
V1004 00:20:20.583000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7475] eval False == True [statically known]
I1004 00:20:20.585000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.586000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.586000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 60 None
V1004 00:20:20.586000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V1004 00:20:20.586000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:20:20.587000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 0 == True [statically known]
V1004 00:20:20.589000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 <= 59 == True [statically known]
V1004 00:20:20.589000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 < 60 == True [statically known]
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "i64[]", y: "f32[60]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:721 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(x); x = None
ge_1: "Sym(u0 >= 0)" = item >= 0
_assert_scalar_default = torch.ops.aten._assert_scalar.default(ge_1, "Runtime assertion failed for expression u0 >= 0 on node 'ge_1'"); ge_1 = _assert_scalar_default = None
le: "Sym(u0 <= 59)" = item <= 59
_assert_scalar_default_1 = torch.ops.aten._assert_scalar.default(le, "Runtime assertion failed for expression u0 <= 59 on node 'le'"); le = _assert_scalar_default_1 = None
#
lt_1: "Sym(u0 < 60)" = item < 60
_assert_scalar_default_2 = torch.ops.aten._assert_scalar.default(lt_1, "Runtime assertion failed for expression u0 < 60 on node 'lt_1'"); lt_1 = _assert_scalar_default_2 = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:724 in forward, code: return y[a]
select: "f32[]" = torch.ops.aten.select.int(y, 0, item); y = item = None
return (select,)
Graph signature:
# inputs
x: USER_INPUT
y: USER_INPUT
# outputs
select: USER_OUTPUT
Range constraints: {u0: VR[0, 59]}
Specialized values#
Another category of data-dependent error happens when the program attempts to extract a concrete data-dependent integer/float value while tracing. This looks something like “Could not extract specialized integer from data-dependent expression”, and is analogous to the previous class of errors - if these occur when attempting to evaluate concrete integer/float values, data-dependent guard errors arise with evaluating concrete boolean values.
This error typically occurs when there is an explicit or implicit int() cast on a data-dependent expression. For example, this list comprehension
has a range() call that implicitly does an int() cast on the size of the list:
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
b = torch.cat([y for y in range(a)], dim=0)
return b + int(a)
inps = (
torch.tensor(32),
torch.randn(60),
)
try:
export(Foo(), inps, strict=False)
except Exception:
tb.print_exc()
I1004 00:20:20.594000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.599000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.599000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] Data dependent variable 'u0' allocated at:
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/bin/sphinx-build", line 7, in <module>
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] sys.exit(main())
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 339, in main
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make_main(argv)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 213, in make_main
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make_mode.run_make_mode(argv[1:])
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make.run_generic_build(args[0])
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return build_main(args + opts)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._init_builder()
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self.events.emit('builder-inited')
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] results.append(listener.handler(self.app, *args))
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ) = generate_dir_rst(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] results = parallel(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/conf.py", line 86, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] p.start()
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 121, in start
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._popen = self._Popen(self)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _default_context.get_context().Process._Popen(process_obj)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return Popen(process_obj)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._launch(process_obj)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] code = process_obj._bootstrap(parent_sentinel=child_r)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self.run()
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/multiprocessing/process.py", line 108, in run
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] self._target(*self._args, **self._kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/conf.py", line 74, in call_fn
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] result = func(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] output_blocks, time_elapsed = execute_script(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] execute_code_block(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] is_last_expr, mem_max = _exec_and_get_memory(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] mem_max, _ = call_memory(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return 0.0, func()
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] exec(self.code, self.fake_main.__dict__)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 756, in <module>
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] export(Foo(), inps, strict=False)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _export(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ep = _export_for_training(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] export_artifact = export_func(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] aten_export_artifact = _to_aten_func( # type: ignore[operator]
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] gm, graph_signature = transform(_make_fx_helper)(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] gm = make_fx(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return make_fx_tracer.trace(f, *args)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._trace_inner(f, *args)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] t = dispatch_trace(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return disable_fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] res = super().trace(root, concrete_args)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] (self.create_arg(fn(*args)),),
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] out = f(*tensors) # type:ignore[call-arg]
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "<string>", line 1, in <lambda>
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return tuple(flat_fn(*args))
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] tree_out = fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] out = mod(*args[params_len:], **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] tree_out = mod(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 747, in forward
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] a = x.item()
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 950, in handler
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return torch._library.utils.handle_dispatch_mode(
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return proxy_call(self, func, self.pre_dispatch, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] out = func(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_ops.py", line 829, in __call__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._op(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/utils/_stats.py", line 28, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self.dispatch(func, types, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._cached_dispatch_impl(func, types, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1474, in _cached_dispatch_impl
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return self._dispatch_impl(func, types, args, kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 2687, in _dispatch_impl
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] op_impl_out = op_impl(self, func, *args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 163, in dispatch_to_op_implementations_dict
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return op_implementations_dict[func](fake_mode, func, *args, **kwargs)
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 425, in local_scalar_dense
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] r = fake_mode.shape_env.create_unbacked_symint()
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519] return retlog(fn(*args, **kwargs))
V1004 00:20:20.600000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6519]
def forward(self, arg0_1: "i64[]", arg1_1: "f32[60]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:747 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(arg0_1); arg0_1 = item = None
def forward(self, arg0_1: "i64[]", arg1_1: "f32[60]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:747 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(arg0_1); arg0_1 = item = None
Traceback (most recent call last):
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 756, in <module>
export(Foo(), inps, strict=False)
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 319, in export
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/__init__.py", line 286, in export
return _export(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
^^^^^^^^^^^
File "<string>", line 1, in <lambda>
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py", line 748, in forward
b = torch.cat([y for y in range(a)], dim=0)
^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/__init__.py", line 438, in __index__
return self.node.int_()
^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 468, in int_
return self.guard_int("", 0) # NB: uses Python backtrace
^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 518, in guard_int
r = self.evaluate()
^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
return self.shape_env.evaluate_sym_node(self, size_oblivious)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
return self.evaluate_expr(
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
return self._inner_evaluate_expr(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
return self._evaluate_expr(
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/torch/fx/experimental/symbolic_shapes.py", line 7570, in _evaluate_expr
raise self._make_data_dependent_error(
torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode: Could not extract specialized integer from data-dependent expression u0 (unhinted: u0). (Size-like symbols: none)
Caused by: (orkspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:748 in forward)
For more information, run with TORCH_LOGS="dynamic"
For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.
For these errors, some basic options you have are:
Avoid unnecessary
int()cast calls, in this case theint(a)in the return statement.Use
torch._check()calls; unfortunately all you may be able to do in this case is specialize (withtorch._check(a == 60)).Rewrite the offending code at a higher level. For example, the list comprehension is semantically a
repeat()op, which doesn’t involve anint()cast. The following rewrite avoids data-dependent errors:
class Foo(torch.nn.Module):
def forward(self, x, y):
a = x.item()
b = y.unsqueeze(0).repeat(a, 1)
return b + a
inps = (
torch.tensor(32),
torch.randn(60),
)
ep = export(Foo(), inps, strict=False)
print(ep)
I1004 00:20:20.611000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.616000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I1004 00:20:20.616000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I1004 00:20:20.620000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 >= 0 [guard added] (_meta_registrations.py:4247 in meta_repeat), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 >= 0"
V1004 00:20:20.620000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[0, int_oo] (update)
V1004 00:20:20.621000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 0 == True [statically known]
I1004 00:20:20.623000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7369] could not evaluate Eq(u0, 0) due to data dependency, it was assumed to be False with no runtime assertions (utils/_stats.py:28 in wrapper)
I1004 00:20:20.623000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7369] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
I1004 00:20:20.628000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7369] could not evaluate 60*u0 < 2 due to data dependency, it was assumed to be False with no runtime assertions (_prims_common/__init__.py:279 in is_contiguous)
I1004 00:20:20.628000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7369] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
I1004 00:20:20.629000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7369] could not evaluate Eq(u0, 1) due to data dependency, it was assumed to be False with no runtime assertions (_prims_common/__init__.py:285 in is_contiguous)
I1004 00:20:20.629000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7369] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
V1004 00:20:20.631000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I1004 00:20:20.635000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.636000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V1004 00:20:20.636000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 60 None
V1004 00:20:20.636000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V1004 00:20:20.636000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V1004 00:20:20.637000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 0 == True [statically known]
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "i64[]", y: "f32[60]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:769 in forward, code: a = x.item()
item: "Sym(u0)" = torch.ops.aten.item.default(x); x = None
#
sym_constrain_range_for_size_default = torch.ops.aten.sym_constrain_range_for_size.default(item); sym_constrain_range_for_size_default = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:769 in forward, code: a = x.item()
ge: "Sym(u0 >= 0)" = item >= 0
_assert_scalar_default = torch.ops.aten._assert_scalar.default(ge, "Runtime assertion failed for expression u0 >= 0 on node 'ge'"); ge = _assert_scalar_default = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:770 in forward, code: b = y.unsqueeze(0).repeat(a, 1)
unsqueeze: "f32[1, 60]" = torch.ops.aten.unsqueeze.default(y, 0); y = None
repeat: "f32[u0, 60]" = torch.ops.aten.repeat.default(unsqueeze, [item, 1]); unsqueeze = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:771 in forward, code: return b + a
add: "f32[u0, 60]" = torch.ops.aten.add.Tensor(repeat, item); repeat = item = None
return (add,)
Graph signature:
# inputs
x: USER_INPUT
y: USER_INPUT
# outputs
add: USER_OUTPUT
Range constraints: {u0: VR[0, int_oo]}
Data-dependent errors can be much more involved, and there are many more options in your toolkit to deal with them: torch._check_is_size(), guard_size_oblivious(), or real-tensor tracing, as starters.
For more in-depth guides, please refer to the Export Programming Model,
or Dealing with GuardOnDataDependentSymNode errors.
Custom Ops#
torch.export can export PyTorch programs with custom operators. Please
refer to this page
on how to author a custom operator in either C++ or Python.
The following is an example of registering a custom operator in python to be
used by torch.export. The important thing to note is that the custom op
must have a FakeTensor kernel.
@torch.library.custom_op("my_custom_library::custom_op", mutates_args={})
def custom_op(x: torch.Tensor) -> torch.Tensor:
print("custom_op called!")
return torch.relu(x)
@custom_op.register_fake
def custom_op_meta(x):
# Returns an empty tensor with the same shape as the expected output
return torch.empty_like(x)
Here is an example of exporting a program with the custom op.
class CustomOpExample(torch.nn.Module):
def forward(self, x):
x = torch.sin(x)
x = torch.ops.my_custom_library.custom_op(x)
x = torch.cos(x)
return x
exported_custom_op_example = export(CustomOpExample(), (torch.randn(3, 3),))
print(exported_custom_op_example)
print(exported_custom_op_example.module()(torch.randn(3, 3)))
I1004 00:20:20.685000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.695000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.695000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 3 None
V1004 00:20:20.695000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 3 None
V1004 00:20:20.695000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 3 None
V1004 00:20:20.695000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 1 None
V1004 00:20:20.695000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, x: "f32[3, 3]"):
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:812 in forward, code: x = torch.sin(x)
sin: "f32[3, 3]" = torch.ops.aten.sin.default(x); x = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:813 in forward, code: x = torch.ops.my_custom_library.custom_op(x)
custom_op: "f32[3, 3]" = torch.ops.my_custom_library.custom_op.default(sin); sin = None
# File: /workspace/tutorials-kr/intermediate_source/torch_export_tutorial.py:814 in forward, code: x = torch.cos(x)
cos: "f32[3, 3]" = torch.ops.aten.cos.default(custom_op); custom_op = None
return (cos,)
Graph signature:
# inputs
x: USER_INPUT
# outputs
cos: USER_OUTPUT
Range constraints: {}
custom_op called!
tensor([[0.7485, 0.6790, 0.8114],
[1.0000, 0.9969, 1.0000],
[0.9950, 1.0000, 0.6667]])
Note that in the ExportedProgram, the custom operator is included in the graph.
IR/Decompositions#
The graph produced by torch.export returns a graph containing only
ATen operators, which are the
basic unit of computation in PyTorch. As there are over 3000 ATen operators,
export provides a way to narrow down the operator set used in the graph based
on certain characteristics, creating different IRs.
By default, export produces the most generic IR which contains all ATen
operators, including both functional and non-functional operators. A functional
operator is one that does not contain any mutations or aliasing of the inputs.
You can find a list of all ATen operators
here
and you can inspect if an operator is functional by checking
op._schema.is_mutable, for example:
print(torch.ops.aten.add.Tensor._schema.is_mutable)
print(torch.ops.aten.add_.Tensor._schema.is_mutable)
False
True
This generic IR can be used to train in eager PyTorch Autograd. This IR can be
more explicitly reached through the API torch.export.export_for_training,
which was introduced in PyTorch 2.5, but calling torch.export.export
should produce the same graph as of PyTorch 2.6.
class DecompExample(torch.nn.Module):
def __init__(self) -> None:
super().__init__()
self.conv = torch.nn.Conv2d(1, 3, 1, 1)
self.bn = torch.nn.BatchNorm2d(3)
def forward(self, x):
x = self.conv(x)
x = self.bn(x)
return (x,)
ep_for_training = torch.export.export_for_training(DecompExample(), (torch.randn(1, 1, 3, 3),))
print(ep_for_training.graph)
I1004 00:20:20.702000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:20.727000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:20.727000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 1 None
V1004 00:20:20.727000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 1 None
V1004 00:20:20.727000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[2] 3 None
V1004 00:20:20.727000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[3] 3 None
V1004 00:20:20.728000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 9 None
V1004 00:20:20.728000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 9 None
V1004 00:20:20.728000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[2] 3 None
V1004 00:20:20.728000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[3] 1 None
V1004 00:20:20.728000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
graph():
%p_conv_weight : [num_users=1] = placeholder[target=p_conv_weight]
%p_conv_bias : [num_users=1] = placeholder[target=p_conv_bias]
%p_bn_weight : [num_users=1] = placeholder[target=p_bn_weight]
%p_bn_bias : [num_users=1] = placeholder[target=p_bn_bias]
%b_bn_running_mean : [num_users=1] = placeholder[target=b_bn_running_mean]
%b_bn_running_var : [num_users=1] = placeholder[target=b_bn_running_var]
%b_bn_num_batches_tracked : [num_users=1] = placeholder[target=b_bn_num_batches_tracked]
%x : [num_users=1] = placeholder[target=x]
%conv2d : [num_users=1] = call_function[target=torch.ops.aten.conv2d.default](args = (%x, %p_conv_weight, %p_conv_bias), kwargs = {})
%add_ : [num_users=0] = call_function[target=torch.ops.aten.add_.Tensor](args = (%b_bn_num_batches_tracked, 1), kwargs = {})
%batch_norm : [num_users=1] = call_function[target=torch.ops.aten.batch_norm.default](args = (%conv2d, %p_bn_weight, %p_bn_bias, %b_bn_running_mean, %b_bn_running_var, True, 0.1, 1e-05, True), kwargs = {})
return (batch_norm,)
We can then lower this exported program to an operator set which only contains
functional ATen operators through the API run_decompositions, which
decomposes the ATen operators into the ones specified in the decomposition
table, and functionalizes the graph. By specifying an empty set, we’re only
performing functionalization, and does not do any additional decompositions.
This results in an IR which contains ~2000 operators (instead of the 3000
operators above), and is ideal for inference cases.
ep_for_inference = ep_for_training.run_decompositions(decomp_table={})
print(ep_for_inference.graph)
graph():
%p_conv_weight : [num_users=1] = placeholder[target=p_conv_weight]
%p_conv_bias : [num_users=1] = placeholder[target=p_conv_bias]
%p_bn_weight : [num_users=1] = placeholder[target=p_bn_weight]
%p_bn_bias : [num_users=1] = placeholder[target=p_bn_bias]
%b_bn_running_mean : [num_users=1] = placeholder[target=b_bn_running_mean]
%b_bn_running_var : [num_users=1] = placeholder[target=b_bn_running_var]
%b_bn_num_batches_tracked : [num_users=1] = placeholder[target=b_bn_num_batches_tracked]
%x : [num_users=1] = placeholder[target=x]
%conv2d : [num_users=1] = call_function[target=torch.ops.aten.conv2d.default](args = (%x, %p_conv_weight, %p_conv_bias), kwargs = {})
%add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%b_bn_num_batches_tracked, 1), kwargs = {})
%_native_batch_norm_legit_functional : [num_users=3] = call_function[target=torch.ops.aten._native_batch_norm_legit_functional.default](args = (%conv2d, %p_bn_weight, %p_bn_bias, %b_bn_running_mean, %b_bn_running_var, True, 0.1, 1e-05), kwargs = {})
%getitem : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 0), kwargs = {})
%getitem_3 : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 3), kwargs = {})
%getitem_4 : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 4), kwargs = {})
return (getitem_3, getitem_4, add, getitem)
As we can see, the previously mutable operator,
torch.ops.aten.add_.default has now been replaced with
torch.ops.aten.add.default, a l operator.
We can also further lower this exported program to an operator set which only contains the Core ATen Operator Set, which is a collection of only ~180 operators. This IR is optimal for backends who do not want to reimplement all ATen operators.
from torch.export import default_decompositions
core_aten_decomp_table = default_decompositions()
core_aten_ep = ep_for_training.run_decompositions(decomp_table=core_aten_decomp_table)
print(core_aten_ep.graph)
graph():
%p_conv_weight : [num_users=1] = placeholder[target=p_conv_weight]
%p_conv_bias : [num_users=1] = placeholder[target=p_conv_bias]
%p_bn_weight : [num_users=1] = placeholder[target=p_bn_weight]
%p_bn_bias : [num_users=1] = placeholder[target=p_bn_bias]
%b_bn_running_mean : [num_users=1] = placeholder[target=b_bn_running_mean]
%b_bn_running_var : [num_users=1] = placeholder[target=b_bn_running_var]
%b_bn_num_batches_tracked : [num_users=1] = placeholder[target=b_bn_num_batches_tracked]
%x : [num_users=1] = placeholder[target=x]
%convolution : [num_users=1] = call_function[target=torch.ops.aten.convolution.default](args = (%x, %p_conv_weight, %p_conv_bias, [1, 1], [0, 0], [1, 1], False, [0, 0], 1), kwargs = {})
%add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%b_bn_num_batches_tracked, 1), kwargs = {})
%_native_batch_norm_legit_functional : [num_users=3] = call_function[target=torch.ops.aten._native_batch_norm_legit_functional.default](args = (%convolution, %p_bn_weight, %p_bn_bias, %b_bn_running_mean, %b_bn_running_var, True, 0.1, 1e-05), kwargs = {})
%getitem : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 0), kwargs = {})
%getitem_3 : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 3), kwargs = {})
%getitem_4 : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 4), kwargs = {})
return (getitem_3, getitem_4, add, getitem)
We now see that torch.ops.aten.conv2d.default has been decomposed
into torch.ops.aten.convolution.default. This is because convolution
is a more “core” operator, as operations like conv1d and conv2d can be
implemented using the same op.
We can also specify our own decomposition behaviors:
my_decomp_table = torch.export.default_decompositions()
def my_awesome_custom_conv2d_function(x, weight, bias, stride=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1):
return 2 * torch.ops.aten.convolution(x, weight, bias, stride, padding, dilation, False, [0, 0], groups)
my_decomp_table[torch.ops.aten.conv2d.default] = my_awesome_custom_conv2d_function
my_ep = ep_for_training.run_decompositions(my_decomp_table)
print(my_ep.graph)
graph():
%p_conv_weight : [num_users=1] = placeholder[target=p_conv_weight]
%p_conv_bias : [num_users=1] = placeholder[target=p_conv_bias]
%p_bn_weight : [num_users=1] = placeholder[target=p_bn_weight]
%p_bn_bias : [num_users=1] = placeholder[target=p_bn_bias]
%b_bn_running_mean : [num_users=1] = placeholder[target=b_bn_running_mean]
%b_bn_running_var : [num_users=1] = placeholder[target=b_bn_running_var]
%b_bn_num_batches_tracked : [num_users=1] = placeholder[target=b_bn_num_batches_tracked]
%x : [num_users=1] = placeholder[target=x]
%convolution : [num_users=1] = call_function[target=torch.ops.aten.convolution.default](args = (%x, %p_conv_weight, %p_conv_bias, [1, 1], [0, 0], [1, 1], False, [0, 0], 1), kwargs = {})
%mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convolution, 2), kwargs = {})
%add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%b_bn_num_batches_tracked, 1), kwargs = {})
%_native_batch_norm_legit_functional : [num_users=3] = call_function[target=torch.ops.aten._native_batch_norm_legit_functional.default](args = (%mul, %p_bn_weight, %p_bn_bias, %b_bn_running_mean, %b_bn_running_var, True, 0.1, 1e-05), kwargs = {})
%getitem : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 0), kwargs = {})
%getitem_3 : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 3), kwargs = {})
%getitem_4 : [num_users=1] = call_function[target=operator.getitem](args = (%_native_batch_norm_legit_functional, 4), kwargs = {})
return (getitem_3, getitem_4, add, getitem)
Notice that instead of torch.ops.aten.conv2d.default being decomposed
into torch.ops.aten.convolution.default, it is now decomposed into
torch.ops.aten.convolution.default and torch.ops.aten.mul.Tensor,
which matches our custom decomposition rule.
ExportDB#
torch.export will only ever export a single computation graph from a PyTorch program. Because of this requirement,
there will be Python or PyTorch features that are not compatible with torch.export, which will require users to
rewrite parts of their model code. We have seen examples of this earlier in the tutorial – for example, rewriting
if-statements using cond.
ExportDB is the standard reference that documents
supported and unsupported Python/PyTorch features for torch.export. It is essentially a list a program samples, each
of which represents the usage of one particular Python/PyTorch feature and its interaction with torch.export.
Examples are also tagged by category so that they can be more easily searched.
For example, let’s use ExportDB to get a better understanding of how the predicate works in the cond operator.
We can look at the example called cond_predicate, which has a torch.cond tag. The example code looks like:
def cond_predicate(x):
"""
The conditional statement (aka predicate) passed to ``cond()`` must be one of the following:
- ``torch.Tensor`` with a single element
- boolean expression
NOTE: If the `pred` is test on a dim with batch size < 2, it will be specialized.
"""
pred = x.dim() > 2 and x.shape[2] > 10
return cond(pred, lambda x: x.cos(), lambda y: y.sin(), [x])
More generally, ExportDB can be used as a reference when one of the following occurs:
Before attempting
torch.export, you know ahead of time that your model uses some tricky Python/PyTorch features and you want to know iftorch.exportcovers that feature.When attempting
torch.export, there is a failure and it’s unclear how to work around it.
ExportDB is not exhaustive, but is intended to cover all use cases found in typical PyTorch code. Feel free to reach
out if there is an important Python/PyTorch feature that should be added to ExportDB or supported by torch.export.
Running the Exported Program#
As torch.export is only a graph capturing mechanism, calling the artifact
produced by torch.export eagerly will be equivalent to running the eager
module. To optimize the execution of the Exported Program, we can pass this
exported artifact to backends such as Inductor through torch.compile,
AOTInductor,
or TensorRT.
class M(torch.nn.Module):
def __init__(self):
super().__init__()
self.linear = torch.nn.Linear(3, 3)
def forward(self, x):
x = self.linear(x)
return x
inp = torch.randn(2, 3, device="cuda")
m = M().to(device="cuda")
ep = torch.export.export(m, (inp,))
# Run it eagerly
res = ep.module()(inp)
print(res)
# Run it with torch.compile
res = torch.compile(ep.module(), backend="inductor")(inp)
print(res)
I1004 00:20:21.493000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] create_env
I1004 00:20:21.503000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V1004 00:20:21.503000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 2 None
V1004 00:20:21.504000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 3 None
V1004 00:20:21.504000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 3 None
V1004 00:20:21.504000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 1 None
V1004 00:20:21.504000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
tensor([[-0.8696, 0.6491, 1.1789],
[ 1.0454, -1.0737, -0.5275]], device='cuda:0',
grad_fn=<AddmmBackward0>)
I1004 00:20:22.488000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:3767] [2/0] create_env
/opt/conda/lib/python3.11/site-packages/torch/_inductor/compile_fx.py:282: UserWarning:
TensorFloat32 tensor cores for float32 matrix multiplication available but not enabled. Consider setting `torch.set_float32_matmul_precision('high')` for better performance.
V1004 00:20:24.047000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7461] [2/0] eval 0 [trivial]
V1004 00:20:24.052000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:7461] [2/0] eval 1 [trivial]
I1004 00:20:24.368000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] [2/0] produce_guards
I1004 00:20:24.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5238] [2/0] produce_guards
V1004 00:20:24.376000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].size()[0] 2 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].size()[1] 3 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].stride()[0] 3 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].stride()[1] 1 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].storage_offset() 0 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].size()[0] 3 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].size()[1] 3 None
V1004 00:20:24.377000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].stride()[0] 3 None
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].stride()[1] 1 None
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].storage_offset() 0 None
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['bias'].size()[0] 3 None
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['bias'].stride()[0] 1 None
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['bias'].storage_offset() 0 None
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].size()[0] == 2
V1004 00:20:24.378000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].size()[1] == 3
V1004 00:20:24.379000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].stride()[0] == 3
V1004 00:20:24.379000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].stride()[1] == 1
V1004 00:20:24.379000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].storage_offset() == 0
V1004 00:20:24.379000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].size()[0] == 3
V1004 00:20:24.379000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].size()[1] == 3
V1004 00:20:24.379000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].stride()[0] == 3
V1004 00:20:24.380000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].stride()[1] == 1
V1004 00:20:24.380000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].storage_offset() == 0
V1004 00:20:24.380000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['bias'].size()[0] == 3
V1004 00:20:24.380000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['bias'].stride()[0] == 1
V1004 00:20:24.380000 3670787 site-packages/torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['bias'].storage_offset() == 0
tensor([[-0.8696, 0.6491, 1.1789],
[ 1.0454, -1.0737, -0.5275]], device='cuda:0',
grad_fn=<CompiledFunctionBackward>)
import torch._inductor
# Note: these APIs are subject to change
# Compile the exported program to a PT2 archive using ``AOTInductor``
with torch.no_grad():
pt2_path = torch._inductor.aoti_compile_and_package(ep)
# Load and run the .so file in Python.
# To load and run it in a C++ environment, see:
# https://pytorch.org/docs/main/torch.compiler_aot_inductor.html
aoti_compiled = torch._inductor.aoti_load_package(pt2_path)
res = aoti_compiled(inp)
Conclusion#
We introduced torch.export, the new PyTorch 2.X way to export single computation
graphs from PyTorch programs. In particular, we demonstrate several code modifications
and considerations (control flow ops, constraints, etc.) that need to be made in order to export a graph.
Total running time of the script: (0 minutes 42.143 seconds)