softwareQinc / staq

Full-stack quantum processing toolkit
https://iopscience.iop.org/article/10.1088/2058-9565/ab9359/pdf
MIT License
155 stars 28 forks source link

Python interface #30

Closed yourball closed 2 years ago

yourball commented 4 years ago

Hi,

great project!

I was wondering if it is possible to add a Python interface to Staq compiler? Of course that might be too much to ask, but on the other hand this would be super helpful for quantum researchers and developers.

In particular, I'm working on a project for automated benchmarking of quantum compilers, and having a python wrapper for basic functionality of Staq would be amazing:)

There are some existing automatic python wrappers for C++ code such as pybind11, SWIG, which are reasonably convenient to use. Did you guys consider implementing something like that?

meamy commented 4 years ago

Hi,

Thanks for your interest! A Python interface is something we've been looking into but haven't had the time to write just yet. Hopefully we can get something out soon, but in the meantime another option might be to run staq directly from within Python or other benchmarking scripts. As long as your tools can read and write openQASM this may be possible as a stop-gap, albeit most less likely ergonomic :) Our original goal with staq was to make source-to-source compilation tools as opposed to a quantum programming toolkit or environment.

We'll keep you posted on any progress towards a python interface. Thanks again!

DevelopDaily commented 4 years ago

If you really proceed to add a Python interface, I hope you do it as an add-on in a separate project. The staqand its sister project qppare the most elegant and the purest C++ quantum platforms I have ever seen. Adding a Python wrapper to them could pollute the core C++ code base technically and conceptually.

I have been doing what @meamy suggested for a long time, happily. I call staqand many other staq-based programs from other scripts. In my experience (and my opinion), that is even a better approach than a Python wrapper because you would never second-guess what the wrapper might have done to your applications.

Here is a friendly reminder of the very sound philosophy of the staq:

The design of staq is inspired from the UNIX philosophy of "less is more"...

--- excerpt from staq

Note that you can easily use Python to pipe in and pipe out with the staqand your own C++ applications.

vsoftco commented 2 years ago

Added a pystaq, a light Python wrapper as of https://github.com/softwareQinc/staq/commit/f3f7dfcc6cdb0940de8dbe7d40968e9f3c716cc9 See https://github.com/softwareQinc/staq/wiki/pystaq for further details.