Skip to content

Annotate variable-length metadata for SPMD - #4890

Merged
anijain2305 merged 16 commits into
mainfrom
gh/anijain2305/44/head
Sep 26, 2026
Merged

anijain2305 merged 16 commits into
mainfrom
gh/anijain2305/44/head

Conversation

@anijain2305

@anijain2305 anijain2305 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
submartingales pushed a commit to botcanlearn/torchtitan-upstream that referenced this pull request Sep 25, 2026
@anijain2305
anijain2305 marked this pull request as ready for review September 26, 2026 00:01
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 26, 2026
Comment thread torchtitan/models/common/attention.py Outdated
Comment on lines +87 to +93
placements = spmd.SpmdType(
{
MeshAxisName.DP: spmd.V,
MeshAxisName.TP: spmd.R,
},
partition_spec=spmd.PartitionSpec(MeshAxisName.DP),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If VarlenMetadata is always getting such fixed spmd_types, then should be put in its constructor / post_init? Maybe should even consider make it frozen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some changes around the ownership, but

  • Kept NamedTuple - its also an immutable container. And other requirement is pytree-able which it is by default, but not a frozen dataclass.
  • The annotations have to be applied later and not at init time because mesh is not active then.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@anijain2305
anijain2305 changed the base branch from gh/anijain2305/44/base to main September 26, 2026 04:04
@anijain2305
anijain2305 merged commit 35ceeb5 into main Sep 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl 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