Skip to content

fix: pass explicit qubit_order to final_state_vector in state_preparation_test - #1455

Merged
mhucka merged 1 commit into
quantumlib:mainfrom
anishbhujbal7:fix/state-prep-qubit-order
Oct 9, 2026
Merged

mhucka merged 1 commit into
quantumlib:mainfrom
anishbhujbal7:fix/state-prep-qubit-order

Conversation

@anishbhujbal7

@anishbhujbal7 anishbhujbal7 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1454

Summary

Passes explicit qubit_order=qubits to final_state_vector() calls in state preparation tests to prevent dimension mismatch errors caused by implicit qubit ordering when idle qubits are present.

Changes Made

  • Explicitly passed qubit_order=qubits to final_state_vector() in src/openfermion/circuits/primitives/state_preparation_test.py:
    • test_prepare_gaussian_state
    • test_prepare_gaussian_state_with_spin_symmetry
    • test_prepare_slater_determinant

Verification

  • Verified locally with pytest-randomly using seed --randomly-seed=1921347655. All tests pass cleanly.

@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 updates the state preparation tests in state_preparation_test.py by explicitly passing the qubit_order=qubits argument to circuit.final_state_vector calls in test_prepare_gaussian_state, test_prepare_gaussian_state_with_spin_symmetry, and test_prepare_slater_determinant. There are no review comments, and I have no additional 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.

The code changes are fine, but the PR description talks about a function that does not exist. Please review for correctness, and also shorten it to a concise summary of what the PR does.

@mhucka mhucka added the s: awaiting-response Status: waiting on a response from someone label Oct 9, 2026
@anishbhujbal7

Copy link
Copy Markdown
Contributor Author

Thanks for pointing that out. I've updated the description to accurately list the modified test functions and shortened the summary

@mhucka mhucka changed the title fix: pass explicit qubit_order to final_state_vector in state_preparation fix: pass explicit qubit_order to final_state_vector in state_preparation_test Oct 9, 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.

Thanks!

@mhucka
mhucka added this pull request to the merge queue Oct 9, 2026
Merged via the queue into quantumlib:main with commit 006d148 Oct 9, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s: awaiting-response Status: waiting on a response from someone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test_prepare_gaussian_state due to missing qubit_order in final_state_vector

2 participants