Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Commit

Permalink
Update RB code to work with Terra's CNOTDihedral class and remove thi…
Browse files Browse the repository at this point in the history
…s class from Ignis (#571)
  • Loading branch information
ShellyGarion authored May 13, 2021
1 parent aee4868 commit 88c17a5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 1,869 deletions.
4 changes: 1 addition & 3 deletions qiskit/ignis/verification/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
InterleavedRBFitter
PurityRBFitter
CNOTDihedralRBFitter
CNOTDihedral
count_gates
gates_per_clifford
calculate_1q_epg
Expand Down Expand Up @@ -115,8 +114,7 @@
QOTPCorrectCounts
"""
from .quantum_volume import qv_circuits, QVFitter
from .randomized_benchmarking import (CNOTDihedral,
randomized_benchmarking_seq,
from .randomized_benchmarking import (randomized_benchmarking_seq,
RBFitter, InterleavedRBFitter,
PurityRBFitter, CNOTDihedralRBFitter,
count_gates, gates_per_clifford,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# Randomized Benchmarking functions
from .circuits import randomized_benchmarking_seq
from .dihedral import (CNOTDihedral, decompose_cnotdihedral, random_cnotdihedral)
from .fitters import (RBFitter, InterleavedRBFitter, PurityRBFitter,
CNOTDihedralRBFitter)
from .rb_utils import (count_gates, gates_per_clifford,
Expand Down
18 changes: 8 additions & 10 deletions qiskit/ignis/verification/randomized_benchmarking/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
from numpy.random import RandomState
import qiskit
from qiskit.circuit import QuantumCircuit, Instruction

from qiskit.quantum_info import Clifford, CNOTDihedral

from .rb_groups import RBgroup
from .dihedral import CNOTDihedral


def handle_length_multiplier(length_multiplier, len_pattern,
Expand Down Expand Up @@ -151,18 +150,17 @@ def handle_interleaved_elem(interleaved_elem, rb_group, keep_original_interleave

for elem in interleaved_elem:
group_elem = elem
group_gates_type = rb_group.group_gates_type()
if isinstance(elem, (QuantumCircuit, Instruction)):
num_qubits = elem.num_qubits
group_elem = rb_group.iden(num_qubits)
group_elem = group_elem.from_circuit(elem)
if not (isinstance(group_elem, qiskit.quantum_info.operators.symplectic.clifford.Clifford)
group_elem = rb_group._rb_group(elem)
if not (isinstance(group_elem, Clifford)
and group_gates_type == 0) and \
not (isinstance(group_elem, CNOTDihedral) and group_gates_type == 1):
raise ValueError("Invalid interleaved element type.")

if not isinstance(group_elem, QuantumCircuit) and \
not isinstance(group_elem,
qiskit.quantum_info.operators.symplectic.clifford.Clifford) \
Clifford) \
and not isinstance(group_elem, CNOTDihedral):
raise ValueError("Invalid interleaved element type. "
"interleaved_elem should be a list of QuantumCircuit,"
Expand Down Expand Up @@ -210,7 +208,7 @@ def randomized_benchmarking_seq(nseeds: int = 1,
interleaved_elem:
Optional[
Union[List[QuantumCircuit], List[Instruction],
List[qiskit.quantum_info.operators.symplectic.Clifford],
List[Clifford],
List[CNOTDihedral]]] = None,
keep_original_interleaved_elem: Optional[bool] = True,
is_purity: bool = False,
Expand Down Expand Up @@ -279,8 +277,8 @@ def randomized_benchmarking_seq(nseeds: int = 1,
lists in ``rb_pattern``.
keep_original_interleaved_elem: whether to keep the original interleaved
element as it is when adding it to the RB circuits or to transform
it to a standard representation via group elements
element as it is when adding it to the RB circuits or to transform
it to a standard representation via group elements
is_purity: ``True`` only for purity randomized benchmarking
(default is ``False``).
Expand Down
Loading

0 comments on commit 88c17a5

Please sign in to comment.