Repository navigation
Fix QIS numerical edge cases and support Hamiltonian copy protocols - #55
Merged
Merged
Conversation
Validate state dimensions and finite inputs before constructing simulators. Respect original qubit labels and identity-gate noise during noisy simulation. Stabilize Renyi entropy, validate real observable expectations and variance, retain small evolution coefficients, and preserve global phase during ZNE folding. Include regression tests and matching Rust, Python, and C API documentation. Validation: 16 core regression tests, 4 C regression tests, and 1200 Python QIS tests passed against the staged source snapshot. Rust formatting and Python formatting checks passed.
Implement copy.copy and copy.deepcopy using the existing owned-value clone. Include type declarations, English and Chinese documentation, and tests for empty operators, independent terms, and alias preservation in nested deepcopy. Validation: all 58 Hamiltonian Python tests passed against an extension built from the staged source snapshot.
Describe endian ordering, release workflow organization, gate-basis tests, and phase conventions directly in terms of CQLib behavior. Cite the original SABRE paper and retain the existing commutative-cancellation implementation reference. Validation: all 99 compiler rewrite tests passed. Runtime behavior is unchanged.
Use a square-root machine-epsilon tolerance for rotated pure-state formation entropy, while checking finite results and physical bounds. Null-space eigenvalue roundoff is amplified by square roots and varies between eigensolver backends. Extract the existing concurrence-to-entropy calculation into a private helper and directly test clamping above one, below zero, and an interior value. Preserve the public API and numerical algorithm. Validation on macOS: 36 entropy unit tests, 16 core regression tests, and 1205 Python QIS tests passed against a freshly built extension. Formatting, Ruff, and Clippy checks passed. Windows and Linux CI verification remains pending.
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.
What Changed
folding.
copy.copy()andcopy.deepcopy()for Python Hamiltonians, including independent copies and nested alias preservation.Why
These changes prevent invalid inputs from producing misleading results and correct numerical and simulation edge cases. Regression tests cover the affected behavior, including non-diagonal pure-state
entropy, sparse qubit labels, coefficient validation, and global phase.
How Tested