Skip to content

Adjust MFU to account for FP8  #560

Closed

Description

@lessw2020

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.

Activity

  1. raghukiran1224 commented on Sep 8, 2024

    @raghukiran1224

    yes, this needs to be updated. The MFU computations for fp8 are too good to be true :)
    CC: @lchu-ibm

  2. tianyu-l commented on Nov 22, 2024

    @tianyu-l
    Contributor

    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?

  3. msaroufim commented on Dec 4, 2024

    @msaroufim

    I chatted with @stas00 briefly offline and he suggested 2 approaches

    1. Assume peak is all computations are done in FP8, as this is no different than how MFU computations are done for BF16
    2. 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

  4. carmocca commented on Dec 5, 2024

    @carmocca
    Contributor

    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.FlopCounterMode already 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

  5. tianyu-l commented on Dec 5, 2024

    @tianyu-l
    Contributor

    thanks @carmocca

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
  6. added
    documentation
    enhancement
    on Feb 1, 2025
  7. tianyu-l commented on Feb 26, 2025

    @tianyu-l
    Contributor

    added TFLOPs in #847 as alternative -- closing this issue

  8. chelsea0x3b commented on Nov 12, 2025

    @chelsea0x3b
    Contributor

    Will this ever be revisited? Currently seeing some bogus MFU numbers like 87% when using fp8.

  9. tianyu-l commented on Nov 12, 2025

    @tianyu-l
    Contributor

    MFU when using mixed fp8 and bf16 is not well-defined. People use token/sec or tflops instead.

  10. chelsea0x3b commented on Nov 12, 2025

    @chelsea0x3b
    Contributor
  11. stas00 commented on Nov 12, 2025

    @stas00

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

  12. tianyu-l commented on Nov 12, 2025

    @tianyu-l
    Contributor

    @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

    • 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.
  13. stas00 commented on Nov 12, 2025

    @stas00

    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.

  14. 15 remaining items

  15. removed
    documentation
    on Feb 9, 2026
  16. added this to the New Feature, Model, Misc milestone on Feb 9, 2026
  17. moved this from Todo to In Progress in TorchTitan Developmenton Feb 20, 2026
  18. added a commit that references this issue on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions