Conversation
- Added a `strategy` parameter to `compile_sampler` and `compile_detector_sampler` methods in `src/tsim/circuit.py` to allow selection of stabilizer rank decomposition strategies ("cat5", "bss", "cutting").
- Updated corresponding classes in `src/tsim/sampler.py` and `src/tsim/compile/pipeline.py` to utilize the new strategy parameter.
- Modified integration tests in `test/integration/test_sampler.py` to validate behavior with different strategies.
- Updated `pyproject.toml` and `uv.lock` to include the `pyzx-param` package from a specific Git repository version.
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
|
There was a problem hiding this comment.
Pull request overview
Adds a decomposition-strategy parameter to the sampling/compilation pipeline so callers can choose between different stabilizer-rank decompositions (cat5/bss/cutting), and expands integration coverage to exercise all supported strategies.
Changes:
- Thread
strategythroughCircuit.compile_*→ sampler classes → compilation pipeline → stabilizer-rank decomposition (find_stab*). - Update integration tests to run under each decomposition strategy.
- Pin
pyzx-paramto a specific git revision viauvsources / lockfile to pick up the new decomposition implementations.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/tsim/circuit.py |
Exposes strategy on public sampler compilation methods and forwards it to samplers. |
src/tsim/sampler.py |
Stores/threads strategy into compile_program for both sampling and probability estimation. |
src/tsim/compile/pipeline.py |
Accepts strategy and passes it into stabilizer-rank decomposition during component compilation. |
src/tsim/compile/stabrank.py |
Passes strategy into pyzx_param.simulate.replace_* decomposition hooks. |
test/integration/test_sampler.py |
Parametrizes key integration tests over cat5, bss, and cutting. |
pyproject.toml |
Adds [tool.uv.sources] override for pyzx-param to a git revision. |
uv.lock |
Locks pyzx-param to the git revision; also changes resolution details for doc deps. |
Comments suppressed due to low confidence (1)
src/tsim/compile/stabrank.py:63
- The
find_stabdocstring still says it "decomposes T gates via BSS decompositions", but decomposition is now strategy-dependent (cat5/bss/cutting). Please update this description so it doesn’t imply BSS is always used.
This is the main entry point for stabilizer rank decomposition. It first removes
U3 phases, then decomposes T gates via BSS decompositions, producing a sum of
scalar graphs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [tool.uv.sources] | ||
| pyzx-param = { git = "https://github.com/rafaelha/pyzx", rev = "f4d440c299b71f576ccc369886ba319fb51dd2e2" } | ||
|
|
There was a problem hiding this comment.
The project code now imports DecompositionStrategy and passes strategy=... into pyzx_param.simulate.replace_* APIs. However, [project.dependencies] still allows pyzx-param>=0.9.2 from PyPI, while only uv users will pick up the git revision via [tool.uv.sources]. To avoid broken installs for pip/packaging users, either (a) bump the minimum released pyzx-param version that contains these APIs, or (b) switch the main dependency to a direct URL reference (PEP 508) matching this git rev.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Addresses #9 and #10
The main change is in the param-pyzx repo, where the decompositions are implemented.
Here, we now use the magic cat 5 decomposition

This decomposition reduces to the following equation from https://arxiv.org/pdf/2202.09202 when theta=pi/4:

Additionally, now the cutting decomposition is used. This simply corresponds to decomposing a single spider with the |0> and |1> state -- this case was previously handled already when only a single non-Clifford state remained.
The following three strategies are now supported: