MULT90063 Introduction to Quantum Computing
Lecture 15 – IBM and Optimisations
14.1 QUI compared to IBM 14.2 QASM and QISKit 14.3 Optimizing circuits
Lecture 16 – IBM Quantum Experience
Copyright By PowCoder代写 加微信 powcoder
Introduction to IBM Quantum Experience: Guest Lecture
Using the IBM system
MULT90063 Introduction to Quantum Computing
IBM and Optimisation
Lecture 15
MULT90063 Introduction to Quantum Computing
The IBM Quantum Computing System
Sign up using your university email before Friday!
MULT90063 Introduction to Quantum Computing
IBM’s Circuit Composer
Access through the left sidebar
MULT90063 Introduction to Quantum Computing
Creating a Bell State Circuit
Drag and drop gates onto your circuit:
MULT90063 Introduction to Quantum Computing
U1 is a rotation around Z by angle lambda, which is equivalent to a rotation around the z-axis by an angle lambda
U1=1 0 0 expi
Most easily understood as:
In the QUI, to emultate these z-rotations, use a global phase of lambda/2. No global phase for the y-rotation.
MULT90063 Introduction to Quantum Computing
The U2 operation is given by
11 exp(i ) U2 = p2 exp(i ) exp(i + i )
Which can be represented as:
In the QUI, to emultate these z-rotations, use a global phase of theta/2. No global phase for the y-rotation.
MULT90063 Introduction to Quantum Computing
The matrix of a U3 rotation is:
1 cos ✓/2 exp(i ) sin(✓/2) U3 = p2 exp(i ) sin(✓/2) exp(i + i ) cos(✓/2)
As a circuit:
MULT90063 Introduction to Quantum Computing
Euler Angle Decomposition
Any rotation can be represented as a rotation around orthogonal axes:
IBM Quantum Experience
MULT90063 Introduction to Quantum Computing
Converting to and from Euler angles
General form of arbitrary rotation about an unit axis n=(nx, ny, nz):
Rn (↵) = cos ↵2 I i sin ↵2 nˆ · = cos↵2 inz sin↵2
sin↵2( inx +ny) Euler angle rotations (with global phase = 0):
U3 = e i( + )/2 cos(✓/2) ei( + )/2 sin(✓/2)
Write out the matrix (with determinant 1) and equate elements.
sin↵2( inx ny) cos↵2 +inz sin↵2
ei( )/2 sin(✓/2) ei( + )/2 cos(✓/2)
MULT90063 Introduction to Quantum Computing
Equating angles
cos↵ =cos + cos✓ 222
sin⇣↵⌘nx =sin sin✓ 222
sin⇣↵⌘ny =cos sin✓ 222
sin ⇣ ↵ ⌘ = sin + cos ✓ 222
MULT90063 Introduction to Quantum Computing
QASM – Quantum Assembly language
MULT90063 Introduction to Quantum Computing
QASM Syntax
Semi-Colons
MULT90063 Introduction to Quantum Computing
Hidden first line: OPENQASM 2.0;
Include standard definitions Declare quantum register Declare classical register
Single qubit gates
(control first parameter, target second)
Dagger indicated by “dg”
Barrier (don’t optimize across it) Measure qubits to classical register
MULT90063 Introduction to Quantum Computing
There is also a Python interface to IBM Quantum Experience.
It is required to make use of the larger machines.
• Authenticate with the system
• Construct circuits (ie. python which translates to QASM)
• Submit jobs, and check for results
• Receive the results of jobs
Python works well with Jupyter interface.
We will use this later when we use the 16 qubit quantum computer.
MULT90063 Introduction to Quantum Computing
Qiskit for the Bell State Circuit
MULT90063 Introduction to Quantum Computing
Lots of examples in the github repository.
MULT90063 Introduction to Quantum Computing
IBM’s Qiskit
MULT90063 Introduction to Quantum Computing
Terra, Aer, Ignis, Aqua
Tera (Earth): Access to IBM Q Devices through python interface Aer (Air): Classical simulation of quantum algorithms/circuits Ignis (Fire): Characterisation of errors, tomography
Aqua (Water): Large selection of quantum algorithms
MULT90063 Introduction to Quantum Computing
Starting a new Workbook
Select Quantum Lab in menu
MULT90063 Introduction to Quantum Computing
We will loosely follow the “Getting Started with Qiskit” tutorial from IBM,
MULT90063 Introduction to Quantum Computing
Python Primer (if required)
MULT90063 Introduction to Quantum Computing
Some Python Basics
Similar to many other imperative languages you may know for numerical work: (C/C++, MATLAB, R, FORTRAN, Julia) and often used for data processing.
MULT90063 Introduction to Quantum Computing
Defining and calling Functions
def keyword indicates a new function
Whitespace is significant in python. Indentation indicates a new block.
Calling a function:
No types on parameters Colon
No semicolons.
Newline is the end of a statement
Named parameters
MULT90063 Introduction to Quantum Computing
Lists and for loops
Lists store a sequence of values. Square brackets indicate a list:
Eg. For loops often use lists:
Accessing an individual element. 0-based!
MULT90063 Introduction to Quantum Computing
Dictionaries
Dictionaries store key-value pairs.
Curly braces indicate a dictionary key value
MULT90063 Introduction to Quantum Computing
Importing other libraries
Importing a module (“as np” is optional). numpy gives similar functionality to MATLAB
Calling functions from that module.
Here creating an X matrix.
Or import individual functions and classes:
qiskit is an Python library/API for interacting with IBM’s quantum computers remotely.
MULT90063 Introduction to Quantum Computing
Qiskit Demonstration
(in browser)
MULT90063 Introduction to Quantum Computing
Circuit Optimisation
MULT90063 Introduction to Quantum Computing
Many gates square to identity
Pro Tip: Most physicists looking at quantum circuit diagrams aren’t multiplying matrices in their head. They’re identifying common patterns.
All of these combinations square to the identity (do nothing)
MULT90063 Introduction to Quantum Computing
Circuit identity: Inverted CNOT
Exercise: You can verify this by writing out the matrices and multiplying!
MULT90063 Introduction to Quantum Computing
Conjugating with Hadamard
MULT90063 Introduction to Quantum Computing
Commuting through Hadamard
MULT90063 Introduction to Quantum Computing
Control-Z from CNOT
MULT90063 Introduction to Quantum Computing
Conjugation with
XRy(✓)X = X ✓cos 2✓I isin 2✓Y ◆X = cos 2✓ X X i sin 2✓ X Y X
= cos 2✓ I + i sin 2✓ Y
= Ry( ✓) Paulis anticommute
Works with any two orthogonal axes.
MULT90063 Introduction to Quantum Computing
Controlled Angle Rotation
If the control is a zero, the rotations cancel. If the control is one, the rotations add.
MULT90063 Introduction to Quantum Computing
Any Controlled U
For U3 Euler angle rotation (on IBM’s system):
Controlled version of a U3 gate:
Rz ✓ + 2
R ( ) R ( )
MULT90063 Introduction to Quantum Computing
Conjugation with Rotation
Conjugation with a rotation:
Changes the axis of rotation, but not the rotation angle. This rotates the axis itself
SRx(✓)S† =cos✓2✓◆I isin✓2✓◆SXS† = cos ✓ 2✓ ◆ I i sin ✓ 2✓ ◆ Y
= Ry(✓) Conjugation with Hadamard is a special case of this.
MULT90063 Introduction to Quantum Computing
Control from “0” state
Open circle = Only apply when the control is “0”
We’ve seen this trick in labs: for example in the oracle for Grover’s algorithm.
MULT90063 Introduction to Quantum Computing
Swap gate from three CNOTs
Let’s check:
00 -> 00 01 -> 10 10 -> 01 11 -> 11
MULT90063 Introduction to Quantum Computing
Square root of SWAP
Square root of swap
26 1 0 0 0 37 26 1 0 0 0 37 0 0 1 0 0 1+i 1 i 0
U=64 75U=642275 Swap 0 1 0 0 SS 0 1 i 1+i 0
MULT90063 Introduction to Quantum Computing
Square Root Swap Construction
R x ⇣ ⇡2 ⌘
Similar to swap Global phase of pi/4
MULT90063 Introduction to Quantum Computing
Toffoli from CNOTS
MULT90063 Introduction to Quantum Computing
Toffoli with Incorrect Phase
If neither control is 1, then no net rotation.
If only first control is a 1, then becomes Z rotation (Ry by pi).
If only second control qubit is a 1, then both halves cancel.
If both controls are 1, then bottom qubit flips because of middle CNOT.
R y ⇣ ⇡4 ⌘
R y ⇣ ⇡4 ⌘
R y ⇣ ⇡4 ⌘
MULT90063 Introduction to Quantum Computing
Multiply Controlled Gates
We can use Toffoli and an ancilla qubit to define multiply controlled gates.
MULT90063 Introduction to Quantum Computing
Mocking up gates
If you use controlled operations on all qubits except the target, then you isolate a single 2×2 subspace, with the rest of the matrix untouched.
26 1 0 0 0 37 C U = 64 0 1 0 0 75
Or controlled off the zero state:
26 a b 0 0 37 C 0 U = 64 c d 0 0 75
MULT90063 Introduction to Quantum Computing
Using Gray codes
Imagine we wanted a 2×2 matrix between the 000 and 111 states:
000 001 011 111
Corresponding sequence:
In this way, complicated multi-qubit gates can be built, piece by piece.
MULT90063 Introduction to Quantum Computing
Square Root Swap Construction
R x ⇣ ⇡2 ⌘
Similar to swap Global phase of pi/4
MULT90063 Introduction to Quantum Computing
Lecture 15 – IBM and Optimisations
14.1 QUI compared to IBM 14.2 QASM and QISKit 14.3 Optimizing circuits
Lecture 16 – IBM Quantum Experience
Introduction to IBM Quantum Experience: Guest Lecture
Using the IBM system
MULT90063 Introduction to Quantum Computing
MULT90063 Introduction to Quantum Computing
Defining a new Function/Gate
Keyword: gate
“cz” is name of gate
a and b are parameters
This gate can then be used like a native gate:
MULT90063 Introduction to Quantum Computing
QASM Header File
Also defines:
rx, ry, rz
Controlled rotations
cu1, cu2, cu3, crz, ch
MULT90063 Introduction to Quantum Computing
Product of single qubit unitaries
Euler angle rotations (with global phase = 0):
U3 = e i( + )/2 cos(✓/2) ei( )/2 sin(✓/2) ei( + )/2 sin(✓/2) ei( + )/2 cos(✓/2)
Write out the matrix and equate elements.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com