Estimate the KV cache memory footprint (in bytes) for three attention variants used in transformer inference: standard Multi-Head Attention (MHA), Grouped-Query Attention (GQA), and Multi-head Latent Attention (MLA).
Given the batch size, sequence length, number of layers, number of heads, head dimension, number of KV groups (for GQA), MLA latent dimension, attention type, and bytes per element, return the total KV cache size in bytes as an integer.
Formulas:
The factor of 2 in MHA/GQA accounts for storing both K and V; MLA stores a single compressed latent vector per token per layer.
The attn_type argument is one of 'mha', 'gqa', or 'mla'. Return an int.