I encountered an issue when attempting to decompose the unitary matrix of QFT(4) using the built-in quantum_shannon_decomposition function in Cirq.
According to the documentation, the quantum_shannon_decomposition function is supposed to decompose the unitary matrix into a sequence of CX, YPow, ZPow, and CNOT gates. However, it seems that the result of the decomposition contains a non-unitary matrix.
```shell
True
Traceback (most recent call last):
File "/tmp/qsd_bug_cirq.py", line 11, in
qsd_qft4_qc = cirq.Circuit(qsd_qft4_op)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/anaconda3/envs/qcs/lib/python3.11/site-packages/cirq/circuits/circuit.py", line 1771, in __init__
flattened_contents = tuple(ops.flatten_to_ops_or_moments(contents))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/anaconda3/envs/qcs/lib/python3.11/site-packages/cirq/ops/op_tree.py", line 134, in flatten_to_ops_or_moments
yield from flatten_to_ops_or_moments(subtree)
File "/anaconda3/envs/qcs/lib/python3.11/site-packages/cirq/ops/op_tree.py", line 133, in flatten_to_ops_or_moments
for subtree in root:
File "/anaconda3/envs/qcs/lib/python3.11/site-packages/cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py", line 89, in quantum_shannon_decomposition
yield from _msb_demuxer(qubits, v1, v2)
File "/anaconda3/envs/qcs/lib/python3.11/site-packages/cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py", line 158, in _msb_demuxer
yield from quantum_shannon_decomposition(demux_qubits[1:], W)
File "/anaconda3/envs/qcs/lib/python3.11/site-packages/cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py", line 66, in quantum_shannon_decomposition
raise ValueError(
ValueError: Expected input matrix u to be unitary, but it fails cirq.is_unitary check
```
Description of the issue
I encountered an issue when attempting to decompose the unitary matrix of QFT(4) using the built-in
quantum_shannon_decomposition
function in Cirq.According to the documentation, the
quantum_shannon_decomposition
function is supposed to decompose the unitary matrix into a sequence of CX, YPow, ZPow, and CNOT gates. However, it seems that the result of the decomposition contains a non-unitary matrix.How to reproduce the issue
Cirq version 1.4.1