-
Notifications
You must be signed in to change notification settings - Fork 57
Add a Pauli frame tracking dialect #2188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
joeycarter
wants to merge
9
commits into
main
Choose a base branch
from
joeycarter/mock-pauli-frame-tracker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
811b6eb
Initial commit
joeycarter a819786
Remove PauliFrame ConversionTest.mlir
joeycarter b815a22
Add verifiers, dialect tests and other infra
joeycarter a9c6839
Rejig set of ops and add more documentation
joeycarter 65b1869
Merge branch 'main' into joeycarter/mock-pauli-frame-tracker
joeycarter e28b082
Format
joeycarter 96aeb05
Add changelog entry
joeycarter d232be7
Merge branch 'main' into joeycarter/mock-pauli-frame-tracker
joeycarter e61ffc6
Add op pauli_frame.init_qreg
joeycarter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| add_subdirectory(IR) | ||
| # add_subdirectory(Transforms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| add_mlir_dialect(PauliFrameOps pauli_frame) | ||
| add_mlir_doc(PauliFrameDialect PauliFrameDialect PauliFrame/ -gen-dialect-doc -gen-op-doc) | ||
| add_mlir_doc(PauliFrameOps PauliFrameOps PauliFrame/ -gen-op-doc) | ||
|
|
||
| set(LLVM_TARGET_DEFINITIONS PauliFrameOps.td) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright 2025 Xanadu Quantum Technologies Inc. | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
|
|
||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "mlir/IR/Dialect.h" | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // PauliFrame dialect declarations. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "PauliFrame/IR/PauliFrameOpsDialect.h.inc" | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // PauliFrame type declarations. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| /// Uncomment the lines below if defining types for the PauliFrame dialect | ||
| // #define GET_TYPEDEF_CLASSES | ||
| // #include "PauliFrame/IR/PauliFrameOpsTypes.h.inc" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| // Copyright 2025 Xanadu Quantum Technologies Inc. | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
|
|
||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef PAULI_FRAME_DIALECT | ||
| #define PAULI_FRAME_DIALECT | ||
|
|
||
| include "mlir/IR/DialectBase.td" | ||
| include "mlir/IR/OpBase.td" | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // PauliFrame dialect definition. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def PauliFrame_Dialect : Dialect { | ||
| let summary = "A dialect for Pauli frame tracking."; | ||
| let description = [{ | ||
| The Pauli frame tracking dialect includes a set of abstractions and operations for | ||
| interacting with an external Pauli frame tracking library. A *Pauli frame tracker* [1] is a | ||
| system that tracks gates from the Pauli group in classical electronics instead of applying | ||
| them to qubits on the device. Doing so reduces the number of quantum operations applied to | ||
| the system, thus reducing the probability of errors. | ||
|
|
||
| A single Pauli record *Rq* tracks all the Pauli gates that are applied on qubit *q*. Every | ||
| set of tracked Pauli gates can be reduced to one of the elements in the set {I, X, Z, XZ}, | ||
| hence a single Pauli record can be stored using two bits, encoded as X- and Z-parity bits: | ||
|
|
||
| I = (0, 0), X = (1, 0), Z = (0, 1), XZ = (1, 1) | ||
|
|
||
| The operations in this dialect aim to represent the Pauli frame tracking components of the | ||
| following five quantum processes required to maintain a system of universal quantum | ||
| computation, as described in Ref. [2]: | ||
|
|
||
| 1. Initialization of a qubit to |0>: | ||
| a. Set Pauli record of target qubit to I. | ||
| b. Initialize target qubit to |0>. | ||
| 2. Measurement: | ||
| a. Measure target qubit. | ||
| b. Correct measurement result based on Pauli record. | ||
| 3. Pauli gates: | ||
| a. Update Pauli record of target qubit accordingly (the Pauli gates themselves are | ||
| not physically applied to the qubit). | ||
| 4. Clifford gates: | ||
| a. Update Pauli record(s) of target qubit(s). | ||
| b. Apply Clifford gate on target qubit(s). | ||
| 5. Non-Clifford gates: | ||
| a. Flush Pauli record(s) of target qubit(s). *Flushing* the Pauli record of a qubit | ||
| refers to physically applying the Pauli gates stored in the record on that qubit | ||
| and then resetting its record to I. | ||
| b. Apply non-Clifford gate on target qubit(s). | ||
|
|
||
| References | ||
| ---------- | ||
|
|
||
| [1] Knill, E. Quantum computing with realistically noisy devices. Nature 434, 39-44 (2005). | ||
| https://doi.org/10.1038/nature03350. | ||
|
|
||
| [2] Riesebos, L., et al. Pauli Frames for Quantum Computer Architectures. | ||
| DAC '17: Proceedings of the 54th Annual Design Automation Conference 76, 1-6 (2017). | ||
| https://doi.org/10.1145/3061639.3062300. | ||
|
|
||
| > [!IMPORTANT] | ||
| > The pauli_frame dialect is experimental and will not maintain API stability between releases. | ||
| > Use at your own risk. | ||
joeycarter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }]; | ||
|
|
||
| /// This is the namespace of the dialect in MLIR, which is used as a prefix for types and ops. | ||
| let name = "pauli_frame"; | ||
|
|
||
| /// This is the C++ namespace in which the dialect and all of its sub-components are placed. | ||
| let cppNamespace = "::catalyst::pauli_frame"; | ||
|
|
||
| let dependentDialects = [ | ||
| "quantum::QuantumDialect" | ||
| ]; | ||
|
|
||
| /// Use the default type printing/parsing hooks, otherwise we would have to explicitly define them. | ||
| /// Uncomment the line below if defining attributes for the PauliFrame dialect | ||
| // let useDefaultAttributePrinterParser = 1; | ||
|
|
||
| /// Uncomment the line below if defining types for the PauliFrame dialect | ||
| // let useDefaultTypePrinterParser = 1; | ||
| } | ||
|
|
||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // PauliFrame dialect types. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| /// Uncomment the lines below if defining types for the PauliFrame dialect | ||
| // class PauliFrame_Type<string name, string typeMnemonic, list<Trait> traits = []> | ||
| // : TypeDef<PauliFrame_Dialect, name, traits> { | ||
| // let mnemonic = typeMnemonic; | ||
| // } | ||
|
|
||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // PauliFrame dialect base operation. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| class PauliFrame_Op<string mnemonic, list<Trait> traits = []> : | ||
| Op<PauliFrame_Dialect, mnemonic, traits>; | ||
|
|
||
|
|
||
| #endif // PAULI_FRAME_DIALECT | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright 2025 Xanadu Quantum Technologies Inc. | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
|
|
||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Quantum/IR/QuantumDialect.h" | ||
|
|
||
| #include "PauliFrame/IR/PauliFrameDialect.h" | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // PauliFrame ops declarations. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| /// Uncomment the lines below if defining attributes for the PauliFrame dialect | ||
| // #define GET_ATTRDEF_CLASSES | ||
| // #include "PauliFrame/IR/PauliFrameAttributes.h.inc" | ||
|
|
||
| #define GET_OP_CLASSES | ||
| #include "PauliFrame/IR/PauliFrameOps.h.inc" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.