Skip to content

Replacing Graphix transpiler with graphix-jcz-transpiler#484

Open
emlynsg wants to merge 75 commits into
masterfrom
add-jcz
Open

Replacing Graphix transpiler with graphix-jcz-transpiler#484
emlynsg wants to merge 75 commits into
masterfrom
add-jcz

Conversation

@emlynsg

@emlynsg emlynsg commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

This PR takes the causal flow-based transpilation method detailed in the graphix-jcz-transpiler and adds it to Graphix, replacing the previous transpilation approach into one that is more principled and consistent with the literature [1].

Major changes include:

  • Full rework of the transpiler.py module to implement $J,, CZ$ gate decomposition and use the causal-flow-based approach to construct patterns
  • Addition of a $J(\alpha)$ gate to circuits, with equivalent additions to random circuits, ops and management to codebase components related to OpenQASM
  • Updates to many tests to account for the new transpiler generating BlochMeasurement commands which need to be inferred as Pauli (usually for preprocessing)

[1] The Measurement Calculus
Vincent Danos, Elham Kashefi, Prakash Panangaden

thierry-martinez added a commit to thierry-martinez/graphix that referenced this pull request Apr 17, 2026
There is currently a bug when using Mypy to type-check code using the
latest Qiskit release (2.4.0, released on 2026-04-16).

See python/mypy#21263

This bug makes the CI `typecheck` workflow fails systematically.
See for instance:
- PR TeamGraphix#484:
  https://github.com/TeamGraphix/graphix/actions/runs/24565948645/job/71826055256
- PR TeamGraphix#481 (I pushed a commit on that branch to fix the problem afterwards):
  https://github.com/TeamGraphix/graphix/actions/runs/24528928441/job/71707158586

The temporary fix proposed in this commit is to add an upperbound in
`requirements-dev.txt`, `qiskit<2.4`, while the bug is not fixed.
thierry-martinez added a commit that referenced this pull request Apr 17, 2026
There is currently a bug when using Mypy to type-check code using the
latest Qiskit release (2.4.0, released on 2026-04-16).

See python/mypy#21263

This bug makes the CI `typecheck` workflow fails systematically.
See for instance:
- PR #484:
  https://github.com/TeamGraphix/graphix/actions/runs/24565948645/job/71826055256
- PR #481 (I pushed a commit on that branch to fix the problem afterwards):
  https://github.com/TeamGraphix/graphix/actions/runs/24528928441/job/71707158586

The temporary fix proposed in this commit is to add an upperbound in
`requirements-dev.txt`, `qiskit<2.4`, while the bug is not fixed.
Emlyn Graham and others added 6 commits April 17, 2026 18:21
* Bump the python-packages group with 2 updates

Updates the requirements on [ruff](https://github.com/astral-sh/ruff) and [qiskit](https://github.com/Qiskit/qiskit) to permit the latest version.

Updates `ruff` from 0.15.10 to 0.15.11
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.15.10...0.15.11)

Updates `qiskit` to 2.4.0
- [Release notes](https://github.com/Qiskit/qiskit/releases)
- [Changelog](https://github.com/Qiskit/qiskit/blob/main/docs/release_notes.rst)
- [Commits](Qiskit/qiskit@1.0.0...2.4.0)

---
updated-dependencies:
- dependency-name: ruff
  dependency-version: 0.15.11
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: python-packages
- dependency-name: qiskit
  dependency-version: 2.4.0
  dependency-type: direct:development
  dependency-group: python-packages
...

Signed-off-by: dependabot[bot] <support@github.com>

* reverting bump to qiskit max version

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Emlyn Graham <egraham@PTB-02009984.paris.inria.fr>
Mypy currently fails when type-checking code against the latest Qiskit
release (2.4.0; see #485 and python/mypy#21263).

While #485 added an upperbound `qiskit<2.4` to `requirements-dev.txt`,
it did not configure Dependabot to respect this limit, causing PR
reverts (see commit bd9c491 in #486).

This commit adds the necessary configuration to prevent those updates.
@emlynsg emlynsg marked this pull request as ready for review April 20, 2026 14:49
@thierry-martinez

Copy link
Copy Markdown
Collaborator

Veriphix tests are likely being killed by the OOM killer. When running the Veriphix test suite locally, I observed that it hangs on the very first test of test_client.py. This test runs a delegated random circuit that only standardizes the pattern, without using Pauli presimulation or space minimization. There is a difficulty that I don't know how to address here: the new transpiler cannot match the performance of the original one without Pauli presimulation, but we do not yet know how to implement Pauli presimulation without setting the input.

@emlynsg

emlynsg commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Veriphix tests are likely being killed by the OOM killer. When running the Veriphix test suite locally, I observed that it hangs on the very first test of test_client.py. This test runs a delegated random circuit that only standardizes the pattern, without using Pauli presimulation or space minimization. There is a difficulty that I don't know how to address here: the new transpiler cannot match the performance of the original one without Pauli presimulation, but we do not yet know how to implement Pauli presimulation without setting the input.

I agree that seems to be the case. I can imagine it should work if either minimize_space or to_space_minimal_pattern are applied -- let's discuss tomorrow morning.

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.89%. Comparing base (6edaaef) to head (94aea0c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #484      +/-   ##
==========================================
+ Coverage   88.85%   89.89%   +1.03%     
==========================================
  Files          49       49              
  Lines        7135     7065      -70     
==========================================
+ Hits         6340     6351      +11     
+ Misses        795      714      -81     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

emlynsg and others added 2 commits April 30, 2026 14:04
Co-authored-by: matulni <m.uldemolins@gmail.com>

@matulni matulni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, very nice work. We should be able recycle some of your ideas in TranspileSwapResult in a more general API for Circuit !

I made some minor comments (and there remain a few comments from a previous review I made to resolve).

Comment thread graphix/qasm3_exporter.py Outdated
Comment thread graphix/qasm3_exporter.py Outdated
Comment thread graphix/qasm3_exporter.py Outdated
Comment thread tests/test_pattern.py Outdated
Comment thread graphix/transpiler.py Outdated
Comment thread graphix/transpiler.py Outdated
thierry-martinez and others added 15 commits June 11, 2026 22:48
Co-authored-by: matulni <m.uldemolins@gmail.com>
Co-authored-by: matulni <m.uldemolins@gmail.com>
… `uv` in CI (#516)

The `setup-uv` composite action ignored the `enable-cache` and
`python-version` inputs. Cache was still enabled by default, which is
the intended behaviour, but the system Python version was used instead
of the one specified. As a result, type‑checking and coverage ran with
Python 3.12 rather than the requested Python 3.14.

This commit fixes the `setup-uv` composite action so that it respects
both the `enable-cache` and `python-version` inputs.

The use of Python 3.12 for type-checking was noticed during the review of #512 (see comment #512 (comment)).

In the type-checking workflow, `python-version` was set to 3.13 (and was ignored) with an outdated comment about Qiskit/qiskit-aer#2378, which is now closed (see comment thierry-martinez/graphix-pyzx#1 (comment)). The `python-version` field has been updated to 3.14.
Bumps the python-packages group with 1 update: [ruff](https://github.com/astral-sh/ruff).


Updates `ruff` from 0.15.15 to 0.15.16
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.15.15...0.15.16)

---
updated-dependencies:
- dependency-name: ruff
  dependency-version: 0.15.16
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-packages
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Pin `matplotlib==3.10.9` for extra `dev` dependencies

This commit adds a pin to `matplotlib==3.10.9` in the `dev` extra
dependencies.

Matplotlib 3.11.0 introduces visual changes that break our
graphical-regression tests.  As we do for other packages whose new
releases can break the test suite, we pin a precise version in the
`dev` extra to ensure reproducible CI while keeping the package
unpinned in the default dependencies so users can choose whichever
version they prefer.

We pin `3.10.9` instead of the newer `3.11.0` because the latter drops
support for Python 3.11, which we continue to support until its
official end-of-life (October 2026):
https://devguide.python.org/versions/

* Restore qiskit constraint in `dev` extra

* Remove `pytest --mpl` in `tests_minimal`

We cannot run `pytest --mpl` in `test_minimal` (without extra), since
the visualization output depends on the version of Matplotlib, and the
pinning is only in the `dev` extra.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants