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

implement aspen qubits and devices #4378

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3,336 changes: 3,336 additions & 0 deletions cirq-rigetti/cirq_rigetti/__fixtures__/QCS-Aspen-8-ISA.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions cirq-rigetti/cirq_rigetti/__init__.py
Expand Up @@ -23,3 +23,18 @@
)
from cirq_rigetti import circuit_sweep_executors
from cirq_rigetti import circuit_transformers
from cirq_rigetti.aspen_device import (
RigettiQCSAspenDevice,
AspenQubit,
OctagonalQubit,
UnsupportedQubit,
UnsupportedRigettiQCSOperation,
UnsupportedRigettiQCSQuantumProcessor,
)


# Registers the cirq_rigetti's public classes for JSON serialization.
from cirq.protocols.json_serialization import _register_resolver
from cirq_rigetti.json_resolver_cache import _class_resolver_dictionary

_register_resolver(_class_resolver_dictionary)
46 changes: 46 additions & 0 deletions cirq-rigetti/cirq_rigetti/_qcs_api_client_decorator.py
@@ -0,0 +1,46 @@
##############################################################################
# Copyright 2021 The Cirq Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
import functools

from qcs_api_client.client import build_sync_client


def _provide_default_client(function):
"""A decorator that will initialize an `httpx.Client` and pass
it to the wrapped function as a kwarg if not already present. This
eases provision of a default `httpx.Client` with Rigetti
QCS configuration and authentication. If the decorator initializes a
default client, it will invoke the wrapped function from within the
`httpx.Client` context.

Args:
function: The decorated function.

Returns:
The `function` wrapped with a default `client`.
"""

@functools.wraps(function)
def wrapper(*args, **kwargs):
if 'client' in kwargs:
return function(*args, **kwargs)

with build_sync_client() as client: # coverage: ignore
# coverage: ignore
kwargs['client'] = client
return function(*args, **kwargs)

return wrapper