Skip to content

Commit 8778e40

Browse files
committed
Add test for Inductor fallback
1 parent 5bcd895 commit 8778e40

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

thunder/tests/test_dynamo.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,24 @@ def func(x):
155155
assert any(target.startswith("thunder_") for target in targets) # Verify that the submodules have name `thunder_*`
156156

157157

158+
@instantiate(dtypes=NOTHING)
159+
def test_inductor_fallback(executor, device, dtype):
160+
x = torch.randn(3, 3, device=device, dtype=dtype)
161+
162+
def func(x):
163+
return x.sinc().cos().sinc().sinc()
164+
165+
def trivial_compile(model, *args, **kwargs):
166+
return model
167+
168+
cfunc = thunderfx(func)
169+
with patch("torch._inductor.compile_fx.compile_fx", side_effect=trivial_compile) as mock_call:
170+
cfunc(x)
171+
172+
# Once for sinc() and once for sinc().sinc()
173+
assert mock_call.call_count == 2
174+
175+
158176
@instantiate(
159177
dtypes=NOTHING,
160178
executors=[DynamoThunderExecutor],

0 commit comments

Comments
 (0)