Skip to content

Add internal direct 2q synthesis interface to UnitarySynthesis#15845

Open
mtreinish wants to merge 1 commit intoQiskit:mainfrom
mtreinish:standalone-synth-interfaces
Open

Add internal direct 2q synthesis interface to UnitarySynthesis#15845
mtreinish wants to merge 1 commit intoQiskit:mainfrom
mtreinish:standalone-synth-interfaces

Conversation

@mtreinish
Copy link
Member

Summary

This commit adds an internal dedicated function to the UnitarySynthesis function to enable other passes that are synthesizes unitaries to reuse the logic from UnitarySynthesis. We're looking at adding new passes that will do 2q synthesized to a target, specifically the two qubit peephole optimization pass being added in #13419. The new interface in this PR lets that pass (and potential future passes) reuse the logic from unitary synthesis without the rest of the infrastructure. This was originally part of #13419 but this opts to split it out since it's logically independent from the PR adding the new pass.

Details and comments

This commit adds an internal dedicated function to the UnitarySynthesis
function to enable other passes that are synthesizes unitaries to reuse
the logic from UnitarySynthesis. We're looking at adding new passes that
will do 2q synthesized to a target, specifically the two qubit peephole
optimization pass being added in Qiskit#13419. The new interface in this PR
lets that pass (and potential future passes) reuse the logic from
unitary synthesis without the rest of the infrastructure. This was
originally part of Qiskit#13419 but this opts to split it out since it's
logically independent from the PR adding the new pass.
@mtreinish mtreinish requested a review from a team as a code owner March 20, 2026 22:56
@mtreinish mtreinish added Changelog: None Do not include in the GitHub Release changelog. Rust This PR or issue is related to Rust code in the repository labels Mar 20, 2026
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

Copy link
Member

@alexanderivrii alexanderivrii left a comment

Choose a reason for hiding this comment

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

LGTM, just a clarification question about return values.

Comment on lines +527 to +532
pub fn synthesize_2q_matrix(
mut unitary: CowArray<Complex64, Ix2>,
qargs_phys: [PhysicalQubit; 2],
qargs_virt: [Qubit; 2],
state: &mut UnitarySynthesisState,
constraint: QpuConstraint,
) -> PyResult<bool> {
) -> PyResult<Option<TwoQSynthesisResult>> {
Copy link
Member

Choose a reason for hiding this comment

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

Since this function is now meant to be used in other files, could you pease add a short docstring or a comment in which case this returns Ok(None) vs Err.

Comment on lines +618 to +620
let Some(result) = synthesize_2q_matrix(unitary, qargs_phys, state, constraint)? else {
return Ok(false);
};
Copy link
Member

Choose a reason for hiding this comment

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

Why is this Ok(false) and not Err?

}

#[inline]
pub fn fidelity_2q_sequence(
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to add a docstring to this function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: None Do not include in the GitHub Release changelog. Rust This PR or issue is related to Rust code in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants