-
Notifications
You must be signed in to change notification settings - Fork 7
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
[FEATURE] External Function Calls #167
Comments
Hi @christian512 , thanks for the suggestion! We are right now in the process of decoupling the We are envisioning something like an unrolled qasm program which would more simply be converted as a list of statements to QIR like - import pyqasm
from qbraid_qir.qasm3 import QasmQIRConverter
def convert_to_qir(raw_qasm_str, ....):
unrolled_qasm = pyqasm.unroll(raw_qasm_str)
qir_converter = QasmQIRConverter(...)
....
return qir_converter.convert(unrolled_qasm) In this structure, an external gate list could be passed to I think, it'll be best to wait till the de-coupling is completed (as the repo is already intimately linked with |
I like the idea @christian512 ! |
Thanks for the feedback, @TheGupta2012 and @ryanhill1! I like the idea of decoupling from If there is a branch where I can contribute let me know :) |
It is happening right now and a rough timeline for |
@christian512 Migration / development on the new project is currently underway at https://github.com/qBraid/pyqasm. Once we've merged PR #3 the project will (hopefully) be stable-enough to then allow us to generate concrete issues and accept new contributors. Like @TheGupta2012 mentioned, this will likely be within 1-2 weeks. Would love to have you as one of the first contributors! |
Hi @christian512 , #3 has now merged and we are working towards integration of Fee free to look at some issues which I opened up in |
Feature Description
I have a custom gate definition in OpenQASM3 and a backend that supports this custom gate natively. When converting to QIR I want that
qbraid_qir
creates a call to an externally linked function for this native gate. Currently the visitor inserts the custom gate operation via_visit_custom_gate_operation()
.An example:
I have a backend that natively supports
rxx
gates. Sincerxx
is not part of thestdgates.inc
, this creates a custom gate definition in OpenQASM3:I could declare an externally linked function in
pyqir
for therxx
gate:The visitor should then add a call to this function instead of replacing the
rxx
with the custom gate definition.This issue might occur more often, since the quantum instruction set is not (yet) fixed and backends have different native gate sets, which are not in
stdgates.inc
nor in the QIS.Implementation (Optional)
I suggest to add a dictionary
_external_gates
to theBasicQasmVisitor
class, that holds the external gate functions:When visiting a generic gate operation, it should be first checked if an external function call is possible (probably insert here).
The initialization of the
pyqir.Function
objects might be a bit difficult, sinceqbraid_qir
would have to add the external function declarations to the qir module usingmod.add_external_function()
. Hence, the user would have to pass thepyqir.FunctionType
and the name of the function to theBasicQasmVisitor
.An example of externally linked functions in
pyqir
can be found here.The text was updated successfully, but these errors were encountered: