Pattern Atlas

Extended Quantum Computing Patterns

Ad-hoc Hybrid Code Execution

Aliases:

Tags:

© https://www.scitepress.org/Link.aspx?doi=10.5220/0012057700003538

Intent

How to execute quantum circuits with classical pre- and post-processing steps with no additional deployment or integration requirements?

Context

Often it is necessary to execute standalone quantum circuits with their classical pre- and post-processing steps without incurring extra overhead to deploy, run, and manage them in the cloud.

Forces

Similar to STANDALONE CIRCUIT EXECUTION. However, using this pattern prevents integrating the classical pre- and post-processing steps. Using local or provider-managed development environments reduces management efforts, e.g., execution of quantum and classical code via single commands.

Solution

Use provider-managed code editors or local editors with manually-added token-based authentication. Figure 3 shows the execution of quantum circuits and classical code using AD-HOC HYBRID CODE EXECUTION. The classical pre- and post-processing steps run in a local or remote code editor. The quantum circuits are executed via function calls, often provided by the programming language or quantum SDK, transmitting the quantum circuit to the quantum cloud offering.

Solution Sketch for Ad-hoc Hybrid Code Execution

Result

This pattern offers developers more control over the execution of quantum and classical parts, e.g., token management or request construction via SDKs, than the STANDALONE CIRCUIT EXECUTION pattern. However, integration with external applications is often limited, which makes it unsuitable for designing larger applications or running several distinct computations. After a successful ad-hoc execution of quantum circuits and their classical pre- and post-processing steps, all artifacts can be packaged and deployed to a compatible offering or published via application marketplaces to simplify their reuse.

Related Patterns

Classical pre-processing steps include STATE PREPARATION, which can be done using, e.g., BASIS ENCODING or ANGLE ENCODING [Weigold et al., 2020]. Post-processing steps comprise, e.g., READOUT ERROR MITIGATION [Beisel et al., 2022]. If multiple quantum circuits must be executed, PRIORITIZED EXECUTION can be used to increase efficiency.

Known Uses

This pattern is supported by various vendors. For example, iPython notebooks are provided as remote code editors by Amazon with Braket [AWS, 2023], IBM with Qiskit [IBM, 2023b], and Google with Cirq [Google, 2020]. Local code editors support different languages via dedicated packages, e.g., Rigettis pyQuil and Forest SDK [Rigetti, 2023a]. Authentication to quantum services is then performed via manual configuration of access tokens.