Skip to content
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

Oxidize UnitarySynthesis pass #13141

Merged
merged 51 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7528db9
Inital attempt at oxidizing unitary synthesis.
ElePT Sep 12, 2024
1296234
Add cacache pygates feature to accelerate
ElePT Sep 12, 2024
4456b36
Use sabre target to speed up preferred_direction
ElePT Sep 13, 2024
b2b202c
Merge branch 'main' of https://github.com/Qiskit/qiskit into oxidize-…
ElePT Sep 13, 2024
c49acc1
Adapt code to changes in PackedInstruction
ElePT Sep 13, 2024
739a5c8
Use target in preferred_direction
ElePT Sep 13, 2024
f527018
Some cleanup
ElePT Sep 13, 2024
eb815d1
More cleanup
ElePT Sep 16, 2024
7498419
Apply inline suggestions from Matt's code review
ElePT Sep 17, 2024
594a697
Merge branch 'main' of https://github.com/Qiskit/qiskit into oxidize-…
ElePT Sep 18, 2024
3d8891c
Apply remaining review suggestions:
ElePT Sep 17, 2024
7fc0a8a
Use dag.apply_operation_back in 1q case. Additional cleanup.
ElePT Sep 18, 2024
e1b6855
Don't return ref to float in two qubit decomposer.
ElePT Sep 20, 2024
8418fdb
Use PyList as input type for coupling_edges (previous approach was in…
ElePT Sep 23, 2024
369c012
Avoid using UnitarySynthesisReturn type, avoid intermediate dag creat…
ElePT Sep 23, 2024
4958425
Refactor appending to out_dag, remove unnecesary clones.
ElePT Sep 23, 2024
d908750
Merge branch 'main' into oxidize-unitary-synthesis
ElePT Sep 25, 2024
0773ea5
Cosmetic changes. Reduce indentation.
ElePT Sep 25, 2024
2a11b9e
Squash bug
ElePT Sep 25, 2024
b1cda36
Fix clippy
ElePT Sep 26, 2024
47f90cf
Add qsd test
ElePT Sep 26, 2024
5a925ca
Avoid making unnecessary variables public
ElePT Sep 26, 2024
63bb16e
Merge branch 'main' of https://github.com/Qiskit/qiskit into oxidize-…
ElePT Oct 1, 2024
dda1de0
Use OperationRef instead of exposing discriminant
ElePT Oct 1, 2024
f3c6f62
Rename DAGCircuit::substitue_node to py_substitute_node
ElePT Oct 1, 2024
f1d6d9c
Restore name in Python world
ElePT Oct 1, 2024
8c11b0f
Rewrite using flatten
ElePT Oct 3, 2024
6afc8cc
Apply suggestions from Ray's code review
ElePT Oct 3, 2024
4428673
Adjust suggestions from code review. Apply remaining feedback:
ElePT Oct 3, 2024
46bc6f9
Apply ownership suggestion from Ray
ElePT Oct 3, 2024
9451cca
Finish applying ownership suggestion from Ray
ElePT Oct 3, 2024
78848ec
Changes to synth_error function: remove error that wasn't handled, de…
ElePT Oct 3, 2024
b4cadb1
Undo flatten
ElePT Oct 4, 2024
1bf9956
Fix style
ElePT Oct 7, 2024
cd77e87
Add getters and setters for TwoQubitGateSequence, expose new, keep st…
ElePT Oct 7, 2024
4d8955a
Apply Ray's suggestion to use unwrap_operation
ElePT Oct 9, 2024
78429dd
Use ExtraInstructionAttributes::default()
ElePT Oct 9, 2024
a5d561a
Apply suggestion to avoid intermediate collection
ElePT Oct 9, 2024
b3988db
Use target::contains_key
ElePT Oct 9, 2024
56fa788
Apply suggestion to use iter() instead of keys()
ElePT Oct 9, 2024
3b3efb8
Merge branch 'oxidize-unitary-synthesis' of https://github.com/ElePT/…
ElePT Oct 9, 2024
08518fe
Final touches
ElePT Oct 9, 2024
b4263dc
Final touches
ElePT Oct 9, 2024
9cacf6f
Merge branch 'main' of https://github.com/Qiskit/qiskit into oxidize-…
ElePT Oct 9, 2024
3c23470
Replace panics with unreachable
ElePT Oct 15, 2024
228f470
Format
ElePT Oct 17, 2024
e21d0d7
Apply suggestions from Matt's code review
ElePT Oct 18, 2024
7f5eb02
Fix suggestions from Matt's code review
ElePT Oct 18, 2024
5deb7f5
Apply remaining suggestions
ElePT Oct 18, 2024
40314f3
Apply final suggestions from code review
raynelfss Oct 18, 2024
0bbf16a
Lint: Use `unwrap_or_default()`.
raynelfss Oct 18, 2024
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
4 changes: 2 additions & 2 deletions crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub fn generate_circuit(

const EULER_BASIS_SIZE: usize = 12;

static EULER_BASES: [&[&str]; EULER_BASIS_SIZE] = [
pub static EULER_BASES: [&[&str]; EULER_BASIS_SIZE] = [
&["u3"],
&["u3", "u2", "u1"],
&["u"],
Expand All @@ -593,7 +593,7 @@ static EULER_BASES: [&[&str]; EULER_BASIS_SIZE] = [
&["rz", "sx", "x"],
&["rz", "sx"],
];
static EULER_BASIS_NAMES: [EulerBasis; EULER_BASIS_SIZE] = [
pub static EULER_BASIS_NAMES: [EulerBasis; EULER_BASIS_SIZE] = [
EulerBasis::U3,
EulerBasis::U321,
EulerBasis::U,
Expand Down
1 change: 1 addition & 0 deletions crates/accelerate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub mod synthesis;
pub mod target_transpiler;
pub mod two_qubit_decompose;
pub mod uc_gate;
pub mod unitary_synthesis;
pub mod utils;
pub mod vf2_layout;

Expand Down
39 changes: 36 additions & 3 deletions crates/accelerate/src/two_qubit_decompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@ pub struct TwoQubitWeylDecomposition {
}

impl TwoQubitWeylDecomposition {
pub fn a(&self) -> f64 {
self.a
}
pub fn b(&self) -> f64 {
self.b
}
pub fn c(&self) -> f64 {
self.c
}
fn weyl_gate(
&self,
simplify: bool,
Expand Down Expand Up @@ -1214,17 +1223,39 @@ impl TwoQubitWeylDecomposition {

type TwoQubitSequenceVec = Vec<(Option<StandardGate>, SmallVec<[f64; 3]>, SmallVec<[u8; 2]>)>;

#[derive(Clone, Debug)]
#[pyclass(sequence)]
pub struct TwoQubitGateSequence {
gates: TwoQubitSequenceVec,
#[pyo3(get)]
global_phase: f64,
}

impl TwoQubitGateSequence {
pub fn gates(&self) -> &TwoQubitSequenceVec {
&self.gates
}

pub fn global_phase(&self) -> f64 {
self.global_phase
}

pub fn set_state(&mut self, state: (TwoQubitSequenceVec, f64)) {
self.gates = state.0;
self.global_phase = state.1;
}
}

impl Default for TwoQubitGateSequence {
fn default() -> Self {
Self::new()
}
}

#[pymethods]
impl TwoQubitGateSequence {
#[new]
fn new() -> Self {
pub fn new() -> Self {
TwoQubitGateSequence {
gates: Vec::new(),
global_phase: 0.,
Expand Down Expand Up @@ -1256,6 +1287,8 @@ impl TwoQubitGateSequence {
}
}
}

#[derive(Clone, Debug)]
ElePT marked this conversation as resolved.
Show resolved Hide resolved
#[allow(non_snake_case)]
#[pyclass(module = "qiskit._accelerate.two_qubit_decompose", subclass)]
pub struct TwoQubitBasisDecomposer {
Expand Down Expand Up @@ -1643,7 +1676,7 @@ impl TwoQubitBasisDecomposer {
Ok(res)
}

fn new_inner(
pub fn new_inner(
gate: String,
gate_matrix: ArrayView2<Complex64>,
basis_fidelity: f64,
Expand Down Expand Up @@ -1781,7 +1814,7 @@ impl TwoQubitBasisDecomposer {
})
}

fn call_inner(
pub fn call_inner(
&self,
unitary: ArrayView2<Complex64>,
basis_fidelity: Option<f64>,
Expand Down
Loading