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
`pygridsynth` provides functionality for approximating multi-qubit unitary matrices using the Clifford+T gate set. This is useful for synthesizing quantum circuits that implement arbitrary multi-qubit unitaries.
144
+
145
+
**Basic usage:**
146
+
<!-- multi_qubit_basic -->
147
+
```python
148
+
import mpmath
149
+
150
+
from pygridsynth.multi_qubit_unitary_approximation import (
151
+
approximate_multi_qubit_unitary,
152
+
)
153
+
154
+
# Define a target unitary matrix (example: 2-qubit identity)
155
+
num_qubits =2
156
+
U = mpmath.eye(2**num_qubits) # 4x4 identity matrix
-`epsilon`: Error tolerance (can be `str`, `float`, or `mpmath.mpf`)
210
+
-`return_domega_matrix`: If `True`, returns `DOmegaMatrix`; if `False`, returns `mpmath.matrix` (default: `False`)
211
+
-`scale_epsilon`: Whether to scale epsilon based on the number of qubits (default: `True`)
212
+
-`cfg`: Optional `GridsynthConfig` object for advanced configuration
213
+
-`**kwargs`: Additional configuration options (ignored if `cfg` is provided)
214
+
215
+
**Returns:**
216
+
217
+
A tuple of `(circuit, U_approx)`:
218
+
-`circuit`: `QuantumCircuit` object representing the Clifford+T decomposition
219
+
-`U_approx`: Approximated unitary matrix (`mpmath.matrix` or `DOmegaMatrix` depending on `return_domega_matrix`)
220
+
221
+
### Mixed Unitary Synthesis
222
+
223
+
`pygridsynth` also provides functionality for mixed unitary synthesis, which approximates a target unitary by mixing multiple perturbed unitaries. This is useful for reducing the number of T-gates in quantum circuits.
224
+
225
+
The library provides two versions: `mixed_synthesis_parallel` (for parallel execution) and `mixed_synthesis_sequential` (for sequential execution).
226
+
227
+
**Basic usage with mpmath.matrix:**
228
+
<!-- mixed_synthesis_sequential -->
229
+
```python
230
+
from pygridsynth.mixed_synthesis import mixed_synthesis_sequential
231
+
from pygridsynth.mymath import diamond_norm_error_from_choi, random_su
232
+
233
+
# Generate a random SU(2^n) unitary matrix
234
+
num_qubits =2
235
+
unitary = random_su(num_qubits)
236
+
237
+
# Parameters
238
+
eps =1e-4# Error tolerance
239
+
M =64# Number of Hermitian operators for perturbation
240
+
seed =123# Random seed for reproducibility
241
+
242
+
# Compute mixed synthesis (sequential version)
243
+
result = mixed_synthesis_sequential(unitary, num_qubits, eps, M, seed=seed)
244
+
245
+
if result isnotNone:
246
+
circuit_list, eu_np_list, probs_gptm, u_choi, u_choi_opt = result
from pygridsynth.mixed_synthesis import mixed_synthesis_parallel
259
+
260
+
# Generate a random SU(2^n) unitary matrix
261
+
num_qubits =2
262
+
unitary = mpmath.eye(2**num_qubits)
263
+
264
+
# Parameters
265
+
eps =1e-4# Error tolerance
266
+
M =64# Number of Hermitian operators for perturbation
267
+
seed =123# Random seed for reproducibility
268
+
269
+
# For faster computation with multiple cores
270
+
result = mixed_synthesis_parallel(unitary, num_qubits, eps, M, seed=seed)
271
+
```
272
+
273
+
**Parameters:**
274
+
275
+
-`unitary`: Target unitary matrix (`mpmath.matrix` or `numpy.ndarray`)
276
+
-`num_qubits`: Number of qubits
277
+
-`eps`: Error tolerance parameter
278
+
-`M`: Number of Hermitian operators for perturbation
279
+
-`seed`: Random seed for reproducibility (default: `123`)
280
+
-`dps`: Decimal precision (default: `-1` for auto-calculation)
281
+
282
+
**Returns:**
283
+
284
+
A tuple of `(circuit_list, eu_np_list, probs_gptm, u_choi_opt)` or `None` on failure:
285
+
-`circuit_list`: List of `QuantumCircuit` objects for perturbed unitaries
286
+
-`eu_np_list`: List of approximated unitary matrices (numpy arrays)
287
+
-`probs_gptm`: Array of mixing probabilities
288
+
-`u_choi_opt`: Optimal mixed Choi matrix
289
+
290
+
**Note:** The parallel version (`mixed_synthesis_parallel`) uses multiprocessing and may be faster for large `M` values, while the sequential version (`mixed_synthesis_sequential`) is more suitable for debugging or when parallel execution is not desired.
291
+
141
292
142
293
## Contributing
143
294
@@ -149,9 +300,15 @@ This project is licensed under the MIT License.
149
300
150
301
## References
151
302
152
-
- Brett Giles and Peter Selinger. Remarks on Matsumoto and Amano's normal form for single-qubit Clifford+T operators, 2019.
153
-
- Ken Matsumoto and Kazuyuki Amano. Representation of Quantum Circuits with Clifford and π/8 Gates, 2008.
154
-
- Neil J. Ross and Peter Selinger. Optimal ancilla-free Clifford+T approximation of z-rotations, 2016.
155
-
- Peter Selinger. Efficient Clifford+T approximation of single-qubit operators, 2014.
156
-
- Peter Selinger and Neil J. Ross. Exact and approximate synthesis of quantum circuits. https://www.mathstat.dal.ca/~selinger/newsynth/, 2018.
157
-
- Vadym Kliuchnikov, Dmitri Maslov, and Michele Mosca. Fast and efficient exact synthesis of single qubit unitaries generated by Clifford and T gates, 2013.
- Peter Selinger. "Efficient Clifford+T approximation of single-qubit operators." Quantum Info. Comput. 15, no. 1-2 (2015): 159-180.
305
+
- Neil J. Ross and Peter Selinger. "Optimal ancilla-free Clifford+T approximation of z-rotations." Quantum Info. Comput. 16, no. 11-12 (2016): 901-953.
306
+
- Vadym Kliuchnikov, Dmitri Maslov, and Michele Mosca. "Fast and efficient exact synthesis of single-qubit unitaries generated by Clifford and T gates." Quantum Info. Comput. 13, no. 7-8 (2013): 607-630.
307
+
- Ken Matsumoto and Kazuyuki Amano. "Representation of Quantum Circuits with Clifford and π/8 Gates." arXiv: Quantum Physics (2008). URL: https://api.semanticscholar.org/CorpusID:17327793.
308
+
- Brett Gordon Giles and Peter Selinger. "Remarks on Matsumoto and Amano's normal form for single-qubit Clifford+T operators." ArXiv abs/1312.6584 (2013). URL: https://api.semanticscholar.org/CorpusID:10077777.
309
+
- Vivek V. Shende, Igor L. Markov, and Stephen S. Bullock. "Minimal universal two-qubit controlled-NOT-based circuits." Phys. Rev. A 69, no. 6 (2004): 062321. DOI: 10.1103/PhysRevA.69.062321.
310
+
- Vivek V. Shende, Igor L. Markov, and Stephen S. Bullock. "Finding Small Two-Qubit Circuits." Proceedings of SPIE - The International Society for Optical Engineering (2004). DOI: 10.1117/12.542381.
311
+
- Vivek V. Shende, Igor L. Markov, and Stephen S. Bullock. "Smaller Two-Qubit Circuits for Quantum Communication and Computation." In Proceedings of the Conference on Design, Automation and Test in Europe - Volume 2, p. 20980. IEEE Computer Society, 2004.
- Anna M. Krol and Zaid Al-Ars. "Beyond quantum Shannon decomposition: Circuit construction for n-qubit gates based on block-ZXZ decomposition." Physical Review Applied 22, no. 3 (2024): 034019. DOI: 10.1103/PhysRevApplied.22.034019.
314
+
- Peter Selinger and Neil J. Ross. "Exact and approximate synthesis of quantum circuits." (2018). URL: https://www.mathstat.dal.ca/~selinger/newsynth/.
0 commit comments