Skip to content

Fix #1405: potential pool.join deadlock in ParallelLinearQubitOperator #1419

Merged
mhucka merged 3 commits into
quantumlib:mainfrom
rosspeili:fix/issue-1405-pool-join-deadlock
Jul 16, 2026
Merged

Fix #1405: potential pool.join deadlock in ParallelLinearQubitOperator #1419
mhucka merged 3 commits into
quantumlib:mainfrom
rosspeili:fix/issue-1405-pool-join-deadlock

Conversation

@rosspeili

@rosspeili rosspeili commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Consume imap_unordered results before joining the worker pool to avoid pipe backpressure deadlocks when state vectors are large.

Fixes #1405

Consume imap_unordered results before joining the worker pool to avoid pipe backpressure deadlocks when state vectors are large.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request resolves a potential deadlock in ParallelLinearQubitOperator._matvec by consuming the results of the multiprocessing pool before calling pool.join(). It also adds a regression test, test_matvec_large_vector_multiprocess, to prevent future regressions. There are no review comments, so I have no feedback to provide.

@mhucka mhucka left a comment

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.

Nice! Thanks for this. One minor suggestion.

Comment thread src/openfermion/linalg/linear_qubit_operator.py Outdated
rosspeili and others added 2 commits July 16, 2026 21:45
Co-authored-by: Michael Hucka <mhucka@google.com>
Apply mhucka's pool.join() guard correctly: return stays after finally, not inside it.
@rosspeili

Copy link
Copy Markdown
Contributor Author

@mhucka applied suggestion but ci failed on black cause gh apply dropped the try/finally indentation and moved return result into the finally block. Pushed a fix that keeps your guard (pool.join() always runs) with correct indentation and return after the try/finally. Thanks for the hint <3

@mhucka mhucka changed the title Fix pool.join deadlock in ParallelLinearQubitOperator (#1405) Fix #1405: pool.join deadlock in ParallelLinearQubitOperator Jul 16, 2026

@mhucka mhucka left a comment

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.

Awesome. Thank you!

@mhucka
mhucka added this pull request to the merge queue Jul 16, 2026
@mhucka mhucka added priority/before-1.8.1 area/health Involves code and/or project health labels Jul 16, 2026
Merged via the queue into quantumlib:main with commit 9e78d09 Jul 16, 2026
23 checks passed
@rosspeili
rosspeili deleted the fix/issue-1405-pool-join-deadlock branch July 16, 2026 19:48
@mhucka mhucka changed the title Fix #1405: pool.join deadlock in ParallelLinearQubitOperator Fix #1405: potential pool.join deadlock in ParallelLinearQubitOperator Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/health Involves code and/or project health priority/before-1.8.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deadlock possibility in linear_qubit_operator.py

2 participants