Skip to content

Commit

Permalink
libquil requires i32
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Oct 24, 2024
1 parent 6e2e7ac commit 29d7199
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/lib/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ impl From<qvm::Error> for Error {
qvm::Error::ToQuil(q) => Self::ToQuil(q),
qvm::Error::Parsing(_)
| qvm::Error::ShotsMustBePositive
| qvm::Error::ShotCountOverflow(_)
| qvm::Error::RegionSizeMismatch { .. }
| qvm::Error::RegionNotFound { .. }
| qvm::Error::Qvm { .. } => Self::Compilation(format!("{err}")),
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/qvm/libquil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl crate::qvm::Client for Client {
let result = libquil_sys::qvm::multishot(
&program,
addresses,
request.trials.get(),
i32::try_from(request.trials.get())?,
request.gate_noise,
request.measurement_noise,
request.rng_seed,
Expand Down Expand Up @@ -147,7 +147,7 @@ impl crate::qvm::Client for Client {
let result = libquil_sys::qvm::multishot_measure(
&program,
qubits.as_slice(),
request.trials.get(),
i32::try_from(request.trials.get())?,
request.rng_seed,
)
.map_err(Error::LibquilSysQvm)?;
Expand Down
10 changes: 9 additions & 1 deletion crates/lib/src/qvm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
//! This module contains all the functionality for running Quil programs on a QVM. Specifically,
//! the [`Execution`] struct in this module.
use std::{collections::HashMap, num::NonZeroU32, str::FromStr, sync::Arc, time::Duration};
use std::{
collections::HashMap,
num::{NonZeroU32, TryFromIntError},
str::FromStr,
sync::Arc,
time::Duration,
};

use quil_rs::{
instruction::{ArithmeticOperand, Instruction, MemoryReference, Move},
Expand Down Expand Up @@ -275,6 +281,8 @@ pub enum Error {
ToQuil(#[from] ToQuilError),
#[error("Shots must be a positive integer.")]
ShotsMustBePositive,
#[error("Requested shot count exceeds QVM limit.")]
ShotCountOverflow(#[from] TryFromIntError),
#[error("Declared region {name} has size {declared} but parameters have size {parameters}.")]
RegionSizeMismatch {
name: String,
Expand Down

0 comments on commit 29d7199

Please sign in to comment.