ArrayFire Quantum Simulator

Edwin Solis ArrayFire, Quantum Computing Leave a Comment

ArrayFire is pleased to announce the release of the first version of the open-source quantum simulator programming library, the ArrayFire Quantum Simulator, AQS for short. 

AQS is a C++14 library that provides the functionality to create, manipulate, visualize, and simulate quantum circuits with quick and accurate results. The library is built upon ArrayFire to provide hardware-neutral, fast CPU and GPU computations with a familiar interface.

Features

Its feature set includes:

  • Fast Statevector calculations of 1000+ gates up to 30 qubits
  • Implementing essential gates (Pauli, Superposition, Rotation, Multiple Control gates, etc.)
  • Support for extending and creating gates
  • Implementation of standard algorithms (QFT, Grover, VQE)
  • Granular control over calculation stages
  • Custom text displayer of created circuits and circuit schematics
  • Integration with ArrayFire, meaning GPU-accelerated calculations with vendor-agnostic programming

Benchmarks

The following benchmarks measure the average runtimes for 100 tests for common quantum algorithms:

Tests \ LibraryAfQuantumSimQiskitQuantum++
QFT (10 qubits)(6.05 ± 0.78) ms(10.68 ± 4.59) ms(12.78 ± 2.1) ms
Grover (10 qubits)(192 ± 15) ms(26.40 ± 0.04) ms(1431 ± 56) ms
Shor (12 qubits)(106.0 ± 3.7) ms(1776 ± 1132) ms(2149 ± 1184) ms

(Tested using Intel i9-9980HK, AMD Radeon Pro 5500M, 16GB, MacOS Monterrey 12.5)

Purpose

The purpose of this library is to provide a simple workflow for simulating quantum circuits in almost any hardware. We provide an expressive and expandable API without sacrificing performance on commodity hardware.

This library targets the needs of students and researchers alike. Students can learn and understand quantum computing and visualize their creations on their local systems. They don’t need to allocate time to cloud providers or quantum computers to experiment and learn about quantum computing. Researchers can use AQS to develop new quantum algorithms in search of quantum advantages in new areas.

Example

A simple yet powerful concept in Quantum Computing is entanglement. An example of how to show entanglement in a Quantum Computer is combining a Hadamard gate and a Controlled Not gate.

Simulating and displaying entanglement with AQS is as easy as writing five lines of code:

// Create a 2-qubit Quantum Circuit
aqs::QCircuit qc{ 2 };

// Add gates to the circuit
qc << aqs::H{0} << aqs::CX{ 0 , 1 };

// Create a 2-qubit Simulator with qubits initialized to the |0> state
aqs::QSimulator qs{ 2 , aqs::QState::zero() };

// Simulate the circuit with the simulator
qs.simulate(qc);

// Profile the simulation for 100 simulations
aqs::print_profile(qs.profile_measure_all(100));

A possible output for this simulation would be:

|00>: 48.00% (48)
|01>:   0.00% (0)
|10>:   0.00% (0)
|11>: 52.00% (52)

AQS can also visualize the circuit from the gates added. To do this, you may add the following:

aqs::print_circuit_text_image(qc, qs);

to get an output like this:

     ┌───┐           
|0⟩──┤ H ├──────█────
     └───┘      │    
              ┌─┴─┐  
|0⟩───────────┤ X ├──
              └───┘  

This is a simple example of leveraging library features to simulate and visualize quantum circuits. For more examples, you can check out the GitHub page containing information about all the features in the library. It includes the following:

  • Hello World with AQS
  • Classical logic gates
  • Superposition states
  • Entanglement of qubit
  • Quantum Fourier Transform (QFT)
  • QFT Addition of two numbers
  • Phase estimation algorithm
  • Grover search algorithm
  • Quantum counting
  • Shor algorithm
  • Variational Quantum Regression
  • Variational Quantum Eigensolver
  • Quantum Teleportation Protocol
  • Drawing circuits

Future

We expect to continue maintaining this library in the future and receive feedback from the community for features they are looking forward to.

In the current stage, we plan to improve performance further by adding optimizations to gate additions and adding noise simulation features further down the line.

Look at the GitHub page: github.com/arrayfire/afQuantumSim where you can find more information on its features, usage, examples, and documentation to start coding!

Leave a Reply

Your email address will not be published.