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

feat!: Use a common struct for both QPU and QVM execution results #223

Merged
merged 79 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
adeda2f
update .gitignore
MarquessV Nov 9, 2022
41598b0
first pass at ndarray implementaion for readout data
MarquessV Nov 22, 2022
3f35c9f
a pass at cleanup, add test for from_register_data_map
MarquessV Nov 22, 2022
016ef7e
another round of cleanup
MarquessV Nov 22, 2022
3356fcb
ReadoutTypes => ReadoutValue
MarquessV Nov 22, 2022
675382d
merge main
MarquessV Nov 22, 2022
b412eda
clippy: must_use and let_underscore_drop
MarquessV Nov 22, 2022
9d58991
Apply suggestions from code review
MarquessV Nov 22, 2022
a7ebfd0
more review comments
MarquessV Nov 22, 2022
14e046d
ExecuteResult => ExecutionResult
MarquessV Nov 22, 2022
8454d66
simplify ReadoutValue enum
MarquessV Nov 22, 2022
2770c08
more tests!
MarquessV Nov 22, 2022
1c7c6ec
Update crates/lib/src/execution_data.rs
MarquessV Nov 22, 2022
da53a50
avoid memory index truncation
MarquessV Nov 22, 2022
51fa1c7
fix bell state integration test
MarquessV Nov 23, 2022
e453d52
fix doc tests
MarquessV Nov 23, 2022
3ac3b18
fix deadlinks in documentation
MarquessV Nov 23, 2022
08d17d8
more doc cleanup
MarquessV Nov 23, 2022
1709974
cleanup docstrings
MarquessV Nov 28, 2022
5ef0d16
use single backticks around identifiers
MarquessV Nov 28, 2022
240c97a
single backticks
MarquessV Nov 28, 2022
9525f0a
chore: add new method for ReadotMap and serialize and deserialize
jselig-rigetti Nov 29, 2022
12718ed
add tracking issue for MemoryReference clone
MarquessV Nov 30, 2022
2d286d5
wip: add helper to use RegisterMatrix as i32 type
jselig-rigetti Nov 30, 2022
71f7340
WIP: refactor execution result types into their respective modules,
MarquessV Jan 14, 2023
a74eadd
to_readout_map w/ docstring
MarquessV Jan 14, 2023
35bf013
more docstrings, fix examples and tests
MarquessV Jan 24, 2023
59eda08
merge main, resolve conflicts, implement some of the python bindings
MarquessV Jan 25, 2023
96d6fa1
pass register matrixes across the border as ndarrays
MarquessV Jan 26, 2023
334dcf4
build out constructors and python tests
MarquessV Jan 27, 2023
f740797
docstring updates, clippy
MarquessV Jan 27, 2023
e0c2512
RegisterData docstring
MarquessV Jan 27, 2023
b0bdefd
more docstring updates
MarquessV Jan 28, 2023
0e1ae9f
clippy
MarquessV Jan 28, 2023
f7fa476
Merge branch 'main' into 215-execution-results-in-common-struct
MarquessV Jan 28, 2023
c6308c7
fix typo
MarquessV Jan 28, 2023
7174501
remove old todo comment
MarquessV Jan 28, 2023
2b249de
missing docstring
MarquessV Jan 28, 2023
0a9a73f
better test from qpu to readout map, doc lints
MarquessV Jan 28, 2023
1da1839
test assertion fix
MarquessV Jan 28, 2023
a82ad02
more docstring example fixes
MarquessV Jan 28, 2023
a219baf
define shared/related deps in workspace dependencies
MarquessV Jan 30, 2023
f3d82b6
cleanup per review comments
MarquessV Jan 31, 2023
e723226
ReadoutData -> ResultData, ReadoutMap -> RegisterMap
MarquessV Jan 31, 2023
f062ede
properly rename python bindings
MarquessV Jan 31, 2023
be90039
QpuReadout -> QpuResultData, sweep for stale references to ReadoutMap
MarquessV Feb 1, 2023
f1f7536
clean up references to QPUReadout
MarquessV Feb 1, 2023
6b2c4f0
Replace QvmMemory alias with QvmResultData struct
MarquessV Feb 1, 2023
6a27ede
handle QvmResultData in Python bindings
MarquessV Feb 1, 2023
f2b6679
use to_owned()
MarquessV Feb 1, 2023
e986592
break out reference sequence check into seperate step with itertools
MarquessV Feb 3, 2023
f44b165
fix conditions
MarquessV Feb 3, 2023
7689dcc
naming
MarquessV Feb 3, 2023
b46e0a5
another sweep for old names
MarquessV Feb 3, 2023
9b37d87
add type hints, configure fmt & linting for pyi files
MarquessV Feb 14, 2023
edc5514
use staticmethod, fix edge case in registermatrix conversion
MarquessV Feb 14, 2023
0cf934b
update Cargo.toml
MarquessV Feb 14, 2023
8dde07a
use rfold, remove extra spaces in docstrings
MarquessV Feb 14, 2023
4a7c926
fix tests
MarquessV Feb 14, 2023
83fa3e3
Update crates/lib/src/execution_data.rs
MarquessV Feb 14, 2023
2e90b58
clarify ReadoutValues docs
MarquessV Feb 14, 2023
93aa5a6
Merge branch 'main' into 215-execution-results-in-common-struct
MarquessV Feb 14, 2023
cdaaf47
Update crates/python/qcs_sdk/_execution_data.pyi
MarquessV Feb 14, 2023
63d2c52
Update crates/python/qcs_sdk/_execution_data.pyi
MarquessV Feb 14, 2023
846b9f8
Update crates/python/qcs_sdk/qpu/result_data.pyi
MarquessV Feb 14, 2023
326fc19
remove extra comment from .flake8
MarquessV Feb 14, 2023
68a570a
Update crates/lib/src/executable.rs
MarquessV Feb 15, 2023
fb7a860
Update crates/lib/src/execution_data.rs
MarquessV Feb 15, 2023
db5b0a5
Update crates/lib/examples/parametric_compilation.rs
MarquessV Feb 15, 2023
3689bfe
reduce visibility of result data members
MarquessV Feb 15, 2023
440fa43
various hint and test improvements
MarquessV Feb 15, 2023
0879bf3
fix setter method name
MarquessV Feb 15, 2023
4ebae0e
cleanup per feedback
MarquessV Feb 15, 2023
c804135
remove redundant py_try_from
MarquessV Feb 15, 2023
342a0c6
make import paths for QVM and QPU result data consistent for both types
MarquessV Feb 15, 2023
6224921
fix imports
MarquessV Feb 15, 2023
1713621
fix weird crates import path
MarquessV Feb 15, 2023
44d62f8
fix enum declaration
MarquessV Feb 16, 2023
adb2c80
allow BSD-2 licence for numpy
MarquessV Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Cargo / rustc artifacts
/target

# Python artifacts
__pycache__/

# Local config
.env
venv/
.venv

# JetBrains
.idea
Expand Down
109 changes: 107 additions & 2 deletions Cargo.lock

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

20 changes: 20 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
[workspace]
members = ["crates/*"]

[workspace.dependencies]
qcs-api = "0.2.1"
qcs-api-client-common = "0.4.2"
qcs-api-client-grpc = "0.4.2"
qcs-api-client-openapi = "0.5.2"
quil-rs = "0.15"
serde_json = "1.0.86"
tokio = "1.24.2"

# 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
# crates version of ndarray in sync.
# Similarly, pyo3 packages (`numpy`, `rigetti-pyo3`, `pyo3*`) track versions together
# and need to be updated together.
ndarray = { version = "0.15.6", features = ["serde"] }
numpy = "0.17"
pyo3 = { version = "0.17", features = ["extension-module"] }
pyo3-asyncio = { version = "0.17", features = ["tokio-runtime"] }
pyo3-build-config = { version = "0.17" }
rigetti-pyo3 = { version = "0.1.0-rc.4", features = ["extension-module", "complex"] }
19 changes: 11 additions & 8 deletions crates/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,35 @@ futures = "0.3.24"
indexmap = "1.9.1"
lazy_static = "1.4.0"
log = "0.4.17"
ndarray.workspace = true
num = { version = "0.4.0", features = ["serde"] }
qcs-api = "0.2.1"
qcs-api-client-common = "0.4.2"
qcs-api-client-openapi = "0.5.2"
qcs-api-client-grpc = "0.4.2"
quil-rs = "0.15"
qcs-api.workspace = true
qcs-api-client-common.workspace = true
qcs-api-client-openapi.workspace = true
qcs-api-client-grpc.workspace = true
quil-rs.workspace = true
reqwest = { version = "0.11.12", default-features = false, features = ["rustls-tls", "json"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.145", features = ["derive"] }
serde_bytes = "0.11.7"
serde_json = "1.0.86"
serde_json.workspace = true
thiserror = "1.0.37"
tokio = { version = "1.24.2", features = ["fs"] }
tokio = { workspace = true, features = ["fs"] }
toml = "0.5.9"
uuid = { version = "1.2.1", features = ["v4"] }
tonic = { version = "0.8.2", features = ["tls", "tls-roots"] }
zmq = { version = "0.9.2", features = ["vendored"] }
itertools = "0.10.5"

[dev-dependencies]
erased-serde = "0.3.23"
float-cmp = "0.9.0"
hex = "0.4.3"
maplit = "1.0.2"
qcs-api-client-grpc = { version = "0.4.2", features = ["server"] }
qcs-api-client-grpc = { workspace = true, features = ["server"] }
simple_logger = { version = "2.3.0", default-features = false }
tempfile = "3.3.0"
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
warp = { version = "0.3.3", default-features = false }
regex = "1.7.0"
test-case = "2.2.2"
MarquessV marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion crates/lib/examples/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn main() {

let result = exe
.with_parameter("theta", 0, PI)
.execute_on_qpu("Aspen-11")
.execute_on_qpu("Aspen-M-3")
.await
.expect("Program should execute successfully");

Expand Down
4 changes: 2 additions & 2 deletions crates/lib/examples/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ async fn main() {

let result = exe
.with_parameter("theta", 0, PI)
.execute_on_qpu("Aspen-11")
.execute_on_qpu("Aspen-M-3")
.await
.expect("Program should execute successfully");

println!("{:?}", result);
println!("{result:?}");
}
33 changes: 15 additions & 18 deletions crates/lib/examples/parametric_compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::f64::consts::PI;
use std::time::Duration;

use qcs::Executable;
use qcs_api_client_grpc::models::controller::{readout_values::Values, IntegerReadoutValues};

const PROGRAM: &str = r#"
DECLARE ro BIT
Expand All @@ -30,32 +29,30 @@ async fn main() {
let theta = step * f64::from(i);
let data = exe
.with_parameter("theta", 0, theta)
.execute_on_qpu("Aspen-11")
.execute_on_qpu("Aspen-M-3")
.await
.expect("Executed program on QPU");
total_execution_time += data
.duration
.expect("Aspen-11 should always report duration");
.expect("Aspen-M-3 should always report duration");

let ro_readout_data = data
.readout_data
.get_readout_values_for_field("ro")
let first_ro_values = data
.result_data
.to_register_map()
.expect("should be able to create a RegisterMap")
.get_register_matrix("ro")
.expect("readout values should contain 'ro'")
.expect("'ro' should contain readout values");
let first_ro_data = ro_readout_data
.first()
.expect("'ro' should contain at least one readout value")
.clone();
let first_ro_values = first_ro_data
.expect("first readout value should ")
.values
.expect("'ro' should have readout values");
if let Values::IntegerValues(IntegerReadoutValues { mut values }) = first_ro_values {
parametric_measurements.append(&mut values)
.as_integer()
.expect("'ro' should be a register of integer values")
.row(0)
.to_owned();

for value in first_ro_values.iter() {
MarquessV marked this conversation as resolved.
Show resolved Hide resolved
parametric_measurements.push(*value)
}
}

println!("Total execution time: {:?}", total_execution_time);
println!("Total execution time: {total_execution_time:?}");

for measurement in parametric_measurements {
if measurement == 1 {
Expand Down
21 changes: 10 additions & 11 deletions crates/lib/examples/quil_t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! [pyquil]: https://pyquil-docs.rigetti.com/en/stable/quilt_getting_started.html#Another-example:-a-simple-T1-experiment

use qcs::Executable;
use qcs_api_client_grpc::models::controller::{readout_values::Values, IntegerReadoutValues};

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

let result = exe
.compile_with_quilc(false)
.execute_on_qpu("Aspen-11")
.execute_on_qpu("Aspen-M-3")
.await
.expect("Program should execute successfully")
.readout_data
.get_readout_values("ro".to_string(), 0)
.expect("Readout data should include 'ro'")
.values
.expect("Readout data should include values");
.result_data
.to_register_map()
.expect("should be able to convert execution data to RegisterMap")
.get_register_matrix("ro")
.expect("Register data should include 'ro'")
.as_integer()
.expect("ro should be a register of integer values")
.to_owned();

match result {
Values::IntegerValues(IntegerReadoutValues { values }) => assert!(!values.is_empty()),
_ => panic!("expected IntegerReadoutValues, got {:?}", result),
}
println!("{result:?}");
}
Loading