Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v0.5.0 #265

Merged
merged 57 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
31b651a
Update CI to agree with new dev policies 👩🏽‍⚖️ (#166)
sduquemesa Oct 14, 2022
4f9ade2
Sampling from Gaussian measurements 🎲 (#143)
sduquemesa Oct 17, 2022
30f8ce4
Rotation gate unitary (#155)
sduquemesa Oct 17, 2022
8265f89
Calculate displacement operator unitary matrix using The Walrus (#147)
sduquemesa Oct 17, 2022
39c8b4b
adds eye_like function to interface and tf backend (#170)
ziofil Oct 20, 2022
a3a238a
Refactor Wigner function into module (#171)
sduquemesa Nov 1, 2022
ff94a45
Bugfix dgate gradient (#176)
ziofil Nov 10, 2022
318c9ab
settings repr (#174)
ziofil Nov 11, 2022
555c6a6
Refactor `utils.homodyne` into `physics.fock` (#177)
sduquemesa Nov 17, 2022
c984ed1
Use marginal distribution when drawing 🎨 (#179)
sduquemesa Nov 24, 2022
5d72b0e
optional callback at each opt step (#175)
ziofil Dec 5, 2022
fc3dfec
Bugfix rgate modes (#180)
ziofil Dec 13, 2022
4dc12a3
allows for full cutoff specification (#181)
ziofil Dec 13, 2022
7fb563b
changes norm to probability in repr of State (#182)
ziofil Dec 13, 2022
2f474c3
Choi application bugfix (#188)
ziofil Jan 9, 2023
3ff0cab
Check changelog entry is created on PRs (#189)
sduquemesa Jan 10, 2023
0655361
Seed (#183)
ziofil Jan 11, 2023
1a1a314
Fock cutoff bugfix (#184)
ziofil Jan 11, 2023
7511b95
fix max int32
ziofil Jan 12, 2023
aa9be5e
Bargmann methods (#185)
ziofil Jan 13, 2023
44650f0
Bugfix axis labels (#190)
ziofil Jan 17, 2023
a9d6ddb
Bugfix typerror (#192)
ziofil Jan 20, 2023
f856be7
blacked (#197)
ziofil Feb 3, 2023
8f17c23
Adds ray-based distributed trainer. (#194)
zeyueN Feb 9, 2023
b135bf7
Circuit drawer (#196)
ziofil Feb 11, 2023
a69fff2
updated README.md
ziofil Feb 16, 2023
7d79a37
ray test fix (#201)
zeyueN Feb 17, 2023
8f6d70d
Improving tests (#191)
ziofil Feb 27, 2023
2b9b182
Compact fock (#154)
rdprins Feb 28, 2023
a95c987
Bugfix misc (#202)
ziofil Feb 28, 2023
df42771
Improve mmtensor (#195)
ziofil Feb 28, 2023
b936c39
displays sign correctly (#209)
ziofil Feb 28, 2023
fbc1614
better type annotations (#199)
ziofil Feb 28, 2023
4fa732d
Add unitary update (#208)
sylviemonet Mar 1, 2023
adda279
fix issue and add test (#210)
ziofil Mar 1, 2023
ad74f57
dm-dm fidelity cutoffs (#212)
ziofil Mar 1, 2023
ff1c947
Displacement gate on MrMustard (#211)
sduquemesa Mar 3, 2023
f24e3a4
Bump version and get changelog ready for release (#213)
ziofil Mar 3, 2023
3582c5a
Dockerize Mr Mustard and create vscode dev-container (#214)
sduquemesa Mar 6, 2023
1eab73f
Choi cutoff fix (#216)
ziofil Mar 7, 2023
a84bb6e
Update requirements (#215)
sduquemesa Mar 7, 2023
af67a53
Fix build action on main branch
sduquemesa Mar 7, 2023
4030c8d
Merge branch 'main' into develop
ziofil Mar 8, 2023
849c1ee
Increment version to 0.5.0-dev (#220)
sduquemesa Mar 8, 2023
8fbaaeb
Merge branch 'develop' of github.com:XanaduAI/MrMustard into develop
ziofil Mar 8, 2023
37270fc
Merge branch 'develop' of github.com:XanaduAI/MrMustard into develop
ziofil Mar 8, 2023
f75dd50
Merge branch 'main' into develop
elib20 Mar 11, 2023
1abad67
Improve callbacks and adds tensorboard (#219)
zeyueN Mar 11, 2023
1335802
Merge branch 'main' into develop
ziofil Mar 24, 2023
6349d30
Modular fock strategies (#235)
ziofil Apr 13, 2023
c736dc3
More strategies (#239)
ziofil May 31, 2023
ebbdd3c
bugfix, test and changelog entry (#246)
ziofil May 31, 2023
c84ee68
Stable BSgate (#248)
ziofil Jun 20, 2023
7bbddbf
Compact fock correction (#249)
rdprins Jun 23, 2023
73b2af6
Bugfix gradients (#253)
ziofil Jun 27, 2023
1f5762d
Migration to Poetry (#257)
ggulli Jul 18, 2023
fcb9512
Release v050 (#264)
ziofil Jul 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ RUN sh -c "$(wget -nv -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/mast

# upgrade pip and install package manager
RUN python -m pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir poetry==1.4.0
RUN poetry config virtualenvs.create false

### TEAR DOWN IMAGE SETUP ###
# switch back to dialog for any ad-hoc use of apt-get
Expand Down
7 changes: 1 addition & 6 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#! /bin/zsh

pip install --no-cache-dir -r requirements.txt
pip install --no-cache-dir -r requirements-dev.txt
pip install --no-cache-dir -r doc/requirements.txt
pip install ray
pip install pylint
pip install -e .
poetry install --all-extras --with dev,doc
115 changes: 114 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,115 @@
# Release 0.5.0

### New features

* Optimization callback functionalities has been improved. A dedicated `Callback` class is added which
is able to access the optimizer, the cost function, the parameters as well as gradients, during the
optimization. In addition, multiple callbacks can be specified. This opens up the endless possiblities
of customizing the the optimization progress with schedulers, trackers, heuristics, tricks, etc.
[(#219)](https://github.com/XanaduAI/MrMustard/pull/219)

* Tensorboard-based optimization tracking is added as a builtin `Callback` class: `TensorboardCallback`.
It can automatically track costs as well as all trainable parameters during optimization in realtime.
Tensorboard can be most conveniently viewed from VScode.
[(#219)](https://github.com/XanaduAI/MrMustard/pull/219)

```python
import numpy as np
from mrmustard.training import Optimizer, TensorboardCallback

def cost_fn():
...

def as_dB(cost):
delta = np.sqrt(np.log(1 / (abs(cost) ** 2)) / (2 * np.pi))
cost_dB = -10 * np.log10(delta**2)
return cost_dB

tb_cb = TensorboardCallback(cost_converter=as_dB, track_grads=True)

opt = Optimizer(euclidean_lr = 0.001);
opt.minimize(cost_fn, max_steps=200, by_optimizing=[...], callbacks=tb_cb)

# Logs will be stored in `tb_cb.logdir` which defaults to `./tb_logdir/...` but can be customized.
# VScode can be used to open the Tensorboard frontend for live monitoring.
# Or, in command line: `tensorboard --logdir={tb_cb.logdir}` and open link in browser.
```

* Gaussian states support a `bargmann` method for returning the bargmann representation.
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

* The `ket` method of `State` now supports new keyword arguments `max_prob` and `max_photons`.
Use them to speed-up the filling of a ket array up to a certain probability or *total* photon number.
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

```python
from mrmustard.lab import Gaussian

# Fills the ket array up to 99% probability or up to the |0,3>, |1,2>, |2,1>, |3,0> subspace, whichever is reached first.
# The array has the autocutoff shape, unless the cutoffs are specified explicitly.
ket = Gaussian(2).ket(max_prob=0.99, max_photons=3)
```

* Gaussian transformations support a `bargmann` method for returning the bargmann representation.
[(#239)](https://github.com/XanaduAI/MrMustard/pull/239)

* BSGate.U now supports method='vanilla' (default) and 'schwinger' (slower, but stable to any cutoff)
[(#248)](https://github.com/XanaduAI/MrMustard/pull/248)

### Breaking Changes

* The previous `callback` argument to `Optimizer.minimize` is now `callbacks` since we can now pass
multiple callbacks to it.
[(#219)](https://github.com/XanaduAI/MrMustard/pull/219)

* The `opt_history` attribute of `Optimizer` does not have the placeholder at the beginning anymore.
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

### Improvements

* The math module now has a submodule `lattice` for constructing recurrence relation strategies in the Fock lattice.
There are a few predefined strategies in `mrmustard.math.lattice.strategies`.
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

* Gradients in the Fock lattice are now computed using the vector-jacobian product.
This saves a lot of memory and speeds up the optimization process by roughly 4x.
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

* Tests of the compact_fock module now use hypothesis.
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

* Faster implementation of the fock representation of `BSgate`, `Sgate` and `SqueezedVacuum`, ranging from 5x to 50x.
[(#239)](https://github.com/XanaduAI/MrMustard/pull/239)

* More robust implementation of cutoffs for States.
[(#239)](https://github.com/XanaduAI/MrMustard/pull/239)

* Dependencies and versioning are now managed using Poetry.
[(#257)](https://github.com/XanaduAI/MrMustard/pull/257)

### Bug fixes

* Fixed a bug that would make two progress bars appear during an optimization
[(#235)](https://github.com/XanaduAI/MrMustard/pull/235)

* The displacement of the dual of an operation had the wrong sign
[(#239)](https://github.com/XanaduAI/MrMustard/pull/239)

* When projecting a Gaussian state onto a Fock state, the upper limit of the autocutoff now respect the Fock projection.
[(#246)](https://github.com/XanaduAI/MrMustard/pull/246)

* Fixed a bug for the algorithms that allow faster PNR sampling from Gaussian circuits using density matrices. When the
cutoff of the first detector is equal to 1, the resulting density matrix is now correct.

### Documentation

### Contributors
[Filippo Miatto](https://github.com/ziofil), [Zeyue Niu](https://github.com/zeyueN),
[Robbe De Prins](https://github.com/rdprins), [Gabriele Gullì](https://github.com/ggulli),
[Richard A. Wolf](https://github.com/ryk-wolf)

---

# Release 0.4.1

### New features
Expand All @@ -23,8 +135,9 @@
### Contributors
[Filippo Miatto](https://github.com/ziofil), [Sebastian Duque Mesa](https://github.com/sduquemesa)

---

# Release 0.4.0
# Release 0.4.0 (current release)

### New features

Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: builds
name: Build package
on:
push:
branches:
Expand All @@ -12,37 +12,37 @@ jobs:
runs-on: ubuntu-latest
env:
HYPOTHESIS_PROFILE: ci

strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}
cancel-in-progress: true

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Build and install Mr Mustard
run: |
python -m pip install --upgrade pip wheel
python setup.py bdist_wheel
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
poetry config virtualenvs.create false
poetry build
pip install dist/mrmustard*.whl
# Move to 'src' to properly test only installed package
# https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#tests-outside-application-code
mkdir src
mv mrmustard src

- name: Install test dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install wheel pytest pytest-cov pytest-mock hypothesis --upgrade
- name: Install only test dependencies
run: poetry install --no-root --extras "ray" --with dev

- name: Run tests
run: |
python -m pytest tests -p no:warnings --tb=native
run: python -m pytest tests -p no:warnings --tb=native
31 changes: 17 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,38 @@ on:
branches:
- develop
pull_request:
paths:
- '.github/workflows/tests.yml'
- 'mrmustard/**'
- 'tests/**'
- 'pyproject.toml'
- 'poetry.lock'
- 'pytest.ini'

jobs:
pytest:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
HYPOTHESIS_PROFILE: ci

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup python ${{ matrix.python-version }}
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install wheel pytest pytest-cov --upgrade
pip install .[ray]
# python setup.py bdist_wheel
# pip install dist/*.whl
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
poetry config virtualenvs.create false
poetry install --extras "ray" --with dev

- name: Run tests
run: python -m pytest tests --cov=mrmustard --cov-report=term-missing --cov-report=xml -p no:warnings --tb=native
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
HYPOTHESIS_PROFILE: ci

steps:
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -19,21 +20,24 @@ jobs:

- name: Build and install Mr Mustard
run: |
python -m pip install --upgrade pip wheel
python setup.py bdist_wheel
python -m pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir poetry==1.4.0
poetry config virtualenvs.create false
poetry build
pip install dist/mrmustard*.whl
# Move to 'src' to properly test only installed package
# https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#tests-outside-application-code
mkdir src
mv mrmustard src

- name: Install test dependencies
run: |
pip install -r requirements.txt
pip install wheel pytest pytest-cov pytest-mock hypothesis --upgrade
- name: Install only test dependencies
run: poetry install --no-root --extras "ray" --with dev

- name: Run tests
run: |
python -m pytest tests -p no:warnings --tb=native
run: python -m pytest tests -p no:warnings --tb=native

- name: Publish
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PIPY_TOKEN }}
Expand Down
13 changes: 7 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ build:
os: ubuntu-22.04
tools:
python: "3.9"
jobs:
post_install:
- pip install --no-cache-dir poetry==1.4.0
- poetry config virtualenvs.create false
- poetry install --with doc

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -16,9 +21,5 @@ sphinx:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: doc/requirements.txt
- method: pip
path: .
system_packages: true
# python:
# install:
50 changes: 0 additions & 50 deletions Dockerfile

This file was deleted.

Loading