OpenVINO GenAI 跑通官方 26B:VLMPipeline + SDPA 的 12 条坑

llama.cpp 是把模型转成 GGUF 再跑,Intel 还有一条原生 OpenVINO GenAI 管线:直接加载官方预转换的 OpenVINO IR(INT4-AWQ),权重质量更有保证。我在 Arc 140T 核显上把它跑通了 gemma-4-26B-A4B 官方原版。这篇是完整跑通记录,重点是那个「必须 VLMPipeline + 强制 SDPA」的诡异坑。

结论:已跑通 ✅。环境:Windows / Arc 140T(19.7GB)/ Python 3.12.10 / openvino-genai 2026.5.0 nightly。模型:官方预转换 IR OpenVINO/gemma-4-26b-a4b-it-int4-ov(INT4 AWQ,14.6GB)。2026-09 实测。

成绩单

指标结果
模型加载41.6s
吞吐(throughput)15.7 t/s
TTFT(首 token)167ms
TPOT(每 token)64ms/token
pp512 / tg128500 / 13.7~14.0 t/s(warmup 后中位数,跨脚本复现两次)
质量复杂问答/翻译/创作/chat 多轮记忆全部正确,无乱码

跑通的三步关键

  • 必须用 VLMPipeline 而非 LLMPipeline(LLMPipeline 报 input_ids 找不到,因输入是 inputs_embeds)
  • 强制 SDPA 后端绕过 Continuous Batching(CB/PA)适配器:VLMPipeline(MODEL_DIR, "GPU", **{"ATTENTION_BACKEND": "SDPA"}),否则报 EMBEDDINGS 断言失败
  • 补全缺失的 openvino_text_embeddings_model.xml(首个 aria2 下载批次静默失败,导致 embedder 创建异常)——校验目录内 16 个必需小文件都在

与 llama.cpp Vulkan 对比

同一官方模型、同为 4-bit 精度:

路线pp512 (t/s)tg128 (t/s)
llama.cpp Vulkan(GGUF Q4_0,13.6GB)285.3020.04
OpenVINO GenAI(IR INT4-AWQ,默认配置)50013.7~14.0

预填充 GenAI 快 ~75%,输出 Vulkan 快 ~46%。差距来自 MoE 后端实现(Vulkan 对 MoE 有异步专家调度优化),非参数可调。GenAI 的价值是官方 INT4-AWQ 权重质量更好,可作备选路线。

12 条坑清单

#解法状态
1必须 VLMPipeline,LLMPipeline 的 input_ids 找不到Gemma-4 被 GenAI 注册为 VLM-only,纯文本也走 VLMPipeline
2OV 2026.2 stateful 解码 bug(首个 token 正常后乱码)用 2026.3-dev nightly(GenAI + runtime 同装)
3连续批处理(CB)需 2026.4 修正栈,空转/错乱强制 ATTENTION_BACKEND=SDPA 走经典 stateful 管线
4router 不能 INT4 量化(仅自转时)OVWeightQuantizationConfig ignored_scope 排除 router;官方 IR 已内置
5纯 INT4 无 AWQ 在 MoE 上质量差官方 int4-ov 质量实测无问题
6整模型必须进显存,19.7GB 紧张调显存后 + 缩短上下文;IR 13.3GB 稳跑
7transformers 版本(仅自转时)pip install transformers==5.5.0(12B 用 5.10.0)
832K 长上下文 rope LUT patch显存只够短上下文,跳过
9HF 直连超时hf-mirror.com 镜像(注意分批校验文件完整性)
10GPU 支持 preview 级Arc 140T 实际实测(15.7 t/s)
11Gemma-4 是视觉模型,文本按 multimodal 处理文本直接 generate 即可
12DYNAMIC_QUANTIZATION_GROUP_SIZE 长上下文乱码设为 0(实测正常无需特殊处理)

环境要求

组件版本
OpenVINO Runtime2026.2.0+(官方 IR 卡要求)/ 2026.3-dev nightly(GPU 干净解码)
openvino-genai (pip)与 OpenVINO nightly 配套
optimum-intel1.27.0+(转换用,本机跑推理可不装)
transformers5.5.0(若需自己导出;12B 需 5.10.0)

总结

  • OpenVINO GenAI 是 llama.cpp 之外的成熟备选:官方 INT4-AWQ 权重,预填充更快,TTFT 167ms 很舒服
  • 核心坑就两个:VLMPipeline + 强制 SDPA,记住了就不折腾
  • 长上下文(529+ token)偶发 CL_OUT_OF_RESOURCES 是驱动 bug(报错自带 'Due to a driver bug'),非显存不足,忽略即可
  • 追求生成速度仍选 llama.cpp Vulkan(20+ t/s),追求官方权重质量选 GenAI
下载提醒:hf-mirror 下载后务必逐文件校验完整性(首批批次会静默漏文件,导致 embedder 创建异常但没报错)。

llama.cpp converts models to GGUF and runs them; Intel offers a native OpenVINO GenAI pipeline that loads officially pre-converted OpenVINO IR (INT4-AWQ) with better weight fidelity. I ran the official gemma-4-26B-A4B through it on an Arc 140T iGPU. Full record here — especially the weird 'must use VLMPipeline + force SDPA' pitfall.

Verdict: works ✅. Env: Windows / Arc 140T (19.7GB) / Python 3.12.10 / openvino-genai 2026.5.0 nightly. Model: official IR OpenVINO/gemma-4-26b-a4b-it-int4-ov (INT4 AWQ, 14.6GB). Tested 2026-09.

Results

MetricResult
Model load41.6s
Throughput15.7 t/s
TTFT (first token)167ms
TPOT (per token)64ms/token
pp512 / tg128500 / 13.7~14.0 t/s (post-warmup median, reproduced across two scripts)
QualityComplex Q&A, translation, writing, multi-turn memory all correct, no garbled output

Three critical steps to get it running

  • Must use VLMPipeline, not LLMPipeline (LLMPipeline fails to find input_ids — the input is inputs_embeds)
  • Force the SDPA backend to bypass the Continuous Batching (CB/PA) adapter: VLMPipeline(MODEL_DIR, "GPU", **{"ATTENTION_BACKEND": "SDPA"}); otherwise an EMBEDDINGS assertion fails
  • Restore the missing openvino_text_embeddings_model.xml (the first aria2 batch silently dropped it, breaking embedder creation) — verify all 16 required small files exist

vs llama.cpp Vulkan

Same official model, both 4-bit:

Routepp512 (t/s)tg128 (t/s)
llama.cpp Vulkan (GGUF Q4_0, 13.6GB)285.3020.04
OpenVINO GenAI (IR INT4-AWQ, default config)50013.7~14.0

GenAI prefill ~75% faster; Vulkan decode ~46% faster. The gap is MoE backend implementation (Vulkan has async expert scheduling) — not tunable. GenAI's value is better weight quality from official INT4-AWQ — a solid alternate route.

The 12-pitfall checklist

#PitfallFixStatus
1Must use VLMPipeline; LLMPipeline can't find input_idsGemma-4 is registered VLM-only; use VLMPipeline for text too
2OV 2026.2 stateful decode bug (garbled after first token)Use 2026.3-dev nightly (GenAI + runtime together)
3Continuous batching needs the 2026.4 fix stackForce ATTENTION_BACKEND=SDPA for classic stateful pipeline
4Router must not be INT4-quantized (self-export only)OVWeightQuantizationConfig ignored_scope; official IR has it built in
5Pure INT4 without AWQ is poor on MoEOfficial int4-ov measured fine
6Entire model must fit VRAM; 19.7GB is tightAfter VRAM tuning + shorter context; 13.3GB IR is stable
7transformers version (self-export only)pip install transformers==5.5.0 (12B needs 5.10.0)
832K long-context rope LUT patchVRAM only fits short contexts; skipped
9HF direct connection times outhf-mirror.com mirror (verify files in batches)
10GPU support is preview-gradeMeasured on Arc 140T (15.7 t/s)
11Gemma-4 is a vision model; text goes through multimodal pathText can just be generated directly
12DYNAMIC_QUANTIZATION_GROUP_SIZE garbles long contextsSet to 0 (measured fine, no special handling)

Environment requirements

ComponentVersion
OpenVINO Runtime2026.2.0+ (official IR card req.) / 2026.3-dev nightly (clean GPU decode)
openvino-genai (pip)Match the OpenVINO nightly
optimum-intel1.27.0+ (for conversion; not needed for inference)
transformers5.5.0 (if self-exporting; 12B needs 5.10.0)

Summary

  • OpenVINO GenAI is a mature alternative to llama.cpp: official INT4-AWQ weights, faster prefill, comfortable 167ms TTFT
  • Two core gotchas: VLMPipeline + forced SDPA — remember these and the rest is smooth
  • Occasional CL_OUT_OF_RESOURCES past 529 tokens is a driver bug (error literally says 'Due to a driver bug'), not OOM — ignore it
  • For decode speed stay on llama.cpp Vulkan (20+ t/s); for official weight quality go GenAI
Download note:After hf-mirror downloads, verify each file — the first batch silently dropped a file that broke embedder creation without any clear error.
返回文章列表