Open FlorianFuerrutter opened 7 months ago
Hey, thanks for the suggestion. Direct unitary extraction from a pattern would certainly be a good feature (we don't have that yet)!
For pattens with flow (only XY-plane measurements), it might be easier to directly translate into a gate network with CZ (edges connecting different flow paths) and
J(\alpha) =
\begin{pmatrix}
1 & e^{i\alpha} \\
1 & -e^{i\alpha}
\end{pmatrix}
(for XY-plane measurements with angle $\alpha$ along flow paths) gates and work out the unitary directly. For pattens with gflow, as you suggest, it's likely best to do simulations. TN simulation without inputs may give you the unitary (if memory allows).
cc: @masa10-f - would you agree or not? lmk what you think.
Thanks for the good comments! @shinich1 @FlorianFuerrutter
As far as I understand, direct construction from tensornetwork seems to be the most efficient method, no matter the type of flow(causal flow / generalize flow / pauli flow). First off, we create a tensornetwork by turning each measurement command into its tensor equivalent(e.g. N -> |+>, E -> 4-rank CZ tensor, M -> projection vector). Then, we contract all the inner edges. After that, we end up with a 2n-rank tensor, which can be reshaped into an n-qubit Unitary matrix. In this approach, we don't have to compute each matrix element one by one; we get them all in one go.
Regarding the implementation, we'll need to modify tensornet.py. It is not hard but may need some tensornetwork know-how.
If you're just looking at patterns with causal flow, @shinich1 's idea is pretty straightforward. We can apply the same techniques used in various quantum circuit libraries.
Just a reminder, the existence of Pauli flow is the weakest condition of Unitary embedding for a given pattern. So what we have to check here is pauli flow :)
Describe the feature you'd like
Hey all, I'm interested if there is any (efficient) way to get the unitary implemented from a given pattern. I did not find any direct function but I think this could be done easily if one can set the input state arbitrarily (issue #53) and check for flow of a pattern.
Additional context
I would propose a (pseudo) code in that direction:
Maybe there is a better way to do this? Maybe even with the current code base?