microsoft / qsharp-language

Official repository for design of the quantum programming language Q# and its core libraries
MIT License
233 stars 54 forks source link

Specification update to enable runtime-implementation initialization and finalization routines #91

Open amccaskey opened 3 years ago

amccaskey commented 3 years ago

Suggestion

In our QIR implementation, we have the need to run one-time initialization before any QIR API functions are called. At program exit, it is also useful for us to explicitly run any finalization activities (clean-up, print out, etc.). One specific use case that drives this initialization functionality is the need to indicate specifics about the backend being targeted. For example, our runtime implementation ultimately delegates to the qcor/xacc infrastructure, and therefore allows one to specify the quantum backend to target (IBM, Rigetti, simulators, etc), and input information for those specific backends (actual backend name, shots, simulation input, etc.). We package all of this type of input into a __quantum__rt_initialize(int, char**) function. The suggestion here is to indicate this in the specification, and ultimately let it be something that is optional, i.e. rt implementations can leverage it or not.

Considerations

This actually may be part of some larger specification update that details target QPU information provided at runtime. We may actually be able to package this as some sort of configuration file that is provided at some specification-noted location on the local host. If that is the case, then one may not need defined init/finalize type function calls, but can provide all input information as part of the configure file.

Affidavit (please fill out)

Please add ticks by placing a cross in the box:

Please tick all that apply: