昇腾 NPU 适配 | CirDiT 多模态扩散量子线路编译模型(3~5 qubit)
基于 genQC 的「离散-连续量子线路多模态扩散模型」(CirDiT, 150M)。
输入 35 qubit 目标酉矩阵 U, 经过多模态扩散采样输出对应的量子线路(离散门序列 + 连续参数)。
num_of_qubits=5,min_gates=4,max_gates=32)h cx ccx swap rx ry rz cp(含参数门)部署到昇腾 NPU(910 系列), 运行环境:
| 组件 | 版本 |
|---|---|
| PyTorch | >= 2.5 |
| torch_npu | >= 2.9.0 (CANN 8.5.1) |
| genQC | 0.2.5 |
| numpy/scipy | 见 requirements.txt |
权重默认读取 ./model/ 目录(config.yaml + model.safetensors + embedder.safetensors + beta_schedule_learned_linear.safetensors)。
如缺失,inference.py 会自动从 HF 镜像(https://hf-mirror.com) 或 gitcode LFS batch 兜底下载。
python -c "from inference import ensure_weights; ensure_weights('./model')"pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
export HF_ENDPOINT=https://hf-mirror.compython inference.py --target qft --num-qubits 3 --samples 1 --device npu:0python inference.py --serve --port 8000 --device npu:0请求编译:
curl -X POST http://127.0.0.1:8000/compile \
-H 'Content-Type: application/json' \
-d '{"num_qubits":3,"target":"qft","samples":1}'健康检查:
curl http://127.0.0.1:8000/health
# {"status":"ok","device":"npu:0"}from_config_file(..., device=torch.device('npu:N')) 将全部权重加载/执行到昇腾 NPU。datacomp_xl_s13b_b90k) 首次运行需下载权重(约 600MB), 走 HF 镜像。cirdit_multimodal_compile_3to5qubit_v1.1/
├── inference.py # 昇腾 NPU 推理脚本(CLI + HTTP 服务)
├── README.md # 本文档
├── requirements.txt # 依赖清单
├── model/ # 权重目录(配置 + 权重, 大权重不随仓库提交)
└── assets/ # 截图素材(agent_workflow / npu_device_call / model_result)