NumPy allowed · plain Python earns 10 bonus points
Q · Kᵀ / √d scores normalized with softmax
Calculate the exact VRAM footprint in bytes required by an LLM KV-cache during multi-turn autoregressive serving.
Implement calculate_kv_cache_bytes(num_layers, num_kv_heads, head_dim, seq_len, batch_size, bytes_per_param=2). Return the total byte count accounting for both Key and Value tensors across all layers, heads, positions, and batch slots.
calculate_kv_cache_bytes(num_layers: int, num_kv_heads: int, head_dim: int, seq_len: int, batch_size: int, bytes_per_param: int = 2) -> int