跳转至

Fock 后端模拟器原理总结报告

作者: TuringQ 技术团队 创建日期: 2026-01-19 版本: 1.0 框架: DeepQuantum 4.4.0


目录

  1. 概述
  2. Fock 态的数学表示
  3. 量子态的操作与演化
  4. 测量机制
  5. 关键数学公式
  6. 应用场景
  7. 参考资料

1. 概述

1.1 定义与用途

Fock 后端模拟器 是光量子计算中基于光子数态(Fock States)表示的量子态模拟系统。它通过离散化光子数空间,将连续变量光量子系统转换为有限维 Hilbert 空间中的计算问题。

核心特征: - 状态空间: 基于 Fock 态基矢 \(\{|n_1, n_2, \ldots, n_m\rangle\}\) 构建的 Hilbert 空间 - 截断维度: 每个模式的光子数 \(n\) 被截断在 \([0, N_{\text{cutoff}})\) 范围内 - 张量表示: 量子态表示为多维张量 \(\psi_{n_1,n_2,\ldots,n_m}\) - 精确模拟: 能够模拟光子数分辨级别的量子态演化

1.2 在光量子计算中的地位

graph TD
    A["光量子计算模拟器"] --> B["Gaussian 后端"]
    A --> C["Fock 后端"]
    A --> D["Bosonic 后端"]

    B --> E["高斯态 |ψₐ⟩"]
    B --> F["协方差矩阵 σ"]
    B --> G["一阶矩 ⟨x̂⟩"]

    C --> H["光子数态 |n₁,n₂,...,nₘ⟩"]
    C --> I["态矢量张量 ψ"]
    C --> J["Fock 空间截断"]

    D --> K["Bosonic 算符"]
    D --> L["相空间表示"]

    C --> M["优势:<br/>- 精确模拟非高斯操作<br/>- 光子数分辨测量<br/>- 小规模系统高精度"]

    style C fill:#90EE90
    style H fill:#FFD700
    style I fill:#FFD700
    style J fill:#FFD700

Fock 后端的独特优势

  1. 非高斯操作: 可以模拟 Kerr、立方相位等非高斯门
  2. 精确测量: 支持光子数分辨测量(PNRD)
  3. 通用性: 理论上可通用量子计算(KLM 方案)
  4. 教育价值: 直观展示光量子比特的离散特性

适用规模: - 小规模: ≤ 4 模式,cutoff ≤ 5(约 \(5^4 = 625\) 维) - 中等规模: 5-8 模式,cutoff ≤ 3(约 \(3^8 = 6561\) 维) - 大规模: 需结合 MPS 压缩或张量网络技术

1.3 与其他后端的对比

特性 Fock 后端 Gaussian 后端 Bosonic 后端
状态表示 Fock 态张量 \(\psi\) 协方差矩阵 \(\Sigma\) Bosonic 算符
适用操作 所有量子门 仅高斯操作 通用操作
测量方式 PNRD、阈值、同位 同位、Homonodyne 通用测量
计算复杂度 指数级 \(O(N_{\text{cutoff}}^m)\) 多项式级 \(O(m^3)\) 中等
精度 精确(在截断内) 精确(高斯态) 近似
典型应用 玻色子采样、QML 连续变量量子计算 量子化学、量子光学

选择指南: - 玻色子采样: Fock 后端(必需) - 高斯玻色采样: Gaussian 后端 - 量子机器学习: Fock 或 Gaussian(视算法而定) - 量子化学模拟: Bosonic 或 Fock(多体系统)


2. Fock 态的数学表示

2.1 Fock 空间的定义

Fock 空间 是描述光子系统的量子力学 Hilbert 空间。对于 \(m\) 个光量子模式,总 Hilbert 空间为各个模式 Fock 空间的张量积:

\[ \mathcal{H} = \mathcal{H}_1 \otimes \mathcal{H}_2 \otimes \cdots \otimes \mathcal{H}_m \]

其中每个子空间 \(\mathcal{H}_i\) 由光子数本征态 \(\{|n\rangle : n = 0, 1, 2, \ldots\}\) 张成。

截断 Fock 空间

在实际模拟中,必须对光子数进行截断。设定截断参数 \(N_{\text{cutoff}}\),则:

\[ \mathcal{H}_{\text{trunc}} = \bigotimes_{i=1}^m \operatorname{span}\{|0\rangle, |1\rangle, \ldots, |N_{\text{cutoff}}-1\rangle\} \]

维度计算

\[ \dim(\mathcal{H}_{\text{trunc}}) = N_{\text{cutoff}}^m \]

例如: - \(m=2\) 模式, \(N_{\text{cutoff}}=3\): \(\dim = 3^2 = 9\) - \(m=4\) 模式, \(N_{\text{cutoff}}=5\): \(\dim = 5^4 = 625\) - \(m=8\) 模式, \(N_{\text{cutoff}}=3\): \(\dim = 3^8 = 6561\)

2.2 光子数本征态

单模 Fock 态

\[ |n\rangle = \frac{(\hat{a}^\dagger)^n}{\sqrt{n!}} |0\rangle \]

其中: - \(\hat{a}^\dagger\): 产生算符(Creation Operator) - \(|0\rangle\): 真空态 - \(n\): 光子数

多模 Fock 态

\[ |n_1, n_2, \ldots, n_m\rangle = |n_1\rangle \otimes |n_2\rangle \otimes \cdots \otimes |n_m\rangle = \prod_{i=1}^m \frac{(\hat{a}_i^\dagger)^{n_i}}{\sqrt{n_i!}} |0\rangle^{\otimes m} \]

正交归一性

\[ \langle n_1', n_2', \ldots, n_m' | n_1, n_2, \ldots, n_m \rangle = \prod_{i=1}^m \delta_{n_i', n_i} \]

2.3 张量积结构

量子态的张量表示

任意量子态 \(|\psi\rangle\) 可以展开为 Fock 态的线性组合:

\[ |\psi\rangle = \sum_{n_1=0}^{N_{\text{cutoff}}-1} \sum_{n_2=0}^{N_{\text{cutoff}}-1} \cdots \sum_{n_m=0}^{N_{\text{cutoff}}-1} \psi_{n_1, n_2, \ldots, n_m} |n_1, n_2, \ldots, n_m\rangle \]

其中振幅 \(\psi_{n_1, n_2, \ldots, n_m}\) 构成 \(m\) 维张量:

# 形状示例 (m=3, cutoff=4)
psi.shape = (4, 4, 4)  # 64 维 Hilbert 空间

# 索引对应光子数配置
psi[0, 1, 2] = 0.5 + 0.3j  # |0,1,2⟩ 态的振幅
psi[3, 0, 1] = 0.2 - 0.1j  # |3,0,1⟩ 态的振幅

张量的存储方式

在 DeepQuantum 实现中,张量被重塑为 1 维向量以便矩阵运算:

\[ \psi_{\text{flat}}[k] = \psi_{n_1, n_2, \ldots, n_m}, \quad k = \sum_{i=1}^m n_i \cdot N_{\text{cutoff}}^{i-1} \]

索引映射示例

m=2, cutoff=3 时的索引映射:
k=0 → (0,0)  → |00⟩
k=1 → (1,0)  → |10⟩
k=2 → (2,0)  → |20⟩
k=3 → (0,1)  → |01⟩
k=4 → (1,1)  → |11⟩
k=5 → (2,1)  → |21⟩
k=6 → (0,2)  → |02⟩
k=7 → (1,2)  → |12⟩
k=8 → (2,2)  → |22⟩

2.4 截断策略

截断的选择原则

  1. 能量约束: \(\sum_i \langle \hat{n}_i \rangle \leq N_{\text{total}}\)
  2. 概率质量: \(\sum_{n \geq N_{\text{cutoff}}} |\psi_n|^2 < \epsilon\)
  3. 计算资源: \(N_{\text{cutoff}}^m \leq \text{内存容量}\)

自适应截断方法

# 动态确定 cutoff
def adaptive_cutoff(state, threshold=1e-6):
    """根据态的能量分布确定合适的截断"""
    photon_distribution = np.abs(state) ** 2
    cumulative_prob = np.cumsum(photon_distribution)
    cutoff = np.argmax(cumulative_prob > 1 - threshold) + 1
    return min(cutoff, MAX_CUTOFF)

误差估计

截断误差主要来自高光子数态的忽略:

\[ \epsilon_{\text{trunc}} = \sum_{n_i \geq N_{\text{cutoff}}} |\psi_{n_1, \ldots, n_m}|^2 \]

经验法则: - 低能态: cutoff = 3-5 - 中等激发: cutoff = 5-10 - 高能态: cutoff ≥ 10(需谨慎)


3. 量子态的操作与演化

3.1 升降算符

湮灭算符(Annihilation Operator)

\[ \hat{a}_i |n_1, \ldots, n_i, \ldots, n_m\rangle = \sqrt{n_i} \cdot |n_1, \ldots, n_i-1, \ldots, n_m\rangle \]

产生算符(Creation Operator)

\[ \hat{a}_i^\dagger |n_1, \ldots, n_i, \ldots, n_m\rangle = \sqrt{n_i+1} \cdot |n_1, \ldots, n_i+1, \ldots, n_m\rangle \]

对易关系

\[ [\hat{a}_i, \hat{a}_j^\dagger] = \delta_{ij}, \quad [\hat{a}_i, \hat{a}_j] = 0, \quad [\hat{a}_i^\dagger, \hat{a}_j^\dagger] = 0 \]

粒子数算符

\[ \hat{n}_i = \hat{a}_i^\dagger \hat{a}_i \]

本征值方程:

\[ \hat{n}_i |n_1, \ldots, n_i, \ldots, n_m\rangle = n_i \cdot |n_1, \ldots, n_i, \ldots, n_m\rangle \]

3.2 常见量子门

3.2.1 分束器(Beam Splitter)

物理描述:分束器实现两个模式之间的线性耦合。

Fock 空间中的表示

分束器作用在模式 \(i\)\(j\) 上,由透射率 \(t\) 和反射率 \(r\) 参数化:

\[ \hat{U}_{\text{BS}}(t, r) = \exp\left(\theta (\hat{a}_i^\dagger \hat{a}_j - \hat{a}_j^\dagger \hat{a}_i)\right) \]

其中: - \(\theta = \arccos(\sqrt{t})\) - \(t + r = 1\)(能量守恒)

输入-输出关系

\[ \begin{pmatrix} \hat{a}_i^{\text{out}} \\ \hat{a}_j^{\text{out}} \end{pmatrix} = \begin{pmatrix} \sqrt{t} & \sqrt{r} \\ -\sqrt{r} & \sqrt{t} \end{pmatrix} \begin{pmatrix} \hat{a}_i^{\text{in}} \\ \hat{a}_j^{\text{in}} \end{pmatrix} \]

矩阵表示示例 (cutoff=2, m=2):

# |00⟩, |10⟩, |01⟩, |20⟩, |11⟩, |02⟩ 的顺序
# t=0.5 (50:50 分束器)
U_BS = np.array([
    [1, 0, 0, 0, 0, 0],           # |00⟩ → |00⟩
    [0, 0.707, -0.707, 0, 0, 0],  # |10⟩ → 0.707|10⟩ - 0.707|01⟩
    [0, 0.707, 0.707, 0, 0, 0],   # |01⟩ → 0.707|10⟩ + 0.707|01⟩
    # ... 更高光子数项
])

物理效应: - Hong-Ou-Mandel 效应:两个光子在 50:50 分束器发生量子干涉 - 光子聚束与反聚束

3.2.2 相移器(Phase Shifter)

物理描述:在单模上引入相位延迟。

酉算符

\[ \hat{U}_{\text{PS}}(\phi) = \exp(i \phi \hat{a}^\dagger \hat{a}) = \exp(i \phi \hat{n}) \]

作用效果

\[ \hat{U}_{\text{PS}}(\phi) |n\rangle = e^{i n \phi} |n\rangle \]

矩阵表示 (对角矩阵):

# cutoff=4
U_PS = np.diag([
    np.exp(1j * 0 * phi),    # |0⟩ → |0⟩
    np.exp(1j * 1 * phi),    # |1⟩ → e^{iφ}|1⟩
    np.exp(1j * 2 * phi),    # |2⟩ → e^{2iφ}|2⟩
    np.exp(1j * 3 * phi),    # |3⟩ → e^{3iφ}|3⟩
])

3.2.3 挤压算符(Squeezing Operator)

物理描述:压缩某个正交分量的量子噪声,同时扩展另一个分量。

定义

\[ \hat{S}(z) = \exp\left(\frac{1}{2}(z^* \hat{a}^2 - z \hat{a}^{\dagger 2})\right) \]

其中 \(z = r e^{i\phi}\) 是挤压参数。

作用效果

\[ \begin{aligned} \hat{S}^\dagger(z) \hat{a} \hat{S}(z) &= \hat{a} \cosh r - \hat{a}^\dagger e^{i\phi} \sinh r \\ \hat{S}^\dagger(z) \hat{a}^\dagger \hat{S}(z) &= \hat{a}^\dagger \cosh r - \hat{a} e^{-i\phi} \sinh r \end{aligned} \]

Fock 态展开

\[ \hat{S}(z) |0\rangle = \frac{1}{\sqrt{\cosh r}} \sum_{n=0}^\infty \frac{\sqrt{(2n)!}}{2^n n!} (-e^{i\phi} \tanh r)^n |2n\rangle \]

矩阵示例 (cutoff=4, \(\phi=0\)):

# 挤压参数 r
S = np.zeros((4, 4), dtype=complex)
S[0, 0] = 1 / np.sqrt(np.cosh(r))
S[2, 0] = -np.sqrt(2) * np.tanh(r) / np.sqrt(np.cosh(r))
S[4, 0] = np.sqrt(6) * np.tanh(r)**2 / np.sqrt(np.cosh(r))
# ... 更高阶项

物理意义: - \(r > 0\): 挤压位置算符 \(\hat{x}\)(压缩 \(\Delta x\)) - \(r < 0\): 挤压动量算符 \(\hat{p}\)(压缩 \(\Delta p\)

3.2.4 位移算符(Displacement Operator)

物理描述:在相空间中平移量子态。

定义

\[ \hat{D}(\alpha) = \exp(\alpha \hat{a}^\dagger - \alpha^* \hat{a}) \]

其中 \(\alpha = |\alpha| e^{i\theta}\) 是复位移参数。

作用效果

\[ \hat{D}(\alpha) |n\rangle = e^{-|\alpha|^2/2} \sum_{k=0}^\infty \frac{\alpha^{k}}{k!} \sqrt{\frac{n!}{(n+k)!}} |n+k\rangle \]

特例:作用在真空态产生相干态

\[ \hat{D}(\alpha) |0\rangle = |\alpha\rangle = e^{-|\alpha|^2/2} \sum_{n=0}^\infty \frac{\alpha^n}{\sqrt{n!}} |n\rangle \]

矩阵表示 (下三角矩阵):

# cutoff=4, alpha=1.0
D = np.zeros((4, 4), dtype=complex)
for n in range(4):
    for k in range(4 - n):
        D[n+k, n] = (alpha**k / np.sqrt(math.factorial(k)) *
                     np.exp(-abs(alpha)**2 / 2) *
                     np.sqrt(math.factorial(n) / math.factorial(n+k)))

3.2.5 Kerr 非线性(Kerr Non-linearity)

物理描述:光子之间的相互作用,导致相位依赖于光子数。

定义

\[ \hat{U}_{\text{Kerr}}(\kappa) = \exp(i \kappa \hat{a}^{\dagger 2} \hat{a}^2) = \exp(i \kappa \hat{n}(\hat{n}-1)) \]

其中 \(\kappa\) 是非线性强度。

作用效果

\[ \hat{U}_{\text{Kerr}}(\kappa) |n\rangle = e^{i \kappa n(n-1)} |n\rangle \]

矩阵表示 (对角矩阵):

# cutoff=4
U_Kerr = np.diag([
    np.exp(1j * kappa * 0 * -1),    # |0⟩ → |0⟩
    np.exp(1j * kappa * 1 * 0),     # |1⟩ → |1⟩
    np.exp(1j * kappa * 2 * 1),     # |2⟩ → e^{2iκ}|2⟩
    np.exp(1j * kappa * 3 * 2),     # |3⟩ → e^{6iκ}|3⟩
])

物理意义: - 产生非经典光态(如薛定谔猫态) - 量子计算中的非高斯门 - 光子数相位自调制

3.3 电路演化

状态演化方程

\[ |\psi_{\text{out}}\rangle = \hat{U}_{\text{total}} |\psi_{\text{in}}\rangle \]

其中总酉算符为各量子门算符的乘积:

\[ \hat{U}_{\text{total}} = \hat{U}_N \cdots \hat{U}_2 \hat{U}_1 \]

矩阵-向量乘法

在截断 Fock 空间中,酉算符表示为 \(D \times D\) 维矩阵(\(D = N_{\text{cutoff}}^m\)):

\[ \psi_{\text{out}} = U_{\text{total}} \cdot \psi_{\text{in}} \]

计算复杂度

  • 空间: \(O(D^2) = O(N_{\text{cutoff}}^{2m})\)
  • 时间: \(O(D^2)\) 每个门操作

优化策略

  1. 稀疏矩阵: 许多量子门(如相移器、Kerr)是稀疏的
  2. 张量网络: 使用 MPS/PESS 表示压缩状态
  3. 门分解: 将复杂门分解为基本门的序列

电路示例

# 3 模式电路
cir = dq.QumodeCircuit(3, cutoff=3)

# 门序列
cir.bs([0, 1], [0.5, 0.3])    # 分束器
cir.r(0, 0.2)                 # 相移器
cir.sq(2, 1.0)                # 挤压
cir.d(1, 0.5+0.3j)            # 位移
cir.kerr([0, 2], [0.1, 0.2])  # Kerr

# 演化
psi_out = cir()

3.4 态矢量的变换

线性变换

对于任意线性操作 \(\hat{U}\)

\[ |\psi'\rangle = \hat{U} |\psi\rangle \implies \psi'_{n_1'\ldots n_m'} = \sum_{n_1,\ldots,n_m} U_{n_1'\ldots n_m', n_1\ldots n_m} \psi_{n_1\ldots n_m} \]

保范性

\[ \langle \psi' | \psi' \rangle = \langle \psi | \hat{U}^\dagger \hat{U} | \psi \rangle = \langle \psi | \psi \rangle = 1 \]

态的归一化

\[ \sum_{n_1,\ldots,n_m} |\psi_{n_1,\ldots,n_m}|^2 = 1 \]

数值稳定性

在演化过程中需要定期归一化:

def normalize_state(psi):
    """归一化量子态"""
    norm = np.sqrt(np.sum(np.abs(psi)**2))
    if norm > 1e-12:  # 避免除零
        return psi / norm
    else:
        raise ValueError("态矢量范数接近零")

4. 测量机制

4.1 光子数测量(PNRD)

定义:光子数分辨探测器(Photon Number Resolving Detector)能够精确测量每个模式的光子数。

测量算符

对于模式 \(i\),测量结果为 \(n\) 的投影算符为:

\[ \hat{P}_i(n) = \hat{I}_1 \otimes \cdots \otimes \hat{I}_{i-1} \otimes |n\rangle_i \langle n| \otimes \hat{I}_{i+1} \otimes \cdots \otimes \hat{I}_m \]

概率分布

测量得到结果 \(\mathbf{n} = (n_1, n_2, \ldots, n_m)\) 的概率:

\[ P(\mathbf{n}) = |\langle n_1, n_2, \ldots, n_m | \psi \rangle|^2 = |\psi_{n_1, n_2, \ldots, n_m}|^2 \]

测量后态(投影测量):

\[ |\psi'\rangle = \frac{\hat{P}(\mathbf{n}) |\psi\rangle}{\sqrt{P(\mathbf{n})}} = \frac{\psi_{n_1,\ldots,n_m}}{\sqrt{P(\mathbf{n})}} |n_1, \ldots, n_m\rangle \]

统计量计算

# 单模光子数期望值
def expect_photon_number(psi, mode_idx, cutoff):
    """计算指定模式的期望光子数"""
    marginal = np.sum(np.abs(psi)**2, axis=tuple(i for i in range(psi.ndim) if i != mode_idx))
    n_values = np.arange(cutoff)
    return np.sum(n_values * marginal)

# 示例
n_avg = expect_photon_number(psi, mode_idx=0, cutoff=4)

物理实现: - 超导纳米线单光子探测器(SNSPD) - 过渡边缘传感器(TES) - 光电倍增管阵列

4.2 阈值探测器

定义:阈值探测器(Threshold Detector)只能区分"有光子"(≥1)和"无光子"(0),不能分辨光子数。

测量算符

\[ \begin{aligned} \hat{P}_i(\text{click}) &= \sum_{n=1}^{N_{\text{cutoff}}-1} |n\rangle_i \langle n| = \hat{I}_i - |0\rangle_i \langle 0| \\ \hat{P}_i(\text{no-click}) &= |0\rangle_i \langle 0| \end{aligned} \]

概率分布

\[ \begin{aligned} P_i(\text{click}) &= 1 - |\psi^{(i)}_0|^2 \\ P_i(\text{no-click}) &= |\psi^{(i)}_0|^2 \end{aligned} \]

其中 \(\psi^{(i)}_0\) 是模式 \(i\) 处于 \(|0\rangle\) 的振幅。

应用场景: - 玻色子采样实验(早期实验) - 低成本探测器系统 - 简化测量模型

4.3 同位测量(Homodyne Detection)

定义:同位测量通过干涉测量光场的正交分量 \(\hat{x}_\theta = \hat{a} e^{-i\theta} + \hat{a}^\dagger e^{i\theta}\)

测量正交分量

  • 位置测量 (\(\theta=0\)): \(\hat{x} = \hat{a} + \hat{a}^\dagger\)
  • 动量测量 (\(\theta=\pi/2\)): \(\hat{p} = -i(\hat{a} - \hat{a}^\dagger)\)

概率分布

对于连续变量结果 \(x\)

\[ P(x) = |\langle x | \psi \rangle|^2 \]

其中 \(|x\rangle\) 是位置本征态:

\[ \langle n | x \rangle = \frac{1}{\pi^{1/4} \sqrt{2^n n!}} H_n(x) e^{-x^2/2} \]

\(H_n(x)\) 是 Hermite 多项式。

数值实现

由于连续谱,需要在网格上离散化:

def homodyne_measurement(psi, theta=0, x_grid=np.linspace(-5, 5, 1000)):
    """同位测量模拟"""
    # 计算 Fock 基在位置基的表示
    projection = np.zeros(len(x_grid), dtype=complex)
    for n in range(len(psi)):
        # Hermite 多项式
        Hn = np.polynomial.hermite.hermval(x_grid, [0]*n + [1])
        # 波函数
        psi_x = (1 / np.pi**0.25 / np.sqrt(2**n * math.factorial(n)) *
                 Hn * np.exp(-x_grid**2 / 2))
        projection += psi[n] * psi_x * np.exp(-1j * n * theta)

    return x_grid, np.abs(projection)**2

4.4 测量结果的统计解释

系综测量

对相同的量子态 \(|\psi\rangle\) 进行 \(N\) 次独立测量:

  • 频率: 结果 \(\mathbf{n}\) 出现的次数 \(N_{\mathbf{n}}\)
  • 频率趋近概率: \(\lim_{N \to \infty} \frac{N_{\mathbf{n}}}{N} = P(\mathbf{n})\)

量子期望值

可观测量 \(\hat{O}\) 的期望值:

\[ \langle \hat{O} \rangle = \langle \psi | \hat{O} | \psi \rangle = \sum_{\mathbf{n}, \mathbf{n}'} \psi_{\mathbf{n}'}^* O_{\mathbf{n}', \mathbf{n}} \psi_{\mathbf{n}} \]

方差

\[ \Delta O^2 = \langle \hat{O}^2 \rangle - \langle \hat{O} \rangle^2 \]

相关函数

多模关联函数:

\[ g^{(2)}_{ij} = \frac{\langle \hat{n}_i \hat{n}_j \rangle}{\langle \hat{n}_i \rangle \langle \hat{n}_j \rangle} \]

MCMC 采样方法

对于高维概率分布,使用马尔可夫链蒙特卡洛采样:

def mcmc_sample(psi, num_samples, cutoff):
    """MCMC 采样光子数配置"""
    import random

    # 初始状态
    current = tuple(random.randint(0, cutoff-1) for _ in range(psi.ndim))

    samples = []
    for _ in range(num_samples):
        # 提议新状态
        proposal = list(current)
        mode = random.randint(0, len(proposal)-1)
        proposal[mode] = random.randint(0, cutoff-1)
        proposal = tuple(proposal)

        # Metropolis-Hastings 接受概率
        p_current = abs(psi[current])**2
        p_proposal = abs(psi[proposal])**2
        alpha = min(1, p_proposal / p_current)

        if random.random() < alpha:
            current = proposal

        samples.append(current)

    return samples

测量模拟流程

flowchart TD
    A[初始量子态 |ψ⟩] --> B[选择测量类型]
    B --> C{测量类型?}

    C -->|PNRD| D[计算光子数分布 Pn = |ψn|²]
    C -->|阈值| E[计算点击概率 Pclick = 1 - |ψ₀|²]
    C -->|同位| F[计算正交分量分布 Px]

    D --> G[根据概率采样结果]
    E --> G
    F --> G

    G --> H[记录测量结果]
    H --> I[更新量子态?]
    I -->|是| J[态坍缩 |ψ'⟩ = Pn|ψ⟩/√Pn]
    I -->|否| K[保持原态]

    J --> L[输出测量结果]
    K --> L

    style D fill:#FFE4B5
    style E fill:#FFE4B5
    style F fill:#FFE4B5
    style J fill:#FFB6C1

5. 关键数学公式

5.1 基本对易关系

\[ [\hat{a}_i, \hat{a}_j^\dagger] = \delta_{ij}, \quad [\hat{a}_i, \hat{a}_j] = 0, \quad [\hat{a}_i^\dagger, \hat{a}_j^\dagger] = 0 \]

物理意义:不同模式的算符相互独立,同模式算符满足正则对易关系。

5.2 正交算符

\[ \begin{aligned} \hat{x} &= \frac{\hat{a} + \hat{a}^\dagger}{\sqrt{2}} \\ \hat{p} &= \frac{\hat{a} - \hat{a}^\dagger}{i\sqrt{2}} \\ [\hat{x}, \hat{p}] &= i \end{aligned} \]

对应代码

def position_operator(cutoff):
    """位置算符 x̂ 在 Fock 基的表示"""
    a = annihilation(cutoff)
    a_dag = a.T.conj()
    return (a + a_dag) / np.sqrt(2)

def momentum_operator(cutoff):
    """动量算符 p̂ 在 Fock 基的表示"""
    a = annihilation(cutoff)
    a_dag = a.T.conj()
    return (a - a_dag) / (1j * np.sqrt(2))

5.3 湮灭算符矩阵

\[ \hat{a} = \sum_{n=0}^{N_{\text{cutoff}}-2} \sqrt{n+1} \cdot |n\rangle \langle n+1| \]

矩阵形式(次对角矩阵):

\[ \hat{a} = \begin{pmatrix} 0 & 1 & 0 & 0 & \cdots \\ 0 & 0 & \sqrt{2} & 0 & \cdots \\ 0 & 0 & 0 & \sqrt{3} & \cdots \\ 0 & 0 & 0 & 0 & \cdots \\ \vdots & \vdots & \vdots & \vdots & \ddots \end{pmatrix} \]

代码实现

def annihilation(cutoff):
    """构建湮灭算符矩阵"""
    a = np.zeros((cutoff, cutoff), dtype=complex)
    for n in range(cutoff - 1):
        a[n, n+1] = np.sqrt(n + 1)
    return a

5.4 分束器变换矩阵

\[ \hat{U}_{\text{BS}}(\theta) = \exp\left(\theta (\hat{a}_1^\dagger \hat{a}_2 - \hat{a}_2^\dagger \hat{a}_1)\right) \]

展开形式

\[ \hat{U}_{\text{BS}} = \sum_{k,l=0}^\infty \frac{(-1)^l \theta^{k+l}}{k! l!} (\hat{a}_1^\dagger \hat{a}_2)^k (\hat{a}_2^\dagger \hat{a}_1)^l \]

矩阵元计算

\[ \langle n_1', n_2' | \hat{U}_{\text{BS}} | n_1, n_2 \rangle = \delta_{n_1'+n_2', n_1+n_2} \cdot \sqrt{\frac{n_1! n_2!}{n_1'! n_2'!}} \cos^{n_1-n_1'}(\theta) \sin^{n_2-n_2'}(\theta) \cdot P_{n_1-n_1'}^{(n_2-n_1', n_1-n_2'-n_2+n_1)}(\cos 2\theta) \]

其中 \(P_n^{(\alpha, \beta)}\) 是 Jacobi 多项式。

5.5 挤压态参数

压缩因子

\[ \begin{aligned} \Delta x &= \frac{e^{-r}}{\sqrt{2}} \\ \Delta p &= \frac{e^{r}}{\sqrt{2}} \\ \Delta x \cdot \Delta p &= \frac{1}{2} \end{aligned} \]

代码计算

def squeeze_parameters(r):
    """计算挤压参数"""
    dx = np.exp(-r) / np.sqrt(2)
    dp = np.exp(r) / np.sqrt(2)
    uncertainty_product = dx * dp
    return dx, dp, uncertainty_product

5.6 相干态展开

\[ |\alpha\rangle = e^{-|\alpha|^2/2} \sum_{n=0}^\infty \frac{\alpha^n}{\sqrt{n!}} |n\rangle \]

光子数分布(泊松分布):

\[ P(n) = |\langle n | \alpha \rangle|^2 = \frac{|\alpha|^{2n} e^{-|\alpha|^2}}{n!} \]

平均光子数

\[ \langle \hat{n} \rangle = |\alpha|^2 \]

5.7 Kerr 相位演化

\[ \hat{U}_{\text{Kerr}}(\kappa, t) = \exp(i \kappa t \hat{n}(\hat{n}-1)) \]

相位累积

\[ \phi_n(t) = \kappa t \cdot n(n-1) \]

代码验证

def kerr_phase(n, kappa, t):
    """计算 Kerr 相位累积"""
    return kappa * t * n * (n - 1)

# 示例:n=2 光子的相位
phi_2 = kerr_phase(n=2, kappa=0.1, t=1.0)  # 0.2 rad

5.8 测量概率公式

联合概率

\[ P(n_1, n_2, \ldots, n_m) = \left| \sum_{n_1', \ldots, n_m'} U_{n_1',\ldots,n_m', n_1,\ldots,n_m} \psi_{n_1',\ldots,n_m'} \right|^2 \]

边缘概率

\[ P_i(n_i) = \sum_{n_1, \ldots, n_{i-1}, n_{i+1}, \ldots, n_m} P(n_1, \ldots, n_m) \]

条件概率

\[ P(n_i | n_j) = \frac{P(n_i, n_j)}{P_j(n_j)} \]

6. 应用场景

6.1 玻色子采样(Boson Sampling)

问题描述

给定 \(n\) 个全同玻色子输入到 \(m\) 个模式的线性光学网络,根据测量的输出模式分布采样。

理论意义

  • 计算复杂性: 除非多项式层次结构坍缩(PH collapse),玻色子采样难以经典模拟
  • 量子霸权: 首个展示量子优势的实际方案(Aaronson & Arkhipov, 2011)

Fock 后端的应用

# 玻色子采样示例
def boson_sampling(m, n, depth):
    """
    m: 模式数
    n: 光子数
    depth: 电路深度
    """
    # 初始化:n 个光子输入前 n 个模式
    cir = dq.QumodeCircuit(m, cutoff=n+1)
    initial_state = np.zeros(m * (n+1))
    initial_state[0] = 1  # |1,1,...,1,0,0,...,0⟩

    # 随机线性光学网络
    for _ in range(depth):
        for i in range(m-1):
            theta = np.random.uniform(0, np.pi)
            cir.bs([i, i+1], [np.cos(theta)**2, np.sin(theta)**2])

    # 演化与测量
    psi = cir()
    samples = np.random.choice(range(m), n, p=np.abs(psi)**2)

    return samples

算法复杂度

  • 经典模拟: \(O(n m 2^n)\)(最佳已知算法)
  • 量子实现: \(O(\text{poly}(n, m))\)

实验里程碑: - 2013: 4 光子玻色子采样 - 2019: 14 光子高斯玻色采样 - 2020: 76 光子"九章"量子霸权实验

6.2 高斯玻色采样(Gaussian Boson Sampling)

改进方案

使用挤压态输入替代 Fock 态,提高采样效率和经典模拟难度。

输入态

\[ |\psi_{\text{in}}\rangle = \bigotimes_{i=1}^m \hat{S}(r_i) |0\rangle \]

输出概率

\[ P(\mathbf{n}) = \frac{|\text{Per}(A_{\mathbf{n}})|^2}{\mathbf{n}! \prod_i \cosh^{n_i+1/2} r_i} \]

其中 \(A_{\mathbf{n}}\) 是子矩阵的 Hafnian:

\[ \text{Haf}(A_{\mathbf{n}}) = \sum_{\sigma \in \text{Pairings}} \prod_{(i,j) \in \sigma} A_{ij} \]

应用: - 图最大团问题(Max Clique) - 图相似性 - 量子机器学习特征映射

6.3 量子机器学习(Quantum Machine Learning)

光量子神经网络

class PhotonicNN:
    def __init__(self, input_dim, hidden_dim, output_dim, cutoff):
        self.cir = dq.QumodeCircuit(input_dim + hidden_dim + output_dim, cutoff)

    def forward(self, x):
        # 编码经典数据
        for i, xi in enumerate(x):
            self.cir.d(i, xi)  # 位移编码

        # 变分层
        for layer in self.layers:
            self.cir.bs(layer['modes'], layer['params'])
            self.cir.r(layer['phase'], layer['phi'])

        # 测量输出
        return self.cir.measure_photon_number()

核方法

Fock 态可以用于构建量子核:

\[ K(\mathbf{x}, \mathbf{x}') = |\langle \psi(\mathbf{x}) | \psi(\mathbf{x}') \rangle|^2 \]

6.4 量子化学模拟

振动模式模拟

分子振动可以用光量子模式模拟:

\[ \hat{H}_{\text{vib}} = \sum_{i=1}^m \hbar \omega_i \left(\hat{a}_i^\dagger \hat{a}_i + \frac{1}{2}\right) + \sum_{i<j} \hbar g_{ij} (\hat{a}_i^\dagger \hat{a}_j + \hat{a}_i \hat{a}_j^\dagger) \]

应用示例

# 模拟水分子的振动模式(3 个模式)
h2o = dq.QumodeCircuit(3, cutoff=5)

# 基态
initial_state = np.zeros([5]*3)
initial_state[0, 0, 0] = 1

# 激发振动态
h2o.sq(0, 0.5)  # 挤压激发
h2o.bs([0, 1], [0.8, 0.2])  # 模式耦合

优势: - 自然处理多体相互作用 - 高维 Hilbert 空间的高效表示 - 模拟振动光谱


7. 参考资料

7.1 核心论文

  1. Aaronson, A., & Arkhipov, A. (2011). "The computational complexity of linear optics". Theory of Computing, 9, 143-252.
  2. 玻色子采样的理论基础
  3. 计算复杂性证明

  4. Hamilton, C. S., Kruse, R., Sansoni, L., Barkhofen, S., Silberhorn, C., & Jex, I. (2017). "Gaussian boson sampling". Physical Review Letters, 119(17), 170501.

  5. 高斯玻色采样方案
  6. Hafnian 计算方法

  7. Lund, A. P., Laing, A., Rahimi-Keshari, S., Rudolph, T., O'Brien, J. L., & Ralph, T. C. (2014). "Boson sampling from a gaussian state". Physical Review Letters, 113(10), 100502.

  8. 高斯态到 Fock 态的转换

  9. Wang, H., et al. (2020). "Gaussian boson sampling with squeezed states". Science, 370(6523), 1460-1463.

  10. "九章"量子霸权实验

7.2 教材与专著

  1. Gerry, C. C., & Knight, P. L. (2005). Introductory Quantum Optics. Cambridge University Press.
  2. 第 2-4 章:量子化光场、相干态、压缩态

  3. Kok, P., & Lovett, B. W. (2010). Introduction to Optical Quantum Information Processing. Cambridge University Press.

  4. 第 5 章:线性光学量子计算
  5. 第 6 章:玻色子采样

  6. Weedbrook, C., et al. (2012). "Gaussian quantum information". Reviews of Modern Physics, 84(2), 621.

  7. 高斯态综述

7.3 DeepQuantum 相关

  1. DeepQuantum 官方文档: https://dqapi.turingq.com/
  2. API 参考
  3. 教程与示例

  4. DeepQuantum 论文: https://arxiv.org/abs/2512.18995

  5. 框架设计与实现
  6. 性能基准测试

  7. 项目内文档

  8. E:\02_Projects\turingQ\docs\光量子计算模拟器核心原理.md
  9. E:\02_Projects\turingQ\docs\光量子计算模拟器数学原理详解.md
  10. E:\02_Projects\turingQ\deepquantum\src\deepquantum\photonic\CLAUDE.md

7.4 编程资源

  1. NumPy 量子计算:
  2. 多维张量操作
  3. 稀疏矩阵表示

  4. SciPy 特殊函数:

  5. Hermite 多项式 (scipy.special.hermite)
  6. Laguerre 多项式 (scipy.special.eval_laguerre)

  7. QuTiP (Quantum Toolbox in Python):

  8. 参考实现
  9. 数值方法验证

7.5 在线资源

  1. Perceval (Quandela): https://github.com/Quandela/Perceval
  2. 光量子计算模拟库
  3. 玻色子采样实现

  4. Strawberry Fields (Xanadu): https://strawberryfields.ai/

  5. 连续变量量子计算
  6. 高斯玻色采样教程

  7. The Walrus (Xanadu): https://the-walrus.readthedocs.io/

  8. Hafnian 和永久计算
  9. 高斯态模拟工具

附录

A. 符号约定

符号 含义 示例
\(\hat{a}\) 湮灭算符 $\hat{a}
\(\hat{a}^\dagger\) 产生算符 $\hat{a}^\dagger
\(\hat{n}\) 粒子数算符 \(\hat{n} = \hat{a}^\dagger \hat{a}\)
$ n\rangle$ Fock 态
$ \alpha\rangle$ 相干态
\(\hat{U}\) 酸算符 \(\hat{U}^\dagger \hat{U} = \hat{I}\)
\(\theta\) 分束器参数 透射率 \(t = \cos^2 \theta\)
\(r\) 挤压参数 $S®
\(\kappa\) Kerr 非线性强度 \(e^{i \kappa \hat{n}(\hat{n}-1)}\)
\(N_{\text{cutoff}}\) 截断维度 \(n \in [0, N_{\text{cutoff}})\)
\(m\) 模式数 \(\mathcal{H} = \bigotimes_{i=1}^m \mathcal{H}_i\)

B. 代码片段索引

# 湮灭算符
def annihilation(cutoff): # §3.1

# 分束器矩阵
def beam_splitter_matrix(theta, cutoff): # §3.2.1

# 挤压态生成
def squeezed_state(r, phi, cutoff): # §3.2.3

# 相干态生成
def coherent_state(alpha, cutoff): # §3.2.4

# 光子数测量
def photon_number_measurement(psi): # §4.1

# 同位测量
def homodyne_measurement(psi, theta): # §4.3

# MCMC 采样
def mcmc_sample(psi, num_samples): # §4.4

# 玻色子采样
def boson_sampling(m, n, depth): # §6.1

C. 性能优化技巧

  1. 稀疏矩阵:

    from scipy.sparse import csr_matrix
    U_sparse = csr_matrix(U_dense)
    psi_out = U_sparse @ psi_in
    

  2. 批处理:

    # 并行处理多个态
    psi_batch = np.stack([psi1, psi2, psi3])
    psi_out_batch = U @ psi_batch.T
    

  3. GPU 加速:

    import torch
    U_gpu = torch.tensor(U, device='cuda')
    psi_gpu = torch.tensor(psi, device='cuda')
    psi_out = U_gpu @ psi_gpu
    

  4. 张量网络:

    # MPS 表示
    from tensornetwork import Node
    psi_mps = [Node(psi.reshape(cutoff, -1))]
    


文档结束

如有问题或建议,请联系 TuringQ 技术团队或查阅 DeepQuantum 官方文档。