Liking cljdoc? Tell your friends :D

org.soulspace.qclojure.application.error-mitigation.readout-error

Readout error mitigation for quantum measurement correction.

This namespace provides functions for correcting measurement errors that occur during quantum state readout. Readout errors are one of the most significant sources of noise in current quantum hardware, and proper mitigation can substantially improve algorithm fidelity.

Key capabilities:

  • Single and multi-qubit readout error characterization
  • Calibration matrix construction using tensor products
  • Linear system solving for error correction
  • Fidelity improvement measurement and analysis

The implementation supports arbitrary numbers of qubits (up to practical memory limits) and uses proper mathematical techniques including matrix inversion and probability normalization to ensure physically valid results.

Typical workflow:

  1. Characterize readout errors using calibration experiments
  2. Create calibration matrix from error parameters
  3. Apply mitigation to measured data using matrix inversion
  4. Analyze improvement in measurement fidelity
Readout error mitigation for quantum measurement correction.

This namespace provides functions for correcting measurement errors
that occur during quantum state readout. Readout errors are one of the
most significant sources of noise in current quantum hardware, and
proper mitigation can substantially improve algorithm fidelity.

Key capabilities:
- Single and multi-qubit readout error characterization
- Calibration matrix construction using tensor products
- Linear system solving for error correction
- Fidelity improvement measurement and analysis

The implementation supports arbitrary numbers of qubits (up to practical memory
limits) and uses proper mathematical techniques including matrix inversion
and probability normalization to ensure physically valid results.

Typical workflow:
1. Characterize readout errors using calibration experiments  
2. Create calibration matrix from error parameters
3. Apply mitigation to measured data using matrix inversion
4. Analyze improvement in measurement fidelity
raw docstring

create-calibration-matrixclj

(create-calibration-matrix num-qubits readout-errors)

Create calibration matrix from readout error characterization for multi-qubit systems.

This function constructs the full calibration matrix for n-qubit quantum systems by computing the tensor product of single-qubit readout matrices. The resulting 2^n × 2^n matrix captures the complete readout error model including correlations between qubits (assuming independent errors per qubit).

The calibration matrix C has the interpretation: C[i,j] = P(measure computational basis state i | prepared computational basis state j)

For example, with 2 qubits, the matrix relates states as: C * [P(|00⟩) P(|01⟩) P(|10⟩) P(|11⟩)]ᵀ = [measured |00⟩ rate, measured |01⟩ rate, ...]ᵀ

The tensor product construction ensures that:

  • Single-qubit error models combine correctly
  • Matrix has proper probabilistic normalization
  • Computational complexity scales as O(4^n) in space

For practical quantum computers, this matrix becomes large (64×64 for 6 qubits, 1024×1024 for 10 qubits), requiring careful memory management and potentially sparse matrix techniques for larger systems.

Parameters:

  • num-qubits: Number of qubits in the quantum register (positive integer ≤ 10)
  • readout-errors: Single-qubit readout error characterization map containing:
    • :prob-0-to-1 - Error probability |0⟩ → |1⟩
    • :prob-1-to-0 - Error probability |1⟩ → |0⟩

Returns: 2^n × 2^n calibration matrix where element (i,j) represents P(measure state i | prepared state j) for computational basis states

Throws: AssertionError if num-qubits > 10 (memory protection) or num-qubits ≤ 0

Example: (create-calibration-matrix 2 {:prob-0-to-1 0.05 :prob-1-to-0 0.03}) ;=> 4×4 matrix for 2-qubit readout error correction

Create calibration matrix from readout error characterization for multi-qubit systems.

This function constructs the full calibration matrix for n-qubit quantum systems
by computing the tensor product of single-qubit readout matrices. The resulting
2^n × 2^n matrix captures the complete readout error model including correlations
between qubits (assuming independent errors per qubit).

The calibration matrix C has the interpretation:
C[i,j] = P(measure computational basis state i | prepared computational basis state j)

For example, with 2 qubits, the matrix relates states as:
C * [P(|00⟩) P(|01⟩) P(|10⟩) P(|11⟩)]ᵀ = [measured |00⟩ rate, measured |01⟩ rate, ...]ᵀ

The tensor product construction ensures that:
- Single-qubit error models combine correctly
- Matrix has proper probabilistic normalization 
- Computational complexity scales as O(4^n) in space

For practical quantum computers, this matrix becomes large (64×64 for 6 qubits,
1024×1024 for 10 qubits), requiring careful memory management and potentially
sparse matrix techniques for larger systems.

Parameters:
- num-qubits: Number of qubits in the quantum register (positive integer ≤ 10)
- readout-errors: Single-qubit readout error characterization map containing:
  - :prob-0-to-1 - Error probability |0⟩ → |1⟩ 
  - :prob-1-to-0 - Error probability |1⟩ → |0⟩

Returns:
2^n × 2^n calibration matrix where element (i,j) represents
P(measure state i | prepared state j) for computational basis states

Throws:
AssertionError if num-qubits > 10 (memory protection) or num-qubits ≤ 0

Example:
(create-calibration-matrix 2 {:prob-0-to-1 0.05 :prob-1-to-0 0.03})
;=> 4×4 matrix for 2-qubit readout error correction
sourceraw docstring

create-single-qubit-readout-matrixclj

(create-single-qubit-readout-matrix readout-errors)

Create readout error matrix for a single qubit from characterization data.

This function constructs the fundamental 2×2 readout error matrix that describes the conditional probabilities of measurement errors for a single qubit. The matrix element (i,j) represents P(measure state i | prepared state j).

Readout errors arise from several physical mechanisms:

  • Imperfect state discrimination in measurement circuits
  • Thermal excitation during readout
  • Crosstalk between measurement channels
  • Finite measurement time and relaxation

The error characterization typically comes from calibration experiments where known states |0⟩ and |1⟩ are prepared and measured repeatedly to determine error probabilities.

Parameters:

  • readout-errors: Map containing error characterization with keys:
    • :prob-0-to-1 - Probability of measuring |1⟩ when |0⟩ was prepared (false positive)
    • :prob-1-to-0 - Probability of measuring |0⟩ when |1⟩ was prepared (false negative)

Returns: 2×2 matrix [[P(0|0) P(0|1)] where: [P(1|0) P(1|1)]]

  • P(0|0) = 1 - prob-0-to-1 (correct measurement of |0⟩)
  • P(0|1) = prob-1-to-0 (error: measure |0⟩ when |1⟩ prepared)
  • P(1|0) = prob-0-to-1 (error: measure |1⟩ when |0⟩ prepared)
  • P(1|1) = 1 - prob-1-to-0 (correct measurement of |1⟩)

Example: (create-single-qubit-readout-matrix {:prob-0-to-1 0.05 :prob-1-to-0 0.03}) ;=> [[0.95 0.03] ; [0.05 0.97]] ; 95% accuracy for |0⟩, 97% accuracy for |1⟩

Create readout error matrix for a single qubit from characterization data.

This function constructs the fundamental 2×2 readout error matrix that describes
the conditional probabilities of measurement errors for a single qubit. The matrix
element (i,j) represents P(measure state i | prepared state j).

Readout errors arise from several physical mechanisms:
- Imperfect state discrimination in measurement circuits
- Thermal excitation during readout
- Crosstalk between measurement channels
- Finite measurement time and relaxation

The error characterization typically comes from calibration experiments where
known states |0⟩ and |1⟩ are prepared and measured repeatedly to determine
error probabilities.

Parameters:
- readout-errors: Map containing error characterization with keys:
  - :prob-0-to-1 - Probability of measuring |1⟩ when |0⟩ was prepared (false positive)
  - :prob-1-to-0 - Probability of measuring |0⟩ when |1⟩ was prepared (false negative)

Returns:
2×2 matrix [[P(0|0) P(0|1)]   where:
            [P(1|0) P(1|1)]]
- P(0|0) = 1 - prob-0-to-1 (correct measurement of |0⟩)
- P(0|1) = prob-1-to-0     (error: measure |0⟩ when |1⟩ prepared)
- P(1|0) = prob-0-to-1     (error: measure |1⟩ when |0⟩ prepared)  
- P(1|1) = 1 - prob-1-to-0 (correct measurement of |1⟩)

Example:
(create-single-qubit-readout-matrix {:prob-0-to-1 0.05 :prob-1-to-0 0.03})
;=> [[0.95 0.03]
;    [0.05 0.97]]  ; 95% accuracy for |0⟩, 97% accuracy for |1⟩
sourceraw docstring

mitigate-readout-errorsclj

(mitigate-readout-errors measured-counts calibration-matrix num-qubits)

Apply readout error mitigation using calibration matrix.

This function corrects measurement errors by solving the linear system: measured_counts = calibration_matrix * true_counts

The calibration matrix C represents the conditional probabilities P(measure i | prepared j) where rows correspond to measured outcomes and columns to prepared states. By inverting this relationship, we can estimate the true quantum state distribution from the noisy measurement data.

The mitigation process:

  1. Convert measured counts to probability distribution
  2. Solve C * true_probs = measured_probs using matrix inversion
  3. Apply non-negativity constraints and renormalization
  4. Convert back to corrected count distribution
  5. Calculate fidelity improvement metrics

Parameters:

  • measured-counts: Map of measurement outcome strings to count numbers e.g. {"00" 450, "01" 25, "10" 30, "11" 495}
  • calibration-matrix: 2^n × 2^n matrix where element (i,j) = P(measure i | prepared j) Constructed from readout error characterization experiments
  • num-qubits: Number of qubits in the quantum system

Returns: Map containing:

  • :measured-counts - Original measurement data
  • :corrected-counts - Error-corrected count distribution
  • :improvement-factor - Ratio of error reduction (< 1.0 means improvement)
  • :total-shots - Total number of measurement shots
  • :target-state - Reference state used for fidelity calculation
  • :measured-fidelity - Fidelity before correction
  • :corrected-fidelity - Fidelity after correction

Example: (mitigate-readout-errors {"00" 450 "11" 450 "01" 50 "10" 50} calibration-matrix 2) ;=> {:improvement-factor 0.12, :corrected-fidelity 0.95, ...}

Apply readout error mitigation using calibration matrix.

This function corrects measurement errors by solving the linear system:
measured_counts = calibration_matrix * true_counts

The calibration matrix C represents the conditional probabilities P(measure i | prepared j)
where rows correspond to measured outcomes and columns to prepared states.
By inverting this relationship, we can estimate the true quantum state distribution
from the noisy measurement data.

The mitigation process:
1. Convert measured counts to probability distribution
2. Solve C * true_probs = measured_probs using matrix inversion
3. Apply non-negativity constraints and renormalization
4. Convert back to corrected count distribution
5. Calculate fidelity improvement metrics

Parameters:
- measured-counts: Map of measurement outcome strings to count numbers
                   e.g. {"00" 450, "01" 25, "10" 30, "11" 495}
- calibration-matrix: 2^n × 2^n matrix where element (i,j) = P(measure i | prepared j)
                      Constructed from readout error characterization experiments
- num-qubits: Number of qubits in the quantum system

Returns:
Map containing:
- :measured-counts - Original measurement data
- :corrected-counts - Error-corrected count distribution
- :improvement-factor - Ratio of error reduction (< 1.0 means improvement)
- :total-shots - Total number of measurement shots
- :target-state - Reference state used for fidelity calculation
- :measured-fidelity - Fidelity before correction
- :corrected-fidelity - Fidelity after correction

Example:
(mitigate-readout-errors {"00" 450 "11" 450 "01" 50 "10" 50}
                         calibration-matrix 2)
;=> {:improvement-factor 0.12, :corrected-fidelity 0.95, ...}
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close