I poked around in the object browser a little.
The C# stubs that you use to call Q# operations
look like this:
using (var sim = new QuantumSimulator())
{
var res = MyOperation.Run(sim, arg1, arg2).Result;
}
It appears that runtime environment was being passed as an argument to the operation. So I looked at the QuantumSimulator
class and then its parent SimulatorBase
which had this helpful comment and definition.
//
// Summary:
// A Base class for Simulators. It provides the infrastructure that makes it easy
// for a Simulator to become an OperationFactory (so the execution of an Operation
// can be tied to this simulator) and to manage the allocation of Qubits (via the
// QubitManager).
public abstract class SimulatorBase : AbstractFactory<AbstractOperation>, IOperationFactory
I'm interpreting this to mean anything that implements AbstractFactory<AbstractOperation>
could be passed as an argument to an operation - thus tying the language structure to the specific run environment. While implementing a real quantum computer, it might be possible to use QuantumSimulator
as an example - it looks like it mostly just implements concrete versions of primitive operations from the Microsoft.Quantum.Primitive
namespace. (All the primitive operations appear to be abstract classes).
I think you'll probably have to concretely implement each of the primitives to appropriately control the qubits on your machine, but then you might be able to use the Q# language almost out of the box.
This is pretty speculative on my part, but it might be a good place to start.
EDIT:
The four namespaces in the Prelude that will need to be modified are
Microsoft.Quantum.Extensions.Bitwise
Microsoft.Quantum.Extensions.Convert
Microsoft.Quantum.Extensions.Math
Microsoft.Quantum.Extensions.RangeFunctions
Microsoft.Quantum.Primitive
XY
which requires at least operationz()
. I am aware that the language is so new, that probably the question will not get an answer yet.... – Towards