Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
578d06e
Refactor connection to autograd with new joint trace creation
beverlylytle May 20, 2025
b04654a
apply update_fusion_call_ctx
beverlylytle May 21, 2025
0c19438
check bw for None
beverlylytle May 21, 2025
f0182ee
don't fuse get_grad
beverlylytle May 23, 2025
440bc96
group get_grads together for torch compile fusions
beverlylytle May 23, 2025
6bb4293
remove torchex impl of get_grad in favor of OpExProcessor exception
beverlylytle May 23, 2025
01dea9d
Merge branch 'main' into reautograd2
beverlylytle May 26, 2025
f45c92d
hide behind flag and clean up
beverlylytle May 26, 2025
eb32063
Xfail test_ddp_grad_bucketing
IvanYashchuk May 27, 2025
32b9675
Xfail test_limit_in_flight_allgathers with bucketing
IvanYashchuk May 27, 2025
675ea02
Xfail test_fsdp_with_no_sync_grad_accumulation
IvanYashchuk May 27, 2025
aafc899
Xfail test_fsdp_grad_parity_with_without_bucketing
IvanYashchuk May 27, 2025
9b4b252
Fix test_rematerialize_all_gather
IvanYashchuk May 27, 2025
a27f390
Restore test_torch_compile_cat_rope_single_fusion
IvanYashchuk May 27, 2025
56625f6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 27, 2025
971c52e
remove extra rematerialization
beverlylytle May 27, 2025
d059353
Merge branch 'main' into reautograd2
beverlylytle May 28, 2025
9cc8c78
remove outdated change
beverlylytle May 28, 2025
67cde6e
Merge branch 'main' into reautograd2
beverlylytle Jun 3, 2025
e1308e1
clean up after merge
beverlylytle Jun 3, 2025
b73702a
more clean up
beverlylytle Jun 3, 2025
d39f270
Merge branch 'main' into reautograd2
beverlylytle Jun 3, 2025
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
Prev Previous commit
Next Next commit
group get_grads together for torch compile fusions
  • Loading branch information
beverlylytle committed May 23, 2025
commit 440bc96d2ec40023b54d7a1ede50b1b2fe7c1932
2 changes: 1 addition & 1 deletion thunder/tests/test_torch_compile_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_torch_compile_cat_rope_single_fusion():

backward_execution_trace = thunder.last_backward_traces(jfn)[-1]
assert len(get_fusions(backward_execution_trace)) == 1
assert len(backward_execution_trace.bound_symbols) == 14
assert len(backward_execution_trace.bound_symbols) == 17


@pytest.mark.skipif(not is_inductor_supported() or platform.system() == "Windows", reason="inductor unsupported")
Expand Down
15 changes: 15 additions & 0 deletions thunder/transforms/autodiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ def shallow_copy_if_input(p):
trace, _ = AugmentedForwardProcessor(trace)()
# run through DCE in case some of the gradients of intermediates are not needed.
trace = thunder.core.transform_common.dce(trace)
# group get_grad symbols together for torch compile fusions
# !!! is it preferrable to do this here or in the torch compile fusion pass?
_group_get_grad_bsyms(trace)

end_time_ns = time.perf_counter_ns()
elapsed_time_ns = end_time_ns - start_time_ns
Expand All @@ -312,6 +315,18 @@ def shallow_copy_if_input(p):
return trace


def _group_get_grad_bsyms(trace):
i = 0
while trace.bound_symbols[i].sym != prims.get_grad:
i += 1
if i == len(trace.bound_symbols):
return
get_grad_bsyms = list(filter(lambda bsym: bsym.sym == prims.get_grad, trace.bound_symbols))
bsyms = list(filter(lambda bsym: bsym.sym != prims.get_grad, trace.bound_symbols))
bsyms = bsyms[:i] + list(get_grad_bsyms) + bsyms[i:]
trace.bound_symbols = bsyms


def split_into_forward_and_backward(joint_trace):
"""split a joint trace for forward and backward into separate ones, including recomputation (aka activation checkpointing)"""

Expand Down
Loading