-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add C FFI for Circuit Construction and transpilation #13276
Comments
The other tool which might be useful in this effort is cbindgen, the docs for this are here: https://github.com/mozilla/cbindgen/blob/master/docs.md |
I am looking into this issue |
Thank you for your interest @DisantHoridnt. Due to the scope of this issue, we’re currently handling it in the maintainer team. However, once we've advanced on this, contributions on concrete, smaller-scoped tasks would be welcome! |
sounds good, I currently am employed as a rust engineer who is responsible for translating c++ code. I might be able to help |
Building off the infrastructure for the sparse observable added in PR Qiskit#13445 this commit adds a C FFI for building Quantum Circuits. Right now there is a function to create an empty circuit with n qubits and m clbits and then a function to add standard gates to a circuit and then also get the op counts out of a circuit. This is a start of the functionality for a C API around interacting with circuits, later PRs will expand this so we can have a more fully featured C API in the future. Part of Qiskit#13276
Building off the infrastructure for the sparse observable added in PR Qiskit#13445 this commit adds a C FFI for building Quantum Circuits. Right now there is a function to create an empty circuit with n qubits and m clbits and then a function to add standard gates to a circuit and then also get the op counts out of a circuit. This is a start of the functionality for a C API around interacting with circuits, later PRs will expand this so we can have a more fully featured C API in the future. Part of Qiskit#13276
Building off the infrastructure for the sparse observable added in PR Qiskit#13445 this commit adds a C FFI for building Quantum Circuits. Right now there is a function to create an empty circuit with n qubits and m clbits and then a function to add standard gates to a circuit and then also get the op counts out of a circuit. This is a start of the functionality for a C API around interacting with circuits, later PRs will expand this so we can have a more fully featured C API in the future. Part of Qiskit#13276
What should we add?
After we have the full rust-native core data model in #13264 we can then expose a compiled language interface directly to that data model. Having a compiled language interface will let users from other programming languages besides Python leverage Qiskit for quantum computation. But also for Python users having this interface would let Python compiled extensions interface with Qiskit at a lower level directly from the extension. This can be exceedingly powerful for accelerating applications of Qiskit in python, the best example is numpy which exposes a C API which is how Qiskit interfaces with numpy arrays from Rust and has been key for our performance as we've been doing more in Rust.
A C FFI is a natural choice for this as most languages can interface with C, including Python and Rust, and defining a C API via rust is very simple, see: https://doc.rust-lang.org/nomicon/ffi.html#calling-rust-code-from-c.
To start this interface should be very low level and only express a basic interface for building a
QuantumCircuit
with standard gates (or other operations defined solely by Qiskit in rust) and then transpiling that circuit (and maybe individual transpiler pass functions). Also, I think to start we should consider this API experimental and not commit to it being a fully stable interface as Qiskit has never had an API like this before, but we should also strive to keep the interface public and stable as defined by the stability policy. Basically say it'll be stable but not guarantee it at least for the first few releases while we figure out the best patterns here.The text was updated successfully, but these errors were encountered: