Repository navigation
[dist_moe] Support eager expert-output callbacks - #5051
Merged
Merged
Conversation
sanketpurandare
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
October 4, 2026 20:53
tianyu-l
approved these changes
Oct 4, 2026
sanketpurandare
force-pushed
the
sanket/dist-moe-eager-postprocess
branch
from
October 4, 2026 21:55
ffa1743 to
2525dc9
Compare
Dist-MoE supports both typed fused postprocess descriptors and eager callable postprocessing. TorchTitan currently accepts only RMSNormPostprocess, which prevents model-owned learned postprocessing modules from using the eager contract. Accept callable results from to_dist_moe_postprocess() and forward the exact object to the annex. Returning the module itself preserves nn.Module.__call__, forward hooks, parameter ownership, state dict entries, and ordinary autograd gradients. Invalid non-callable results still fail at the integration boundary. Test: python -m pytest -q tests/unit_tests/cpu/test_dist_moe.py tests/unit_tests/cpu/test_trainer.py -k "dist_moe or cuda_graph_accumulation_supports_eager_gradient_reduction" (32 passed)
sanketpurandare
force-pushed
the
sanket/dist-moe-eager-postprocess
branch
2 times, most recently
from
October 4, 2026 22:43
2525dc9 to
492f5a2
Compare
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.
Motivation
The Dist-MoE annex supports two post-expert policies: typed fused descriptors and eager callables. TorchTitan currently accepts only
RMSNormPostprocess, preventing a model-owned learned postprocess module from using the annex eager path while retaining normal module, optimizer, FSDP, checkpoint, hook, and autograd ownership.Design
Allow
to_dist_moe_postprocess()to return eitherdist_moe.RMSNormPostprocessor any callable. TorchTitan forwards the exact returned object todist_moe.ExecutionOptions; it does not execute, wrap, copy, or reinterpret the callback. Returning the module itself therefore preservesnn.Module.__call__, forward hooks, parameters in the state dict, and ordinary input/parameter gradients.The existing invalid-result check remains strict: objects that are neither the typed descriptor nor callable fail at the TorchTitan integration boundary. Annex marks callable policies as eager, so this does not claim arbitrary-callback make_fx or GraphTrainer support.
Verification
mainerrors described in the lower PR.This PR is the upper layer of the native GitHub stack and is based on #5050.
Stack created with GitHub Stacks CLI