Distributed Simulation of Statevectors and Density Matrices (Jones et al. 2023)

I. Introduction

A. Notation

Bit Extraction Notation

i⁡[t] i of t represents the t t qubit of the binary basis i i

13=11012=i 13 equals 1101 sub 2 equals i

bit:  3 2 1 0
      1 1 0 1

i⁡[2]=1 i of 2 equals 1

Negated Bit Notation

If i⁡[t]=1 i of t equals 1 represents the binary value of qubit t t in statevector i i, then ! i⁡[t] i of t represents flipping the value such that ! i⁡[t]=0 i of t equals 0, and vice versa

Flipped Index Notation

If it i sub t represents the statevector i i with t t unchanged, then i¬t i sub not t represents the same statevector with the t t bit flipped

Multiple-bit Flip Notation

Similar to flipped index notation, except i¬{t1,t2} i sub not the set t sub 1 comma t sub 2 represents flipping both bit values in the binary string

Statevector Notation

For a N N qubit state

|ψ⟩=∑i2Nαi⁡|i⟩ divides psi right angle bracket equals the sum from i to 2 to the N power of alpha sub i of divides i right angle bracket

Computational bases are represented using binary decimal notation. For a 3 3 qubit state

|0⟩3=|000⟩ divides 0 right angle bracket sub 3 equals divides 000 right angle bracket, |1⟩3=|001⟩ divides 1 right angle bracket sub 3 equals divides 001 right angle bracket, |2⟩3=|010⟩ divides 2 right angle bracket sub 3 equals divides 010 right angle bracket, |3⟩3=|011⟩,⋯,|7⟩3=|111⟩ divides 3 right angle bracket sub 3 equals divides 011 right angle bracket comma dot dot dot comma divides 7 right angle bracket sub 3 equals divides 111 right angle bracket

And it is stored as

|ψ⟩N=[α0,α1,⋯,α2N-1] divides psi right angle bracket sub N equals open bracket alpha sub 0 comma alpha sub 1 comma dot dot dot comma alpha sub 2 to the N power minus 1 close bracket

This is the statevector, where each index corresponds to the basis state

Prefix & Suffix Bits

Consider a node to be "one computer/machine participating in the simulation. Distributed simulation defines W W as the number of nodes being used, which assumes

W=2w W equals 2 to the w-th power (# of nodes available is a power of 2 2)

Every amplitude index i i has N N bits total:

  • Some of those bits identify the node

  • The remaining bits identify the amplitudes position within that node

Suppose N=6 N equals 6. A statevector then would look like

q6 q5 q4 q3 q2 q1 q0

Now suppose W=8 W equals 8. That is, we have 8 8 nodes to work with. Since W=23 W equals 2 cubed, that means we need 3 3 bits to identify the node, i.e. the prefix bits. These prefix bits are defined as the rank bits

r1 r0 q4 q3 q2 q1 q0

The remaining suffix bits are local index bits, defined as λ=N-w lamda equals N minus w. The key difference is

  • Suffix/local bits can be manipulated entirely within one node

  • Prefix/rank bits requires communication with other nodes, usually reassigning the statevector to a new node

global index = equals (prefix bits)(suffix bits)

Moreover, global amplitude index i i can be decomposed into a combination of the node rank r r bit-shifted to the left by λ lamda and the local-index j j

i = (r << lambda) + j

Symbol

Meaning

it i sub t

value of bit t t in index i i

! it i sub t

flipped value of bit t t

i¬t i sub not t

index after flipping bit t t

i¬{t1,t2} i sub not the set t sub 1 comma t sub 2

index after flipping bits t1 t sub 1, t2 t sub 2

αi alpha sub i

amplitude stored at index i i

r r

node rank

j j

local index

W=2w W equals 2 to the w-th power

number of nodes

λ=N-w lamda equals N minus w

number of suffix/local bits

prefix bits

encoded in rank

suffix bits

encoded in local index

II. Local Statevector Algorithms

A. Local Costs

"Before we can discuss the challenges of distributed simulation, we must first understand the simpler problem of local (i.e. non-distributed), shared memory simulation." (Section II, first paragraph)

Recall that the simulation stores a full-state vector |ψ⟩=∑i2Nαi⁡|i⟩ divides psi right angle bracket equals the sum from i to 2 to the N power of alpha sub i of divides i right angle bracket as an array

ψ={α0,α1,⋯,α2N-1} psi equals the set alpha sub 0 comma alpha sub 1 comma dot dot dot comma alpha sub 2 to the N power minus 1

This notation gives a complete description of a quantum state, but the memory costs grow exponentially as N N increases

  • Considering C/C++ plus plus stores complex doubles as 16 16 bytes, for N N qubits we would need

2N 2 to the N power states × times 16 16 bytes

  • Dense mixed states are even worse

2N 2 to the N power states × times 2N 2 to the N power states × times 16 16 bytes

Full statevector simulators are useful for researchers because resource utilization and runtime costs are roughly the same across circuits of equal size, irregardless of state properties, making resource prediction trivial

But there are two main drawbacks of full state simulation, which is that it requires simultaneously

  1. Storing 2N 2 to the N power complex doubles (α) alpha

  2. Simulating n n qubit operators, which required O⁡(2N+n) O of open paren 2 raised to the N plus n power close paren floating point operations

Thus, the authors use four local performance metrics to measure these costs

Basic Operations bops

Bitwise operations, integer arithmetic, logical checks, indexing, etc.

i ^ (1ULL << targ)
(i >> targ) & 1
if (ctrlBit == 1)

Floating Point Operations flops

Arithmetic operations on real or complex values

m00*beta + m01*gamma;
m10*beta + m11*gamma;

NOTE: The paper distinguishes bops from flops because complex arithmetic is much for expensive than logical or bit manipulation operations

Memory memory

Memory overhead, i.e. the size of temporary data structures created during an algorithm

  • This excludes persistent pre-allocated memory dedicated to the quantum state representation

    • one-target gate: O⁡(1) O of 1 extra memory

    • many-target gate: O⁡(2n) O of open paren 2 to the n-th power close paren temporary array

Writes writes

The number of writes to heap/main memory, especially writes to statevectors

  • Moving amplitudes to and from memory is more often the bottleneck as opposed to performing arithmetic operations

  • Thus if an algorithm writes to fewer amplitudes, it may be much faster than other algorithms even if the math looks the same

Cost tags are summarized as:

[a bops][b flops][c memory][d writes]

NOTE: These metrics of course do not capture all local simulation considerations. Presented algorithms are optimized to avoid branching, enable auto-vectorization, cache efficiently, and avoid false sharing when possible in multithreaded settings. (Section 2, 2 commapg. 5 5)

B. One Target Gate

Let M^t M hat sub tdenote a single qubit gate operating on qubit t t, described by a complex matrix

M^t=[m00m01m10m11] M hat sub t equals the 2 by 2 matrix Row 1: m sub 00 m sub 01 Row 2: m sub 10 m sub 11

M^t M hat sub t gets applied to the target qubit t t as follows

M^t⁡|ψ⟩=∑i2N(αi⁡|iN-1⟩⋯M^t⁡|it⟩⋯|i0⟩) M hat sub t of divides psi right angle bracket equals the sum from i to 2 to the N power of open paren alpha sub i of divides i sub N minus 1 right angle bracket dot dot dot M hat sub t of divides i sub t right angle bracket dot dot dot divides i sub 0 right angle bracket close paren

M^t⁡|it⟩={m00⁡|0⟩+m01⁡|1⟩it=0m10⁡|0⟩+m11⁡|1⟩it=1 M hat sub t of divides i sub t right angle bracket equals 2 cases Case 1: m sub 00 of divides 0 right angle bracket plus m sub 01 of divides 1 right angle bracket blank i sub t equals 0 Case 2: m sub 10 of divides 0 right angle bracket plus m sub 11 of divides 1 right angle bracket blank i sub t equals 1

! it i sub t here means logical bit flip on it i sub t, where I will also be denoting it as jt j sub t. Putting it together:

M^t⁡|ψ⟩=∑i2N(αi)⁢|iN-1⟩⋯(mit⁢it⁡|it⟩+mjt⁢it⁡|jt⟩)⋯|i0⟩ M hat sub t of divides psi right angle bracket equals the sum from i to 2 to the N power of open paren alpha sub i close paren divides i sub N minus 1 right angle bracket dot dot dot open paren m sub i sub t i sub t of divides i sub t right angle bracket plus m sub j sub t i sub t of divides j sub t right angle bracket close paren dot dot dot divides i sub 0 right angle bracket

M^t⁡|ψ⟩=∑i2N(αi⁢mit⁢it)⁢|i⟩+αi⁢mjt⁢it⁡|i¬t⟩ M hat sub t of divides psi right angle bracket equals the sum from i to 2 to the N power of open paren alpha sub i m sub i sub t i sub t close paren divides i right angle bracket plus alpha sub i m sub j sub t i sub t of divides i sub not t right angle bracket

This final equations reveals that applying a one target gate operator to a full-statevector linearly combines pairs of amplitudes. Thus, when applying the operator M^t M hat sub t, the amplitudes of |ψ⟩ divides psi right angle bracket are simultaneously modified to become

αi→αi⁢mit⁢it+αi¬t⁢mit⁢jt alpha sub i right arrow alpha sub i m sub i sub t i sub t plus alpha sub i sub not t m sub i sub t j sub t

Since the pairs of amplitudes are (αi,αi¬t) open paren alpha sub i comma alpha sub i sub not t close paren, and since i¬t=i±2t i sub not t equals i plus or minus 2 to the t-th power, paired amplitudes are always a distance 2t 2 to the t-th power apart