qir-alliance / pyqir

PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).
https://qir-alliance.github.io/pyqir
MIT License
54 stars 24 forks source link

Add API for inserting phi nodes #279

Closed ausbin closed 3 weeks ago

ausbin commented 1 month ago

Allows inserting phi nodes and conditional branches. Hopefully addresses #242 and possibly #277

Testing

pytest passes with a local build of LLVM 14.0.6. I am building with the incantation here

I added a low-effort unit test. If y'all are interested in merging I can put more effort into adding new unit tests (when the giga-test I added fails, the output from pytest is pretty much unreadable)

idavis commented 1 month ago

To address this, I have updated #224 and created #280 as a tracking issue. A high level goal is to enable typed/opaque pointers using LLVM 16 to allow migration from the older typed pointers in QIR and then future versions would all be using the opaque APIs.

idavis commented 1 month ago

I've created a new issue #281 for tracking phi nodes and other bits that are part of adding the core of the adaptive profile support.

ausbin commented 1 month ago

@idavis I'm a little confused by your response, is that a note to self or something actionable on my end?

Also, is there a definition of the adaptive profile online? I only know about this Q# documentation, but I was hoping for something analogous to the description of the Base Profile.

idavis commented 1 month ago

@ausbin Could you please separate the phi node support from the dyn qubits? I like the phi node work. I'm hesitant to add the dyn qubits as the QIR profiles haven't defined what dynamic qubits will look like.

Here is the current Adaptive Profile. Using phi nodes requires the integer computation extension.

ausbin commented 3 weeks ago

Thanks for the link, @idavis. I will take a look.

I removed the dyn_qubit() stuff and added a couple of tests, is that better?