|
32 | 32 | Signature, |
33 | 33 | SoquetT, |
34 | 34 | ) |
| 35 | +from qualtran.bloqs.bookkeeping import Partition |
35 | 36 | from qualtran.drawing import Text, TextBox, WireSymbol |
36 | 37 | from qualtran.symbolics import is_symbolic, SymbolicInt |
37 | 38 |
|
@@ -116,11 +117,17 @@ def ctrl_adder( |
116 | 117 | bb: 'BloqBuilder', ctrl_soqs: Sequence['SoquetT'], in_soqs: Dict[str, 'SoquetT'] |
117 | 118 | ) -> Tuple[Iterable['SoquetT'], Iterable['SoquetT']]: |
118 | 119 | parts = [ |
119 | | - (Register(f'ctrl_{i}', dtype=dtype, shape=shape), 'q') |
| 120 | + Register(f"ctrl_{i}", dtype=dtype, shape=shape) |
120 | 121 | for i, (dtype, shape) in enumerate(ctrl_spec.activation_function_dtypes()) |
121 | | - ] + [(reg, 'q') for reg in self.signature] |
122 | | - all_soqs = in_soqs | {f'ctrl_{i}': ctrl_soq for i, ctrl_soq in enumerate(ctrl_soqs)} |
123 | | - out_soqs = bb.add_and_partition(ctrl_I, partitions=parts, left_only=False, **all_soqs) |
| 122 | + ] + [reg for reg in self.signature] |
| 123 | + |
| 124 | + all_soqs = in_soqs | {f"ctrl_{i}": ctrl_soq for i, ctrl_soq in enumerate(ctrl_soqs)} |
| 125 | + |
| 126 | + pratition = Partition(ctrl_I.signature.n_qubits(), regs=parts) |
| 127 | + q = bb.add(pratition.adjoint(), **all_soqs) |
| 128 | + q = bb.add(ctrl_I, q=q) |
| 129 | + out_soqs = bb.add(pratition, x=q) |
| 130 | + |
124 | 131 | return out_soqs[:-1], out_soqs[-1:] |
125 | 132 |
|
126 | 133 | return ctrl_I, ctrl_adder |
|
0 commit comments