Repository navigation
Conversation
fegin
added a commit
that referenced
this pull request
Apr 15, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: 024c91a Pull-Request: #2987
This was referenced Apr 14, 2026
fegin
added a commit
that referenced
this pull request
Apr 16, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: dd1302d Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 16, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: fbc7406 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 16, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: de8ec72 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 17, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: de8ec72 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 17, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: f994221 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 17, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: c492349 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 17, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: b17f18b Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 17, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: 89fffe8 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 17, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: efacf3a Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 20, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: b735e21 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 20, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: 5fdc220 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 20, 2026
…ama3 Add full DTensor mode where all params/buffers/inputs are DTensors on a multi-dimensional SPMD mesh. CP is handled declaratively via LocalMapSpec (K/V Replicate on CP dim for all-gather) instead of apply_cp_to_forward. **Verified parallelisms:** FSDP + TP FSDP HSDP FSDP + TP HSDP + TP FSDP + CP + TP PP + FSDP + TP PP + FSDP + CP PP + CP + TP To run all of the verifications above: 1. CP only supports FlexAttention. Varlen will come next. SDPA will only be supported if is_causal is False. 2. FSDP + TP requires a PyTorch PR to fix the loss parallel. 3. PP + * requires a PyTorch PR to fix the split tensor issue. 4. max_autotune must be True for FlexAttention compilation for certain parallelisms combinations. 5. This PR changes how cross_entropy_loss is done to not use flatten. This requires further investigation. ghstack-source-id: 4860e66 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 24, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: a80492f Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 24, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: 0de2646 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: 4c31447 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: 1396172 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: cdc8374 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
…a3 adoption (#2963) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * #2987 * #3113 * #3080 * #2986 * #2969 * __->__ #2963 **Summary** Replace string-keyed plan dicts passed to `parallelize_module()` with `ShardingSpec` attached to each `Module.Config`. Sharding is co-located with the rest of a submodule's configuration and applied by `Module.parallelize(mesh)` via auto-recursion. **NOTE that we have to do some compromise designs due to the backward compatibility issues, these should be removed either full DTensor is applied or at some time in the future** **Known TODOs for follow-up:** - apply_cp_to_forward: This is a workaround to keep the current CP work. Remove once all models use config-based sharding + full DTensor - input_layouts: Another workaround. We can remove it once all inputs flow as DTensors - LocalMapInnerAttention: remove entire class once all models use config-based sharding (#2986) - parallelize(tp_mesh): pass full SPMD mesh once FSDP/CP also uses DTensor (#2987) - _shard_outputs: extend to support nested outputs (tuples/dicts) for multi-tensor forward
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
…eek V3, GPT-OSS (#2969) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * #2987 * #3113 * #3080 * #2986 * __->__ #2969 * #2963 Convert dense-layer TP and attention for all remaining models to config-based `ShardingSpec`, leaving MoE part unchanged, still using `apply_moe_ep_tp()`. After this PR, every model's attention uses `Module.parallelize()`. **We will remove LocalInnerAttention in the next PR.** **Models that are not converted: Flux and qwen3-vl.** 1. Flux doesn't support TP. So it is out of the current scope. We can convert it during the full dtensor PRs. 2. qwen3-vl vision part is hard to convert without full dtensor support. It is doable but let's not do the hacky way and wait until the full dtensor PRs.
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: b801068 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 27, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: bc8998b Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: 78ff6a4 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: f997bf4 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: e3a9ebe Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * #2987 * #3113 * #3080 * __->__ #2986 Replace runtime DTensor detection in `LocalMapInnerAttention` with static `LocalMapSpec` on inner attention configs via sharding.py. All inner attention types (SDPA, FlexAttention, Varlen) now use `Module.parallelize()` local_map for TP DTensor→local conversion. - Set LocalMapSpec on inner attention in all model sharding.py files - Migrate Flux CP from apply_cp_to_attention_module to apply_cp_to_forward - Remove LocalMapInnerAttention class; subclasses inherit Module directly - Remove apply_cp_to_attention_module (no remaining callers) - Migrate experiments/rl to config-based sharding: - VLLMAttentionWrapper inherits Module directly (no runtime DTensor bridge). - parallelize_qwen3 replaced with model.parallelize(tp_mesh); legacy parallelize_module plan deleted. - set_qwen3_sharding_spec(..., include_positions=True) installed on the config before build() in vllm_wrapper and in trainer.PolicyTrainer._build_model. - compute_logprobs materializes DTensor logits to plain via full_tensor() (downstream RL uses plain-tensor indexing). - Add include_positions kwarg to set_gqa_attention_sharding so the generator path annotates the positions argument.
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: 31a14a2 Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (``dp_replicate`` x ``dp_shard`` x ``cp`` x ``tp``). Enabled via ``--training.full_dtensor``. CP is handled declaratively via ``LocalMapSpec`` (K/V ``Replicate`` on CP dim for all-gather) instead of ``apply_cp_to_forward`` hooks. FSDP2 uses ``DataParallelMeshDims`` to identify ``dp_shard`` and ``cp`` as data-parallel dims on the multi-D mesh. Verified parallelisms (100 steps, bit-wise identical loss with ``--debug.seed=42 --debug.deterministic``): - FSDP - HSDP - FSDP + TP - HSDP + TP - FSDP + CP (FlexAttention) - FSDP + TP + CP (FlexAttention) - PP + FSDP + TP - PP + FSDP + CP (FlexAttention) - PP + TP + CP (FlexAttention) Caveats: - CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with ``is_causal=True``. ``validate_config`` enforces this. - FSDP + TP requires a PyTorch-side fix to ``_find_all_reduce_mesh_dim`` and ``_nll_loss_forward_handler`` in ``torch/distributed/tensor/ parallel/loss.py`` so ``loss_parallel`` works on multi-D meshes. - PP + * requires a PyTorch-side fix to use ``_split_tensor`` instead of ``torch.tensor_split`` for the target microbatch split in ``torch/distributed/pipelining/schedules.py``; the raw split goes through DTensor dispatch and turns ``Shard(0)`` into ``Replicate()`` via an implicit all-gather. - FlexAttention needs ``max_autotune=True`` for compilation under TP + CP + FSDP. Set in ``models/common/attention.py``. - ``cross_entropy_loss`` uses ``pred.permute(0, 2, 1)`` (3D form) instead of ``pred.flatten(0, 1)`` when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch on ``dp_shard`` and seq on ``cp``) and produces ``_StridedShard``, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent. - EP is not supported with full_dtensor. - Currently only llama3 has the full_dtensor sharding spec; other models raise ``NotImplementedError`` from ``validate_config``. ghstack-source-id: 87febed Pull-Request: #2987
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
…ds (#3080) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * #2987 * #3113 * __->__ #3080 MATH backend has been an issue in the past, e.g., silently fall back to MATH backend causing CP debugging issue. While we have local_map to avoid complicated interaction between MATH attention with DTensor, it doesn't worth to keep another one if it make developers like harder and we don't proactively develop with it. This PR just removes it.
fegin
added a commit
that referenced
this pull request
Apr 28, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * #2987 * __->__ #3113 * #3080 Cosmetic follow-up to PR1 review: **The major convention change is using `axis` for Mesh. So this changes many docstring, comment and code. But we cannot change the upstream PyTorch DeviceMesh API yet due to the BC issues** - Move ``StrEnum`` and the mesh-axis-name enum to ``torchtitan/protocols/typespy``. - Rename ``MeshDimName`` -> ``MeshAxisName``. Establish the convention that throughout torchtitan code we own, ``axis``/``axes`` refers to a ``DeviceMesh`` axis and ``dim``/``dimension`` is reserved for tensor dimensions. The exception: when calling into PyTorch upstream APIs (``DeviceMesh.mesh_dim_names``, ``DataParallelMeshDims``) we keep the upstream spelling at the call site since we cannot rename it; values flowing through our code are then named with ``axis``. - Add the rule to ``.claude/CLAUDE.md`` (Naming) and update ``.claude/rules/distributed.md`` to match. No behavior change; pre-commit clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Add full DTensor mode where all params, buffers, and inputs are DTensors on a multi-dimensional SPMD mesh (
dp_replicatexdp_shardxcpxtp). Enabled via--training.full_dtensor. CP is handled declaratively viaLocalMapSpec(K/VReplicateon CP dim for all-gather) instead ofapply_cp_to_forwardhooks. FSDP2 usesDataParallelMeshDimsto identifydp_shardandcpas data-parallel dims on the multi-D mesh.Verified parallelisms:
FSDP + TP
FSDP
HSDP
FSDP + TP
HSDP + TP
FSDP + CP + TP
PP + FSDP + TP
PP + FSDP + CP
PP + CP + TP
Caveats:
CP + full_dtensor requires FlexAttention. After K/V all-gather on CP, Q and K/V have asymmetric sequence lengths, which SDPA/varlen cannot handle with
is_causal=True.validate_configenforces this.FSDP + TP requires a PyTorch-side fix, PR180936 to
_find_all_reduce_mesh_dimand_nll_loss_forward_handlerintorch/distributed/tensor/parallel/loss.pysoloss_parallelworks on multi-D meshes.PP requires a PyTorch-side fix, PR180937 to use
_split_tensorinstead oftorch.tensor_splitfor the target microbatch split intorch/distributed/pipelining/schedules.py; the raw split goes through DTensor dispatch and turnsShard(0)intoReplicate()via an implicit all-gather.FlexAttention needs
max_autotune=Truefor compilation under TP + CP + FSDP.cross_entropy_lossusespred.permute(0, 2, 1)(3D form) instead ofpred.flatten(0, 1)when pred is a DTensor. Flattening merges differently-sharded dims (e.g. batch ondp_shardand seq oncp) and produces_StridedShard, which breaks downstream scalar loss dispatch. The permute avoids the merge and is functionally equivalent.EP is not supported with full_dtensor yet.
Currently only llama3 has the full_dtensor sharding spec; other models raise
NotImplementedErrorfromvalidate_config.