Skip to content

Don't test forward compatibility in qpy compat tests #11101

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

Merged
merged 6 commits into from
Oct 30, 2023

Conversation

mtreinish
Copy link
Member

Summary

The qpy compatibility tests are designed to test backwards compatibility. They generate QPY files using all historical releases of Qiskit with QPY support and test that all proposed changes are able to load the qpy files. There was an underlying assumption to how the tests were written that the version under test is always newer than all the historical releases. This has been true in the past because the release model for qiskit mean that we were maintaining at most one stable release at a time, and when we released a new minor version of qiskit we retired the previous minor version release series's branch. However, moving forward this assumption will no longer be true as we're moving to a model where we support > 1 branch at a time. When we start supporting > 1 release series at a time, PRs proposed to the older stable branches will no longer be able to test all releases because QPY only support backwards compatibility and will not be able to load QPY files generated from newer releases. The example of this was in the 0.25.x series, there is overlap in the support of the stable/0.25 branch and the stable/0.45 branch, and after the release of 0.45.0rc1 the tests started to fail because you can't load QPY files generated with 0.45.0rc1 with 0.25.x.

This commit address this by adding a condition to the QPY compat scripts to ensure that the version under test is >= the QPY file source version. If we encounter that scenario we just skip the tests. This should prevent this situation from occurring for future releases as we expand our support windows.

Details and comments

The qpy compatibility tests are designed to test backwards
compatibility. They generate QPY files using all historical releases
of Qiskit with QPY support and test that all proposed changes are
able to load the qpy files. There was an underlying assumption to how
the tests were written that the version under test is always newer
than all the historical releases. This has been true in the past because
the release model for qiskit mean that we were maintaining at most one
stable release at a time, and when we released a new minor version of
qiskit we retired the previous minor version release series's branch.
However, moving forward this assumption will no longer be true as we're
moving to a model where we support > 1 branch at a time. When we start
supporting > 1 release series at a time, PRs proposed to the older
stable branches will no longer be able to test all releases because QPY
only support backwards compatibility and will not be able to load QPY
files generated from newer releases. The example of this was in the
0.25.x series, there is overlap in the support of the stable/0.25 branch
and the stable/0.45 branch, and after the release of 0.45.0rc1 the tests
started to fail because you can't load QPY files generated with
0.45.0rc1 with 0.25.x.

This commit address this by adding a condition to the QPY compat scripts
to ensure that the version under test is >= the QPY file source version.
If we encounter that scenario we just skip the tests. This should
prevent this situation from occurring for future releases as we expand
our support windows.
@mtreinish mtreinish added type: qa Issues and PRs that relate to testing and code quality stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: None Do not include in changelog labels Oct 24, 2023
@mtreinish mtreinish added this to the 0.45.0 milestone Oct 24, 2023
@mtreinish mtreinish requested a review from a team as a code owner October 24, 2023 19:22
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core
  • @mtreinish
  • @nkanazawa1989

@coveralls
Copy link

coveralls commented Oct 24, 2023

Pull Request Test Coverage Report for Build 6696660231

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 18 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.01%) to 86.913%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.76%
crates/qasm2/src/lex.rs 5 91.41%
crates/qasm2/src/parse.rs 12 97.13%
Totals Coverage Status
Change from base Build 6694310616: -0.01%
Covered Lines: 73982
Relevant Lines: 85122

💛 - Coveralls

This commit adds a small python script to compare two version strings
and determine whether the version under test is newer (or the same) as
the source version. The logic for making this determination was a bit
more involved in bash, so using a python script lets us reuse the regex
built into qpy's interface to support this comparison already.
mtreinish and others added 2 commits October 30, 2023 13:28
This commit fixes the return code generation if an invalid comparison is
requested. We want to handle this with a 0 return code to treat it as a
skip, but the previous logic would error before we evaluated the if
statement.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

This seems right to me now. I suppose it's technically possible that if we ever cause the bash script to feed the wrong inputs to the Python script we'll start skipping every version of QPY (unhandled exception has nonzero return code), but that'll at least show something in the logs.

@jakelishman jakelishman enabled auto-merge October 30, 2023 17:50
@jakelishman jakelishman added this pull request to the merge queue Oct 30, 2023
Merged via the queue into Qiskit:main with commit 2b5503c Oct 30, 2023
mergify bot pushed a commit that referenced this pull request Oct 30, 2023
* Don't test forward compatibility in qpy compat tests

The qpy compatibility tests are designed to test backwards
compatibility. They generate QPY files using all historical releases
of Qiskit with QPY support and test that all proposed changes are
able to load the qpy files. There was an underlying assumption to how
the tests were written that the version under test is always newer
than all the historical releases. This has been true in the past because
the release model for qiskit mean that we were maintaining at most one
stable release at a time, and when we released a new minor version of
qiskit we retired the previous minor version release series's branch.
However, moving forward this assumption will no longer be true as we're
moving to a model where we support > 1 branch at a time. When we start
supporting > 1 release series at a time, PRs proposed to the older
stable branches will no longer be able to test all releases because QPY
only support backwards compatibility and will not be able to load QPY
files generated from newer releases. The example of this was in the
0.25.x series, there is overlap in the support of the stable/0.25 branch
and the stable/0.45 branch, and after the release of 0.45.0rc1 the tests
started to fail because you can't load QPY files generated with
0.45.0rc1 with 0.25.x.

This commit address this by adding a condition to the QPY compat scripts
to ensure that the version under test is >= the QPY file source version.
If we encounter that scenario we just skip the tests. This should
prevent this situation from occurring for future releases as we expand
our support windows.

* Fix syntax errors

* Use a Python script to compare versions

This commit adds a small python script to compare two version strings
and determine whether the version under test is newer (or the same) as
the source version. The logic for making this determination was a bit
more involved in bash, so using a python script lets us reuse the regex
built into qpy's interface to support this comparison already.

* Fix lint

* Fix return code with invalid version

This commit fixes the return code generation if an invalid comparison is
requested. We want to handle this with a 0 return code to treat it as a
skip, but the previous logic would error before we evaluated the if
statement.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
(cherry picked from commit 2b5503c)
github-merge-queue bot pushed a commit that referenced this pull request Oct 30, 2023
* Don't test forward compatibility in qpy compat tests

The qpy compatibility tests are designed to test backwards
compatibility. They generate QPY files using all historical releases
of Qiskit with QPY support and test that all proposed changes are
able to load the qpy files. There was an underlying assumption to how
the tests were written that the version under test is always newer
than all the historical releases. This has been true in the past because
the release model for qiskit mean that we were maintaining at most one
stable release at a time, and when we released a new minor version of
qiskit we retired the previous minor version release series's branch.
However, moving forward this assumption will no longer be true as we're
moving to a model where we support > 1 branch at a time. When we start
supporting > 1 release series at a time, PRs proposed to the older
stable branches will no longer be able to test all releases because QPY
only support backwards compatibility and will not be able to load QPY
files generated from newer releases. The example of this was in the
0.25.x series, there is overlap in the support of the stable/0.25 branch
and the stable/0.45 branch, and after the release of 0.45.0rc1 the tests
started to fail because you can't load QPY files generated with
0.45.0rc1 with 0.25.x.

This commit address this by adding a condition to the QPY compat scripts
to ensure that the version under test is >= the QPY file source version.
If we encounter that scenario we just skip the tests. This should
prevent this situation from occurring for future releases as we expand
our support windows.

* Fix syntax errors

* Use a Python script to compare versions

This commit adds a small python script to compare two version strings
and determine whether the version under test is newer (or the same) as
the source version. The logic for making this determination was a bit
more involved in bash, so using a python script lets us reuse the regex
built into qpy's interface to support this comparison already.

* Fix lint

* Fix return code with invalid version

This commit fixes the return code generation if an invalid comparison is
requested. We want to handle this with a 0 return code to treat it as a
skip, but the previous logic would error before we evaluated the if
statement.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
(cherry picked from commit 2b5503c)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@mtreinish mtreinish deleted the fix-qpy-backwards-compat branch November 1, 2023 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog stable backport potential The bug might be minimal and/or import enough to be port to stable type: qa Issues and PRs that relate to testing and code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants