Skip to content

Fixed Qdrift test #7621

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 12 commits into from
Jun 9, 2025
Merged

Fixed Qdrift test #7621

merged 12 commits into from
Jun 9, 2025

Conversation

Jaybsoni
Copy link
Contributor

@Jaybsoni Jaybsoni commented Jun 5, 2025

Context:
Integration tests for the Qdrift template were failing. These tests were comparing the state produced after applying QDrift with the state produced after applying its decomposition.

The source of the discrepancy was a bug in the tests themselves. Specifically, the expected state was produced by multiplying the gates in the expected decomposition of QDrift in the opposite order. The order should be reversed from that of the decomposition.

This should have caused all of the tests to fail initially, however the hamiltonians used while testing Qdrift had accidentally been chosen such that most of their terms commuted with each other. Due to this, the order of the decomposition didn't matter except for the few edge cases.

Description of the Change:

  • Updated the test hamiltonians so that they don't all commute.
  • Reversed the order of the expected_decomp list

Copy link
Contributor

github-actions bot commented Jun 5, 2025

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@Jaybsoni
Copy link
Contributor Author

Jaybsoni commented Jun 5, 2025

[sc-91298]

@Jaybsoni
Copy link
Contributor Author

Jaybsoni commented Jun 5, 2025

Since the bug was in the test itself, I think we don't need a changelog entry for this correct?

Copy link

codecov bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.68%. Comparing base (05b469d) to head (d3e8ce5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7621   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files         530      530           
  Lines       52140    52140           
=======================================
  Hits        51977    51977           
  Misses        163      163           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@JerryChen97 JerryChen97 left a comment

Choose a reason for hiding this comment

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

Thank you so much for fixing this! @Jaybsoni
On the changelog, I guess we can put a note in the internal part. Usually if it's a very minor fix to test suite or something like typo correction we don't put into changelog atl, but for things like fixing known issues within test suites we still leave a note there.
Also, mind creating a new test to specifically test it with a Hamiltonian that from the very beginning won't allow similar coincidental order reversal atl?

@Jaybsoni
Copy link
Contributor Author

Jaybsoni commented Jun 6, 2025

@JerryChen97

Also, mind creating a new test to specifically test it with a Hamiltonian that from the very beginning won't allow similar coincidental order reversal atl?

I changed the hamiltonian on line 35 such that its terms no longer commute. Furthermore, the hamiltonian on line 31 also has terms which don't commute. I think this should be sufficient. If we want, we can increase the number of samples (n), this would increase the likelihood of sampling terms which don't commute and would have cause the test to fail sooner. However I don't think it's required anymore.

@Jaybsoni Jaybsoni requested a review from JerryChen97 June 6, 2025 18:49
Copy link
Contributor

@JerryChen97 JerryChen97 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@SimoneGasperini SimoneGasperini left a comment

Choose a reason for hiding this comment

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

LGTM!

I don't have anything else to say. I was about to suggest just adding a comment, making sure to use non-commuting terms in the test Hamiltonian, but I see that it is already there.

Thank you!

@JerryChen97 JerryChen97 enabled auto-merge June 9, 2025 18:08
@JerryChen97 JerryChen97 added this pull request to the merge queue Jun 9, 2025
Merged via the queue into master with commit cc83784 Jun 9, 2025
53 checks passed
@JerryChen97 JerryChen97 deleted the fix_qdrift_test branch June 9, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants