Repository navigation
Remove the full_dtensor SPMD backend - #4217
Conversation
[ghstack-poisoned]
| global_vocab_size: int | None = None, | ||
| ) -> torch.Tensor: | ||
| """Cross-entropy loss with sum reduction for token-based normalization.""" | ||
| if isinstance(pred, DTensor) and isinstance(labels, DTensor): |
There was a problem hiding this comment.
to confirm: for partial_dtensor with TP, the output are not DTensor?
There was a problem hiding this comment.
pred is a DTensor; labels is not.
| yield | ||
|
|
||
|
|
||
| def validate_config(parallel_dims: "ParallelDims", model: nn.Module) -> None: |
There was a problem hiding this comment.
this should happen in update_from_config at config time
|
just curious, there's torchtitan/torchtitan/models/qwen3_5/model.py Lines 343 to 357 in ad09b17 |
| "sum", | ||
| ) | ||
|
|
||
| return _local_cross_entropy(pred, labels) |
[ghstack-poisoned]
Good point, it is unclear. I would proceed to land this one. Without full dtensor, it is easier for Agent to infer. |
…too coarsely Research turned up the decisive context, and it makes the report sharper rather than weaker. resolve_fsdp_mesh in upstream/main already carries a comment describing this exact failure -- "assert_type filters out inactive size-1 axes, so params get no annotations under a size-1 full mesh" -- but the guard fires only when the WHOLE dense storage mesh is size 1. At TP=1 with FSDP>1 the mesh is size 12, so DataParallelMeshDims IS passed while a param whose only non-Replicate axis is tp still loses its annotation. The check wants to be per-parameter. That also refines the mechanism: the proximate trigger is the missing ANNOTATION, not the missing shard. FSDP converts a plain-but-annotated tensor via spmd.get_local_type; the raise needs plain AND unannotated. Ruled out by test, not argument: - spmd_types package version. Our venv had 0.2.1 while requirements pins 0.2.3 -- a real divergence and a strong candidate, since that package owns assert_type. Installed 0.2.3 into a throwaway overlay: fails identically (12473448), torch untouched. Not the cause; still worth fixing the venv. - AC (all five arms), a torch nightly (main has the same check), and unmerged upstream work (no PR touches these symbols, no matching issue). Also flags something that changes our own plan: full_dtensor is being REMOVED upstream (601cf4d, pytorch#4217). Our agpt configs are pinned to it, so that pin is a dead end and should move to partial_dtensor. Kept an explicit unresolved note: upstream CI defaults to llama3_debugmodel and features.py covers FSDP-only shapes, so if those are green something in our environment still differs. A maintainer can answer that instantly.
…ng removed upstream Both config registries pinned spmd_backend="full_dtensor" since the 79th sync. Two independent reasons that is wrong now: 1. Upstream is DELETING the backend. 601cf4d ("Remove the full_dtensor SPMD backend", pytorch#4217, 2026-08-19) drops full_dtensor.py entirely -- 167 lines already gone in upstream/main. The next sync removes the file our parallelize.py imports resolve_fsdp_mesh from. Pinning to it is a dead end with a known expiry. 2. The evidence for the original pin did not cover compiled runs. Its comment cites job 12473350 as "full_dtensor runs 4/4 steps", but that probe ran --compile.no-enable. Compiled agpt on full_dtensor hits the vc_check DeviceMesh assertion, which is how the user's agpt_20b run failed. partial_dtensor is the supported fallback, is what upstream pins for its own rl+hf CI suites (b64d3f6, pytorch#4228), and is the same code path that produced every production trajectory before pytorch#4085 renamed "default" -> "partial_dtensor". spmd_types stays unusable for now and the comment records why, with a pointer to the writeup: it is an UPSTREAM gap, not ours -- core llama3 through core's own trainer fails identically (12473444) while partial_dtensor passes in the same job. resolve_fsdp_mesh already guards this shape, but only when the whole storage mesh is size 1. Verification of partial for the MoE configs is in flight; moe_10b_2b and moe_small have both already passed 5/5 on it. One arm in that job (moe_small on full_dtensor) reported a bogus ImportError -- I installed spmd_types 0.2.3 into the venv six seconds before it ran, so it read a half-swapped package. That arm is void, not a result, and it is the reason not to pip-install while jobs are live.
…sor removal 601cf4d (pytorch#4217) deletes torchtitan/distributed/full_dtensor.py. Two ezpz files import from it and will fail at import time on the next merge: agpt/parallelize.py:44 and moe/parallelize.py:50. Worth flagging BEFORE the sync because it is not a pure import rewrite: resolve_fsdp_mesh and resolve_sparse_fsdp_mesh moved to distributed/fsdp.py with unchanged logic, but validate_config is GONE -- no definition anywhere in upstream/main's distributed/. Those call sites need dropping or reimplementing, and 'full_dtensor' also stops being a legal spmd_backend value. Placed at the top of the file rather than appended, since the point is to be seen before someone starts the merge, not after.
…ak on import Upstream pytorch#4217 (601cf4d) deletes torchtitan/distributed/full_dtensor.py. agpt/parallelize.py and moe/parallelize.py both import from it, so the next sync is an immediate ImportError in two files. Fixing it now, while both locations still work, rather than discovering it mid-merge. New ezpz/fsdp_compat.py resolves resolve_fsdp_mesh / resolve_sparse_fsdp_mesh from distributed.fsdp (post-pytorch#4217) and falls back to distributed.full_dtensor (our current tree). Post-sync path is tried FIRST so that once the merge lands we are on the upstream import with no fallback in play. Both models now import from the shim. validate_config is deliberately NOT shimmed. It is gone from upstream/main entirely -- no definition anywhere in the tree -- and the models that called it simply dropped the call: llama3/parallelize.py:40 is now just `if spmd_backend == "spmd_types" or tp_enabled: model.parallelize(...)`, and deepseek_v3 (our moe base) likewise. Reimplementing it locally would mean maintaining a check upstream no longer has, so both ezpz call sites are dropped to match. This is a behavior change, hence the hardware check below rather than a bare import test. "full_dtensor" stays in the backend tuples for now: it is still a legal value on this tree, and removing it is the sync's job, not this commit's.
Three detail docs had accumulated (spmd-types-plain-tensor, spmd-types-newer-torch-attempt, agpt-full-dtensor-vc-check), each written mid-investigation and each carrying a partial and at times superseded picture. This is the single page to read: which backend to use, what broke, and why. Covers the three findings that matter: - spmd_types fails for a PYTORCH reason, not a torchtitan one. Proven by A/B: torch 2.14.0.dev20260722+xpu runs 3/3 where the shipped 2.13 gives 0/3, same venv and config. Needs pytorch da19cbd78 (2026-06-23). - full_dtensor is a dead end (being removed in pytorch#4217) and its vc_check assertion tracks model.parallelize() running, not the backend name. - "default" was RENAMED to partial_dtensor in pytorch#4085, so old logs reporting "default" -- including the 482-step 30B run -- were already on it. Includes the working newer-torch recipe and the narrow usable-nightly window, since that took several attempts to find, and a call-out for the Aurora stack maintainers: our build is dated Aug 2 but lacks a Jun 23 commit. All four external links (2 PRs, 2 commits) verified to resolve, and the PR titles checked against what the page claims.
Stack from ghstack (oldest at bottom):
Now that spmd_types is the default backend (thanks to @pianpwk) and partial_dtensor is the fallback, drop
parallelism.spmd_backend == "full_dtensor"and everything that only existed to support it. This makes people's life easier.