Closed AroosaIjaz closed 4 years ago
Thanks @AroosaIjaz for reporting.
@trbromley, it looks like the apps layer might be generating a non-unitary interferometer?
With help from @nquesada, we tracked this problem down to the decompositions.takagi()
function. This function can return a non-unitary matrix when input matrices that are highly degenerate.
One common case for a degenerate spectrum is when corresponding to a graph, perhaps why @AroosaIjaz noticed this through the graph similarity application in the apps layer.
It's quite an unpredictable bug, i.e., not all degenerate matrices result in non unitary output. However, we managed to find that the adjacency matrix of nx.balanced_tree(2, 4)
reliably results in takagi()
returning a non-unitary matrix. To accommodate for this, we have updated the takagi
function to treat real-valued matrices differently, using a simpler approach that correctly returns a unitary matrix.
I think there may still be a chance that highly degenerate complex-valued matrices can cause a problem, but @nquesada is working on updating takagi()
even more.
Nice detective work @trbromley @nquesada :shipit:
Thank you, guys!
Issue description
I called the Monte Carlo event probability function which has some issue with the decomposition functions for gaussian backend. I tried to solve the error by changing the tolerance level in the
rectangular
function indecompositions.py
. This did not help and on printing the 'diffn' in therectangular
function, values >1 were also seen. The error looks like this:Expected behavior: monte carlo feature vectors outputted
Actual behavior: ValueError seen
Reproduces how often: The error might or might not occur when I change the n_mean or the adj matrix.
System information:
Python version: 3.5.6 Platform info: Darwin-18.7.0-x86_64-i386-64bit Installation path: /Users/aroosa/Desktop/xanadu/strawberryfields/strawberryfields Strawberry Fields version: 0.13.0-dev Numpy version: 1.17.4 Scipy version: 1.3.3 SymPy version: 1.5.1 NetworkX version: 2.4 The Walrus version: 0.11.0 Blackbird version: 0.2.3 /opt/anaconda3/envs/graph/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning:
Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
/opt/anaconda3/envs/graph/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning:
Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
/opt/anaconda3/envs/graph/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:460: FutureWarning:
Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
/opt/anaconda3/envs/graph/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:461: FutureWarning:
Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
/opt/anaconda3/envs/graph/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:462: FutureWarning:
Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
/opt/anaconda3/envs/graph/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:465: FutureWarning:
Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
TensorFlow version: 1.3.0