量子隐形传态(Quantum Teleportation)
利用纠缠、经典通信以及包含中途测量和条件校正的动态电路,将未知量子态从一个量子比特传送到另一个量子比特。
问题
什么是量子隐形传态?
量子隐形传态是一种协议,使用两个经典比特和一个共享Bell对,将未知量子态从一个位置(Alice)传送到另一个位置(Bob)。尽管名称如此,并没有物质或能量被传输——只有量子信息。
该协议由 Bennett、Brassard、Crepeau、Jozsa、Peres 和 Wootters 于 1993 年提出,并已在从厘米到超过 1,000 公里的距离上(使用墨子号卫星)进行了实验演示。
Alice 持有一个处于未知态的量子比特:
协议完成后,Bob 持有一个处于完全相同态
不可克隆定理(No-Cloning Theorem)
一个自然的问题是:我们能否简单地复制量子态?不可克隆定理证明未知量子态无法被完美复制。不存在酉操作
反证法。 假设这样的
对两边取内积:
这仅在
隐形传态绕过了不可克隆定理,因为原始态在测量过程中被销毁。信息被转移,而非复制。
graph TD
A["Unknown state |psi> = alpha|0> + beta|1>"] --> B{"Can we copy it?"}
B -->|"No-Cloning Theorem"| C["Cannot clone unknown quantum states"]
B -->|"Teleportation"| D["Transfer (destroy original)"]
D --> E["Alice measures her qubits"]
E --> F["Sends 2 classical bits"]
F --> G["Bob applies correction"]
G --> H["Bob now holds |psi>"]
style C fill:#FFCDD2
style H fill:#C8E6C9为什么量子隐形传态很重要?
量子隐形传态不仅仅是理论上的奇观。它是以下领域的基础构件:
- 量子通信。 隐形传态使得量子密钥分发和用于长距离量子通信的量子中继网络成为可能。
- 量子计算架构。 在模块化和分布式量子计算机中,隐形传态在处理节点之间移动量子信息。
- 门传态。 某些量子门(特别是容错计算中的 T 门)通过使用特制资源态的传态实现。
- 量子纠错。 表面码的格点缝合使用基于传态的态注入和逻辑门操作。
- 基础物理。 隐形传态已被用于演示量子非局域性,并在越来越大的距离尺度上测试量子力学。
graph TD
T["Quantum Teleportation"] --> A["Quantum Repeaters"]
T --> B["Distributed QC"]
T --> C["Gate Teleportation"]
T --> D["Error Correction"]
T --> E["Quantum Networking"]
style T fill:#1565C0,color:#fff
style A fill:#42A5F5,color:#fff
style B fill:#42A5F5,color:#fff
style C fill:#42A5F5,color:#fff
style D fill:#42A5F5,color:#fff
style E fill:#42A5F5,color:#fff方案
协议概述
隐形传态协议使用三个量子比特和两个经典比特:
| 量子比特 | 角色 | 持有者 |
|---|---|---|
| 要传态的未知态 | Alice | |
| Alice 的Bell对份额 | Alice | |
| Bob 的Bell对份额 | Bob |
协议有五个步骤:
- 制备未知态
在 上。 - 创建Bell对在
和 之间:对 施加 H,然后以 为控制、 为目标施加 CNOT。 - Bell测量 Alice 的量子比特(
, ):以 为控制、 为目标施加 CNOT,然后对 施加 H,然后测量两者到经典比特。 - 发送两个经典测量结果
给 Bob。 - 条件校正在
上:施加 。
校正后,
flowchart TD
subgraph Step1["Step 1: Prepare"]
A1["|psi> on q0"]
end
subgraph Step2["Step 2: Bell Pair"]
A2["H(q1)"]
A3["CNOT(q1, q2)"]
A2 --> A3
end
subgraph Step3["Step 3: Bell Measurement"]
A4["CNOT(q0, q1)"]
A5["H(q0)"]
A6["Measure q0 -> c0"]
A7["Measure q1 -> c1"]
A4 --> A5 --> A6
A5 --> A7
end
subgraph Step4["Step 4: Classical Channel"]
A8["Send (c0, c1) to Bob"]
end
subgraph Step5["Step 5: Conditional Correction"]
A9["qif c0: Z(q2)"]
A10["qif c1: X(q2)"]
A9 --> A10
end
Step1 --> Step2 --> Step3 --> Step4 --> Step5
style Step1 fill:#E3F2FD
style Step2 fill:#E8F5E9
style Step3 fill:#FFF3E0
style Step4 fill:#F3E5F5
style Step5 fill:#FFEBEE校正表
测量结果决定了 Bob 必须施加的校正:
| Bob 的校正 | 概率 | ||
|---|---|---|---|
| 0 | 0 | 恒等操作( | 1/4 |
| 0 | 1 | 1/4 | |
| 1 | 0 | 1/4 | |
| 1 | 1 | 1/4 |
每种结果以等概率 1/4 出现,与输入态
电路图
flowchart LR
subgraph Qubits
Q0["q0: |psi>"]
Q1["q1: |0>"]
Q2["q2: |0>"]
end
subgraph BellPair["Create Bell Pair"]
H1["H"]
CX1["CNOT"]
end
subgraph BellMeas["Bell Measurement"]
CX2["CNOT"]
H2["H"]
M0["Measure -> c0"]
M1["Measure -> c1"]
end
subgraph Correction["Conditional"]
CZ["qif c0: Z(q2)"]
CX3["qif c1: X(q2)"]
end
Q0 --> CX2 --> H2 --> M0
Q1 --> CX2
Q1 --> CX1
H1 --> CX1
Q2 --> CX1
M0 --> CZ --> CX3
M1 --> CZ
Q2 --> CZ
Q2 --> CX3
CX3 --> Result["q2 = |psi>"]为什么需要动态电路
隐形传态需要中途测量和条件门应用。校正操作依赖于运行时才能知道的测量结果。这从根本上不同于所有门都预先固定的静态电路。
pyqpanda3 提供了 qif 构造专门用于此目的:
from pyqpanda3 import core
# Measure a qubit, then conditionally apply a gate
prog = core.QProg()
prog << core.measure(0, 0) # Measure q0 -> cbit 0
correction = core.QProg()
correction << core.Z(1) # Apply Z to q1 if cbit[0] == 1
no_op = core.QProg() # Do nothing otherwise
prog << core.qif([0]).then(correction).qelse(no_op)代码
传态已知态
最简单的验证:传态
from pyqpanda3 import core
# Qubit layout:
# q0: the state |psi> = |1> to teleport
# q1: Alice's half of the Bell pair
# q2: Bob's half of the Bell pair (receives |psi>)
prog = core.QProg()
# Step 1: Prepare |psi> = |1> on q0
prog << core.X(0)
# Step 2: Create Bell pair between q1 and q2
prog << core.H(1)
prog << core.CNOT(1, 2)
# Step 3: Bell measurement on (q0, q1)
prog << core.CNOT(0, 1)
prog << core.H(0)
prog << core.measure(0, 0) # m0 -> cbit 0
prog << core.measure(1, 1) # m1 -> cbit 1
# Step 4: Bob's conditional corrections using qif
# If m0 == 1, apply Z to q2
z_correction = core.QProg()
z_correction << core.Z(2)
no_z = core.QProg()
prog << core.qif([0]).then(z_correction).qelse(no_z)
# If m1 == 1, apply X to q2
x_correction = core.QProg()
x_correction << core.X(2)
no_x = core.QProg()
prog << core.qif([1]).then(x_correction).qelse(no_x)
# Step 5: Measure Bob's qubit to verify
prog << core.measure(2, 2)
# Run the circuit
machine = core.CPUQVM()
machine.run(prog, shots=10000)
counts = machine.result().get_counts()
print("Teleportation of |1> results:", counts)
# Extract just Bob's measurement outcome (qubit 2)
# get_counts() returns strings in big-endian order: cbit2 cbit1 cbit0
bob_1 = sum(v for k, v in counts.items() if k[0] == '1')
bob_0 = sum(v for k, v in counts.items() if k[0] == '0')
print(f"Bob's qubit: |0> = {bob_0}, |1> = {bob_1}")
print(f"Fidelity: {bob_1 / (bob_0 + bob_1):.4f}")运行结果:
Teleportation of |1> results: {'100': 2494, '101': 2495, '110': 2515, '111': 2496}
Bob's qubit: |0> = 0, |1> = 10000
Fidelity: 1.0000预期输出(计数因采样噪声略有变化,但保真度始终为 1.0000):
Teleportation of |1> results: {'100': ~2500, '101': ~2500, '110': ~2500, '111': ~2500}
Bob's qubit: |0> = 0, |1> = 10000
Fidelity: 1.0000所有四种测量模式以大约相等的概率(各 1/4)出现,且 Bob 的量子比特(最左边的比特 cbit2)始终为 1,确认了完美的传态。
传态任意态 RY(theta)|0>
为演示协议对任何态(不仅仅是计算基态)都有效,我们传态
from pyqpanda3 import core
import numpy as np
theta = 0.7 # Arbitrary angle in radians
# Build the teleportation circuit for RY(theta)|0>
prog = core.QProg()
# Step 1: Prepare |psi> = RY(theta)|0> on q0
prog << core.RY(0, theta)
# Step 2: Bell pair between q1 and q2
prog << core.H(1)
prog << core.CNOT(1, 2)
# Step 3: Bell measurement on (q0, q1)
prog << core.CNOT(0, 1)
prog << core.H(0)
prog << core.measure(0, 0)
prog << core.measure(1, 1)
# Step 4: Conditional corrections on q2
z_corr = core.QProg()
z_corr << core.Z(2)
no_z = core.QProg()
prog << core.qif([0]).then(z_corr).qelse(no_z)
x_corr = core.QProg()
x_corr << core.X(2)
no_x = core.QProg()
prog << core.qif([1]).then(x_corr).qelse(no_x)
# Final measurement of Bob's qubit
prog << core.measure(2, 2)
# Run the teleportation
machine = core.CPUQVM()
machine.run(prog, shots=50000)
counts = machine.result().get_counts()
# Compute the probability that Bob measures |1>
# get_counts() returns strings in big-endian order: cbit2 cbit1 cbit0
bob_1 = sum(v for k, v in counts.items() if k[0] == '1')
bob_0 = sum(v for k, v in counts.items() if k[0] == '0')
total = bob_0 + bob_1
measured_prob_1 = bob_1 / total
# Theoretical probability
expected_prob_1 = np.sin(theta / 2) ** 2
print(f"Theta: {theta}")
print(f"Expected P(|1>): {expected_prob_1:.6f}")
print(f"Measured P(|1>): {measured_prob_1:.6f}")
print(f"Error: {abs(measured_prob_1 - expected_prob_1):.6f}")运行结果:
Theta: 0.7
Expected P(|1>): 0.117579
Measured P(|1>): 0.119220
Error: 0.001641预期输出(理论上):
Theta: 0.7
Expected P(|1>): 0.117579
Measured P(|1>): 0.117579
Error: 0.000000测量的概率与理论值密切匹配。微小的差异来自有限采样的统计噪声,随着采样次数增加而减小。
使用状态向量比较验证保真度
为进行更精确的验证,我们使用状态向量内积将传态后的态与原始态直接比较。运行两次模拟:一次用于原始态,一次用于传态后的态(目标量子比特不测量)。
from pyqpanda3 import core
import numpy as np
theta = 1.23 # Arbitrary angle
# --- Reference: prepare the original state on a single qubit ---
ref_prog = core.QProg()
ref_prog << core.RY(0, theta)
ref_machine = core.CPUQVM()
ref_machine.run(ref_prog, shots=1)
ref_sv = ref_machine.result().get_state_vector()
# The original state on qubit 0
original_state = np.array(ref_sv[:2]) # |00> and |01> amplitudes
original_state = original_state / np.linalg.norm(original_state)
# --- Teleportation: prepare and transfer ---
# We run the unitary part (no measurement, no correction) and then
# check each branch separately using the statevector.
# For an exact fidelity check, use DensityMatrixSimulator (see below).
# Prepare the full teleportation unitary (Steps 1-3, no measurement)
unitary_prog = core.QProg()
unitary_prog << core.RY(0, theta)
unitary_prog << core.H(1)
unitary_prog << core.CNOT(1, 2)
unitary_prog << core.CNOT(0, 1)
unitary_prog << core.H(0)
unitary_machine = core.CPUQVM()
unitary_machine.run(unitary_prog, shots=1)
teleport_sv = unitary_machine.result().get_state_vector()
# The 8-amplitude state vector uses big-endian ordering (q2 q1 q0):
# teleport_sv[i] = amplitude of |q2 q1 q0> where i = q2*4 + q1*2 + q0
# After Bell measurement, for (m0,m1) = (0,0): q2 should be in |psi>.
# Indices where q0=0, q1=0: |000> (idx 0) and |100> (idx 4).
# Extract Bob's uncorrected state for measurement outcome (0,0)
bob_uncorrected_00 = np.array([teleport_sv[0], teleport_sv[4]])
bob_uncorrected_00 = bob_uncorrected_00 / np.linalg.norm(bob_uncorrected_00)
# Fidelity for branch (0,0): no correction needed
fidelity_00 = abs(np.dot(np.conj(original_state), bob_uncorrected_00)) ** 2
print(f"Fidelity for branch (0,0): {fidelity_00:.10f}")
print(f"Perfect teleportation: {abs(fidelity_00 - 1.0) < 1e-10}")运行结果:
Fidelity for branch (0,0): 1.0000000000
Perfect teleportation: True预期输出:
Fidelity for branch (0,0): 1.0000000000
Perfect teleportation: True使用 DensityMatrixSimulator 精确计算保真度
DensityMatrixSimulator 提供了无采样噪声的精确分析方法来分析传态后的态。我们计算完整协议后 Bob 量子比特的密度矩阵并与理想态比较。
from pyqpanda3 import core
import numpy as np
theta = 0.85
# Step 1: Compute the ideal target density matrix.
alpha = np.cos(theta / 2)
beta = np.sin(theta / 2)
psi_ideal = np.array([alpha, beta])
# Step 2: Run teleportation with deferred measurement.
# 使用量子控制门(延迟测量原理)替代经典条件校正 qif。
prog = core.QProg()
prog << core.RY(0, theta)
prog << core.H(1)
prog << core.CNOT(1, 2)
prog << core.CNOT(0, 1)
prog << core.H(0)
prog << core.CZ(0, 2) # Z 校正(延迟测量)
prog << core.CNOT(1, 2) # X 校正(延迟测量)
prog << core.measure(0, 0)
prog << core.measure(1, 1)
dm_sim = core.DensityMatrixSimulator()
dm_sim.run(prog)
# Step 3: Get the reduced density matrix for Bob's qubit (qubit 2)
rho_bob = dm_sim.reduced_density_matrix([2])
# Step 4: Compute fidelity.
fidelity = np.real(psi_ideal.conj() @ rho_bob @ psi_ideal)
print(f"Target state: cos({theta}/2)|0> + sin({theta}/2)|1>")
print(f"alpha = {alpha:.6f}, beta = {beta:.6f}")
print(f"Bob's reduced density matrix:\n{rho_bob}")
print(f"Teleportation fidelity: {fidelity:.10f}")
print(f"Perfect fidelity: {abs(fidelity - 1.0) < 1e-8}")运行结果:
Target state: cos(0.85/2)|0> + sin(0.85/2)|1>
alpha = 0.911039, beta = 0.412321
Bob's reduced density matrix:
[[0.82999157+0.j 0.3756402 +0.j]
[0.3756402 +0.j 0.17000843+0.j]]
Teleportation fidelity: 1.0000000000
Perfect fidelity: True预期输出:
Target state: cos(0.85/2)|0> + sin(0.85/2)|1>
alpha = 0.911039, beta = 0.412321
Bob's reduced density matrix:
[[0.82999157+0.j 0.3756402 +0.j]
[0.3756402 +0.j 0.17000843+0.j]]
Teleportation fidelity: 1.0000000000
Perfect fidelity: TrueBob 量子比特的约化密度矩阵精确匹配
带噪声模拟的隐形传态
真实量子硬件会通过门缺陷、退相干和测量噪声引入误差。本示例模拟具有真实去极化噪声的隐形传态并量化保真度退化。
from pyqpanda3 import core
import numpy as np
theta = 0.85
alpha = np.cos(theta / 2)
beta = np.sin(theta / 2)
psi_ideal = np.array([alpha, beta])
def teleport_reduced_state(theta):
"""Run ideal teleportation and return Bob's reduced density matrix."""
prog = core.QProg()
prog << core.RY(0, theta)
prog << core.H(1) << core.CNOT(1, 2)
prog << core.CNOT(0, 1) << core.H(0)
prog << core.CZ(0, 2) << core.CNOT(1, 2)
prog << core.measure(0, 0) << core.measure(1, 1)
dm = core.DensityMatrixSimulator()
dm.run(prog)
return dm.reduced_density_matrix([2])
# --- Ideal teleportation ---
rho_ideal = teleport_reduced_state(theta)
# --- Apply depolarizing noise analytically ---
# We model the cumulative effect of gate errors: each gate with error
# rate p depolarizes the state slightly. The net effect on Bob's qubit
# is a mixture of the ideal state and the maximally mixed state I/2.
p_h = 0.01 # 1% depolarizing on single-qubit gates
p_cnot = 0.02 # 2% depolarizing on two-qubit gates
n_h = 3 # number of H gates affecting Bob's state
n_cnot = 2 # number of CNOT gates affecting Bob's state
survival = (1 - p_h) ** n_h * (1 - p_cnot) ** n_cnot
rho_noisy = survival * rho_ideal + (1 - survival) * np.eye(2) / 2
# Compute fidelity for both
fid_ideal = np.real(psi_ideal.conj() @ rho_ideal @ psi_ideal)
fid_noisy = np.real(psi_ideal.conj() @ rho_noisy @ psi_ideal)
print(f"Ideal teleportation fidelity: {fid_ideal:.6f}")
print(f"Noisy teleportation fidelity: {fid_noisy:.6f}")
print(f"Fidelity loss due to noise: {fid_ideal - fid_noisy:.6f}")
# Compare purity of Bob's qubit in both cases
purity_ideal = np.trace(rho_ideal @ rho_ideal).real
purity_noisy = np.trace(rho_noisy @ rho_noisy).real
print(f"\nBob's qubit purity (ideal): {purity_ideal:.6f}")
print(f"Bob's qubit purity (noisy): {purity_noisy:.6f}")运行结果:
Ideal teleportation fidelity: 1.000000
Noisy teleportation fidelity: 0.965938
Fidelity loss due to noise: 0.034062
Bob's qubit purity (ideal): 1.000000
Bob's qubit purity (noisy): 0.934196预期输出:
Ideal teleportation fidelity: 1.000000
Noisy teleportation fidelity: 0.965938
Fidelity loss due to noise: 0.034062
Bob's qubit purity (ideal): 1.000000
Bob's qubit purity (noisy): 0.934196噪声使保真度低于 1.0 并在 Bob 的量子比特中引入混合性(纯度 < 1)。具体值取决于噪声模型参数。
比较不同噪声信道
不同物理误差机制对传态保真度的影响不同。本示例施加几种噪声信道并测量影响。
from pyqpanda3 import core
import numpy as np
theta = 1.0
alpha = np.cos(theta / 2)
beta = np.sin(theta / 2)
psi_ideal = np.array([alpha, beta])
def teleport_ideal_rho(theta):
"""Run ideal teleportation and return Bob's reduced density matrix."""
prog = core.QProg()
prog << core.RY(0, theta)
prog << core.H(1) << core.CNOT(1, 2)
prog << core.CNOT(0, 1) << core.H(0)
prog << core.CZ(0, 2) << core.CNOT(1, 2)
prog << core.measure(0, 0) << core.measure(1, 1)
dm = core.DensityMatrixSimulator()
dm.run(prog)
return dm.reduced_density_matrix([2])
rho_ideal = teleport_ideal_rho(theta)
# Define noise channels as functions on a 2x2 density matrix
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)
def apply_bit_flip(rho, p):
return (1 - p) * rho + p * X @ rho @ X
def apply_phase_flip(rho, p):
return (1 - p) * rho + p * Z @ rho @ Z
def apply_depolarizing(rho, p):
return (1 - 3 * p / 4) * rho + (p / 4) * (X @ rho @ X + Y @ rho @ Y + Z @ rho @ Z)
def apply_amp_damping(rho, gamma):
E0 = np.array([[1, 0], [0, np.sqrt(1 - gamma)]], dtype=complex)
E1 = np.array([[0, np.sqrt(gamma)], [0, 0]], dtype=complex)
return E0 @ rho @ E0.conj().T + E1 @ rho @ E1.conj().T
def apply_phase_damping(rho, lam):
E0 = np.array([[1, 0], [0, np.sqrt(1 - lam)]], dtype=complex)
E1 = np.array([[0, 0], [0, np.sqrt(lam)]], dtype=complex)
return E0 @ rho @ E0.conj().T + E1 @ rho @ E1.conj().T
# Apply each channel to Bob's reduced density matrix
error_rate = 0.03
n_single = 4 # approximate number of single-qubit gates in the circuit
n_two = 2 # approximate number of two-qubit gates
p_eff = 1 - (1 - error_rate) ** (n_single + n_two)
channels = {
"No noise": lambda r: r,
"Bit Flip (X)": lambda r: apply_bit_flip(r, p_eff),
"Phase Flip (Z)": lambda r: apply_phase_flip(r, p_eff),
"Depolarizing": lambda r: apply_depolarizing(r, p_eff),
"Amplitude Damping": lambda r: apply_amp_damping(r, p_eff),
"Phase Damping": lambda r: apply_phase_damping(r, p_eff),
}
print(f"{'Channel':<22s} {'Fidelity':>8s}")
print("-" * 35)
for name, channel in channels.items():
rho_noisy = channel(rho_ideal)
fid = np.real(psi_ideal.conj() @ rho_noisy @ psi_ideal)
print(f"{name:<22s} {fid:>8.4f}")运行结果:
Channel Fidelity
-----------------------------------
No noise 1.0000
Bit Flip (X) 0.9512
Phase Flip (Z) 0.8817
Depolarizing 0.9165
Amplitude Damping 0.9898
Phase Damping 0.9691预期输出(近似):
Channel Fidelity
-----------------------------------
No noise 1.0000
Bit Flip (X) 0.9512
Phase Flip (Z) 0.8817
Depolarizing 0.9165
Amplitude Damping 0.9898
Phase Damping 0.9691主要观察:
- 去极化噪声最具破坏性,因为它同时施加了 X、Y 和 Z 误差的组合。
- 相位阻尼和相位翻转对传态保真度具有相同的效果,因为两者都引入通过 CNOT 门传播的 Z 类误差。
- 振幅阻尼具有不对称性:它优先驱动
向 ,偏置测量结果。
扫描多个角度
通过在一系列
from pyqpanda3 import core
import numpy as np
def run_teleportation(theta, shots=10000):
"""Run teleportation of RY(theta)|0> and return Bob's |1> probability."""
prog = core.QProg()
prog << core.RY(0, theta)
prog << core.H(1)
prog << core.CNOT(1, 2)
prog << core.CNOT(0, 1)
prog << core.H(0)
prog << core.measure(0, 0)
prog << core.measure(1, 1)
z_corr = core.QProg()
z_corr << core.Z(2)
no_z = core.QProg()
prog << core.qif([0]).then(z_corr).qelse(no_z)
x_corr = core.QProg()
x_corr << core.X(2)
no_x = core.QProg()
prog << core.qif([1]).then(x_corr).qelse(no_x)
prog << core.measure(2, 2)
machine = core.CPUQVM()
machine.run(prog, shots=shots)
counts = machine.result().get_counts()
# get_counts() returns strings in big-endian order: cbit2 cbit1 cbit0
bob_1 = sum(v for k, v in counts.items() if k[0] == '1')
return bob_1 / shots
print(f"{'theta':>6s} {'Expected':>10s} {'Measured':>10s} {'Error':>10s}")
print("-" * 44)
for theta in np.linspace(0, np.pi, 10):
expected = np.sin(theta / 2) ** 2
measured = run_teleportation(theta)
error = abs(measured - expected)
print(f"{theta:>6.3f} {expected:>10.6f} {measured:>10.6f} {error:>10.6f}")运行结果:
theta Expected Measured Error
--------------------------------------------
0.000 0.000000 0.000000 0.000000
0.349 0.030154 0.030600 0.000446
0.698 0.116978 0.122900 0.005922
1.047 0.250000 0.253100 0.003100
1.396 0.413176 0.412200 0.000976
1.745 0.586824 0.587000 0.000176
2.094 0.750000 0.745200 0.004800
2.443 0.883022 0.880700 0.002322
2.793 0.969846 0.971300 0.001454
3.142 1.000000 1.000000 0.000000预期输出(每次运行因采样噪声略有差异,误差通常在 0.01 以内):
theta Expected Measured Error
--------------------------------------------
0.000 0.000000 0.000000 0.000000
0.349 0.030154 ~0.030 ~0.001
0.698 0.116978 ~0.117 ~0.005
1.047 0.250000 ~0.250 ~0.005
1.396 0.413176 ~0.413 ~0.005
1.745 0.586824 ~0.587 ~0.005
2.094 0.750000 ~0.750 ~0.005
2.443 0.883022 ~0.883 ~0.005
2.793 0.969846 ~0.970 ~0.002
3.142 1.000000 1.000000 0.000000测量的概率在整个
解析
数学推导
三量子比特初始态(步骤 1 和 2 之后)为:
代入
在三个量子比特的计算基中展开:
CNOT(0, 1) 之后
以
注意:
H(0) 之后
对
按量子比特
这是关键分解。对于每个测量结果
Bell基分解
Bell测量后的态可以简洁地写为:
这个优美的表达式表明:
- 测量结果
均匀随机:每个以概率 出现。 - 对于每个结果,Bob 的量子比特恰好是
,可以通过施加 (利用 )校正回 。 - 校正
始终是 Pauli 算子,实现效率高。
flowchart TD
A["|psi> x |Phi+>"] --> B["CNOT(q0,q1)"]
B --> C["H(q0)"]
C --> D{"Measure (m0,m1)"}
D -->|"00"| E["q2 = |psi> (no correction)"]
D -->|"01"| F["q2 = X|psi> (apply Z)"]
D -->|"10"| G["q2 = Z|psi> (apply X)"]
D -->|"11"| H["q2 = ZX|psi> (apply XZ)"]
E --> I["q2 = |psi>"]
F --> I
G --> I
H --> I
style D fill:#FF9800,color:#fff
style I fill:#4CAF50,color:#fff详细校正推导
让我们显式验证每个分支。
分支
无需校正。Bob 已经持有
分支
Bob 施加
分支
Bob 施加
分支
Bob 依次施加
由于
这给出
更为简洁。
完整校正表:
| Bob 的态 | 校正 | 结果 | |
|---|---|---|---|
| (0, 0) | |||
| (0, 1) | |||
| (1, 0) | |||
| (1, 1) |
资源分析
隐形传态协议需要:
| 资源 | 数量 |
|---|---|
| 量子比特 | 3(1 个数据 + 2 个Bell对) |
| 纠缠门(CNOT) | 2(1 个用于Bell对 + 1 个用于Bell测量) |
| 单量子比特门 | 2(Bell对的 Hadamard + 测量的 Hadamard) |
| 测量 | 2(中途测量) |
| 发送的经典比特 | 2 |
| 条件门 | 最多 2(一个 Z,一个 X) |
| 总电路深度 | ~5 层 |
电路深度是恒定的(不随传态态的复杂性而变化),使得传态对任何输入态都高效。
为什么原始态被销毁
不可克隆定理保证
形式上,测量
与Bell态的联系
隐形传态协议依赖共享Bell对
| 使用的Bell态 | 校正表 |
|---|---|
| 如上(标准) | |
| 当 | |
| 当 | |
| 两个交换组合 |
Bell态必须在协议开始前共享。在实践中,这意味着:
- Alice 创建Bell对并将一个量子比特发送给 Bob(量子通信)
- 第三方创建Bell对并向各方分发一个量子比特
- Bell对由量子网络节点生成
纠缠作为资源
隐形传态消耗一个单位的纠缠(一个 ebit,由纠缠熵
graph LR
A["1 ebit<br/>(Bell pair)"] --> C["Teleportation<br/>Protocol"]
B["2 classical bits"] --> C
C --> D["1 qubit<br/>transferred"]
style A fill:#E3F2FD
style B fill:#FFF3E0
style D fill:#E8F5E9这种权衡是最优的:不可能用少于一个 ebit 和两个经典比特来传态一个量子比特。这是因为:
- 一个 ebit 是必要的,因为无纠缠时,无通信定理禁止仅通过经典信道传输量子信息。
- 两个经典比特是必要的,因为 Alice 的Bell测量有四个等概率结果,Bob 需要区分所有四种以施加正确的 Pauli 校正。
实用技巧
1. 先用已知态验证。 在传态未知态之前,用
2. 使用 DensityMatrixSimulator 调试。 当 CPUQVM 结果看起来不正确时,切换到 DensityMatrixSimulator 检查 Bob 量子比特的精确密度矩阵。这消除了调试过程中的采样噪声。
3. 检查校正顺序。 校正必须以
4. 真实地建模硬件噪声。 对于硬件预测,使用逐门、逐量子比特的噪声模型,误差率来自校准数据。典型超导硬件的单量子比特门误差为 0.05-0.1%,双量子比特门误差为 0.5-2%。
5. 隐形传态电路是良好的硬件基准。 在真实硬件上运行传态并测量输出保真度可直接评估纠缠门质量、读出保真度和整体系统相干性。保真度低于 ~0.8 通常表明存在显著硬件问题。
6. 动态电路必不可少。 隐形传态无法作为静态电路实现,因为校正依赖于测量结果。在 pyqpanda3 中,使用 qif 进行条件 Pauli 校正,如上述代码示例所示。