qiskit-community / qiskit-ignis

Ignis (deprecated) provides tools for quantum hardware verification, noise characterization, and error correction.
Apache License 2.0
168 stars 160 forks source link

Gateset Tomography does not correctly estimate readout errors #404

Closed ChriPiv closed 4 years ago

ChriPiv commented 4 years ago

Informations

What is the current behavior?

GST should give us an estimate of the readout error in the circuit, by giving us a single POVM measurement operator. In the current implementation in qiskit, this POVM operator seems to be a perfect projection.

Steps to reproduce the problem

Following code runs a GST on a simple basis set, using a noise_model that includes readout noise. GST should be able to give us an estimate of that readout error.

from qiskit import *
from qiskit.extensions import HGate
from qiskit.compiler import transpile
from qiskit.providers.aer.noise import *
from qiskit.ignis.verification.tomography.basis.gatesetbasis import default_gateset_basis
from qiskit.ignis.verification.tomography import *

# create some noise model
noise_model = NoiseModel()
depol_error = depolarizing_error(0.1, 1)
readout_error = ReadoutError([[0.9, 0.1], [0.15, 0.85]])
noise_model.add_all_qubit_quantum_error(depol_error, ['u2', 'u3'])
noise_model.add_all_qubit_readout_error(readout_error)

# create GST circuits
gate = HGate()
basis = default_gateset_basis()
basis.add_gate(gate)
circuits = gateset_tomography_circuits(gateset_basis=basis)
for i in range(len(circuits)):
    circuits[i] = transpile(circuits[i], basis_gates=['id', 'u2', 'u3'])

# Run GST circuits
job = qiskit.execute(circuits, Aer.get_backend('qasm_simulator'), noise_model=noise_model, shots=10000)
result = job.result()

# Run GST fitter
fitter = GatesetTomographyFitter(result, circuits, basis)
result_gates = fitter.fit()
print(result_gates.keys())
# 'E', 'rho', 'Id', 'X_Rot_90', 'Y_Rot_90', 'h'
print(result_gates['rho'])
# [[1., 0.], [0., 0.]]
print(result_gates['E'])
# [[1., 0.], [0., 0.]]

What is the expected behavior?

The above code should not return a perfect projection [[1., 0.], [0., 0.]] for result_gates['E'].

Suggested solutions

gadial commented 4 years ago

This was a whole missing piece (thanks for catching it!), fixed in #408 .