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

[BUG] Duplicate qubits not detected in function call #80

Open
TheGupta2012 opened this issue Nov 14, 2024 · 0 comments
Open

[BUG] Duplicate qubits not detected in function call #80

TheGupta2012 opened this issue Nov 14, 2024 · 0 comments
Labels
bug Something isn't working qasm3 Related to openqasm3

Comments

@TheGupta2012
Copy link
Contributor

Environment

  • PyQASM version: source
  • Python version: 3.12.7
  • Operating system: macOS 14.4

What happened?

The following qasm program passes unrolling -

In [1]: import pyqasm

In [2]: qasm_str = """
   ...: OPENQASM 3.0;
   ...: include "stdgates.inc";
   ...:
   ...: qubit[2] q;
   ...:
   ...: def custom_fn( qubit q1, qubit q2, qubit q3) -> bool {
   ...:    h q1;
   ...:    h q2;
   ...:    h q3;
   ...:    return true;
   ...: }
   ...:
   ...: bool result = custom_fn(q[0], q[1], q[1]);
   ...: """

In [3]: mod = pyqasm.loads(qasm_str)

In [4]: mod.unroll()

In [5]: mod.qasm_str().splitlines()
Out[5]:
['OPENQASM 3.0;',
 'include "stdgates.inc";',
 'qubit[2] q;',
 'h q[0];',
 'h q[1];',
 'h q[1];']

but should have raised the error that we have duplicate qubit arguments present in the function call.

Suggestions (Optional)

  • The duplicate_qubit_detect_map should be updated across argument validation. Presently, it is only getting updated if a register name is not present.
  • Moreover, the validate_unique_qubits should have a more descriptive doc and moved to the Qasm3SubroutineProcessor because it is referred only inside the process_quantum_arg method
@TheGupta2012 TheGupta2012 added bug Something isn't working qasm3 Related to openqasm3 labels Nov 14, 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 qasm3 Related to openqasm3
Projects
None yet
Development

No branches or pull requests

1 participant