randomized_benchmarking_seq¶
- randomized_benchmarking_seq(nseeds=1, length_vector=None, rb_pattern=None, length_multiplier=1, seed_offset=0, align_cliffs=False, interleaved_gates=None, is_purity=False, group_gates=None)[source]¶
Generate generic randomized benchmarking (RB) sequences.
- Parameters
nseeds (
int
) – The number of seeds. For each seed the function generates a separate list of output RB circuits.length_vector (
Optional
[List
[int
]]) –Length vector of the RB sequence lengths. Must be in ascending order. RB sequences of increasing length grow on top of the previous sequences.
For example:
length_vector = [1, 10, 20, 50, 75, 100, 125, 150, 175]
length_vector = None
is the same aslength_vector = [1, 10, 20]
rb_pattern (
Optional
[List
[List
[int
]]]) –A list of the lists of integers representing the qubits indexes. For example,
[[i,j],[k],...]
will make simultaneous RB sequences, where there is a 2-qubit RB sequence on qbits Qi and Qj, and a 1-qubit RB sequence on qubit Qk, etc. Each qubit appers at most once. The number of qubits on which RB is done is the sum of the lists sizes.For example:
rb_pattern = [[0]]
orrb_pattern = None
– create a 1-qubit RB sequence on qubit Q0.rb_pattern = [[0,1]]
– create a 2-qubit RB sequence on qubits Q0 and Q1.rb_pattern = [[2],[6,4]]
– create RB sequences that are 2-qubit RB for qubits Q6 and Q4, and 1-qubit RB for qubit Q2.
length_multiplier (
Optional
[List
[int
]]) – An array that scales each RB sequence by the multiplier.seed_offset (
int
) – What to start the seeds at, if we want to add more seeds later.align_cliffs (
bool
) –If
True
adds a barrier across all qubits in the pattern after each set of group elements (not necessarily Cliffords).Note: the alignment considers the group multiplier.
interleaved_gates (
Optional
[List
[List
[str
]]]) – A list of lists of gates that will be interleaved. It is notNone
only for interleaved randomized benchmarking. The lengths of the lists should be equal to the length of the lists inrb_pattern
.is_purity (
bool
) –True
only for purity randomized benchmarking (default isFalse
).Note: if
is_purity = True
then all patterns inrb_pattern
should have the same dimension (e.g. only 1-qubit sequences, or only 2-qubit sequences), andlength_multiplier = None
.group_gates (
Optional
[str
]) –On which group (or set of gates) we perform RB (the default is the Clifford group).
group_gates='0'
orgroup_gates=None
orgroup_gates='Clifford'
– Clifford group.group_gates='1'
orgroup_gates='CNOT-Dihedral'
orgroup_gates='Non-Clifford'
– CNOT-Dihedral group.
- Return type
(typing.List[typing.List[qiskit.circuit.quantumcircuit.QuantumCircuit]], typing.List[typing.List[int]], typing.Union[typing.List[typing.List[qiskit.circuit.quantumcircuit.QuantumCircuit]], NoneType], typing.Union[typing.List[typing.List[typing.List[qiskit.circuit.quantumcircuit.QuantumCircuit]]], NoneType], typing.Union[int, NoneType])
- Returns
A tuple of different fields depending on the inputs. The different fields are:
circuits
: list of lists of circuits for the RB sequences (a separate list for each seed).xdata
: the sequences lengths (with multiplier if applicable).circuits_interleaved
: (only ifinterleaved_gates
is notNone
): list of lists of circuits for the interleaved RB sequences (a separate list for each seed).circuits_purity
: (only ifis_purity=True
): list of lists of lists of circuits for purity RB (a separate list for each seed and each of the \(3^n\) circuits).npurity
: (only ifis_purity=True
): the number of purity RB circuits (per seed) which equals to \(3^n\), where n is the dimension.
- Raises
ValueError – if
group_gates
is unknown.ValueError – if
rb_pattern
is not valid.ValueError – if
length_multiplier
is not valid.
Examples
Generate simultaneous standard RB sequences.
length_vector = [1,10,20] rb_pattern = [[0,3],[2],[1]] length_multiplier = [1,3,3] align_cliffs = True
Create RB sequences that are 2-qubit RB for qubits Q0 and Q3, 1-qubit RB for qubit Q1, and 1-qubit RB for qubit Q2. Generate three times as many 1-qubit RB sequence elements, than 2-qubit elements. Place a barrier after 1 group element for the first pattern and after 3 group elements for the second and third patterns. The output
xdata
in this case isxdata=[[1,10,20],[3,30,60],[3,30,60]]
Generate simultaneous interleaved RB sequences.
rb_pattern = [[0,3],[2],[1]] interleaved_gates = [['cx 0 1'], ['x 0'], ['h 0']]
Interleave the 2-qubit gate
cx
on qubits Q0 and Q3, a 1-qubit gatex
on qubit Q2, and a 1-qubit gateh
on qubit Q1.Generated purity RB sequences.
rb_pattern = [[0,3],[1,2]] npurity = True
Create purity 2-qubit RB circuits separately on qubits Q0 and Q3 and on qubtis Q1 and Q2. The output is
npurity = 9
in this case.