Skip to content

Commit 900d8d3

Browse files
Update on "[graph_trainer] Copy forward metadata to backward subgraphs"
Graph-trainer was only copying seq_nr metadata within the outer FX graph. That misses the way old AOT behaves for flex attention: the matching forward source for a backward flex node can live inside a nested GraphModule, including placeholder nodes from the captured flex subgraphs. In practice that meant backward flex nodes in the graph-trainer path could miss the forward custom / nn_module_stack metadata that old AOT used to recover. The old outer-graph heuristic was also unreliable once remat-tagged nodes showed up in the same seq_nr bucket, because the first outer node with that seq_nr was no longer a reliable proxy for the true forward source. Fix _copy_fwd_metadata_to_bw_nodes() to mirror the old AOT behavior more closely: - walk all nested GraphModules - build the seq_nr -> forward-node map across those subgraphs - only copy onto nodes identified as backward via partitioner_tag or remat metadata 1) This should address failures in #2934 [ghstack-poisoned]
2 parents 78a5ec4 + 8fed349 commit 900d8d3

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

torchtitan/experiments/graph_trainer/tests/test_trace_module.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,8 @@ def test_deepseek_v3(self):
680680
self._run_model_test(DeepSeekV3Model, config)
681681

682682
def test_deepseek_v3_flex_attention(self):
683-
"""Multi-step bitwise test for DeepSeek MLA + flex attention + regional_inductor.
684-
685-
Uses a tiny model with small head dims to stay within triton shared
686-
memory limits. Annotates FlexAttention.forward via annotate_fn before
683+
"""Tests if we can propagate fwd node metadata reliably through backward.
684+
Annotates FlexAttention.forward via annotate_fn before
687685
tracing so compile_with_inductor flows into the graph naturally.
688686
"""
689687
from torch.fx.traceback import annotate_fn

0 commit comments

Comments
 (0)