-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adding __matmul__
to CircuitComponent
s
#347
Conversation
**Description of the Change:** Using python built-in logger, this PR silences the annoying `ComplexWarning`s coming from `tf.cast`. Additionally, it gets rid of tensorflow's import messages. --------- Co-authored-by: Filippo Miatto <ziofil@users.noreply.github.com>
**Context:** In the latest MrM release, `scipy` was unpinned. Syncing the `develop` branch with this latest release causes pytest errors due to improper type handling on `scipy`'s side. **Description of the Change:** - Syncing `develop` with latest `main` - Fixing scipy error by adding a `dtype` parameter to `math.sqrtm` so that it never returns arrays of an unsupported type (specifically, `complex256`) - Updating dependencies - Modifying the CHANGELOG in preparation for release --------- Co-authored-by: zy <48225584+zeyueN@users.noreply.github.com>
**Context:** The previous solution based on `logging` does not appear to work on every OS
**Context:** ``` from mrmustard.lab import * Vacuum(1) ``` Executing the code above triggers a long list of annoying warnings, displayed between the recap of the state and the phase-space plot. **Description of the Change:** This PR removes the cause of the warnings, without changing the way that the plot looks
**Context:** ``` probs = np.array([1e-6 for _ in range(300)]) results = [math.Categorical(probs, "") for _ in range(100)] assert len(set(results)) > 1 ``` When using the numpy backend, the code above fails: `results` contains 100 identical values. This is because `math.Categorical` uses `np.random.multinomial`, which assumes that the probabilities sum up to `1` (if not, the last probability is increased such that the resulting probabilities sum up to `1`)
**Context:** Add a new file triples.py in the physics module to include all triples in Bargmann representations of the states and transformations. This PR will set up the basic physics for Bargmann objects. **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: SamFerracin <samuele.ferracin@xanadu.ai> Co-authored-by: SamFerracin <samuele.ferracin@gmail.com>
**Context:** Bug fix of the triples for attenuator **Description of the Change:** c=1.0 for attenuator **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:**
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## prototype-tn #347 +/- ##
===============================================
Coverage ? 85.03%
===============================================
Files ? 74
Lines ? 5440
Branches ? 0
===============================================
Hits ? 4626
Misses ? 814
Partials ? 0
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR!
I've checked the logic in side matmul which works for me!
Just leave an open question to discuss: if we do this matmul in simulator and with Fock in each step, would the idea to have the tensor network doesn't exist anymore?
…epresentation docs to make them consistent (#341) **Context:** Fock and ArrayAnsatz, docs and tests --------- Co-authored-by: Filippo Miatto <miatto@gmail.com> Co-authored-by: Filippo Miatto <ziofil@users.noreply.github.com> Co-authored-by: Yuan <16817699+sylviemonet@users.noreply.github.com> Co-authored-by: Sebastián Duque Mesa <675763+sduquemesa@users.noreply.github.com> Co-authored-by: zy <48225584+zeyueN@users.noreply.github.com>
@sylviemonet the tensor network idea still exists, but it is orthogonal to the matmul/rshift. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me now!
**Context:** There are three bugs fixed in this PR. 1. the projection onto the Vacuum state will use the generaldyne where the projection function is not correct. For example, `from mrmustard.lab import *;Vacuum(3) << Vacuum(3)` The projection in the example above is not 1.0, which should be 1.0. This has been fixed by changing the functions inside generaldyne. 3. add more text to explain about complex_gaussian_integral and other function in bargmann.py. 4. fix the problems that the state will be reassigned during the running of the circuit. For example, `from mrmustard.lab import *; vac0 = Vacuum(1); d1 = Dgate(0.1, 0.1); vac0 >> d1; vac0.bargmann()` the state `vac0` state will be modified after going through the first Dgate, which is not the behaviour we want. **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: Filippo Miatto <ziofil@users.noreply.github.com> Co-authored-by: SamFerracin <samuele.ferracin@xanadu.ai>
…tests (#348) **Context:** Because of the tests were `np.allclose(b, 0)`, we haven't tested the length of the b vector just the values. Hence we have mistakes in the length of b Vector of rotation gate, thermal state and attenuator/amplifier channels. In this PR, we fix the b vectors of them and fix the tests with respect to the shape of the vector it should be. We also fix the type hint for the functions. **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: SamFerracin <samuele.ferracin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Context:
Adds matmul to circuit components.
Also changes/adds a bunch of stuff that is needed for it, such as:
Wires.__rshift__
intoWires.__matmul__
, so that all rshift (matmul) in lab_dev mean the same thing, i.e. that they do (do not) add missing adjointsTests:
For the tests, it applies
@
to sequences of states and gates, and compares the representation of the resulting component to those that one gets by implementing the same sequence withmrmustard.lab
. Small differences found, which can be discussed offline