Giter VIP home page Giter VIP logo

Comments (3)

LaurentAjdnik avatar LaurentAjdnik commented on August 29, 2024

Hi @bettinaheim!

there also exist tools that create an AST for a Python program

Using the built-in ast Python library probably is the way to go. Here's a nice tutorial.

From here, any Python source file can be converted into LLVM IR, with a little bit (= a ton) of work. PyLLVM attempted to do this: "A compiler from a subset of Python to LLVM-IR".

invoke the pyqir_generator on each node to emit QIR
compile parts of Python itself to QIR

The current mock language specializes in quantum circuit description, which makes it ready for conversion into QIR through pygir-generator.

Do we agree that our Python sample should mostly be code for generating a circuit, with no other complex Python code around?

For instance a few lines of Qiskit that would be parsed through the ast library and sent to pyqir-generator for QIR output (hence not using the Qiskit library itself at all)?

from pyqir.

LaurentAjdnik avatar LaurentAjdnik commented on August 29, 2024

Quick and dirty proof of concept on https://github.com/LaurentAjdnik/QWOQ2QIR (Qiskit without Qiskit to QIR 😁).

from pyqir.

bettinaheim avatar bettinaheim commented on August 29, 2024

This proof of concept is great, and exactly along the lines I was thinking. Yes, I agree that the main caveat to this approach is that Python is a huge language, and I would not generally recommend aiming to compile all of Python to QIR.
There are actually several projects that have worked on a Python -> LLVM compiler, in particular I believe related to a similar desire in the machine learning community to on one hand allow people to write domain specific code in Python and on the other hand leverage LLVM for performance benefits. I would hence agree that the goal here should be to illustrate what can be done and focus on what is most important for quantum programs (i.e. define a subset of python that is compiled to QIR rather than aiming for a general purpose tool).

@LaurentAjdnik Would you consider contributing a sample to this repository based on your work?

from pyqir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.