Author Topic: Back to the Future - Open Quantum Assembly Language  (Read 555 times)

LiaoMi

  • Member
  • **
  • Posts: 227
Back to the Future - Open Quantum Assembly Language
« on: February 07, 2018, 11:34:50 PM »


https://arxiv.org/pdf/1707.03429
This document describes a quantum assembly language (QASM) called OpenQASM that is used to implement experiments with low depth quantum circuits. OpenQASM represents universal physical circuits over the CNOT plus SU(2) basis with straight-line code that includes measurement, reset, fast feedback, and gate subroutines. The simple text language can be written by hand or by higher level tools and may be executed on the IBM Q Experience.

Gate and operation specification for quantum circuits - https://github.com/QISKit/openqasm

qft.qasm: Quantum Fourier transform on 4 qubits.

Code: [Select]
// quantum Fourier transform
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
creg c[4];
x q[0];
x q[2];
barrier q;
h q[0];
cu1(pi/2) q[1],q[0];
h q[1];
cu1(pi/4) q[2],q[0];
cu1(pi/2) q[2],q[1];
h q[2];
cu1(pi/8) q[3],q[0];
cu1(pi/4) q[3],q[1];
cu1(pi/2) q[3],q[2];
h q[3];
measure q -> c;

https://en.wikipedia.org/wiki/OpenQASM

Quote
Open Quantum Assembly Language (OpenQASM; pronounced "open kazm") is an intermediate representation for quantum instructions. The language was first described in a paper published in July 2017, and source code was released as part of IBM's Quantum Information Software Kit (QISKit) for use with their Quantum Experience cloud quantum computing platform. The language has similar qualities to traditional hardware description languages such as Verilog.

libquantum is a C library for the simulation of quantum mechanics, with a special focus laid to quantum computing. It started as a pure quantum computer simulator, but support for general quantum simulation has been recently added.

Quantum computing - Quantum virtual machine (libquantum) http://www.libquantum.de/
Based on the principles of quantum mechanics, libquantum provides an implementation of a quantum register. Basic operations for register manipulation such as the Hadamard gate or the Controlled-NOT gate are available through an easy-to-use interface. Measurements can be performed on either single qubits or the whole quantum register.

Features

Simulation of arbitrary quantum algorithms is possible
High performance and low memory consumption
Optional time-evolution using fourth-order Runge-Kutta or exact diagonalization, including optimizations for sparse Hamiltonians
Decoherence support for realistic quantum computation
Interface for quantum error correction (QEC)
Supports the density operator formalism
Implementations of Shor's factoring algorithm and Grover's search algorithm are included
libquantum is available as Free Software under the terms of the GNU General Public License (GPL), version 3. See the file COPYING for further details.


Be ready for the future  :biggrin:

daydreamer

  • Member
  • ***
  • Posts: 354
Re: Back to the Future - Open Quantum Assembly Language
« Reply #1 on: February 08, 2018, 01:52:27 AM »
I have some trouble with my flux.asm code, a serious bug appeared when I ran it,my clock shows me I am back in the good old 1955...  :badgrin:
Quote from Flashdance
Nick  :  When you give up your dream, you die.

daydreamer

  • Member
  • ***
  • Posts: 354
Re: Back to the Future - Open Quantum Assembly Language
« Reply #2 on: February 09, 2018, 01:57:30 AM »
and now the matrix battery is coming:
https://www3.nhk.or.jp/nhkworld/en/vod/scienceview/2015184/

you find Qasm is to advanced, start with the basics, like in QBASIC  :P :badgrin:
« Last Edit: February 10, 2018, 06:55:14 AM by daydreamer »
Quote from Flashdance
Nick  :  When you give up your dream, you die.

aw27

  • Member
  • *****
  • Posts: 1202
  • Let's Make ASM Great Again!
Re: Back to the Future - Open Quantum Assembly Language
« Reply #3 on: February 09, 2018, 04:58:35 AM »
@LiaoMi
The IBM Quantum Computer does not understand the cul instructions.  :(



PS: On a second attempt I could make it run after dropping some gate U1. But I don't understand how it works, I guess I need to spend time reading the instructions.

LiaoMi

  • Member
  • **
  • Posts: 227
Re: Back to the Future - Open Quantum Assembly Language
« Reply #4 on: February 09, 2018, 10:01:54 PM »
@LiaoMi
The IBM Quantum Computer does not understand the cul instructions.  :(



PS: On a second attempt I could make it run after dropping some gate U1. But I don't understand how it works, I guess I need to spend time reading the instructions.

Hi,

Controlled (cX cY cZ) gates
The matrix representing the controlled U is

When U is one of the Pauli matrices, σx, σy, or σz, the respective terms "controlled-X", "controlled-Y", or "controlled-Z" are sometimes used.

The same thing for me  :biggrin: maybe execution depends on the version of the backend, with logic "Controlled NOT gate" is not so difficult, but visualization of the simulation, it reminds me of matrix calculations or simulations of simd instructions.
Backend: ibmqx2 (5 Qubits) - active for me and

Code: [Select]
// Implementation of Deutsch algorithm with two qubits for f(x)=x
OPENQASM 2.0;
include "qelib1.inc";

qreg q[5];
creg c[5];

x q[4];
h q[3];
h q[4];
cx q[3],q[4];
h q[3];
measure q[3] -> c[3];
 

https://github.com/QISKit/openqasm/blob/master/examples/ibmqx2/Deutsch_Algorithm.qasm works for me  :P Who wants to try, the simulator can be found here - https://quantumexperience.ng.bluemix.net/qx/qasm

Information about gates https://en.wikipedia.org/wiki/Quantum_gate
https://en.wikipedia.org/wiki/Qubit

Some gates are not supported in this topology or not defined, probably there is a dependency on the topology set.

Open Quantum Assembly Language - https://github.com/QISKit/openqasm/blob/master/spec/qasm2.rst
Information about the different backends on the IBM Q experience -  https://github.com/QISKit/ibmqx-backend-information

aw27

  • Member
  • *****
  • Posts: 1202
  • Let's Make ASM Great Again!
Re: Back to the Future - Open Quantum Assembly Language
« Reply #5 on: February 10, 2018, 02:24:36 AM »

When we select to run on the real computer, not the simulator, the job enters in a queue and take ages for the results to be delivered, although the message says  will be the next one to run.
Only today I received the result from my yesterday's run.

I will try again when there are more qubits, 5 is too short for anything interesting.  :biggrin: