Skip to content

Commit a98fc61

Browse files
authored
Make ancilla for BiQubitsMixer sided too. (#6313)
* Make ancilla for BiQubitsMixer sided too. * Add note regarding need for adjoint for ancilla qubits in BiQubitsMixer.
1 parent fefe350 commit a98fc61

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

cirq-ft/cirq_ft/algos/arithmetic_gates.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Iterable, Optional, Sequence, Tuple, Union, List, Iterator
16-
from numpy.typing import NDArray
15+
from typing import Iterable, Iterator, List, Optional, Sequence, Tuple, Union
1716

18-
from cirq._compat import cached_property
1917
import attr
2018
import cirq
19+
from cirq._compat import cached_property
20+
from numpy.typing import NDArray
21+
2122
from cirq_ft import infra
2223
from cirq_ft.algos import and_gate
2324

@@ -142,13 +143,25 @@ class BiQubitsMixer(infra.GateWithRegisters):
142143
y = 2*y_msb + y_lsb
143144
The Gate mixes the 4 qubits so that sign(x - y) = sign(x_lsb' - y_lsb') where x_lsb' and y_lsb'
144145
are the final values of x_lsb' and y_lsb'.
146+
147+
Note that the ancilla qubits are used to reduce the T-count and the user
148+
should clean the qubits at a later point in time with the adjoint gate.
149+
See: https://github.com/quantumlib/Cirq/pull/6313 and
150+
https://github.com/quantumlib/Qualtran/issues/389
145151
""" # pylint: disable=line-too-long
146152

147153
adjoint: bool = False
148154

149155
@cached_property
150156
def signature(self) -> infra.Signature:
151-
return infra.Signature.build(x=2, y=2, ancilla=3)
157+
one_side = infra.Side.RIGHT if not self.adjoint else infra.Side.LEFT
158+
return infra.Signature(
159+
[
160+
infra.Register('x', 2),
161+
infra.Register('y', 2),
162+
infra.Register('ancilla', 3, side=one_side),
163+
]
164+
)
152165

153166
def __repr__(self) -> str:
154167
return f'cirq_ft.algos.BiQubitsMixer({self.adjoint})'

0 commit comments

Comments
 (0)