Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new BaseSimulatorBackend interface and a concrete StateVector simulator backend with core operations (evolution, measurement, tensoring, etc.), extends measurement bases with flip and conjugate methods, and adds corresponding tests and documentation.
- Implement
BaseSimulatorBackendabstract class - Add
StateVectorclass with numerical routines (evolve,measure,entangle, ...) - Extend
MeasBasiswithflip/conjugateand update docs/tests
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_statevec.py | Add unit tests for StateVector; covers init, evolve, measure, etc. |
| graphix_zx/statevec.py | Implement StateVector methods and state-management logic |
| graphix_zx/simulator_backend.py | Introduce BaseSimulatorBackend interface |
| graphix_zx/matrix.py | Add is_hermitian helper |
| graphix_zx/common.py | Add abstract flip/conjugate to MeasBasis and implement in two subclasses |
| docs/source/statevec.rst | Document StateVector module |
| docs/source/simulator_backend.rst | Document simulator_backend module |
| docs/source/references.rst | Register the new modules in the reference guide |
Comments suppressed due to low confidence (6)
graphix_zx/statevec.py:119
- [nitpick] The parameter
num_qubitsshadows thenum_qubitsproperty, which can be confusing. Consider renaming to something likecountornew_qubits.
def add_node(self, num_qubits: int) -> None:
graphix_zx/statevec.py:158
- [nitpick] The example in the docstring is unclear about the permutation convention. Clarify whether the list represents a mapping from old-to-new or new-to-old axes so users aren't confused.
if permutation is [2, 0, 1], then
graphix_zx/statevec.py:155
- The
reordermethod is new but lacks any unit tests. Consider adding tests to cover common permutations and verify that qubit ordering is handled correctly.
def reorder(self, permutation: Sequence[int]) -> None:
graphix_zx/statevec.py:130
- The
entangle(and by extensionadd_node) methods are not exercised by the existing tests. Adding coverage for these operations would help prevent regressions.
def entangle(self, qubits: tuple[int, int]) -> None:
graphix_zx/matrix.py:39
- It’s safer to first check that
matis square (shape[0] == shape[1]) before comparing to its conjugate transpose, to avoid unexpected broadcasting.
def is_hermitian(mat: NDArray[T]) -> bool:
graphix_zx/common.py:121
- The new
flipandconjugatemethods on measurement bases lack direct unit tests. Consider adding tests to validate their behavior for each basis type.
def flip(self) -> PlannerMeasBasis:
Closed
EarlMilktea
requested changes
Jun 26, 2025
nabe98
requested changes
Jun 27, 2025
EarlMilktea
requested changes
Jul 18, 2025
EarlMilktea
approved these changes
Jul 22, 2025
nabe98
approved these changes
Jul 22, 2025
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.
Before submitting, please check the following:
pytest)ruffmypyandpyrightmake htmlin./docs/- you may need to install dependency for sphinx docs, seedocs/requirements.txt.)Then, please fill in below:
Context (if applicable):
I have implemented
simulator_backendandstatevecfor the basic numerical calculation. Currently,simulator_backendhas a minimum set of abstract methods, which will be extended in future PRs.I added
flipandconjugatemethods incommon.MeasBasis.Description of the change:
Related issue: