[2/2] Add grouped-expert FP8 GraphTrainer support - #2
Open
WhoisZihan wants to merge 2 commits into
Open
Conversation
WhoisZihan
force-pushed
the
feature/graph-trainer-fp8-support-pr2
branch
from
August 31, 2026 10:04
c85f257 to
49c2118
Compare
WhoisZihan
force-pushed
the
feature/graph-trainer-fp8-support-pr2
branch
from
August 31, 2026 10:04
49c2118 to
cc2463b
Compare
This was referenced Aug 31, 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.
The goal is to extend GraphTrainer FP8 support from dense linear layers to MoE grouped experts running with expert parallelism (EP), while keeping FP8 limited to local expert computation and preserving the existing communication path.
Implementation
Grouped-expert FP8 is more difficult than dense FP8 because the number of tokens assigned to each expert is dynamic. Under EP, tokens are exchanged and then reordered into expert-major layout before grouped GEMM. FP8/MXFP8 grouped GEMM also requires each expert's token group to satisfy a kernel-specific alignment constraint. These dynamic padded shapes can produce compound symbolic expressions that FakeTensor and regional Inductor cannot codegen directly.
This PR addresses these issues in three parts:
aten._scaled_grouped_mmpath when a data-dependent symbolic layout guard prevents FakeTensor from constructing output metadata.The GraphTrainer FP8 pass is also extended to distinguish dense scaled GEMM from grouped scaled GEMM. The grouped-expert pad SymInt path is traceable. With
TORCHTITAN_FP8_EP_UNBACKED_PAD=1, the custom path creates an unbacked padded length and installs a shape-only grouped-GEMM metadata fallback, allowing the supported path to reach regional Inductor. Regions with unbound compound EP padding symbols that remain after this workaround are skipped with a warning rather than generating an invalid regional kernel. Full Inductor remains available as the fallback for those cases.The workaround is opt-in through
TORCHTITAN_FP8_EP_UNBACKED_PAD=1and is installed only when the grouped-expert padding path needs it. The eager execution path continues to use TorchAO's regularpermute_and_padimplementation.Detailed changes
aten._scaled_grouped_mmas the compute target for grouped FP8.Code Scope
Most of the graph analysis and tracing changes are inside
torchtitan/experiments/graph_trainer. A few shared changes are required to connect GraphTrainer with the existing TorchAO grouped-expert implementation:No FP8 communication or change to the general high-precision EP communication semantics is introduced by this PR.
Tests
The PR adds or updates coverage for:
The GPU integration cases use the existing H100 test suite and 10 training steps for smoke coverage.
Known Limits
TORCHTITAN_FP8_EP_UNBACKED_PAD=1. Regions with unbound symbols that remain after this workaround are skipped and run eagerly; full Inductor remains the fallback.aten._scaled_grouped_mmimplementation and may need adjustment when that implementation changes.