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

adding rotated randomized benchmarking circuits to calibrator #2248

Merged
merged 6 commits into from
Mar 29, 2024

Conversation

FarLab
Copy link
Contributor

@FarLab FarLab commented Mar 27, 2024

Description

This PR will add rotated randomized benchmarking circuits to the calibrator settings as was requested in #2065.


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

@FarLab FarLab requested a review from natestemen March 27, 2024 19:37
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.28%. Comparing base (b9036cf) to head (4725b8a).
Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2248   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files          90       90           
  Lines        4257     4264    +7     
=======================================
+ Hits         4184     4191    +7     
  Misses         73       73           

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

@natestemen
Copy link
Member

After checking out this branch I was able to do the following.

$ make format
ruff check --fix
mitiq/calibration/settings.py:344:80: E501 Line too long (80 > 79)
mitiq/calibration/settings.py:345:80: E501 Line too long (98 > 79)
mitiq/calibration/settings.py:348:80: E501 Line too long (90 > 79)
Found 5 errors (2 fixed, 3 remaining).

The errors on lines 344, 345, and 348 of mitiq/calibration/settings.py will need to be corrected by hand. If this doesn't work for you let me know and I can push the fix!

output of git diff after running make format
diff --git a/mitiq/calibration/settings.py b/mitiq/calibration/settings.py
index 4616fe5d..3c592690 100644
--- a/mitiq/calibration/settings.py
+++ b/mitiq/calibration/settings.py
@@ -18,8 +18,8 @@ from mitiq.benchmarks import (
     generate_mirror_circuit,
     generate_quantum_volume_circuit,
     generate_rb_circuits,
+    generate_rotated_rb_circuits,
     generate_w_circuit,
-    generate_rotated_rb_circuits
 )
 from mitiq.interface import convert_from_mitiq
 from mitiq.pec import execute_with_pec
diff --git a/mitiq/calibration/tests/test_settings.py b/mitiq/calibration/tests/test_settings.py
index fe37751f..f1c4f0c1 100644
--- a/mitiq/calibration/tests/test_settings.py
+++ b/mitiq/calibration/tests/test_settings.py
@@ -5,8 +5,8 @@
 import json

import cirq
-import pytest
import numpy as np
+import pytest
import qiskit

from mitiq import QPROGRAM, SUPPORTED_PROGRAM_TYPES

@FarLab
Copy link
Contributor Author

FarLab commented Mar 28, 2024

Thanks for checking Nate, I'll try correct the errors on lines 344, 345, and 348 of mitiq/calibration/settings.py.

@FarLab FarLab linked an issue Mar 28, 2024 that may be closed by this pull request
"num_qubits": 2,
"circuit_depth": 1,
"circuit_type": "rotated_rb",
"num_qubits": 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

In the code, you are branching off logic based on the number of qubits. You want at least one test for each of the two logical branches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right!

0
]
ideal = {
"0": (2 / 3) * np.sin(theta / 2) ** 2,
Copy link
Contributor

@cosenal cosenal Mar 28, 2024

Choose a reason for hiding this comment

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

Why not using a variable, say p, for this expression and then 1 - p as expression for "1".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, that is cleaner

@FarLab FarLab requested a review from cosenal March 29, 2024 09:12
Copy link
Contributor

@cosenal cosenal left a comment

Choose a reason for hiding this comment

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

LGTM

Note: I haven't checked the math from the issue discussion, so I would feel more comfortable with a second review from somebody who has.

@FarLab FarLab merged commit b5c7dc1 into master Mar 29, 2024
18 checks passed
@FarLab FarLab deleted the fl-rotated_rb_ideal branch March 29, 2024 14:06
cosenal pushed a commit that referenced this pull request Jun 26, 2024
* added rotated rb circuits in calibrator

* added tests for rotated rb circuits in calibration

* missing numpy import

* fixed formatting issue

* fix format issue

* added a new variable p for probality of measuring 0 and an extra test for rotated rb circuits
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.

Add rotated RB circuits to calibrator
3 participants