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

AutoQASM generates OpenQASM which assumes subroutine access to input variables #7

Open
ajberdy opened this issue Nov 28, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ajberdy
Copy link
Contributor

ajberdy commented Nov 28, 2023

The following code is technically against the OpenQASM spec, as you can only close over global const variables (https://openqasm.com/language/scope.html#subroutine-and-gate-scope)

We may want to choose to interpret this as inputs allowed, since it's ambiguous whether those can change at runtime (be overwritten)

@aq.subroutine
def rx_alpha(qubit: int):
    rx(qubit, FreeParameter("alpha"))

@aq.main(num_qubits=3)
def parametric():
    rx_alpha(2)

expected = """OPENQASM 3.0;
def rx_alpha(int[32] qubit) {
    rx(alpha) __qubits__[qubit];
}
input float[64] alpha;
qubit[3] __qubits__;
rx_alpha(2);"""

Note that the generated rx_alpha subroutine references the alpha input variable, which is defined only at global scope.

@rmshaffer rmshaffer changed the title Program class generates invalid OpenQASM (subroutine access to input variables) AutoQASM Program class generates invalid OpenQASM (subroutine access to input variables) Apr 15, 2024
@rmshaffer rmshaffer transferred this issue from amazon-braket/amazon-braket-sdk-python May 8, 2024
@rmshaffer rmshaffer added the bug Something isn't working label May 8, 2024
@rmshaffer rmshaffer changed the title AutoQASM Program class generates invalid OpenQASM (subroutine access to input variables) AutoQASM generates OpenQASM which assumes subroutine access to input variables May 8, 2024
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
Development

No branches or pull requests

2 participants