Skip to main content

Python interface for the QCS Rust SDK

Project description

QCS SDK Python

⚠️ In Development

qcs-sdk-python provides an interface to Rigetti Quantum Cloud Services (QCS), allowing users to compile and run Quil programs on Rigetti quantum processors. Internally, it is powered by the QCS Rust SDK.

While this package can be used directly, pyQuil offers more functionality and a higher-level interface for building and executing Quil programs. This package is still in early development and breaking changes should be expected between minor versions.

Documentation

Documentation for the current release of qcs_sdk is published here. Every version of qcs_sdk ships with type stubs that can provide type hints and documentation to Python tooling and editors.

Troubleshooting

Enabling Debug logging

This package integrates with Python's logging facility through a Rust crate called pyo3_log. The quickest way to get started is to just enable debug logging:

import logging
logging.basicConfig(level=logging.DEBUG)

Because this is implemented with Rust, there are some important differences in regards to log levels and filtering.

The TRACE log level

Rust has a TRACE log level that doesn't exist in Python. It is less severe than DEBUG and is set to a value of 5. While the DEBUG level is recommended for troubleshooting, you can choose to target TRACE level logs and below like so:

import logging
logging.basicConfig(level=5)

Runtime Configuration and Caching

pyo3_log caches loggers and their level filters to improve performance. This means that logger re-configuration done at runtime may cause unexpected logging behavior in certain situations. If this is a concern, this section of the pyo3_log documentation goes into more detail.

These caches can be reset using the following:

qcs_sdk.reset_logging()

This will allow the logging handlers to pick up the most recently-applied configuration from the Python side.

Filtering Logs

Because the logs are emitted from a Rust library, the logger names will correspond to the fully qualified path of the Rust module in the library where the log occurred. These fully qualified paths all have their own logger, and have to be configured individually.

For example, say you wanted to disable the following log:

DEBUG:hyper.proto.h1.io:flushed 124 bytes

You could get the logger for hyper.proto.h1.io and disable it like so:

logging.getLogger("hyper.proto.h1.io").disabled = True

This can become cumbersome, since there are a handful of libraries all logging from a handful of modules that you may not be concerned with. A less cumbersome, but more heavy handed approach is to apply a filter to all logging handlers at runtime. For example, if you only cared about logs from a qcs library, you could setup a log filter like so:

class QCSLogFilter(logging.Filter):
    def filter(self, record) -> bool:
        return "qcs" in record.name

for handler in logging.root.handlers:
    handler.addFilter(QCSLogFilter())

This applies to all logs, so you may want to tune the filter method to include other logs you care about. See the caching section above for important information about the application of these filters.

OpenTelemetry Integration

This package supports collection of OpenTelemetry trace data. Clients may configure any OpenTelemetry collector that supports the OTLP Specification. Rigetti will not have access to the OpenTelemetry data you collect.

To enable the integration, you should install the qcs-sdk[tracing-opentelemetry] extra; this installs opentelemetry-api. By default, no tracing data is collected at runtime. Because the QCS-SDK is built as a pyo3 Rust extension-module, you will need to use pyo3-tracing-subscriber to configure collection of your client network requests. See qcs_sdk._tracing_subscriber module level documentation for more detail.

import my_module
from qcs_sdk._tracing_subscriber import (
    GlobalTracingConfig,
    SimpleConfig,
    Tracing,
    subscriber,
)
from qcs_sdk._tracing_subscriber.layers import otel_otlp


def main():
    tracing_configuration = GlobalTracingConfig(
        export_process=SimpleConfig(
            subscriber=subscriber.Config(
                # By default this supports the standard OTLP environment variables.
                # See https://opentelemetry.io/docs/specs/otel/protocol/exporter/
                layer=otel_otlp.Config()
            )
        )
    )
    with Tracing(config=config):
        result = my_module.example_function()
        my_module.other_example_function(result)

if __name__ == '__main__':
    main()

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

qcs_sdk_python-0.21.4-cp311-cp311-manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.21.4-cp311-cp311-manylinux_2_28_ppc64le.whl (6.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ ppc64le

qcs_sdk_python-0.21.4-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (11.6 MB view details)

Uploaded CPython 3.11 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

qcs_sdk_python-0.21.4-cp310-none-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_ppc64le.whl (6.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ ppc64le

qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_aarch64.whl (6.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ ARM64

qcs_sdk_python-0.21.4-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (11.6 MB view details)

Uploaded CPython 3.10 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

File details

Details for the file qcs_sdk_python-0.21.4-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e4393e1825196bdf8df9ea5094f978f60bf8f4f02fdc204ea8892d182328f157
MD5 512c0eb490d79f8ef22f1f064f04c763
BLAKE2b-256 fd59bc9325c87f6becfeadfe5019b8b5e3f011a582ea6d27780dd1024d355b1a

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp311-cp311-manylinux_2_28_ppc64le.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp311-cp311-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 0775773493dca85e8ee326a4d3fe049b37ce3ba3b29a1c66f511054215435c3f
MD5 97f64bba9af6fd249175aed773b23b17
BLAKE2b-256 b154d08c1c741977155ee9082cf145b1be14b52dd91288a937980d6f493f8688

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 939b93e7c5e63cbd0673373377c191a89c784de444a3d40791e88f554344d41f
MD5 772874abd0f6fcda2e7230b98c38d805
BLAKE2b-256 0594ac916d79e616062a0ed19ade70a572c02c01907b8367575f6c9ce3e2bff3

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 6ff4d14a4494bb1e9fdc85927dea822f85697269ae99758f6c09fdcb961717ba
MD5 dc365a7e77500e12fb15176f0eff7a76
BLAKE2b-256 f1f49080de3e3ef252a7fda45d9d4793a8b5a67e6452a8beb389deb87c20ff6a

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6453bc1c9a84dbe41dae6e44d3e4d5a9acbd960ee3fc80666d6b558e2f74e2bf
MD5 e36b7646cb2abe8ff8a196e4a5b39155
BLAKE2b-256 c0f2a4ba8f896c9c8d4aa4a4ac8eec60fee36947e447fcb7252b341f93e566c0

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_ppc64le.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 64abf84485313fc519702daddb89171cfe66c3bbe7e7c158398a282b3d47697d
MD5 2cd974f478d2234b5f46a62dbc72460b
BLAKE2b-256 0e833c04ef339ec3bff862e9848a4c3996cd30689acdd3607e8884dcf88c5dd1

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9d7622e6803106d94384ac73b4fae74758959a8659da772814725af92ee078e2
MD5 11ea8c0ee773b7d3fa377ff93de41afd
BLAKE2b-256 1b4a8bd191aef9f50db181196f41060eed4ffa638c755e2bd42e909af0a16be2

See more details on using hashes here.

File details

Details for the file qcs_sdk_python-0.21.4-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for qcs_sdk_python-0.21.4-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 4aca891caea35e3b5d00138e84fc0b3132c457d5fc300143d7c6736ee873f5b7
MD5 b3443d682771e62f90f6238a6e6d82c1
BLAKE2b-256 0dfd8d10b2d950c685255a441a735c4f633c31ec60ce7331dcb1d7b4fbc221fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page