Cache Arithmetic

A 32-layer transformer has 32 attention heads with head_dim=128, and uses fp16 (2 bytes/value). For one sequence of 4096 tokens at batch size 1, roughly how large is the KV cache?

A

~8.4 GB

B

~34 GB

C

~2.1 GB

D

~1.07 GB

E

~0.5 GB