-
Notifications
You must be signed in to change notification settings - Fork 615
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
Legacy operator arithmetic deprecation #6287
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6287 +/- ##
==========================================
- Coverage 99.70% 99.39% -0.32%
==========================================
Files 445 445
Lines 42260 42271 +11
==========================================
- Hits 42137 42016 -121
- Misses 123 255 +132 ☔ View full report in Codecov by Sentry. |
Should we also replace |
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.
There are a lot more than can be simplified around our testing with legacy opmath. Although I'm ok to approve if we're under pressure of time to merge this by today, since we're removing legacy opmath completely in a few months anyway?
tests/devices/default_qubit/test_default_qubit_preprocessing.py
Outdated
Show resolved
Hide resolved
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.
I didn't get through that much of it but here are a few comment for now :)
Looks like running some tests only when legacy op math is active has caused some humps with codecov. Not sure if it should be addressed or not. |
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.
This looks like a painfully large amount of work, thank you for doing this 🚀
To fix the error in:
I guess we can safely remove the |
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
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.
I can only guess how daunting this deprecation was, thanks a lot! I see that there is still a test_use_legacy_opmath_fixture
entry in the test duration files, but I don't think this is an issue
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.
One non-blocking comment, this looks good to me! 🚀
It looks like I just need to add back some of the duplicate tests we had for legacy opmath tests to pass. For some reason, the legacy opmath enable only happens after all the parameters for parametrized tests are created, so we're ending up in a situation where we create LinearCombinations and Prods when Hamiltonians and Tensors are expected. |
Confirmation that all tests pass with |
Proceeding to force merge after discussing with @mudit2812 !! Context: Tests that used to run in CI for legacy opmath have been changed to only run in the Plugin Test Matrix |
**Context:** It's time to fully remove the legacy operator arithmetic (`Tensor` and `qml.ops.Hamiltonian`, and all of the structure surrounding them). **Description of the Change:** - [x] remove `qml.ops.Hamiltonian` - [x] remove `Tensor` - [x] remove `disable_` and `enable_new_opmath` - [x] remove `operation.convert_to_legacy_H` - [x] remove `qml.pauli.simplify` - [x] remove `PauliWord.hamiltonian` and `PauliSentence.hamiltonian`, and any other functionality in the pauli module that supported legacy opmath - [x] remove any if/else handling in place to deal with legacy opmath through the code base - [x] remove `legacy_opmath_only`, `new_opmath_only` and `use_legacy_and_new_opmath` test fixtures, and all irrelevant tests - [x] remove the warning suppressions added in [PR6287](#6287) - [x] remove the legacy test fixture (--disable-opmath) [sc-77523] --------- Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Context:
Legacy op math is being deprecated.
Description of the Change:
qml.ops.Hamiltonian
is deprecated.qml.operation.Tensor
is deprecated.qml.operation.disable_new_opmath
andqml.operation.enable_new_opmath
(as well as the context managers) are deprecated.qml.operation.convert_to_legacy_H
is deprecated.PauliWord.hamiltonian
andPauliSentence.hamiltonian
is deprecated.qml.pauli.simplify
is deprecated.Removed
use_legacy_opmath
anduse_new_opmath
fixtures. Instead, we use eitherlegacy_opmath_only
,new_opmath_only
, or no fixture, as appropriate for the tests.Added warning suppression for all the above deprecation warnings to
pytest.ini
. Additionally, I also added the same warning suppressions toconftest.py
for the case when--disable-opmath=True
, since the warning filters inpytest.ini
only suppress warnings that come from inside tests, not ones that come from outside the tests, such as when deprecated code is used for creating parameters for a test.Benefits:
Possible Drawbacks:
In some instances, there will be a LOT of deprecation warnings at the same time. The most impactful example of this if if using
qml.qchem.molecular_hamiltonian
,qml.qchem.qubit_observable
. These usingsimplify
andPauliSentence.hamiltonian
with legacy op math, so there will be up to 4 warnings at once when using these.Additionally,
qml.qchem.tapering.symmetry_generators
andqml.qchem.tapering.clifford
usePauliSentence.hamiltonian
when legacy op math is enabled, so there will be up to 3 warnings at once when using these.Related GitHub Issues:
I will run the test suite with
disable_new_opmath
set toTrue
once before merging to confirm that legacy op math tests do not fail.[sc-71940] [sc-66727] [sc-66724]