-
-
Notifications
You must be signed in to change notification settings - Fork 55
✨ Add Hadamard Lifting #1605
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
base: main
Are you sure you want to change the base?
✨ Add Hadamard Lifting #1605
Changes from 42 commits
789654d
e05e2fe
fc10555
fa877c6
d784d01
e1b6b37
59739f1
9dc386e
5653b9a
67d3c7c
95e3604
e01a8b9
798c514
baf731c
a43b158
7fd4f75
9c43526
18382b3
7a89811
cc5f15c
a682420
2c298bf
e3da07f
b3bf966
b2862e8
e9c66b3
13c046d
db8491e
f95eeb0
18cb1b0
fb70183
d785bdb
74edb2e
cc97cfd
26ca2ed
a15d2c1
233da3f
6af2a96
664abad
cf245b1
4ab38c1
57159ae
c966623
8d32188
edc59a2
cdfc8ed
de726cb
500b0d1
b67a26f
928f6c5
9b2397e
20b6580
3b430d4
ee2f941
f3cb1d7
e5ba050
afdb6b0
44d8c98
1ca77fa
10b21ed
f183f63
89da08c
2f0dbe6
31995a8
3750513
0da58cf
1c2a5a8
fce739b
3331f0c
7f1256b
3084ec4
615bbd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,4 +72,64 @@ def MappingPass : Pass<"place-and-route", "mlir::ModuleOp"> { | |
| "The number of inserted SWAPs">]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Optimization Passes | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def HadamardLifting : Pass<"hadamard-lifting", "mlir::ModuleOp"> { | ||
| let dependentDialects = ["mlir::qco::QCODialect"]; | ||
| let summary = "This pass attempts to move Hadamard gates as far away from " | ||
| "measurements as possible by flipping them " | ||
|
LiRem101 marked this conversation as resolved.
Outdated
|
||
| "with Pauli gates. Additionally, it can change target and " | ||
| "control qubits from Pauli-Z gates to make " | ||
| "Hadamard lifting applicable. It also lifts Hadamard gates " | ||
| "over CNOT gates if that moves a measurement " | ||
| "directly after a control."; | ||
|
burgholzer marked this conversation as resolved.
Outdated
|
||
| let description = [{ | ||
| This pass lifts Hadamard gates away from the measurements in order to apply measurement lifting more effectively. It | ||
|
burgholzer marked this conversation as resolved.
Outdated
|
||
| uses the following commutation rules: | ||
| ┌───┐ ┌───┐ ┌───┐ ┌───┐ | ||
| ─┤ X ├─┤ H ├─ => ─┤ H ├─┤ Z ├─ | ||
| └───┘ └───┘ └───┘ └───┘ | ||
| ┌───┐ ┌───┐ ┌───┐ ┌───┐ | ||
| ─┤ Z ├─┤ H ├─ => ─┤ H ├─┤ X ├─ | ||
| └───┘ └───┘ └───┘ └───┘ | ||
| ┌───┐ ┌───┐ ┌───┐ ┌───┐ | ||
| ─┤ Y ├─┤ H ├─ => ─┤ H ├─┤ Y ├─ | ||
| └───┘ └───┘ └───┘ └───┘ | ||
| Hadamard lifting is only applied to lift Hadamard gates further in front in the circuit, not the other way around. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am tripping over the wording here. "lifting in front" does not really sound like proper English. It is rather "lift up", in general.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will adapt the wording. The naming I'd like to discuss again after I worked through the review, as we discussed. |
||
|
|
||
| If the Hadamard and Pauli gates are controlled, they are only lifted if both gates are controlled by exactly the | ||
| same qubits and the Pauli gate is not a Pauli Y gate. In that case, the swap of the Pauli Y gate and the Hadamard | ||
| gate introduces a phase (YH = -HY) which leads to a non-global phase for controlled gates. | ||
|
burgholzer marked this conversation as resolved.
Outdated
|
||
|
|
||
| In the case of the controlled Pauli Z gate, controls and targets are interchangeable. Therefore, transformation | ||
| routines as follows are possible and applied: | ||
| ┌───┐ | ||
| ┤ Z ├──■── ──■────■── ──■────■── | ||
| └─┬─┘┌─┴─┐ => ┌─┴─┐┌─┴─┐ => ┌─┴─┐┌─┴─┐ | ||
| ──■──┤ H ├ ┤ Z ├┤ H ├ ┤ H ├┤ X ├ | ||
| └───┘ └───┘└───┘ └───┘└───┘ | ||
| The commutation of controlled gates is only done if there are no gates applied between the two controlled gates to | ||
| any of the qubits used on the controlled gates. | ||
|
burgholzer marked this conversation as resolved.
Outdated
|
||
|
|
||
| In order to reduce multi-qubit gates, a third transformation routine is applied. Using the commutation rule | ||
| ┌───┐┌───┐┌───┐ | ||
| ──■── ┤ H ├┤ X ├┤ H ├ | ||
| ┌─┴─┐ => │───│└─┬─┘│───│ | ||
| ┤ X ├ ┤ H ├──■──┤ H ├ | ||
| └───┘ └───┘ └───┘ | ||
| the following transformation is applied to circuits where a Hadamard gate follows a target gate of a controlled | ||
| Pauli X gate, which is followed by a measurement: | ||
| ┌───┐┌───┐┌───┐ | ||
| ──■───────────── ┤ H ├┤ X ├┤ H ├── | ||
| ┌─┴─┐┌───┐┌──────┐ => │───│└─┬─┘│───┘──┐ | ||
| ┤ X ├┤ H ├┤ Meas │ ┤ H ├──■──┤ Meas │ | ||
| └───┘└───┘└──────┘ └───┘ └──────┘ | ||
|
|
||
| Afterward the measurement lifting routine could transform the CNOT into a classically controlled Pauli X. | ||
|
burgholzer marked this conversation as resolved.
Outdated
burgholzer marked this conversation as resolved.
Outdated
|
||
|
|
||
| }]; | ||
| } | ||
|
|
||
| #endif // MLIR_DIALECT_QCO_TRANSFORMS_PASSES_TD | ||
Uh oh!
There was an error while loading. Please reload this page.