读见

SenseNova-Loop-9B 用 32 层运行 56 次:这对 KV cache 有何影响,以及 9B 和 14.6B 分别意味着什么

原题SenseNova-Loop-9B runs 32 layers 56 times: what that does to the KV cache, and what the 9B and 14.6B figures mean

约 9 分钟约 2,069 字原文英文已翻译

推荐理由选长上下文模型时,可用层复用拆解区分权重占用、实际计算和缓存开销,避免用单一参数量推测部署成本。

读前速览

5 个要点

文章分析了 SenseNova-Loop-9B 的创新架构:它使用 32 个不同的层,其中 24 层运行两次,总计执行 56 次,从而实现相当于 14.6B 参数模型的推理计算量,同时借助混合注意力机制高效控制 KV cache 的内存占用。

  1. 循环架构通过一个共享权重、运行两次的 24 层模块,仅用 32 个不同的层就完成了 56 次层计算。

    第 0-3 层和第 28-31 层各执行一次,第 4-27 层(共 24 层)执行两次,总计执行 56 次。这样一来,模型以 9.66B 的存储参数量实现了相当于 14.6B 参数模型的推理计算量;其每个 token 的运行速度更接近 14.6B 稠密模型,同时保持了 9B 模型的内存占用。

  2. 混合注意力设计仅使用 8 个全注意力层,与稠密模型相比可减少 75% 的 KV cache 内存占用。

    只有索引为 3、7、11、15、19、23、27 和 31 的层使用全注意力;其余 24 层使用具有固定大小循环状态的线性注意力。在 256K 上下文长度下,BF16 cache 可从全层使用全注意力时的 34.4GB 降至 8.6GB(共享 cache)或 15GB(每次循环单独使用 cache),因此可部署在消费级 GPU 上。

  3. 带 Sinkhorn 归一化的双流流形约束超连接(mHC)无需标准残差连接,即可实现复杂路由。

    循环模块使用两条残差流,并通过学习得到的映射执行读取、混合和回写;这些映射受到 Sinkhorn 归一化约束,共进行 20 次迭代。路由参数以 FP32 存储,骨干网络则使用 BF16,因此需要定制推理实现来保持计算顺序。

  4. 基准测试结果显示,这款 9B 模型在多项评测任务中可与 27B 稠密模型竞争。

    SenseNova-Loop-9B 在 AutomationBench 上得分为 36.67,在 Terminal-Bench 2.1 上为 59.55,在 GAIA 上为 69.90,在 BIRD 上为 72.34;在大多数指标上达到或超过 Qwen3.8-27B,同时采用 4-bit 量化时仅占用 4.9GB,体现出较高的参数效率。

  5. 循环扩展研究表明,增加循环次数能够提升模型性能。

    在训练数据固定的情况下,对 1-4 次循环进行测试后发现,3-4 次循环带来的相对提升最高:AIDABench-QA 提升 6.42%,Workbuddy-office 提升 16.93%,LiveCodeBench V6 提升 8.10%,AIDABench 可视化任务提升 8.55%。发布版本默认使用 2 次循环,以平衡效率和性能。

完整摘要

本文分析了 SenseNova-Loop-9B:这款在 Hugging Face 发布、拥有 9.66B 参数的语言模型采用了新颖的循环架构,每次前向传播时,32 层中的 24 层会执行两次,因此总计执行 56 次层计算,推理计算量约相当于 14.6B 参数模型。该模型仅使用 8 个全注意力层,而稠密模型通常使用 32 个,因此大幅降低了 KV cache 的内存需求;在 256K 上下文长度和 BF16 精度下,内存占用为 8.6-15GB。其架构采用带 Sinkhorn 归一化的双流流形约束超连接(mHC),在多个基准测试中表现出色,可与 Qwen3.8-27B 等 27B 模型竞争,并在 AutomationBench、Terminal-Bench 和 GAIA 上取得提升。文章还详细分析了内存需求的数学计算,并展示了循环扩展(1-4 次)能使多项任务的性能提升 6-17%。

目录 · 11 节

查看原文

太长不看TL;DR

  • SenseNova-Loop-9B 于 2026 年 11 月 17 日在 Hugging Face 上以 Apache 2.0 许可证发布。它存储了约 96.6 亿个参数,但每次前向传播会从仅有的 32 个不同层中执行 56 个解码器层;模型卡称,这相当于推理时约 146 亿个参数。
    SenseNova-Loop-9B was released on Hugging Face on November 17, 2026 under Apache 2.0. It stores about 9.66B parameters, but it executes 56 decoder layers per forward pass from only 32 distinct layers, which the card says is about 14.6B inference-equivalent parameters.
  • 循环在权重方面开销较低,但计算并非免费。每个 token 的计算量大约是存储规模所暗示的 1.5 倍,因此,针对不同的问题,“9B”和“14.6B”都是准确的数字。
    The loop is cheap in weights and not free in compute. Per token you do roughly 1.5 times the work the stored size suggests, so "9B" and "14.6B" are both honest numbers for different questions.
  • 32 层中只有 8 层使用全注意力。其余 24 层是具有固定大小状态的线性注意力层。这就是为什么模型卡在 256K 上下文、4 位权重和 8 位缓存的配置下,标注的 GPU 内存约为 15 GiB。我的计算结果是,256K 上下文下,BF16 缓存需要 8.6 至 15.0 GB;如果 32 层全部采用全注意力,则需要 34.4 GB。
    Only 8 of the 32 layers use full attention. The other 24 are linear-attention layers with a fixed-size state. That is why the card quotes about 15 GiB of GPU memory at a 256K context with 4-bit weights and an 8-bit cache. My arithmetic puts the BF16 cache at 8.6 to 15.0 GB at 256K, versus 34.4 GB if all 32 layers were full attention.
  • 基准测试表中的数据由厂商报告。该版本在展示的全部七个项目上均优于 Preview;与 Qwen3.8-27B 相比,它在两个项目上持平或领先,而在 NL2Repo 上落后,得分为 41.36,对方为 44.60。
    The benchmark table is vendor-reported. The release improves on the Preview on all seven rows shown, and against Qwen3.8-27B it matches or leads on two rows and trails on NL2Repo, 41.36 against 44.60.

KV cache at 256K tokens

SenseNova 发布了什么? What did SenseNova release?

仓库 sensenova/SenseNova-Loop-9B 于 2026 年 11 月 17 日创建。预览版 SenseNova-Loop-9B-Preview 于 10 月 31 日发布。该版本新增了 AWQ 和 GGUF 构建版本,模型卡于 11 月 18 日宣布了这一点。以下是我能直接核实的事实:The repository sensenova/SenseNova-Loop-9B was created on November 17, 2026. A Preview, SenseNova-Loop-9B-Preview, came out on October 31. The release adds AWQ and GGUF builds, which the card announced on November 18. The facts I could check directly:

  • 元数据和卡片中均采用 Apache 2.0 许可证。
    License: Apache 2.0 in both the metadata and the card.
  • 权重:Hugging Face API 报告称,模型包含 9,653,102,832 个 BF16 参数和 3,151,744 个 FP32 参数(mHC 路由参数),总计 9,656,254,576 个参数。磁盘上的 safetensors 分片总计 19.32 GB,其中包括一个单独的 0.49 GB 文件,用于多 token 预测草稿头。
    Weights: the Hugging Face API reports 9,653,102,832 BF16 parameters plus 3,151,744 FP32 ones (the mHC routing parameters), 9,656,254,576 in total. The safetensors shards on disk add up to 19.32 GB, which includes a separate 0.49 GB file for the multi-token-prediction draft head.
  • 输入和输出:输入文本和图像,输出文本,检查点中包含视觉塔。模型卡片给出的上下文长度最高可达 512K 个 token。我能查阅到的 Preview 配置列出的 max_position_embeddings 为 262,144,因此下面同时展示 256K 和 512K。
    Inputs and outputs: text and images in, text out, with a vision tower in the checkpoint. The card gives a context length of up to 512K tokens. The Preview config I could read lists max_position_embeddings of 262,144, so I show both 256K and 512K below.
  • 架构类:SenseNovaLoopForConditionalGeneration,使用 trust_remote_code=True 加载。文本骨干网络由 Qwen3.5 风格的混合模块构成,这与 Preview 配置中的 qwen3_5_text 模型类型一致。
    Architecture class: SenseNovaLoopForConditionalGeneration, loaded with trust_remote_code=True. The text backbone is built from Qwen3.5-style hybrid blocks, per the qwen3_5_text model type in the Preview config.

该卡片列出的预览环境为 Transformers 5.18.0、PyTorch 2.11.0 和 CUDA 13.0,并说明发布版引擎的版本将随模型一并更新。对于 SGLang,卡片指向一个尚未合并的拉取请求,因此目前预计需要运行开发分支。The card lists the Preview environment as Transformers 5.18.0, PyTorch 2.11.0 and CUDA 13.0, and says the release engine versions will be updated with the model. For SGLang it points to an open pull request, so expect to run a development branch for now.

模型如何用 32 层实现 56 次层执行? How does a model get 56 layer executions from 32 layers?

解码器有 32 个不同的层。第 0 至第 3 层运行一次。第 4 至第 27 层共 24 层,使用共享权重连续运行两次。第 28 至第 31 层以及输出头各运行一次。计算很简单:The decoder has 32 distinct layers. Layers 0 to 3 run once. Layers 4 to 27, a block of 24, run twice in a row with shared weights. Layers 28 to 31 and the output head run once. The arithmetic is simple:

distinct = 32
looped = 24          # layers 4..27
passes = 2
executions = (distinct - looped) + looped * passes
print(executions)    # 56
Enter fullscreen mode Exit fullscreen mode

如果 B 是循环块,h 是其输入,那么循环计算就是 B(B(h))。该卡片的循环范围字段为 [4, 28),循环 2 次;Preview 配置中的 loop_settings 也包含相同的值。If B is the looped block and h its input, the looped computation is B(B(h)). The card's loop-range field is [4, 28) with 2 passes, and the Preview config carries the same values under loop_settings.

这解释了卡片上的两个参数量数字。约 9B 是你实际存储的参数量。约 14.6B 是在非循环模型中,要实现每个 token 相同的计算量所需的参数量。卡片上的 14.6B 介于 9.66B 和 2 倍的 9.66B 之间;如果只有中间的一部分重复,而嵌入层不重复,这正是预期结果。That explains the two parameter figures on the card. About 9B is what you store. About 14.6B is what you would need in a non-looped model to spend the same compute per token. The card's 14.6B sits between 9.66B and 2 times 9.66B, which is what you expect when only a middle slice repeats and the embeddings do not.

关键在于横向比较表格中的各项指标。一个标称 9B、采用循环结构的模型,在每个 token 的处理速度上更接近 14.6B 稠密模型,而在下载大小和权重内存占用上则更接近 9B 模型。单看任一数字都无法说明成本。The important comparison is what you read across a table. A model quoted as 9B that loops is closer to a 14.6B dense model in speed per token, and closer to a 9B model in download size and in weight memory. Neither number alone tells you the cost.

什么是 mHC 流?它们会给部署带来哪些变化? What are the mHC streams, and what do they change for deployment?

此次发布将该循环结构与双流流形约束超连接相结合,在卡片上写作 mHC。循环块不再只有一个残差流,而是携带两个残差流。通过学习得到的映射决定每一层如何从这些流中读取、在两者之间混合,并写回。混合映射受到 Sinkhorn 归一化的约束,该方法交替进行行归一化和列归一化,配置中使用了 20 次迭代。The release pairs the loop with two-stream manifold-constrained hyper-connections, written mHC on the card. Instead of one residual stream, the looped block carries two. Learned mappings decide how each layer reads from the streams, mixes between them and writes back. The mixing map is constrained with Sinkhorn normalization, which alternates row and column normalization, and the configuration uses 20 iterations.

对于任何部署它的人来说,有两点很重要。第一,20 次 Sinkhorn 迭代是每个 mHC 步骤内部的操作,与两次通过该模块的计算是分开的,这一点很容易混淆。第二,路由参数以 FP32 存储,而骨干网络采用 BF16;卡片说明,兼容的推理实现必须加载这些参数,并保持相同的计算顺序。这就是通用运行时无法原样加载该模型的原因,也解释了为什么卡片附带了自定义代码,并指向特定的引擎构建版本。Two details matter for anyone deploying it. First, the 20 Sinkhorn iterations are internal to each mHC step and are separate from the two passes through the block, which is easy to confuse. Second, the routing parameters are stored in FP32 while the backbone is BF16, and the card says a compatible inference implementation must load them and keep the same computation order. That is why a generic runtime cannot load the model unmodified, and why the card ships custom code and points to specific engine builds.

长上下文究竟需要多少内存? How much memory does long context really need?

这正是这种架构发挥优势的地方。在 Preview 配置中,full_attention_interval 为 4,layer_types 则每三层 linear_attention 层交替一层 full_attention 层。32 层中共有 8 个 full-attention 层,索引分别为 3、7、11、15、19、23、27 和 31。其中 6 个位于循环范围内,另外 2 个位于循环范围外。This is where the architecture pays off. In the Preview config, full_attention_interval is 4 and layer_types alternates three linear_attention layers with one full_attention layer. Across 32 layers that gives 8 full-attention layers, at indices 3, 7, 11, 15, 19, 23, 27 and 31. Six of them sit inside the looped range and two outside it.

只有全注意力层的 KV 缓存会随着上下文长度增长。线性注意力层则保留固定大小的循环状态。配置中给出的 KV 头数为 4,头维度为 256,因此在一个全注意力层中,一个 token 会存储:Only full-attention layers grow a KV cache with context length. The linear-attention layers keep a fixed-size recurrent state. The config gives 4 KV heads and a head dimension of 256, so one token in one full-attention layer stores:

kv_heads, head_dim, bytes_el = 4, 256, 2          # BF16 cache
per_token_per_layer = 2 * kv_heads * head_dim * bytes_el   # 4096 bytes

def kv_gb(full_layer_executions, ctx):
    return full_layer_executions * per_token_per_layer * ctx / 1e9

# Case A: each physical full-attention layer keeps one cache, shared by both passes = 8
# Case B: a separate cache per pass: 2 outside the loop + 6 inside x 2 passes = 14
# Baseline: all 32 layers full attention
for ctx in (65_536, 131_072, 262_144, 524_288):
    print(ctx, kv_gb(32, ctx), kv_gb(14, ctx), kv_gb(8, ctx))
Enter fullscreen mode Exit fullscreen mode
Context All 32 full 14 executions (per-pass) 8 layers (shared)
64K 8.6 GB 3.8 GB 2.2 GB
128K 17.2 GB 7.5 GB 4.3 GB
256K 34.4 GB 15.0 GB 8.6 GB
512K 68.7 GB 30.1 GB 17.2 GB

我不知道给定的运行时实现的是哪种情况。由于第二轮看到的隐藏状态与第一轮不同,自然的理解是每轮使用单独的缓存,但引擎也可能共享或压缩这些缓存。请将这两列视为根据我的计算得出的上下界,而非测量结果。相比之下,线性注意力的状态很小:若有 32 个值头,每个头的维度为 128 × 128,且使用 FP32,那么每个序列的单层状态约为 2.1 MB,因此 24 个这样的层约为 50 MB。I do not know which case a given runtime implements. Because the second pass sees different hidden states from the first, separate per-pass caches are the natural reading, but an engine could share or compress them. Treat the two columns as bounds from my arithmetic, not measurements. The linear-attention state is tiny by comparison: with 32 value heads of 128 by 128 in FP32, one layer holds about 2.1 MB per sequence, so 24 such layers are about 50 MB.

现在将其与该卡的部署表进行比较,该表假设 4 位权重约为 4.9 GB:Now compare with the card's deployment table, which assumes 4-bit weights of about 4.9 GB:

Context 8-bit KV cache 4-bit KV cache
64K about 10 GiB about 9 GiB
128K about 12 GiB about 10 GiB
256K about 15 GiB about 12 GiB

在 256K、使用 8 位缓存时,我估算的缓存容量范围是 4 到 7 GiB。加上 4.6 GiB 的权重后,总计为 8.6 到 11.6 GiB。显卡标称约 15 GiB,差额很可能来自视觉塔、草稿头、激活值和运行时开销,而这些都没有计入我的计算。256K 时,8 位和 4 位两列相差 3 GiB,这意味着 8 位缓存接近 6 GiB,落在我估算的两个边界之间。数值都四舍五入到了整 GiB,所以我不会对此作更多解读。At 256K with an 8-bit cache, my bounds give 4 to 7 GiB for the cache. Add 4.6 GiB of weights and you reach 8.6 to 11.6 GiB. The card says about 15 GiB, and the gap is plausibly the vision tower, the draft head, activations and runtime overhead, which my arithmetic leaves out. The difference between the 8-bit and 4-bit columns, 3 GiB at 256K, points to an 8-bit cache near 6 GiB, which falls between my two bounds. The figures are rounded to whole GiB, so I would not read more into it than that.

实际来看:一个 9B 模型在采用量化权重和量化缓存的情况下,256K 窗口大约需要 16 GB。使用 BF16 时,仅权重就约为 18 GiB,因此对于短上下文下未量化的检查点,24 GB 显卡是比较合理的最低配置。The practical reading: a 9B model with a 256K window fits in roughly 16 GB only with quantized weights and a quantized cache. In BF16 the weights alone are about 18 GiB, so a 24 GB card is the sensible floor for the unquantized checkpoint at short context.

基准测试结果表明了什么? What do the benchmarks show?

以下所有数字均来自供应商的卡片。我没有复现这些数字。与 Preview 的对比:All numbers below are from the vendor's card. I have not reproduced them. The comparison against the Preview:

Preview vs release

卡片显示,该版本在所列的七项基准测试中均优于 Preview。AutomationBench 从 14.33 提升至 36.67,Terminal-Bench 2.1 从 40.45 提升至 59.55,GAIA 从 37.86 提升至 69.90。作为文本转 SQL 基准测试,BIRD 从 71.38 提升至 72.34。与卡片列出的最接近的竞争对手 Qwen3.8-27B 相比:The card says the release beats the Preview on all seven benchmarks shown. AutomationBench rises from 14.33 to 36.67, Terminal-Bench 2.1 from 40.45 to 59.55 and GAIA from 37.86 to 69.90. BIRD, a text-to-SQL benchmark, moves from 71.38 to 72.34. Against the closest rival the card names, Qwen3.8-27B:

Benchmark SenseNova-Loop-9B Qwen3.8-27B
AutomationBench 36.67 36.67
AIDABench 65.31 65.01
NL2Repo 41.36 44.60

在仓库生成任务上,两者打平、微弱领先,另有3.24分的差距。一款约有90亿参数的模型,在智能体和数据分析项目上的成绩与一款270亿参数的稠密模型相差仅几分,而4位量化后体积为4.9 GB。对于本地智能体而言,这是个不错的取舍,前提是你的工作负载与这些基准测试相似。A tie, a narrow lead and a gap of 3.24 points on a repository-generation task. A model storing about 9B parameters lands within a few points of a 27B dense model on agent and data-analysis rows, at 4.9 GB in 4-bit. That is a useful trade for a local agent, as long as your workload resembles those benchmarks.

多循环几次会有帮助吗? Does more looping help?

该卡片包含一项循环扩展研究。作者以使用 9B 模型进行单次循环为基线,在训练数据和其他设置保持不变的情况下调整循环次数。四项任务的结果均有所提升,并在循环三次或四次时取得最佳成绩。The card includes a loop-scaling study. Using the 9B model with a single pass as the baseline, the authors vary the loop count with training data and other settings fixed. Results improve across four tasks, with the best scores at three or four loops.

Loop scaling

AIDABench-QA 和 Workbuddy-office 在三轮时达到峰值,相较于单轮分别提升了 6.42% 和 16.93%。LiveCodeBench V6 和 AIDABench 数据可视化在四轮时达到峰值,分别提升了 8.10% 和 8.55%。从两轮增加到四轮,LiveCodeBench V6 提升了 1.04 个百分点,数据可视化提升了 1.35 个百分点。为平衡推理效率,发布版本默认采用两轮。研究涵盖一至四轮,作者表示,更深层次和动态调整循环次数将是未来的研究方向。AIDABench-QA and Workbuddy-office peak at three loops, improving by 6.42 percent and 16.93 percent relative to one pass. LiveCodeBench V6 and AIDABench data visualization peak at four loops, improving by 8.10 and 8.55 percent. Moving from two to four loops adds 1.04 points on LiveCodeBench V6 and 1.35 on data visualization. The release defaults to two loops to balance inference efficiency. The study covers one to four loops, and the authors say deeper and dynamic loop counts are future work.

在部署时,这是一个需要权衡成本的参数。按我对 KV 的估算,在每轮独立计算的情况下,每多一轮就可能增加 6 次完整注意力执行,因此四轮配置对缓存的压力会远高于默认的两轮配置,除非运行时会在不同轮次之间共享缓存。不要想当然地认为上面的内存表也适用于这种情况;请先检查运行时的行为。For deployment this is a knob with a price. By my KV arithmetic, every extra pass could add 6 full-attention executions in the per-pass case, so a four-loop setup would have far more cache pressure than the two-loop default, unless the runtime shares caches across passes. Check the runtime's behavior before assuming the memory table above carries over.

我该如何运行它? How do I run it?

该卡片中的 Transformers 示例通过自定义代码在一张 GPU 上以 BF16 加载模型:The card's Transformers example loads the model in BF16 on one GPU with custom code:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "sensenova/SenseNova-Loop-9B"
tok = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id, trust_remote_code=True, dtype=torch.bfloat16, device_map={"": "cuda:0"}
).eval()

msgs = [{"role": "user", "content": "What is 13 times 7?"}]
prompt = tok.apply_chat_template(msgs, tokenize=False,
                                 add_generation_prompt=True, enable_thinking=True)
inputs = tok(prompt, return_tensors="pt").to("cuda:0")
out = model.generate(**inputs, max_new_tokens=512, do_sample=False, use_cache=True)
print(tok.decode(out[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))
Enter fullscreen mode Exit fullscreen mode

由于 trust_remote_code=True 会执行仓库中的 Python 代码,因此在任何重要环境中运行之前,请先阅读 modeling_sensenova_loop.py 并固定一个版本。模型卡片还列出了 LightLLM 和 SGLang 的使用路径,以及 AWQ 4-bit 和采用 BF16、Q8_0、Q5_K_M、Q4_K_M 格式的 GGUF 文件。Because trust_remote_code=True executes the repository's Python, read modeling_sensenova_loop.py and pin a revision before running it anywhere that matters. The card also lists LightLLM and SGLang paths, plus AWQ 4-bit and GGUF files in BF16, Q8_0, Q5_K_M and Q4_K_M.

这篇发布说明对小型模型有什么说法? What does this release say about small models?

有三点值得关注。第一,同一周内,循环架构已在不止一个开放模型系列中发布,因此表格需要分别呈现“已存储参数”和“每个 token 的计算量”,因为这是两个不同的维度。第二,混合注意力对内存占用的影响,远大于参数量:32 层中有 24 层采用固定大小状态,因此长上下文问题涉及的是 8 层,而非 32 层。第三,厂商评测的不仅是问答,还包括智能体运行框架和数据分析任务,这与人们在本地实际运行的任务相符。Three things stand out. First, looping is now shipping in more than one open family within the same week, so "parameters stored" and "compute per token" are separate axes that tables need to show. Second, hybrid attention changes the memory story more than the parameter count does: with 24 of 32 layers using fixed-size state, long context is an 8-layer problem, not a 32-layer one. Third, vendors are measuring agent harnesses and data-analysis tasks, not only question answering, which matches what people run locally.

如果你在估算硬件配置,先根据上下文目标和缓存精度进行估算,然后再加上权重。如果你在比较模型,请并列比较存储大小、执行次数和缓存层数。If you are sizing hardware, start from your context target and your cache precision, then add weights. If you are comparing models, put stored size, execution count and cache layers side by side.

常见问题 FAQ

SenseNova-Loop-9B 是什么?它是一款开放权重的多模态解码器,存储参数约为 9.66B,通过将一个包含 24 层的模块重复使用两次,实现了 56 次层执行,而不同层共 32 层。它采用 Apache 2.0 许可证发布。What is SenseNova-Loop-9B?
An open-weights multimodal decoder with about 9.66B stored parameters that reuses a block of 24 layers twice, giving 56 layer executions from 32 distinct layers. It is released under Apache 2.0.

14.6B 推理等效是什么意思?这是该显卡估算出的稠密模型规模,表示它的每 token 计算量与循环模型相当。存储占用和权重内存仍接近 9B。What does 14.6B inference-equivalent mean?
It is the card's estimate of the dense model size that would match the per-token compute of the looped model. Storage and weight memory stay near 9B.

在 256K 个 token 时需要多少 KV 缓存?根据我按 Preview 配置的计算结果,BF16 格式下需要 8.6 GB 到 15.0 GB,具体取决于运行时是为每个物理全注意力层保留一份缓存,还是每次 pass 保留一份。若是一个采用相同注意力头配置的 32 层全注意力模型,则需要 34.4 GB。How much KV cache does it need at 256K tokens?
By my arithmetic from the Preview config, between 8.6 GB and 15.0 GB in BF16, depending on whether a runtime keeps one cache per physical full-attention layer or one per pass. An all-full-attention 32-layer model with the same heads would need 34.4 GB.

它能在 16 GB 显存的 GPU 上运行吗?模型卡估算,在 256K 上下文长度下,使用 4 位权重和 8 位缓存约需 15 GiB;使用 4 位缓存则约需 12 GiB。上下文越短,所需显存越少。Can it run on a 16 GB GPU?
The card estimates about 15 GiB at 256K with 4-bit weights and an 8-bit cache, and about 12 GiB with a 4-bit cache. Shorter contexts need less.

基准测试分数是否独立?不是。它们来自供应商提供的显卡。依赖这些分数之前,请先复现与你的工作负载相关的测试项目。Are the benchmark scores independent?
No. They come from the vendor's card. Reproduce the rows that matter to your workload before relying on them.

链接 Links

延伸阅读 Further reading

值得记下

  1. 存储的参数量约为 9B。若不采用循环架构,要在每个 token 上投入相同的计算量,模型就需要约 14.6B 参数。
  2. 一个标称为 9B、采用循环架构的模型,每个 token 的运行速度更接近 14.6B 稠密模型,而下载大小和权重内存占用则更接近 9B 模型。
  3. 只有全注意力层的 KV cache 会随上下文长度增长。线性注意力层则保持固定大小的循环状态。
  4. 实际来看:一个具有 256K 窗口的 9B 模型,只有在权重量化且 cache 也经过量化时,才能装进约 16 GB 的内存。
  5. 一个存储约 9B 参数的模型,在智能体和数据分析相关指标上与 27B 稠密模型的得分差距只有几个百分点,而其 4-bit 量化版本仅占用 4.9 GB。

← 回到本期 · 第 12 条