2017 07 04_cmmse_quantum_programming_v1

Post on 22-Jan-2018

183 views 0 download

transcript

Quantum ProgrammingA New Approach to Solve Complex Problems

Francisco Gálvez RamirezIBM Staff

fjgramirez@es.ibm.com

Introducing myself

Francisco Gálvez

BS in Experimental Physics (UV)Master in Advanced Physics (UV)

Cloud and Integrated Systems Expert

fjgramirez@es.ibm.com

@fjgramirez

Francisco J. Galvez Ramirez

Agenda

Why Quantum Computation

The IBM Quantum Computer

Quantum Algorithms

How to Program a Quantum Computer

Tools for Quantum Computing

Why Quantum Computation ?

Why Quantum Computation ?

“...nature isn't classical, dammit, and if you want to make a simulation of nature, you'd better make it quantum mechanical...” –

Richard Feynman, Simulating Physics with Computers

Why Quantum Computation ?

A qubit is the quantum concept of a bit.

0 1 It’s not any element or device. It’s a logical concept that can be implemented on a wide range of different systems with quantum behaviour

As a bit, a single qubit can represent two states 0 and 1

But additionally a qubit is able to manage all possible combinations amont base states 0 and 1

10 βα +

10 βαψ +=

What is a Qubit?

Why Quantum Computation ?

Spin Qubits – Electron or nuclear spins on a solid Substract.

Superconducting Circuits – currents superposition around a superconductor.

Ion’s Traps– Trap ions in electric fields

Photonic Circuits – The qubits are photons driven in in silicon circuits.

Qubit Implementation

Why Quantum Computation ?

2 BITS

0

1

0 0

0

1

0

1 A 0 0 + B 1 0 + C 0 1 + D 1 1

1 0

0 1

1 1

2 QUBITS

One state made of a combination of every possible state of the

system

Quantum Superposition

Why Quantum Computation ?

Quantum Entanglement

1. Preparing an entangled states.

An entangled stated can be prepared by applying a common operation to the system.

2. Measurement

0

1

The IBM Quantum Computer

March - 2016: Quantum Computing in the Cloud

IBM scientists have built a quantum processor that any user can access through the first quantum computing platform available in the cloud.

IBM Quantum Experience, allows users to execute algorithms and experiments on a real quantum processor

Marzo-2017: IBM announces IBM Q

IBM Q is the new line of Quantum Computers

IBM announces the building of a quantum computer of 50 qubits and that will offer services of quantum computation in the cloud

Mayo-2017: First Commercial Quantum Computer

16 and 17 qubits universal quantum computers

IBM announces a prototype of 17 qubits commercial quantum computing

IBM has discovered how to scale quantum architecture

In three years it is planned to reach 50 qubits

IBM Superconducting Qubits Arquitecture

IBM's new 17-qubit quantum computer.

Coherence Times

• Coherence in IBM today is about 100 microseconds

• There are several initiatives to improve the coherence times:

• Different materials

• Redesign of geometries

• Cavity Quality

• IR Shielding

• Important progress has been made in the last decade

The Quantum Volume

The Dilution Refrigerator

A key piece of the Quantum Computer is the Dilution Refrigerator

Working Temperature 15 mK Dilution Refrigerator 3He + 4He

Some Quantum Algorithms

Quantum Algorithms

• Deusch Algorithm – Determines whether a funcion is balanced or unbalanced

• Shor Algorithm – Large numbers factorization

• Grover Algoritm – Search in unstructured spaces

Deustch Algorithm

f1:

0 0

1 0 f2:

0 1

1 1

Deustch-Josza Algorithm Extends Deustch’s algorithm to n value registers

f3:

0 0

1 1 f4:

0 1

1 0

Shor Algorithm

• Number of steps that a classic computer needs to run in order to find the prime factors of a number N of x digits

It grows exponencially with x

• The Shor algorithm is made up of two parts:

1. One Classical part - Which focuses on finding the period of a function

2. A quantum part based on QFT technics

In 2001, IBM and Stanford University, executed for the first time the Shor algorithm in the first quantum computer of 7 qubits developed in Los Álamos.

https://www-03.ibm.com/press/us/en/pressrelease/965.wss

Grover Algorithm

• How many attempts need a data search in an unordered N-element database to locate a particular element?

An average of N/2 attemps are needed)

http://www.dma.eui.upm.es/MatDis/Seminario4/AlgoritmoGrover.pdf

• A Quantum Computer executing the Grover Algorithm would run attempsN

How To Program A Quantum Computer?

Quantum Circuits

The Circuit Model

Gates execution time ~ 25 ns~25 ns~25 ns ~25 ns ... ... ... ... ...

Coherence time 100 ms

measurement

Quantum Operations

X-Gate

Flips a qubit from a 0 to a 1, or vice versa.

Hadamard Gate

Puts a qubit into a superposition of states.

Flips a second qubit only if the first qubit is 1.

Controlled Not Gate

Entanglement

H gate puts the first qubit in a superposition. CNOT gate both flips and does not flip the second qubit.

Assuming the qubits start as 0, when measured, they will be 11 or 00, but never 10 or 01.

Quantum Operations

It is a basic circuit that acts on one or several qubits It is equivalent to logical gates in digital circuits

Quantum Gates

1. Quantum Gates are Reversible

2. Matematically are represented by unitary matrices.

3. The qubits upon they act keep their quantum nature.

=11

11

2

1

=

0100

1000

0010

0001

=

Hadamard GateC-NOT Gate

=

01

10

X - Gate

Quantum Operations

Quantum Gates Set

Tools For Quantum Programming

Tools for Quantum Programming

IBM Quantum ExperienceVisual interface, Drag and Drop for 5 qubits

QISKit OpenQASMAsembler Language for representing Quantum Circuits

QISKit APIPython API to create and execute Quantum Circuits

IBM Quantum Experience

Graphical Interface used to create programs for the quantum processor It allows to create quantum circuits using a logical gates library and well defined points of

measurement

Programming the Grover Algorithm – (I)

A list of N item and there’s one item with a unique property that we wish to locate

1 2 3 4 ... ... N=2nω

A classical computation needs to check on average of this boxes 2N

On a quantum computer, using the Grover’s algorithm it can be done in aprox. steps N

Programming the Grover Algorithm – (II)

∑−

=

=1

0

1 N

x

xN

s

At the beginning we have a uniform superposition

amplitu

de

N

1

Items1 2 3 ( .... )

Programming the Grover Algorithm – (III)

We need a function such that: for the marked state: 1)( =xf ω

In that way we build the “oracle” matrix: fU

( ) xxU xff

)(1−=

Applying the oracle reflection: If is an unmarked item, the oracle does nothing, otherwise: x

ωω −=fU

amplitu

de

N

1

Items1 2 3 ( .... )

Programming the Grover Algorithm

We now apply an additional reflection about the state .

In the bra-ket notation this reflection is written as:

This transformation maps the state to:

and completes the transformation:

s

12 −= ssU s

'tsU ψ

tfst UU ψψ =+1

amplitude

Items1 2 3 ( .... )

sU

Programming the Grover Algorithm – (IV)

Programming the Grover Algorithm – (V)

Programming the Grover Algorithm – (VI)

Programming the Grover Algorithm – (VII)

Programming the Grover Algorithm – (VIII)

Programming the Grover Algorithm – (IX)

Programming the Grover Algorithm – (X)

Getting the right oracle function :

For element

For element

For element

For element

00

fU

10

11

fU

Programming the Grover Algorithm – Results

asdf

QISKit OpenQASM

What is OpenQASM?

An intermediate representation for Quantun CircuitsHardware AgnosticOPENQASM, or “Quantum Assembly Language,” is a simple text representation that describes generic quantum circuits.OpenQASM submit batch jobs via HTTP API/PYTHON wrapper.

OpenQASM

Language Statements

IBMQASM 2.0; qreg name[size]; creg name[size]; include "filename"; gate name(params) qargs { body } opaque name(params) qargs; U(theta,phi,lambda) qubit|qreg; CX qubit|qreg,qubit|qreg; measure qubit|qreg -> bit|creg; reset qubit|qreg; gatename(params) qargs; if(creg==int) qop; barrier qargs;

QISKit OpenQASM

Predefined Gates

// These are the predefined gatesU(theta,phi,lambda) qubit|qreg;CX qubit|qreg,qubit|qreg;

New Gate Definition

// This is the definitiongate name(params) qargs{ body}// This is an examplegate g a{ U(0,0,0) a;}

gate crz(theta) a,b{ U(0,0,theta/2) a; CX a,b; U(0,0,-theta/2) b; CX a,b; U(0,0,theta/2) b;}crz(pi/2) q[0],q[1];

QISKit OpenQASM

Example: Quantum Fourier Transform// quantum Fourier transformIBMQASM 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;

The quantum Fourier transform demonstrates parameter passing to gate subroutines.

This circuit applies the QFT to the state and measures in the computational basis.

=3210 qqqq 0101

QISKit API

What is QISKit API?

Access to IBM’s Quantum Experience using a Python interface. This interface allows working with quantum circuits and executing multiple

circuits in an efficient batch of experiments.

QISKit API

Basic program elements:

The Quantum ProgramQuantumProgram()

The Circuit.create_circuit()

The Quantum Register.create_quantum_registers()

The Classical Register.create_classical_registers()

QISKit API

The CircuitFirst, create the circuit

circuit = Q_program.get_circuit(“Circuit")

The Registers Quantum Registers

q2 = Q_program.create_quantum_registers("q2", 2)

Classical Registersc2 = Q_program.create_classical_registers("c2", 2)

QISKit API

The GatesAdding Gates to the circuit

QISKit APIExtracting QASM code

QISKit API

Creating an entangled Bell state

1.Create Quantum Registersq2 = Q_program.create_quantum_registers("q2", 2)

1.Create Classical Registersc2 = Q_program.create_classical_registers("c2", 2)

Thanks