qalgora-Q Docs Hub量子文档 ✦ Ask AI✦ 问问文档

Readout Error Mitigation

◐ Design-level API
This page documents qalgora-Q API design, architecture, or adaptation workflows. Code examples illustrate intended usage and are not guaranteed to run in the current reference implementation.

Correct biased measurement counts by inverting a confusion matrix calibrated from known input states.

Calibrate & correct

import qalgora
import numpy as np

# 1. characterize the readout with calibration circuits
confusion = qalgora.experimental.measure_confusion_matrix(n_qubits=2,
                                                          noise_model=noise)
# 2. invert it
correction = np.linalg.inv(confusion)

# 3. apply to raw counts (normalize counts to a probability vector first)
raw = qalgora.sample(kernel, shots_count=10000, noise_model=noise)
corrected = correction @ raw.to_vector()
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.
Inversion and normalization caveats
Directly inverting the confusion matrix amplifies statistical noise and can produce negative probabilities or a total that drifts from 1. In practice one uses a pseudo-inverse, constrained least squares, regularization, or clips negative entries and renormalizes. Note too that raw.to_vector() should be normalized from counts into a probability vector, and the corrected vector is typically truncated to non-negative values and renormalized afterwards.

Strategies

  • Full confusion matrix — captures all correlated readout errors, but 2N×2N; small systems only.
  • Tensored / k-local — assume independent qubit errors. An independent single-qubit model calibrates with cost growing linearly in qubit count; a k-local model's cost grows exponentially in the block size and roughly linearly in the number of blocks.
  • Single-qubit — cheapest approximation for weakly-correlated readout.

读出误差缓解

◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。

通过对已知输入态标定混淆矩阵,再对其求逆,修正带偏差的测量计数。

标定与校正

import qalgora
import numpy as np

# 1. characterize the readout with calibration circuits
confusion = qalgora.experimental.measure_confusion_matrix(n_qubits=2,
                                                          noise_model=noise)
# 2. invert it
correction = np.linalg.inv(confusion)

# 3. apply to raw counts(先把计数归一化为概率向量)
raw = qalgora.sample(kernel, shots_count=10000, noise_model=noise)
corrected = correction @ raw.to_vector()
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。
求逆与归一化注意事项
直接矩阵求逆会放大统计噪声,可能产生负概率或总概率偏离 1;实际常用伪逆、约束最小二乘、正则化、截断负值并重新归一化。此外 raw.to_vector() 应先把计数归一化为概率向量,校正后的向量通常再做截断负值与重新归一化处理。

策略

  • 完整混淆矩阵 — 能捕捉全部关联读出误差,但规模为 2N×2N,仅适用于小规模系统。
  • 张量积 / k-局域 — 假设各量子比特读出误差独立。独立单比特模型标定规模随量子比特数线性增长;k-局域模型开销随块大小指数增长、随块数近似线性增长。
  • 单量子比特 — 最低开销的近似,适用于弱关联读出场景。