-
Notifications
You must be signed in to change notification settings - Fork 127
[DRAFT] Unitary Layer RB #1561
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
base: main
Are you sure you want to change the base?
[DRAFT] Unitary Layer RB #1561
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good!
@@ -55,13 +55,15 @@ def _transpile_clifford_circuit( | |||
return _apply_qubit_layout(_decompose_clifford_ops(circuit), physical_qubits=physical_qubits) | |||
|
|||
|
|||
def _decompose_clifford_ops(circuit: QuantumCircuit) -> QuantumCircuit: | |||
def _decompose_clifford_ops(circuit: QuantumCircuit, all_circs: bool = False) -> QuantumCircuit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add on to the comment below to mention all_circs
?
if BackendV1 is not None and isinstance(backend, BackendV1): | ||
super()._set_backend(BackendV2Converter(backend, add_delay=True)) | ||
else: | ||
super()._set_backend(backend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new experiment. Let's start off not supporting BackendV1.
if BackendV1 is not None and isinstance(backend, BackendV1): | |
super()._set_backend(BackendV2Converter(backend, add_delay=True)) | |
else: | |
super()._set_backend(backend) | |
super()._set_backend(backend) |
try: | ||
from qiskit.providers import BackendV2Converter | ||
from qiskit.providers.backend import BackendV1 | ||
except ImportError: | ||
BackendV1 = None | ||
BackendV2Converter = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's start off without this backwards compatibility for Qiskit v1 and BackendV1.
|
||
import numpy as np | ||
from qiskit import QuantumCircuit | ||
from qiskit_experiments.library import StandardRB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused:
from qiskit_experiments.library import StandardRB |
noise_model = NoiseModel() | ||
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-3, 1), ["sx", "x"]) | ||
noise_model.add_all_qubit_quantum_error(depolarizing_error(0, 1), ["rz"]) | ||
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-2, 2), ["cx"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error should be on the gate used?
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-2, 2), ["cx"]) | |
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-2, 2), ["rzz"]) |
opts = self.experiment_options | ||
# validate two_qubit_gate if it is set | ||
if opts.two_qubit_gates: | ||
# TO DO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a to do or are we dropping validation? It should be easy to add the check if we are keeping this.
A generator of :class:`QuantumCircuit`\s. | ||
""" | ||
opts = self.experiment_options | ||
residal_qubits_by_layer = [self.__residual_qubits(layer) for layer in opts.two_qubit_layers] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
residal_qubits_by_layer = [self.__residual_qubits(layer) for layer in opts.two_qubit_layers] | |
residual_qubits_by_layer = [self.__residual_qubits(layer) for layer in opts.two_qubit_layers] |
num_qubits = max(self.physical_qubits) + 1 | ||
for i_sample in range(opts.num_samples): | ||
for i_set, (two_qubit_layer, one_qubits) in enumerate( | ||
zip(opts.two_qubit_layers, residal_qubits_by_layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zip(opts.two_qubit_layers, residal_qubits_by_layer) | |
zip(opts.two_qubit_layers, residual_qubits_by_layer) |
backend: Optional[Backend] = None, | ||
num_samples: int = 6, | ||
seed: Optional[Union[int, SeedSequence, BitGenerator, Generator]] = None, | ||
two_qubit_gates: Sequence[CircuitInstruction] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_instruction
actually returns an Instruction
rather than a CircuitInstruction
. Instruction
is an abstract instruction that can be applied and CircuitInstruction
is a specific application (it includes the qubits to apply the instruction on). Could we just make the type Gate
though? That is a subclass of Instruction
.
backend=backend, | ||
num_samples=num_samples, | ||
seed=seed, | ||
two_qubit_gates=[qc.to_instruction()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do from qiskit.circuit.library import RZZGate
and two_qubit_gates=[RZZGate(0.5)]
here.
Added a new class to do layer fidelity with an arbitrary set of 2Q unitary circuits for the entangling layer. Example usage: