pyzx quantum circuit optimization using the zx calculus
play

PyZX: Quantum circuit optimization using the ZX-calculus Aleks - PowerPoint PPT Presentation

PyZX: Quantum circuit optimization using the ZX-calculus Aleks Kissinger aleks@cs.ru.nl John van de Wetering john@vdwetering.name Institute for Computing and Information Sciences Radboud University Nijmegen December 17, 2018 Introduction


  1. PyZX: Quantum circuit optimization using the ZX-calculus Aleks Kissinger aleks@cs.ru.nl John van de Wetering john@vdwetering.name Institute for Computing and Information Sciences Radboud University Nijmegen December 17, 2018

  2. Introduction § In fault-tolerant quantum computing, Clifford gates are cheap.

  3. Introduction § In fault-tolerant quantum computing, Clifford gates are cheap. § But to achieve universal QC we need other gates.

  4. Introduction § In fault-tolerant quantum computing, Clifford gates are cheap. § But to achieve universal QC we need other gates. § Most commonly T “ R Z p π { 4 q .

  5. Introduction § In fault-tolerant quantum computing, Clifford gates are cheap. § But to achieve universal QC we need other gates. § Most commonly T “ R Z p π { 4 q . § T gates are far more expensive than Clifford gates.

  6. Introduction § In fault-tolerant quantum computing, Clifford gates are cheap. § But to achieve universal QC we need other gates. § Most commonly T “ R Z p π { 4 q . § T gates are far more expensive than Clifford gates. § So: Optimizing fault tolerant QC means optimizing T-count.

  7. T-count optimization Finding optimal T-count is NP-hard, so we need heuristics.

  8. T-count optimization Finding optimal T-count is NP-hard, so we need heuristics. Existing heuristics fall basically in two categories.

  9. Method 1: Commutation and Cancellation Adjacent T gates become Clifford: T : = T = T T S

  10. Method 1: Commutation and Cancellation Adjacent T gates become Clifford: T : = T = T T S ñ By making T gates adjacent, we can decrease T count.

  11. Method 1: Commutation and Cancellation Adjacent T gates become Clifford: T : = T = T T S ñ By making T gates adjacent, we can decrease T count. T T = + + = T T T T + + + +

  12. Method 1: Commutation and Cancellation Adjacent T gates become Clifford: T : = T = T T S ñ By making T gates adjacent, we can decrease T count. T T = + + = T T T T + + + + And loads more...

  13. Method 2: Phase Polynomials Circuits built out of CNOT and T gates can be written as 4 g p x q | f 1 p x q , . . . , f n p x qy U | x y “ e i π where x P Z n 2 is a binary vector, g : Z n 2 Ñ Z 8 is a polynomial and f i : Z n 2 Ñ Z 2 are Z 2 -linear functions.

  14. Method 2: Phase Polynomials Circuits built out of CNOT and T gates can be written as 4 g p x q | f 1 p x q , . . . , f n p x qy U | x y “ e i π where x P Z n 2 is a binary vector, g : Z n 2 Ñ Z 8 is a polynomial and f i : Z n 2 Ñ Z 2 are Z 2 -linear functions. ñ Using this translation, we can make interesting simplifications

  15. Method 2: Phase Polynomials Circuits built out of CNOT and T gates can be written as 4 g p x q | f 1 p x q , . . . , f n p x qy U | x y “ e i π where x P Z n 2 is a binary vector, g : Z n 2 Ñ Z 8 is a polynomial and f i : Z n 2 Ñ Z 2 are Z 2 -linear functions. ñ Using this translation, we can make interesting simplifications T + + = T T S T + + + + (but optimal T-count finding still seems to be in NP)

  16. Limitations Using commutation, cancellation and phase polynomials, a lot of progress can be made...

  17. Limitations Using commutation, cancellation and phase polynomials, a lot of progress can be made... ...but there is an obvious limitation:

  18. Limitations Using commutation, cancellation and phase polynomials, a lot of progress can be made... ...but there is an obvious limitation: These methods never stray from the circuit model

  19. Limitations Using commutation, cancellation and phase polynomials, a lot of progress can be made... ...but there is an obvious limitation: These methods never stray from the circuit model Enter the ZX-calculus

  20. ZX-diagrams § ZX-diagrams consist of two types of maps x 0 ¨ ¨ ¨ 0 | ` e i α | 1 ¨ ¨ ¨ 1 y § Z-spiders : “ | 0 ¨ ¨ ¨ 0 y x 1 ¨ ¨ ¨ 1 | α ... ... x + ¨ ¨ ¨ + | ` e i α | - ¨ ¨ ¨ - y § X-spiders : “ | + ¨ ¨ ¨ + y x - ¨ ¨ ¨ - | α ... ...

  21. ZX-diagrams § ZX-diagrams consist of two types of maps x 0 ¨ ¨ ¨ 0 | ` e i α | 1 ¨ ¨ ¨ 1 y § Z-spiders : “ | 0 ¨ ¨ ¨ 0 y x 1 ¨ ¨ ¨ 1 | α ... ... x + ¨ ¨ ¨ + | ` e i α | - ¨ ¨ ¨ - y § X-spiders : “ | + ¨ ¨ ¨ + y x - ¨ ¨ ¨ - | α ... ... § By wiring these together, we can make arbitrary linear maps between qubits. For instance: “ H “ T “ - π - π - π π 2 2 2 4 CNOT “ CZ “

  22. ZX-diagrams § ZX-diagrams consist of two types of maps x 0 ¨ ¨ ¨ 0 | ` e i α | 1 ¨ ¨ ¨ 1 y § Z-spiders : “ | 0 ¨ ¨ ¨ 0 y x 1 ¨ ¨ ¨ 1 | α ... ... x + ¨ ¨ ¨ + | ` e i α | - ¨ ¨ ¨ - y § X-spiders : “ | + ¨ ¨ ¨ + y x - ¨ ¨ ¨ - | α ... ... § By wiring these together, we can make arbitrary linear maps between qubits. For instance: “ H “ T “ - π - π - π π 2 2 2 4 CNOT “ CZ “ But also: GHZ = T magic state = π 4

  23. ZX-calculus α ... ... “ ... α ` β “ ... ... α α ... ... β ... ... a π a π a π a π “ a π α “ ... ... a π α p - 1 q a α ... ... a π a π “ “ “ α, β P r 0 , 2 π s , a P t 0 , 1 u

  24. Circuit optimization with the ZX-calculus § Write your circuit as a ZX-diagram.

  25. Circuit optimization with the ZX-calculus § Write your circuit as a ZX-diagram. § Apply rewrite rules to simplify it.

  26. Circuit optimization with the ZX-calculus § Write your circuit as a ZX-diagram. § Apply rewrite rules to simplify it. § Turn the resulting diagram back into a circuit.

  27. First steps: graph-like ZX-diagrams § First turn all X-spiders into Z-spiders: = α α ... ... ... ...

  28. First steps: graph-like ZX-diagrams § First turn all X-spiders into Z-spiders: = α α ... ... ... ... § Cancel all double Hadamards: “ .

  29. First steps: graph-like ZX-diagrams § First turn all X-spiders into Z-spiders: = α α ... ... ... ... § Cancel all double Hadamards: “ . § Fuse all adjacent spiders.

  30. First steps: graph-like ZX-diagrams § First turn all X-spiders into Z-spiders: = α α ... ... ... ... § Cancel all double Hadamards: “ . § Fuse all adjacent spiders. § Cancel parallel connections: ... ... ... ... = ... ... ... = = ... α β α β α β α β

  31. First steps: graph-like ZX-diagrams § First turn all X-spiders into Z-spiders: = α α ... ... ... ... § Cancel all double Hadamards: “ . § Fuse all adjacent spiders. § Cancel parallel connections: ... ... ... ... = ... ... ... = = ... α β α β α β α β § Use new notation: : “

  32. Example α α “ γ γ α α “ “ γ γ α α “ “ γ γ

  33. More involved example π π 2 2 π π π 2 2 2 π π 2 2 π 2 = π π 2 2 π π π 2 2 2 π π 2

  34. More involved example π π 2 2 π π π 2 2 2 π π 2 2 π 2 = π π 2 2 π π π 2 2 2 π π 2 We call these diagrams graph-like .

  35. More involved example π π 2 2 π π π 2 2 2 π π 2 2 π 2 = π π 2 2 π π π 2 2 2 π π 2 We call these diagrams graph-like . To simplify these diagrams, we want to remove as many interior vertices as possible.

  36. Local complementation and pivoting ˘ π α 1 ¯ π α n ¯ π 2 2 2 ... ... ... α 1 α n “ ... ... ... α 2 ¯ π 1 ¯ π α n 2 ´ 2 α n α 2 1 ´ ... ... ... ... ... ... ... ... j π k π α 1 γ 1 α 1 ` k π γ 1 ` j π ... ... ... ... “ ... α n γ n α n ` k π γ n ` j π ... ... ... ... β n ... ... β n ` p j ` k ` 1 q π β 1 ... ... β 1 ` p j ` k ` 1 q π ...

  37. Simplification so far § Convert diagram into graph-like diagram.

  38. Simplification so far § Convert diagram into graph-like diagram. § Remove all internal ˘ π { 2 spiders by local complementation.

  39. Simplification so far § Convert diagram into graph-like diagram. § Remove all internal ˘ π { 2 spiders by local complementation. § Remove all connected internal a π spiders by pivoting.

  40. Simplification so far § Convert diagram into graph-like diagram. § Remove all internal ˘ π { 2 spiders by local complementation. § Remove all connected internal a π spiders by pivoting. § Remove internal a π spider connected to boundary by unfusing and pivoting: α ˚ ˚ j π α j π “ ˚ ˚ ... ... ... ... α 1 α n α 1 α n ... ... ... ...

  41. Simplification so far § Convert diagram into graph-like diagram. § Remove all internal ˘ π { 2 spiders by local complementation. § Remove all connected internal a π spiders by pivoting. § Remove internal a π spider connected to boundary by unfusing and pivoting: α ˚ ˚ j π α j π “ ˚ ˚ ... ... ... ... α 1 α n α 1 α n ... ... ... ... § If the original diagram was Clifford, then the simplified diagram has no internal spiders

  42. Clifford example Recall the example Clifford diagram: π π 2 2 π π π 2 2 2 π π 2

  43. Clifford example Recall the example Clifford diagram: π π 2 2 π π π 2 2 2 π π 2 This can be reduced by the described procedure to: π π π π π 2 π π 2

  44. Clifford+T example 7 π 5 π 4 4 π 2 3 π 5 π 2 4 3 π π 2 4

  45. Clifford+T example 7 π 5 π 4 4 π 2 3 π 5 π 2 4 3 π π 2 4 Question: How do we turn this into a circuit.

Recommend


More recommend