Skip to content

Conversation

ddddddanni
Copy link
Contributor

Previous PR is #7435
This PR allow user to run measuring_pauli_strings in sweep mode. In this mode, the function uses parameterized circuits and sweeps parameters for both Pauli measurements and readout benchmarking

@github-actions github-actions bot added the size: L 250< lines changed <1000 label Aug 12, 2025
@ddddddanni ddddddanni marked this pull request as ready for review August 14, 2025 03:31
@ddddddanni ddddddanni requested review from vtomole and a team as code owners August 14, 2025 03:31
@ddddddanni ddddddanni requested a review from maffoo August 14, 2025 03:31
@eliottrosenberg eliottrosenberg self-requested a review August 14, 2025 16:23
Copy link
Collaborator

@eliottrosenberg eliottrosenberg left a comment

Choose a reason for hiding this comment

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

I tested this on hardware, and it seems to have a bug. For example, compare the last line of the output of this cell to the output of this cell. result and result2 come from the couple of cells above those. Reproduced again futher down in that colab.

Copy link
Collaborator

@eliottrosenberg eliottrosenberg left a comment

Choose a reason for hiding this comment

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

Ok, I found the difference. If you start with the following circuit:

0: ───────────────────────H───@───H───
                              │
1: ───────────────H───@───H───@───────
                      │
2: ───H───────@───H───@───────────────
              │
3: ───H───@───@───────────────────────
          │
4: ───H───@───────H───@───────────────
                      │
5: ───────────────H───@───H───@───────
                              │
6: ───────────────────────H───@───H───

and then measure X(q(0))*X(q(1))*X(q(2))*X(q(3))*X(q(4))*X(q(5))*X(q(6)), the sweep version gives you

0: ───────────────────────H───@───H───PhX(phi0/2 - 1/2)^theta0───M('m')───
                              │                                  │
1: ───────────────H───@───H───@───────PhX(phi1/2 - 1/2)^theta1───M────────
                      │                                          │
2: ───H───────@───H───@───────────────PhX(phi2/2 - 1/2)^theta2───M────────
              │                                                  │
3: ───H───@───@───────────────────────PhX(phi3/2 - 1/2)^theta3───M────────
          │                                                      │
4: ───H───@───────H───@───────────────PhX(phi4/2 - 1/2)^theta4───M────────
                      │                                          │
5: ───────────────H───@───H───@───────PhX(phi5/2 - 1/2)^theta5───M────────
                              │                                  │
6: ───────────────────────H───@───H───PhX(phi6/2 - 1/2)^theta6───M────────

with the basis change all in the same moment, whereas in the batch version, you get

0: ───────────────────────────────H───────────@───H───────────Ry(-0.5π)───M('m')───
                                              │                           │
1: ───────────────H───────────@───H───────────@───Ry(-0.5π)───────────────M────────
                              │                                           │
2: ───H───────@───H───────────@───Ry(-0.5π)───────────────────────────────M────────
              │                                                           │
3: ───H───@───@───Ry(-0.5π)───────────────────────────────────────────────M────────
          │                                                               │
4: ───H───@───────H───────────@───Ry(-0.5π)───────────────────────────────M────────
                              │                                           │
5: ───────────────H───────────@───H───────────@───Ry(-0.5π)───────────────M────────
                                              │                           │
6: ───────────────────────────────H───────────@───H───────────Ry(-0.5π)───M────────

with the basis change done as early as possible. In this case, you get a higher-fidelity result with the basis change done as early as possible because you are insensitive to the dephasing that happens between the final basis change gate and the measurement, but that may not always be the intended behavior. Maybe we could add an insert_strategy argument so that users have the choice of whether to do the basis change all in the same penultimate moment or as early as possible.

@eliottrosenberg
Copy link
Collaborator

Thanks, @ddddddanni! It looks like it is printing out the circuits for debugging, and you might want to remove that.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added size: XL lines changed >1000 and removed size: L 250< lines changed <1000 labels Aug 25, 2025
@github-actions github-actions bot added size: L 250< lines changed <1000 and removed size: XL lines changed >1000 labels Aug 25, 2025
@ddddddanni
Copy link
Contributor Author

Thanks, @ddddddanni! It looks like it is printing out the circuits for debugging, and you might want to remove that.

Done!

@github-actions github-actions bot added size: M 50< lines changed <250 size: XL lines changed >1000 and removed size: L 250< lines changed <1000 size: M 50< lines changed <250 labels Sep 1, 2025
@github-actions github-actions bot added size: L 250< lines changed <1000 and removed size: XL lines changed >1000 labels Sep 1, 2025
Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.50%. Comparing base (d0e2bc5) to head (cffc694).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7569   +/-   ##
=======================================
  Coverage   97.50%   97.50%           
=======================================
  Files        1103     1103           
  Lines       99707    99789   +82     
=======================================
+ Hits        97222    97302   +80     
- Misses       2485     2487    +2     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants