Floki00/cirdit_multimodal_compile_3to5qubit_v1.1 — 面向 3-5 qubit 量子线路编译的多模态扩散模型,昇腾 Ascend NPU 推理适配。
MultimodalDiffusionPipeline_ParametrizedCompilation
UnitaryCLIPPartialNoiseCompilationCirDiT(扩散 Transformer,DDIM,v-type 预测,~150M 参数)CachedFrozenOpenCLIPEmbedder(OpenCLIP ViT-B-32 / datacomp_xl_s13b_b90k)RotationalMultimodialPresetEmbedderTinyh, cx, ccx, swap, rx, ry, rz, cp,线路最多 32 门npu:0(Ascend 910),全文件不含任何 GPU 专用设备调用。try-except 捕获 NPU 初始化异常(torch_npu 导入失败或 npu:0 不可用),打印清晰错误并优雅退出。./model_weights/Floki00__cirdit_multimodal_compile_3to5qubit_v1.1;启动时优先加载本地缓存,未命中才从 hf-mirror.com 下载。./logs/ascend/(Ascend 运行日志)。python3 inference.py --text "compile a 3-qubit circuit that implements the quantum Fourier transform"可选参数:
| 参数 | 说明 | 默认 |
|---|---|---|
--text | 文本提示词(必填),描述要编译的线路 | - |
--qubits | qubit 数 3-5,自动从文本解析,解析不到取 3 | 3 |
--steps | DDIM 去噪步数 | 50 |
--guidance | CFG 引导尺度 | 3.0 |
--seed | 随机种子 | - |
输出 JSON 包含 compiled_circuit(指令列表)与 qasm 字符串。
uvicorn inference:app --host 0.0.0.0 --port 8101POST /predict:
curl -X POST http://127.0.0.1:8101/predict \
-H 'Content-Type: application/json' \
-d '{"text":"compile a 4-qubit circuit that implements the quantum Fourier transform"}'请求体:{"text": "...", "qubits": 3, "steps": 50, "guidance": 3.0, "seed": 1}(后四者可省略)。
pip install -r requirements.txt
pip install genQC==0.2.5依赖:torch / torch_npu(Ascend 环境)、transformers、open_clip_torch、omegaconf、matplotlib、safetensors、einops、numpy、fastapi、uvicorn。
inference.py # 双模式推理入口 (CLI + FastAPI)
download_weights.py # 权重下载工具 (hf-mirror, 断点续传)
model_weights/Floki00__cirdit_.../ # 权重本地缓存 (git 忽略)
assets/ # 运行截图
logs/ # 运行日志 (git 忽略)