Skip to content
This repository was archived by the owner on Jul 29, 2026. It is now read-only.

Commit 86747c7

Browse files
apchytrheltluke
andauthored
Merging snapshot 26/05/26 (#654)
Co-authored-by: Luke Helt <luke.helt@gmail.com>
1 parent 9dc057e commit 86747c7

184 files changed

Lines changed: 13136 additions & 5294 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CHANGELOG.md

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
### Breaking changes
44

5+
* Deprecated `CircuitComponent.ansatz` returning `None`.
6+
7+
* Deprecated passing an `Ansatz` into `__mul__`.
8+
9+
* Updated `ComputationalGraph` to make use of `mm_einsum` sublist style calls.
10+
11+
* Deprecated `mm_einsum` support for `ArrayLike` operands.
12+
13+
* Removed `DISCRETIZATION_METHOD`; Wigner computation now uses only Clenshaw.
14+
15+
* Bumped minimum pydantic to version 2.11 to support @cached_property directly.
16+
17+
* Dropped support for Python 3.11.
18+
519
* Deprecated `Circuit` in the `lab` module.
620

721
* Updated `lab` to use the new `AnsatzFactory` under the hood.
@@ -53,8 +67,46 @@ implementation `math.cython_lattice.beamsplitter`.
5367
* Changed the API of `Coherent`, `DisplacedSqueezed`, `Dgate` from real `x`, `y` parameters to a complex `alpha`.
5468
[(#617)](https://github.com/XanaduAI/MrMustard/pull/617)
5569

70+
### New features
71+
72+
* Added the new `Circuit` class.
73+
74+
* Added Siegel-disk Riemannian optimization (Bergman metric) for complex symmetric matrices with operator norm < 1, via `Variable.siegel` and `Optimizer(siegel_lr=...)`.
75+
76+
* Introduced the `ComputationalGraph`, a class to represent computations where nodes are components and edges are tensor contractions.
77+
5678
### Improvements
5779

80+
* Added support for Python 3.14.
81+
82+
* Added native jax version of the vanilla hermite_renormalized function.
83+
84+
* `Optimizer` now catches `KeyboardInterrupt` during `minimize` and returns the current variable values instead of crashing. Added an opt-in `parameter_history` flag to `Optimizer.minimize` that stores intermediate variable values at each step in `Optimizer.parameter_history`.
85+
86+
* Updated `mm_einsum` to support a sublist signature. As a result, contractions are no longer constrained to the number of supported characters.
87+
88+
* Added `fock_config` and `representation_config` to `ComputationalGraph`.
89+
90+
* Updated `ComputationalGraph` to do things in standard order.
91+
92+
* `oscillator_eigenstate` now supports arbitrary batch dimensions.
93+
94+
* Updated built-in `CircuitComponent`s to expose a `name` argument for users.
95+
96+
* Added `fock_diagonals_1leftover` (in `mrmustard.mathlib.lattice.strategies.fock_diagonals`), a numerically stable and exact algorithm for computing conditional density matrices.
97+
98+
* Added the `CircuitComponent.from_fock` classmethod.
99+
100+
* Added `WIGNER_2D_RESOLUTION` and `WIGNER_BOUNDS` settings for the single-mode state repr Wigner plot.
101+
102+
* Fixed `hermite_renormalized`: user-provided `stable` now overrides `STABLE_FOCK_CONVERSION`.
103+
104+
* Added `visualize_2d_with_arrows` to `State`.
105+
106+
* Made `fock_diagonals` numerically stable (in `mrmustard.mathlib.lattice.strategies.fock_diagonals`). It computes the multimode Fock diagonal / photon-number probabilities of a Gaussian operator.
107+
108+
* Added `max_disp` as a keyword argument to `GaussianKet.random` and `GaussianDM.random`. When given, each mode is displaced by a random complex amplitude sampled uniformly from the disk of radius `max_disp`.
109+
58110
* Added `tan`, `tanh`, `argmax`, `argmin`, `argsort`, and `mean` functions to the math backend.
59111

60112
* Added `stellar_roots()` and `plot_stellar_roots()` methods to `Ket` for computing and visualizing the zeros of the Bargmann polynomial of single-mode states.
@@ -133,6 +185,10 @@ matrix is provided and a random interferometer is to be generated.
133185
* Added ability to raise when contracting two circuit components in different
134186
representations by setting `settings.DEFAULT_REPRESENTATION` to `None`.
135187

188+
* Added the `Kgate` (Kerr) non-Gaussian single-mode unitary, diagonal in the Fock basis
189+
with entries :math:`e^{i\kappa n*(n-1)}`.
190+
[(#653)](https://github.com/XanaduAI/MrMustard/pull/653)
191+
136192
* Added support for Python 3.13.
137193
[(#640)](https://github.com/XanaduAI/MrMustard/pull/640)
138194

@@ -151,14 +207,18 @@ representations by setting `settings.DEFAULT_REPRESENTATION` to `None`.
151207
* Added a ``rich`` based repr to ``ParameterSet``.
152208
[(#616)](https://github.com/XanaduAI/MrMustard/pull/616)
153209

154-
* Added the `Kgate` (Kerr) non-Gaussian single-mode unitary, diagonal in the Fock basis
155-
with entries :math:`e^{i\kappa n*(n-1)}`.
156-
[(#653)](https://github.com/XanaduAI/MrMustard/pull/653)
157-
158210
### Bug fixes
159211

160-
* Fixed editable installs failing with a `FileNotFoundError` on `ninja` when re-running `uv run` (build isolation is now disabled for `mrmustard` so the rebuild hook uses the environment's stable `ninja`/`meson`).
161-
[(#655)](https://github.com/XanaduAI/MrMustard/pull/655)
212+
* Fixed a bug in `ComputationalGraph` where generic `CircuitComponent` subclasses were populating the `ansatz_dict`.
213+
214+
* Tests will now all pass on GPU when selecting the JAX backend.
215+
216+
* Moved `jax.config` logic from `mrmustard/math/backend_jax.py` into `mrmustard/__init__.py` to ensure settings are updated even when the backend is
217+
not set to `jax`.
218+
219+
* Added an absolute tolerance of `1e-20` to the check that a determinant in `complex_gaussian_integral_2_jitted` is close to `0` to mitigate underflows.
220+
221+
* Fixed a bug in `mm_einsum` where the user-supplied path would only work for the Bargmann contraction. Now it works all the way through.
162222

163223
* Fixed a bug in `CircuitComponent.quadrature` where einsum fock indices collided with mode indices for states on non-zero modes (e.g. a single-mode DM on mode 1 after tracing), forcing the number of quadrature points to equal the Fock cutoff and silently giving wrong results.
164224

@@ -173,6 +233,9 @@ with entries :math:`e^{i\kappa n*(n-1)}`.
173233

174234
* Fixed a bug that prevented `Number` from being JIT compiled in the JAX backend.
175235

236+
* Fixed editable installs failing with a `FileNotFoundError` on `ninja` when re-running `uv run` (build isolation is now disabled for `mrmustard` so the rebuild hook uses the environment's stable `ninja`/`meson`).
237+
[(#655)](https://github.com/XanaduAI/MrMustard/pull/655)
238+
176239
* Fixed bug in Gaussian integrals where small/large c values were not multiplying correctly.
177240
[(#641)](https://github.com/XanaduAI/MrMustard/pull/641)
178241

.github/workflows/pre_commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Install uv
1313
uses: astral-sh/setup-uv@v5
1414
with:
15-
python-version: "3.13"
15+
python-version: "3.14"
1616

1717
- name: Run pre-commit
1818
run: uv run --frozen --only-dev pre-commit run --all-files

.github/workflows/tests_docs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ jobs:
1616
concurrency:
1717
group: ${{ github.workflow }}-${{ github.ref }}
1818
cancel-in-progress: true
19-
env:
20-
HYPOTHESIS_PROFILE: ci
2119

2220
steps:
2321
- name: Checkout repo
@@ -26,7 +24,7 @@ jobs:
2624
- name: Install uv
2725
uses: astral-sh/setup-uv@v5
2826
with:
29-
python-version: "3.13"
27+
python-version: "3.14"
3028

3129
- name: Install system dependencies
3230
run: sudo apt-get update && sudo apt-get install -y graphviz

.github/workflows/tests_jax.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ jobs:
1818
id-token: write # This is required for requesting the JWT for S3 access
1919
strategy:
2020
matrix:
21-
python-version: ['3.11', '3.13']
21+
python-version: ['3.12', '3.14']
2222
env:
23-
HYPOTHESIS_PROFILE: ci
24-
UPLOAD_TIMINGS: ${{ github.event_name != 'pull_request' && matrix.python-version == '3.13' && 'true' || 'false' }}
23+
UPLOAD_TIMINGS: ${{ github.event_name != 'pull_request' && matrix.python-version == '3.14' && 'true' || 'false' }}
2524

2625
steps:
2726
- name: Checkout repo

.github/workflows/tests_numpy.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ jobs:
1818
id-token: write # This is required for requesting the JWT for S3 access
1919
strategy:
2020
matrix:
21-
python-version: ['3.11', '3.13']
21+
python-version: ['3.12', '3.14']
2222
env:
23-
HYPOTHESIS_PROFILE: ci
24-
UPLOAD_TIMINGS: ${{ github.event_name != 'pull_request' && matrix.python-version == '3.13' && 'true' || 'false' }}
23+
UPLOAD_TIMINGS: ${{ github.event_name != 'pull_request' && matrix.python-version == '3.14' && 'true' || 'false' }}
2524

2625
steps:
2726
- name: Checkout repo

.github/workflows/upload.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
jobs:
77
upload:
88
runs-on: ubuntu-latest
9-
env:
10-
HYPOTHESIS_PROFILE: ci
119

1210
steps:
1311
- name: Checkout repo
@@ -16,7 +14,7 @@ jobs:
1614
- name: Install uv
1715
uses: astral-sh/setup-uv@v5
1816
with:
19-
python-version: "3.13"
17+
python-version: "3.14"
2018

2119
- name: Build and install Mr Mustard
2220
run: |

.pre-commit-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ repos:
33
rev: v0.18.1
44
hooks:
55
- id: cython-lint
6-
args: [--max-line-length=100]
76
- id: double-quote-cython-strings
87
- repo: https://github.com/pre-commit/pre-commit-hooks
98
rev: v2.3.0
@@ -12,8 +11,12 @@ repos:
1211
- id: check-merge-conflict
1312
args: [--assume-in-merge]
1413
exclude: \.rst$
14+
- repo: https://github.com/astral-sh/uv-pre-commit
15+
rev: 0.8.11
16+
hooks:
17+
- id: uv-lock
1518
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.12.0
19+
rev: v0.15.7
1720
hooks:
1821
- id: ruff-check
1922
args: [ --fix, --exit-non-zero-on-fix]

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version: 2
55
build:
66
os: ubuntu-22.04
77
tools:
8-
python: "3.11"
8+
python: "3.14"
99
apt_packages:
1010
- graphviz
1111
jobs:

doc/code/lab.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ The `lab` module
88
.. toctree::
99
:maxdepth: 1
1010

11+
lab/circuit
1112
lab/circuit_components
1213
lab/circuit_components_utils
14+
lab/computational_graph
1315
lab/samplers
1416
lab/states
1517
lab/transformations

doc/code/lab/circuit.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. currentmodule:: mrmustard.lab.circuit
2+
3+
Circuit
4+
=======
5+
6+
.. autosummary::
7+
:nosignatures:
8+
9+
Circuit
10+
11+
12+
Circuit
13+
-------
14+
15+
.. autoclass:: mrmustard.lab.circuit::Circuit
16+
:members:

0 commit comments

Comments
 (0)