首页 > AI前沿 > Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels

Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels

arXiv自然语言 2026-11-18 00:36 22 阅读 查看原文
用户要求将一段纯文本新闻正文排版成语义化的HTML片段。需要遵循以下规则: 1. 只输出HTML片段本身,不要Markdown围栏、不要解释。 2. 每个自然段落用`

`包裹,长文用`

`/`

`划分小节。 3. 列表内容用`
  • `,引用用`
    `,代码用`
    `,重要句子可用``。
    4. 保留原文所有信息,不得增删改内容。
    5. 不要输出``/``/``等文档级标签。
    
    分析正文内容:
    正文是一段关于Gemma 4 31B模型的KV cache优化的技术性描述。内容非常连贯,是一个长段落。
    原文:
    "In the global attention layers of Gemma 4 31B, the value is the normalized key projection, and the key is the value scaled by a fixed weight, with rotary position encoding on one quarter of its dimensions. The Gemma 4 report states that this design reduces the global KV cache by up to 37.5%, but the open serving engines that we checked still store a full key and a full value: 1,024 values per KV head and token. We store one 640-value row instead, exact in real arithmetic, and an unchanged paged attention kernel reads it through two overlapping strided views as its key cache and its value cache. In a vLLM prototype with the 16-bit 31B model, the outputs are bit-identical to an emulation of the same arithmetic on the stock cache, 2 of 432 final answers differ from the stock engine (within its run-to-run noise), and the steady decode KV memory per request falls by a factor of 1.34 to 1.40 at 32K to 64K tokens. On a prefill/decode pair of two A100 GPUs with NIXL transfer and CPU offload, a decode engine with a full 15 GiB pool ran 1.38 times the stock decode tokens per step for 16K-token prompts (repeated to 0.06%) and 1.24 times for 8K-token prompts; a model of the vLLM block pool predicted both ratios to within 1% (the engine was 0.7% to 0.9% higher) and matched the change between them. The eager decode throughput rose by 1.30 and 1.11 times, and on this path the compact engine gave the same output tokens as the emulation for 8 prompts at batch 1. The run-time prototype makes an eager step 4% to 9% slower at equal batch, and the method does not yet stack with an 8-bit KV cache at the default scale."
    
    考虑到这段文本主要是陈述事实和实验结果,没有明显的列表、引用或代码块。可以将其划分为几个自然段落,或者加一个小标题。
    为了符合“长文用

    /

    划分小节”和“每个自然段落用

    包裹”,我可以将原文按逻辑拆分成几个段落,或者保持原样作为一个段落,但加个标题。 原文其实是一个整体段落,但为了排版好看,可以按逻辑拆分成3-4个`

    `,或者只加一个`

    `标题,然后整个作为一个`

    `。 规则说“每个自然段落用

    包裹”,原文本身是一个自然段落。我可以直接用一个`

    `包裹,或者按句子群拆分。为了安全,按逻辑拆分几个`

    `,或者就一个`

    `。 不如加一个 `

    ` 作为小节标题,比如 "Gemma 4 31B KV Cache 优化"?不行,规则4说“不得增删改内容”,加标题属于增加内容。所以不能自己编造标题。 那就只输出 `

    ...

    `。如果原文只有一个自然段,那就只输出一个 `

    `。 或者将原文拆分成几个 `

    `,只要不改变文字内容。 拆分点: 1. In the global attention layers... as its key cache and its value cache. 2. In a vLLM prototype... at 32K to 64K tokens. 3. On a prefill/decode pair... and matched the change between them. 4. The eager decode throughput... at the default scale. 这样拆分成4个段落,完全保留原文字符,没有增删改。 重要句子可以用 ``,比如 "reduces the global KV cache by up to 37.5%" 或者 "steady decode KV memory per request falls by a factor of 1.34 to 1.40"。不过不加也可以,规则说“可用”。为了自然,加一两个 ``。 检查原文: In the global attention layers of Gemma 4 31B, the value is the normalized key projection, and the key is the value scaled by a fixed weight, with rotary position encoding on one quarter of its dimensions. The Gemma 4 report states that this design reduces the global KV cache by up to 37.5%, but the open serving engines that we checked still store a full key and a full value: 1,024 values per KV head and token. We store one 640-value row instead, exact in real arithmetic, and an unchanged paged attention kernel reads it through two overlapping strided views as its key cache and its value cache. In a vLLM prototype with the 16-bit 31B model, the outputs are bit-identical to an emulation of the same arithmetic on the stock cache, 2 of 432 final answers differ from the stock engine (within its run-to-run noise), and the steady decode KV memory per request falls by a factor of 1.34 to 1.40 at 32K to 64K tokens. On a prefill/decode pair of two A100 GPUs with NIXL transfer and CPU offload, a decode engine with a full 15 GiB pool ran 1.38 times the stock decode tokens per step for 16K-token prompts (repeated to 0.06%) and 1.24 times for 8K-token prompts; a model of the vLLM block pool predicted both ratios to within 1% (the engine was 0.7% to 0.9% higher) and matched the change between them. The eager decode throughput rose by 1.30 and 1.11 times, and on this path the compact engine gave the same output tokens as the emulation for 8 prompts at batch 1. The run-time prototype makes an eager step 4% to 9% slower at equal batch, and the method does not yet stack with an 8-bit KV cache at the default scale. 排版:

    In the global attention layers of Gemma 4 31B, the value is the normalized key projection, and the key is the value scaled by a fixed weight, with rotary position encoding on one quarter of its dimensions. The Gemma 4 report states that this design reduces the global KV cache by up to 37.5%, but the open serving engines that we checked still store a full key and a full value: 1,024 values per KV head and token. We store one 640-value row instead, exact in real arithmetic, and an unchanged paged attention kernel reads it through two overlapping strided views as its key cache and its value cache.

    In a vLLM prototype with the 16-bit 31B model, the outputs are bit-identical to an emulation of the same arithmetic on the stock cache, 2 of 432 final answers differ from the stock engine (within its run-to-run noise), and the steady decode KV memory per request falls by a factor of 1.34 to 1.40 at 32K to 64K tokens.

    On a prefill/decode pair of two A100 GPUs with NIXL transfer and CPU offload, a decode engine with a full 15 GiB pool ran 1.38 times the stock decode tokens per step for 16K-token prompts (repeated to 0.06%) and 1.24 times for 8K-token prompts; a model of the vLLM block pool predicted both ratio