Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
16688b8
add a function to replace gates by Pauli rotations
ShellyGarion Jan 4, 2026
d7f06d8
add pbc_transformation pass in rust (initial version)
ShellyGarion Jan 13, 2026
bff9262
minor fix, formatting
ShellyGarion Jan 13, 2026
09ab911
add python pbc transpiler pass
ShellyGarion Jan 13, 2026
cd35a4d
add initial test
ShellyGarion Jan 13, 2026
9c2b9f0
minor fix
ShellyGarion Jan 13, 2026
6f09d15
formatting
ShellyGarion Jan 13, 2026
e8434fc
handle non param gates
ShellyGarion Jan 13, 2026
826eb3b
add test for non-param gates
ShellyGarion Jan 13, 2026
2448eb7
add UGate, handle several parameters
ShellyGarion Jan 21, 2026
e7cb094
Merge branch 'main' into pbc_transformation
ShellyGarion Jan 21, 2026
82da8f7
minor update following PR 15434
ShellyGarion Jan 21, 2026
642fb0e
fix comment
ShellyGarion Jan 21, 2026
76d3465
complete handling all 1-qubit gates
ShellyGarion Jan 22, 2026
025297e
add CUGate, CU3Gate
ShellyGarion Jan 22, 2026
4859585
fix test
ShellyGarion Jan 22, 2026
5e2cece
complete handling all 2-qubit gates
ShellyGarion Jan 25, 2026
9cefe36
reduce code duplication. add generate_pauli_evolution_gate function
ShellyGarion Jan 26, 2026
a04c1ac
handle barrier and measure
ShellyGarion Jan 26, 2026
7b046ff
handle parameters, not only floats
ShellyGarion Jan 26, 2026
57212a6
remove un-needed if-else
ShellyGarion Jan 26, 2026
8bcdaf4
enhance test
ShellyGarion Jan 26, 2026
37449f0
add a test for parametrized gates
ShellyGarion Jan 27, 2026
db88f4d
do not panic. raise TranspilerError instead
ShellyGarion Jan 27, 2026
572f0e3
fix error
ShellyGarion Jan 27, 2026
0c1cb7b
improved synthesis for H, CH, ECR
ShellyGarion Jan 27, 2026
9c28e17
update docs
ShellyGarion Jan 28, 2026
9befd0f
add release notes
ShellyGarion Jan 28, 2026
3750154
fix reno
ShellyGarion Jan 28, 2026
dd0093a
unify U and U3
ShellyGarion Jan 29, 2026
ae7d9cb
remove with_capacity
ShellyGarion Jan 29, 2026
7a7813c
add PPM instead of measure, delay and reset
ShellyGarion Jan 29, 2026
c3d09a4
Merge branch 'main' into pbc_transformation
ShellyGarion Jan 29, 2026
a15e778
remove PyGate, following PR 15277
ShellyGarion Jan 29, 2026
8f6cbbd
handle unreachable
ShellyGarion Jan 29, 2026
399cb76
unify the cases of 0 and 1 parametrs. reduce code duplication
ShellyGarion Jan 29, 2026
1f5bcb8
raise error for GlobalPhaseGate
ShellyGarion Jan 29, 2026
5b65ac4
simplify tests using get_standard_gate_name_mapping
ShellyGarion Jan 29, 2026
b7ad3e6
update tests following review
ShellyGarion Feb 2, 2026
bbd4812
update release notes following review
ShellyGarion Feb 2, 2026
ba71485
fix comments
ShellyGarion Feb 2, 2026
70d401e
fix header
ShellyGarion Feb 2, 2026
7f03852
fix header
ShellyGarion Feb 2, 2026
b2c1bda
fix header
ShellyGarion Feb 2, 2026
3f64cbe
replace function by a table
ShellyGarion Feb 2, 2026
9533e44
add check that a gate is not an instruction
ShellyGarion Feb 2, 2026
0b75b1c
replace unreachble by panic
ShellyGarion Feb 2, 2026
a70c1a9
handle GlobalPhaseGate
ShellyGarion Feb 2, 2026
e15c9d4
update tests
ShellyGarion Feb 2, 2026
a146c03
update docstring
ShellyGarion Feb 2, 2026
65a5e75
enhance and fix docs following review
ShellyGarion Feb 8, 2026
e83d398
update types
ShellyGarion Feb 8, 2026
7fab525
nicer handle of barrier/reset/delay
ShellyGarion Feb 8, 2026
52ae177
move original_qubits outside the loop
ShellyGarion Feb 8, 2026
e24fde6
fix typos
ShellyGarion Feb 9, 2026
b58d030
add PBC transform for the 3-qubit gates
ShellyGarion Feb 18, 2026
7b69aef
update comment
ShellyGarion Feb 18, 2026
3bd8e70
update tests
ShellyGarion Feb 18, 2026
23544af
simplify RCCX
ShellyGarion Feb 18, 2026
5ba0d47
rename pass to ConvertToPauliRotations
ShellyGarion Mar 4, 2026
dc24546
remove pbc_transformation files
ShellyGarion Mar 4, 2026
0c243f1
formatting
ShellyGarion Mar 4, 2026
dd7301f
fix misprint
ShellyGarion Mar 4, 2026
653a7d2
Merge branch 'main' into pbc_transformation
ShellyGarion Mar 4, 2026
0bdcb42
Merge branch 'main' into pbc_transformation
ShellyGarion Mar 5, 2026
ad52f46
replace PauliEvolutioGate by PauliProductRotationGate
ShellyGarion Mar 5, 2026
9720d84
update tests to check PPR gate
ShellyGarion Mar 5, 2026
a11105c
update docs to use PPR
ShellyGarion Mar 5, 2026
34f741d
update release notes to use PPR
ShellyGarion Mar 5, 2026
230b03e
Merge branch 'main' into pbc_transformation
ShellyGarion Mar 5, 2026
2aaec38
Merge branch 'main' into pbc_transformation
alexanderivrii Mar 6, 2026
bb80d47
Update crates/transpiler/src/passes/convert_to_pauli_rotations.rs
ShellyGarion Mar 8, 2026
fc8f385
Update crates/transpiler/src/passes/convert_to_pauli_rotations.rs
ShellyGarion Mar 8, 2026
56a05e5
Update crates/transpiler/src/passes/convert_to_pauli_rotations.rs
ShellyGarion Mar 8, 2026
4ef37dc
Update crates/transpiler/src/passes/convert_to_pauli_rotations.rs
ShellyGarion Mar 8, 2026
9064b73
Update crates/transpiler/src/passes/convert_to_pauli_rotations.rs
ShellyGarion Mar 8, 2026
80478eb
Update crates/transpiler/src/passes/convert_to_pauli_rotations.rs
ShellyGarion Mar 8, 2026
f0cf83e
Update qiskit/transpiler/passes/optimization/convert_to_pauli_rotatio…
ShellyGarion Mar 8, 2026
737156f
update docs and reno following review
ShellyGarion Mar 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/transpiler/src/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ mod inverse_cancellation;
mod litinski_transformation;
mod optimize_1q_gates_decomposition;
mod optimize_clifford_t;
mod pbc_transformation;
mod remove_diagonal_gates_before_measure;
mod remove_identity_equiv;
pub mod sabre;
Expand Down
164 changes: 164 additions & 0 deletions crates/transpiler/src/passes/pbc_transformation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// This code is part of Qiskit.
//
// (C) Copyright IBM 2026
//
// This code is licensed under the Apache License, Version 2.0. You may
// obtain a copy of this license in the LICENSE.txt file in the root directory
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
//
// Any modifications or derivative works of this code must retain this
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

use std::f64::consts::{FRAC_PI_2, FRAC_PI_4, FRAC_PI_8, PI};

use qiskit_circuit::operations::StandardGate;

/// Map gates to a list of equivalent Pauli rotations and a global phase.
/// Each element of the list is of the form ((Pauli string, phase rescale factor, [qubit indices]), global phase).
/// For gates that didn't have a phase (e.g. X)
/// the phase rescale factor is simply the phase of the rotation gate. The convention is
/// `original_gate = PauliEvolutionGate(pauli, phase) * e^{i global_phase * phase}`
Comment thread
alexanderivrii marked this conversation as resolved.
Outdated

fn replace_gate_by_pauli_rotation(
gate: &StandardGate,
) -> (&'static [(&str, f64, &'static [u32])], f64) {
Comment thread
alexanderivrii marked this conversation as resolved.
Outdated
match gate {
StandardGate::I => (&[("I", 0.0, &[0])], 0.0),
StandardGate::X => (&[("X", FRAC_PI_2, &[0])], FRAC_PI_2),
StandardGate::Y => (&[("Y", FRAC_PI_2, &[0])], FRAC_PI_2),
StandardGate::Z => (&[("Z", FRAC_PI_2, &[0])], FRAC_PI_2),
StandardGate::S => (&[("Z", FRAC_PI_4, &[0])], FRAC_PI_4),
StandardGate::Sdg => (&[("Z", -FRAC_PI_4, &[0])], -FRAC_PI_4),
StandardGate::T => (&[("Z", FRAC_PI_8, &[0])], FRAC_PI_8),
StandardGate::Tdg => (&[("Z", -FRAC_PI_8, &[0])], -FRAC_PI_8),
StandardGate::SX => (&[("X", FRAC_PI_4, &[0])], FRAC_PI_4),
StandardGate::SXdg => (&[("X", -FRAC_PI_4, &[0])], -FRAC_PI_4),
StandardGate::H => (
&[
("Z", FRAC_PI_4, &[0]),
("X", FRAC_PI_4, &[0]),
("Z", FRAC_PI_4, &[0]),
],
FRAC_PI_2,
),
StandardGate::RZ => (&[("Z", 0.5, &[0])], 0.0),
StandardGate::RX => (&[("X", 0.5, &[0])], 0.0),
StandardGate::RY => (&[("Y", 0.5, &[0])], 0.0),
StandardGate::Phase => (&[("Z", 0.5, &[0])], 0.5),
StandardGate::U1 => (&[("Z", 0.5, &[0])], 0.5),
StandardGate::CX => (
&[
("XZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("X", -FRAC_PI_4, &[1]),
],
-FRAC_PI_4,
),
StandardGate::CZ => (
&[
("ZZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("Z", -FRAC_PI_4, &[1]),
],
-FRAC_PI_4,
),
StandardGate::CY => (
&[
("YZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("Y", -FRAC_PI_4, &[1]),
],
-FRAC_PI_4,
),
StandardGate::CH => (
&[
("Z", FRAC_PI_2, &[1]),
("X", FRAC_PI_4, &[1]),
("Z", 3.0 * FRAC_PI_8, &[1]),
("XZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("X", -FRAC_PI_4, &[1]),
("Z", FRAC_PI_8, &[1]),
("X", FRAC_PI_4, &[1]),
],
3.0 * FRAC_PI_4,
),
StandardGate::CS => (
&[
("ZZ", -FRAC_PI_8, &[0, 1]),
("Z", FRAC_PI_8, &[0]),
("Z", FRAC_PI_8, &[1]),
],
FRAC_PI_8,
),
StandardGate::CSdg => (
&[
("ZZ", FRAC_PI_8, &[0, 1]),
("Z", -FRAC_PI_8, &[0]),
("Z", -FRAC_PI_8, &[1]),
],
-FRAC_PI_8,
),
StandardGate::CSX => (
&[
("XZ", -FRAC_PI_8, &[0, 1]),
("Z", FRAC_PI_8, &[0]),
("X", FRAC_PI_8, &[1]),
],
FRAC_PI_8,
),
StandardGate::Swap => (
&[
("XX", FRAC_PI_4, &[0, 1]),
("YY", FRAC_PI_4, &[0, 1]),
("ZZ", FRAC_PI_4, &[0, 1]),
],
FRAC_PI_4,
),
StandardGate::ISwap => (
&[("XX", -FRAC_PI_4, &[0, 1]), ("YY", -FRAC_PI_4, &[0, 1])],
0.0,
),
StandardGate::DCX => (
&[
("XZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("X", -FRAC_PI_4, &[1]),
("XZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("X", -FRAC_PI_4, &[1]),
],
-FRAC_PI_2,
),
StandardGate::ECR => (
&[
("Y", -FRAC_PI_2, &[0]),
("Z", FRAC_PI_4, &[0]),
("X", -FRAC_PI_4, &[1]),
("XZ", FRAC_PI_4, &[0, 1]),
("Z", -FRAC_PI_4, &[0]),
("X", -FRAC_PI_4, &[1]),
],
-2.0 * PI,
),
StandardGate::RZZ => (&[("ZZ", 0.5, &[0, 1])], 0.0),
StandardGate::RXX => (&[("XX", 0.5, &[0, 1])], 0.0),
StandardGate::RYY => (&[("YY", 0.5, &[0, 1])], 0.0),
StandardGate::RZX => (&[("ZX", 0.5, &[0, 1])], 0.0),
StandardGate::CPhase => (
&[("ZZ", -0.25, &[0, 1]), ("Z", 0.25, &[0]), ("Z", 0.25, &[1])],
0.25,
),
StandardGate::CU1 => (
&[("ZZ", -0.25, &[0, 1]), ("Z", 0.25, &[0]), ("Z", 0.25, &[1])],
0.25,
),
StandardGate::CRZ => (&[("ZZ", -0.25, &[0, 1]), ("Z", 0.25, &[1])], 0.0),
StandardGate::CRX => (&[("XZ", -0.25, &[0, 1]), ("X", 0.25, &[1])], 0.0),
StandardGate::CRY => (&[("YZ", -0.25, &[0, 1]), ("Y", 0.25, &[1])], 0.0),
_ => unreachable!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unreachable is for paths that the code should be unable to reach -- it would be nicer for this to return None or an error (or at least a panic!)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But unreachable! calls panic!, right?

Copy link
Copy Markdown
Collaborator

@Cryoris Cryoris Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this distinction is to give a better indication of what went wrong. With unreachable you indicate it should be impossible to reach that part of the code, whereas a panic is a more generic break in the program

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced unreachable be panic in 0b75b1c

"This is only called for one and two qubit gates with no paramers or with a single parameter."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now support any standard gate with up to 1 parameter, and can update this message, right?

Copy link
Copy Markdown
Member Author

@ShellyGarion ShellyGarion Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this is unreachable since we call this function only for 1q and 2q gates with 0 or 1 parameters ?
(there is another function for 1q and 2q gates with >1 parameters)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced unreachable be panic in 0b75b1c

),
}
}
Loading