Skip to content

[ci][models] block qwen3.5 spmd_types, fix dsv3 compile - #3901

Merged
pianpwk merged 3 commits into
mainfrom
gh/pianpwk/64/head
Jul 11, 2026
Merged

pianpwk merged 3 commits into
mainfrom
gh/pianpwk/64/head

Conversation

@pianpwk

@pianpwk pianpwk commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Do not enable the spmd_types backend for qwen3.5 model CI because that model is not wired for the spmd_types mesh axes yet.

Allow spmd_types compile coverage to run by avoiding spmd_types tensor metadata assertions while Dynamo is compiling and using the regular all_to_all path during compile/tracing.

pianpwk added 2 commits July 10, 2026 13:46
[ghstack-poisoned]
[ghstack-poisoned]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 10, 2026
@pianpwk pianpwk changed the title Fix spmd_types model integration variants [ci][models] block qwen3.5 spmd_types, fix dsv3 compile Jul 10, 2026
[ghstack-poisoned]
pianpwk added a commit that referenced this pull request Jul 11, 2026
Do not enable the spmd_types backend for qwen3.5 model CI because that model is not wired for the spmd_types mesh axes yet.

Allow spmd_types compile coverage to run by avoiding spmd_types tensor metadata assertions while Dynamo is compiling and using the regular all_to_all path during compile/tracing.

ghstack-source-id: 9937a65
Pull Request resolved: #3901
@pianpwk
pianpwk changed the base branch from gh/pianpwk/64/base to main July 11, 2026 00:39
@pianpwk
pianpwk merged commit 0d7f4ab into main Jul 11, 2026
8 of 11 checks passed
@sdmyzlp

sdmyzlp commented Jul 11, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @pianpwk, sorry to bother — quick question on spmd_types:

I see two patterns in current codebase:

if get_spmd_backend() == "spmd_types" and not torch.compiler.is_compiling():

and

if get_spmd_backend() == "spmd_types" and spmd.is_type_checking():

Could you please clarify their intended difference? And will they be unified to is_compiling() eventually? Thanks!

saforem2 added a commit to saforem2/torchtitan that referenced this pull request Jul 12, 2026
Merged 3d277c1 (51c197c CosSinRoPE/ComplexRoPE YaRN unify pytorch#3787 +
0d7f4ab qwen3.5 spmd block / dsv3 compile fix pytorch#3901). No replays:
agpt/moe diff empty. RoPE change is numerically neutral for us -- agpt
uses cos_sin with scaling=none (never hits the modified YaRN branch),
never sets mscale (removed field is a no-op), and moe's mscale is on
Attention.Config not RoPE.Config. sync_smoke VERDICT ok (job 12470359),
all 3 configs bit-identical to 64th-67th syncs.
@pianpwk

pianpwk commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Hi @pianpwk, sorry to bother — quick question on spmd_types:

I see two patterns in current codebase:

if get_spmd_backend() == "spmd_types" and not torch.compiler.is_compiling():

and

if get_spmd_backend() == "spmd_types" and spmd.is_type_checking():

Could you please clarify their intended difference? And will they be unified to is_compiling() eventually? Thanks!

@sdmyzlp sorry for the late response! this is a bit of sloppiness, but either should work. I believe we should only assert, if typechecking + no compile. upstream we should be working on making this compile friendly, but that's WIP.

In the meantime please do use the and spmd.is_type_checking(): pattern if you need to.

jemitche1 pushed a commit to jemitche1/torchtitan that referenced this pull request Jul 15, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* __->__ pytorch#3901

Do not enable the spmd_types backend for qwen3.5 model CI because that
model is not wired for the spmd_types mesh axes yet.

Allow spmd_types compile coverage to run by avoiding spmd_types tensor
metadata assertions while Dynamo is compiling and using the regular
all_to_all path during compile/tracing.
Jeremalloch added a commit to Jeremalloch/torchtitan that referenced this pull request Jul 27, 2026
Wire the dense Qwen3.5 model for the spmd_types backend, which CI
previously blocked (pytorch#3901: not wired for the spmd_types mesh axes).

- parallelize.py: resolve the FSDP mesh via resolve_fsdp_mesh /
  resolve_sparse_fsdp_mesh under spmd_types (there is no flattened
  "fsdp" axis; FSDP shards the multi-axis dense storage mesh along
  DataParallelMeshDims), pass dp_mesh_dims through to the decoder and
  vision-encoder fully_shard calls, and run model.parallelize() even
  for pure-FSDP topologies since the SPMD parameter annotations are
  what fully_shard translates into DTensor params.
- sharding.py: annotate vision params without explicit state shardings
  as Replicate (FLUX's annotate_dp_cp_params_as_r pattern); add the
  missing out_src/in_src shardings that spmd_types requires to be
  explicit; redistribute the first decoder block's input R -> SP at the
  module boundary (the layer-0 residual previously relied on implicit
  DTensor redistribution, which spmd_types local tensors cannot do);
  vision rotary inv_freq R instead of I (same Replicate DTensor
  placement, but I cannot mix with R under typechecking); scaled-bias
  rowwise config for the vision rowwise-with-bias linears.
- __init__.py: vision attn.proj, mlp.fc2, and merger.fc2 become
  ScaledBiasRowwiseLinear (gpt_oss pattern) so the per-rank bias/tp
  contribution sums correctly through the TP all-reduce; addmm cannot
  type a Partial matmul plus Replicate bias.
- model.py: run the depthwise deltanet conv with local groups under
  spmd_types (module groups is the global channel count); local-region
  head-split views with boundary re-typing (SeparateQKVLinear pattern);
  register the FLA kernel autograd Functions as local-only for
  typechecking; annotate multimodal extras (pixel values, grid dims,
  mrope positions) that the trainer's input annotation does not cover;
  keep vision position/scatter index bookkeeping out of typechecking.
- vision_encoder.py: local-region head splits, position-embedding and
  block-mask construction outside typechecking with boundary re-typing.
- rope.py: build the MRoPE interleaved cache in a local region and
  re-type at the boundary.

Validated on 4x H100 (dp_shard=2, tp=2): spmd_types runs
qwen35_debugmodel, spmd_types + --debug.spmd_typechecking runs with AC
disabled, and seeded deterministic loss/grad_norm stays within float
noise of the default backend. Default-backend numerics compared against
unmodified main with the same seed. MoE (EP token dispatcher) and the
qwen3.5 CI spmd_types exclusion are follow-ups.
wconstab added a commit that referenced this pull request Aug 1, 2026
## Summary

Temporarily disables the H100 GraphTrainer flavor
`aot_fx_trace_deepseek_v3_fsdp_tp_ep_regional_inductor` while we
root-cause the FSDP bucketing topological-sort failure tracked in #4047.

This is a narrow skip for the known-bad DeepSeekV3 FSDP+TP+EP
regional-inductor configuration. It does not disable the broader
GraphTrainer suite.

## CI failures this is mitigating

- Current main sample:
https://github.com/pytorch/torchtitan/actions/runs/30676454329/job/91304654124
- First failing sample found:
https://github.com/pytorch/torchtitan/actions/runs/29133288004
- Last passing sample found:
https://github.com/pytorch/torchtitan/actions/runs/29094009588

The failure is:

```text
AssertionError: stable topological sort of region failed
```

on this path:

```text
torchtitan/experiments/graph_trainer/fsdp_passes.py:591 joint_transformer_block_bucketing_reordering_pass
torch/_inductor/fx_passes/bucketing.py:1291 _sort_bucket_region
torch/_dynamo/graph_deduplication.py:405 _stable_topological_sort_region
```

## Notes

The current suspicion is that the PyTorch nightly range
`fbc1dfeabfda7f4cc0a95635726b700e732c19dd` ->
`0ce05af6274d975672dd30447bf00010317288ef` exposed or introduced this.
TorchTitan #3901 landed in the same scheduled-run gap, but it did not
touch GraphTrainer and appears unlikely to affect this non-`spmd_types`
flavor.

Current main also has separate H100 EP-overlap alias/wait-sink failures.
Those are intentionally out of scope for this skip.

## Test plan

```bash
python3 -m py_compile torchtitan/experiments/graph_trainer/tests/integration_tests.py
python3 - <<'PY'
from torchtitan.experiments.graph_trainer.tests.integration_tests import build_graph_trainer_h100_test_list
name = 'aot_fx_trace_deepseek_v3_fsdp_tp_ep_regional_inductor'
for test in build_graph_trainer_h100_test_list():
    if test.test_name == name:
        print(f'{test.test_name} disabled={test.disabled} ngpu={test.ngpu}')
        break
else:
    raise SystemExit(f'{name} not found')
PY
```
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.

3 participants