feat: add sim/pauli package for arbitrary Pauli expectation values#2
Merged
feat: add sim/pauli package for arbitrary Pauli expectation values#2
Conversation
Add Pauli algebra types (PauliString, PauliSum) with symplectic encoding and efficient expectation value computation for both statevector and density matrix simulators. Enables Hamiltonian energy evaluation and variational workflows beyond the existing Z-only ExpectationValue. - Statevector: O(2^n) single-pass via bitmask phase trick, parallel at 17+ qubits - Density matrix: O(2^n) reading one element per row of rho - Shot-based: Z-basis parity estimation from measurement counts - Wrapper methods on both Sim types: ExpectPauliString, ExpectPauliSum - Z-only ExpectationValue added to density matrix for statevector parity
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4be9916bd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Every package now has a dedicated doc.go with [Symbol] cross-references, bulleted lists, and code examples following godoc best practices. Also fixes pre-commit hook to handle separate Go modules (braket, otelbridge, prombridge).
Groups changed packages by their nearest go.mod and runs a single go vet invocation per module instead of one per directory.
…dge case tests Fix 5 bugs found during full codebase audit: - (critical) densitymatrix gate2ColsParallel used conjugate-transpose instead of element-wise conjugate, producing wrong results for non-symmetric 2Q gates at >=9 qubits - (medium) ExpectPauliString/ExpectPauliSum lacked qubit count validation, causing index-out-of-range panics on mismatch - (low) MergeRotations had no default case for unexpected rotation axis - (low) Parser implicit measurement silently referenced nonexistent classical bits when numClbits < numQubits Also fix pre-commit hook to avoid bash 4+ associative arrays (declare -A) which fail on macOS default bash 3.2 and zsh. Add ~60 new tests across 17 packages including first-ever coverage for circuit/ir, regression tests for the parallel kernel fix, and edge case tests for zero-shot runs, empty circuits, boundary conditions, and error paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Pauli algebra types (PauliString, PauliSum) with symplectic encoding and efficient expectation value computation for both statevector and density matrix simulators. Enables Hamiltonian energy evaluation and variational workflows beyond the existing Z-only ExpectationValue.