xformers icon indicating copy to clipboard operation
xformers copied to clipboard

attention's flop calculation when casual is set to True.

Open kf-zhang opened this issue 10 months ago • 2 comments

❓ Questions and Help

I'm currently trying to comprehend the attention flop calculation as defined here. However, I am facing confusion regarding this specific section, which pertains to the flop calculation when 'casual' is set to True. It seems that the flop is incorrect when query's length is different from key-value' s length.

kf-zhang avatar Apr 22 '24 06:04 kf-zhang

It seems that the flop is incorrect when query's length is different from key-value' s length

Yes indeed, you are right. I guess we also need to distinguish between causal from topleft / bottomright when num_kv != num_q. This is not passed in the API at the moment. Out of curiosity, what are you using this function for?

danthe3rd avatar Apr 24 '24 12:04 danthe3rd

I'm trying to calculate mfu and understand how flop is calculated. Many papers describe their system's efficiency using mfu, but few explain how to calculate flop.

kf-zhang avatar Apr 29 '24 13:04 kf-zhang