PennyLane
Install
Install
  1. Compilation/
  2. Parity Matrix Intermediate Representation

Parity Matrix Intermediate Representation

OverviewDetailsResources

The parity matrix is an intermediate representation to efficiently describe the action of CNOT circuits. They are utilized in CNOT routing algorithms like, e.g., RowCol.

Inputs

  • CNOT circuit with n qubits

Outputs

  • n \times n binary matrix P with P_{ij} \in \{0, 1\}

Example

Consider the following CNOT circuit,

x_0: ────╭●───────╭X─╭●─┤  x_0 ⊕ x_3
x_1: ────│──╭X────│──│──┤  x_0 ⊕ x_1 ⊕ x_2 ⊕ x_3
x_2: ─╭X─╰X─╰●─╭X─│──╰X─┤  x_2 ⊕ x_3
x_3: ─╰●───────╰●─╰●────┤  x_3

and its corresponding parity matrix

P = \begin{pmatrix} 1 & 0 & 0 & 1 \\ 1 & 1 & 1 & 1 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 1\end{pmatrix}.

The rows correspond to the input qubits and tell us how they are transformed. E.g., the first row tells us that qubit x_0 is transformed to x_0 \oplus x_3.

Very easy-to-read examples are SWAP circuits that just permute qubits, as the corresponding parity matrix is a permutation matrix.

x_0: ─╭SWAP─────────────┤  x_1
x_1: ─╰SWAP─╭SWAP───────┤  x_2
x_2: ───────╰SWAP─╭SWAP─┤  x_3
x_3: ─────────────╰SWAP─┤  x_0
P = \begin{pmatrix} 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0\end{pmatrix}

Another typical example is a CNOT ladder, which continuously adds parities to lower qubits.

x_0: ─╭●───────┤  x_0
x_1: ─╰X─╭●────┤  x_0 ⊕ x_1
x_2: ────╰X─╭●─┤  x_0 ⊕ x_1 ⊕ x_2
x_3: ───────╰X─┤  x_0 ⊕ x_1 ⊕ x_2 ⊕ x_3
P = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 1 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 \\ 1 & 1 & 1 & 1 \end{pmatrix}

Typical usage

Parity matrices are utilized in CNOT routing algorithms like RowCol.

References

[1] "CNOT circuit extraction for topologically-constrained quantum memories", Aleks Kissinger, Arianne Meijer-van de Griend, arXiv:1904.00633, 2019

[2] "Quantum circuit optimizations for NISQ architectures", Beatrice Nash, Vlad Gheorghiu, Michele Mosca, arXiv:1904.01972, 2019

[3] "Optimization of CNOT circuits on limited connectivity architecture", Bujiao Wu, Xiaoyu He, Shuai Yang, Lifu Shou, Guojing Tian, Jialin Zhang, Xiaoming Sun, arXiv:1910.14478, 2019

[4] "Dynamic Qubit Routing with CNOT Circuit Synthesis for Quantum Compilation", Arianne Meijer-van de Griend, Sarah Meng Li, arXiv:2205.00724, 2022

[5] "Global Synthesis of CNOT Circuits with Holes", Ewan Murphy, Aleks Kissinger, arXiv:2308.16496, 2023

Cite this page

@misc{PennyLane-ParityMatrix,
    title = "Parity Matrix Intermediate Representation",
    author = "Korbinian Kottmann",
    year = "2025",
    howpublished = "\url{https://pennylane.ai/compilation/parity-matrix-intermediate-representation}"
}

Page author(s)

Korbinian Kottmann
Korbinian Kottmann

Korbinian Kottmann

Korbinian likes simulating quantum systems, whether it be via tensor network methods during his PhD, or with quantum computers at Xanadu. Currently, he works on quantum compilation to make simulation algorithms go brrr.

Never miss a milestone

Get the latest quantum updates delivered to your inbox.

Join the list
PennyLane

PennyLane is an open-source quantum software platform for quantum computing, quantum machine learning, and quantum chemistry. Create meaningful quantum algorithms, from inspiration to implementation.

Created with ❤️ by Xanadu.

Research

  • Research

  • Performance

  • Hardware and simulators

  • Demos library

  • Compilation hub

  • Quantum datasets

Education

  • Teach

  • Learn

  • Codebook

  • Coding challenges

  • Videos

  • Glossary

Software

  • Install

  • Features

  • PennyLane documentation

  • Catalyst documentation

  • Development guide

  • How-to guides

  • API

  • GitHub


Xanadu

© Copyright 2026 | Xanadu | All rights reserved

TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.

Privacy policyTerms of serviceCookies policyCode of conduct