Skip to content

[MFU] Skip MFU display when FP8/MX quantization is active and add GB200/GB3… - #2451

Merged
shuhuayu merged 4 commits into
pytorch:mainfrom
shuhuayu:opt
Mar 1, 2026
Merged

shuhuayu merged 4 commits into
pytorch:mainfrom
shuhuayu:opt

Conversation

@shuhuayu

Copy link
Copy Markdown
Contributor

Hide MFU when quantization is active and add peak tflops for GB200 and GB300. This is a short-term answer to #560.

Before this pr, when fp8 is enabled. MFU is displayed but over bf16 peak flops.
1-26 2311505,123 - го61 -

After this pr, when fp8/mx quantization is active, MFU is shown to be N/A.
6 71148 gred 10rk 2 445

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 27, 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.

Thanks!

# (FP8/MX) is active, so we skip it in that case.
tflops = self.num_flops_per_token * tps / 1e12
if self.has_quantization:
mfu = None

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.

can we set it to "N/A" here to avoid the
self.logger.log({k: v for k, v in metrics.items() if v is not None}, step) below? Not sure if it can be "logged"

@shuhuayu shuhuayu Feb 27, 2026 •

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.

"N/A" cannot be handled by TensorBoard so I propose to put mfu into metrics dict only when it is not None.

Comment thread torchtitan/trainer.py
Comment on lines +275 to +279
# Check if any converter uses quantization (FP8, MX, etc.)
has_quantization = any(
getattr(cc, "_quantization_type", None) is not None
for cc in config.model_converters.converters
)

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.

This is too hacky. A less hacky way is to let all quantization converters inherit QuantizationConverter parent class, and use isinstance(..., QuantizationConverter.Config) to test here.

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.

Sounds great. Built a wrapper config QuantizationConverter(Configurable).

Comment thread torchtitan/trainer.py Outdated
model_param_count,
self.metrics_processor.num_flops_per_token,
) = model_config.get_nparams_and_flops(model, config.training.seq_len)
self.metrics_processor.has_quantization = has_quantization

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.

let's put it in build arg, instead of doing this direct setter. Things can become hard to read / debug if we use too many direct setter.

Comment thread torchtitan/tools/utils.py Outdated
# BF16 dense per GPU: 2,500 TFLOPS (half of 5,000 TFLOPS with sparsity)
# data from https://www.nvidia.com/en-us/data-center/dgx-gb300
return 2.5e15
elif "GB200" in device_name:

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.

let's consolidate the two entries

Comment thread torchtitan/protocols/model_converter.py Outdated
...


class QuantizationConverter(Configurable):

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.

Because of proximity, let's put this in quantization folder, maybe quantization/init.py

qt = getattr(config, "_quantization_type", None)
if qt is not None:
if isinstance(config, QuantizationConverter.Config):
qt = config._quantization_type

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.

Can we just use the type of the config, instead of this extra string? If so, let's deprecate _quantization_type.

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.

Good suggestion. This is a little bit tricky. For example Float8GroupedMMConverter and Float8LinearConverter have the same quantization type float8. If we only compare the config types, these legitimate combination would be rejected. What do you think? There are ways to check this by using config's module, but i guess this is hacky.

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.

Oh good point. One way to do this is to let Float8 converters share an intermediate level of parent, e.g. Float8Converter. That seems not necessary for now, so let's keep what you are doing.

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

stamp

@tianyu-l tianyu-l linked an issue Feb 28, 2026 that may be closed by this pull request
@shuhuayu
shuhuayu merged commit f113706 into pytorch:main Mar 1, 2026
27 of 29 checks passed
danielvegamyhre pushed a commit that referenced this pull request Mar 6, 2026
…00/GB3… (#2451)

Hide MFU when quantization is active and add peak tflops for GB200 and
GB300. This is a short-term answer to
#560.

Before this pr, when fp8 is enabled. MFU is displayed but over bf16 peak
flops.
<img width="968" height="320" alt="1-26 2311505,123 - го61 -"
src="https://github.com/user-attachments/assets/0e77c8c4-c287-419e-a11f-a1afeadf1b67"
/>

After this pr, when fp8/mx quantization is active, MFU is shown to be
N/A.
<img width="1133" height="270" alt="6 71148 gred 10rk 2 445"
src="https://github.com/user-attachments/assets/ce68464a-a1c2-4cfd-888b-595a41a7bf49"
/>
acisseJZhong pushed a commit that referenced this pull request Mar 11, 2026
…00/GB3… (#2451)

Hide MFU when quantization is active and add peak tflops for GB200 and
GB300. This is a short-term answer to
#560.

Before this pr, when fp8 is enabled. MFU is displayed but over bf16 peak
flops.
<img width="968" height="320" alt="1-26 2311505,123 - го61 -"
src="https://github.com/user-attachments/assets/0e77c8c4-c287-419e-a11f-a1afeadf1b67"
/>

After this pr, when fp8/mx quantization is active, MFU is shown to be
N/A.
<img width="1133" height="270" alt="6 71148 gred 10rk 2 445"
src="https://github.com/user-attachments/assets/ce68464a-a1c2-4cfd-888b-595a41a7bf49"
/>
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
…00/GB3… (pytorch#2451)

Hide MFU when quantization is active and add peak tflops for GB200 and
GB300. This is a short-term answer to
pytorch#560.

Before this pr, when fp8 is enabled. MFU is displayed but over bf16 peak
flops.
<img width="968" height="320" alt="1-26 2311505,123 - го61 -"
src="https://github.com/user-attachments/assets/0e77c8c4-c287-419e-a11f-a1afeadf1b67"
/>

After this pr, when fp8/mx quantization is active, MFU is shown to be
N/A.
<img width="1133" height="270" alt="6 71148 gred 10rk 2 445"
src="https://github.com/user-attachments/assets/ce68464a-a1c2-4cfd-888b-595a41a7bf49"
/>
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
…00/GB3… (pytorch#2451)

Hide MFU when quantization is active and add peak tflops for GB200 and
GB300. This is a short-term answer to
pytorch#560.

Before this pr, when fp8 is enabled. MFU is displayed but over bf16 peak
flops.
<img width="968" height="320" alt="1-26 2311505,123 - го61 -"
src="https://github.com/user-attachments/assets/0e77c8c4-c287-419e-a11f-a1afeadf1b67"
/>

After this pr, when fp8/mx quantization is active, MFU is shown to be
N/A.
<img width="1133" height="270" alt="6 71148 gred 10rk 2 445"
src="https://github.com/user-attachments/assets/ce68464a-a1c2-4cfd-888b-595a41a7bf49"
/>
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.

Adjust MFU to account for FP8

2 participants