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

Non-unitary matrix ValueError #12

Open
soyjdezcurra opened this issue Feb 19, 2024 · 3 comments
Open

Non-unitary matrix ValueError #12

soyjdezcurra opened this issue Feb 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@soyjdezcurra
Copy link

Steps to reproduce the problem

Input non-unitary matrix. I used the following matrix and vector:
matrix = [[ 48, 19, 6, 3],
[ 35, 5, 1, 0],
[ 57, 36, 18, 7],
[105, 95, 85, 75]]
b = [56.98, 31.83, 12.89, 7.46]

What is the current behavior?

Raises ValueError and doesn't run.

What is the expected behavior?

Solver should work with a non-unitary matrix (decompose into linear combination of unitaries).

@soyjdezcurra soyjdezcurra added the bug Something isn't working label Feb 19, 2024
@NicoRenaud
Copy link

Thanks @soyjdezcurra, for vqls to work the A matrix has to be symmetric (and hermitian if complex). Otherwise the pauli decomposition won't work. There was a test to check if the input matrix is symmetric or not, but it apparently got removed since the error you mentioned was a non-unitary one.

Can you try with a symmetric matrix and let me know if that works for you ?

Thanks

@soyjdezcurra
Copy link
Author

It does work with a symmetric matrix. Is there no way for vqls to work with a non-symmetric matrix?

Thanks for your time.

@NicoRenaud
Copy link

Hi and sorry for the late reply. You can have a non symmetric matrix but you then need to use a Pauli Decomposition to decompose it over unitaries. That may results in a large number of unitaries depending on your input matrix.

You can use:

vqls = VLQS(estimator, ansatz, optimizer, ..., options={'matrix_decomposition':'pauli'})
vqls.solve(A,b)

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

No branches or pull requests

2 participants