1 of 19

Programming a quantum computer

Evan

2 of 19

Contents

  1. A classical language hierarchy
  2. A quantum language hierarchy
    1. Logical operations and qubits
  3. Circuits for hardware (notebook)

3 of 19

What happens when I run a line of code?

  • Code is translated into increasingly specific forms
  • Final form is characterized by only 0’s and 1’s corresponding to transistors in hardware

4 of 19

Classical language hierarchy

5 of 19

Y := 3

X := Y + 2

My code:

8-BIT ADDER

CLOCK

My hardware:

  • High level
  • No reference to hardware
  • Easy to read

Wires carrying 0 V / 2 V

6 of 19

Y := 3

X := Y + 2

My code:

8-BIT ADDER

CLOCK

My hardware:

MOV AX,DATA

MOV DS,AX

LEA DX,MSG1

MOV AH,9

INT 21H

MOV AH,1

INT 21H

  • Semi-readable
  • Describes movement of data explicitly

7 of 19

Y := 3

X := Y + 2

My code:

8-BIT ADDER

CLOCK

My hardware:

MOV AX,DATA

MOV DS,AX

LEA DX,MSG1

MOV AH,9

INT 21H

MOV AH,1

INT 21H

0x 60 00 00 80

0x A4 00 00 00

0x 60 01 00 84

0x A4 01 01 00

0x 60 02 00 00

0x 60 03 00 04

0x 60 04 00 00

0x 60 05 00 01

0x 08 00 00 02

0x 20 00 00 03

0x 20 04 04 05

0x 11 20 04 01

  • Machine instructions
  • Inputs suitable for hardware
  • Specific to processor
    • (e.g. INTEL 8087)

8 of 19

Quantum language hierarchy

9 of 19

My code:

My hardware:

DC / AC microwave lines

  • High level
  • reference to hardware?
  • Easy to read

q0, q1 = GridQubit.rect(1, 2)

Circuit += Rx(pi/2).on(q0)

Circuit += SWAP(q0, q1)

Engine.run(Circuit)

Cirq

Google software hierarchy

Transmon qubit

10 of 19

My code:

Transmon qubit

My hardware:

DC / AC microwave lines

q0, q1 = GridQubit.rect(1, 2)

Circuit += Rx(pi/2).on(q0)

Circuit += SWAP(q0, q1)

Engine.run(Circuit)

Circuit serialization & parsing & ???

  • Still readable
  • Restricted syntax
  • Portable!

Google software hierarchy

11 of 19

My code:

My hardware:

q0, q1 = GridQubit.rect(1, 2)

Circuit += Rx(pi/2).on(q0)

Circuit += SWAP(q0, q1)

Engine.run(Circuit)

0x 60 00 00 80

0x A4 00 00 00

0x 60 01 00 84

0x A4 01 01 00

0x 60 02 00 00

0x 60 03 00 04

  • Machine instructions for microwave technology

0x 60 04 00 00

0x 60 05 00 01

0x 08 00 00 02

0x 20 00 00 03

0x 20 04 04 05

0x 11 20 04 01

Circuit serialization & parsing & ???

Transmon qubit

Google software hierarchy

12 of 19

My code:

My hardware:

DC / AC microwave lines

RX(PI/2) 0

SWAP 0 1

MEASURE 0 [0]

MEASURE 1 [1]

0x 60 00 00 80

0x 60 04 00 00

0x 60 05 00 01

0x 08 00 00 02

0x 20 00 00 03

0x A4 00 00 00

0x 20 04 04 05

0x 11 20 04 01 0x 60 01 00 84

0x 60 03 00 04

0x A4 01 01 00

0x 60 02 00 00

<qiskit code>

IBM software hierarchy

Transmon qubit

QASM: “Quantum Assembly Language”

13 of 19

My code:

My hardware:

DC / AC microwave lines

Qreg q[2];

Creg c[2];

RX q[0];

SWAP q[0],q[1];

measure q -> c;

0x 60 00 00 80

0x A4 00 00 00

0x 60 01 00 84

0x A4 01 01 00

0x 60 02 00 00

0x 60 03 00 04

0x 60 04 00 00

0x 60 05 00 01

0x 08 00 00 02

0x 20 00 00 03

0x 20 04 04 05

0x 11 20 04 01

<pyquil code>

Rigetti software hierarchy

Transmon qubit

QUIL: “Quantum Instruction Language”

14 of 19

Many quantum circuit libraries have similar scope

  • qiskit (IBM), cirq (Google), pyquil (Rigetti) are not languages
  • All three are designed for roughly the same purpose
    • Different levels of abstraction - Cirq allows selecting qubits, qiskit defines classical registers, etc.
    • Most are currently or soon to be cross-compatible: Cirq->QASM, Cirq->QUIL
  • Usage may differ according to goal
    • Near-term?
    • Hardware-agnostic?
    • Compiler options?

15 of 19

Some circuit libraries have different aims

  • strawberryfields (Xanadu) - supports continuous variable quantum computing
    • These are usually photonic quantum computers
    • Continuous variables correspond to position/momentum of photon oscillations
  • ocean (D-wave) - supports quantum annealing
    • Annealers are physical systems whose state/evolution can be mapped to solutions of problems

16 of 19

Quantum programming languages are more specific

  • Q# (Microsoft) is a standalone language for programming quantum circuits
    • Still has similar functionality to popular libraries, for now
    • Still must be compiled into instructions for physical devices
  • The future of quantum programming will look very different
    • Managing single qubits is informationally equivalent to managing individual transistors
    • Useful higher-level routines will eventually be discovered
    • Many operations will be implemented for logical quantum computing

17 of 19

Another layer in the language hierarchy?

Transmon qubit

DC / AC microwave lines

<Quantum assembly language / lower language>

<Hardware instructions>

<High level quantum language/library>

<Logical Encoding>

18 of 19

Logical qubits are error-resistant encodings

  • “Logical qubit” refers to some encoding of qubits, that itself acts as a single qubit
  • “Logical gates” are what act on logical qubits
  • A simple example is the three-qubit encoding: “Shor’s code”
    • How does this work??

Devitt, Simon J, William J Munro, and Kae Nemoto. “Quantum Error Correction for Beginners.” Reports on Progress in Physics 76.7 (2013): 076001.

19 of 19

Code Example