[1/2] [GraphTrainer] Support dense FP8 compilation - #4384
Open
WhoisZihan wants to merge 2 commits into
Open
Conversation
WhoisZihan
requested review from
IvanKobzarev,
SherlockNoMad,
aditvenk,
fegin,
sanketpurandare,
tianyu-l,
wconstab,
wwwjn and
xmfan
as code owners
August 31, 2026 10:55
This was referenced Aug 31, 2026
Author
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.
RFC available in #3990
The goal is to adds the foundation for compiling and running quantized TorchAO FP8 models with GraphTrainer, which currently does not support regional inductor for fp8 nodes.
Implementation
The main problem is that TorchAO FP8 quantization is implemented through a dynamic sequence of casts, scaling operations, and scaled matrix multiplications. Detecting FP8 regions solely from individual operators is fragile because the traced decomposition can vary across PyTorch and TorchAO versions. This change preserves quantization provenance from the converted modules and uses it during GraphTrainer validation and regional annotation.
Another challenge is PP which partitions graph and might cut a complete FP8 region into two separated parts. To handle such situation, we should
graph_pp_pre_partition_fp8_passes, which means we ensure the fp8 region contains complete chains of nodes, instead of silent fallback to bf16.Detailed changes are
Code Scope
Almost all of the changes are GraphTrainer only, with only one exception that we need to keep
_quantization_emulatefield in Float8Linear module so that fp8 passes can identify emulated nodes.Known Limits
This PR only supports the fp8 linear nodes, then MoE grouped experts part can be found in [2/2] Add grouped-expert FP8 GraphTrainer support