Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bloch-Messiah returns incorrect results #728

Open
1 task done
nquesada opened this issue Aug 11, 2022 · 2 comments · May be fixed by #729
Open
1 task done

Bloch-Messiah returns incorrect results #728

nquesada opened this issue Aug 11, 2022 · 2 comments · May be fixed by #729
Assignees
Labels
bug Something isn't working

Comments

@nquesada
Copy link
Collaborator

nquesada commented Aug 11, 2022

Before posting a bug report

  • I have searched exisisting GitHub issues to make sure the issue does not already exist.

Expected behavior

Consider

import numpy as np
from thewalrus.random import random_symplectic
from thewalrus.quantum import is_symplectic
from strawberryfields.decompositions import bloch_messiah

r = np.array([1,1,1,1,2,2,0,0,0,0,0,0])
Sdiag= np.diag(np.concatenate([np.exp(r), np.exp(-r)]))
num_modes = len(r)
O1 = random_symplectic(num_modes, passive=True)
O2 = random_symplectic(num_modes, passive=True)
S = O1 @ Sdiag @ O2
assert is_symplectic(S)

# Do the Bloch-Messiah from SF
from strawberryfields.decompositions import bloch_messiah
O1, S, O2 = bloch_messiah(S)

assert is_symplectic(Sdiag)
assert is_symplectic(O1)
assert is_symplectic(O2)

Actual behavior

The returned matrices O1 and O2 in the example above are not symplectic.

Reproduces how often

Always

System information

Strawberry Fields: a Python library for continuous-variable quantum circuits.
Copyright 2018-2020 Xanadu Quantum Technologies Inc.

Python version:            3.9.7
Platform info:             
Installation path:         
Strawberry Fields version: 0.22.0-dev
Numpy version:             1.21.5
Scipy version:             1.8.0
SymPy version:             1.10
NetworkX version:          2.6.3
The Walrus version:        0.20.0-dev
Blackbird version:         0.4.0
XCC version:               0.1.2
TensorFlow version:        2.6.2

Source code

No response

Tracebacks

No response

Additional information

A fixed Bloch-Messiah can be found in https://github.com/polyquantique/thewalrus/pull/2
@nquesada nquesada added the bug Something isn't working label Aug 11, 2022
@nquesada nquesada changed the title Bloch-Messiah returns in correct results Bloch-Messiah returns incorrect results Aug 11, 2022
@josh146
Copy link
Member

josh146 commented Aug 12, 2022

Thanks for catching this @nquesada 😬

@sduquemesa
Copy link
Contributor

I haven't been able to find the root cause of this but it also happens for r = np.array([1,0,0]) or any other array with more than one zero. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants