Skip to content

Commit ef1cd1c

Browse files
chore: 4gb limit, improve clarity on const names like the ai desires
1 parent 66875fb commit ef1cd1c

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/lib/src/client.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! initialize those clients (e.g. with authentication metadata).
44
55
use std::time::Duration;
6-
use std::usize;
76

87
use qcs_api_client_common::configuration::{ClientConfiguration, TokenError};
98
#[cfg(feature = "tracing")]
@@ -28,8 +27,8 @@ pub use qcs_api_client_common::configuration::LoadError;
2827
pub use qcs_api_client_grpc::tonic::Error as GrpcError;
2928
pub use qcs_api_client_openapi::apis::Error as OpenApiError;
3029

31-
/// The maximum size of a gRPC response to the translation service, in bytes.
32-
const MAX_TRANSLATION_REQUEST_SIZE: usize = 50 * 1024 * 1024;
30+
/// The maximum size of a gRPC request to the translation service, in bytes.
31+
const MAX_TRANSLATION_OUTBOUND_REQUEST_SIZE: usize = 50 * 1024 * 1024;
3332

3433
/// A type alias for the underlying gRPC connection used by all gRPC clients within this library.
3534
/// It is public so that users can create gRPC clients with different APIs using a "raw" connection
@@ -138,9 +137,10 @@ impl Qcs {
138137
#[cfg(feature = "grpc-web")]
139138
let channel = wrap_channel_with_grpc_web(service);
140139
Ok(TranslationClient::new(channel)
141-
.max_encoding_message_size(MAX_TRANSLATION_REQUEST_SIZE)
142-
// do not limit the received response size - practically, the limit is 4Gb.
143-
.max_decoding_message_size(usize::MAX))
140+
.max_encoding_message_size(MAX_TRANSLATION_OUTBOUND_REQUEST_SIZE)
141+
// do not limit the received response size, although practically the limit is 4Gb due
142+
// to the frame_length of the message being a u32.
143+
.max_decoding_message_size(u32::MAX as usize))
144144
}
145145
}
146146

crates/lib/src/qpu/api.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use crate::executable::Parameters;
4545
use crate::client::{GrpcClientError, GrpcConnection, Qcs};
4646

4747
/// The maximum size of a gRPC request to the controller service, in bytes.
48-
const MAX_CONTROLLER_REQUEST_SIZE: usize = 250 * 1024 * 1024;
48+
const MAX_CONTROLLER_OUTBOUND_REQUEST_SIZE: usize = 250 * 1024 * 1024;
4949

5050
pub(crate) fn params_into_job_execution_configuration(
5151
params: &Parameters,
@@ -539,9 +539,10 @@ pub trait ExecutionTarget<'a> {
539539
.get_qpu_grpc_connection(client, quantum_processor_id)
540540
.await?;
541541
Ok(ControllerClient::new(service)
542-
.max_encoding_message_size(MAX_CONTROLLER_REQUEST_SIZE)
543-
// do not limit the received response size - practically, the limit is 4Gb.
544-
.max_decoding_message_size(usize::MAX))
542+
.max_encoding_message_size(MAX_CONTROLLER_OUTBOUND_REQUEST_SIZE)
543+
// do not limit the received response size, although practically the limit is 4Gb due
544+
// to the frame_length of the message being a u32.
545+
.max_decoding_message_size(u32::MAX as usize))
545546
}
546547

547548
/// Get a GRPC connection to a QPU, without specifying the API to use.

0 commit comments

Comments
 (0)