Skip to content

[graph_trainer]Remove _remove_dead_empty_strided_chains workaround - #3496

Merged
SherlockNoMad merged 1 commit into
mainfrom
graph_trainer/remove-empty-strided-shadow-dce
Jun 4, 2026
Merged

SherlockNoMad merged 1 commit into
mainfrom
graph_trainer/remove-empty-strided-shadow-dce

Conversation

@SherlockNoMad

@SherlockNoMad SherlockNoMad commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#3480 added _remove_dead_empty_strided_chains as a workaround for a DTensor + make_fx bug: shard propagation runs each op on fake global-shape tensors to derive metadata, and when make_fx captured that inference it left a dead empty_strided-backed "shadow" node for every DTensor op. Bounds-checked ops (aten.embedding, nll_loss) read the uninitialized empty_strided index/target and tripped device-side assert for any tensor_parallel_degree > 1 aot_fx_trace config.

The proper upstream fix wraps the fake-tensor metadata inference in disable_proxy_modes_tracing inside ShardingPropagator._propagate_tensor_meta_non_cached, so the shadow nodes never enter the make_fx graph — pytorch/pytorch #185865. That makes this DCE a no-op, so this PR removes it (per the workaround's own docstring: "Remove this pass once that fix lands in the graph_trainer CI nightly.").

Blocking dependency

  • pytorch/pytorch #185865 must be merged and present in the nightly first. As of this PR it is not (the nightly is installed unpinned via --pre torch).
  • Symptom if merged early: embedding/nll_loss OOB device-side asserts return for TP aot_fx_trace paths — e.g. test_bitwise_deterministic.py and the AutoParallel TP tests.

Test plan

Once #185865 is in the CI nightly, the existing graph_trainer suites are the validation (no behavior change expected):

pytest torchtitan/experiments/graph_trainer/tests/test_bitwise_deterministic.py
pytest torchtitan/experiments/graph_trainer/tests/test_trace_module.py
pytest torchtitan/experiments/graph_trainer/tests/test_numerics.py

🤖 Generated with Claude Code

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 3, 2026
@SherlockNoMad
SherlockNoMad marked this pull request as ready for review June 3, 2026 20:54
DO NOT MERGE until pytorch/pytorch #185865 (or a reland) is in the CI nightly.

#3480 added `_remove_dead_empty_strided_chains` as a workaround: DTensor shard
propagation ran each op on fake global-shape tensors for metadata, and when
make_fx captured that inference it left a dead `empty_strided`-backed "shadow"
node for every DTensor op. Bounds-checked ops (`aten.embedding`, `nll_loss`)
read the uninitialized `empty_strided` index/target and tripped device-side
asserts for any `tensor_parallel_degree > 1` aot_fx_trace config.

The proper upstream fix wraps the fake-tensor metadata inference in
`disable_proxy_modes_tracing` inside
`ShardingPropagator._propagate_tensor_meta_non_cached`, so the shadow nodes
never enter the make_fx graph (pytorch/pytorch #185865). That makes this DCE a
no-op, so remove it.

Caveat: #185865 is not yet in the cu130 nightly that graph_trainer CI installs
(unpinned `--pre torch`). Until it lands there, this PR's CI will fail with the
shadow-node asserts (e.g. the bitwise-deterministic and AutoParallel TP tests).
Hold until the nightly contains the fix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@SherlockNoMad
SherlockNoMad force-pushed the graph_trainer/remove-empty-strided-shadow-dce branch from 6a03351 to daac1a9 Compare June 4, 2026 21:07
@SherlockNoMad SherlockNoMad changed the title [graph_trainer][DO NOT MERGE] Remove _remove_dead_empty_strided_chains workaround [graph_trainer]Remove _remove_dead_empty_strided_chains workaround Jun 4, 2026
@SherlockNoMad
SherlockNoMad merged commit 4b22687 into main Jun 4, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants