Skip to content

Separate out process_runs closure in Optimize1qGatesDecomposition#16595

Merged
mtreinish merged 1 commit into
Qiskit:mainfrom
mtreinish:split-out-process-runs
Jul 16, 2026
Merged

Separate out process_runs closure in Optimize1qGatesDecomposition#16595
mtreinish merged 1 commit into
Qiskit:mainfrom
mtreinish:split-out-process-runs

Conversation

@mtreinish

Copy link
Copy Markdown
Member

This commit splits out the internal closure process_runs that is internally used by the Optimize1qGatesDecomposition pass to process and synthesize a 1q run found in the circuit. This is just a mechanical change that is setting the stage for fixing the deadlock reported in issue #16591 that is being fixed by #16592. This change was originally part of #16592 but was split out to make the logic change made in #16592 more clear. This is just the mechanical pre-work needed for that, however while not strictly a fix this PR will need to backported to also backport #16592.

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

This commit splits out the internal closure `process_runs` that is
internally used by the Optimize1qGatesDecomposition pass to process and
synthesize a 1q run found in the circuit. This is just a mechanical
change that is setting the stage for fixing the deadlock reported in
issue Qiskit#16591 that is being fixed by Qiskit#16592. This change was originally
part of Qiskit#16592 but was split out to make the logic change made in Qiskit#16592
more clear. This is just the mechanical pre-work needed for that,
however while not strictly a fix this PR will need to backported to also
backport Qiskit#16592.
@mtreinish mtreinish added this to the 2.5.1 milestone Jul 16, 2026
@mtreinish
mtreinish requested a review from a team as a code owner July 16, 2026 19:38
@mtreinish
mtreinish requested a review from jeevan0920 July 16, 2026 19:38
@mtreinish mtreinish added stable backport potential Make Mergify open a backport PR to the most recent stable branch on merge. Changelog: None Do not include in the GitHub Release changelog. Rust This PR or issue is related to Rust code in the repository labels Jul 16, 2026
@qiskit-bot

Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@jakelishman jakelishman left a comment

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.

I carved out the two hunks like so:

{ git cat-file blob pr/16595:crates/transpiler/src/passes/optimize_1q_gates_decomposition.rs | head -n460 | tail -n+378; } > new.txt

{ git cat-file blob pr/16595~:crates/transpiler/src/passes/optimize_1q_gates_decomposition.rs | head -n470 | tail -n+382; } > old.txt

then did diff -b old.txt new.txt and got

12c12
<                     match state.get_basis_set(PhysicalQubit::new(0), target, basis_gates.as_ref()) {
---
>             match state.get_basis_set(PhysicalQubit::new(0), target, basis_gates) {
19c19
<                     match state.get_basis_set(qubit, target, basis_gates.as_ref()) {
---
>             match state.get_basis_set(qubit, target, basis_gates) {
27,31c27
<                     state.get_euler_basis_set(
<                         PhysicalQubit::new(0),
<                         target,
<                         global_decomposers.as_ref(),
<                     )
---
>             state.get_euler_basis_set(PhysicalQubit::new(0), target, global_decomposers)
34,36c30,31
<                 state.target_basis_per_qubit[qubit.index()].get_or_init(|| {
<                     state.get_euler_basis_set(qubit, target, global_decomposers.as_ref())
<                 })
---
>         state.target_basis_per_qubit[qubit.index()]
>             .get_or_init(|| state.get_euler_basis_set(qubit, target, global_decomposers))
89d83
<         };

which is fairly easy to see is just rustfmt changes and a reference getting outlined.

state: &Optimize1qGatesDecompositionState,
target: Option<&Target>,
basis_gates: Option<&HashSet<String>>,
global_decomposers: Option<&Vec<String>>,

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.

Arguably this should be Option<&[String]> and make the corresponding bits Option::as_deref(), but I see get_euler_basis_set requires Option<&Vec<String>> for some reason, so let's leave it.

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.

Heh, that's exactly what my process was while I was writing #16592 last night. I didn't want to make a deeper change as part of this to keep it targeted for backport so I just left it as &Vec.

@jakelishman
jakelishman enabled auto-merge July 16, 2026 20:06
@jakelishman
jakelishman added this pull request to the merge queue Jul 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 16, 2026
@mtreinish
mtreinish added this pull request to the merge queue Jul 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 16, 2026
@mtreinish
mtreinish added this pull request to the merge queue Jul 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 16, 2026
@mtreinish
mtreinish added this pull request to the merge queue Jul 16, 2026
Merged via the queue into Qiskit:main with commit e455f1a Jul 16, 2026
50 of 52 checks passed
@mtreinish
mtreinish deleted the split-out-process-runs branch July 16, 2026 22:20
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 stable backport potential Make Mergify open a backport PR to the most recent stable branch on merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants