Skip to content

Commit 1aff15c

Browse files
authored
Make AC recompute test topology-robust (#490)
Accept MUST_RECOMPUTE nodes carrying AutoParallel's AC graph id, since those are AP-owned FSDP recompute tags and may include wait_tensor nodes depending on the selected sharding strategy. Authored with Claude. stack-info: PR: #490, branch: aditvenk/stack/2
1 parent e988086 commit 1aff15c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tests/test_activation_checkpointing.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ def input_fn():
309309
def test_ac_joint_pass_marks_recomputable_nodes(device_mesh_1d):
310310
"""ac_joint_pass sets PREFER_RECOMPUTE on recomputable forward nodes
311311
(excluding getitem and already-tagged nodes)."""
312-
from autoparallel.graph_passes.activation_checkpointing import ac_joint_pass
312+
from autoparallel.graph_passes.activation_checkpointing import (
313+
AP_AC_GRAPH_ID,
314+
ac_joint_pass,
315+
)
313316

314317
graph = _build_parallel_graph(AttentionBlockNoAC, device_mesh_1d)
315318
ac_joint_pass(graph, ac_stage_size_in_GiB=None)
@@ -324,13 +327,11 @@ def test_ac_joint_pass_marks_recomputable_nodes(device_mesh_1d):
324327
recompute = n.meta.get("recompute")
325328
if recompute is None:
326329
continue
327-
# All-gather nodes are tagged MUST_RECOMPUTE by
328-
# mark_fsdp_all_gather_recomputation (runs unconditionally in AP);
329-
# skip them so we only assert on tags set by ac_joint_pass.
330+
# AP-owned FSDP all-gather regions use MUST_RECOMPUTE.
330331
if recompute == CheckpointPolicy.MUST_RECOMPUTE:
331332
assert (
332-
"all_gather" in n.name
333-
), f"{n} has MUST_RECOMPUTE but is not an all-gather node"
333+
n.meta.get("ac_graph_id") == AP_AC_GRAPH_ID
334+
), f"{n} has unexpected MUST_RECOMPUTE"
334335
continue
335336
assert recompute in (
336337
CheckpointPolicy.PREFER_RECOMPUTE,

0 commit comments

Comments
 (0)