Skip to content

[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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

[DRAFT] Unitary Layer RB #1561

wants to merge 4 commits into from

Conversation

dcmckayibm
Copy link
Collaborator

Added a new class to do layer fidelity with an arbitrary set of 2Q unitary circuits for the entangling layer. Example usage:

rzz_gate_lst = []

for i in range(10):

    qc = QuantumCircuit(2)
    qc.rzz(np.pi/2/10*(i+1),0,1)
    print(np.pi/2/10*(i+1))

    rzz_gate_lst.append(qc.to_instruction())


rb_obj = LayerFidelityUnitary(physical_qubits = [0,1,2,3], 
                              two_qubit_layers = [[[0,1],[2,3]]], 
                              two_qubit_gates=rzz_gate_lst, 
                              lengths = [2,10,100], backend=backend, num_samples=1, seed=1, layer_barrier=False)

Copy link
Collaborator

@wshanks wshanks left a 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:
Copy link
Collaborator

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?

Comment on lines +348 to +351
if BackendV1 is not None and isinstance(backend, BackendV1):
super()._set_backend(BackendV2Converter(backend, add_delay=True))
else:
super()._set_backend(backend)
Copy link
Collaborator

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.

Suggested change
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)

Comment on lines +32 to +38
try:
from qiskit.providers import BackendV2Converter
from qiskit.providers.backend import BackendV1
except ImportError:
BackendV1 = None
BackendV2Converter = None

Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused:

Suggested change
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"])
Copy link
Collaborator

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?

Suggested change
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
Copy link
Collaborator

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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
Copy link
Collaborator

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()],
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants