Skip to content

[graph_trainer] Re-enable llama3 AutoParallel numerics test (was empty_strided shadow-node bug) - #3495

Merged
SherlockNoMad merged 1 commit into
mainfrom
graph_trainer/reenable-autoparallel-llama3-numerics
Jun 4, 2026
Merged

SherlockNoMad merged 1 commit into
mainfrom
graph_trainer/reenable-autoparallel-llama3-numerics

Conversation

@SherlockNoMad

Copy link
Copy Markdown
Contributor

Summary

The skip on test_llama3_aot_fx_trace_autoparallel_vs_eager and the integration test autoparallel_llama3_fsdp_tp blamed an "upstream AutoParallel nll_loss assertion regression" / "incorrect loss partitioning". That was a misattribution — it is the same empty_strided dead-shadow-node bug that #3480 root-caused and fixed with _remove_dead_empty_strided_chains.

Root cause

AutoParallel produces a model-only graph (vocab-sharded DTensor logits); the loss op is applied afterwards inside graph_trainer's make_fwd_bwd_step, which is traced by minimal_fx_tracer — exactly the graph the DCE cleans. Under the unfixed nightly, DTensor shard propagation leaves a dead nll_loss shadow node reading an uninitialized empty_strided target, which trips the bounds check t >= 0 && t < n_classes at runtime — the same failure class as the embedding OOB in #3480. _remove_dead_empty_strided_chains strips that dead chain. The upstream fix is pytorch/pytorch #185865.

Minimal isolation (simulating the unfixed nightly by restoring the pre-fix _propagate_tensor_meta_non_cached) confirms the DCE removes the dead bounds-checked shadow op:

before: empty_strided=2, embedding=2   # dead aten.embedding(empty_strided_w, empty_strided_idx) [num_users=0]
after _remove_dead_empty_strided_chains: empty_strided=0, embedding=1

Verification

Ran on 8×H100 with autoparallel installed — loss matches eager:

Max loss difference: step=11 baseline=3.6115226 test=3.6113948 diff=0.000128
1 passed in 226.67s

CI runs this unit test on the unfixed nightly (integration_test_8gpu_graph_trainer.yaml), so it exercises the DCE path directly. Keep _remove_dead_empty_strided_chains until #185865 lands.

Left disabled (verified separate, still-open bugs)

Test plan

pytest torchtitan/experiments/graph_trainer/tests/test_numerics.py::TestGraphTrainerAutoParallelNumerics::test_llama3_aot_fx_trace_autoparallel_vs_eager

🤖 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 force-pushed the graph_trainer/reenable-autoparallel-llama3-numerics branch from ce96d6d to 0848090 Compare June 3, 2026 19:36
…y_strided shadow-node bug)

The skip on `test_llama3_aot_fx_trace_autoparallel_vs_eager` (and the
integration test `autoparallel_llama3_fsdp_tp`) blamed an "upstream
AutoParallel nll_loss assertion regression" / "incorrect loss partitioning".
That was a misattribution: it is the same empty_strided dead-shadow-node bug
that #3480 root-caused and fixed with `_remove_dead_empty_strided_chains`.

AutoParallel produces a model-only graph (vocab-sharded DTensor logits); the
loss op is applied afterwards inside graph_trainer's `make_fwd_bwd_step`, which
is traced by `minimal_fx_tracer` -- exactly the graph the DCE cleans. Under the
unfixed nightly, DTensor shard propagation leaves a dead `nll_loss` shadow node
reading an uninitialized `empty_strided` target, which trips the bounds check
`t >= 0 && t < n_classes` at runtime (same failure class as the embedding OOB).
`_remove_dead_empty_strided_chains` strips that dead chain. The upstream fix is
pytorch/pytorch #185865.

Verified on 8xH100 (autoparallel installed): the loss matches eager (max diff
1.3e-4), `1 passed`. CI runs this unit test on the unfixed nightly
(integration_test_8gpu_graph_trainer.yaml), so it exercises the DCE path
directly -- keep `_remove_dead_empty_strided_chains` until #185865 lands.

The DSv3 AutoParallel and JIT (#2149) tests remain disabled: separate,
still-open bugs (confirmed #2149 still reproduces "Node tangents_2 was invalid,
but is output").

Test plan:
  pytest torchtitan/experiments/graph_trainer/tests/test_numerics.py::TestGraphTrainerAutoParallelNumerics::test_llama3_aot_fx_trace_autoparallel_vs_eager

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@SherlockNoMad
SherlockNoMad force-pushed the graph_trainer/reenable-autoparallel-llama3-numerics branch from 0848090 to c0e90b3 Compare June 4, 2026 21:08
@SherlockNoMad
SherlockNoMad merged commit 72338b0 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