qir-alliance / qcor

C++ compiler for heterogeneous quantum-classical computing built on Clang and XACC
http://docs.aide-qc.org
MIT License
97 stars 39 forks source link

Make QCOR QIR Compatible with QIR Alliance QAT Tool #246

Open amccaskey opened 2 years ago

amccaskey commented 2 years ago

I just tried to take a QIR file output from qcor and translate to the base profile with the QAT tool from the QIR Alliance. It did not work out of the box. Turns out, QAT will look for a function attribute and perform the transformation from there.

From Stefan

QAT looks for a specific LLVM attribute to know which function to start it’s processing from. 
This can be either “InteropFriendly” (the default) or “EntryPoint” (selectable with “—entry-point-attr EntryPoint”). 
Then the IR needs to be updated to have that attribute on exactly one function.
In this case, if I update main to include that attribute, the transformation succeeds.

Also there is a discrepancy with our measurement call

One other thing to note: transformation of measurement into the form described in the base profile, 
which uses static result identifiers, is dependent on seeing the intrinsic “__quantum__qis__m__body” 
as the measurement function. That’s why the “__quantum__qis__mz” in the above did not get transformed.
amccaskey commented 2 years ago

QSharp outputs QIR with measure instructions __quantum__qis__m__body. Suggest we do the same since this is what QAT apply base profile looks for.

stevescia commented 1 year ago

I'd like to investigate this bug; can you assign to me?