Skip to content

[GraphTrainer] Enhance FP8 region compilation - #3989

Closed
WhoisZihan wants to merge 10 commits into
pytorch:mainfrom
WhoisZihan:feature/graph-trainer-fp8
Closed

[GraphTrainer] Enhance FP8 region compilation#3989
WhoisZihan wants to merge 10 commits into
pytorch:mainfrom
WhoisZihan:feature/graph-trainer-fp8

Conversation

@WhoisZihan

Copy link
Copy Markdown

Summary

Add opt-in FP8 support to GraphTrainer for already-quantized TorchAO modules.

The implementation:

  • propagates quantization provenance into the traced forward and backward graphs;
  • validates that non-emulated quantized regions contain supported FP8 compute;
  • supports full/regional Inductor compilation with FP8 regions;
  • preserves FP8 behavior across GraphPP forward/backward and backward-input/
    backward-weight partitioning;
  • includes quantization configuration in precompile artifact fingerprints.

Design

Quantized modules annotate traced nodes with their module FQN, quantization kind,
and emulation mode. The FP8 passes use this provenance together with actual FP8
operand dtypes to distinguish supported _scaled_mm compute from unrelated
scaled operations.

For regional Inductor, FP8 components are identified after graph rewrites and
tagged only when the identified component is complete. GraphPP first validates
the complete stage joint graph, then re-identifies regions independently in
each extracted callable.

GraphPP may produce shared FP8 quantization in the backward-input graph and pass
the quantized tensor into the backward-weight graph. Such FP8 placeholders are
treated as valid callable boundaries, allowing the local _scaled_mm region to
be compiled without duplicating quantization work.

Strict validation detects missing provenance or unsupported lowering instead of
silently falling back to eager execution. Emulated Float8Linear modules are
exempt from the _scaled_mm requirement because they intentionally use
higher-precision compute.

Current limitations

  • FP8 CUDA Graph capture has not been validated and cudagraph_pass must be
    disabled.
  • Regional Inductor compilation does not support FP8 grouped experts; full
    Inductor should be used for those graphs.
  • FP8 precompile currently supports regional dense FP8 graphs only.
  • Performance and numerical validation across larger distributed configurations
    remains follow-up work.

Testing

  • FP8 configuration and strict-validation tests
  • quantization provenance propagation tests
  • regional component completeness tests
  • emulation-mode tests
  • precompile fingerprint tests
  • GraphPP partition and FP8-placeholder boundary tests
  • Float8Linear regional Inductor forward/backward GPU test

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 27, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/8gpu

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@WhoisZihan WhoisZihan changed the title [GraphTrainer] Support FP8 region nodes capture and compilation [GraphTrainer] Enhance FP8 region compilation Jul 27, 2026
@WhoisZihan
WhoisZihan force-pushed the feature/graph-trainer-fp8 branch 2 times, most recently from 6b98299 to ca8a3c2 Compare August 10, 2026 06:51
@WhoisZihan
WhoisZihan force-pushed the feature/graph-trainer-fp8 branch from ca8a3c2 to 37d7991 Compare August 10, 2026 06:53
@WhoisZihan

Copy link
Copy Markdown
Author

Removed the cudagraph restriction in previous implementation, now we can turn on cudagraph for fp8 nodes in GraphTrainer.
The performance of debugmodel on single sm90 card is

setup TPS mean memory speedup
Trainer FP8 169k 1.30 GiB 1.00×
Graph regional w/o cudagraph 287k 0.96 GiB 1.70×
Graph regional w/ cudagraph 300k 0.96 GiB 1.77×

@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.

seems not graph trainer only

@WhoisZihan

Copy link
Copy Markdown
Author

seems not graph trainer only

Added QuantizationSignature for precompile to avoid using old cache when the quantization config changes, but it does seem to carry some other signatures unrelated to quantization, and precompile with fp8 has not been well tested yet.
If you would like to keep precompile untouched at the moment, I can remove it in this thread and recover it in future follow-ups, or I can test the pre-compile coverage in next step.

@WhoisZihan
WhoisZihan force-pushed the feature/graph-trainer-fp8 branch from e66c42a to 37d7991 Compare August 31, 2026 09:30
@WhoisZihan

WhoisZihan commented Aug 31, 2026

Copy link
Copy Markdown
Author

Refactored in #4384

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu 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