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

Fix bug in QPY symengine payload version handling #13259

Merged

Conversation

mtreinish
Copy link
Member

Summary

This commit fixes a bug that slipped into the sole fix that made up the now yanked 1.2.3 release, #13251. The fix logic had a typo/mistake when evaluating the major version in the symengine payload that meant if you were trying to load a QPY payload generated with a different symengine release it would always error. This only got through CI because there was no test coverage of the edge case we were trying to fix. This commit addresses both issues. It first fixes the typo in the QPY parsing (which is a 2 character change) and then updates the QPY compat tests to explicitly test using multiple symengine versions with QPY to make sure we're exercising this code path moving forward (and validating this fix).

Details and comments

This commit fixes a bug that slipped into the sole fix that made up
the now yanked 1.2.3 release, Qiskit#13251. The fix logic had a typo/mistake
when evaluating the major version in the symengine payload that meant
if you were trying to load a QPY payload generated with a different
symengine release it would always error. This only got through CI because
there was no test coverage of the edge case we were trying to fix. This
commit addresses both issues. It first fixes the typo in the QPY parsing
(which is a 2 character change) and then updates the QPY compat tests to
explicitly test using multiple symengine versions with QPY to make sure
we're exercising this code path moving forward (and validating this
fix).
@mtreinish mtreinish added priority: high stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qpy Related to QPY serialization labels Oct 2, 2024
@mtreinish mtreinish added this to the 1.2.3 milestone Oct 2, 2024
@mtreinish mtreinish requested a review from a team as a code owner October 2, 2024 20:11
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

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

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11150886319

Details

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 26 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.03%) to 88.843%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/qpy/common.py 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 2 92.23%
crates/qasm2/src/parse.rs 24 95.77%
Totals Coverage Status
Change from base Build 11144723003: -0.03%
Covered Lines: 74134
Relevant Lines: 83444

💛 - Coveralls

Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

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

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.

I verified this PR locally by generating the QPY backwards-compat test suite with both symengine 0.11 and symengine 0.13, and I was able to use this PR to load both sets, with both symengine 0.11 and 0.13 (so I tried all four combinations of generator and loader). Further, I was able to reproduce the loading failures (using the same files) with the parent of this commit.

I did these tests locally twice on #13251, but crucially failed to repeat them locally for the changes made after the second review (as did Matt), because we were rushing too much. That's how it wasn't caught by humans. The bigger failure is that we didn't think through a good way to add it to CI to automate the process - we thought we'd need a whole other CI job, and were in a rush to get out the release so thought we'd do it later.

I agree with Kevin that the CI runs show that this executed as expected. I also checked the CI logs to verify that symengine 0.13.0 was installed in qiskit_venv, and symengine 0.11.0 was installed in symengine_11_venv.

Comment on lines +29 to +30
# symengine is pinned to 0.13 to explicitly test the migration path reusing the venv
"$qiskit_venv/bin/pip" install -c "$our_dir/../../constraints.txt" "$our_dir/../.." packaging "symengine~=0.13"
Copy link
Member

Choose a reason for hiding this comment

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

This isn't actually a pin on symengine 0.13 - it's equivalent to symengine>=0.13,==0.*, so it'd allow 0.14, but I think that's intended, given the comment lower in the file about needing an update when symengine 0.14 is released?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I actually meant to remove this. I just checked it's in my local diff but I didn't add that to the commit. I started down the path of thinking about pinning here, but figured it'd be better to handle it explicitly at that future date than protect against it in the test setup preemptively. Especially since we have the cap in the requirements file. I can remove this if you'd prefer.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's ok as written - it's good to be explicit that it's specifically something newer than the 0.11 series, which this pin does.

It's just the comment that's a bit misleading, but I strongly suspect we're going to need to re-do this file a little bit as part of making the cache keys for the QPY jobs more reliable - things like generation script requirements will need to be separated off to become part of the cache key - and we'll be able to expand the inter-symengine-version testing once that's fixed as well, because the jobs will run faster.

@jakelishman
Copy link
Member

Oh, also for posterity: I verified that the only differences between the files parameterized.qpy generated with symengine==0.11.0 and symengine==0.13.0 are the minor version bytes changing from 0x0b to 0x0d for each symengine expression, and the UUIDs of the parameters changing. When I set the UUIDs of the two generated Parameter instances to known, fixed values, the only differences between the two files were the minor-version bytes.

@jakelishman jakelishman added this pull request to the merge queue Oct 2, 2024
Merged via the queue into Qiskit:main with commit e5ec413 Oct 2, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Oct 2, 2024
This commit fixes a bug that slipped into the sole fix that made up
the now yanked 1.2.3 release, #13251. The fix logic had a typo/mistake
when evaluating the major version in the symengine payload that meant
if you were trying to load a QPY payload generated with a different
symengine release it would always error. This only got through CI because
there was no test coverage of the edge case we were trying to fix. This
commit addresses both issues. It first fixes the typo in the QPY parsing
(which is a 2 character change) and then updates the QPY compat tests to
explicitly test using multiple symengine versions with QPY to make sure
we're exercising this code path moving forward (and validating this
fix).

(cherry picked from commit e5ec413)

# Conflicts:
#	qiskit/qpy/__init__.py
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Oct 3, 2024
This commit fixes a bug that slipped into the sole fix that made up
the now yanked 1.2.3 release, Qiskit#13251. The fix logic had a typo/mistake
when evaluating the major version in the symengine payload that meant
if you were trying to load a QPY payload generated with a different
symengine release it would always error. This only got through CI because
there was no test coverage of the edge case we were trying to fix. This
commit addresses both issues. It first fixes the typo in the QPY parsing
(which is a 2 character change) and then updates the QPY compat tests to
explicitly test using multiple symengine versions with QPY to make sure
we're exercising this code path moving forward (and validating this
fix).
@mtreinish mtreinish deleted the really-fix-qpy-symengine-version-mismatch branch October 3, 2024 11:18
github-merge-queue bot pushed a commit that referenced this pull request Oct 3, 2024
…13260)

* Fix bug in QPY symengine payload version handling (#13259)

This commit fixes a bug that slipped into the sole fix that made up
the now yanked 1.2.3 release, #13251. The fix logic had a typo/mistake
when evaluating the major version in the symengine payload that meant
if you were trying to load a QPY payload generated with a different
symengine release it would always error. This only got through CI because
there was no test coverage of the edge case we were trying to fix. This
commit addresses both issues. It first fixes the typo in the QPY parsing
(which is a 2 character change) and then updates the QPY compat tests to
explicitly test using multiple symengine versions with QPY to make sure
we're exercising this code path moving forward (and validating this
fix).

(cherry picked from commit e5ec413)

# Conflicts:
#	qiskit/qpy/__init__.py

* Fix merge artifact

---------

Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: Julien Gacon <[email protected]>
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Oct 7, 2024
This commit fixes a bug that slipped into the sole fix that made up
the now yanked 1.2.3 release, Qiskit#13251. The fix logic had a typo/mistake
when evaluating the major version in the symengine payload that meant
if you were trying to load a QPY payload generated with a different
symengine release it would always error. This only got through CI because
there was no test coverage of the edge case we were trying to fix. This
commit addresses both issues. It first fixes the typo in the QPY parsing
(which is a 2 character change) and then updates the QPY compat tests to
explicitly test using multiple symengine versions with QPY to make sure
we're exercising this code path moving forward (and validating this
fix).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qpy Related to QPY serialization priority: high 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.

5 participants