[spmd_types] global_valid_tokens: float | None - #3586
Merged
Conversation
[ghstack-poisoned]
This was referenced Jun 9, 2026
tianyu-l
approved these changes
Jun 9, 2026
pianpwk
added a commit
that referenced
this pull request
Jun 9, 2026
Adding this to allow both spmd types specs, and DTensor-style placements. We're adding something like D107576760 in spmd_types, but in the meantime, because non-llama3 models are still in DTensor placement form, I think we have 2 options: 1) keep this as a hybrid spmd/DTensor container (e.g. moe_sharding.py calls `dense_activation_placement(tp=Replicate())`, and migrate to SpmdLayout once all models are off full_dtensor. 2) since we're adding a spmd->DTensor translation shim anyways, migrate all models from `Replicate/Shard/Partial` to `spmd.R/S/P` immediately, use SpmdLayout, and go deal with I/R distinctions later. This should be ok because non-llama3 models won't support spmd backend yet. Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0) (oldest at bottom): * #3278 * #3472 * #3468 * #3471 * #3253 * #3587 * #3586 * __->__ #3501
[ghstack-poisoned]
pianpwk
marked this pull request as ready for review
June 9, 2026 08:02
pianpwk
requested review from
IvanKobzarev,
SherlockNoMad,
aditvenk,
fegin,
felipemello1,
sanketpurandare,
wconstab,
wwwjn and
xmfan
as code owners
June 9, 2026 08:02
saforem2
added a commit
to saforem2/torchtitan
that referenced
this pull request
Jun 9, 2026
…one) Upstream `[spmd_types] global_valid_tokens: float | None (pytorch#3586, 2026-06-09)` retyped `global_valid_tokens` from `torch.Tensor` to `float | None` and switched the no-DP branch from `local_valid_tokens.float()` (returns a Tensor) to `float(local_valid_tokens.item())` (returns a Python float). Mirror that in: - `ezpz/trainer.py` `forward_backward_step` no-DP branch - `ezpz/validator.py` `validate` no-DP branch DP branch is left as-is (still returns a Tensor from `dist_sum`) — upstream itself does the same, the annotation is loose, and consumers (BaseLoss.__call__, ChunkedCELoss) accept either at runtime. The DP path is the only one any current production / smoke run takes, so functional behavior is unchanged. This replay just keeps the no-DP fallback honest about its return type.
wwwjn
pushed a commit
that referenced
this pull request
Jun 10, 2026
Adding this to allow both spmd types specs, and DTensor-style placements. We're adding something like D107576760 in spmd_types, but in the meantime, because non-llama3 models are still in DTensor placement form, I think we have 2 options: 1) keep this as a hybrid spmd/DTensor container (e.g. moe_sharding.py calls `dense_activation_placement(tp=Replicate())`, and migrate to SpmdLayout once all models are off full_dtensor. 2) since we're adding a spmd->DTensor translation shim anyways, migrate all models from `Replicate/Shard/Partial` to `spmd.R/S/P` immediately, use SpmdLayout, and go deal with I/R distinctions later. This should be ok because non-llama3 models won't support spmd backend yet. Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0) (oldest at bottom): * #3278 * #3472 * #3468 * #3471 * #3253 * #3587 * #3586 * __->__ #3501
wwwjn
pushed a commit
that referenced
this pull request
Jun 10, 2026
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.
Per-request, to avoid typechecking this
Stack from ghstack (oldest at bottom):