You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From internal discussions, logging an issue around updating our MFU calculations so that if FP8 is used, we can generate an accurate MFU number.
Atm - FP8 replaces wq/wk/wv/wo in Attention, and w1/w2/w3 in the MLP.
Thus, need an adjusted calculation.
In addition, would like to correctly pull the proper MFU (fp8 or bf16) based on the training config being run so this is handled automatically for the user.
Hmm I don't see a proper way to calculate MFU when some computations (linear) use FP8 and some others use BF16 (everything else, e.g. sdpa). What should be the right way?
I chatted with @stas00 briefly offline and he suggested 2 approaches
Assume peak is all computations are done in FP8, as this is no different than how MFU computations are done for BF16
Assume peak is a weighted average of BF16 and FP8
1 feels simpler with the main con being that numbers we share might be "low" compared to other vendors if they use 2 but we can make it clear how we define MFU in high level marketing material
I feel like PyTorch could offer a very similar utility that measures peak flops per operator. Imagine that you prepare your model first (parallelize, fp8, etc) and then measure the peak flops. From my understanding, such utility could understand the differences between the theoretical performance of the operators based on runtime information like their dtypes.
But if you want to go the easy route, option 1 seems the better choice to me. For the big models most flops will go to the linears anyways and forkers can always customize the calculation.
But please do not perpetuate the abuse of MFU as a marketing number 🙏. You can report tokens per second (if not padding) or sequences per second. MFU measuring contests are pointless unless the flops calculation is proved to be exactly the same
To me there is no right way of doing mixed MFU with BF16 and FP8, the approaches @msaroufim mentioned sound "less wrong" but not correct.
Fine-grained MFU e.g. at op level makes sense, but at the cost that it is no longer a top-line metric for e2e systems.
I agree that we should focus on metrics like tokens/sec to make fair comparisons (but even for that different repos have different ways of measuring). This is what we report in the torchtitan paper.
We still keep MFU around because it's more intuitive than tokens/sec. E.g. when using Context Parallel with ultra long sequences, the throughput would drop a lot naturally, but we can look at MFU ~30%--40% to have confidence that the implementation is good.
I guess the way torchtitan calculates MFU was unfortunately influenced by other popular repos. I hope the community can agree on the metrics and their calculation.
Perhaps going forward it'd be the easiest to report tflops not as a single number? but something like 415(bf16) 490(fp8) - then fp4, mxfp4, etc. can be added as well - whatever the different dtypes are used - report each separately. Then everything becomes well-defined. And MFU as well 43%(bf16) 45%(fp8).
My take is that MFU was used as a "top-line" "logical" metric, whose denominator takes into account the time we spend on data loading, recomputation, etc. If separating computation per dtype / per op, yes we could count per-op / per-dtype utility rate, but how do you attribute the "general waste"?
So I'd say
If current MFU is confusing and useless, we should consider deleting it. But then we lose it for bf16 monitoring, should we enable it conditionally? but what if I just wanna get a sense of how fast fp8 is rather than taking the MFU literally. One could argue that we should use tflops / tps, which is what I mentioned earlier and what I'm seeing the community / papers / tech reports are using.
If users want fine-grained metrics measuring something else, proposals and discussions are welcome. But to me it sounds like adding an entirely new metric to track (e.g. just like grad_norm), rather than as a replacement of MFU.
I personally don't use MFU as it's already a BS number since 100% is unachievable and moreover the achievable efficiency wildly varies between gpus. So if you move from B200 to GB200 you already have to recalibrate since the achievable performance/effiency isn't the same (see the tables I linked to).
Relative TFLOPS are very useful because they tell you how much improvement or regression has been made against some previous baseline. But when you run different parts of compute in different regime a single TFLOPS number is not possible. Even if you somehow do a weighted average the important information will be lost in averaging. So as I mentioned above reporting TFLOPS per dtype (for all ops of that dtype) is probably the next common sense practical thing.
If people then want to convert this to MFU so that they could boast about their system's efficiency it's totally their choice.
I did like MFU as an indicator of the efficiency of the compute before I created MAMF metrics. So for example Megatron-LM reported that when they moved from A100 to H100 back in the day they couldn't reach the same MFU - not because their code was somehow inferior (it was super optimized), but because the H100's compute efficiency was much worse than that of H100 (and the trend continues btw if you check the table in the link of the first para). So that's where I'd say it's useful still. But again not as a comparison across frameworks. The latter is wrong because people can't even agree on how to measure FLOPs (in particular various fwd re-runs and for example Flash Attention flops don't fit into any known approach, Tri Dao himself shares some very unusual multipliers because he wrote this stuff - what are the chances that other developers will calculate FLOPs correctly.
My recommendation is this - measure FLOPs in whatever way you like and compare your previous code version's FLOPs/s to your current code version's of the same. Then you know if you make a regression or you're making things better. If it's a public framework clearly disclose how you measure FLOPs for different components.
Reacted by ChewKokWah, Joonhyung Lee/이준형, Rustem and Younes B
Activity
raghukiran1224 commentedon Sep 8, 2024
yes, this needs to be updated. The MFU computations for
fp8are too good to be true :)CC: @lchu-ibm
tianyu-l commentedon Nov 22, 2024
Hmm I don't see a proper way to calculate MFU when some computations (linear) use FP8 and some others use BF16 (everything else, e.g. sdpa). What should be the right way?
msaroufim commentedon Dec 4, 2024
I chatted with @stas00 briefly offline and he suggested 2 approaches
1 feels simpler with the main con being that numbers we share might be "low" compared to other vendors if they use 2 but we can make it clear how we define MFU in high level marketing material
carmocca commentedon Dec 5, 2024
My personal thoughts:
I was surprised when I saw that torchtitan uses the simple and overoptimistic "academic" flops formula (https://github.com/pytorch/torchtitan/blob/main/torchtitan/utils.py#L231) considering that
torch.utils.flop_counter.FlopCounterModealready exists (and in my experience, works quite well).I feel like PyTorch could offer a very similar utility that measures peak flops per operator. Imagine that you prepare your model first (parallelize, fp8, etc) and then measure the peak flops. From my understanding, such utility could understand the differences between the theoretical performance of the operators based on runtime information like their dtypes.
But if you want to go the easy route, option 1 seems the better choice to me. For the big models most flops will go to the linears anyways and forkers can always customize the calculation.
But please do not perpetuate the abuse of MFU as a marketing number 🙏. You can report tokens per second (if not padding) or sequences per second. MFU measuring contests are pointless unless the flops calculation is proved to be exactly the same
tianyu-l commentedon Dec 5, 2024
thanks @carmocca
tianyu-l commentedon Feb 26, 2025
added TFLOPs in #847 as alternative -- closing this issue
chelsea0x3b commentedon Nov 12, 2025
Will this ever be revisited? Currently seeing some bogus MFU numbers like 87% when using fp8.
tianyu-l commentedon Nov 12, 2025
MFU when using mixed fp8 and bf16 is not well-defined. People use token/sec or tflops instead.
chelsea0x3b commentedon Nov 12, 2025
stas00 commentedon Nov 12, 2025
Perhaps going forward it'd be the easiest to report tflops not as a single number? but something like
415(bf16) 490(fp8)- then fp4, mxfp4, etc. can be added as well - whatever the different dtypes are used - report each separately. Then everything becomes well-defined. And MFU as well43%(bf16) 45%(fp8).tianyu-l commentedon Nov 12, 2025
@coreylowman @stas00
My take is that MFU was used as a "top-line" "logical" metric, whose denominator takes into account the time we spend on data loading, recomputation, etc. If separating computation per dtype / per op, yes we could count per-op / per-dtype utility rate, but how do you attribute the "general waste"?
So I'd say
grad_norm), rather than as a replacement of MFU.stas00 commentedon Nov 12, 2025
I personally don't use MFU as it's already a BS number since 100% is unachievable and moreover the achievable efficiency wildly varies between gpus. So if you move from B200 to GB200 you already have to recalibrate since the achievable performance/effiency isn't the same (see the tables I linked to).
Relative TFLOPS are very useful because they tell you how much improvement or regression has been made against some previous baseline. But when you run different parts of compute in different regime a single TFLOPS number is not possible. Even if you somehow do a weighted average the important information will be lost in averaging. So as I mentioned above reporting TFLOPS per dtype (for all ops of that dtype) is probably the next common sense practical thing.
If people then want to convert this to MFU so that they could boast about their system's efficiency it's totally their choice.
I did like MFU as an indicator of the efficiency of the compute before I created MAMF metrics. So for example Megatron-LM reported that when they moved from A100 to H100 back in the day they couldn't reach the same MFU - not because their code was somehow inferior (it was super optimized), but because the H100's compute efficiency was much worse than that of H100 (and the trend continues btw if you check the table in the link of the first para). So that's where I'd say it's useful still. But again not as a comparison across frameworks. The latter is wrong because people can't even agree on how to measure FLOPs (in particular various fwd re-runs and for example Flash Attention flops don't fit into any known approach, Tri Dao himself shares some very unusual multipliers because he wrote this stuff - what are the chances that other developers will calculate FLOPs correctly.
My recommendation is this - measure FLOPs in whatever way you like and compare your previous code version's FLOPs/s to your current code version's of the same. Then you know if you make a regression or you're making things better. If it's a public framework clearly disclose how you measure FLOPs for different components.
15 remaining items
[MFU] Skip MFU display when FP8/MX quantization is active and add GB2…
[MFU] Skip MFU display when FP8/MX quantization is active and add GB2…
[MFU] Skip MFU display when FP8/MX quantization is active and add GB2…
[MFU] Skip MFU display when FP8/MX quantization is active and add GB2…
[MFU] Skip MFU display when FP8/MX quantization is active and add GB2…
Merge pull request pytorch#560 from google-pytorch:docs/add-oss-readm…