3
$\begingroup$

I was running the IBM qiskit sample code and noticed that the results vary on different backends. I thought it was quantum noise, so I repeated the same calculation on many different backends and got this figure:

enter image description here

The results are very consistent within the same backend but vary quite a bit between backends, particularly on fake_manila, fake_kyoto, and ibm_kyoto. So, the cause does not seem to be quantum noise.

BTW, The theoretical result (from matrix multiplication) is shown on the right most point as $\langle v|H|v\rangle$.

Did I do something wrong?

Here is my code:

from qiskit.circuit.library import RealAmplitudes
from qiskit.quantum_info import SparsePauliOp
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import Session, EstimatorV2 as Estimator

from qiskit_ibm_runtime.fake_provider import (FakeAlgiers, FakeAthensV2, FakeBelemV2, FakeManilaV2,
                                              FakeAuckland, FakeBrisbane, FakeOsaka, FakeKyoto)
from qiskit.quantum_info import Statevector
import numpy as np

psi = RealAmplitudes(num_qubits=2, reps=2)
theta = [0, 1, 1, 2, 3, 5]

hamiltonian = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])

service = QiskitRuntimeService()
fake_backends = [FakeAlgiers(), FakeAthensV2(), FakeBelemV2(), FakeManilaV2(), FakeAuckland(),
                 FakeBrisbane(), FakeOsaka(), FakeKyoto()] 
real_backends = service.backends(simulator=False, operational=True)
all_backends = real_backends

results = {}  # keep track all the results
repeats = 10
for backend in fake_backends:
    pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
    isa_psi = pm.run(psi)
    isa_observables = hamiltonian.apply_layout(isa_psi.layout)

    estimator = Estimator(backend=backend)
    values = results.get(backend.name, [])
    for r in range(repeats):
        job = estimator.run([(isa_psi, isa_observables, [theta])])
        pub_result = job.result()[0]
        print(f"Expected values from {backend.name}: {pub_result.data.evs}")
        values.append(pub_result.data.evs)
    results[backend.name] = values

repeats = 3
for backend in real_backends:
    pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
    isa_psi = pm.run(psi)
    isa_observables = hamiltonian.apply_layout(isa_psi.layout)

    with Session(service=service, backend=backend):
        estimator = Estimator(backend=backend)
        values = results.get(backend.name, [])
        for r in range(repeats):
            job = estimator.run([(isa_psi, isa_observables, [theta])])
            pub_result = job.result()[0]
            print(f"Expected values from {backend.name}: {pub_result.data.evs}")
            values.append(pub_result.data.evs)
        results[backend.name] = values

# compute <psi|H|psi> using matrices
statevector = Statevector(psi.assign_parameters(theta))
v = np.matrix(statevector.data).transpose()
h = hamiltonian.to_matrix()
results['<v|H|v>'] = v.getH() @  h @ v
print(f"<v|H|v> = {v.getH() @  h @ v}")
$\endgroup$

1 Answer 1

4
$\begingroup$

The problem is caused by a different type of noise each QPU suffers from. Nowadays, it is even not easy to produce two completely same qubits, not to mention two identical QPUs.

Please, have a look at calibration data in IBM Q portal. You can see that for example T1 and T2 times vary widely both for particular QPU and also among them.

These discrepancies in quality of qubits cause that one circuit runs differently on different backends.

$\endgroup$
5
  • 2
    $\begingroup$ At least for fake backends, I would expected the answer be centered at the 'true' value with some noises. But the results are in a tight range for each fake backend but away from the 'true' value. $\endgroup$
    – Guangliang
    Apr 7 at 16:42
  • 1
    $\begingroup$ @Guangliang: This would be the case for "faultless" simulator. However, the fake backends behave in the same way as real QPUs they represent. $\endgroup$ Apr 7 at 18:17
  • $\begingroup$ If the fake backends behave in the same way as the real ones, then how to explain the gap between ibm_kyoto and fake_kyoto? There seems to be some systematic difference between these two. $\endgroup$
    – Guangliang
    Apr 8 at 14:14
  • 1
    $\begingroup$ @Guangliang: Good point. Now, I will a little bit speculate. Real QPU are sometimes recalibrated and sometimes upgraded. You can check yourself by comparison of QPU parameters downloaded sometime ago with the one after QPU maintanance. There could be differences. Maybe, these changes were not reflected in the fake model. However, as I said, this is plaussible scenario but still only a hypothesis. $\endgroup$ Apr 8 at 15:11
  • $\begingroup$ @Guangliang: If the answer is ok for you, could you please accept it? $\endgroup$ Apr 11 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.