[{"data":1,"prerenderedAt":486},["ShallowReactive",2],{"content-query-tHAyVQyC3O":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"category":13,"body":14,"_type":480,"_id":481,"_source":482,"_file":483,"_stem":484,"_extension":485},"/technology-blogs/zh/2026-5-7","zh",false,"","MindSpore Quantum 0.12.0 发布：张量网络模拟、量子启发式算法族与量子硬件抽象层全面升级","MindSpore Quantum 是一款开源的混合量子-经典编程框架，依托于 MindSpore 深度学习框架，在量子算法模拟、训练与实现方面展现卓越性能。","2026-5-7","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/11/28/8e0e0150508a4c5ba4287fa3bec8ea3f.png","technology-blogs","技术解读",{"type":15,"children":16,"toc":471},"root",[17,25,30,35,55,60,71,76,87,97,106,113,118,123,128,133,138,143,150,157,162,167,190,195,200,210,216,221,228,240,245,252,257,265,271,276,283,306,311,316,321,326,334,339,347,352,358,363,371,376,384,389,402,408,413,431,436,441,448,460],{"type":18,"tag":19,"props":20,"children":22},"element","h1",{"id":21},"mindspore-quantum-0120-发布张量网络模拟量子启发式算法族与量子硬件抽象层全面升级",[23],{"type":24,"value":8},"text",{"type":18,"tag":26,"props":27,"children":28},"p",{},[29],{"type":24,"value":9},{"type":18,"tag":26,"props":31,"children":32},{},[33],{"type":24,"value":34},"0.12.0 版本以“扩展边界”为核心，聚焦三大方向：",{"type":18,"tag":36,"props":37,"children":38},"ul",{},[39,45,50],{"type":18,"tag":40,"props":41,"children":42},"li",{},[43],{"type":24,"value":44},"引入 MPS 张量网络模拟器，突破量子比特数限制；",{"type":18,"tag":40,"props":46,"children":47},{},[48],{"type":24,"value":49},"丰富量子启发式优化算法族工具箱；",{"type":18,"tag":40,"props":51,"children":52},{},[53],{"type":24,"value":54},"打通从模拟器到真实量子硬件的路径。",{"type":18,"tag":26,"props":56,"children":57},{},[58],{"type":24,"value":59},"这些特性助力研究者从理论验证到硬件部署的高效跨越。",{"type":18,"tag":61,"props":62,"children":64},"div",{"style":63},"text-align: center;",[65],{"type":18,"tag":66,"props":67,"children":70},"img",{"src":68,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/1.jpg","display: block;margin: 0 auto;max-width:60%",[],{"type":18,"tag":26,"props":72,"children":73},{},[74],{"type":24,"value":75},"本次版本核心亮点：",{"type":18,"tag":26,"props":77,"children":78},{},[79,85],{"type":18,"tag":80,"props":81,"children":82},"span",{},[83],{"type":24,"value":84},"BETA",{"type":24,"value":86}," mqmps 张量网络模拟器：新增矩阵乘积态（MPS）后端，在中等纠缠线路上以远少于态矢量方法的内存模拟更多量子比特。",{"type":18,"tag":26,"props":88,"children":89},{},[90,95],{"type":18,"tag":80,"props":91,"children":92},{},[93],{"type":24,"value":94},"STABLE",{"type":24,"value":96}," QAIA 算法族扩展：QAIA 模块新增 TSB/USB/LSB 三种量化模拟分叉变体，为组合优化问题提供更丰富的求解工具。",{"type":18,"tag":26,"props":98,"children":99},{},[100,104],{"type":18,"tag":80,"props":101,"children":102},{},[103],{"type":24,"value":84},{"type":24,"value":105}," QPU 硬件抽象层：发布 QPU 抽象基类，调用风格与 Simulator 高度一致，大幅降低从模拟器迁移到真实硬件的成本。开发者仅需实现一个采样方法，即可将算法无缝对接任意量子硬件。",{"type":18,"tag":107,"props":108,"children":110},"h2",{"id":109},"_01-mqmps矩阵乘积态模拟器突破量子比特数限制",[111],{"type":24,"value":112},"01 mqmps：矩阵乘积态模拟器，突破量子比特数限制",{"type":18,"tag":26,"props":114,"children":115},{},[116],{"type":24,"value":117},"全振幅态矢量模拟器的内存需求随量子比特数呈指数增长（2nX16字节，complex128）—— 模拟 30 个量子比特就需要约 16 GiB 内存，而 40 个量子比特则需要超过 16 TiB。这一”内存墙”严重制约了量子算法的规模化验证。",{"type":18,"tag":26,"props":119,"children":120},{},[121],{"type":24,"value":122},"MindSpore Quantum 0.12.0 引入了全新的矩阵乘积态（Matrix Product State, MPS）模拟器后端 mqmps。MPS 以张量网络的形式表示量子态，其内存消耗主要取决于线路的纠缠度（由键维度 χ 控制），而非量子比特数本身。当线路纠缠度适中时，mqmps 可以用远少于态矢量方法的内存模拟更多的量子比特。",{"type":18,"tag":26,"props":124,"children":125},{},[126],{"type":24,"value":127},"性能对比：",{"type":18,"tag":26,"props":129,"children":130},{},[131],{"type":24,"value":132},"下图展示了在一个深度为 5 的低纠缠线路（相邻比特 CNOT + 单比特 RY 门）上，以 max_bond_dimension=0（精确模式）运行 apply_circuit 的单次耗时对比：",{"type":18,"tag":26,"props":134,"children":135},{},[136],{"type":24,"value":137},"在 24 个量子比特时，mqvector 需要约 1.1 秒，而 mqmps 仅需 0.005 秒，差距显著。随着比特数增长，态矢量的指数开销使其耗时急剧上升，而 MPS 的耗时仅线性增长。",{"type":18,"tag":26,"props":139,"children":140},{},[141],{"type":24,"value":142},"在更大的比特数下（测试覆盖至 100 量子比特），mqmps 仍可在毫秒级完成线路执行。",{"type":18,"tag":61,"props":144,"children":145},{"style":63},[146],{"type":18,"tag":66,"props":147,"children":149},{"src":148,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/2.jpg",[],{"type":18,"tag":61,"props":151,"children":152},{"style":63},[153],{"type":18,"tag":66,"props":154,"children":156},{"src":155,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/3.jpg",[],{"type":18,"tag":26,"props":158,"children":159},{},[160],{"type":24,"value":161},"需要强调的是，MPS 的性能优势与线路纠缠度密切相关。对于高度纠缠的线路（如深层随机线路），键维度会快速增长，MPS 的优势将减弱甚至消失。 mqmps  最适合的场景包括：浅层变分线路、一维近邻结构的量子多体模拟、以及中等纠缠度的 VQE 线路等。",{"type":18,"tag":26,"props":163,"children":164},{},[165],{"type":24,"value":166},"mqmps 后端的核心技术特点：",{"type":18,"tag":36,"props":168,"children":169},{},[170,175,180,185],{"type":18,"tag":40,"props":171,"children":172},{},[173],{"type":24,"value":174},"高性能 C++ 内核：底层基于 BLAS/LAPACK 实现，确保张量运算的数值稳定性和计算效率。",{"type":18,"tag":40,"props":176,"children":177},{},[178],{"type":24,"value":179},"支持单比特和双比特门：非相邻量子比特上的双比特门会自动插入 SWAP 门进行路由。",{"type":18,"tag":40,"props":181,"children":182},{},[183],{"type":24,"value":184},"完整功能支持：支持测量、采样、约化密度矩阵计算以及 Pauli 期望值估计。",{"type":18,"tag":40,"props":186,"children":187},{},[188],{"type":24,"value":189},"可调键维度：通过 max_bond_dimension 参数控制精度与效率的平衡。设为 0 时为精确模拟（无截断），设为正整数时可在精度与效率之间权衡。",{"type":18,"tag":26,"props":191,"children":192},{},[193],{"type":24,"value":194},"快速上手：",{"type":18,"tag":26,"props":196,"children":197},{},[198],{"type":24,"value":199},"使用 mqmps 后端只需在创建模拟器时指定后端名称，其余代码与 mqvector 完全一致。",{"type":18,"tag":201,"props":202,"children":204},"pre",{"code":203},"from mindquantum.simulator import Simulator\nfrom mindquantum.core.circuit import Circuit\nfrom mindquantum.core.gates import H, X, RY\nfrom mindquantum.core.operators import Hamiltonian, QubitOperator\n\n# 创建 MPS 模拟器（100 个量子比特）\nsim = Simulator('mqmps', 100, max_bond_dimension=64)\n\n# 构建量子线路：线性连接的变分结构\ncirc = Circuit()\nfor i inrange(100):\n  circ += RY(0.1* i).on(i)\nfor i inrange(99):\n  circ += X.on(i +1, i)\n\nsim.apply_circuit(circ)\n\n# 计算 Pauli 期望值\nham = Hamiltonian(QubitOperator('Z0 Z1') + QubitOperator('Z50 Z51'))\nexp = sim.get_expectation(ham)\nprint(f\"期望值: {exp}\")\n\n# 也支持约化密度矩阵（保留比特数不宜过多）\nrho = sim.get_reduced_density_matrix([0, 1])\nprint(f\"约化密度矩阵:\\n{rho}\")\n",[205],{"type":18,"tag":206,"props":207,"children":208},"code",{"__ignoreMap":7},[209],{"type":24,"value":203},{"type":18,"tag":107,"props":211,"children":213},{"id":212},"_02-qaia-算法族扩展量化模拟分叉算法-tsbusblsb",[214],{"type":24,"value":215},"02 QAIA 算法族扩展：量化模拟分叉算法 TSB/USB/LSB",{"type":18,"tag":26,"props":217,"children":218},{},[219],{"type":24,"value":220},"组合优化是量子计算最具近期实用价值的应用方向之一。MindSpore Quantum 0.12.0 为 QAIA（量子退火启发式算法）模块新增了三种量化模拟分叉（Quantized Simulated Bifurcation）变体：",{"type":18,"tag":61,"props":222,"children":223},{"style":63},[224],{"type":18,"tag":66,"props":225,"children":227},{"src":226,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/4.jpg",[],{"type":18,"tag":26,"props":229,"children":230},{},[231,233,238],{"type":24,"value":232},"三种新算法均支持 CPU，源自论文 ",{"type":18,"tag":80,"props":234,"children":235},{},[236],{"type":24,"value":237},"1",{"type":24,"value":239},"。其中 TSB 通过三元量化将乘累加运算简化为加减法，USB 和 LSB 则分别采用均匀量化和对数量化策略。论文指出，量化引入的随机性有助于系统跳出局部最优，在长搜索中获得更高质量的解，同时在短搜索中加速能量收敛。",{"type":18,"tag":26,"props":241,"children":242},{},[243],{"type":24,"value":244},"在全连接图 MaxCut 基准测试中，TSB 的 Time-to-Solution（TTS）相比 DSB 最高可达 2 倍加速，且随问题规模增大优势更加显著。",{"type":18,"tag":61,"props":246,"children":247},{"style":63},[248],{"type":18,"tag":66,"props":249,"children":251},{"src":250,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/5.jpg",[],{"type":18,"tag":26,"props":253,"children":254},{},[255],{"type":24,"value":256},"示例代码：",{"type":18,"tag":201,"props":258,"children":260},{"code":259},"import numpy as np\nfrom scipy.sparse import csr_matrix\nfrom mindquantum.algorithm.qaia import TSB, USB, LSB\n\n# 构建组合优化问题（随机对称耦合矩阵）\nnp.random.seed(42)\nN =1024\nJ = csr_matrix(np.random.randn(N, N).astype(np.float32))\nJ = (J + J.T) /2\nJ.setdiag(0)\n\n# 使用三元量化模拟分叉 (TSB)\nsolver = TSB(J, n_iter=500, batch_size=10, backend='cpu-float32',strategy='linear')\n# 支持 linear/exponential/logarithmic\n\nsolver.update()\nbest_energy = solver.calc_energy().min()\nprint(f\"TSB 最优能量: {best_energy:.2f}\")\n",[261],{"type":18,"tag":206,"props":262,"children":263},{"__ignoreMap":7},[264],{"type":24,"value":259},{"type":18,"tag":107,"props":266,"children":268},{"id":267},"_03-qpu硬件抽象层便捷对接真实量子计算机",[269],{"type":24,"value":270},"03 QPU：硬件抽象层，便捷对接真实量子计算机",{"type":18,"tag":26,"props":272,"children":273},{},[274],{"type":24,"value":275},"将量子算法从模拟器部署到真实硬件，往往意味着大量的代码重构。为了降低这一迁移成本，MindSpore Quantum 0.12.0 推出了QPU 抽象基类 —— 一套与 Simulator 接口风格统一的硬件抽象层。",{"type":18,"tag":61,"props":277,"children":278},{"style":63},[279],{"type":18,"tag":66,"props":280,"children":282},{"src":281,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/6.jpg",[],{"type":18,"tag":36,"props":284,"children":285},{},[286,291,296,301],{"type":18,"tag":40,"props":287,"children":288},{},[289],{"type":24,"value":290},"仅需实现 sampling() 方法：开发者只需编写一个调用目标硬件 SDK 的采样函数，即可将 MindSpore Quantum 与该硬件打通。期望值估计和梯度计算均由基类自动完成。",{"type":18,"tag":40,"props":292,"children":293},{},[294],{"type":24,"value":295},"基于采样的期望值估计：get_expectation() 自动执行 Pauli 基旋转并从测量结果中进行统计估计，用户无需手动处理测量基变换。",{"type":18,"tag":40,"props":297,"children":298},{},[299],{"type":24,"value":300},"基于采样的梯度估计：get_expectation_with_grad() 返回与模拟器完全兼容的 GradOpsWrapper，支持参数平移规则（Parameter-Shift Rule）和中心有限差分，覆盖 RX、RY、RZ、U3、Rxx、Ryy、Rzz 等 10+ 种参数化门族，并能智能地为每个参数选择最优策略。",{"type":18,"tag":40,"props":302,"children":303},{},[304],{"type":24,"value":305},"批量优化接口：可选择性重写 _sampling_batch() 以实现批量任务提交，进一步提升硬件利用率。",{"type":18,"tag":26,"props":307,"children":308},{},[309],{"type":24,"value":310},"在基于 Pauli Hamiltonian 的无测量变分线路等常见 VQE/QAOA 场景中，用户只需将 Simulator 替换为 QPU 子类实例，即可将算法迁移到真实量子硬件上运行。",{"type":18,"tag":26,"props":312,"children":313},{},[314],{"type":24,"value":315},"需要注意的是，当前 QPU 仅支持 QubitOperator 构建的 Hamiltonian，且不支持 circ_left/simulator_left 等高级用法；硬件拓扑约束和原生门编译需在子类中处理。",{"type":18,"tag":26,"props":317,"children":318},{},[319],{"type":24,"value":320},"快速上手：对接 Quafu 超导量子云平台",{"type":18,"tag":26,"props":322,"children":323},{},[324],{"type":24,"value":325},"以下示例对接北京量子信息科学研究院的 Quafu 平台，展示如何用 QPU 将 MindSpore Quantum 算法部署到真实量子硬件。整个对接只需实现一个 sampling() 方法，核心逻辑不到 20 行：",{"type":18,"tag":201,"props":327,"children":329},{"code":328},"from mindquantum.device import QPU\nfrom mindquantum.core.circuit import Circuit\nfrom mindquantum.core.gates import Measure\nfrom mindquantum.core.gates.measurement import MeasureResult\nfrom mindquantum.core.operators import QubitOperator, Hamiltonian\nfrom quafu import QuantumCircuit as QuafuCircuit, Task\nimport numpy as np\n\nclass QuafuQPU(QPU):    \n\"\"\"对接 Quafu 超导量子云平台的 QPU 子类。\"\"\"\n  def__init__(self, n_qubits, backend=\"ScQ-P136\", default_shots=4000, **kwargs): \n    super().__init__(n_qubits=n_qubits, default_shots=default_shots, **kwargs)\n    self.backend = backend \n    self._task = Task()\n    self._task.config(backend=backend, shots=default_shots, compile=True)   \n\n  def sampling(self, circuit, pr=None, shots=1, seed=None):        \n  # MindQuantum 线路 → OpenQASM → Quafu 线路 → 提交真机       \n    circ = circuit.apply_value(pr) if pr isnotNoneelse circuit     \n    if not circ.has_measure_gate: \n       circ = circ + Circuit([Measure(f'q{i}').on(i) for i inrange(circ.n_qubits)]) \n       qc = QuafuCircuit(circ.n_qubits)  \n       qc.from_openqasm(circ.to_openqasm())\n       self._task.config(backend=self.backend, shots=shots, compile=True) \n       res =self._task.send(qc) \n\n       # Quafu 计数结果 → MindQuantum MeasureResult（注意端序翻转） \n       mr = MeasureResult()\n       mr.add_measure([g for g in circ ifisinstance(g, Measure)]) \n       samples = []\n       for bitstr, count in res.counts.items(): \n       samples.extend([[int(b) for b inreversed(bitstr)]] * count)    \n       mr.collect_data(np.array(samples)) \n return mr\n",[330],{"type":18,"tag":206,"props":331,"children":332},{"__ignoreMap":7},[333],{"type":24,"value":328},{"type":18,"tag":26,"props":335,"children":336},{},[337],{"type":24,"value":338},"使用 QuafuQPU，在真实量子芯片上运行 Bell 态实验与使用模拟器几乎没有区别：",{"type":18,"tag":201,"props":340,"children":342},{"code":341},"# 创建 QPU 实例，连接 Quafu 136 比特超导芯片\nqpu = QuafuQPU(n_qubits=2, backend=\"ScQ-P136\", default_shots=4000)\n\n# Bell 态线路\ncirc = Circuit().h(0).x(1, 0)\nham = Hamiltonian(QubitOperator('Z0 Z1'))\n\n# 一行代码获得真机期望值 —— 接口与 Simulator 完全一致\nexp = qpu.get_expectation(ham, circ)\nprint(f\"真机={exp}\")  \n# 理论值 1.0，实际值因硬件噪声略有偏差\n\n# 同样支持参数化线路的梯度计算，可直接用于变分优化\nparam_circ = Circuit().ry('theta', 0).x(1, 0)\ngrad_ops = qpu.get_expectation_with_grad(ham, param_circ)\nf, g = grad_ops(np.array([0.5]))\nprint(f\"期望值: {f}, 梯度: {g}\")\n",[343],{"type":18,"tag":206,"props":344,"children":345},{"__ignoreMap":7},[346],{"type":24,"value":341},{"type":18,"tag":26,"props":348,"children":349},{},[350],{"type":24,"value":351},"MindSpore Quantum 通过 OpenQASM 作为中间表示与 Quafu 对接，无需手动转换线路格式。这一模式同样适用于其他支持 OpenQASM 的量子硬件平台 —— 只需替换sampling()中的 SDK 调用即可。",{"type":18,"tag":107,"props":353,"children":355},{"id":354},"_04-安装与升级指南",[356],{"type":24,"value":357},"04 安装与升级指南",{"type":18,"tag":26,"props":359,"children":360},{},[361],{"type":24,"value":362},"安装MindSpore Quantum 0.12.0:",{"type":18,"tag":201,"props":364,"children":366},{"code":365},"pip install mindquantum==0.12.0\n",[367],{"type":18,"tag":206,"props":368,"children":369},{"__ignoreMap":7},[370],{"type":24,"value":365},{"type":18,"tag":26,"props":372,"children":373},{},[374],{"type":24,"value":375},"从旧版本升级:",{"type":18,"tag":201,"props":377,"children":379},{"code":378},"pip install --upgrade mindquantum==0.12.0\n",[380],{"type":18,"tag":206,"props":381,"children":382},{"__ignoreMap":7},[383],{"type":24,"value":378},{"type":18,"tag":26,"props":385,"children":386},{},[387],{"type":24,"value":388},"温馨提示：",{"type":18,"tag":36,"props":390,"children":391},{},[392,397],{"type":18,"tag":40,"props":393,"children":394},{},[395],{"type":24,"value":396},"使用 mqmps 后端无需额外依赖，开箱即用。",{"type":18,"tag":40,"props":398,"children":399},{},[400],{"type":24,"value":401},"使用 QPU 需要安装目标量子硬件平台的 SDK。",{"type":18,"tag":107,"props":403,"children":405},{"id":404},"_05-结语",[406],{"type":24,"value":407},"05 结语",{"type":18,"tag":26,"props":409,"children":410},{},[411],{"type":24,"value":412},"MindSpore Quantum 0.12.0 在模拟能力、算法丰富度和硬件对接三方面迈出重要一步：",{"type":18,"tag":36,"props":414,"children":415},{},[416,421,426],{"type":18,"tag":40,"props":417,"children":418},{},[419],{"type":24,"value":420},"mqmps 为低纠缠、大比特数场景提供全新解决方案；",{"type":18,"tag":40,"props":422,"children":423},{},[424],{"type":24,"value":425},"QAIA 量化模拟分叉算法为组合优化提供更灵活的工具；",{"type":18,"tag":40,"props":427,"children":428},{},[429],{"type":24,"value":430},"QPU 接口为真实硬件部署提供统一编程入口。",{"type":18,"tag":26,"props":432,"children":433},{},[434],{"type":24,"value":435},"本版本还包含多项改进与问题修复（子模块导入错误提示优化、MQSABRE 映射修复、OpenQASM 增强等）。",{"type":18,"tag":26,"props":437,"children":438},{},[439],{"type":24,"value":440},"衷心感谢所有贡献代码与建议的开发者！欢迎广大用户下载体验新版本，并随时通过社区向我们反馈宝贵的意见和建议。",{"type":18,"tag":61,"props":442,"children":443},{"style":63},[444],{"type":18,"tag":66,"props":445,"children":447},{"src":446,"style":69,"alt":7},"/category/information/technology-blogs/banner/2026-5-7/7.jpg",[],{"type":18,"tag":449,"props":450,"children":451},"blockquote",{},[452],{"type":18,"tag":449,"props":453,"children":454},{},[455],{"type":18,"tag":26,"props":456,"children":457},{},[458],{"type":24,"value":459},"点击【阅读原文】查阅完整 Release Notes。",{"type":18,"tag":26,"props":461,"children":462},{},[463,465,469],{"type":24,"value":464},"参考文献\n",{"type":18,"tag":80,"props":466,"children":467},{},[468],{"type":24,"value":237},{"type":24,"value":470}," T. Zhang and J. Han, “Quantized Simulated Bifurcation for the Ising Model,” in 2023 IEEE 23rd International Conference on Nanotechnology (NANO), Jeju City, Korea, 2023, doi: 10.1109/NANO58406.2023.10231308.",{"title":7,"searchDepth":472,"depth":472,"links":473},4,[474,476,477,478,479],{"id":109,"depth":475,"text":112},2,{"id":212,"depth":475,"text":215},{"id":267,"depth":475,"text":270},{"id":354,"depth":475,"text":357},{"id":404,"depth":475,"text":407},"markdown","content:technology-blogs:zh:2026-5-7.md","content","technology-blogs/zh/2026-5-7.md","technology-blogs/zh/2026-5-7","md",1778320643066]