-
Notifications
You must be signed in to change notification settings - Fork 45
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
Enable use of qiskit ParameterExpressions for circuit conversion: qiskit to braket #139
Conversation
…t to braket This modification allows users to convert their qiskit circuit object that was parametrized with a qiskit ParameterVector to convert it to a braket circuit.
Hi @lukasvoss, thank you for the contribution! This is a great feature. Please add some tests that cover the lines you've added and show that your changes work correctly. |
By default, qiskit names elements of a ``ParameterVector`` are named like this 'a[<index>]'. The '[]' parentheses are not supported by the QASM 3 syntax which leads to an error when trying to run a Braket Circuit with free parameters following the '[]'-naming. Therefore, I ensured that these will be removed before the ``ParamterExpression`` is passed to create a FreeParameterExpression out of it.
…t ``ParameterVector`` Assume this example: A one-qubit qiskit circuit with the parametrized Rx-gate as its only operation. When using a qiskit ``ParameterVector``` of length 1 (i.e., params = ParameterVector("a", 1)), this would lead to the Parameter being called 'a[0]' which leads to a QASM 3 syntax error when trying to run the circuit. The proposed changes ensure that the squared-parentheses '[]' are being removed in the parameter names.
Dear Lauren, dear Jean-Christophe, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On top of the comment above, we should also have tests in test_adapter.py
. test_convert_parametric_qiskit_to_braket_circuit
should be a good one to duplicate and adapt with ParameterExpression
and ParameterVector
.
@lukasvoss I took the liberty to push commits to your PR. Let me know if you are satisfied with the current implementation. |
@jcjaskula-aws Thanks for your contribution, looks good to me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will now be handled with renaming parameter values, adjusting for QASM3 compatibility by removing parenthesis and controlling for duplicates in the parameter naming.
@ALL: Thanks for all your contributions! |
Summary
convert_qiskit_to_braket_circuit
function.Details
This could look something like this for a parametrized CNOT gate in qiskit: