qiskit-community / qiskit-experiments

Qiskit Experiments
https://qiskit-community.github.io/qiskit-experiments/
Apache License 2.0
154 stars 125 forks source link

Experiments QPT returns poor fidelity #724

Closed nkanazawa1989 closed 2 years ago

nkanazawa1989 commented 2 years ago

Informations

What is the current behavior?

QPT experiment in Qiskit Experiments reports lower fidelity than one in Qiskit Ignis.

Steps to reproduce the problem

from qiskit_experiments.library import ProcessTomography
from qiskit.ignis.verification import ProcessTomographyFitter, process_tomography_circuits
from qiskit import circuit, quantum_info as qi
from qiskit.providers.aer import AerSimulator

backend = AerSimulator(seed_simulator=123, shots=3000)

qc = circuit.QuantumCircuit(2)
qc.cx(0, 1)

# Qiskit Experiments
exp = ProcessTomography(qc, qubits=(0, 1))
exp.set_transpile_options(basis_gates=["cx", "sx", "rz"])
exp.analysis.set_options(fitter="cvxpy_linear_lstsq", fitter_options={"solver": "CVXOPT"})
exp.backend = backend
expdata = exp.run().block_for_results()
expdata.analysis_results("process_fidelity").value  # 0.9731546899748647

# Ignis
qpt_qcs = process_tomography_circuits(qc, measured_qubits=[0, 1])
result = backend.run(qpt_qcs).result()
process_fitter = ProcessTomographyFitter(result, circuits=qpt_qcs)
qpt_choi = process_fitter.fit(method='cvx', solver='CVXOPT')
qi.process_fidelity(qpt_choi, qc)  # 0.9999604926522441
chriseclectic commented 2 years ago

I need to look into this more, but one initial issue I found was the cvxpy fitter in experiments doesn't automatically set the trace preserving constraint for QPT. So until I can fix that you need to do that manually via "trace_preserving": True in the fitter options. That increases fidelity of the example to 0.9988, but that still looks a little low.

chriseclectic commented 2 years ago

I've figured out what the issue causing this is and will work on a fix. Basically the difference was that zero outcome measurements basis elements were not being included in the basis matrix from the lstsq fitters, which leads to slightly incorrectly normalized distributions when using the weighted fitters which makes the fitter struggle to satisfy the CPTP constraints as well.