Skip to content

Commit 3533c59

Browse files
authored
[thunderfx] Handle output node with no example_value (#2429)
1 parent e7d0977 commit 3533c59

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

thunder/dynamo/splitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def is_thunder_supported_partition(node: torch.fx.Node) -> bool:
172172
for n in graph_module.graph.nodes:
173173
if n.op == "output":
174174
for n in n.all_input_nodes:
175-
if n.meta["example_value"].grad_fn is None:
175+
if "example_value" not in n.meta or n.meta["example_value"].grad_fn is None:
176176
is_differentiable_outputs.append(False)
177177
else:
178178
is_differentiable_outputs.append(True)

thunder/tests/test_dynamo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,3 +1686,15 @@ def forward(self, x):
16861686
actual_output.backward()
16871687
expected_output.backward()
16881688
torch.testing.assert_close(org_m.fc.weight.grad, thunder_m.fc.weight.grad)
1689+
1690+
1691+
def test_thunderfx_node_with_no_example_value():
1692+
def test_fn(x):
1693+
y = x + 10
1694+
z = y.tolist()[0]
1695+
return z + 2
1696+
1697+
x = torch.tensor([1, 2, 3, 4, 5])
1698+
actual = thunderfx(test_fn)(x)
1699+
expected = test_fn(x)
1700+
torch.testing.assert_close(actual, expected)

0 commit comments

Comments
 (0)