Skip to content

Commit 7114f71

Browse files
MarquessVShadow53jselig-rigettikalzoo
authored
feat!: The execution_data module now provides ExecutionData as a replacement for both Qvm and Qpu structs. It serves a common interface for interacting with both result shapes when possible. See the ExecutionData documentation for more details on how to use it. (#223)
Co-authored-by: Michael Bryant <[email protected]> Co-authored-by: Jake Selig <[email protected]> Co-authored-by: Kalan <[email protected]>
1 parent 7a96c0c commit 7114f71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1648
-560
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Cargo / rustc artifacts
22
/target
33

4+
# Python artifacts
5+
__pycache__/
6+
47
# Local config
58
.env
69
venv/
10+
.venv
711

812
# JetBrains
913
.idea

Cargo.lock

Lines changed: 107 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
[workspace]
22
members = ["crates/*"]
33

4+
[workspace.dependencies]
5+
qcs-api = "0.2.1"
6+
qcs-api-client-common = "0.4.2"
7+
qcs-api-client-grpc = "0.4.2"
8+
qcs-api-client-openapi = "0.5.2"
9+
quil-rs = "0.15"
10+
serde_json = "1.0.86"
11+
tokio = "1.24.2"
12+
13+
# ndarray is used by the `qcs` crate, but it is also used in the `python` crate via a
14+
# re-export through the numpy crate. They should be updated as a pair to keep both
15+
# crates version of ndarray in sync.
16+
# Similarly, pyo3 packages (`numpy`, `rigetti-pyo3`, `pyo3*`) track versions together
17+
# and need to be updated together.
18+
ndarray = { version = "0.15.6", features = ["serde"] }
19+
numpy = "0.17"
20+
pyo3 = { version = "0.17", features = ["extension-module"] }
21+
pyo3-asyncio = { version = "0.17", features = ["tokio-runtime"] }
22+
pyo3-build-config = { version = "0.17" }
23+
rigetti-pyo3 = { version = "0.1.0-rc.4", features = ["extension-module", "complex"] }

crates/lib/Cargo.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,35 @@ futures = "0.3.24"
1919
indexmap = "1.9.1"
2020
lazy_static = "1.4.0"
2121
log = "0.4.17"
22+
ndarray.workspace = true
2223
num = { version = "0.4.0", features = ["serde"] }
23-
qcs-api = "0.2.1"
24-
qcs-api-client-common = "0.4.2"
25-
qcs-api-client-openapi = "0.5.2"
26-
qcs-api-client-grpc = "0.4.2"
27-
quil-rs = "0.15"
24+
qcs-api.workspace = true
25+
qcs-api-client-common.workspace = true
26+
qcs-api-client-openapi.workspace = true
27+
qcs-api-client-grpc.workspace = true
28+
quil-rs.workspace = true
2829
reqwest = { version = "0.11.12", default-features = false, features = ["rustls-tls", "json"] }
2930
rmp-serde = "1.1.1"
3031
serde = { version = "1.0.145", features = ["derive"] }
3132
serde_bytes = "0.11.7"
32-
serde_json = "1.0.86"
33+
serde_json.workspace = true
3334
thiserror = "1.0.37"
34-
tokio = { version = "1.24.2", features = ["fs"] }
35+
tokio = { workspace = true, features = ["fs"] }
3536
toml = "0.5.9"
3637
uuid = { version = "1.2.1", features = ["v4"] }
3738
tonic = { version = "0.8.2", features = ["tls", "tls-roots"] }
3839
zmq = { version = "0.9.2", features = ["vendored"] }
40+
itertools = "0.10.5"
3941

4042
[dev-dependencies]
4143
erased-serde = "0.3.23"
4244
float-cmp = "0.9.0"
4345
hex = "0.4.3"
4446
maplit = "1.0.2"
45-
qcs-api-client-grpc = { version = "0.4.2", features = ["server"] }
47+
qcs-api-client-grpc = { workspace = true, features = ["server"] }
4648
simple_logger = { version = "2.3.0", default-features = false }
4749
tempfile = "3.3.0"
4850
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
4951
warp = { version = "0.3.3", default-features = false }
5052
regex = "1.7.0"
53+
test-case = "2.2.2"

crates/lib/examples/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async fn main() {
1717

1818
let result = exe
1919
.with_parameter("theta", 0, PI)
20-
.execute_on_qpu("Aspen-11")
20+
.execute_on_qpu("Aspen-M-3")
2121
.await
2222
.expect("Program should execute successfully");
2323

crates/lib/examples/local.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ async fn main() {
1818

1919
let result = exe
2020
.with_parameter("theta", 0, PI)
21-
.execute_on_qpu("Aspen-11")
21+
.execute_on_qpu("Aspen-M-3")
2222
.await
2323
.expect("Program should execute successfully");
2424

25-
println!("{:?}", result);
25+
println!("{result:?}");
2626
}

crates/lib/examples/parametric_compilation.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::f64::consts::PI;
55
use std::time::Duration;
66

77
use qcs::Executable;
8-
use qcs_api_client_grpc::models::controller::{readout_values::Values, IntegerReadoutValues};
98

109
const PROGRAM: &str = r#"
1110
DECLARE ro BIT
@@ -30,32 +29,30 @@ async fn main() {
3029
let theta = step * f64::from(i);
3130
let data = exe
3231
.with_parameter("theta", 0, theta)
33-
.execute_on_qpu("Aspen-11")
32+
.execute_on_qpu("Aspen-M-3")
3433
.await
3534
.expect("Executed program on QPU");
3635
total_execution_time += data
3736
.duration
38-
.expect("Aspen-11 should always report duration");
37+
.expect("Aspen-M-3 should always report duration");
3938

40-
let ro_readout_data = data
41-
.readout_data
42-
.get_readout_values_for_field("ro")
39+
let first_ro_values = data
40+
.result_data
41+
.to_register_map()
42+
.expect("should be able to create a RegisterMap")
43+
.get_register_matrix("ro")
4344
.expect("readout values should contain 'ro'")
44-
.expect("'ro' should contain readout values");
45-
let first_ro_data = ro_readout_data
46-
.first()
47-
.expect("'ro' should contain at least one readout value")
48-
.clone();
49-
let first_ro_values = first_ro_data
50-
.expect("first readout value should ")
51-
.values
52-
.expect("'ro' should have readout values");
53-
if let Values::IntegerValues(IntegerReadoutValues { mut values }) = first_ro_values {
54-
parametric_measurements.append(&mut values)
45+
.as_integer()
46+
.expect("'ro' should be a register of integer values")
47+
.row(0)
48+
.to_owned();
49+
50+
for value in &first_ro_values {
51+
parametric_measurements.push(*value)
5552
}
5653
}
5754

58-
println!("Total execution time: {:?}", total_execution_time);
55+
println!("Total execution time: {total_execution_time:?}");
5956

6057
for measurement in parametric_measurements {
6158
if measurement == 1 {

crates/lib/examples/quil_t.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! [pyquil]: https://pyquil-docs.rigetti.com/en/stable/quilt_getting_started.html#Another-example:-a-simple-T1-experiment
44
55
use qcs::Executable;
6-
use qcs_api_client_grpc::models::controller::{readout_values::Values, IntegerReadoutValues};
76

87
/// This program doesn't do much, the main point is that it will fail if quilc is invoked.
98
const PROGRAM: &str = r#"
@@ -20,17 +19,17 @@ async fn main() {
2019

2120
let result = exe
2221
.compile_with_quilc(false)
23-
.execute_on_qpu("Aspen-11")
22+
.execute_on_qpu("Aspen-M-3")
2423
.await
2524
.expect("Program should execute successfully")
26-
.readout_data
27-
.get_readout_values("ro".to_string(), 0)
28-
.expect("Readout data should include 'ro'")
29-
.values
30-
.expect("Readout data should include values");
25+
.result_data
26+
.to_register_map()
27+
.expect("should be able to convert execution data to RegisterMap")
28+
.get_register_matrix("ro")
29+
.expect("Register data should include 'ro'")
30+
.as_integer()
31+
.expect("ro should be a register of integer values")
32+
.to_owned();
3133

32-
match result {
33-
Values::IntegerValues(IntegerReadoutValues { values }) => assert!(!values.is_empty()),
34-
_ => panic!("expected IntegerReadoutValues, got {:?}", result),
35-
}
34+
println!("{result:?}");
3635
}

0 commit comments

Comments
 (0)