7NY.US
Programming Quantum Algorithms on a Quantum Computer
Page #3     2016-05-10 00:44:52

 ► 

Programming Quantum Algorithms on a Quantum Computer

IBM accepted my request to use their quantum computer to develop my own experiments, and even run them in, on the world's first fully-controllable quantum processor through the IBM Cloud located in Yorktown Heights, New York, I'm going to write about my experience and share documentation.

I love quantum mechanics since I was a kid, I read all the books aviable in the little library near my home, and magazines too, I can't forget this image:

In November 11, 1989, Don Eigler and colleagues drew the IBM logo in atoms. He and his team were able to literally move 35 xenon atoms on a background of copper atoms to spell out IBM, when I see this image, I thought: "Some day, I'm going to have a Company, and I'm going to manipulate atoms to draw my logo", when I was 15, a cranioencephalic trauma changed my life, I forget a lot of information, and I never studied physics, anyway, I did something better than draw my logo in atoms, this is a dream come true, I manipulated quantum states to obtain this:

Execution results

7NY.US experiment. Quantum algorithm by Miguel Angel Vargas Cruz
Executed on: May 5, 2016 1:49:49 AM
Results date: May 5, 2016 1:50:10 AM
Number of shots: 1

Q0 |0⟩
M
Q1 |0⟩
M
Q2 |0⟩
X
M
Q3 |0⟩
X
M
Q4 |0⟩
X
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
00111

Device Calibration: 2016-05-04 15:52

Q0
T1: 54.8μs
T2: 60.9μs
εg: 3.2×10-3
εr: 4.1×10-2
ε02g: 6.43×10-2
Q1
T1: 78.5μs
T2: 109.2μs
εg: 1.8×10-3
εr: 1.8×10-2
ε12g: 3.97×10-2
Q2
T1: 66.7μs
T2: 61.9μs
εg: 2.6×10-3
εr: 2.1×10-2

Q3
T1: 59.7μs
T2: 51.6μs
εg: 4.8×10-3
εr: 4.1×10-2
ε32g: 6.07×10-2
Q4
T1: 79.4μs
T2: 80.2μs
εg: 1.8×10-3
εr: 3.7×10-2
ε42g: 3.48×10-2

Bloch measurement

Q0 |0⟩
BM
Q1 |0⟩
BM
Q2 |0⟩
X
BM
Q3 |0⟩
X
BM
Q4 |0⟩
X
BM
qubit 0yzxx: 0.000, y: 0.000, z: 1.000qubit 1yzxx: 0.000, y: 0.000, z: 1.000qubit 2yzxx:-0.010, y:0.002, z:-0.997qubit 3yzxx: 0.000, y: 0.002, z: -0.997qubit 4yzxx: 0.000, y: 0.002, z: -0.997

Thanks IBM!!!, is so simple to understand if you are a developer, the quantum composer I use, contains four classes of gates, each denoted by a letter, in this case I only used Pauli X gate is known as an Xπ-rotation and it takes |0⟩→X|0⟩=|1⟩ in other words, it flips the zero to a one, or vice versa, this is why it is also commonly referred to as a bit-flip. The first class of gates (ID) represents an idle operation on the qubit for a time equal to the single-qubit gate duration. The second class of gates X, Y, Z represents a group known as Pauli operators, which represent bit-flips (X, which is a classical NOT), phase-flips (Z), and a combined bit-flip and phase-flip (Y). The third class H, S, S† represents Clifford gates, for generating quantum superpositions, along with the all important CNOT two-qubit gate which is necessary for entanglement. The final class T, T†, represents gates that are required for universal control.

A quantum algorithm (circuit) begins by preparing the qubits in well-defined states (here the ground state, |0⟩), then executing a series of one-qubit and two-qubit gates in time, followed by a measurement of the qubits. There are two options for measurement: a standard measurement which is a simple Z projection (M), or a Bloch measurement (BM) which is a Bloch sphere projection to indicate the final qubit state having been projected along the X, Y and Z axes. After measurement, the qubit state becomes classical (either |0⟩ or |1⟩ but never a quantum superposition); this is represented by the double line that appears after a measurement operation. This is the reference for the next experiments in this article.

Bloch Sphere

BLOCH SPHERE Probabilities in the standard basis are not enough to specify a quantum state because it cannot capture the phase of the superposition. A convenient representation for a qubit is the Bloch sphere.

If we define a qubit state by |ψ⟩=cos(θ/2)|0⟩+esin(θ/2)|1⟩ where θ and φ are defined in the picture, we see that there is a one-to-one correspondence between pure qubit states (2) and the points on the surface of a unit sphere (ℝ3). This is significant because now we can simply visualize qubit states and gates. We can reconstruct an arbitrary unknown qubit state |ψ⟩ by measuring the Bloch vector, whose vector components are the expectation values of the three Pauli operators, given by ⟨X⟩=tr(|ψ⟩⟨ψ|X), ⟨Y⟩=tr(|ψ⟩⟨ψ|Y), and ⟨Z⟩=tr(|ψ⟩⟨ψ|Z). The state is given by |ψ⟩⟨ψ|=(I+⟨X⟩X+⟨Y⟩Y+⟨Z⟩Z)/2.

Each expectation value ⟨Q⟩ can be obtained experimentally by first preparing the state, rotating the standard basis frame to lie along the corresponding axis, and making a measurement in the standard basis. The probabilities of obtaining the two possible outcomes 0 and 1 are used to evaluate the desired expectation value via ⟨Q⟩=P(0)-P(1). As an example, let's look at measuring the expectation value of X, ⟨X⟩=tr(|ψ⟩⟨ψ|X), depicted in the circuit below. Once |ψ⟩ is prepared we implement the gate H that exchanges Z to X, then we make a measurement in the standard basis. The desired expectation value is given by ⟨X⟩=P(0)-P(1). Similarly, we can use the S†-H gate to measure ⟨Y⟩.

Looks so simple but have been an epic experience for me, now, it's time to share you information about the quantum computer and quantum mechanics basics, to finish with experiments.

About quantum computers

Today's computers perform calculations and process information using the classical model of computation, in this model, all information is reducible to bits, which can take the values of either 0 or 1, and all processing can be performed via simple logic gates (AND, OR, NOT, NAND) acting on one or two bits at a time. At any point in its computation, a classical computer's state is entirely determined by the states of all its bits, so that a computer with n bits can exist in one of 2n possible states, ranging from 00...0 to 11...1, a quantum computer also has bits, just like any computer, but instead of 0 and 1, its quantum bits, or qubits, can represent a 0, 1, or both at once, a property known as superposition. This by itself is not much help, since a computer whose bits can be intermediate between 0 and 1 is just an analog computer, scarcely more powerful than an ordinary digital computer. A quantum computer takes advantage of a special kind of superposition that allows for exponentially many logical states at once, all the states from |00...0⟩ and |11...1⟩.

The vast majority of these quantum superpositions, and the ones most useful for quantum computation, are entangled they are states of the whole computer that do not correspond to any assignment of digital or analog states of the individual qubits. The quantum mechanics have some counterintuitive ideas, for example a physical system in a perfectly definite state can still behave randomly, or two systems that are too far apart to influence each other can nevertheless behave in ways that, though individually random, are somehow strongly correlated, anyway, this is great.

The Quantum Bit (Qubit)

A qubit is a quantum system consisting of two levels, labeled |0⟩ and |1⟩ (here we are using Dirac's bra-ket notation) and is represented by a two-dimensional vector space over the complex numbers ℂ2. This means that a qubit takes two complex numbers to fully describe it. The computational (or standard) basis corresponds to the two levels |0⟩ and |1⟩, and corresponds to the following vectors:

The qubit does not always have to be in just |0⟩ or |1⟩ but can be in any quantum state, denoted |ψ⟩, which can be any superposition |ψ⟩=α|0⟩+β|1⟩, of the basis vectors. The superposition quantities α and β are complex numbers; together they obey |α|2+|β|2=1.

Interesting things happen when quantum systems are measured, or observed. Quantum measurement is described by the Born rule. In particular, if a qubit that is in some state |ψ⟩ is measured in the standard basis, the result 0 is obtained with probability |α|2 and the result 1 is obtained with the complementary probability |β|2. A point of fascination is that a quantum measurement takes any superposition state of the qubit, and projects it to either the state |0⟩ or the state |1⟩ with a probability determined from the parameters of the superposition.

In IBM Quantum Lab are able the temperature cold enough (15 milliKelvin in a dilution refrigerator) that there is no ambient noise or heat to excite the superconducting qubit; after the system has gotten cold enough (for a few days), the superconducting qubit reaches equilibrium down to the ground state |0⟩, the IBM quantum computer uses a type of qubit called a superconducting transmon qubit, which is made from superconducting materials such as niobium and aluminum, patterned on a silicon substrate.

Let's talk about laws

Quantum is a system like everything else. To each physical system there corresponds a Hilbert space that is a linear vector space with complex coefficients and inner products ⟨φ|ψ⟩=Σiφi*ψi of dimensionality equal to the system's maximum number of reliably distinguishable states:

A quantum state is a configuration of the system. Each direction (ray) in the Hilbert space corresponds to a possible state of the system, other qubit states include:

with two states being reliably distinguishable if and only if their directions are orthogonal (inner product is zero).

A quantum state changes; it naturally wants to evolve, but it can always be undone. Evolution of a closed system is a unitary (unitary means linear and inner product preserving) transformation on its Hilbert space.

Scaling - how parts make a whole. The Hilbert space of a composite system is the tensor product of the Hilbert space of the parts, a two-qubit system can exist in a product state such as |00⟩ or |0+⟩ but also in an entangled state (|00⟩+|11⟩)/√2, in which neither qubit has a definite state, even though the pair together does.

Quantum measurements are probabilistic. Each possible measurement (measurement causes the system to behave probabilistically and forget its pre-measurement state, unless that state happens to lie entirely with one of the subspaces Πj) on a system corresponds to a resolution of it's Hilbert space into orthogonal subspaces j} where ΣjΠj=1, on state |ψ⟩ the result j occurs with probability P(j)=⟩ψ|πj|ψ⟩ and the state after the measurement is j⟩=πj|ψ⟩/√Pj.

Excited State and Pauli Operators

Quantum gates, or operations, are typically represented as matrices. A gate that acts on one qubit is represented by a 2×2 unitary matrix. Since quantum operations need to be reversible and preserve probability amplitudes, the matrices must be unitary. The result of the quantum gate is found by multiplying the matrix representing the gate with the vector representing the quantum state.

|ψ'⟩=U|ψ⟩ where U†U=1 (A† represents the complex conjugation and transpose of any matrix A).

A common group of gates, known as the Pauli Operators, are represented by the matrices:

Executing Pauli Operators

Pauli X

Q0 |0⟩
X
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
X
BM
qubit 0yzxx: -0.010, y: 0.002, z: -0.997

Pauli Y

Q0 |0⟩
Y
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
Y
BM
qubit 0yzxx: -0.002, y: -0.010, z: -0.997

Pauli Z

Q0 |0⟩
Z
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
Z
BM
qubit 0yzxx: -0.005, y: -0.001, z: 0.998

Superposition

Superposition is the concept that adding quantum states together (similar to overlaying two waves) results in a new quantum state. To make superpositions we need to expand our set of gates to include {H,S,S†}, and are represented by the matrices:

H known as the Hadamard gate, on one of the qubits that has been prepared in the |0⟩ state and then followed by the standard measurement. The qubit should spend half it's time in the |0⟩ state and the other half in the |1⟩ state. Before the measurement forced it to choose, the qubit was in both states at once. This is part of the reason for the often-misused analogy that a quantum computer does everything at once.

Applying the H gate to |0⟩ does a size-2 discrete Fourier transform, making the state |+⟩=(1/√2)(|0⟩+|1⟩), this is the standard representation of a superposition state. We can define the state |-⟩=(1/√2)(|0⟩-|1⟩), which with |+⟩ forms a new basis called the diagonal (or conjugate) basis. The H makes the above superposition and then the Z flips the phase (|1⟩ to -|1⟩).

Trying Superposition (+) X Measurement and Superposition (-) X Measurement, we should find that nearly 100% of the time the outcome is 0 and 1 respectively. That is, if we make a measurement in the standard basis, the outcome is completely uniform, but in the diagonal basis, it has deterministic outcome. No measurement can distinguish all four kinds of states |0⟩, |1⟩, |+⟩, |-⟩. This is not a limitation of the measurement, but a fundamental consequence of the uncertainty principle.

The circular or Y basis: |⟳⟩=(1/√2)(|0⟩+i|1⟩), |↺⟩=(1/√2)(|0⟩-i|1⟩). To make the |⟳⟩ state we need to use the additional gate S, the phase gate. This gate applies a complex phase to |1⟩, via the application of an H followed by an S gate.

Like the above example, measurement in the standard basis will not give you different statistics. Even measurement in the diagonal basis will be random. To measure in this basis we must rotate the standard basis Z to the circular basis Y. To do this, use an S† followed by H before your measurement.

Superpositions algorithms

Superposition (+)

Q0 |0⟩
H
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
H
BM
qubit 0yzxx: 0.997, y: 0.004, z: 0.006

Superposition (-)

Q0 |0⟩
H
Z
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
H
Z
BM
qubit 0yzxx: -1.000, y: -0.005, z: 0.001

Superposition (+)
X Measurement

Q0 |0⟩
H
H
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
H
H
BM
qubit 0yzxx: 0.000, y: 0.000, z: 1.000

Superposition (-)
X Measurement

Q0 |0⟩
H
Z
H
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
H
Z
H
BM
qubit 0yzxx: -0.010, y: 0.002, z: -0.997

Superposition (+i)
Y Measurement

Q0 |0⟩
H
S
S†
H
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
H
S
S†
H
BM
qubit 0yzxx: 0.000, y: 0.000, z: 1.000

Superposition (-i)
Y Measurement

Q0 |0⟩
H
S†
S†
H
M

Distribution

1
0.875
0.75
0.625
0.5
0.375
0.25
0.125
0
01

Bloch measurement

Q0 |0⟩
H
S†
S†
H
BM
qubit 0yzxx: -0.010, y: 0.002, z: -0.997

Decoherence

Real quantum computers must deal with decoherence, or the loss of information due to environmental disturbances (noise). The Bloch vector formalism is sufficient to describe the state of the system under decoherence processes. The pure states so far have ρ=|ψ⟩⟨ψ| and a Bloch vector of length 1, touching the surface of the Bloch sphere. Decoherence causes our quantum states to become mixed states, which have a density matrix ρ that can be written as a sum over pure states ρ=σkpkk⟩⟨ψk| and a Bloch vector that sits inside the Bloch sphere |⟨X⟩|2+|⟨Y⟩|2+|⟨Z⟩|2<1.

Energy relaxation and T1. One important decoherence process is called energy relaxation, where the excited |1⟩ state decays toward the ground state |0⟩. The time constant of this process, T1, is an extremely important figure-of-merit for any implementation of quantum computing.

Dephasing and T2. Dephasing is another decoherence process, and unlike energy relaxation, it affects only superposition states. It can be understood solely in a quantum setting as it has no classical analog. The time constant T2 includes the effect of dephasing as well as energy relaxation, and is another crucial figure-of-merit.

Follow us on Facebook, comment about the post and don't forget to share.

7NY.US