xuan-luo's picture
download
raw
2.31 kB
"""Exact parameter and theoretical compact incremental-cache accounting."""
LAYERS, HIDDEN, Q_HEADS, KV_HEADS, HEAD_DIM = 12, 512, 8, 4, 64
TARGET_PARAMETERS = 100_872_704
NON_ATTN_NON_FFN_PARAMETERS = 51_524_096
LOCAL_WINDOW = 128
def ffn_widths(layers=LAYERS, hidden=HIDDEN, default=2166):
if (layers, hidden, default) == (LAYERS, HIDDEN, 2166):
return [2166] * 4 + [2165] * 8
return [default] * layers
def budget(roll_dim: int, dtype_bytes: int = 2):
if roll_dim not in (8, 16, 32, 64) or HEAD_DIM % roll_dim:
raise ValueError("roll_dim must be 8, 16, 32, or 64")
projection = LAYERS * HIDDEN * (Q_HEADS * HEAD_DIM + 2 * KV_HEADS * HEAD_DIM)
output = LAYERS * Q_HEADS * HEAD_DIM * HIDDEN
parameters = (NON_ATTN_NON_FFN_PARAMETERS + projection + output
+ 3 * HIDDEN * sum(ffn_widths()))
slots = HEAD_DIM // roll_dim
independent_states = LAYERS + slots - 1
rolling_elements = 2 * KV_HEADS * roll_dim * independent_states
local_elements = LAYERS * KV_HEADS * 2 * HEAD_DIM * LOCAL_WINDOW
contexts = {}
for context in (2048, 8192, 32768):
rolling_bytes = context * rolling_elements * dtype_bytes
local_bytes = local_elements * dtype_bytes
contexts[str(context)] = {
"rolling_bytes": rolling_bytes, "local_ring_bytes": local_bytes,
"persistent_auxiliary_bytes": 0,
"total_cache_bytes": rolling_bytes + local_bytes,
}
return {
"parameters": parameters, "target_parameters": TARGET_PARAMETERS,
"parameter_difference": parameters - TARGET_PARAMETERS,
"projection_layout": "Q[8,64],K[4,64],V[4,64]",
"ffn_widths": ffn_widths(), "roll_dim": roll_dim,
"rolling_slots": slots, "independent_states": independent_states,
"rolling_elements_per_token": rolling_elements,
"rolling_bytes_per_token": rolling_elements * dtype_bytes,
"local_ring_elements_per_sequence": local_elements,
"local_ring_bytes_per_sequence": local_elements * dtype_bytes,
"persistent_auxiliary_bytes": 0,
"workspace": "flash-attn local+distant outputs/LSE; not persistent cache",
"incremental_cache_status": "theoretical; incremental decode not implemented",
"contexts": contexts,
}

Xet Storage Details

Size:
2.31 kB
·
Xet hash:
5c0c546a7c6a2250f3a82c548459fb5a975b87d7e5f82052ef3fd5c43c496892

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.