This project demonstrates the complete adaptation of HiDream-O1-Image (ModelScope: HiDream-ai/HiDream-O1-Image) to run on Huawei Ascend NPU via vLLM-Ascend.
Although HiDream-O1-Image includes a diffusion head for image generation, its core architecture is Qwen3VLForConditionalGeneration, which vLLM already supports natively. The only adaptation required is filtering out the diffusion-specific weights during model loading.
| Item | Value |
|---|---|
| Model Name | HiDream-O1-Image |
| ModelScope ID | HiDream-ai/HiDream-O1-Image |
| Architecture | Qwen3VLForConditionalGeneration |
| Model Type | qwen3_vl |
| Text Backbone | 36 layers, 4096 hidden, 32 heads, GQA 8 KV heads |
| Vision Tower | 27 layers, 1152 hidden, deepstack [8,16,24] |
| Attention | GQA + MRoPE |
| Quantization | None (bfloat16) |
| Weight Format | Safetensors (8 shards, ~38 GB total) |
| Download Source | ModelScope only (Hugging Face / GitHub Release explicitly prohibited) |
vllm_ascend:registermodelscope download --model HiDream-ai/HiDream-O1-Image --local_dir /models/HiDream-O1-Imagecd /vllm-workspace/vllm
git apply /path/to/hidream_qwen3_vl.patchbash run_hidream_ascend.shbash verify_hidream.shThe only code change is in vllm/model_executor/models/qwen3_vl.py, within Qwen3VLForConditionalGeneration.load_weights.
HiDream-O1-Image contains 9 extra weight keys for its diffusion head:
model.final_layer2.linear.{bias,weight}
model.t_embedder1.mlp.{0,2}.{bias,weight}
model.x_embedder.proj{1,2}.{bias,weight}These are filtered out before being passed to AutoWeightsLoader, preventing a ValueError during weight loading.
| Stage | Description | Status |
|---|---|---|
| Stage A | Dummy weight fast gate | Passed |
| Stage B | Real-weight mandatory gate | Passed |
完整报告见
accuracy_check.md,自动化脚本见accuracy_compare.py。
accuracy_compare.py 在 CPU/GPU 基线与 NPU vLLM 之间复现以原始 Qwen3VLForConditionalGeneration 在 Transformers 框架下以 bfloat16、temperature=0、top-p=1.0 运行的输出为参考基线。
accuracy_compare.py --mode compare 计算:
| 误差来源 | 影响 | 预期量级 |
|---|---|---|
| bfloat16 尾数截断 | hidden state 微小漂移 | ~1e-3 |
| NPU ACL Graph 算子融合 | 浮点运算顺序变化 | ~1e-4 ~ 1e-3 |
| vLLM PagedAttention(单请求/temperature=0) | 无随机性差异 | 0 |
| 扩散头权重过滤 | 不影响 text+image→text | N/A |
final_layer2, t_embedder1, x_embedder) are ignored during vLLM inference. This adaptation validates multimodal understanding (text + image -> text) only.| File | Description |
|---|---|
README.md | This file |
adaptation_report.md | Detailed adaptation report |
run_hidream_ascend.sh | Deployment script |
verify_hidream.sh | Validation script |
run_log.md | Execution logs summary |
hidream_qwen3_vl.patch | Code patch for vLLM |
submit_note.md | Submission notes |
Apache-2.0 (same as vLLM)