1 of 74

TQEC: ZX Graphs and Lattice Surgery

Adrien Suau, Yiming Zhang, Purva Thakre, Sam Burdick, Yilun Zhao, Ricky Young, Arabella Schelpe, Ángela Elisa Álvarez, Victory Omole, Gian Giacomo Guerreschi, Kabir Dubey, Jose A Bolanos, Tianyi Hao, Reinhard Stahn, Jerome Lenssen, Moritz Schmidt, Mohammed Imaduddin, Brendan Reid, Milo Moses, Sean Collins, Mark Agib, Kwok Ho Wan, Austin Fowler

https://groups.google.com/g/tqec-design-automation

2 of 74

Program flow*

Qrisp/Jasp

Qiskit

Cirq

ProjectQ

Pytket

Qmod

Qualtran

Pandora

OpenQASM 2.0

PyZX

Topologiq

tqec

stim

* non-exhaustive examples

Central message: compiling an algorithm to lattice surgery should go via a ZX graph.

3 of 74

Where kind of hardware are we talking about?

4 of 74

Where kind of hardware are we talking about?

5 of 74

Performance data

arXiv:2408.13687, Nature 638 (2025) 920-926

Mean errors:

  • 1q ~5x10-4
  • 2q ~4x10-3
  • Measure/Idle ~8x10-3

6 of 74

Bigger is better

Bigger arrays show exponentially slower growth of logical error.

7 of 74

Precisely describing the surface code: stabilizers

The simplest stabilizers are just operators that leave some useful state unchanged, eg:

Pauli matrices:

Since the eigenstates are uniquely specified by the stabilizers, we can write them instead of the states.

8 of 74

Simple example:

Consider

​

This state is stabilized by 3 independent stabilizers

​

For complex states, the list of independent stabilizers can be far more compact than the state itself. We’ll need stabilizers to talk about the surface code.

+XXX

+ZZI

+IZZ

9 of 74

What about errors?

Consider the effect of errors:

​

What does this do to our stabilizers?

​

​

To say the same thing another way: or:

​

Errors flip the sign of stabilizers they anticommute with (XZ = -ZX). If we can work out how to measure the sign of a stabilizer, we can detect errors.

+XXX

-ZZI

+IZZ

10 of 74

A zero measurement means the output is the +1 eigenstate of A, one means -1 eigenstate

H

controlled-A

H

11 of 74

Let’s specialize to the surface code

Measure X stabilizer

Measure Z stabilizer

12 of 74

And now let’s put it all together

This is the surface code memory circuit in full detail

13 of 74

Let’s go 3D

d rounds

d rounds

0 rounds

0 rounds

Logical operators stick to walls of the same color.

This is 2d rounds of memory.

14 of 74

Moving things around

15 of 74

RGB = XYZ mnemonic

This is also just memory

Slices of the structure tell you what the computer should be doing at every instant of time

Logical operators stick to walls of the same color.

16 of 74

What about junctions?

blue node

red node

Logical operators with opposite color to the node must propagate to all edges, same color logical operators must touch an even number of edges.

17 of 74

Let’s formalize these rules

Prep |0> or Z basis measurement

Logical operators with opposite color to the node must propagate to all edges, same color logical operators must touch an even number of edges.

18 of 74

CNOT gates copy X on control, and Z on target to both outputs.

Hadamard converts X into Z and vice versa.

Reminder: gates as maps of matrices

Any process that maps logical operators as shown also implements that gate.

19 of 74

Let’s use these rules

A lattice surgery CNOT is a blue node (control) connected to a red node (target)

​

​

​

These paths are called correlation surfaces, basically a set of measurements that gives you sign information.

20 of 74

Example CNOTs

Control = blue node

Target = red node

This is CNOT

This is also CNOT

Provided you get the nodes right, the rest is arbitrary noodles

21 of 74

One more logical gate

Logical operators that pass through a layer of Hadamard gates are interchanged X⟷Z.

22 of 74

Let’s convert this…

This circuit prepares a 7 qubit Steane code, but all that really matters is that it’s made of gates that we can realize in tqec.

23 of 74

…into this in PyZX

This is the canonical ZX graph version of the quantum circuit that prepares a 7 qubit Steane code.

24 of 74

Fun with structures

Nodes of the same color connected by an edge can be merged/unmerged.

This is the “spider rule”.

​

​

Follows from lattice surgery.

25 of 74

Summary of ZX graphs from lattice surgery

Spider rule: merge and split same color nodes

Hadamard rule: can change color of node with only H edges

Two edge spider rule gives the identity rule.

26 of 74

PyZX can use these rules to simplify the ZX graph to just

27 of 74

Which is equivalent* to this…

Q: How can we turn this into lattice surgery?

* Used the above, which is true because both structures support one red left + two reds right, and two blues left + one blue right. This is the “bialgebra-rule”.

​

​

28 of 74

Node by node…

1

1

Volume = 1

29 of 74

Node by node…

1

1

2

3

4

2

3

4

Volume = 4

30 of 74

Node by node…

1

2

3

4

2

3

4

1

5

6

7

5

6

7

8

8

Volume = 12, best so far

31 of 74

Or automatically using topologiq (Jose A Bolanos)…

Volume = 18, best so far

32 of 74

Topologiq step by step

Topologiq uses an edge by edge algorithm with a randomly determined starting point.

​

​

​

Vast scope for further research.

33 of 74

Now what?

We have a structure…

But just as with CNOT we also need correlation surfaces…

34 of 74

Revisiting PyZX

Back when our computation was in PyZX we actually had correlation surfaces, future work to use them.

These give us the time ordering of our non-Clifford nodes, more about this later…

35 of 74

  1. Start from any leaf
  2. Explore the graph node-by-node
    1. Keep a generator set of correlation surfaces for the subgraph explored
  3. Generate valid correlation surfaces given the newly explored node
  4. Prune redundant ones to keep the generator set minimal
  5. Repeat from 2, overall complexity currently O(n4)

Algorithm: Tianyi Hao

CS dept University of Wisconsin-Madison

36 of 74

Issue: currently slow to find correlation surfaces…

Algorithm: Tianyi Hao

Currently ~O(n4)

​

Have ideas to reduce this to O(n)

​

37 of 74

Graphs for universal quantum computation

A Z node is by default green in PyZX, but blue using our RGB convention

Let’s focus on one node

38 of 74

Graphs for universal quantum computation

Can always express a ZX graph using only non-overlapping horizontal and vertical edges with only single-edge nodes having non-zero angles

39 of 74

Graphs for universal quantum computation

40 of 74

Let’s dive into the details, circuits and lattice surgery

Magic state cultivation: growing T states as cheap as CNOT gates

Craig Gidney, Cody Jones, Noah Shutty

arXiv:2409.17595

​

Can get O(p5) suppression.

​

Likely good enough for practical purposes at Lambda ~10.

How does a T state give us a T gate?

time

41 of 74

Achieving universal quantum computation

Data

T state

|0> |1>

Consume T states to implement T gates

Output

42 of 74

Why does this work?

Data

T state

|0> |1>

Output

This is teleportation.

T is a Z rotation and commutes through the Z control node

43 of 74

Why does this work?

Data

T state

|0> |1>

Output

This is teleportation.

T becomes T dagger if commuted through X, and this must be corrected with S.

44 of 74

Next missing piece: the S gate

The T gate requires an S gate 50% of the time.

|0> |1>

Data

Ancilla

Output

45 of 74

Next missing piece: Y-basis measurement

​

​

Data

Ancilla

Y-basis measurement

|0> |1>

time

Output

46 of 74

Don't want the S-gate? X-basis measurement

​

​

Data

Ancilla

X-basis measurement

|0> |1>

Top surface blue = transversal data qubit MX, red = MZ, this is logical measurement.

time

47 of 74

Let's put the full T-gate together

Data

Ancilla

Data

Data

Let’s focus up to here

48 of 74

Let's put the full T-gate together

Data

Ancilla

Data

Data

Parity of the blue correlation surface gives the measurement result

Both red and blue correlation surfaces can terminate on a T node

classical

49 of 74

Now the S-gate bit

Data

Ancilla

X- or Y-basis measurement

Data

Data

Ancilla

Want to be able to omit this

X- or Z-basis measurement

50 of 74

Now the S-gate bit

Data

Ancilla

X- or Y-basis measurement

Data

Data

Ancilla

Want to be able to omit this

X- or Z-basis measurement

Setting the indicated node to blue (X measurement) makes the structure a fancy identity gate. Z -> Z, X -> X

51 of 74

Now the S-gate bit

Data

Ancilla

X- or Y-basis measurement

Data

Data

Ancilla

Want to be able to omit this

X- or Z-basis measurement

Setting the indicated node to red (Z measurement) makes the structure an S gate. Z -> Z, Y -> X

52 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

53 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

​

Deform and simplify

54 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

​

Deform and simplify

55 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

​

Deform and simplify

56 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

​

Deform and simplify

57 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

​

Deform and simplify

58 of 74

Let's put the full T-gate together

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

​

Deform and simplify

59 of 74

Let's put the full T-gate together

ZX graph version! Let’s study this!

60 of 74

Let's put the full T-gate together

This correlation surface controls the color of the white node. There will be a classical processing delay.

61 of 74

Let's put the full T-gate together

T gates are diagonal, so Z -> Z (TZ = ZT), an eigenstate of Z (|0> or |1>) stays an eigenstate of Z.

62 of 74

Let's put the full T-gate together

Suppose that the T gate succeeds and no S gate correction is required. The white node will be set to be an X basis measurement, meaning a blue node.

63 of 74

Let's put the full T-gate together

The X correlation surface now only interacts with the T state, no S gate is applied.

64 of 74

Let's put the full T-gate together

But wait! Haven’t I made an arbitrary choice? Couldn’t I have made the correlation surface go this way?

65 of 74

Let's put the full T-gate together

A blue correlation surface cannot terminate on a blue node, so this is not valid and is not supported.

Only Y correlation surfaces can terminate on Y (green) nodes.

66 of 74

Let's put the full T-gate together

Suppose that the T gate “fails” and an S gate correction is required. The white node will be set to be a Z basis measurement, meaning a red node.

67 of 74

Let's put the full T-gate together

Now the S gate (green node) is included.

68 of 74

Let's put the full T-gate together

Note that the exact measurements included in the continuing correlation surface depend on whether or not the S-gate is included, hence a time ordering.

69 of 74

Let's put a small algorithm together

Start with just the first T gate.

​

Need enough time to process the results of the logical measurement and determine whether we apply a layer of data qubit Hadamard gates before measurement.

​

At 1 µs per round, distance 30, and classical processing latency of 10 µs, could "complete" a T-gate in 10 µs given sufficient space-time volume.

70 of 74

What do you mean 10 µs?

At first glance this may seem like a more reasonable amount of time.

71 of 74

1) Execute most of the structure

​

2) After classical processing determine basis and measure

​

3) After classical processing determine basis and measure

1

1

2

3

72 of 74

Can’t do universal computations yet…

We have a structure…

Get a set of correlation surfaces (observables in stim)

73 of 74

Use stim to simulate or drive quantum computer

74 of 74

Summary

tqec is a group of enthusiasts working towards building an open source full stack fault-tolerant quantum compiler

There is much work to be done! Please join the community, all are welcome :-)

https://groups.google.com/g/tqec-design-automation