Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the prologue in check_vjp #1427

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions thunder/tests/opinfos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,12 +1648,7 @@ def celu_sample_generator(op, device, dtype, requires_grad):
dtypes=(datatypes.floating,),
sample_input_generator=celu_sample_generator,
torch_reference=_elementwise_unary_torch(torch.celu),
test_directives=(
DecorateInfo(
custom_comparator(partial(assert_close, atol=1e-6, rtol=1e-6)),
"test_vjp_correctness",
),
),
test_directives=(),
)
elementwise_unary_ops.append(celu_opinfo)

Expand Down
6 changes: 2 additions & 4 deletions thunder/tests/test_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,15 @@ def check_vjp(f, *primals, comp, executor="torch", set_compile_data: bool = Fals

u = tree_map(make, primals)

# dirty little trick for speed: skip the prologue
jf = executor.make_callable(f, disable_torch_autograd=True)
comp_f = thunder.compile_data(jf).get_computation_and_inputs(*primals)[0].computation_fn
comp_f = thunder.jit(f)

outs_p, J_u = numerical_jvp(comp_f)(primals, u)

multiple_results = isinstance(outs_p, Sequence)

v = tree_map(make, outs_p)
if set_compile_data:
with thunder.core.compile_data.compile_data_and_stats(thunder.compile_data(jf), None):
with thunder.core.compile_data.compile_data_and_stats(thunder.compile_data(comp_f), None):
initial_trace_vjp_f = thunder.trace()(vjp(f), primals, v)
else:
initial_trace_vjp_f = thunder.trace()(vjp(f), primals, v)
Expand Down
Loading