Skip to content

## [SYCL] 0.3.43 多模态推理输出乱码,0.3.41 正常 #155

Description

@allanmeng

背景

自从上次跟你联调,解决 0.3.41 在某些环境编译出现 bin/ lib/ 问题后,我的应用系统环境发生了很多变化

pytorch.xpu 2.12-->2.13

comfyui 0.27--> 0.28

今天拿到 0.3.43,sycl 编译,测试时候发现了一些问题:

PyTorch XPU llama-cpp-python ComfyUI 结果
2.13 0.3.41 (a5ceecb) 0.27 ❌ access violation,SYCL decode 崩溃
2.13 0.3.41 (a5ceecb) 0.28 ❌ access violation,SYCL decode 崩溃
2.13 0.3.43 (a641283) 0.28 ❌ access violation,SYCL decode 崩溃
2.12 0.3.41 (a5ceecb) 0.27 ✅ 正常
2.12 0.3.41 (a5ceecb) 0.28 ✅ 正常
2.12 0.3.43 (a641283) 0.27 ✅ 跑通(输出乱码)
2.12 0.3.43 (a641283) 0.28 ✅ 跑通(输出乱码)
任意 任意 Standalone ✅ 跑通(不崩溃验证)

但这些问题是交叉场景,我无法定位到 单纯的是 llama-cpp-python-sycl 的部分,

所以我尽量收缩范围,先集中在一个 0.3.43 llama-cpp-python 编译的sycl 可能性很高的问题入手,
就是下面这个:

llama-cpp-python 结果
0.3.41 (a5ceecb) ✅ 正常
0.3.43 (a641283) ✅ 跑通(输出乱码)

这个问题没有ComfyUI / PyTorch 依赖
0.3.41 (a5ceecb) 是之前改完 bin/ 的 hot fix 版本(我没升级 0.3.42)

0.3.41_standalone.txt
0.3.43_standalone.txt

环境

  • OS: Windows 11
  • GPU: Intel Arc B580, SYCL oneAPI 2025.3.2
  • Python: 3.13.11

模型

  • 主模型: Qwen3.5-4B Q4_K_M (hybrid: attention + SSM)
  • mmproj: mmproj-BF16.gguf

测试方式

纯 standalone Python 脚本(不含 ComfyUI / PyTorch),mmproj_path 传入 Llama()create_chat_completion 带图片。

结果

版本 输出
0.3.41 (a5ceecb) 用户希望我用中文详细描述这张图片的内容。
0.3.43 (a641283) #enkofferrhzosима方方面面...(随机垃圾字节)

详细对比

指标 0.3.41 0.3.43
Chat template 相同 相同
渲染 prompt 151 chars 151 chars
图像编码尺寸 1088×1440 1088×1440
IMAGE chunk 1530 tokens 1530 tokens
GPU graphs reused 98 98
生成速度 14.72 ms/tok 14.65 ms/tok
模型加载时间 17839 ms 9963 ms
输出 正常中文 乱码

所有可测量指标(模板渲染、图像编码、GPU 计算)在两个版本间完全相同。唯一显著差异是模型加载时间减半(17839ms → 9963ms),同时输出质量崩塌。推测 0.3.43 的 SYCL 权重加载或 KV cache 初始化不完整,导致 token 生成质量退化。

重现脚本

F:\ComfyUI-aki-v3\python\python.exe -c "
import os
os.environ['PATH'] = r'F:\Intel-oneAPI\2025.3\bin' + os.pathsep + \
    r'F:\ComfyUI-aki-v3\python\Lib\site-packages\llama_cpp\lib'

from llama_cpp import Llama
import base64

llm = Llama(
    model_path=r'F:\...\Qwen3.5-4B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf',
    mmproj_path=r'F:\...\Qwen3.5-4B-Uncensored-HauhauCS-Aggressive-mmproj-BF16.gguf',
    n_gpu_layers=-1, n_ctx=4096, ctx_checkpoints=0,
    n_batch=2048, n_ubatch=512, offload_kqv=True, use_mmap=True,
    chat_handler_kwargs={'use_gpu': True, 'image_min_tokens': 1024},
)

with open(r'F:\...\image.png', 'rb') as f:
    data_uri = 'data:image/png;base64,' + base64.b64encode(f.read()).decode()

response = llm.create_chat_completion(
    messages=[
        {'role': 'system', 'content': '你必须用中文回答'},
        {'role': 'user', 'content': [
            {'type': 'text', 'text': '用中文详细描述这张图片的内容'},
            {'type': 'image_url', 'image_url': {'url': data_uri}}
        ]}
    ],
    max_tokens=100,
)
print(response['choices'][0]['message']['content'][:200])
"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions