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

Pyquil converts real gate parameter to complex. #1701

Open
bramathon opened this issue Nov 25, 2023 · 1 comment
Open

Pyquil converts real gate parameter to complex. #1701

bramathon opened this issue Nov 25, 2023 · 1 comment
Labels
bug 🐛 An issue that needs fixing.

Comments

@bramathon
Copy link
Contributor

This code snippet shows that the real parameter value provided (pi) is converted to a complex value (3.141592653589793+0j).

from numpy import pi
import pyquil
from pyquil.quil import Program
from pyquil.quilbase import Gate

print("Pyquil Version: " + pyquil.__version__)

program = Program()
program += Gate("RX", params=[pi], qubits=[0])

program.instructions[0].params[0]

Prior to pyquil 4 this would not happen.

I'm not sure if this is a bug, or intentional behaviour. However, I have difficulty understanding why this would be intentional as may expressions are defined only on the reals. Besides that, it doesn't seem right for pyquil to change the type of the value I provide.

@bramathon bramathon added the bug 🐛 An issue that needs fixing. label Nov 25, 2023
@MarquessV
Copy link
Contributor

MarquessV commented Dec 1, 2023

This has to do with how quil-rs stores parameters. Currently, it upcasts everything to a complex number since it is sufficient for representing all number types. I can look into expanding this to include integer and floating point types. Created a tracking quil-rs issue.

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

2 participants