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

Add slow_test as it's no longer part of Qiskit 1.0 #141

Merged
merged 5 commits into from
Feb 6, 2024

Conversation

woodsp-ibm
Copy link
Member

@woodsp-ibm woodsp-ibm commented Feb 1, 2024

Summary

slow_test used to be part of qiskit.test but the whole test folder was removed for Qiskit 1.0. This adds a copy of that slow_test decorator locally.

Additionally this updates other units testing for failures that started since this was created - see comments below for more detail.

Details and comments

The Monitor jobs, that run against Qiskit main branch, started failing last night after the removal.

@woodsp-ibm woodsp-ibm added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Feb 1, 2024
@coveralls
Copy link

coveralls commented Feb 1, 2024

Pull Request Test Coverage Report for Build 7788009998

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 90.625%

Files with Coverage Reduction New Missed Lines %
qiskit_algorithms/gradients/reverse/reverse_gradient.py 3 94.74%
Totals Coverage Status
Change from base Build 7785719773: -0.04%
Covered Lines: 6486
Relevant Lines: 7157

💛 - Coveralls

@woodsp-ibm
Copy link
Member Author

Since I did this it seems there is a new failure in the 1.0 Monitor dues to the change in signature of inverse method. This adds the additional parameter so lint is ok with it in 1.0, the extra parameter is ok with lint in earlier versions e.g 0.46. Rather than create a separate PR as this was to fix the 1.0 monitoring jobs, and it just again test logic change, I included it here.

@woodsp-ibm
Copy link
Member Author

Hmm., now its running tests, which it did not get that far on nightly CI, it seems there are a whole bunch of failures that did not happen a couple of days ago when I first pushed this PR.

@woodsp-ibm
Copy link
Member Author

woodsp-ibm commented Feb 3, 2024

Seems the failures are due Estimator now only supporting SparsePauliOp in 1.0. So where tests had a SparsePauliOp and then done to_matrix() on this to create a matrix op, and tested with both, I dropped the conversion and test using that.

In one place a different operator was created to check re-use, I converted that to a SparsePauliOp.

Typehints on the algorithms for the operators supported ideally need updating since its no longer BaseOperator as per what the Estimator supported. Maybe this can be revisited along with #136.

Copy link
Contributor

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

Just a small comment about a comment in inverse :)

The rest, LGTM

@@ -48,7 +48,7 @@ class WhatAmI(Gate):
def __init__(self, angle):
super().__init__(name="whatami", num_qubits=2, params=[angle])

def inverse(self):
def inverse(self, annotated: bool = False):
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably deserves a comment that can be removed once Qiskit 0.46 reaches eol.

Copy link
Collaborator

Choose a reason for hiding this comment

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

After a quick look at Qiskit/qiskit#11593 it looks like that argument is intended to live in 1.0+, so the comment wouldn't be necessary, right?

Copy link
Member Author

@woodsp-ibm woodsp-ibm Feb 5, 2024

Choose a reason for hiding this comment

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

That argument is new in 1.0 - and while adding it now is compatible with 0.46 as it was without causes lint to fail as you can see in the CI jobs which have recently been merged where the monitor jobs, on 1.0, failed (they are not required to pass to merge). Ie the extra param needs to stay there - it just happens to be backwards compatible with 0.46 doing it this way - as you can see it all passes - the main CI which is done using 0.46 presently and the monitor jobs using Qsikit main.

************* Module test.time_evolvers.test_pvqd
test/time_evolvers/test_pvqd.py:51:4: W0221: Number of parameters was 2 in 'Instruction.inverse' and is now 1 in overriding 'WhatAmI.inverse' method (arguments-differ)

And this is just a test case, not main code

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, then I think that the comment is not necessary here.

Copy link
Collaborator

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

This looks good to me, maybe we can update the type hints in a quick follow-up PR instead of with #136.

@woodsp-ibm
Copy link
Member Author

woodsp-ibm commented Feb 5, 2024

This looks good to me, maybe we can update the type hints in a quick follow-up PR

I don't know whats the right thing here. If you use 0.46 then the hints are correct as the primitives support a wider set. If you use the new 1.0 then its really only then its just SparsePauliOp. Since most people arguably just use SparsePauliOp - the apps all do - maybe it does not matter too much. If you had code that used one of the other operators it would still work with 0.46 albeit that it raises a deprecation warning rather than fail as it does if you use 1.0. If we changed to SparsePauliOp only then maybe mypy would complain on your code with the other operators.

Copy link
Collaborator

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Ok, let's go ahead with this PR and I think we can leave the BaseOperator typehint for compatibility with 0.46, I agree that it's not too harmful.

@ElePT ElePT merged commit 2245288 into qiskit-community:main Feb 6, 2024
18 checks passed
mergify bot pushed a commit that referenced this pull request Feb 6, 2024
(cherry picked from commit 2245288)

# Conflicts:
#	test/optimizers/test_optimizer_aqgd.py
ElePT added a commit that referenced this pull request Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants