You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multi-controlled gates are currently partially objects (MCX MCU1) and partially functions monkey-patched to the circuit (mcr*). Some, as the MCX, moved to the circuit library as Gate objects. In principle library objects can be added to the circuit using compose, but all multi-controlled gates right now are accessible as circuit methods.
This raises two questions:
Which multi-controlled gates should have their proper class?
How should they be added to circuits?
Possible solution:
The ones where we know of multiple implementations, such as MCX, or where more efficient implementations that the standard control mechanism are known.
Advantage: Less circuit methods
Problem: Verbose and need to import each gate to control
b. Allow the controlled circuit methods to accept lists of qubits:
circuit.crx(0.2, [0, 1, 2, 3, 4], 5) # goes and does RXGate(0.2).control(5)circuit.cx([0, 1, 2, 3, 4], 5) # goes and does MCX(5)
maybe the cx is still qualified to have mcx to also allow arguments such as mode.
Advantage: easy adding of multi-controlled gates, no additional methods
Problem: circuit.cx([0,1], 2) currently means apply two CX gates.
c. Keep mcrx as circuit method and
circuit.mcrx(0.2, [0, 1, 2, 3, 4], 5) # goes and does RXGate(0.2).control(5)circuit.mcx([0, 1, 2, 3, 4], 5) # goes and does MCX(5)
Advantage: easy adding of multi-controlled gates,
But: additional methods
Personally I'd prefer 2b, since it gives us the power of multi-controlled gates with an intuitive and somewhat expected syntax and I'm not aware of a use-case for the current interpretation where cx([0, 1], 2) constructs two CX gates. Also adding special variants of a gate can be done using a mode flag which is a little more convenient than importing the gate and appending it, i.e. circuit.cx(..., mode='v-chain') over from ... import MCXVChain; circuit.append(MCXVChain(), ...).
Are there opinions that the multi-controlled gates should only be library objects and not offer circuit methods? (@ajavadia@jaygambetta)
The text was updated successfully, but these errors were encountered:
I'm not aware of a use-case for the current interpretation where cx([0, 1], 2) constructs two CX gates
This is actually quite nice to have, and saves writing a for-loop just to add gates where you know they are going to go. Useful for cluster states, GHZ states etc.
Multi-controlled gates are currently partially objects (
MCX MCU1
) and partially functions monkey-patched to the circuit (mcr*
). Some, as theMCX
, moved to the circuit library asGate
objects. In principle library objects can be added to the circuit usingcompose
, but all multi-controlled gates right now are accessible as circuit methods.This raises two questions:
Possible solution:
The ones where we know of multiple implementations, such as
MCX
, or where more efficient implementations that the standard control mechanism are known.Two options:
a. Don't allow circuit methods:
Advantage: Less circuit methods
Problem: Verbose and need to import each gate to control
b. Allow the controlled circuit methods to accept lists of qubits:
maybe the
cx
is still qualified to havemcx
to also allow arguments such asmode
.Advantage: easy adding of multi-controlled gates, no additional methods
Problem:
circuit.cx([0,1], 2)
currently means apply twoCX
gates.c. Keep
mcrx
as circuit method andAdvantage: easy adding of multi-controlled gates,
But: additional methods
Personally I'd prefer 2b, since it gives us the power of multi-controlled gates with an intuitive and somewhat expected syntax and I'm not aware of a use-case for the current interpretation where
cx([0, 1], 2)
constructs two CX gates. Also adding special variants of a gate can be done using amode
flag which is a little more convenient than importing the gate and appending it, i.e.circuit.cx(..., mode='v-chain')
overfrom ... import MCXVChain; circuit.append(MCXVChain(), ...)
.Are there opinions that the multi-controlled gates should only be library objects and not offer circuit methods? (@ajavadia @jaygambetta)
The text was updated successfully, but these errors were encountered: