-
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!
qiskit_experiments/library/randomized_benchmarking/layer_fidelity_unitary.py
Outdated
Show resolved
Hide resolved
qiskit_experiments/library/randomized_benchmarking/layer_fidelity_unitary.py
Outdated
Show resolved
Hide resolved
qiskit_experiments/library/randomized_benchmarking/layer_fidelity_unitary.py
Outdated
Show resolved
Hide resolved
qiskit_experiments/library/randomized_benchmarking/layer_fidelity_unitary.py
Outdated
Show resolved
Hide resolved
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.
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.
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.
The Qiskit documentation for definition
describes it as "Return definition in terms of other basic gates". For RZZ, it is in terms of CX and RZ. Elsewhere the documentation says that the transpiler uses the definition to reason about basis gate equivalence. So I think what you highlight is okay -- the gates just have definitions in terms for CX to help with transpilation.
We can check that the gates are in the target by doing target.instruction_suported(g.name, qargs)
, similar to the one qubit case below but looping over the pairs in two_qubit_layers
instead of the individual physical qubits. (We could also pass parameters to instruction_supported
but there is not much point now. There is no support for ranges of valid parameters so all angles will still give True
).
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.
Hmm, looking at your other comment on gate vs instruction, I see that you are thinking of the case of submitting an arbitrary circuit which will be a unitary that could be benchmarked, while I am thinking in terms of a single named gate, like rzz
. For the abitrary circuit, we would need to check that the target supports all of its instructions (assuming we would not want to transpile it).
qiskit_experiments/library/randomized_benchmarking/layer_fidelity_unitary.py
Outdated
Show resolved
Hide resolved
qiskit_experiments/library/randomized_benchmarking/layer_fidelity_unitary.py
Outdated
Show resolved
Hide resolved
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
.
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.
Ah ok, that probably makes more sense. And then it would be from a circuit using .to_gate()
?
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.
It wouldn't change any other code I assume?
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.
I don't think it would change other code. If we only supported a named gate and not the output of QuantumCircuit.to_instruction
/QuantumCircuit.to_gate
, I think we could take out the change to clifford_utils.py
where a special case for instructions with names starting with "circuit" was added. I think that is falling into the case of adding internal instructions one by one instead of just data.append
like it could if RZZGate
was passed directly.
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.
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.
I guess this was more illustrative of how it would be done in a general case?
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.
One question is which is the general case -- passing a list of individual Qiskit gates or passing a list of gates that are derived from circuits and contain multiple instructions?
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
…ity_unitary.py Co-authored-by: Will Shanks <[email protected]>
Added a new class to do layer fidelity with an arbitrary set of 2Q unitary circuits for the entangling layer. Example usage: