注意
跳到最后下载完整示例代码。
torch.export 教程#
创建于:2023年10月02日 | 最后更新:2025年01月27日 | 最后验证:2024年11月05日
作者: William Wen, Zhengxu Chen, Angela Yi, Pian Pawakapan
警告
torch.export
及其相关功能处于原型阶段,可能存在向后不兼容的更改。本教程提供了 PyTorch 2.5 中 torch.export
用法的一个快照。
torch.export()
是 PyTorch 2.X 中将 PyTorch 模型导出为标准化模型表示的方法,旨在在不同的(即无 Python 的)环境中运行。官方文档可在此处找到。
在本教程中,您将学习如何使用 torch.export()
从 PyTorch 程序中提取 ExportedProgram
(即单图表示)。我们还将详细说明您可能需要进行的一些考虑/修改,以使您的模型与 torch.export
兼容。
内容
基本用法#
torch.export
通过给定示例输入来追踪目标函数,从而从 PyTorch 程序中提取单图表示。torch.export.export()
是 torch.export
的主要入口点。
在本教程中,torch.export
和 torch.export.export()
实际上是同义词,尽管 torch.export
通常指 PyTorch 2.X 导出过程,而 torch.export.export()
通常指实际的函数调用。
torch.export.export()
的签名是
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()
通过调用 mod(*args, **kwargs)
来追踪张量计算图,并将其封装在 ExportedProgram
中,该程序可以序列化或稍后使用不同的输入执行。要执行 ExportedProgram
,我们可以对其调用 .module()
以返回一个 torch.nn.Module
,该模块可调用,就像原始程序一样。我们将在本教程的后面详细介绍 dynamic_shapes
参数。
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.5841, 0.2436, 1.4318, 0.4833, 0.0000, 0.0000, 0.4459, 0.0000, 0.0000,
0.0261],
[0.0000, 0.3076, 0.7006, 0.0000, 0.0000, 1.4329, 1.2819, 0.5917, 0.0000,
0.0000],
[0.0000, 0.4326, 0.5646, 0.0000, 0.0000, 0.0000, 0.8712, 0.4053, 0.0000,
0.1184],
[0.0000, 0.0000, 1.5187, 0.0886, 1.1841, 1.9360, 0.8710, 0.0828, 0.3565,
0.0000],
[0.0000, 0.1547, 0.0000, 0.8242, 0.7148, 0.3902, 0.5161, 0.0000, 1.2215,
0.3352],
[0.0000, 0.7022, 0.4164, 0.0000, 0.8376, 0.1391, 0.0000, 0.0000, 0.5833,
0.3531],
[2.0872, 0.0000, 0.0000, 0.0000, 0.0000, 0.0075, 0.0000, 0.4213, 1.0923,
0.1521],
[0.0000, 0.5056, 0.0000, 0.0000, 0.0000, 0.1845, 0.0000, 0.0000, 0.2468,
0.0629]], grad_fn=<ReluBackward0>)
让我们回顾一下 ExportedProgram
中一些值得关注的属性。
graph
属性是从我们导出的函数中追踪的 FX 图,即所有 PyTorch 操作的计算图。FX 图采用“ATen IR”表示,这意味着它仅包含“ATen 级别”的操作。
graph_signature
属性提供了导出图中输入和输出节点的更详细描述,说明哪些是参数、缓冲区、用户输入或用户输出。
range_constraints
属性将在后面介绍。
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: /var/lib/workspace/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: /usr/local/lib/python3.10/dist-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: /var/lib/workspace/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: {}
有关更多详细信息,请参阅 torch.export
文档。
图中断#
尽管 torch.export
与 torch.compile
共享组件,但 torch.export
的关键限制在于它不支持图中断。这是因为处理图中断涉及使用默认 Python 评估来解释不支持的操作,这与导出用例不兼容。因此,为了使您的模型代码与 torch.export
兼容,您需要修改代码以移除图中断。
在以下情况下需要图中断:
数据依赖的控制流
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: /var/lib/workspace/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: /var/lib/workspace/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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 122, in <module>
export(Bad1(), (torch.randn(3, 3),))
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 319, in export
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/lib/python3.10/dist-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 "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 116, in forward
if x.sum() > 0:
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 538, in guard_bool
r = self.evaluate()
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
return self.shape_env.evaluate_sym_node(self, size_oblivious)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
return self.evaluate_expr(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
return self._inner_evaluate_expr(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
return self._evaluate_expr(
File "/usr/local/lib/python3.10/dist-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 "/var/lib/workspace/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()`.
使用
.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()
调用不支持的函数(例如许多内置函数)
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()
非严格导出#
默认情况下,torch.export
使用 TorchDynamo(一个字节码分析引擎)来符号化分析 Python 代码并根据结果构建图,从而追踪程序。这种分析使 torch.export
能够提供更强的安全保证,但并非所有 Python 代码都受支持,导致这些图中断。
为了解决这个问题,在 PyTorch 2.3 中,我们引入了一种新的导出模式,称为非严格模式,在该模式下,我们使用 Python 解释器按其在 eager 模式下的方式精确执行程序,从而允许我们跳过不受支持的 Python 功能。这是通过添加 strict=False
标志来完成的。
回顾一些导致图中断的先前示例
调用不支持的函数(例如许多内置函数)会追踪
,但在此情况下,id(x)
在图中被特殊化为一个常量整数。这是因为 id(x)
不是张量操作,因此该操作未记录在图中。
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: /var/lib/workspace/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: /var/lib/workspace/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, 139970646554832); add = None
return (add_1,)
Graph signature:
# inputs
x: USER_INPUT
# outputs
add_1: USER_OUTPUT
Range constraints: {}
tensor([[1.3997e+14, 1.3997e+14, 1.3997e+14],
[1.3997e+14, 1.3997e+14, 1.3997e+14],
[1.3997e+14, 1.3997e+14, 1.3997e+14]])
但是,仍有一些功能需要重写原始模块
控制流操作#
torch.export
实际上支持数据依赖的控制流。但是这些需要使用控制流操作来表达。例如,我们可以像这样使用 cond
操作来修复上面的控制流示例
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: /var/lib/workspace/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]])
cond
存在一些限制,应该注意:
谓词(即
x.sum() > 0
)必须产生布尔值或单元素张量。操作数(即
[x]
)必须是张量。分支函数(即
true_fn
和false_fn
)的签名必须与操作数匹配,并且它们都必须返回具有相同元数据(例如,dtype
、shape
等)的单个张量。分支函数不能修改输入或全局变量。
分支函数不能访问闭包变量,除非函数定义在方法的范围内,否则不能访问
self
。
有关 cond
的更多详细信息,请查看 cond 文档。
我们还可以使用 map
,它在第一个张量参数的第一个维度上应用一个函数。
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.]])
其他控制流操作包括 while_loop
、associative_scan
和 scan
。有关每个操作符的更多文档,请参阅此页面。
约束/动态形状#
本节介绍导出程序的动态行为和表示。动态行为因特定要导出的模型而异,因此在本教程的大部分内容中,我们将重点关注这个特定的玩具模型(并标注了生成的张量形状)
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
默认情况下,torch.export
生成一个静态程序。其结果之一是,在运行时,该程序将无法处理具有不同形状的输入,即使它们在 eager 模式下是有效的。
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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 286, in <module>
ep.module()(w, x, torch.randn(3, 4), torch.randn(12))
File "/usr/local/lib/python3.10/dist-packages/torch/fx/graph_module.py", line 848, in call_wrapped
return self._wrapped_call(self, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/graph_module.py", line 424, in __call__
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/fx/graph_module.py", line 411, in __call__
return super(self.cls, obj).__call__(*args, **kwargs) # type: ignore[misc]
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1879, in _call_impl
return inner()
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1806, in inner
args_kwargs_result = hook(self, args, kwargs) # type: ignore[misc]
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_unlift.py", line 83, in _check_input_constraints_pre_hook
_check_input_constraints_for_graph(
File "/usr/local/lib/python3.10/dist-packages/torch/_export/utils.py", line 426, in _check_input_constraints_for_graph
_check_symint(
File "/usr/local/lib/python3.10/dist-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)
基本概念:符号和守卫#
为了启用动态性,export()
提供了一个 dynamic_shapes
参数。使用动态形状最简单的方法是使用 Dim.AUTO
并查看返回的程序。动态行为在输入维度级别指定;对于每个输入,我们可以指定一个值元组
在查看生成的程序之前,让我们了解指定 dynamic_shapes
的含义,以及它如何与导出交互。对于指定了 Dim
对象的每个输入维度,都会分配一个符号,其范围为 [2, inf]
(为什么不是 [0, inf]
或 [1, inf]
?我们将在 0/1 特化部分稍后解释)。
导出然后运行模型追踪,查看模型执行的每个操作。每个单独的操作都可以发出所谓的“守卫”;基本上是程序有效所必需的布尔条件。当守卫涉及为输入维度分配的符号时,程序包含对有效输入形状的限制;即程序的动态行为。符号形状子系统负责接收所有发出的守卫并生成符合所有这些守卫的最终程序表示。在我们看到 ExportedProgram
中的“最终表示”之前,让我们看看我们正在追踪的玩具模型发出的守卫。
在这里,每个前向输入张量都标注了在追踪开始时分配的符号
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
让我们了解每个操作和发出的守卫
x0 = x + y
:这是一个带广播的元素级加法,因为x
是一个一维张量,y
是一个二维张量。x
在y
的最后一个维度上进行广播,发出守卫s2 == s4
。x1 = self.l(w)
:调用nn.Linear()
会执行与模型参数的矩阵乘法。在导出中,参数、缓冲区和常量被视为程序状态,这被认为是静态的,因此这是动态输入(w: [s0, s1]
)与静态形状张量的矩阵乘法。这会发出守卫s1 == 5
。x2 = x0.flatten()
:此调用实际上没有发出任何守卫!(至少与输入形状无关)x3 = x2 + z
:展平后x2
的形状为[s3*s4]
,此元素级加法发出s3 * s4 == s5
。
将所有这些守卫写下来并总结起来几乎就像一个数学证明,这就是符号形状子系统试图做的事情!总而言之,我们可以得出结论,程序必须具有以下输入形状才能有效
w: [s0, 5]
x: [s2]
y: [s3, s2]
z: [s2*s3]
当我们最终打印出导出的程序以查看结果时,这些形状就是我们在相应输入上看到的标注。
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: /var/lib/workspace/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: /usr/local/lib/python3.10/dist-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: /var/lib/workspace/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: /var/lib/workspace/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]}
另一个值得注意的特性是上面的 range_constraints
字段,其中包含每个符号的有效范围。目前这并不是很有趣,因为此导出调用不会发出任何与符号边界相关的守卫,并且每个基本符号都有一个通用边界,但这将在稍后出现。
到目前为止,由于我们一直在导出这个玩具模型,这种体验并不能代表调试动态形状守卫和问题通常有多困难。在大多数情况下,不清楚会发出哪些守卫,以及哪些操作和用户代码部分负责。对于这个玩具模型,我们精确地指出了确切的行,并且守卫非常直观。
在更复杂的情况下,一个有用的第一步是始终启用详细日志记录。这可以通过环境变量 TORCH_LOGS="+dynamic"
或通过交互式 torch._logging.set_logs(dynamic=10)
来完成
I0807 18:29:20.153000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:20.155000 31202 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"
I0807 18:29:20.155000 31202 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"
V0807 18:29:20.156000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.158000 31202 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"
I0807 18:29:20.159000 31202 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"
I0807 18:29:20.160000 31202 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"
I0807 18:29:20.161000 31202 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"
V0807 18:29:20.166000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.167000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.168000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.169000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.169000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.170000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.171000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.171000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.173000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.173000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.175000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.176000 31202 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)"
I0807 18:29:20.177000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s77 (solve) VR[2, int_oo]
V0807 18:29:20.178000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.184000 31202 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)"
V0807 18:29:20.185000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I0807 18:29:20.185000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V0807 18:29:20.197000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(Eq(s17*s77, 1)) == False [statically known]
V0807 18:29:20.198000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.200000 31202 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)"
V0807 18:29:20.202000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[4, int_oo] (update)
I0807 18:29:20.202000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = s17*s77 (solve) VR[4, int_oo]
I0807 18:29:20.207000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:20.207000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s15 None
V0807 18:29:20.208000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 None
V0807 18:29:20.208000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V0807 18:29:20.208000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V0807 18:29:20.208000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V0807 18:29:20.209000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s77 None
V0807 18:29:20.209000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V0807 18:29:20.209000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:20.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V0807 18:29:20.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] s77 None
V0807 18:29:20.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] s77 None
V0807 18:29:20.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V0807 18:29:20.211000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:20.211000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] s17*s77 None
V0807 18:29:20.211000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V0807 18:29:20.211000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
V0807 18:29:20.220000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
V0807 18:29:20.226000 31202 torch/fx/experimental/symbolic_shapes.py:7461] eval 5 [trivial]
即使是这个简单的玩具模型,它也会吐出相当多的内容。这里的日志行已被截断,忽略了不必要的信息,但通过查看日志,我们可以看到与我们上面描述的相关行;例如,符号的分配
"""
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"
带有 create_symbol 的行显示了何时分配了新符号,并且日志还识别了张量变量名和为它们分配的维度。在其他行中,我们还可以看到发出的守卫
"""
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'
在 [guard added]
消息旁边,我们还可以看到负责的用户代码行——幸运的是,这里的模型足够简单。在许多实际情况下,情况并非如此简单:高级 torch 操作可能具有复杂的伪内核实现或操作分解,这使得守卫的发出位置和内容变得复杂。在这种情况下,深入挖掘和调查的最佳方法是遵循日志的建议,并使用环境变量 TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="..."
重新运行,以进一步归因于感兴趣的守卫。
Dim.AUTO
只是与 dynamic_shapes
交互的可用选项之一;截至本文撰写时,还有另外 2 个选项可用:Dim.DYNAMIC
和 Dim.STATIC
。Dim.STATIC
只是将一个维度标记为静态,而 Dim.DYNAMIC
除了一个方面外,与 Dim.AUTO
在所有方面都相似:它在特化为常量时会引发错误;这旨在保持动态性。例如,看看当在动态标记的维度上发出静态守卫时会发生什么
I0807 18:29:20.231000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:20.232000 31202 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"
I0807 18:29:20.232000 31202 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"
V0807 18:29:20.233000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.235000 31202 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"
I0807 18:29:20.236000 31202 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"
I0807 18:29:20.237000 31202 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"
I0807 18:29:20.238000 31202 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"
V0807 18:29:20.243000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.244000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.244000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.246000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.246000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.247000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.248000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.248000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.249000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.250000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.252000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.253000 31202 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)"
I0807 18:29:20.254000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s77 (solve) VR[2, int_oo]
V0807 18:29:20.255000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.261000 31202 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)"
V0807 18:29:20.262000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I0807 18:29:20.262000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V0807 18:29:20.274000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(Eq(s17*s77, 1)) == False [statically known]
V0807 18:29:20.275000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.277000 31202 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)"
V0807 18:29:20.278000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[4, int_oo] (update)
I0807 18:29:20.279000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = s17*s77 (solve) VR[4, int_oo]
I0807 18:29:20.284000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:20.284000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s15 None
V0807 18:29:20.284000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 RelaxedUnspecConstraint(warn_only=False)
V0807 18:29:20.493000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V0807 18:29:20.494000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V0807 18:29:20.495000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V0807 18:29:20.495000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s77 None
V0807 18:29:20.495000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V0807 18:29:20.496000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:20.496000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V0807 18:29:20.496000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] s77 None
V0807 18:29:20.497000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] s77 None
V0807 18:29:20.497000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V0807 18:29:20.497000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:20.497000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] s17*s77 None
V0807 18:29:20.498000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V0807 18:29:20.498000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 549, in produce_guards_and_solve_constraints
raise constraint_violation_error
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 418, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 269, in forward
x1 = self.l(w) # [6, 3]
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/linear.py", line 125, in forward
return F.linear(input, self.weight, self.bias)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2601, in _dispatch_impl
decomposition_table[func](*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_decomp/decompositions.py", line 90, in inner
r = f(*tree_map(increase_prec, args), **tree_map(increase_prec, kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_decomp/decompositions.py", line 1462, in addmm
out = alpha * torch.mm(mat1, mat2)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
r = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_meta_registrations.py", line 2417, in meta_mm
torch._check(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 418, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 319, in export
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/lib/python3.10/dist-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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 418, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 269, in forward
x1 = self.l(w) # [6, 3]
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/linear.py", line 125, in forward
return F.linear(input, self.weight, self.bias)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2601, in _dispatch_impl
decomposition_table[func](*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_decomp/decompositions.py", line 90, in inner
r = f(*tree_map(increase_prec, args), **tree_map(increase_prec, kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_decomp/decompositions.py", line 1462, in addmm
out = alpha * torch.mm(mat1, mat2)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
r = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_prims_common/wrappers.py", line 309, in _fn
result = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_meta_registrations.py", line 2417, in meta_mm
torch._check(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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()`.
静态守卫并非总是模型固有的;它们也可以来自用户规范。事实上,导致形状特化的一个常见陷阱是当用户为等效维度指定冲突的标记时;一个是动态的,另一个是静态的。当 x.shape[0]
和 y.shape[1]
出现这种情况时,会引发相同的错误类型
I0807 18:29:20.566000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:20.568000 31202 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"
I0807 18:29:20.568000 31202 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"
V0807 18:29:20.569000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.571000 31202 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"
I0807 18:29:20.572000 31202 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"
I0807 18:29:20.574000 31202 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"
V0807 18:29:20.580000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.581000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.582000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.583000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.584000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.585000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.586000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.586000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.592000 31202 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)"
V0807 18:29:20.593000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s94 = VR[4, 4] (update)
I0807 18:29:20.593000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = 4 (range_refined_to_singleton) VR[4, 4]
I0807 18:29:20.602000 31202 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)"
V0807 18:29:20.603000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I0807 18:29:20.604000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V0807 18:29:20.606000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.623000 31202 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)"
V0807 18:29:20.626000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[8, int_oo] (update)
I0807 18:29:20.627000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = 4*s17 (solve) VR[8, int_oo]
I0807 18:29:20.632000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:20.632000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s15 None
V0807 18:29:20.632000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 None
V0807 18:29:20.633000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V0807 18:29:20.633000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V0807 18:29:20.633000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V0807 18:29:20.633000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 4 None
V0807 18:29:20.634000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V0807 18:29:20.634000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:20.634000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V0807 18:29:20.635000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] 4 RelaxedUnspecConstraint(warn_only=False)
V0807 18:29:20.669000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 4 None
V0807 18:29:20.670000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V0807 18:29:20.670000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:20.670000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] 4*s17 None
V0807 18:29:20.671000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V0807 18:29:20.671000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 549, in produce_guards_and_solve_constraints
raise constraint_violation_error
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 431, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 268, in forward
x0 = x + y # [8, 4]
File "??", line 0, in PyNumber_Add
File "??", line 0, in _Py_c_pow
File "??", line 0, in PyThread_start_new_thread
File "??", line 0, in _PyType_LookupId
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 431, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 319, in export
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/lib/python3.10/dist-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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 431, in <module>
export(model, (w, x, y, z), dynamic_shapes=dynamic_shapes)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 268, in forward
x0 = x + y # [8, 4]
File "??", line 0, in PyNumber_Add
File "??", line 0, in _Py_c_pow
File "??", line 0, in PyThread_start_new_thread
File "??", line 0, in _PyType_LookupId
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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()`.
这里你可能会问为什么导出会“特化”,即为什么我们通过选择静态路径来解决这种静态/动态冲突。答案是因为上面描述的符号和守卫的符号形状系统。当 x.shape[0]
被标记为静态时,我们不分配符号,并将其编译为具体的整数 4。为 y.shape[1]
分配了一个符号,因此我们最终发出守卫 s3 == 4
,导致特化。
导出的一个特性是,在追踪过程中,断言、torch._check()
和 if/else
条件等语句也会发出守卫。看看当我们使用这些语句增强现有模型时会发生什么
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()
I0807 18:29:20.729000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:20.731000 31202 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"
I0807 18:29:20.731000 31202 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"
V0807 18:29:20.732000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.734000 31202 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"
I0807 18:29:20.735000 31202 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"
I0807 18:29:20.736000 31202 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"
I0807 18:29:20.738000 31202 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"
V0807 18:29:20.743000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.744000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.745000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.746000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.746000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.748000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.748000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.749000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.750000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.751000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.756000 31202 torch/fx/experimental/symbolic_shapes.py:7197] eval s15 <= 512 [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:450 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="s15 <= 512"
V0807 18:29:20.757000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s15 = VR[2, 512] (update)
I0807 18:29:20.760000 31202 torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert s77 >= 4 [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:451 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="s77 >= 4"
V0807 18:29:20.761000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s77 = VR[4, int_oo] (update)
I0807 18:29:20.766000 31202 torch/fx/experimental/symbolic_shapes.py:7197] eval Eq(s15, s77 + 2) [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:452 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(s15, s77 + 2)"
V0807 18:29:20.767000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s15 = VR[6, 512] (update)
V0807 18:29:20.769000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s77 = VR[4, 510] (update)
I0807 18:29:20.770000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s15 = s77 + 2 (solve) VR[6, 512]
V0807 18:29:20.772000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.775000 31202 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)"
V0807 18:29:20.776000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s94 = VR[4, 510] (update)
I0807 18:29:20.776000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s77 (solve) VR[4, 510]
V0807 18:29:20.780000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.786000 31202 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)"
V0807 18:29:20.787000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s21 = VR[5, 5] (update)
I0807 18:29:20.788000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s21 = 5 (range_refined_to_singleton) VR[5, 5]
V0807 18:29:20.803000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(Eq(s17*s77, 1)) == False [statically known]
V0807 18:29:20.804000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.813000 31202 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)"
V0807 18:29:20.815000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s68 = VR[8, int_oo] (update)
I0807 18:29:20.815000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s68 = s17*s77 (solve) VR[8, int_oo]
I0807 18:29:20.820000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:20.821000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[0] s77 + 2 None
V0807 18:29:20.821000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].size()[1] 5 None
V0807 18:29:20.822000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[0] 5 None
V0807 18:29:20.822000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].stride()[1] 1 None
V0807 18:29:20.822000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['w'].storage_offset() 0 None
V0807 18:29:20.823000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s77 None
V0807 18:29:20.823000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 1 None
V0807 18:29:20.823000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:20.824000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 None
V0807 18:29:20.824000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] s77 None
V0807 18:29:20.824000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] s77 None
V0807 18:29:20.825000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V0807 18:29:20.825000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:20.825000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].size()[0] s17*s77 None
V0807 18:29:20.826000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].stride()[0] 1 None
V0807 18:29:20.826000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['z'].storage_offset() 0 None
V0807 18:29:20.838000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert s77 >= 4 == True [statically known]
V0807 18:29:20.839000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
V0807 18:29:20.846000 31202 torch/fx/experimental/symbolic_shapes.py:7461] eval 5 [trivial]
每个语句都会发出一个额外的守卫,并且导出的程序会显示更改;s0
被消除,取而代之的是 s2 + 2
,s2
现在包含下限和上限,这反映在 range_constraints
中。
对于 if/else 条件,您可能会问为什么会选择 True 分支,以及为什么不是从追踪中发出的 w.shape[0] != x.shape[0] + 2
守卫。答案是导出由追踪提供的样本输入引导,并特化于所采取的分支。如果提供了不同的样本输入形状导致 if 条件失败,导出将追踪并发出与 else 分支对应的守卫。此外,您可能会问为什么我们只追踪了 if 分支,以及是否可以在程序中保持控制流并保持两个分支都活跃。为此,请参阅上面 控制流操作
部分中对模型代码的重写。
0/1 特化#
既然我们正在讨论守卫和特化,那么现在是时候讨论我们前面提到的 0/1 特化问题了。最重要的是,导出将特化样本输入维度,其值为 0 或 1,因为这些形状具有追踪时属性,这些属性不适用于其他形状。例如,大小为 1 的张量可以广播,而其他大小则会失败;大小为 0 …。这仅仅意味着当您希望程序对它们进行硬编码时,您应该指定 0/1 样本输入,而当需要动态行为时,则指定非 0/1 样本输入。看看当我们导出这个线性层时运行时会发生什么
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()
I0807 18:29:20.852000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:20.863000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:20.864000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].size()[0] 1 None
V0807 18:29:20.864000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].size()[1] 4 None
V0807 18:29:20.864000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].stride()[0] 4 None
V0807 18:29:20.864000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].stride()[1] 1 None
V0807 18:29:20.865000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['input'].storage_offset() 0 None
W0807 18:29:20.867000 31202 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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 500, in <module>
ep.module()(torch.randn(2, 4))
File "/usr/local/lib/python3.10/dist-packages/torch/fx/graph_module.py", line 848, in call_wrapped
return self._wrapped_call(self, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/graph_module.py", line 424, in __call__
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/fx/graph_module.py", line 411, in __call__
return super(self.cls, obj).__call__(*args, **kwargs) # type: ignore[misc]
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1879, in _call_impl
return inner()
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1806, in inner
args_kwargs_result = hook(self, args, kwargs) # type: ignore[misc]
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_unlift.py", line 83, in _check_input_constraints_pre_hook
_check_input_constraints_for_graph(
File "/usr/local/lib/python3.10/dist-packages/torch/_export/utils.py", line 426, in _check_input_constraints_for_graph
_check_symint(
File "/usr/local/lib/python3.10/dist-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)
命名维度#
到目前为止,我们只讨论了 3 种指定动态形状的方法:Dim.AUTO
、Dim.DYNAMIC
和 Dim.STATIC
。它们的吸引力在于低摩擦的用户体验;在模型追踪过程中发出的所有守卫都会被遵守,并且动态行为,如最小/最大范围、关系以及静态/动态维度,都会在导出底层自动确定。动态形状子系统本质上充当一个“发现”过程,总结这些守卫并呈现导出认为的程序整体动态行为。这种设计的缺点在于,一旦用户对这些模型的动态行为有更强的期望或信念,就会出现问题——也许强烈希望保持动态性,不惜一切代价避免特定维度的特化,或者只是想通过更改原始模型代码来捕获动态行为的变化,或者可能是底层分解或元内核。这些变化将不会被检测到,并且 export()
调用很可能会成功,除非有测试来检查生成的 ExportedProgram
表示。
对于这种情况,我们建议使用“传统”的动态形状指定方式,导出工具的长期用户可能熟悉:命名 Dims
这种动态形状样式允许用户指定为输入维度分配哪些符号、这些符号的最小/最大边界,并对生成的 ExportedProgram
的动态行为施加限制;如果模型追踪发出与给定关系或静态/动态规范冲突的守卫,则会引发 ConstraintViolation
错误。例如,在上述规范中,断言了以下内容
x.shape[0]
的范围为[4, 256]
,并与y.shape[0]
通过y.shape[0] == 2 * x.shape[0]
相关。x.shape[1]
是静态的。y.shape[1]
的范围是[2, 512]
,并且与任何其他维度无关。
在这种设计中,我们允许维度之间的关系通过单变量线性表达式来指定:A * dim + B
可以为任何维度指定。这允许用户为动态维度指定更复杂的约束,例如整数可分性。
约束违规,建议修复#
这种指定方式的一个常见问题(在 Dim.AUTO
引入之前)是,该指定通常与模型追踪产生的结果不匹配。这将导致 ConstraintViolation
错误和导出建议的修复——例如,对于此模型和指定,模型本身要求 x
和 y
的维度 0 之间相等,并且要求维度 1 是静态的。
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()
I0807 18:29:20.875000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:20.877000 31202 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"
I0807 18:29:20.879000 31202 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"
V0807 18:29:20.880000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.882000 31202 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"
I0807 18:29:20.883000 31202 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"
V0807 18:29:20.889000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.891000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.892000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.893000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.894000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.895000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
V0807 18:29:20.897000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:20.899000 31202 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)"
I0807 18:29:20.900000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = s27 (solve) VR[2, int_oo]
I0807 18:29:20.902000 31202 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)"
I0807 18:29:20.904000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s77 = s17 (solve) VR[2, int_oo]
V0807 18:29:20.906000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == False [statically known]
I0807 18:29:20.915000 31202 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)"
V0807 18:29:20.916000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s27 = VR[4, 4] (update)
I0807 18:29:20.917000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s27 = 4 (range_refined_to_singleton) VR[4, 4]
I0807 18:29:20.922000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:20.923000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range s94 = VR[4, 4] (update)
I0807 18:29:20.923000 31202 torch/fx/experimental/symbolic_shapes.py:6776] set_replacement s94 = 4 (find) VR[4, 4]
V0807 18:29:20.923000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] s17 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V0807 18:29:20.924000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 4 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V0807 18:29:20.942000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 4 None
V0807 18:29:20.942000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 1 None
V0807 18:29:20.942000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:20.943000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] s17 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V0807 18:29:20.943000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[1] 4 StrictMinMaxConstraint(warn_only=False, vr=VR[0, int_oo])
V0807 18:29:20.953000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 4 None
V0807 18:29:20.953000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[1] 1 None
V0807 18:29:20.953000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 549, in produce_guards_and_solve_constraints
raise constraint_violation_error
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 553, in forward
return w + torch.ones(4)
File "??", line 0, in PyNumber_Add
File "??", line 0, in _Py_c_pow
File "??", line 0, in PyThread_start_new_thread
File "??", line 0, in _PyType_LookupId
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
File "??", line 0, in PyObject_Call
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 5405, in produce_guards_verbose
expr1, expr2 = get_expression(src1), get_expression(src2) # type: ignore[]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 5399, in get_expression
return symint.node.expr
File "??", line 0, in PyObject_GetAttr
File "??", line 0, in _PyObject_GenericGetAttrWithDict
File "??", line 0, in PyObject_IsTrue
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 189, in expr
return self.shape_env.replace(self._expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyErr_FormatFromCause
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6324, in replace
r = self._find(s)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyErr_FormatFromCause
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6809, in _find
self._set_replacement(a, replaced, "find")
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 319, in export
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/lib/python3.10/dist-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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-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 _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
out = f(*tensors) # type:ignore[call-arg]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "<string>", line 1, in <lambda>
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 553, in forward
return w + torch.ones(4)
File "??", line 0, in PyNumber_Add
File "??", line 0, in _Py_c_pow
File "??", line 0, in PyThread_start_new_thread
File "??", line 0, in _PyType_LookupId
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "??", line 0, in _PyObject_GetDictPtr
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 "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
return proxy_call(self, func, self.pre_dispatch, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in PyObject_CallMethod
File "??", line 0, in PyModule_AddObjectRef
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2581, in _dispatch_impl
return maybe_propagate_real_tensors(fast_impl(self, *args, **kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 962, in fast_binary_impl
final_shape = infer_size(final_shape, shape)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 922, in infer_size
torch._check(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1684, in _check
_check_with(RuntimeError, cond, message)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 1647, in _check_with
if expect_true(cond):
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 1702, in expect_true
return a.node.expect_true(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 559, in expect_true
return self.shape_env.guard_or_defer_runtime_assert(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7730, in guard_or_defer_runtime_assert
self._maybe_guard_rel(expr)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyCodec_EncodeText
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6868, in _maybe_guard_rel
self._refine_ranges(expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7819, in _refine_ranges
self._set_replacement(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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 "??", line 0, in _start
File "??", line 0, in __libc_start_main
File "??", line 0, in __libc_init_first
File "??", line 0, in Py_BytesMain
File "??", line 0, in Py_RunMain
File "??", line 0, in _PyRun_AnyFileObject
File "??", line 0, in _PyRun_SimpleFileObject
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyInit__collections
File "??", line 0, in PyUnicode_Tailmatch
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/bin/sphinx-build", line 7, in <module>
sys.exit(main())
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
return make_main(argv)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
return make_mode.run_make_mode(argv[1:])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
return make.run_generic_build(args[0])
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
return build_main(args + opts)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
self._init_builder()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
self.events.emit('builder-inited')
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
results.append(listener.handler(self.app, *args))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
) = generate_dir_rst(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
results = parallel(
File "??", line 0, in PyUnicode_Decode
File "??", line 0, in _PyLong_FromByteArray
File "??", line 0, in PyObject_SelfIter
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 85, in wrapper
p.start()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
return Popen(process_obj)
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in _PyStack_AsDict
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
code = process_obj._bootstrap(parent_sentinel=child_r)
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/conf.py", line 73, in call_fn
result = func(*args, **kwargs)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
output_blocks, time_elapsed = execute_script(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
execute_code_block(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
is_last_expr, mem_max = _exec_and_get_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
mem_max, _ = call_memory(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
return 0.0, func()
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyInit__datetime
File "??", line 0, in _PyObject_Call_Prepend
File "??", line 0, in _PyObject_FastCallDictTstate
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
exec(self.code, self.fake_main.__dict__)
File "??", line 0, in PyCell_New
File "??", line 0, in PyFrozenSet_New
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in PyEval_EvalCode
File "??", line 0, in _PyEval_EvalFrameDefault
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 557, in <module>
ep = export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1798, in _export_to_aten_ir_make_fx
produce_guards_callback(gm)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1944, in _produce_guards_callback
return produce_guards_and_solve_constraints(
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 514, in produce_guards_and_solve_constraints
shape_env.produce_guards(
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 5200, in produce_guards
return self.produce_guards_verbose(*args, **kwargs, langs=("python",))[0].exprs
File "??", line 0, in PyObject_Call
File "??", line 0, in PyMethod_New
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 5405, in produce_guards_verbose
expr1, expr2 = get_expression(src1), get_expression(src2) # type: ignore[]
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 5399, in get_expression
return symint.node.expr
File "??", line 0, in PyObject_GetAttr
File "??", line 0, in _PyObject_GenericGetAttrWithDict
File "??", line 0, in PyObject_IsTrue
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 189, in expr
return self.shape_env.replace(self._expr)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyErr_FormatFromCause
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6324, in replace
r = self._find(s)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 2539, in wrapper
return fn_cache(self, *args, **kwargs)
File "??", line 0, in PyObject_Call
File "??", line 0, in _PyErr_FormatFromCause
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6809, in _find
self._set_replacement(a, replaced, "find")
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 6768, in _set_replacement
CapturedTraceback.extract(cpp=True)
File "??", line 0, in _PyFunction_Vectorcall
File "??", line 0, in _PyEval_EvalFrameDefault
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_traceback.py", line 212, in extract
torch._C._profiler.gather_traceback(python=True, script=script, cpp=cpp),
File "??", line 0, in _PyObject_MakeTpCall
File "??", line 0, in PyObject_CallFunctionObjArgs
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()`.
建议的修复是,用户可以交互式地将更改复制粘贴到他们的动态形状规范中,然后成功导出。
最后,关于规范选项还有一些需要了解的:
None
是静态行为的一个很好的选择: -dynamic_shapes=None
(默认)将整个模型导出为静态。 - 在输入级别指定None
将所有张量维度导出为静态,并且对于非张量输入也是必需的。 - 在维度级别指定None
将特化该维度,尽管这已弃用,取而代之的是Dim.STATIC
。指定每维整数值也会产生静态行为,并且会额外检查所提供的样本输入是否与规范匹配。
这些选项结合在下面的输入和动态形状规范中
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,
}
数据依赖错误#
在尝试导出模型时,您可能遇到过诸如“无法基于数据依赖表达式设置守卫”或“无法从数据依赖表达式中提取特化整数”之类的错误。这些错误的存在是因为 torch.export()
使用 FakeTensors 编译程序,这些 FakeTensors 象征性地表示其真实的张量对应物。虽然这些具有等效的符号属性(例如大小、步长、数据类型),但它们的不同之处在于 FakeTensors 不包含任何数据值。虽然这避免了不必要的内存使用和昂贵的计算,但这也意味着导出可能无法开箱即用地编译用户代码中依赖数据值的部分。简而言之,如果编译器需要一个具体的、数据依赖的值才能继续,它将报错,抱怨该值不可用。
数据依赖的值出现在许多地方,常见的来源是诸如 item()
、tolist()
或 torch.unbind()
等从张量中提取标量值的调用。这些值在导出的程序中是如何表示的?在约束/动态形状一节中,我们讨论了分配符号来表示动态输入维度。这里也发生了同样的事情:我们为程序中出现的每个数据依赖值分配符号。重要的区别是这些是“无支持”符号,与为输入维度分配的“有支持”符号形成对比。“有支持/无支持”术语指的是符号是否存在“提示”:一个支持符号的具体值,可以告知编译器如何继续。
在输入形状符号(有支持符号)的情况下,这些提示仅仅是提供的样本输入形状,这解释了为什么控制流分支由样本输入属性决定。对于数据依赖值,符号在追踪期间从 FakeTensor“数据”中获取,因此编译器不知道这些符号将采用的实际值(提示)。
让我们看看这些如何出现在导出的程序中
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)
I0807 18:29:21.040000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.045000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.046000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I0807 18:29:21.050000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u1 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.050000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u1]
I0807 18:29:21.051000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u2 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.052000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u2]
I0807 18:29:21.053000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:21.054000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:21.054000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 2 None
V0807 18:29:21.054000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V0807 18:29:21.055000 31202 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: /var/lib/workspace/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: /var/lib/workspace/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]}
结果是分配并返回了 3 个无支持符号(注意它们以“u”而不是通常的“s”开头,后者用于输入形状/有支持符号):1 个用于 item()
调用,1 个用于 y
的每个元素,通过 tolist()
调用。请注意,从范围约束字段中,它们采用的范围是 [-int_oo, int_oo]
,而不是分配给输入形状符号的默认 [0, int_oo]
范围,因为我们不知道这些值是什么——它们不代表大小,因此不一定具有正值。
守卫,torch._check()#
但上面的情况很容易导出,因为这些符号的具体值未用于任何编译器决策;所有相关的是返回值是无支持符号。本节中强调的数据依赖错误是以下情况,其中遇到数据依赖守卫
这里我们实际上需要 a
的“提示”或具体值,以便编译器决定是追踪 return y + 2
还是 return y * 5
作为输出。因为我们使用 FakeTensors 进行追踪,所以我们不知道 a // 2 >= 5
实际评估结果,并且导出报错:“无法基于数据依赖表达式 u0 // 2 >= 5 (unhinted)
设置守卫”。
那么我们如何导出这个玩具模型呢?与 torch.compile()
不同,导出需要完整的图编译,我们不能仅仅在此处中断图。这里有一些基本选项:
手动特化:我们可以通过选择要追踪的分支进行干预,可以通过删除控制流代码以仅包含特化分支,或使用
torch.compiler.is_compiling()
在编译时守卫追踪的内容。torch.cond()
:我们可以重写控制流代码以使用torch.cond()
,这样我们就不特化一个分支。
虽然这些选项是有效的,但它们都有其缺点。选项 1 有时需要对模型代码进行大量侵入性重写才能进行特化,并且 torch.cond()
不是一个处理数据依赖错误的综合系统。
通常推荐的方法是使用 torch._check()
调用。虽然这些看起来纯粹是断言语句,但它们实际上是一个告知编译器符号属性的系统。虽然 torch._check()
调用在运行时确实充当断言,但在编译时追踪时,检查的表达式会发送到符号形状子系统进行推理,并且从表达式为真而来的任何符号属性都会存储为符号属性(如果它足够智能可以推断这些属性)。因此,即使无支持符号没有提示,如果我们能够通过 torch._check()
调用来传达这些符号通常为真的属性,我们就有可能绕过数据依赖守卫,而无需重写有问题的模型代码。
例如,在上面的模型中,插入 torch._check(a >= 10)
将告诉编译器始终可以返回 y + 2
,而 torch._check(a == 4)
将告诉它返回 y * 5
。看看我们重新导出此模型时会发生什么。
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)
I0807 18:29:21.061000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.066000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.066000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I0807 18:29:21.068000 31202 torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 >= 10 [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:673 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 >= 10"
V0807 18:29:21.069000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[10, int_oo] (update)
I0807 18:29:21.074000 31202 torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 <= 60 [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:674 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 <= 60"
V0807 18:29:21.075000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[10, 60] (update)
V0807 18:29:21.080000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == True [statically known]
I0807 18:29:21.083000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:21.083000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:21.084000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 4 None
V0807 18:29:21.084000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V0807 18:29:21.084000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:21.086000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 10 == True [statically known]
V0807 18:29:21.087000 31202 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: /var/lib/workspace/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: /var/lib/workspace/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]}
导出成功,请注意范围约束字段中 u0
的范围为 [10, 60]
。
那么 torch._check()
调用实际传达了哪些信息呢?这取决于符号形状子系统变得多么智能,但从根本上说,这些通常是正确的:
与非数据依赖表达式的相等性:
torch._check()
调用,用于传递诸如u0 == s0 + 4
或u0 == 5
等相等性。范围细化:提供符号下限或上限的调用,如上所示。
关于更复杂表达式的一些基本推理:插入
torch._check(a < 4)
通常会告诉编译器a >= 4
为假。对复杂表达式的检查,例如torch._check(a ** 2 - 3 * a <= 10)
通常会使您通过相同的守卫。
如前所述,torch._check()
调用不仅适用于数据依赖的控制流。例如,这里有一个模型,其中 torch._check()
插入有效,而手动特化和 torch.cond()
无效
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()
I0807 18:29:21.092000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.098000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.098000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] Data dependent variable 'u0' allocated at:
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/bin/sphinx-build", line 7, in <module>
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] sys.exit(main())
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make_main(argv)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make_mode.run_make_mode(argv[1:])
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make.run_generic_build(args[0])
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return build_main(args + opts)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._init_builder()
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self.events.emit('builder-inited')
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] results.append(listener.handler(self.app, *args))
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ) = generate_dir_rst(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] results = parallel(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/conf.py", line 85, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] p.start()
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._popen = self._Popen(self)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _default_context.get_context().Process._Popen(process_obj)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return Popen(process_obj)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._launch(process_obj)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] code = process_obj._bootstrap(parent_sentinel=child_r)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self.run()
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._target(*self._args, **self._kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/conf.py", line 73, in call_fn
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] result = func(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] output_blocks, time_elapsed = execute_script(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] execute_code_block(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] is_last_expr, mem_max = _exec_and_get_memory(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] mem_max, _ = call_memory(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return 0.0, func()
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] exec(self.code, self.fake_main.__dict__)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 709, in <module>
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] export(Foo(), inps)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _export(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ep = _export_for_training(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] export_artifact = export_func(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] aten_export_artifact = _to_aten_func( # type: ignore[operator]
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] gm, graph_signature = transform(_make_fx_helper)(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] gm = make_fx(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make_fx_tracer.trace(f, *args)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._trace_inner(f, *args)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] t = dispatch_trace(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return disable_fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] res = super().trace(root, concrete_args)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] (self.create_arg(fn(*args)),),
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] out = f(*tensors) # type:ignore[call-arg]
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "<string>", line 1, in <lambda>
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return tuple(flat_fn(*args))
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] tree_out = fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] out = mod(*args[params_len:], **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] tree_out = mod(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 701, in forward
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] a = x.item()
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return torch._library.utils.handle_dispatch_mode(
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return proxy_call(self, func, self.pre_dispatch, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] out = func(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._op(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self.dispatch(func, types, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._cached_dispatch_impl(func, types, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1474, in _cached_dispatch_impl
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._dispatch_impl(func, types, args, kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2687, in _dispatch_impl
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] op_impl_out = op_impl(self, func, *args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 163, in dispatch_to_op_implementations_dict
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return op_implementations_dict[func](fake_mode, func, *args, **kwargs)
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 425, in local_scalar_dense
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] r = fake_mode.shape_env.create_unbacked_symint()
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return retlog(fn(*args, **kwargs))
V0807 18:29:21.101000 31202 torch/fx/experimental/symbolic_shapes.py:6519]
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] failed while attempting to run meta for aten.select.int
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] Traceback (most recent call last):
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] r = func(*args, **kwargs)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return self._op(*args, **kwargs)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/_meta_registrations.py", line 5545, in meta_select
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] guard_size_oblivious(-index > size) or guard_size_oblivious(index >= size)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 473, in guard_size_oblivious
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return expr.node.guard_size_oblivious("", 0)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 596, in guard_size_oblivious
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] r = self.evaluate(size_oblivious=True)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return self.shape_env.evaluate_sym_node(self, size_oblivious)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return self.evaluate_expr(
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return self._inner_evaluate_expr(
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return retlog(fn(*args, **kwargs))
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] return self._evaluate_expr(
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7570, in _evaluate_expr
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] raise self._make_data_dependent_error(
E0807 18:29:21.110000 31202 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)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721]
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] Caused by: (_meta_registrations.py:5545 in meta_select)
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] For more information, run with TORCH_LOGS="dynamic"
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721] For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
E0807 18:29:21.110000 31202 torch/_subclasses/fake_tensor.py:2721]
E0807 18:29:21.110000 31202 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: /var/lib/workspace/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: /var/lib/workspace/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: /var/lib/workspace/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: /var/lib/workspace/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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 709, in <module>
export(Foo(), inps)
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 319, in export
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/lib/python3.10/dist-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 "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 702, in forward
return y[a]
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1026, in run
t = _method(t, *_args)
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
return torch._library.utils.handle_dispatch_mode(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
out = func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1487, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2717, in _dispatch_impl
r = func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
return self._op(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_meta_registrations.py", line 5545, in meta_select
guard_size_oblivious(-index > size) or guard_size_oblivious(index >= size)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 473, in guard_size_oblivious
return expr.node.guard_size_oblivious("", 0)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 596, in guard_size_oblivious
r = self.evaluate(size_oblivious=True)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
return self.shape_env.evaluate_sym_node(self, size_oblivious)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
return self.evaluate_expr(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
return self._inner_evaluate_expr(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
return self._evaluate_expr(
File "/usr/local/lib/python3.10/dist-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 "/var/lib/workspace/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()`.
这是一个 torch._check()
插入是必需的场景,仅仅是为了防止操作失败。导出调用将失败并显示“无法对数据相关表达式 -u0 > 60
进行保护”,这意味着编译器不知道这是否是有效的索引操作——即 x
的值是否超出 y
的范围。在这里,手动特化过于严格,torch.cond()
没有用武之地。相反,告知编译器 u0
的范围就足够了
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)
I0807 18:29:21.125000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.130000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.131000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I0807 18:29:21.132000 31202 torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 >= 0 [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:722 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 >= 0"
V0807 18:29:21.133000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[0, int_oo] (update)
I0807 18:29:21.136000 31202 torch/fx/experimental/symbolic_shapes.py:7197] runtime_assert u0 < 60 [guard added] (ar/lib/workspace/intermediate_source/torch_export_tutorial.py:723 in forward), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="u0 < 60"
V0807 18:29:21.136000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[0, 59] (update)
V0807 18:29:21.139000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(-u0 > 60) == False [statically known]
V0807 18:29:21.139000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval size_oblivious(u0 >= 60) == False [statically known]
V0807 18:29:21.140000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == True [statically known]
V0807 18:29:21.141000 31202 torch/fx/experimental/symbolic_shapes.py:7475] eval False == True [statically known]
I0807 18:29:21.143000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:21.144000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:21.144000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 60 None
V0807 18:29:21.144000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V0807 18:29:21.144000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:21.146000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 0 == True [statically known]
V0807 18:29:21.148000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 <= 59 == True [statically known]
V0807 18:29:21.149000 31202 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: /var/lib/workspace/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: /var/lib/workspace/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]}
特化值#
另一种数据依赖错误发生在程序在追踪时尝试提取具体的、数据依赖的整数/浮点值时。这看起来像“无法从数据依赖表达式中提取特化整数”,并且与上一类错误类似——如果这些错误发生在尝试评估具体的整数/浮点值时,则在评估具体的布尔值时会产生数据依赖的守卫错误。
此错误通常在数据相关表达式上存在显式或隐式 int()
类型转换时发生。例如,这个列表推导式有一个 range() 调用,它隐式地对列表的大小进行 int()
类型转换。
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()
I0807 18:29:21.155000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.162000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.162000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] Data dependent variable 'u0' allocated at:
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/bin/sphinx-build", line 7, in <module>
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] sys.exit(main())
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 339, in main
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make_main(argv)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 213, in make_main
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make_mode.run_make_mode(argv[1:])
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 181, in run_make_mode
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make.run_generic_build(args[0])
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/make_mode.py", line 169, in run_generic_build
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return build_main(args + opts)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/cmd/build.py", line 293, in build_main
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 272, in __init__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._init_builder()
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/application.py", line 343, in _init_builder
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self.events.emit('builder-inited')
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx/events.py", line 97, in emit
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] results.append(listener.handler(self.app, *args))
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_gallery.py", line 757, in generate_gallery_rst
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ) = generate_dir_rst(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 606, in generate_dir_rst
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] results = parallel(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 607, in <genexpr>
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] p_fun(fname, target_dir, src_dir, gallery_conf) for fname in iterator
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/conf.py", line 85, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] p.start()
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._popen = self._Popen(self)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _default_context.get_context().Process._Popen(process_obj)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/context.py", line 281, in _Popen
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return Popen(process_obj)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._launch(process_obj)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 71, in _launch
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] code = process_obj._bootstrap(parent_sentinel=child_r)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self.run()
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] self._target(*self._args, **self._kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/conf.py", line 73, in call_fn
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] result = func(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1374, in generate_file_rst
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] output_blocks, time_elapsed = execute_script(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1192, in execute_script
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] execute_code_block(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1048, in execute_code_block
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] is_last_expr, mem_max = _exec_and_get_memory(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 876, in _exec_and_get_memory
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] mem_max, _ = call_memory(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 1725, in _sg_call_memory_noop
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return 0.0, func()
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/sphinx_gallery/gen_rst.py", line 794, in __call__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] exec(self.code, self.fake_main.__dict__)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 756, in <module>
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] export(Foo(), inps, strict=False)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _export(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ep = _export_for_training(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ep = fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] export_artifact = export_func(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] aten_export_artifact = _to_aten_func( # type: ignore[operator]
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] gm, graph_signature = transform(_make_fx_helper)(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1900, in _aot_export_non_strict
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] gm, sig = aot_export(wrapped_mod, args, kwargs=kwargs, **flags)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] gm = make_fx(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return make_fx_tracer.trace(f, *args)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._trace_inner(f, *args)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] t = dispatch_trace(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return disable_fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1254, in dispatch_trace
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] graph = tracer.trace(root, concrete_args) # type: ignore[arg-type]
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] res = super().trace(root, concrete_args)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] (self.create_arg(fn(*args)),),
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1312, in wrapped
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] out = f(*tensors) # type:ignore[call-arg]
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "<string>", line 1, in <lambda>
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return tuple(flat_fn(*args))
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] tree_out = fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] out = mod(*args[params_len:], **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] tree_out = mod(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self.call_module(mod, forward, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return Tracer.call_module(self, m, forward, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] ret_val = forward(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return _orig_module_call(mod, *args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._call_impl(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return forward_call(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 747, in forward
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] a = x.item()
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1360, in __torch_function__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1407, in __torch_function__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_export/non_strict_utils.py", line 1051, in __torch_function__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return func(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 950, in handler
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return torch._library.utils.handle_dispatch_mode(
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_library/utils.py", line 296, in handle_dispatch_mode
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return curr_mode.__torch_dispatch__(op_overload, overload_types, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1462, in __torch_dispatch__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return proxy_call(self, func, self.pre_dispatch, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 914, in proxy_call
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] out = func(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 829, in __call__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._op(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/utils/_stats.py", line 28, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return fn(*args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1352, in __torch_dispatch__
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self.dispatch(func, types, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2058, in dispatch
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._cached_dispatch_impl(func, types, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 1474, in _cached_dispatch_impl
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return self._dispatch_impl(func, types, args, kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_tensor.py", line 2687, in _dispatch_impl
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] op_impl_out = op_impl(self, func, *args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 163, in dispatch_to_op_implementations_dict
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return op_implementations_dict[func](fake_mode, func, *args, **kwargs)
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/fake_impls.py", line 425, in local_scalar_dense
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] r = fake_mode.shape_env.create_unbacked_symint()
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519] return retlog(fn(*args, **kwargs))
V0807 18:29:21.163000 31202 torch/fx/experimental/symbolic_shapes.py:6519]
def forward(self, arg0_1: "i64[]", arg1_1: "f32[60]"):
# File: /var/lib/workspace/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: /var/lib/workspace/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 "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 756, in <module>
export(Foo(), inps, strict=False)
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 319, in export
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 286, in export
return _export(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2176, in _export
ep = _export_for_training(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1164, in wrapper
raise e
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1130, in wrapper
ep = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 123, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 2037, in _export_for_training
export_artifact = export_func(
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1979, in _non_strict_export
aten_export_artifact = _to_aten_func( # type: ignore[operator]
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1770, in _export_to_aten_ir_make_fx
gm, graph_signature = transform(_make_fx_helper)(
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/export/_trace.py", line 1685, in _make_fx_helper
gm = make_fx(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2318, in wrapped
return make_fx_tracer.trace(f, *args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2250, in trace
return self._trace_inner(f, *args)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 2221, in _trace_inner
t = dispatch_trace(
File "/usr/local/lib/python3.10/dist-packages/torch/_compile.py", line 53, in inner
return disable_fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-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/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1835, in trace
res = super().trace(root, concrete_args)
File "/usr/local/lib/python3.10/dist-packages/torch/_dynamo/eval_frame.py", line 929, in _fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 850, in trace
(self.create_arg(fn(*args)),),
File "/usr/local/lib/python3.10/dist-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 "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1589, in wrapped_fn
return tuple(flat_fn(*args))
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/utils.py", line 184, in flat_fn
tree_out = fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/_functorch/_aot_autograd/traced_function_transforms.py", line 906, in functional_call
out = mod(*args[params_len:], **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/export/_trace.py", line 1884, in forward
tree_out = mod(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 825, in module_call_wrapper
return self.call_module(mod, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/proxy_tensor.py", line 1905, in call_module
return Tracer.call_module(self, m, forward, args, kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 542, in call_module
ret_val = forward(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/_symbolic_trace.py", line 818, in forward
return _orig_module_call(mod, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
File "/var/lib/workspace/intermediate_source/torch_export_tutorial.py", line 748, in forward
b = torch.cat([y for y in range(a)], dim=0)
File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 438, in __index__
return self.node.int_()
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 468, in int_
return self.guard_int("", 0) # NB: uses Python backtrace
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 518, in guard_int
r = self.evaluate()
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/sym_node.py", line 512, in evaluate
return self.shape_env.evaluate_sym_node(self, size_oblivious)
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7223, in evaluate_sym_node
return self.evaluate_expr(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7323, in evaluate_expr
return self._inner_evaluate_expr(
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/recording.py", line 272, in wrapper
return retlog(fn(*args, **kwargs))
File "/usr/local/lib/python3.10/dist-packages/torch/fx/experimental/symbolic_shapes.py", line 7346, in _inner_evaluate_expr
return self._evaluate_expr(
File "/usr/local/lib/python3.10/dist-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: (ar/lib/workspace/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()`.
对于这些错误,您有一些基本选项:
避免不必要的
int()
转换调用,在本例中是返回语句中的int(a)
。使用
torch._check()
调用;不幸的是,在这种情况下,您唯一能做的就是特化(使用torch._check(a == 60)
)。在更高层重写有问题的代码。例如,列表推导式在语义上是一个
repeat()
操作,它不涉及int()
转换。以下重写避免了数据依赖错误
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)
I0807 18:29:21.180000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.185000 31202 torch/fx/experimental/symbolic_shapes.py:4776] create_unbacked_symint u0 [-int_oo, int_oo] (_subclasses/fake_impls.py:425 in local_scalar_dense)
I0807 18:29:21.186000 31202 torch/fx/experimental/symbolic_shapes.py:1287] compute_unbacked_bindings [u0]
I0807 18:29:21.190000 31202 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"
V0807 18:29:21.190000 31202 torch/fx/experimental/symbolic_shapes.py:6606] _update_var_to_range u0 = VR[0, int_oo] (update)
V0807 18:29:21.191000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert u0 >= 0 == True [statically known]
I0807 18:29:21.194000 31202 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)
I0807 18:29:21.194000 31202 torch/fx/experimental/symbolic_shapes.py:7369] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
I0807 18:29:21.201000 31202 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)
I0807 18:29:21.201000 31202 torch/fx/experimental/symbolic_shapes.py:7369] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
I0807 18:29:21.202000 31202 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)
I0807 18:29:21.202000 31202 torch/fx/experimental/symbolic_shapes.py:7369] For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
V0807 18:29:21.204000 31202 torch/fx/experimental/symbolic_shapes.py:7694] runtime_assert True == True [statically known]
I0807 18:29:21.209000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:21.209000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
V0807 18:29:21.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].size()[0] 60 None
V0807 18:29:21.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].stride()[0] 1 None
V0807 18:29:21.210000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['y'].storage_offset() 0 None
V0807 18:29:21.211000 31202 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: /var/lib/workspace/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: /var/lib/workspace/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: /var/lib/workspace/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: /var/lib/workspace/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]}
数据依赖错误可能更复杂,您的工具包中有更多处理它们的选项:torch._check_is_size()
、guard_size_oblivious()
或真实张量追踪,作为入门。有关更深入的指南,请参阅导出编程模型或处理 GuardOnDataDependentSymNode 错误。
自定义操作#
torch.export
可以导出包含自定义操作的 PyTorch 程序。请参阅此页面,了解如何在 C++ 或 Python 中编写自定义操作。
以下是注册一个在 python 中使用的自定义操作以供 torch.export
使用的示例。需要注意的是,自定义操作必须有一个 FakeTensor 内核。
@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)
以下是使用自定义操作导出程序的示例。
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)))
I0807 18:29:21.288000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.297000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:21.297000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 3 None
V0807 18:29:21.298000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 3 None
V0807 18:29:21.298000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 3 None
V0807 18:29:21.298000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 1 None
V0807 18:29:21.298000 31202 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: /var/lib/workspace/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: /var/lib/workspace/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: /var/lib/workspace/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([[1.0000, 0.9505, 1.0000],
[1.0000, 0.9908, 1.0000],
[0.6922, 0.9436, 1.0000]])
请注意,在 ExportedProgram
中,自定义操作包含在图中。
IR/分解#
torch.export
生成的图只包含 ATen 操作符,它们是 PyTorch 中计算的基本单元。由于有超过 3000 个 ATen 操作符,export 提供了一种根据某些特性缩小图中使用的操作符集的方法,从而创建不同的 IR。
默认情况下,导出会生成最通用的 IR,其中包含所有 ATen 操作符,包括功能性和非功能性操作符。功能性操作符是指不包含任何输入修改或别名的操作符。您可以在此处找到所有 ATen 操作符的列表,您可以通过检查 op._schema.is_mutable
来检查操作符是否是功能性的,例如
print(torch.ops.aten.add.Tensor._schema.is_mutable)
print(torch.ops.aten.add_.Tensor._schema.is_mutable)
False
True
此通用 IR 可用于在 eager PyTorch Autograd 中进行训练。此 IR 可以通过 PyTorch 2.5 中引入的 API torch.export.export_for_training
更明确地访问,但调用 torch.export.export
应在 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)
I0807 18:29:21.308000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:21.339000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:21.340000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 1 None
V0807 18:29:21.340000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 1 None
V0807 18:29:21.340000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[2] 3 None
V0807 18:29:21.341000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[3] 3 None
V0807 18:29:21.341000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 9 None
V0807 18:29:21.341000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 9 None
V0807 18:29:21.341000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[2] 3 None
V0807 18:29:21.342000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[3] 1 None
V0807 18:29:21.342000 31202 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,)
然后,我们可以通过 API run_decompositions
将这个导出的程序降低到一个只包含功能性 ATen 操作符的操作符集,该 API 将 ATen 操作符分解为分解表中指定的操作符,并使图功能化。通过指定一个空集,我们只执行功能化,而不执行任何额外的分解。这会生成一个包含约 2000 个操作符(而不是上面提到的 3000 个操作符)的 IR,非常适合推理场景。
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)
正如我们所看到的,之前可变的运算符 torch.ops.aten.add_.default
现在已被 torch.ops.aten.add.default
取代,后者是一个功能性运算符。
我们还可以将这个导出的程序进一步降低到仅包含核心 ATen 运算符集的运算符集,该集合包含大约 180 个运算符。这个 IR 对不希望重新实现所有 ATen 运算符的后端来说是最佳选择。
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)
我们现在看到 torch.ops.aten.conv2d.default
已被分解为 torch.ops.aten.convolution.default
。这是因为 convolution
是一个更“核心”的操作符,因为像 conv1d
和 conv2d
这样的操作可以使用相同的操作符来实现。
我们还可以指定自己的分解行为
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)
注意,torch.ops.aten.conv2d.default
没有分解成 torch.ops.aten.convolution.default
,而是分解成了 torch.ops.aten.convolution.default
和 torch.ops.aten.mul.Tensor
,这符合我们自定义的分解规则。
ExportDB#
torch.export
总是只从 PyTorch 程序中导出一个计算图。由于此要求,将存在与 torch.export
不兼容的 Python 或 PyTorch 功能,这将要求用户重写其模型代码的一部分。我们在本教程前面看到了这方面的示例——例如,使用 cond
重写 if 语句。
ExportDB 是记录 torch.export
支持和不支持的 Python/PyTorch 功能的标准参考。它本质上是一个程序示例列表,每个示例都代表了一个特定 Python/PyTorch 功能的用法及其与 torch.export
的交互。示例还按类别标记,以便更容易搜索。
例如,让我们使用 ExportDB 来更好地理解 cond
操作符中谓词的工作原理。我们可以查看名为 cond_predicate
的示例,它带有 torch.cond
标签。示例代码如下:
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])
更一般地,当发生以下情况时,ExportDB 可用作参考:
在尝试
torch.export
之前,您预先知道您的模型使用了一些棘手的 Python/PyTorch 功能,并且您想知道torch.export
是否涵盖该功能。尝试
torch.export
时失败,并且不清楚如何解决。
ExportDB 并非详尽无遗,但旨在涵盖典型 PyTorch 代码中发现的所有用例。如果存在应添加到 ExportDB 或由 torch.export
支持的重要 Python/PyTorch 功能,请随时联系我们。
运行导出的程序#
由于 torch.export
仅是一种图捕获机制,因此急切地调用 torch.export
生成的 Artifact 将等同于运行急切模块。为了优化导出程序的执行,我们可以将此导出 Artifact 传递给后端,例如通过 torch.compile
、AOTInductor 或 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)
I0807 18:29:22.282000 31202 torch/fx/experimental/symbolic_shapes.py:3767] create_env
I0807 18:29:22.295000 31202 torch/fx/experimental/symbolic_shapes.py:5238] produce_guards
V0807 18:29:22.296000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[0] 2 None
V0807 18:29:22.296000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].size()[1] 3 None
V0807 18:29:22.296000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[0] 3 None
V0807 18:29:22.296000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].stride()[1] 1 None
V0807 18:29:22.297000 31202 torch/fx/experimental/symbolic_shapes.py:5458] track_symint L['x'].storage_offset() 0 None
tensor([[ 0.0612, 0.3335, 0.3846],
[-0.0829, 0.1520, 0.3304]], device='cuda:0',
grad_fn=<AddmmBackward0>)
I0807 18:29:23.677000 31202 torch/fx/experimental/symbolic_shapes.py:3767] [2/0] create_env
/usr/local/lib/python3.10/dist-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.
I0807 18:29:24.401000 31202 torch/fx/experimental/symbolic_shapes.py:5238] [2/0] produce_guards
I0807 18:29:24.410000 31202 torch/fx/experimental/symbolic_shapes.py:5238] [2/0] produce_guards
V0807 18:29:24.410000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].size()[0] 2 None
V0807 18:29:24.411000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].size()[1] 3 None
V0807 18:29:24.411000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].stride()[0] 3 None
V0807 18:29:24.411000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].stride()[1] 1 None
V0807 18:29:24.412000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['x'].storage_offset() 0 None
V0807 18:29:24.412000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].size()[0] 3 None
V0807 18:29:24.412000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].size()[1] 3 None
V0807 18:29:24.412000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].stride()[0] 3 None
V0807 18:29:24.413000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].stride()[1] 1 None
V0807 18:29:24.413000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['weight'].storage_offset() 0 None
V0807 18:29:24.413000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['bias'].size()[0] 3 None
V0807 18:29:24.413000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['bias'].stride()[0] 1 None
V0807 18:29:24.414000 31202 torch/fx/experimental/symbolic_shapes.py:5458] [2/0] track_symint L['self']._modules['linear']._parameters['bias'].storage_offset() 0 None
V0807 18:29:24.414000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].size()[0] == 2
V0807 18:29:24.414000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].size()[1] == 3
V0807 18:29:24.415000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].stride()[0] == 3
V0807 18:29:24.415000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].stride()[1] == 1
V0807 18:29:24.415000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['x'].storage_offset() == 0
V0807 18:29:24.415000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].size()[0] == 3
V0807 18:29:24.416000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].size()[1] == 3
V0807 18:29:24.416000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].stride()[0] == 3
V0807 18:29:24.416000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].stride()[1] == 1
V0807 18:29:24.417000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['weight'].storage_offset() == 0
V0807 18:29:24.417000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['bias'].size()[0] == 3
V0807 18:29:24.417000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['bias'].stride()[0] == 1
V0807 18:29:24.417000 31202 torch/fx/experimental/symbolic_shapes.py:5679] [2/0] Skipping guard L['self']._modules['linear']._parameters['bias'].storage_offset() == 0
tensor([[ 0.0612, 0.3335, 0.3846],
[-0.0829, 0.1520, 0.3304]], 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.ac.cn/docs/stable/torch.compiler_aot_inductor.html
aoti_compiled = torch._inductor.aoti_load_package(pt2_path)
res = aoti_compiled(inp)
结论#
我们介绍了 torch.export
,这是 PyTorch 2.X 中从 PyTorch 程序导出单个计算图的新方法。我们特别演示了为了导出图而需要进行的几项代码修改和考虑(控制流操作、约束等)。
脚本总运行时间: (0 分钟 5.199 秒)