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.

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 Distribution

qcs_sdk_python-0.17.7.tar.gz (226.2 kB view hashes)

Uploaded Source

Built Distributions

qcs_sdk_python-0.17.7-cp312-none-win_amd64.whl (5.9 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

qcs_sdk_python-0.17.7-cp312-cp312-manylinux_2_28_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.17.7-cp312-cp312-manylinux_2_28_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.28+ ARM64

qcs_sdk_python-0.17.7-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (10.3 MB view hashes)

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

qcs_sdk_python-0.17.7-cp311-none-win_amd64.whl (5.8 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

qcs_sdk_python-0.17.7-cp311-cp311-manylinux_2_28_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.17.7-cp311-cp311-manylinux_2_28_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ ARM64

qcs_sdk_python-0.17.7-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (10.3 MB view hashes)

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

qcs_sdk_python-0.17.7-cp310-none-win_amd64.whl (5.8 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

qcs_sdk_python-0.17.7-cp310-cp310-manylinux_2_28_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.17.7-cp310-cp310-manylinux_2_28_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ ARM64

qcs_sdk_python-0.17.7-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (10.3 MB view hashes)

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

qcs_sdk_python-0.17.7-cp39-none-win_amd64.whl (5.8 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

qcs_sdk_python-0.17.7-cp39-cp39-manylinux_2_28_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.17.7-cp39-cp39-manylinux_2_28_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ ARM64

qcs_sdk_python-0.17.7-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (10.3 MB view hashes)

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

qcs_sdk_python-0.17.7-cp38-none-win_amd64.whl (5.8 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

qcs_sdk_python-0.17.7-cp38-cp38-manylinux_2_28_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

qcs_sdk_python-0.17.7-cp38-cp38-manylinux_2_28_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ ARM64

qcs_sdk_python-0.17.7-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (10.3 MB view hashes)

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

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