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

update ctxs of bsym representing torch.autograd.Funcion #1462

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
15 changes: 15 additions & 0 deletions thunder/core/jit_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,21 @@ def grad_transform(*args, **kwargs):
execution_transform=core_of_forward,
grad_transform=grad_transform,
)

bsym_of_func: BoundSymbol = get_jit_ctx().computation_trace.scopes[-1][-1]
import_ctx, call_ctx, object_ctx = {}, {}, {}
for bsym in trace_of_fwd.bound_symbols:
for d_to_update, src in zip((import_ctx, call_ctx, object_ctx), bsym.gather_ctxs()):
d_to_update.update(src)
if import_ctx:
bsym_of_func._import_ctx.update(import_ctx)
if call_ctx:
if bsym_of_func._call_ctx is not None:
bsym_of_func._call_ctx = call_ctx
else:
bsym_of_func._call_ctx.update(call_ctx)
if object_ctx:
bsym_of_func._object_ctx.update(object_ctx)
return forward_result


Expand Down
Loading