In short: If I have access to a real quantum computer, is there a possibility to control it using Q#?
Before you downvote this into nirvana because "there's no quantum computer available yet": I'm a physicist and our group is able to do real gates on real world qubits. I also have some background in programming (mostly C++).
So for the sake of this question, let's pretend someone has access to a real world device which is able to perform certain quantum operations on a number of qubits. Obviously the number of qubits might be limited and so might be the possible operations. Let's also say someone is proficient enough with Q# and if necessary C#. Is it possible to "redirect" the computation from the built in simulator to some real world device? Or would one have to basically rewrite the whole Q# library? Is there some way to define my own QuantumSimulator
and how would I start doing that?
Q-tips can push wax further into the ear canal, which can cause impaction, discomfort, or a rupture in the ear drum. If the wax gets pushed too far into the ear canal, it could require surgical intervention. If left untreated, long-term complications can even lead to infections or hearing loss. '
Using cotton swabs to clean inside your ears can cause a variety of ear problems, including things like earwax impaction, injury, and infection. If you must clean your ears, first soften the earwax and then irrigate your ear with warm water, allowing it to drain. Never insert an object like a cotton swab into your ear.
If you push cotton swabs, pencils, your finger or other objects into your ear canal to try to remove wax, the force can push the wax further into the ear and compress it against the eardrum. Earwax blockage, also called cerumen impaction, is a common cause of temporary hearing loss.
The Vagus nerve—a branchlike structure that runs from your brain to your butt—can be stimulated via the ear, Dr. Pross says. This may play a small role in that pleasurable sensation you feel from the Q-tip, he says.
According to Microsoft QDK, the approach Microsoft has taken is based on a coprocessor scheme. So we can safely assume that it is very similar to how a GPU or a FPGA works:
The Q# standard library consists of two essential parts: The prelude (machine-specific operations and functions) and The canon (device-independent logic and wrappers).
So your runtime will need implement the types and functions of the Prelude.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With