Is it possible to use Q# to control my own quantum computer? [closed]
Asked Answered
T

4

13

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?

Towards answered 13/12, 2017 at 20:41 Comment(3)
Dive into the source of Q# :} The "real world computer" will still need to provide lower-level interface (as any hardware does) and it is this interface (and how such is exposed) that may need to be considered before being able to answer such questions at all..Barnsley
I will definitely do that, but sadly i won't be able to find the time until next year. So i thought maybe someone already knows something like "oh yeah, you need to implement interface XY which requires at least operation z(). I am aware that the language is so new, that probably the question will not get an answer yet....Towards
They certainly make it sound like it’s designed to run on real hardware. Even if it’s not possible now I bet they’ll define an interface like that later.Chuckwalla
D
4

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

Downward answered 14/12, 2017 at 4:13 Comment(0)
M
4

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 main program runs on main processor under well-familiar .NET framework;
  • the coprocessor-specific subroutines are translated to the architecture-specific instructions just the same way as it is done for GPU, wrapped into arbitrary functions, and then uploaded to the physical device;
  • and then called like they were normal functions.

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.

Moss answered 15/12, 2017 at 2:9 Comment(0)
S
0

In simple terms, yes. Microsoft has made Q# for the exact purpose that when people have access to real life Qubits and Quantum computers they can simply start using Q# as they already have the experience coding with it in the virtual environments. As to how you can do this, I have no idea, I suggest the best thing to do is to email Microsoft themselves they'll be pretty happy to help you out.

Staggard answered 8/1, 2018 at 5:5 Comment(0)
A
0

According to Microsoft: "The callable itself is then run on a target machine. Such target machines can be actual quantum hardware or the multiple simulators available as part of the QDK." Although that quantum hardware would have to have a set of intrinsic functions and operations that are needed to write with Q#.

Allonge answered 2/6, 2021 at 16:24 Comment(1)
@Towards I am curious, were you guys able to do this?Allonge

© 2022 - 2024 — McMap. All rights reserved.