
Misc. bug: Device Lost on Intel dGPU using Vulkan backend
快速结论:该报错主要发生在 Intel Arc 系列独立显卡(如 B580、B70、B60)运行 llama.cpp Vulkan 后端时,表现为 VK_ERROR_DEVICE_LOST 或系统完全卡死。优先尝试通过环境变量 GGML_VK_DISABLE_COOPMAT=1 和 GGML_VK_DISABLE_COOPMAT2=1 禁用 cooperative matrix(coopmat)功能。
问题场景
用户在使用 llama-bench 或 llama-cli 加载 MoE 架构模型(如 Qwen3-30B-A3B、Qwen3-Coder-30B-A3B、Qwen3-32B 等),并使用 Vulkan 后端进行推理或基准测试时触发。问题在 llama-bench 上可 100% 复现,但在 llama-cli 和 llama-server 上可能为间歇性出现。当使用 -b 32 -ub 32 等小 batch size 配合 -n 0 参数时,触发概率更高。
报错原文
VK_ERROR_DEVICE_LOST
# 另见主机端崩溃(STATUS_STACK_BUFFER_OVERRUN)
Exception code: 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN)
Faulting module: ucrtbase.dll
Fault offset: 0x00000000000a527e (重复出现,非模型特定)
# Validation 与 extension 相关警告(非错误,但出现于日志中)
Validation Warning: [BestPractices-deprecated-extension] vkCreateDevice(): Attempting to enable deprecated extension VK_EXT_pipeline_robustness...
Validation Warning: [BestPractices-deprecated-extension] vkCreateDevice(): Attempting to enable deprecated extension VK_KHR_maintenance4...
Validation Warning: [BestPractices-deprecated-extension] vkCreateDevice(): Attempting to enable deprecated extension VK_KHR_shader_integer_dot_product...
Validation Warning: [BestPractices-deprecated-extension] vkCreateDevice(): Attempting to enable deprecated extension VK_EXT_subgroup_size_control...
Validation Warning: [BestPractices-deprecated-extension] vkCreateDevice(): Attempting to enable deprecated extension VK_KHR_16bit_storage...
Validation Warning: [BestPractices-deprecated-extension] vkCreateDevice(): Attempting to enable deprecated extension VK_KHR_shader_non_semantic_info...
原因分析
可能原因:该问题与 Intel Arc 显卡的 Vulkan cooperative matrix(coopmat)实现有关,尤其是 VK_KHR_cooperative_matrix 扩展。具体来说,以下两条 shader pipeline 被确认会触发崩溃:
matmul_q4_k_f32_f16acc_aligned_smatmul_q6_k_f32_f16acc_aligned_s
由于崩溃需要的调用次数随机(有时不崩溃),可能还存在竞争条件。也有可能是 Intel 驱动编译器的问题。在一个较新版本(b9245)上,同一 bug 还会通过 STATUS_STACK_BUFFER_OVERRUN 路径表现出来(主机端 ucrtbase.dll 崩溃,偏移地址固定为 0xa527e)。
环境排查
- 显卡型号:Intel Arc B580、Arc Pro B70、Arc B60 等 Intel dGPU
- 操作系统:Windows 11 / Windows Server 2022
- 驱动版本:32.0.101.8515、32.0.101.8724、32.0.101.8737(均可能触发)
- llama.cpp 版本:commit 8827 (5e6c0e18b)、b8850、b9245 等均可复现;b8555 未观察到崩溃
- 编译选项:
-DGGML_VULKAN=ON -DGGML_VULKAN_VALIDATE=ON(验证模式下可看到 extension 弃用警告) - 模型类型:MoE 架构模型(如 Qwen3 系列,包含 A3B 混合专家结构)
- Vulkan SDK 版本(可选):1.4.341.1
解决步骤
- 禁用 cooperative matrix(可优先尝试):
设置以下环境变量后重新运行测试/推理:set GGML_VK_DISABLE_COOPMAT=1 set GGML_VK_DISABLE_COOPMAT2=1注意:此方法会降低推理速度(例如 Intel Arc Pro B70 上约从 17–22 tok/s 降至约 12 tok/s),但能完全避免崩溃。
- 尝试不使用
flash_attn:
部分用户反馈启用 flash attention(-fa)会加速触发崩溃,可尝试去掉-fa参数。 - 切换至较旧版本的 llama.cpp:
确认 b8555 版本在此硬件上运行正常(参考 Intel AI Playground 打包版本)。如果可能,可尝试回退到此版本附近。 - 降低 batch size:
使用更小的-b和-ub值(如-b 32 -ub 32)在部分用户中可提高稳定性(但本 Issue 中该参数组合反而触发了崩溃)。建议根据实际硬件和模型调整。 - 更新 Intel 显卡驱动:
尝试升级到最新 Intel 官方驱动,或安装 Arc Control 提供的推荐版本。 - 禁用 TDR(超时检测与恢复,仅限实验性):
在 Windows 注册表中设置TdrLevel=0(需重启),但 Issue 中显示即使禁用 TDR,崩溃仍然发生。此操作非推荐修复方案。
验证方法
设置 GGML_VK_DISABLE_COOPMAT=1 和 GGML_VK_DISABLE_COOPMAT2=1 后,重新运行之前触发崩溃的命令(例如 llama-bench.exe -m your_model.gguf -n 0 -b 32 -ub 32),确认不再出现 VK_ERROR_DEVICE_LOST 或系统冻结。可反复运行 5 次以上以验证稳定性。若希望确认 coopmat 已禁用,可在启动日志中搜索相关状态,或观察推理速度是否下降(约 30–50%)。



