Skip to content

Non Unitary BARENCO gate #1805

@glanzz

Description

@glanzz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An issue that needs fixing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions