C3XGate(angle=...) deprecation#4378
Conversation
Co-authored-by: Julien Gacon <gaconju@gmail.com>
| string (e.g. '110'), or None. If None, use all 1s. | ||
| """ | ||
| super().__init__('c3sqrtx', 4, [], label=label, num_ctrl_qubits=3, ctrl_state=ctrl_state) | ||
| self.base_gate = Gate('sqrtx', 1, []) |
There was a problem hiding this comment.
Did we agree to give this gate it's own class in this PR?
There was a problem hiding this comment.
If we have the SXGate base class it depends. We need to check if this decomposition is more efficient than the default mechanism to construct the 3-controlled version, also blocked by #4638.
There was a problem hiding this comment.
With #4638 and SXGate().control(3):
>>> transpiled = transpile(circuit, basis_gates=['u1','u2','u3','cx'], optimization_level=0)
>>> transpiled.count_ops()
OrderedDict([('cx', 120), ('u1', 112), ('u3', 30), ('u2', 4)])
>>> transpiled = transpile(circuit, basis_gates=['u1','u2','u3','cx'], optimization_level=3)
>>> transpiled.count_ops()
OrderedDict([('cx', 100), ('u1', 98), ('u3', 2), ('u2', 1)])the decomposition in this PR
>>> transpiled = transpile(circuit, basis_gates=['u1','u2','u3','cx'], optimization_level=0)
>>> transpiled.count_ops()
OrderedDict([('u1', 21), ('cx', 20), ('u2', 14)])
>>> transpiled = transpile(circuit, basis_gates=['u1','u2','u3','cx'], optimization_level=3)
>>> transpiled.count_ops()
OrderedDict([('u1', 20), ('cx', 20), ('u2', 2)])Looking at the CX count I think we should add this class.
| """ | ||
| from .u1 import CU1Gate | ||
|
|
||
| controlled_v = Instruction('cv', 2, 0, []) |
There was a problem hiding this comment.
This could go into the new module for sqrtx as well.
There was a problem hiding this comment.
It should, waiting for it to be merged 👍
|
|
|
#4638 merged. removing |
| # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | ||
| # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], | ||
| # [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=complex) | ||
| def to_matrix(self): |
There was a problem hiding this comment.
This is correct only if angle==pi/4, right?
There was a problem hiding this comment.
Yes. In principle we could compute the matrix for any angle and return that
|
PR #5668 is already taking care of this. Closing. |
Summary
The
C3XGateclass supports anangleparameter mostly because the need of aC3SqrtXGate. This turnsC3XGateinto a genericC3RXGate(which supportangle) and makesC3SqrtXGateandC3XGatesubclasses ofC3RXGate.Details and comments