Skip to content

Fix state vector shape validation in PauliSum - #8465

Open
NiranjanRSoorej06 wants to merge 1 commit into
quantumlib:mainfrom
NiranjanRSoorej06:fix-8463-state-vector-validation
Open

NiranjanRSoorej06 wants to merge 1 commit into
quantumlib:mainfrom
NiranjanRSoorej06:fix-8463-state-vector-validation

Conversation

@NiranjanRSoorej06

Copy link
Copy Markdown

Summary

Validate state vector shapes before checking qubit map indices in PauliSum.expectation_from_state_vector.

Add regression tests for invalid state vector sizes and ensure existing qubit map validation behavior is preserved.

Tests

  • linear_combinations_test.py: 224 passed
  • pauli_string_test.py: 420 passed
  • Formatting, lint, and changed-file checks passed.
  • Confirmed that the regression test fails on the original implementation and passes with this change.

Screenshots

  1. Baseline: Regression Test Fails on Original Implementation
screenshot-2026-10-17_18-31-42 2. Baseline Test Output: Incorrect Validation Error screenshot-2026-10-17_18-31-57 3. Regression Failure: Expected Shape Validation Error screenshot-2026-10-17_18-32-03 4. Fixed Implementation: Regression Tests Pass screenshot-2026-10-17_18-32-20

The full test suite had 3 failures related to missing LaTeX tooling in the local environment.

Fixes #8463

@NiranjanRSoorej06
NiranjanRSoorej06 requested a review from a team as a code owner October 17, 2026 14:35
@github-actions github-actions Bot added the size: S 10< lines changed <50 label Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Invalid 1D state-vector lengths bypass shape validation in Pauli expectation calculations

1 participant