62
$\begingroup$

Is there any way to emulate a quantum computer in my normal computer, so that I will be able to test and try quantum programming languages (such as Q#)? I mean something that I can really test my hypothesis and gets the most accurate results.

Update: I'm not really looking for simulating a quantum computer, but I'm not sure if its possible to efficiently emulate one on a normal non-quantum based PC.

$\endgroup$
38
$\begingroup$

Yes, it's possible (but slow). There are a couple of existing (this is only a partial list) emulators:

  • QDD: A Quantum Computer Emulation Library

    QDD is a C++ library which provides a relatively intuitive set of quantum computing constructs within the context of the C++ programming environment. QDD is unique in that the its emulation of quantum computing is based upon a Binary Decision Diagram (BDD) representation of the quantum state.

  • jQuantum

    jQuantum is a program which simulates a quantum computer. You can design quantum circuits with it and let them run. The current state of the quantum register is illustrated.

  • QCE

    QCE is a software tool that emulates various hardware designs of Quantum Computers. QCE simulates the physical processes that govern the operation of a hardware quantum processor, strictly according to the laws of quantum mechanics. QCE also provides an environment to debug and execute quantum algorithms under realistic experimental conditions.

(In addition, Q# only works with MS's QDK, thanks @Pavel)

The downside to all of these is simple: they still run on binary (non-quantum) circuits. To the best of my knowledge, there's no easily accessible quantum computer to use for running these things. And since it takes multiple binary bits to express a single qubit, the amount of computational power needed to simulate a quantum program gets large very quickly.

I'll quote a paper on the subject (J. Allcock, 2010):

Our evaluation shows that our implementations are very accurate, but at the same time we use a significant amount of additional memory in order to achieve this. Reducing our aims for accuracy would allow us to decrease representation size, and therefore emulate more qubits with the same amount of memory.

p 89, section 5.1

As our implementations get more accurate, they also get slower.

TL;DR: it's possible, and some emulators exist, but none are very efficient for large amounts of qubits.

$\endgroup$
  • $\begingroup$ Note that none of these emulators can (currently) be used by Q#, which only works with Microsoft's QDK. $\endgroup$ – Pavel Mar 12 '18 at 18:26
  • 3
    $\begingroup$ In addition to what you said: There are programatic ways to run code on the IBM Quantum Experience which provides real quantum computers - not Q# code, but QASM instead. QISKit is the way to go here. github.com/QISKit $\endgroup$ – blalasaadri Mar 13 '18 at 6:50
25
$\begingroup$

Yes, it is possible to simulate a quantum computer on a normal one – But you most likely have to sacrifice efficiency.

The dimension of the state space rises exponentially with the number of qubits ($2^n$, where $n$ is the number of qubits), so the linear algebra you will be dealing with won't be too light – You'll encounter very large matrices and the algorithm you use (regardless of how efficient it is) will likely become exponentially-scaling pretty fast. However, emulating a QC on a normal machine is definitely possible.


Resources

You may be interested in Q# as other answers noted. Some more emulators:

  • Quantum Computing Playground

    Quantum Computing Playground is a browser-based WebGL Chrome Experiment. It features a GPU-accelerated quantum computer with a simple IDE interface, and its own scripting language with debugging and 3D quantum state visualization features. Quantum Computing Playground can efficiently simulate quantum registers up to 22 qubits, run Grover's and Shor's algorithms, and has a variety of quantum gates built into the scripting language itself.

  • QX Simulator

    The QX Simulator is a universal quantum computer simulator developped at QuTech by Nader Khammassi. The QX allows quantum algorithm designers to simulate the execution of their quantum circuits on a quantum computer. The simulator defines a low-level quantum assembly language namely Quantum Code which allows the users to describe their circuits in a simple textual source code file. The source code file is then used as the input of the simulator which executes its content.

  • Quantum++

    Quantum++ is a modern C++11 general purpose quantum computing library, composed solely of template header files. Quantum++ is written in standard C++11 and has very low external dependencies, using only the Eigen 3 linear algebra header-only template library and, if available, the OpenMP multi-processing library.

  • Quantum Computer Language

    Despite many common concepts with classical computer science, quantum computing is still widely considered as a special discipline within the broad field of theoretical physics. [...] QCL (Quantum Computation Language) tries to fill this gap: QCL is a high level, architecture independent programming language for quantum computers, with a syntax derived from classical procedural languages like C or Pascal. This allows for the complete implementation and simulation of quantum algorithms (including classical components) in one consistent formalism.

  • More relevant emulators can be found on Quantiki

$\endgroup$
21
$\begingroup$

Yes, it is possible to simulate quantum computations on a classical computer. But the cost of simulations grows exponentially with qubit count and/or circuit depth and/or particular operation counts.

For trying ideas quickly, my simulator Quirk is great. It's an open-source drag-and-drop quantum circuit simulator that runs in your web browser. You can access a live version at algassert.com/quirk.

Here is a screenshot of Quirk's example Grover circuit, which is instrumented with intermediate state displays to track the "hidden" state becoming more likely:

Screenshot of Quirk

$\endgroup$
16
$\begingroup$

If you're specifically looking at Q#, then it's super easy to use with an emulator -- in fact, it's not possible to have Q# but not have the emulator, they're bundled together.

To get started, first you need to download .NET Core from Microsoft's website.

When you download Microsoft's Quantum Development Kit through dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.2-*" or Microsoft's website, it downloads both the language and Microsoft's own emulator together.

Creating a new Q# project (dotnet new console -lang Q#) will automatically configure it to use the emulator, so when you type in some Q# and run the project it "just works".

$\endgroup$
3
$\begingroup$

I think a nice "overview" about the subject can be found at: Quantiki

They have a list of quantum computer simulators in several languages, some of the simulators have been cited here before. However, they keep a list that they update to inform (or try to inform) of the project's status. There are some "libraries" such as:

Haskell

qchas (qchas: A library for implementing Quantum Algorithms) - A library useful for implementing Quantum Algorithms. It contains definitions of Quantum Gates, Qubits.

Python

qubiter : The Qubiter project aims to provide eventually a full suite of tools, written mostly in Python, for designing and simulating quantum circuits on classical computers.

Javascript

jsqis : jsqis, at its core, is a quantum computer simulator written in Javascript. It allows initialization of quantum registers and their manipulation by means of quantum gates.

$\endgroup$
2
$\begingroup$

Yes. If you build it yourself, find a 3rd party computer with the same specs as the BullSequana M9600 series, or come up with €100K+ and buy a system from Atos.

Notice the similarity between the BullSequana M9600 series and the Atos QLM. Atis QLM vs. M9600

Same box (and probably internal components) with different software (but you wanted to use your own, Q#). Atos claims: "The highest-performing quantum simulator in the world". I'm not sure about that but the specs for the 30 qubit version are reachable, just two Intel CPUs and 1TB of memory.

Atos QLM .PDF Brochure.

Is there any way to emulate a quantum computer in my normal computer, so that I will be able to test and try quantum programming languages (such as Q#)?

If you use only 256GB of memory and 1-24TB of Swap Drive it will be slow but it will work.

I mean something that I can really test my hypothesis on and get the most accurate results.

Quote from the Brochure:

"The Atos Quantum Learning Machine computes the exact execution of a quantum program, with double digit precision. It simulates the laws of physics, which are at the very heart of quantum computing. This is very different to existing quantum processors, which suffer from quantum noise, quantum decoherence, and manufacturing biases, as well as performance bottlenecks. Simulation on the Atos Quantum Learning Machine enables developers to focus on their applications and algorithms, without having to wait for quantum machines to be available".

They claim high accuracy, since it's a simulator it's not subject to noise - nor will it be as fast, or as expensive. In theory you could add some memory, drives, and software to your computer ...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.