qcs_api_client_grpc/gen/
services.translation.rs

1// Copyright 2023 Rigetti Computing
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15
16// This file is @generated by prost-build.
17/// Options specified on RPCs that translate Quil to a ControllerJob. Intended to support custom pre-processing
18/// and other translation features.
19#[derive(Clone, PartialEq, ::prost::Message)]
20pub struct TranslationOptions {
21    /// When set, the client program will be pre-processed via the Q-CTRL API
22    /// before translation.
23    #[prost(message, optional, tag = "1")]
24    pub q_ctrl: ::core::option::Option<translation_options::QCtrl>,
25    #[prost(message, optional, tag = "2")]
26    pub riverlane: ::core::option::Option<translation_options::Riverlane>,
27    /// The backend to use for translation, to include relevant options.
28    /// If neither is specified, the implementing service may select the
29    /// translation backend and options.
30    #[prost(oneof = "translation_options::TranslationBackend", tags = "101, 102")]
31    pub translation_backend: ::core::option::Option<
32        translation_options::TranslationBackend,
33    >,
34}
35/// Nested message and enum types in `TranslationOptions`.
36pub mod translation_options {
37    #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
38    pub struct QCtrl {
39        /// Indicates whether Q-CTRL pre-processing should consider the set of
40        /// program qubits to be fixed. If true, Q-CTRL may only remap qubits to
41        /// others specified within the user-submitted program. If false, Q-CTRL may
42        /// remap program qubits to any physical qubit on the device in order to
43        /// optimize the program.
44        ///
45        /// Note, this attribute is used to set `fixed_layouts` attribute on Q-CTRL's
46        /// `CompileOptions` message. Q-CTRL supports compilation of mutliple programs
47        /// at once, while Rigetti's `TranslationOptions` are currently scoped to a
48        /// single program. As such, we use `fixed_layout` rather than `fixed_layouts`.
49        #[prost(bool, optional, tag = "1")]
50        pub fixed_layout: ::core::option::Option<bool>,
51    }
52    #[derive(Clone, PartialEq, ::prost::Message)]
53    pub struct Riverlane {
54        /// The (opaque) configuration data, per instrument, to send to Riverlane's QECi box(es).
55        #[prost(map = "string, bytes", tag = "2")]
56        pub qeci_configuration_data: ::std::collections::HashMap<
57            ::prost::alloc::string::String,
58            ::prost::alloc::vec::Vec<u8>,
59        >,
60        /// The maximum expected latency between a `qeci_csr_read_request` extern
61        /// call and receiving the data with the `is_qeci_csr_read_complete` extern
62        #[prost(uint64, tag = "3")]
63        pub qeci_max_nanoseconds_until_read_available: u64,
64    }
65    /// The backend to use for translation, to include relevant options.
66    /// If neither is specified, the implementing service may select the
67    /// translation backend and options.
68    #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
69    pub enum TranslationBackend {
70        #[prost(message, tag = "101")]
71        V1(super::BackendV1Options),
72        #[prost(message, tag = "102")]
73        V2(super::BackendV2Options),
74    }
75}
76/// Options for translation backend V1
77#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
78pub struct BackendV1Options {}
79/// Options for translation backend V2
80#[derive(Clone, Copy, PartialEq, ::prost::Message)]
81pub struct BackendV2Options {
82    /// Whether to prepend the default calibrations for a particular QPU to the program.
83    /// This may be set to false if you have prepended your own calibrations, or are submitting
84    /// a pre-calibrated pulse-level program which does not need further expansion.
85    #[prost(bool, optional, tag = "1")]
86    pub prepend_default_calibrations: ::core::option::Option<bool>,
87    /// The number of seconds to stall at the beginning of each num-shots loop iteration in order to allow adiabatic reset.
88    #[prost(double, optional, tag = "2")]
89    pub passive_reset_delay_seconds: ::core::option::Option<f64>,
90    /// Whether to disable bounds checks on dynamic memory access. Only available to authorized users.
91    #[prost(bool, optional, tag = "4")]
92    pub allow_unchecked_pointer_arithmetic: ::core::option::Option<bool>,
93    /// Whether to skip program frame validation against Rigetti calibrations.
94    #[prost(bool, optional, tag = "5")]
95    pub allow_frame_redefinition: ::core::option::Option<bool>,
96    /// Whether to force all real-time-classified readout values to be stored in sequencer memory. If false or unset, only readout values that are
97    /// read by the program are written to sequencer memory following readout.
98    #[prost(bool, optional, tag = "6")]
99    pub store_all_readout_values: ::core::option::Option<bool>,
100}
101#[derive(Clone, PartialEq, ::prost::Message)]
102pub struct TranslateQuilToEncryptedControllerJobRequest {
103    #[prost(string, tag = "1")]
104    pub quantum_processor_id: ::prost::alloc::string::String,
105    #[prost(string, tag = "2")]
106    pub quil_program: ::prost::alloc::string::String,
107    /// Specification of optional translation features.
108    #[prost(message, optional, tag = "4")]
109    pub options: ::core::option::Option<TranslationOptions>,
110    #[prost(
111        oneof = "translate_quil_to_encrypted_controller_job_request::NumShots",
112        tags = "3"
113    )]
114    pub num_shots: ::core::option::Option<
115        translate_quil_to_encrypted_controller_job_request::NumShots,
116    >,
117}
118/// Nested message and enum types in `TranslateQuilToEncryptedControllerJobRequest`.
119pub mod translate_quil_to_encrypted_controller_job_request {
120    #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
121    pub enum NumShots {
122        #[prost(uint32, tag = "3")]
123        NumShotsValue(u32),
124    }
125}
126#[derive(Clone, PartialEq, ::prost::Message)]
127pub struct TranslateQuilToEncryptedControllerJobResponse {
128    #[prost(message, optional, tag = "1")]
129    pub job: ::core::option::Option<
130        super::super::models::controller::EncryptedControllerJob,
131    >,
132    #[prost(message, optional, tag = "2")]
133    pub metadata: ::core::option::Option<
134        super::super::models::translation::QuilTranslationMetadata,
135    >,
136}
137#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
138pub struct QuantumProcessorQuilCalibrationProgram {
139    /// The Quil program containing the requested calibrations
140    #[prost(string, tag = "1")]
141    pub quil_calibration_program: ::prost::alloc::string::String,
142}
143#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
144pub struct GetQuantumProcessorQuilCalibrationProgramRequest {
145    /// The quantum processor for which to retrieve the calibration program.
146    #[prost(string, tag = "1")]
147    pub quantum_processor_id: ::prost::alloc::string::String,
148}
149/// Generated client implementations.
150pub mod translation_client {
151    #![allow(
152        unused_variables,
153        dead_code,
154        missing_docs,
155        clippy::wildcard_imports,
156        clippy::let_unit_value,
157    )]
158    use tonic::codegen::*;
159    use tonic::codegen::http::Uri;
160    #[derive(Debug, Clone)]
161    pub struct TranslationClient<T> {
162        inner: tonic::client::Grpc<T>,
163    }
164    impl TranslationClient<tonic::transport::Channel> {
165        /// Attempt to create a new client by connecting to a given endpoint.
166        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
167        where
168            D: TryInto<tonic::transport::Endpoint>,
169            D::Error: Into<StdError>,
170        {
171            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
172            Ok(Self::new(conn))
173        }
174    }
175    impl<T> TranslationClient<T>
176    where
177        T: tonic::client::GrpcService<tonic::body::Body>,
178        T::Error: Into<StdError>,
179        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
180        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
181    {
182        pub fn new(inner: T) -> Self {
183            let inner = tonic::client::Grpc::new(inner);
184            Self { inner }
185        }
186        pub fn with_origin(inner: T, origin: Uri) -> Self {
187            let inner = tonic::client::Grpc::with_origin(inner, origin);
188            Self { inner }
189        }
190        pub fn with_interceptor<F>(
191            inner: T,
192            interceptor: F,
193        ) -> TranslationClient<InterceptedService<T, F>>
194        where
195            F: tonic::service::Interceptor,
196            T::ResponseBody: Default,
197            T: tonic::codegen::Service<
198                http::Request<tonic::body::Body>,
199                Response = http::Response<
200                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
201                >,
202            >,
203            <T as tonic::codegen::Service<
204                http::Request<tonic::body::Body>,
205            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
206        {
207            TranslationClient::new(InterceptedService::new(inner, interceptor))
208        }
209        /// Compress requests with the given encoding.
210        ///
211        /// This requires the server to support it otherwise it might respond with an
212        /// error.
213        #[must_use]
214        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
215            self.inner = self.inner.send_compressed(encoding);
216            self
217        }
218        /// Enable decompressing responses.
219        #[must_use]
220        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
221            self.inner = self.inner.accept_compressed(encoding);
222            self
223        }
224        /// Limits the maximum size of a decoded message.
225        ///
226        /// Default: `4MB`
227        #[must_use]
228        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
229            self.inner = self.inner.max_decoding_message_size(limit);
230            self
231        }
232        /// Limits the maximum size of an encoded message.
233        ///
234        /// Default: `usize::MAX`
235        #[must_use]
236        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
237            self.inner = self.inner.max_encoding_message_size(limit);
238            self
239        }
240        pub async fn translate_quil_to_encrypted_controller_job(
241            &mut self,
242            request: impl tonic::IntoRequest<
243                super::TranslateQuilToEncryptedControllerJobRequest,
244            >,
245        ) -> std::result::Result<
246            tonic::Response<super::TranslateQuilToEncryptedControllerJobResponse>,
247            tonic::Status,
248        > {
249            self.inner
250                .ready()
251                .await
252                .map_err(|e| {
253                    tonic::Status::unknown(
254                        format!("Service was not ready: {}", e.into()),
255                    )
256                })?;
257            let codec = tonic_prost::ProstCodec::default();
258            let path = http::uri::PathAndQuery::from_static(
259                "/services.translation.Translation/TranslateQuilToEncryptedControllerJob",
260            );
261            let mut req = request.into_request();
262            req.extensions_mut()
263                .insert(
264                    GrpcMethod::new(
265                        "services.translation.Translation",
266                        "TranslateQuilToEncryptedControllerJob",
267                    ),
268                );
269            self.inner.unary(req, path, codec).await
270        }
271        /// Get the current calibration program for the given quantum processor.
272        pub async fn get_quantum_processor_quil_calibration_program(
273            &mut self,
274            request: impl tonic::IntoRequest<
275                super::GetQuantumProcessorQuilCalibrationProgramRequest,
276            >,
277        ) -> std::result::Result<
278            tonic::Response<super::QuantumProcessorQuilCalibrationProgram>,
279            tonic::Status,
280        > {
281            self.inner
282                .ready()
283                .await
284                .map_err(|e| {
285                    tonic::Status::unknown(
286                        format!("Service was not ready: {}", e.into()),
287                    )
288                })?;
289            let codec = tonic_prost::ProstCodec::default();
290            let path = http::uri::PathAndQuery::from_static(
291                "/services.translation.Translation/GetQuantumProcessorQuilCalibrationProgram",
292            );
293            let mut req = request.into_request();
294            req.extensions_mut()
295                .insert(
296                    GrpcMethod::new(
297                        "services.translation.Translation",
298                        "GetQuantumProcessorQuilCalibrationProgram",
299                    ),
300                );
301            self.inner.unary(req, path, codec).await
302        }
303    }
304}
305/// Generated server implementations.
306#[cfg(feature = "server")]
307pub mod translation_server {
308    #![allow(
309        unused_variables,
310        dead_code,
311        missing_docs,
312        clippy::wildcard_imports,
313        clippy::let_unit_value,
314    )]
315    use tonic::codegen::*;
316    /// Generated trait containing gRPC methods that should be implemented for use with TranslationServer.
317    #[async_trait]
318    pub trait Translation: std::marker::Send + std::marker::Sync + 'static {
319        async fn translate_quil_to_encrypted_controller_job(
320            &self,
321            request: tonic::Request<super::TranslateQuilToEncryptedControllerJobRequest>,
322        ) -> std::result::Result<
323            tonic::Response<super::TranslateQuilToEncryptedControllerJobResponse>,
324            tonic::Status,
325        >;
326        /// Get the current calibration program for the given quantum processor.
327        async fn get_quantum_processor_quil_calibration_program(
328            &self,
329            request: tonic::Request<
330                super::GetQuantumProcessorQuilCalibrationProgramRequest,
331            >,
332        ) -> std::result::Result<
333            tonic::Response<super::QuantumProcessorQuilCalibrationProgram>,
334            tonic::Status,
335        >;
336    }
337    #[derive(Debug)]
338    pub struct TranslationServer<T> {
339        inner: Arc<T>,
340        accept_compression_encodings: EnabledCompressionEncodings,
341        send_compression_encodings: EnabledCompressionEncodings,
342        max_decoding_message_size: Option<usize>,
343        max_encoding_message_size: Option<usize>,
344    }
345    impl<T> TranslationServer<T> {
346        pub fn new(inner: T) -> Self {
347            Self::from_arc(Arc::new(inner))
348        }
349        pub fn from_arc(inner: Arc<T>) -> Self {
350            Self {
351                inner,
352                accept_compression_encodings: Default::default(),
353                send_compression_encodings: Default::default(),
354                max_decoding_message_size: None,
355                max_encoding_message_size: None,
356            }
357        }
358        pub fn with_interceptor<F>(
359            inner: T,
360            interceptor: F,
361        ) -> InterceptedService<Self, F>
362        where
363            F: tonic::service::Interceptor,
364        {
365            InterceptedService::new(Self::new(inner), interceptor)
366        }
367        /// Enable decompressing requests with the given encoding.
368        #[must_use]
369        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
370            self.accept_compression_encodings.enable(encoding);
371            self
372        }
373        /// Compress responses with the given encoding, if the client supports it.
374        #[must_use]
375        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
376            self.send_compression_encodings.enable(encoding);
377            self
378        }
379        /// Limits the maximum size of a decoded message.
380        ///
381        /// Default: `4MB`
382        #[must_use]
383        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
384            self.max_decoding_message_size = Some(limit);
385            self
386        }
387        /// Limits the maximum size of an encoded message.
388        ///
389        /// Default: `usize::MAX`
390        #[must_use]
391        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
392            self.max_encoding_message_size = Some(limit);
393            self
394        }
395    }
396    impl<T, B> tonic::codegen::Service<http::Request<B>> for TranslationServer<T>
397    where
398        T: Translation,
399        B: Body + std::marker::Send + 'static,
400        B::Error: Into<StdError> + std::marker::Send + 'static,
401    {
402        type Response = http::Response<tonic::body::Body>;
403        type Error = std::convert::Infallible;
404        type Future = BoxFuture<Self::Response, Self::Error>;
405        fn poll_ready(
406            &mut self,
407            _cx: &mut Context<'_>,
408        ) -> Poll<std::result::Result<(), Self::Error>> {
409            Poll::Ready(Ok(()))
410        }
411        fn call(&mut self, req: http::Request<B>) -> Self::Future {
412            match req.uri().path() {
413                "/services.translation.Translation/TranslateQuilToEncryptedControllerJob" => {
414                    #[allow(non_camel_case_types)]
415                    struct TranslateQuilToEncryptedControllerJobSvc<T: Translation>(
416                        pub Arc<T>,
417                    );
418                    impl<
419                        T: Translation,
420                    > tonic::server::UnaryService<
421                        super::TranslateQuilToEncryptedControllerJobRequest,
422                    > for TranslateQuilToEncryptedControllerJobSvc<T> {
423                        type Response = super::TranslateQuilToEncryptedControllerJobResponse;
424                        type Future = BoxFuture<
425                            tonic::Response<Self::Response>,
426                            tonic::Status,
427                        >;
428                        fn call(
429                            &mut self,
430                            request: tonic::Request<
431                                super::TranslateQuilToEncryptedControllerJobRequest,
432                            >,
433                        ) -> Self::Future {
434                            let inner = Arc::clone(&self.0);
435                            let fut = async move {
436                                <T as Translation>::translate_quil_to_encrypted_controller_job(
437                                        &inner,
438                                        request,
439                                    )
440                                    .await
441                            };
442                            Box::pin(fut)
443                        }
444                    }
445                    let accept_compression_encodings = self.accept_compression_encodings;
446                    let send_compression_encodings = self.send_compression_encodings;
447                    let max_decoding_message_size = self.max_decoding_message_size;
448                    let max_encoding_message_size = self.max_encoding_message_size;
449                    let inner = self.inner.clone();
450                    let fut = async move {
451                        let method = TranslateQuilToEncryptedControllerJobSvc(inner);
452                        let codec = tonic_prost::ProstCodec::default();
453                        let mut grpc = tonic::server::Grpc::new(codec)
454                            .apply_compression_config(
455                                accept_compression_encodings,
456                                send_compression_encodings,
457                            )
458                            .apply_max_message_size_config(
459                                max_decoding_message_size,
460                                max_encoding_message_size,
461                            );
462                        let res = grpc.unary(method, req).await;
463                        Ok(res)
464                    };
465                    Box::pin(fut)
466                }
467                "/services.translation.Translation/GetQuantumProcessorQuilCalibrationProgram" => {
468                    #[allow(non_camel_case_types)]
469                    struct GetQuantumProcessorQuilCalibrationProgramSvc<T: Translation>(
470                        pub Arc<T>,
471                    );
472                    impl<
473                        T: Translation,
474                    > tonic::server::UnaryService<
475                        super::GetQuantumProcessorQuilCalibrationProgramRequest,
476                    > for GetQuantumProcessorQuilCalibrationProgramSvc<T> {
477                        type Response = super::QuantumProcessorQuilCalibrationProgram;
478                        type Future = BoxFuture<
479                            tonic::Response<Self::Response>,
480                            tonic::Status,
481                        >;
482                        fn call(
483                            &mut self,
484                            request: tonic::Request<
485                                super::GetQuantumProcessorQuilCalibrationProgramRequest,
486                            >,
487                        ) -> Self::Future {
488                            let inner = Arc::clone(&self.0);
489                            let fut = async move {
490                                <T as Translation>::get_quantum_processor_quil_calibration_program(
491                                        &inner,
492                                        request,
493                                    )
494                                    .await
495                            };
496                            Box::pin(fut)
497                        }
498                    }
499                    let accept_compression_encodings = self.accept_compression_encodings;
500                    let send_compression_encodings = self.send_compression_encodings;
501                    let max_decoding_message_size = self.max_decoding_message_size;
502                    let max_encoding_message_size = self.max_encoding_message_size;
503                    let inner = self.inner.clone();
504                    let fut = async move {
505                        let method = GetQuantumProcessorQuilCalibrationProgramSvc(inner);
506                        let codec = tonic_prost::ProstCodec::default();
507                        let mut grpc = tonic::server::Grpc::new(codec)
508                            .apply_compression_config(
509                                accept_compression_encodings,
510                                send_compression_encodings,
511                            )
512                            .apply_max_message_size_config(
513                                max_decoding_message_size,
514                                max_encoding_message_size,
515                            );
516                        let res = grpc.unary(method, req).await;
517                        Ok(res)
518                    };
519                    Box::pin(fut)
520                }
521                _ => {
522                    Box::pin(async move {
523                        let mut response = http::Response::new(
524                            tonic::body::Body::default(),
525                        );
526                        let headers = response.headers_mut();
527                        headers
528                            .insert(
529                                tonic::Status::GRPC_STATUS,
530                                (tonic::Code::Unimplemented as i32).into(),
531                            );
532                        headers
533                            .insert(
534                                http::header::CONTENT_TYPE,
535                                tonic::metadata::GRPC_CONTENT_TYPE,
536                            );
537                        Ok(response)
538                    })
539                }
540            }
541        }
542    }
543    impl<T> Clone for TranslationServer<T> {
544        fn clone(&self) -> Self {
545            let inner = self.inner.clone();
546            Self {
547                inner,
548                accept_compression_encodings: self.accept_compression_encodings,
549                send_compression_encodings: self.send_compression_encodings,
550                max_decoding_message_size: self.max_decoding_message_size,
551                max_encoding_message_size: self.max_encoding_message_size,
552            }
553        }
554    }
555    /// Generated gRPC service name
556    pub const SERVICE_NAME: &str = "services.translation.Translation";
557    impl<T> tonic::server::NamedService for TranslationServer<T> {
558        const NAME: &'static str = SERVICE_NAME;
559    }
560}
561