|
| 1 | +// Copyright 2025 Xanadu Quantum Technologies Inc. |
| 2 | + |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | + |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#ifndef PAULI_FRAME_DIALECT |
| 16 | +#define PAULI_FRAME_DIALECT |
| 17 | + |
| 18 | +include "mlir/IR/DialectBase.td" |
| 19 | +include "mlir/IR/OpBase.td" |
| 20 | + |
| 21 | +//===----------------------------------------------------------------------===// |
| 22 | +// PauliFrame dialect definition. |
| 23 | +//===----------------------------------------------------------------------===// |
| 24 | + |
| 25 | +def PauliFrame_Dialect : Dialect { |
| 26 | + let summary = "A dialect for Pauli frame tracking."; |
| 27 | + let description = [{ |
| 28 | + The Pauli frame tracking dialect includes a set of abstractions and operations for |
| 29 | + interacting with an external Pauli frame tracking library. A *Pauli frame tracker* [1] is a |
| 30 | + system that tracks gates from the Pauli group in classical electronics instead of applying |
| 31 | + them to qubits on the device. Doing so reduces the number of quantum operations applied to |
| 32 | + the system, thus reducing the probability of errors. |
| 33 | + |
| 34 | + A single Pauli record *Rq* tracks all the Pauli gates that are applied on qubit *q*. Every |
| 35 | + set of tracked Pauli gates can be reduced to one of the elements in the set {I, X, Z, XZ}, |
| 36 | + hence a single Pauli record can be stored using two bits, encoded as X- and Z-parity bits: |
| 37 | + |
| 38 | + I = (0, 0), X = (1, 0), Z = (0, 1), XZ = (1, 1) |
| 39 | + |
| 40 | + The operations in this dialect aim to represent the Pauli frame tracking components of the |
| 41 | + following five quantum processes required to maintain a system of universal quantum |
| 42 | + computation, as described in Ref. [2]: |
| 43 | + |
| 44 | + 1. Initialization of a qubit to |0>: |
| 45 | + a. Set Pauli record of target qubit to I. |
| 46 | + b. Initialize target qubit to |0>. |
| 47 | + 2. Measurement: |
| 48 | + a. Measure target qubit. |
| 49 | + b. Correct measurement result based on Pauli record. |
| 50 | + 3. Pauli gates: |
| 51 | + a. Update Pauli record of target qubit accordingly (the Pauli gates themselves are |
| 52 | + not physically applied to the qubit). |
| 53 | + 4. Clifford gates: |
| 54 | + a. Update Pauli record(s) of target qubit(s). |
| 55 | + b. Apply Clifford gate on target qubit(s). |
| 56 | + 5. Non-Clifford gates: |
| 57 | + a. Flush Pauli record(s) of target qubit(s). *Flushing* the Pauli record of a qubit |
| 58 | + refers to physically applying the Pauli gates stored in the record on that qubit |
| 59 | + and then resetting its record to I. |
| 60 | + b. Apply non-Clifford gate on target qubit(s). |
| 61 | + |
| 62 | + References |
| 63 | + ---------- |
| 64 | + |
| 65 | + [1] Knill, E. Quantum computing with realistically noisy devices. Nature 434, 39-44 (2005). |
| 66 | + https://doi.org/10.1038/nature03350. |
| 67 | + |
| 68 | + [2] Riesebos, L., et al. Pauli Frames for Quantum Computer Architectures. |
| 69 | + DAC '17: Proceedings of the 54th Annual Design Automation Conference 76, 1-6 (2017). |
| 70 | + https://doi.org/10.1145/3061639.3062300. |
| 71 | + |
| 72 | + > [!IMPORTANT] |
| 73 | + > The pauli_frame dialect is experimental and will not maintain API stability between releases. |
| 74 | + > Use at your own risk. |
| 75 | + }]; |
| 76 | + |
| 77 | + /// This is the namespace of the dialect in MLIR, which is used as a prefix for types and ops. |
| 78 | + let name = "pauli_frame"; |
| 79 | + |
| 80 | + /// This is the C++ namespace in which the dialect and all of its sub-components are placed. |
| 81 | + let cppNamespace = "::catalyst::pauli_frame"; |
| 82 | + |
| 83 | + let dependentDialects = [ |
| 84 | + "quantum::QuantumDialect" |
| 85 | + ]; |
| 86 | + |
| 87 | + /// Use the default type printing/parsing hooks, otherwise we would have to explicitly define them. |
| 88 | + let useDefaultAttributePrinterParser = 1; |
| 89 | + |
| 90 | + /// Uncomment the line below if defining types for the PauliFrame dialect |
| 91 | + // let useDefaultTypePrinterParser = 1; |
| 92 | +} |
| 93 | + |
| 94 | + |
| 95 | +//===----------------------------------------------------------------------===// |
| 96 | +// PauliFrame dialect types. |
| 97 | +//===----------------------------------------------------------------------===// |
| 98 | + |
| 99 | +/// Uncomment the lines below if defining types for the PauliFrame dialect |
| 100 | +// class PauliFrame_Type<string name, string typeMnemonic, list<Trait> traits = []> |
| 101 | +// : TypeDef<PauliFrame_Dialect, name, traits> { |
| 102 | +// let mnemonic = typeMnemonic; |
| 103 | +// } |
| 104 | + |
| 105 | + |
| 106 | +//===----------------------------------------------------------------------===// |
| 107 | +// PauliFrame dialect base operation. |
| 108 | +//===----------------------------------------------------------------------===// |
| 109 | + |
| 110 | +class PauliFrame_Op<string mnemonic, list<Trait> traits = []> : |
| 111 | + Op<PauliFrame_Dialect, mnemonic, traits>; |
| 112 | + |
| 113 | + |
| 114 | +#endif // PAULI_FRAME_DIALECT |
0 commit comments