Skip to content

Commit

Permalink
feat!: Make Python bindings public (#463)
Browse files Browse the repository at this point in the history
* wip: various publicity modifications and refactors

* derive debug on PyTranslationOptions

* add utility method for converting TranslationOptions into protobuf bytes

* add methods for inspecting a PyConnectionStrategy

* update qcs dependencies

* update rigetti-pyo3

* update Cargo.lock

* replace py_sync module w/ rigetti-pyo3

* Apply suggestions from code review

Co-authored-by: Kyle J Strand <[email protected]>

* update qcs-api-client-grpc

* remove stale TODO

* reduce visibility of gRPC message size constant

* update qcs-api-cilent packages, use uv instead of poetry

* activate virtual environment

* commit the change

* activate venv

* separate steps?

* write to GITHUB_ENV

* try cat

* try action

* remove duplicated command

* add missing dev dep

* Update qcs-api-client-rust packages

* update quil-rs

---------

Co-authored-by: Kyle J Strand <[email protected]>
  • Loading branch information
MarquessV and BatmanAoD authored Sep 17, 2024
1 parent cc3cab2 commit 43cbad7
Show file tree
Hide file tree
Showing 38 changed files with 438 additions and 457 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.20.1'

- name: Install libquil dependencies
run: sudo apt install -y libffi\* libblas\* liblapack\*
- name: Install libquil
run: |
curl https://raw.githubusercontent.com/rigetti/libquil/main/install.sh | bash -s 0.3.0
- uses: Swatinem/rust-cache@v2
- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: --debug cargo-make
- name: Install poetry
uses: snok/install-poetry@v1
- uses: syphar/restore-virtualenv@v1
# may protect against linking failure: no space left on device
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install poetry
uses: snok/install-poetry@v1
- uses: Swatinem/rust-cache@v2
- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: --debug cargo-make
- uses: syphar/restore-virtualenv@v1
- name: Build qcs-sdk-python documentation
uses: actions-rs/cargo@v1
with:
Expand Down
84 changes: 57 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ resolver = "2"

[workspace.dependencies]
qcs-api = "0.2.1"
qcs-api-client-common = "0.8.4"
qcs-api-client-grpc = "0.8.4"
qcs-api-client-openapi = "0.9.4"
qcs-api-client-common = "0.10.0"
qcs-api-client-grpc = "0.10.0"
qcs-api-client-openapi = "0.11.0"
serde_json = "1.0.86"
thiserror = "1.0.57"
tokio = "1.36.0"
# We specify quil-rs as a git and versioned dependency so that we can keep the version of
# quil-rs used in both the Rust and Python packages in sync. The tag used should always
# be a `quil-py` tag and should be comaptible with the version specified in
# be a `quil-py` tag and should be compatible with the version specified in
# `crates/python/pyproject.toml`.
# The version must also be specified in order to publish to crates.io. Cargo enforces
# that the specified version is the same as the version in the git repository.
quil-rs = { version = "0.27.1", git = "https://github.com/rigetti/quil-rs", tag = "quil-py/v0.11.1" }
quil-rs = { version = "0.28.1", git = "https://github.com/rigetti/quil-rs", tag = "quil-py/v0.12.1" }

# ndarray is used by the `qcs` crate, but it is also used in the `python` crate via a
# re-export through the numpy crate. They should be updated as a pair to keep both
Expand All @@ -32,7 +32,7 @@ pyo3-opentelemetry = { version = "=0.3.2-dev.1" }
pyo3-tracing-subscriber = { version = "=0.1.2-dev.1", default-features = true }

pyo3-build-config = "0.20.0"
rigetti-pyo3 = { version = "0.3.1", default-features = false, features = ["time", "complex"] }
rigetti-pyo3 = { version = "0.4.1", default-features = false, features = ["complex", "time"] }

# The primary intent of these options is to reduce the binary size for Python wheels
# since PyPi has limits on how much storage a project can use.
Expand Down
11 changes: 4 additions & 7 deletions crates/lib/src/compiler/quilc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ mod tests {
serde_json::from_reader(File::open("tests/qvm_isa.json").unwrap()).unwrap()
}

async fn rpcq_client() -> rpcq::Client {
fn rpcq_client() -> rpcq::Client {
let qcs = Qcs::load();
let endpoint = qcs.get_config().quilc_url();
rpcq::Client::new(endpoint).unwrap()
Expand All @@ -366,7 +366,6 @@ mod tests {
#[tokio::test]
async fn compare_native_quil_to_expected_output() {
let output = rpcq_client()
.await
.compile_program(
"MEASURE 0",
TargetDevice::try_from(qvm_isa()).expect("Couldn't build target device from ISA"),
Expand All @@ -390,7 +389,6 @@ MEASURE 1 ro[1]
let client = Qcs::load();
let client = qvm::http::HttpClient::from(&client);
let output = rpcq_client()
.await
.compile_program(
BELL_STATE,
TargetDevice::try_from(aspen_9_isa())
Expand Down Expand Up @@ -426,7 +424,6 @@ MEASURE 1 ro[1]
#[tokio::test]
async fn test_compile_declare_only() {
let output = rpcq_client()
.await
.compile_program(
"DECLARE ro BIT[1]\n",
TargetDevice::try_from(aspen_9_isa())
Expand All @@ -440,7 +437,7 @@ MEASURE 1 ro[1]

#[tokio::test]
async fn get_version_info_from_quilc() {
let rpcq_client = rpcq_client().await;
let rpcq_client = rpcq_client();
let version = rpcq_client
.get_version_info()
.expect("Should get version info from quilc");
Expand All @@ -450,7 +447,7 @@ MEASURE 1 ro[1]

#[tokio::test]
async fn test_conjugate_pauli_by_clifford() {
let rpcq_client = rpcq_client().await;
let rpcq_client = rpcq_client();
let request = ConjugateByCliffordRequest {
pauli: PauliTerm {
indices: vec![0],
Expand All @@ -473,7 +470,7 @@ MEASURE 1 ro[1]

#[tokio::test]
async fn test_generate_randomized_benchmark_sequence() {
let rpcq_client = rpcq_client().await;
let rpcq_client = rpcq_client();
let request = RandomizedBenchmarkingRequest {
depth: 2,
qubits: 1,
Expand Down
Loading

0 comments on commit 43cbad7

Please sign in to comment.