Skip to content

Keep model state stable during remat replay - #4887

Merged
anijain2305 merged 9 commits into
mainfrom
gh/anijain2305/43/head
Sep 26, 2026
Merged

anijain2305 merged 9 commits into
mainfrom
gh/anijain2305/43/head

Conversation

@anijain2305

@anijain2305 anijain2305 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

[ghstack-poisoned]
[ghstack-poisoned]
Comment thread torchtitan/models/common/moe.py Outdated
if self._debug_force_load_balance:
topk_expert_ids_TK, _ = self._debug_force_load_balance_routing(scores_TE)
else:
topk_expert_ids_TK = self._select_experts(

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.

Lets inline this - it was a helper created earlier

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@anijain2305
anijain2305 marked this pull request as ready for review September 25, 2026 23:47
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 25, 2026

@tianyu-l tianyu-l left a comment

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.

one question

Comment thread torchtitan/models/common/moe.py Outdated
with torch.no_grad():
self.tokens_per_expert_E.add_(masked_routing_map_TE.sum(dim=0))
if not remat.is_recomputing():
with spmd.no_typecheck(), torch.no_grad():

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.

with spmd.no_typecheck() looks new, why didn't we have it before?

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.

not required

[ghstack-poisoned]
[ghstack-poisoned]
@anijain2305
anijain2305 changed the base branch from gh/anijain2305/43/base to main September 26, 2026 01:44
@anijain2305
anijain2305 merged commit 232378f into main Sep 26, 2026
16 checks passed
submartingales pushed a commit to botcanlearn/torchtitan-upstream that referenced this pull request Sep 26, 2026
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