concept
Hardware and memory estimates
Simplified uniform decoder cache and capacity arithmetic in bytes; not a hardware fit guarantee.
Formal Syntax & Structure
artificial-intelligence syntaxartificial-intelligence
memory_budget(weights, layers, kv_heads, head_dim, tokens, sequences, element_bytes, overhead, capacity)Working Example
Example Snippetartificial-intelligence
def memory_budget(weights, layers, kv_heads, head_dim, tokens, sequences, element_bytes, overhead, capacity): values = (weights, layers, kv_heads, head_dim, tokens, sequences, element_bytes, overhead, capacity) if any(type(x) is not int or x < 0 for x in values): raise ValueError("nonnegative integer units required") if min(layers, kv_heads, head_dim, element_bytes) == 0: raise ValueError("invalid architecture") cache = 2 * layers * kv_heads * head_dim * tokens * sequences * element_bytes total = weights + cache + overhead return cache, total, capacity - total
print(memory_budget(1_000_000_000, 16, 4, 64, 1024, 2, 2, 200_000_000, 2_000_000_000))print(memory_budget(1_000_000_000, 16, 4, 64, 1024, 32, 2, 200_000_000, 2_000_000_000))