diff --git a/crates/lib/src/executable.rs b/crates/lib/src/executable.rs index a0d3a059b..38ea5934b 100644 --- a/crates/lib/src/executable.rs +++ b/crates/lib/src/executable.rs @@ -732,6 +732,7 @@ impl From 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}")), diff --git a/crates/lib/src/qvm/libquil.rs b/crates/lib/src/qvm/libquil.rs index 1bb640118..3c583a547 100644 --- a/crates/lib/src/qvm/libquil.rs +++ b/crates/lib/src/qvm/libquil.rs @@ -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, @@ -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)?; diff --git a/crates/lib/src/qvm/mod.rs b/crates/lib/src/qvm/mod.rs index e71d84728..e7fae1c6d 100644 --- a/crates/lib/src/qvm/mod.rs +++ b/crates/lib/src/qvm/mod.rs @@ -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}, @@ -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,