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

Feature/base qcvv framework #992

Merged
merged 31 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0de866f
Feature: add base qcvv framework
cdbf1 Jul 16, 2024
0aa0d41
nit: add blank line
cdbf1 Jul 16, 2024
41bcc9b
Move qcvv to Supermarq
cdbf1 Jul 19, 2024
17b585b
Fix imports and tests
cdbf1 Jul 19, 2024
6dbdfa2
Revised results processing
cdbf1 Jul 19, 2024
a8ba683
Fix tests
cdbf1 Jul 19, 2024
246c58d
Remove qcvv from cirq docs
cdbf1 Jul 19, 2024
3eac549
Patch css Service in tests
cdbf1 Jul 19, 2024
9d8e844
Fix import css
cdbf1 Jul 19, 2024
26af253
fix: fix tests and notebook
cdbf1 Jul 22, 2024
d107276
fix: add seaborn to requirements
cdbf1 Jul 22, 2024
5859d69
fix: add future annotations to notebook
cdbf1 Jul 22, 2024
215b806
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Jul 23, 2024
48aa81d
Fixes following review
cdbf1 Jul 31, 2024
cc881ad
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Jul 31, 2024
f58dcd0
minor fix to tests and docs
cdbf1 Jul 31, 2024
3cde95e
Reduce circuit count in example
cdbf1 Jul 31, 2024
f361b14
Further fixes from code review
cdbf1 Aug 1, 2024
16cf125
Remove kw_only data classes as it doesn't work with python 3.8
cdbf1 Aug 1, 2024
2a0092c
Fix: add functionality for multiple subjobs
cdbf1 Aug 2, 2024
f3ea316
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Aug 2, 2024
43c7879
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Aug 5, 2024
39c415b
Minor updates to naming
cdbf1 Aug 5, 2024
aa30d6b
Fix: add generic results type for subclassing
cdbf1 Aug 5, 2024
88327b0
Fix: fixes from RR review
cdbf1 Aug 6, 2024
41f41f6
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Aug 6, 2024
5c49765
Add functionality for compilation only and running via a callable
cdbf1 Aug 12, 2024
1932534
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Aug 12, 2024
574095e
Further updates
cdbf1 Aug 13, 2024
6a2acf0
Final fix
cdbf1 Aug 13, 2024
28858d6
Merge branch 'main' into feature/base_qcvv_framework
cdbf1 Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cirq-superstaq/cirq_superstaq/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,20 @@ def __repr__(self) -> str:
def _value_equality_values_(self) -> tuple[str, dict[str, Any]]:
return self._job_id, self._job

def __getitem__(self, idx: int) -> css.Job:
cdbf1 marked this conversation as resolved.
Show resolved Hide resolved
cdbf1 marked this conversation as resolved.
Show resolved Hide resolved
"""Args:
idx: The index of the sub-job to return. Each sub-job corresponds to the a single
circuit.

Returns:
A sub-job at the given index.
"""
job_id = self._job_id.split(",")[idx]
sub_job = css.Job(self._client, job_id)
if job_id in self._job:
sub_job._job[job_id] = self._job[job_id]
return sub_job


def _get_marginal_counts(counts: dict[str, int], indices: Sequence[int]) -> dict[str, int]:
"""Compute a marginal distribution, accumulating total counts on specific bits (by index).
Expand Down
27 changes: 27 additions & 0 deletions cirq-superstaq/cirq_superstaq/job_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ def new_job() -> css.Job:
return css.Job(client, "new_job_id")


@pytest.fixture
def multi_circuit_job() -> css.Job:
"""Fixture for a job with multiple circuits submitted

Returns:
A job with multiple subjobs
"""
client = gss.superstaq_client._SuperstaqClient(
client_name="cirq-superstaq",
remote_host="http://example.com",
api_key="to_my_heart",
)
job = css.Job(client, "job_id1,job_id2,job_id3")
job._job = {
"job_id1": css.Job(client, "job_id1"),
"job_id2": css.Job(client, "job_id2"),
"job_id3": css.Job(client, "job_id3"),
cdbf1 marked this conversation as resolved.
Show resolved Hide resolved
}
return job


def _mocked_request_response(content: object) -> requests.Response:
response = requests.Response()
response.status_code = requests.codes.OK
Expand Down Expand Up @@ -456,6 +477,12 @@ def test_job_results_poll_failure(mock_sleep: mock.MagicMock, job: css.job.Job)
assert mock_sleep.call_count == 5


def test_job_getitem(multi_circuit_job: css.job.Job) -> None:
job_1 = multi_circuit_job[0]
assert isinstance(job_1, css.Job)
assert job_1.job_id() == "job_id1"
cdbf1 marked this conversation as resolved.
Show resolved Hide resolved


def test_get_marginal_counts() -> None:
counts_dict = {"10": 50, "11": 50}
indices = [0]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Superstaq Documentation
=======================
Welcome! Here you can find more about Infleqtion's state-of-the-art quantum software platform that uses proprietary cross-layer optimization techniques to deliver unmatched performance.

.. raw:: html

<div class="container-index">
Expand Down
12 changes: 12 additions & 0 deletions supermarq-benchmarks/examples/qcvv/qcvv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
QCVV: Quantum Characterisation, Validation and Verification
===========================================================

The Supermarq QCVV library provides a customizable toolkit for testing and characterizing
quantum devices. The toolkit can either be used with simulators or on live devices.

For a demonstration of how to implement a new experiment take a look at the following notebook

.. toctree::
:maxdepth: 1

qcvv_css
348 changes: 348 additions & 0 deletions supermarq-benchmarks/examples/qcvv/qcvv_css.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions supermarq-benchmarks/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cirq-superstaq~=0.5.21
qiskit-superstaq~=0.5.21
scikit-learn>=1.0
seaborn>=0.13.2
3 changes: 2 additions & 1 deletion supermarq-benchmarks/supermarq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import benchmark, converters, features, plotting, simulation, stabilizers
from . import benchmark, converters, features, plotting, qcvv, simulation, stabilizers
from ._version import __version__
from .benchmarks import (
bit_code,
Expand Down Expand Up @@ -27,4 +27,5 @@
"simulation",
"stabilizers",
"vqe_proxy",
"qcvv",
]
1 change: 1 addition & 0 deletions supermarq-benchmarks/supermarq/qcvv/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""A toolkit of QCVV routines."""
Loading
Loading