Estimate the total key-value (KV) cache memory in bytes for a transformer that mixes full attention layers and sliding-window attention (SWA) layers. With grouped-query attention (GQA) the cache stores num_kv_heads per layer (not num_heads). For full-attention layers, every token's K and V are kept (effective sequence length = seqlen). For SWA layers, only the most recent window tokens are retained (effective sequence length = min(seqlen, window)).
Implement kv_cache_bytes(num_layers_full, num_layers_swa, batch, seqlen, window, num_kv_heads, head_dim, dtype_bytes) that returns the total KV cache size in bytes as an integer.
For a single layer, KV cache bytes = 2 * batch * effective_seqlen * num_kv_heads * head_dim * dtype_bytes (the factor of 2 accounts for storing both K and V). Sum across all layers.