good news - we've actually included optimized causal and non-causal versions of the flash attention backwards pass with TK - would love for you to check them out!
causal: https://github.com/HazyResearch/ThunderKittens/blob/main/exa...
non-causal: https://github.com/HazyResearch/ThunderKittens/blob/main/exa...