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
{{ message }}
Repository navigation
Potentially incorrect attention flop calculation due to wrong head_dim? #1920
It seems we need to revisit the formula of attention flops computation, especially for Qwen3 and DeepSeek V3.
Maybe we can separate num params computation from total flops calculation -- the former can be shared across models, the latter may need to be customized for each model due to different attention details.
Overall I think attention part may not matter much in flop computation due to the its scale compared with the matmul part.
Proposed a fix in this pr: #1923. Following the previously mentioned convention, the sparsity introduced by fixed_block_size (attention window) in local layers of Llama 4 models is also ignored.
Activity
tianyu-l commentedon Oct 19, 2025
It seems we need to revisit the formula of attention flops computation, especially for Qwen3 and DeepSeek V3.
Maybe we can separate num params computation from total flops calculation -- the former can be shared across models, the latter may need to be customized for each model due to different attention details.
Overall I think attention part may not matter much in flop computation due to the its scale compared with the matmul part.
cc @shuhuayu @wwwjn
gau-nernst commentedon Oct 20, 2025
Also just noticed that, due to causal attention, shouldn't the attention FLOPs be further divided by 2?
tianyu-l commentedon Oct 20, 2025
See
torchtitan/torchtitan/models/utils.py
Line 384 in a8899e4
shuhuayu commentedon Oct 21, 2025
Proposed a fix in this pr: #1923. Following the previously mentioned convention, the sparsity introduced by
fixed_block_size(attention window) in local layers of Llama 4 models is also ignored.