Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomized benchmarking fails to analyze the results from IBM Eagle, due to the lack of 2Q gate decomposition value for ECR gate #1419

Closed
jungmin-cho-eng opened this issue Feb 28, 2024 · 0 comments · Fixed by #1431
Labels
bug Something isn't working

Comments

@jungmin-cho-eng
Copy link

jungmin-cho-eng commented Feb 28, 2024

Informations

  • Qiskit Experiments version: 0.6.0
  • Python version: 3.12.1
  • Operating system: Ubuntu 20.04.6

What is the current behavior?

When I run Randomized benchmarking on IBM Eagle machine by following Randomized benchmarking reference, qiskit-experiment fails to analyze the results. Specifically, Python interpreter prints TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' from qiskit_experiments/library/randomized_benchmarking/rb_analysis.py", line 370, in _calculate_epg

Steps to reproduce the problem

Run a two-qubit RB experiment on any IBM Eagle backend.
Following code is from Randomized benchmarking reference

import numpy as np
from qiskit_experiments.library import StandardRB, InterleavedRB
from qiskit_experiments.framework import ParallelExperiment, BatchExperiment
import qiskit.circuit.library as circuits

service = QiskitRuntimeService(channel='ibm_quantum', token=*** Your token ***)
backend = service.backend('ibm_kyoto')  # Instead of ibm_kyoto, you can use ibm_brisbane, ibm_osaka, ibm_nazca, or ibm_cusco

lengths_2_qubit = np.arange(1, 200, 30)
lengths_1_qubit = np.arange(1, 800, 200)
num_samples = 10
seed = 1010
qubits = (1, 2)

# Run a 1-qubit RB experiment on qubits 1, 2 to determine the error-per-gate of 1-qubit gates
single_exps = BatchExperiment(
    [
        StandardRB((qubit,), lengths_1_qubit, num_samples=num_samples, seed=seed)
        for qubit in qubits
    ],
    flatten_results=True,
)
expdata_1q = single_exps.run(backend).block_for_results()

# Run an RB experiment on qubits 1, 2
exp_2q = StandardRB(qubits, lengths_2_qubit, num_samples=num_samples, seed=seed)

# Use the EPG data of the 1-qubit runs to ensure correct 2-qubit EPG computation
exp_2q.analysis.set_options(epg_1_qubit=expdata_1q.analysis_results())

# Run the 2-qubit experiment
expdata_2q = exp_2q.run(backend).block_for_results()

# View result data
print("Gate error ratio: %s" % expdata_2q.experiment.analysis.options.gate_error_ratio)
display(expdata_2q.figure(0))
for result in expdata_2q.analysis_results():
    print(result)

What is the expected behavior?

Randomized benchmarking should analyze the results from IBM backend and print the result without any error.

Suggested solutions

The cause of the error is that rb_analysis.py lacks the Clifford decomposition ratio for ECR gate. IBM Eagle machines use ECR gate as a basis two-qubit gate. Therefore, when rb_analysis.py calculates EPC from EPG_ecr, it tries to find the Clifford decomposition ratio for ECR gate from a dictionary standard_2q_ratio. However, there is no such key in the dictionary, so it gets None as a return. Then, it multiplies the retuned None with a float, so a TypeError occurs.

From line 317 to 335 in qiskit_experiments/library/randomized_benchmarking/rb_analysis.py", line 370, in _calculate_epg, I added a key and a value "ecr": 1.0, at the end of the dictionary standard_2q_ratio.
ECR gate is also a Clifford gate (Reference), so the value 1.0 makes sense.

    # Gate count in (CX, CSX)-based decomposition, 1q gate contribution is ignored.
    # Amplitude or duration modulated pulse implementation is not considered.
    standard_2q_ratio = {
        "swap": 3.0,
        "rxx": 2.0,
        "rzz": 2.0,
        "cx": 1.0,
        "cy": 1.0,
        "cz": 1.0,
        "ch": 1.0,
        "crx": 2.0,
        "cry": 2.0,
        "crz": 2.0,
        "csx": 1.0,
        "cu1": 2.0,
        "cp": 2.0,
        "cu": 2.0,
        "cu3": 2.0,
        "ecr": 1.0,  # -> I added this line
    }

With the modified rb_analysis.py as the upper code block, I verified that Randomized benchmarking works without an error for ibm_kyoto.

@jungmin-cho-eng jungmin-cho-eng added the bug Something isn't working label Feb 28, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 16, 2024
### Summary
Fixed a bug in EPG (error per gate) computation in `RBAnalysis` where it
fails with a ``TypeError`` for backends with ECR gate as a 2-qubit basis
gate (e.g. IBM Eagle processors).
Fixed #1419 .

### Details and comments
Added the standard gate error ratio (`1.0`) for ECR gate as suggested in
the issue. Also added a sentence to explain how to skip EPG computation
in the manual.
mergify bot pushed a commit that referenced this issue Apr 16, 2024
### Summary
Fixed a bug in EPG (error per gate) computation in `RBAnalysis` where it
fails with a ``TypeError`` for backends with ECR gate as a 2-qubit basis
gate (e.g. IBM Eagle processors).
Fixed #1419 .

### Details and comments
Added the standard gate error ratio (`1.0`) for ECR gate as suggested in
the issue. Also added a sentence to explain how to skip EPG computation
in the manual.

(cherry picked from commit 44178f7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant