模型名称: Floki00/cirdit_multimodal_compile_3to5qubit_v1.1
模型链接: HuggingFace
模型描述: CirDiT(Circuit Diffusion Transformer)是用于量子电路编译的多模态扩散模型。给定目标酉矩阵和自然语言描述,模型通过双分支(电路结构 + 门参数)联合扩散采样,输出可执行的量子线路门编码和参数值。
模型架构: UnitaryCLIPPartialNoiseCompilationCirDiT(genQC)
核心权重(revision bd2c968):
| 文件 | 大小 | SHA-256 |
|---|---|---|
model.safetensors | ~765 MB | 9fe6326a260eee854e71d02075f89a2d9e79c10be2d77e9fea4cd27a856ffef9 |
embedder.safetensors | ~5 MB | 071b1f29feeac8eaaa62e3ca17946c2a40bf8ea08de8237f3d74286c5672057a |
beta_schedule_learned_linear.safetensors | ~1 KB | 128fc8d486718ba92a84d072a95b4130a052ff14e89843249ac2a3c25bcf5936 |
文本编码器: laion/CLIP-ViT-B-32-DataComp.XL-s13B-b90K @ f0e2ffa
输入规格:
[2, 2^k, 2^k],k ∈ {3, 4, 5}输出规格:
[1, system_size, max_gates],值域为离散门类型索引[1, system_size, max_gates, param_dim]| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架(平台提供) |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端(平台提供) |
| torchvision | >= 0.25.0 | open_clip 依赖(平台提供) |
| genQC | 0.2.5 | 量子电路扩散模型框架 |
| open_clip_torch | 3.3.0 | CLIP 文本编码器 |
| numpy | 2.4.4 | 数值计算 |
| safetensors | 0.8.0 | 安全张量加载 |
| huggingface_hub | 0.36.2 | HF 缓存访问 |
| omegaconf | 2.3.1 | 配置解析 |
| 昇腾驱动 | CANN 8.5+ | 推荐 CANN 8.5.1 |
安装命令(模型层依赖,不覆盖平台 torch/torch_npu):
python3 -m pip install --target ../pydeps -r requirements.txt
export PYTHONPATH="$PWD/../pydeps:$PYTHONPATH"# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"克隆模型权重到本地目录(使用 GitCode 镜像):
git clone https://gitcode.com/hf_mirrors/Floki00/cirdit_multimodal_compile_3to5qubit_v1.1.git ../model
git -C ../model checkout bd2c968349d0915580b5acbaf970d2fc446d2503
git -C ../model lfs pull准备文本编码器 HF 缓存:
export HF_ENDPOINT=https://ai.gitcode.com
export HF_HOME="$PWD/../hf-cache"
hf download laion/CLIP-ViT-B-32-DataComp.XL-s13B-b90K \
--revision f0e2ffa09cbadab3db6a261ec1ec56407ce42912source /usr/local/Ascend/ascend-toolkit/set_env.sh
export HF_HOME="$PWD/../hf-cache"
export PYTHONPATH="$PWD/../pydeps:$PYTHONPATH"python3 inference.py \
--model_path ../model \
--device npu:0 \
--seed 20260816 \
--steps 40 \
--guidance 1.0 \
--samples 8 \
--system_size 5 \
--max_gates 32 \
--qubits 3 4 5 \
--output_json result.json| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--model_path | str | 必填 | 模型 checkpoint 目录(含 config.yaml + safetensors) |
--device | str | npu:0 | 昇腾 NPU 设备,仅接受 npu:N 格式 |
--seed | int | 20260816 | 全局随机种子 |
--steps | int | 40 | DDIM 去噪步数 |
--guidance | float | 1.0 | CFG++ 引导强度 |
--samples | int | 8 | 生成样本数 |
--system_size | int | 5 | 量子比特数(线路宽度) |
--max_gates | int | 32 | 最大门层数(线路深度) |
--qubits | int[] | 3 4 5 | 循环使用的量子比特配置 |
--output_json | str | result.json | 结果输出路径 |
[INFO] Loading pipeline from ../model ...
[INFO]: Loading tensor from `.../beta_schedule_learned_linear.safetensors` onto device: npu:0.
[INFO]: Loading model from `.../model.safetensors` onto device: npu:0.
[INFO]: `RotationalMultimodialPresetEmbedderTiny`. Freeze model: True
[INFO] Pipeline loaded. 186,143,209 parameters on npu:0 (Ascend910_9362)
[1/8] k=3 time=2.22s gates=160 tokens
[2/8] k=4 time=1.41s gates=160 tokens
[3/8] k=5 time=1.42s gates=160 tokens
[4/8] k=3 time=1.43s gates=160 tokens
[5/8] k=4 time=1.40s gates=160 tokens
[6/8] k=5 time=1.41s gates=160 tokens
[7/8] k=3 time=1.44s gates=160 tokens
[8/8] k=4 time=1.43s gates=160 tokens
[INFO] Total: 12.18s for 8 samples
[INFO] Results written to result.json运行命令:
python3 inference.py --model_path ../model --device npu:0 --seed 20260816 \
--steps 10 --samples 1 --system_size 3 --max_gates 16 --qubits 3输出:
[INFO] Pipeline loaded. 186,143,209 parameters on npu:0 (Ascend910_9362)
[1/1] k=3 time=0.98s gates=160 tokens
[INFO] Total: 0.98s for 1 samples运行命令:
python3 inference.py --model_path ../model --device npu:0 --seed 20260816 \
--steps 40 --samples 1 --system_size 5 --max_gates 32 --qubits 5输出:
[INFO] Pipeline loaded. 186,143,209 parameters on npu:0 (Ascend910_9362)
[1/1] k=5 time=0.39s gates=160 tokens
[INFO] Total: 0.39s for 1 samples运行命令:
python3 inference.py --model_path ../model --device npu:0 --seed 20260816 \
--steps 40 --guidance 1.0 --samples 8 --system_size 5 \
--max_gates 32 --qubits 3 4 5 --output_json result.json输出:
{
"model_id": "Floki00/cirdit_multimodal_compile_3to5qubit_v1.1",
"device": "npu:0",
"npu_name": "Ascend910_9362",
"steps": 40,
"guidance": 1.0,
"total_time_s": 12.18,
"parameter_count": 186143209,
"exit_status": 0,
"samples": [
{"id": "sample-000", "num_of_qubits": 3, "gates": [0, ...], "output_shape": [1, 5, 32, 16]},
{"id": "sample-001", "num_of_qubits": 4, "gates": [0, ...], "output_shape": [1, 5, 32, 16]}
]
}


评测说明: 量子电路编译任务的评测边界为输出契约验证——shape、token 计数、设备放置、有限性(无 NaN/Inf)和退出状态。不评价生成线路的物理质量( fidelity / gate count optimality),因为该模型面向编译可行性,不保证最优解。
验证结果:
| 指标 | 3-qubit | 4-qubit | 5-qubit |
|---|---|---|---|
| 输出 shape | [1,5,32,16] | [1,5,32,16] | [1,5,32,16] |
| 门 token 数 | 160 | 160 | 160 |
| NaN / Inf | 0 / 0 | 0 / 0 | 0 / 0 |
| 参数计数 | 186,143,209 (match) | 186,143,209 (match) | 186,143,209 (match) |
| 设备放置 | npu:0 | npu:0 | npu:0 |
| 配置项 | 值 |
|---|---|
| NPU 型号 | Ascend910_9362 |
| NPU 卡数 | 1 (npu:0) |
| 显存占用 | ~1017 MB |
| torch_npu | 2.9.0.post1 |
| CANN | 8.5.1 |
| 模型参数量 | 186,143,209 |
| 推理吞吐 | ~1.4 s/sample (40 DDIM steps) |
无。模型已通过完整 NPU forward 验证,输出 shape、参数计数和退出状态均符合预期。