zyw-PC(192.168.31.31),RTX 5060 Ti 16GB,i5-12600HX,64GB DDR4# GPU 机,llama.cpp 主干(2026-11-23 master)
export LD_LIBRARY_PATH=LD_LIBRARY_PATH
cd ~/llama.cpp-master
./build/bin/llama-server \
-m ~/models/inkling-2-mini-uncensored/Inkling-2-Mini-Uncensored-AD-IQ3_S.gguf \
--mmproj ~/models/inkling-2-mini-uncensored/mmproj-Inkling-2-Mini-Uncensored-F16.gguf \
--ctx-size 65536 \
-ctk q4_0 -ctv q4_0 -fa on \
-ncmoe 8 -ngl 99 -ub 256 -b 256 \
--jinja --host 0.0.0.0 --port 8081 -t 8
启动脚本已放在 GPU 机:~/run-inkling-gguf.sh [ctx] [ncmoe]、~/ub.sh CTX NCMOE UB、~/one.sh CTX NCMOE、~/sweep.sh、~/ctxsweep.sh
| ctx | ncmoe | ub | 显存占用 | 解码 tok/s | 备注 |
|---|---|---|---|---|---|
| 32768 | 2 | 512 默认 | 15443 MiB | 47.54 | 32K 最快档,极限压显存 |
| 32768 | 4 | 512 | 14521 MiB | 42.23 | |
| 32768 | 6 | 512 | 13599 MiB | 38.44 | |
| 32768 | 8 | 512 | 13599 MiB | 29.51 | |
| 32768 | 10 | 512 | — | 23.48 | |
| 32768 | 12 | 512 | — | 19.66 | |
| 32768 | 0 | — | — | OOM | 全专家上卡不可能(需再 3.36 GB) |
| 65536 | 8 | 256 | 13853 MiB | 29.53 | |
| 65536 | 12 | 256 | 13851 MiB | 19.89 | |
| 131072 | 20 | 128 | 13497 MiB | 12.72 | |
| 262144 | 20 | 64 | 14641 MiB | 12.61 | 实测最长可用档 |
| 262144 | 24 | 128 | — | 失败 | compute buffer 需 12058 MiB |
| 524288 | — | — | — | 未测通 | 按线性推算需 ~56 GB |
| 1048576 | — | — | — | 不可能 | compute buffer 申请 107132 MiB |
推理实测样例(32K / ncmoe 8):700 token 输出,693 字中文散文正文 + 676 字思考链,24.08 秒,29.51 tok/s,HTTP 200。
先前判断错误。曾按 8 个 global visit × 8 KV heads × 128 dim × K+V 算出 FP16 KV = 32 KB/token、q4_0 = 9.2 KB/token,据此认为「省 KV 就能救 1M」。实测否定了这个推算:
| ctx | llama.cpp 报的分配量 | 折算 B/token |
|---|---|---|
| 131072 | 12900 MiB | ~103 KB |
| 262144 | 28336 MiB | ~113 KB |
| 524288 | 55984 MiB | ~112 KB |
| 1048576 | 107132 MiB | ~107 KB |
换算下来是每 token 约 104–113 KB,是我算的 q4_0 KV 值的 11 倍,且随 ctx 近似线性。这说明被卡住的是 llama.cpp 为 prefill 预分配的 compute buffer(中间张量),不是 KV cache。
-ub(micro-batch)| 同一配置 | ub 128 | ub 64 |
|---|---|---|
| 262K + ncmoe 20 | 失败(compute >12.6 GB) | 成功 14641 MiB |
降 -ub 把 compute buffer 压下来,代价是 prefill 分更多块、长 prompt 预填充变慢。这是 16 GB 卡能吃下 262K 的唯一方法。
Inkling 2 Mini 是 looped transformer:24 物理层,中间 12 层跑 3 遍 = 48 次层应用。vLLM 文档写明:
"every core layer has a KV cache and a conv-state cache per pass (48 of each in total)"
即 48 套独立 KV cache。同时 24 层里是 20 层 sliding-window(1024) + 4 层 full attention,混合注意力让 prefill 的中间张量进一步膨胀。llama.cpp 也确认记录了两个 arch:LLM_ARCH_INKLING2 与 LLM_ARCH_INKLING2_LOOP。
对比 vLLM 侧的门槛(官方 recipe 原文):
验证平台只有 GB200 / B300 / GB300 / H100 / H200 / DGX Spark;"On H100 and DGX Spark, the recipe caps the context at 262,144 tokens to fit in memory."
H100 80GB 都只能开 262K。单卡 TP1 才能跑满 1M,GB200 上只够约 1.8 个并发 1M 请求。消费级 16 GB 不在支持范围。
undefined reference to cudaMalloc@libcudart.so.13。CUDA 装在 ~/cuda-13.0 且系统没有 ldconfig。修法:
export PATH=PATH
export LIBRARY_PATH=LIBRARY_PATH
cmake -B build -G Ninja -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=120 \
-DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=OFF \
-DCMAKE_EXE_LINKER_FLAGS="-LHOME/cuda-13.0/lib64" \
-DCMAKE_SHARED_LINKER_FLAGS="-LHOME/cuda-13.0/lib64"UI: no assets available - building without an embedded UI,只影响浏览器界面,API 正常。pkill 后至少等 10-15 秒再起下一个实例,否则误判 OOM。stdbuf -oL -eL,或直接看 allocating N MiB 的错误行反推。-ncmoe 的语义:--n-cpu-moe N 是把前 N 层的专家权重放 CPU,不是"第 N 层"。配合日志警告 tensor overrides to CPU are used with mmap enabled 确认生效。reasoning_effort 是 0.9,300 token 会全被 reasoning 吃掉、content 为空。要正文必须给 max_tokens ≥ 800。| 方案 | 32K 解码 | 262K 解码 | 备注 |
|---|---|---|---|
| llama.cpp + AtomicChat IQ3_S | 47.54(ncmoe 2) | 12.61(ncmoe 20 / ub 64) | 本次实测 |
| Strata SQ-15(官方包) | 88.0(官方数据) | 不支持(16GB 卡溢出 60%) | 带 DSpark 推测解码 |
| Strata SQ-20(官方包) | 54.2 hybrid(同卡实测数据) | — | 100% 质量 |
llama.cpp 速度低于 Strata SQ-15 的主要原因:没有 DSpark 草稿头。AtomicChat 仓库不含 DSpark;Unsloth 仓库里有 dspark-Inkling-2-Mini-Q8_0.gguf(给原版权重训的,abliterated 上未验证)。
GPU 机:
~/models/inkling-2-mini-uncensored/Inkling-2-Mini-Uncensored-AD-IQ3_S.gguf(13,340,510,176 B)+ mmproj-Inkling-2-Mini-Uncensored-F16.gguf(639,348,448 B)~/llama.cpp-master/build/bin/llama-server~/run-inkling-gguf.sh、~/ub.sh、~/one.sh、~/sweep.sh、~/ctxsweep.sh、~/bench_inkling.sh~/sw_*.log、~/ub_*.log、~/one_*.log、~/inkling_srv.log、~/llama_build2.logDSH 机(模型副本已 scp 至 GPU 机,本地保留):
~/Downloads/xunlei-downloads/Inkling-2-Mini-Uncensored-AD-IQ3_S.gguf~/Downloads/xunlei-downloads/mmproj-Inkling-2-Mini-Uncensored-F16.gguf待恢复:Strata SQ-15 与 strata-inkling 引擎的下载已在 22:56 暂停(VP72bx00ohmo0zZl601IuL6PA1 停在 1.15 GB、VP72by4sjkFHw9FAaTF9-dvWA1 停在 0.22 GB),需要时可重新 add。
用 13,528 token 的中文长 prompt(900 段重复散文 + 单句提问)实测:
| 指标 | 值 |
|---|---|
| prompt_n | 13,528 |
| prefill 速度 | 365.9 tok/s(整段约 37 秒) |
| 该次 decode | 26.82 tok/s |
| 端到端墙钟 | 42.5 秒(含 150 token 输出) |
含义:塞 1.4 万 token 的文档要等 37 秒预填充。64K 满打满算约 180 秒(3 分钟)才开始出字。这是降低 -ub 的代价——ub 越小,prefill 分块越多、越慢。用于长文档问答可以接受,用于交互式对话偏慢。
# GPU 机 :8081,2026-11-23 01:44 起
ctx=65536 ncmoe=8 ub=256
显存 14563 MiB / 16311 MiB
decode ~29.5 tok/s,prefill ~366 tok/s
OpenAI 兼容:http://192.168.31.31:8081/v1
模型名:inkling
一键重启:bash ~/up.sh
⚠️ ComfyUI(:8189)已被停掉腾显存,恢复用 GPU 机 bash ~/start_comfy_C_64g.sh。
单元:/etc/systemd/system/inkling.service(已 enable 开机自启)
[Unit]
Description=llama.cpp llama-server - Inkling 2 Mini (Uncensored IQ3_S, 64K)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=zyw
WorkingDirectory=/home/zyw/llama.cpp-master
Environment=LD_LIBRARY_PATH=/home/zyw/cuda-13.0/lib64
Environment=CUDA_VISIBLE_DEVICES=0
ExecStart=/home/zyw/llama.cpp-master/build/bin/llama-server \
-m /home/zyw/models/inkling-2-mini-uncensored/Inkling-2-Mini-Uncensored-AD-IQ3_S.gguf \
--mmproj /home/zyw/models/inkling-2-mini-uncensored/mmproj-Inkling-2-Mini-Uncensored-F16.gguf \
--ctx-size 65536 -ctk q4_0 -ctv q4_0 -fa on \
-ncmoe 8 -ngl 99 -ub 256 -b 256 --jinja \
--alias inkling --host 0.0.0.0 --port 8081 -t 8
Restart=on-failure
RestartSec=15
TimeoutStartSec=300
StandardOutput=append:/home/zyw/inkling_systemd.log
StandardError=append:/home/zyw/inkling_systemd.log
[Install]
WantedBy=multi-user.target
GPU 机 ~/inklingctl.sh:
| 命令 | 作用 |
|---|---|
inklingctl.sh start | 停 ComfyUI → 启 Inkling,轮询到 health ok |
inklingctl.sh stop / restart | 启停 |
inklingctl.sh status | 服务状态 + health + 显存 + 端口占用 |
inklingctl.sh log [n] | 看 systemd 日志尾 |
inklingctl.sh ink | 切到 Inkling 模式(停 ComfyUI) |
inklingctl.sh comfy | 切回 ComfyUI(停 Inkling,跑 start_comfy_C_64g.sh) |
inklingctl.sh free | 两个都停,释放显存 |
| 项目 | 结果 |
|---|---|
systemd is-enabled / is-active | enabled / active |
/health | {"status":"ok"} |
/v1/models 模型 ID | inkling(--alias 生效) |
| 显存占用 | 14,696 MiB / 16,311 MiB |
| 端口 | 0.0.0.0:8081 |
| 从 DSH 机(192.168.31.76)跨机调用 | HTTP 200,2.7 秒 |
| 中文文本推理 | 1+1 → 2,29.41 tok/s |
| 视觉输入(base64 PNG) | 可用:准确描述「一只手正推开磨砂玻璃门,门后模糊地站着一位穿蓝色浴巾的女子」,6.6 秒,29.77 tok/s |
5060 Ti 16GB 只能容纳一个 14.7 GB 级服务。ComfyUI 空闲时仅占 151 MiB,可与 Inkling 共存;但 ComfyUI 一跑生成就会 OOM。用 inklingctl.sh ink / comfy 切换,不要两个同时干活。
~/.dsh/profiles/web/cordis.patch.yml 的 providers 下追加:
inkling:
displayName: Inkling 2 Mini (本地 · 无审查 · 64K)
api: openai-completions
baseURL: http://192.168.31.31:8081/v1
apiKeyEnv: LOCAL_LLM_API_KEY
streamIdleTimeoutMs: 600000
models:
- id: inkling
name: Inkling-2-Mini-Uncensored IQ3_S @31
contextWindow: 65536
maxTokens: 8192
input:
- text
- image
reasoningEfforts: false
compat:
maxTokensField: max_tokens
注意:DSH 侧 maxTokens 别给太小——该模型默认思考链很长(reasoning_effort 0.9),300 token 会被 reasoning 吃满导致正文为空,建议 ≥ 2048。
尝试用 Unsloth 的 dspark-Inkling-2-Mini-Q8_0.gguf(402,278,560 B,sha256 2ec78510da837e8fc3be54a14757a0c5fbd2d8d9e85a0d92853fafdf674f3773)启用推测解码,两个硬性不兼容,已放弃:
E llama_model_load: error loading model: check_tensor_dims:
tensor 'markov_w1.weight' has wrong shape; expected 256, 200058, got 256, 201024, 1, 1
src/models/dspark.cpp:82-85:
const int64_t dspark_markov_rank = ml->get_tensor_meta("markov_w1.weight")->ne[0];
dspark_markov_w1 = create_tensor(..., { dspark_markov_rank, n_vocab }, 0);
dspark_markov_w2 = create_tensor(..., { dspark_markov_rank, n_vocab_draft }, 0);
n_vocab 取目标模型词表长度。三个 GGUF 实测:
| 文件 | arch | tokenizer 长度 | markov_w1 实际列数 |
|---|---|---|---|
| AtomicChat IQ3_S | inkling2_loop | 200,058 | — |
| unsloth UD-IQ2_XXS | inkling2 | 200,058 | — |
| unsloth dspark Q8_0 | dflash | 200,058 | 201,024 |
dspark 按原版 config.json 的 vocab_size(含 padding)转换,所有 GGUF 词表却是 200,058。换任何主模型都撞同一个错,与 abliterated 无关。
inkling2_loopunslothai/llama.cpp b12588-cuda13-newer(~/unsloth-llama/):
E llama_model_load: error loading model: unknown model architecture: 'inkling2_loop'
draft-dspark,不认识 inkling2_loopinkling2_loop,dspark 词表校验失败官方配套只覆盖 inkling2 标签的 GGUF,abliterated 版本用的是 inkling2_loop,两边各缺一块。
| spec-type | decode tok/s |
|---|---|
| none(基线) | 29.53 |
| ngram-simple | 29.39 |
| ngram-cache | 22.07 |
散文类创意文本重复率低,n-gram 投机解码没有提升空间。
markov_w1 从 201,024 列裁到 200,058(多出的 966 列是 padding 权重,理论上裁剪无害),或反向给主模型词表补 paddingn_vocab 取 max(tokenizer 长度, 张量实际列数)用户报 {got exception: Unexpected empty grammar stack after accepting piece: ? (30)} 后,去 llama.cpp 仓库查了社区反馈,发现我们之前的 -ncmoe 配置有严重缺陷,已修正。
--n-cpu-moe 会让长 prompt 输出垃圾(issue #32755)标题:inkling2_loop: garbage output when loop-layer experts run on CPU (--n-cpu-moe) with long prompts; correct with --override-tensor offloading only non-loop layers
原报告(gfx1030 / RX 6800,但结论与后端无关):
With
--n-cpu-moe N(CPU-offloaded experts), generation oninkling2_loopmodels degrades to repetitive garbage ("GGGG...", parroting) once the prompt is long enough (~4-6K tokens). The failure correlates strictly with CPU-offloading experts of the loop layers (blocks 6-17).
关键细节(正中我们的配置):
--n-cpu-moe Noffloads the first N layers; at N=8 that covers blocks 0-7, i.e. the loop layers 6 and 7 — consistent with "any CPU-offloaded expert in the loop range corrupts output above a prompt-length threshold".
我们的原配置正是 -ncmoe 8,而 Inkling 的循环层是 blocks 6-17(24 层里的中间 12 层,跑 3 遍)。
| 卸载方式 | 落在循环层? | 长 prompt |
|---|---|---|
--n-cpu-moe 24(全层) | 是 | 硬垃圾 "GGGG..."×1500 |
--n-cpu-moe 8 | 是(含 6、7) | 复读/鹦鹉学舌(4-6K 起) |
-ot 只卸 0-5、18-23 | 否 | 正确,实测到 11.5K |
官方 workaround:
-ot 'blk\.([0-5]|1[8-9]|2[0-3])\.ffn_.*_exps=CPU'
已落地为 GPU 机 ~/inkling-run.sh(systemd 的 ExecStart 指向它,避免 systemd 词法解析吃掉反斜杠):
OT='blk\.([0-5]|1[8-9]|2[0-3])\.ffn_.*_exps=CPU'
exec ./build/bin/llama-server \
-m $M/Inkling-2-Mini-Uncensored-AD-IQ3_S.gguf \
--mmproj $M/mmproj-Inkling-2-Mini-Uncensored-F16.gguf \
--ctx-size 65536 -ctk q4_0 -ctv q4_0 -fa on \
-ot "$OT" -ngl 99 -ub 256 -b 256 --jinja \
--alias inkling --host 0.0.0.0 --port 8081 -t 8
显存从 14,696 MiB 降到 11,930 MiB(同样卸载 12 层专家,但落在非循环层,且少占 2.8 GB)。
| 测试 | 结果 |
|---|---|
| 短对话「用一句中文自我介绍」 | 27.25 tok/s,「我是 Inkling,由 Thinking Machines Lab 开发的人工智能助手。」 |
| 6,152 token 长文概括 | 正确:「本季度内将结算页三个步骤合并为一」(prefill 294.5 tok/s,decode 27.38) |
| 4,704 token + 双问题 | 正确:「涉及结算页。/ 合并为一步。」(reasoning 440 token) |
对照:同条件下 -ncmoe 8 在 6.3K prompt 会输出 "GGGG..."。
Unexpected empty grammar stack 根因(issue #32818)标题:chat : inkling tool-call grammar crash with thinking off ("unexpected empty grammar stack")
触发条件:请求里带 tools 数组(客户端开了「工具/函数调用」)。
根因(维护者分析):
That assumes the generation prompt ends at
<|message_model|>. But the inkling templates pre-fill<|message_model|><|content_text|>on the thinking-off path (the stockinkling2.jinjaenable_thinking=falsebranch). Every normal reply therefore begins with bare text.
即:grammar trigger 锚定在 <|message_model|>,而模板在关闭思考时预填了 <|content_text|>,导致 grammar 触发点对不上 → 解析栈被清空 → 抛异常 → HTTP 500。
影响面:LM Studio 用户同样中招(lmstudio-ai/lmstudio-bug-tracker#2632)。common/parsers/inkling.cpp 自 PR #32381 起未变。
规避方案:
| 方案 | 效果 | 副作用 |
|---|---|---|
| 客户端关闭「工具调用/函数」 | 立刻正常 | 无工具能力 |
用 GGUF 内嵌模板 + --reasoning off | 不崩(报告者实测) | 换掉了模板 |
--skip-chat-parsing | 不崩 | tool_calls 字段丢失,思考链泄漏进 content,格式混乱 —— 不推荐 |
| 等上游修复 | — | 报告者建议两个方向:把 trigger 锚定到实际 tool 名,或 mismatch 时降级而非抛异常 |
结论:这个错误不是服务坏了,是客户端发了 tools。关掉工具功能即可。
| Issue | 内容 | 对我们的影响 |
|---|---|---|
| #32804 | ~79k+ token context 时 GGML_ASSERT(s2 <= uint32_t::max()) CUDA abort | 64K 安全,别超 79K |
| #32778 | prompt > ~96 token 全输出 ?,且服务保持坏状态 | 未复现(可能已修) |
| #32753 | reasoning_effort: "none" 实际给 0.9,不是 0 | 思考链长,max_tokens 必须 ≥1024 |
| #32768 | 特性请求 loop_share_cache(48 套 KV 可共享) | 若能落地,长上下文成本大降 |
| #32744 | MoE cache 把 shared expert 存 3 份(循环模型) | 显存浪费 |
| #32785 | KV cache locality 与 layer placement 不匹配 | 影响多卡 |
| #32798 | tokenizer 与 HF 的 token id 不一致(ignore_merges 未启用) | 仅影响精确对齐 |
| #32755 | 本文 §10.1,已修正 | 关键 |
| #32800 | Vulkan 后端 tool calls 500 | 我们用 CUDA,无关 |
| #32812 | Inkling-2-Mini-Uncensored-AD-Q4_K.gguf eval bug | 同系列模型,IQ3_S 暂未遇 |
| #32707 | IQ4_NL prefill 极慢且 5090 上崩溃 | 我们 IQ3_S 未遇 |
| Unsloth PR #389 | repeating fixes:循环层设备按持有权重的层分配、后续 visit 给独立 host 视图 | 上游未合,是 #32755 的正解 |
systemd: inkling.service enabled + active
启动器: ~/inkling-run.sh
关键参数: -ot 'blk\.([0-5]|1[8-9]|2[0-3])\.ffn_.*_exps=CPU'
ctx=65536 KV q4_0 ub=256 alias=inkling
显存: 11,930 / 16,311 MiB
decode ~27 tok/s,prefill ~290 tok/s
http://192.168.31.31:8081/v1
使用约束:
max_tokens ≥ 1024(思考链默认 0.9 档,会吃 400-600 token)inklingctl.sh ink / comfy 切换