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 BARENCO gate #1805

Open
2 tasks done
glanzz opened this issue Oct 10, 2024 · 0 comments
Open
2 tasks done

Non Unitary BARENCO gate #1805

glanzz opened this issue Oct 10, 2024 · 0 comments
Labels
bug 🐛 An issue that needs fixing.

Comments

@glanzz
Copy link

glanzz commented Oct 10, 2024

Pre-Report Checklist

  • I am running the latest versions of pyQuil and the Forest SDK
  • I checked to make sure that this bug has not already been reported

Issue Description

I tried using BARENCO gate, i understand its experimental feature. But, the gate seems to provide non-unitary matrix when used with the following values.
{'alpha': -0.033780566167632184, 'phi': 0.0320570678937734, 'theta': 1.0471975511965976}

How to Reproduce

Code Snippet

from pyquil.simulation.matrices import *
from pyquil import Program
from pyquil.quilbase import DefGate

circuit = Program()
matrix = BARENCO(**{'alpha': -0.033780566167632184, 'phi': 0.0320570678937734, 'theta': 1.0471975511965976})
customgate = DefGate(f'BARENCO', matrix)
CUSTOM_GATE = customgate.get_constructor()
circuit += customgate
circuit += CUSTOM_GATE(0,1)

Error Output

customgate = DefGate(f'BARENCO', matrix)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/quilenv/lib/python3.11/site-packages/pyquil/quilbase.py", line 683, in __new__
    DefGate._validate_matrix(matrix, parameters is not None and len(parameters) > 0)
  File "/Users/xxx/quilenv/lib/python3.11/site-packages/pyquil/quilbase.py", line 721, in _validate_matrix
    raise ValueError("Matrix must be unitary.")
ValueError: Matrix must be unitary.

Environment Context

Operating System:

Python Version (python -V): 3.11

Quilc Version (quilc --version): 1.23.0

QVM Version (qvm --version): 1.17.1

Python Environment Details (pip freeze or conda list):
pyquil = 4.14.3

@glanzz glanzz added the bug 🐛 An issue that needs fixing. label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue that needs fixing.
Projects
None yet
Development

No branches or pull requests

1 participant