Blog
15
July
,
2025

ExecutionSession and Its Use in Hybrid Algorithms

Share the article
Our library

Hybrid quantum algorithms are prominent in the quantum computing world, and extensive research has focused on hybrid schemes to harness the power of quantum computers. Notable examples include QAOA, VQE, QNN, and more. At their core, hybrid algorithms involve an iterative process alternating between classical and quantum computation, where the latter is manifested in the form of sampling quantum circuits, yielding measured state counts.⁣⁣

At Classiq, we provide a method for designing, debugging and executing hybrid algorithms that is both straightforward and efficient. Our Python SDK features the 𝘌𝘹𝘦𝘤𝘶𝘵𝘪𝘰𝘯𝘚𝘦𝘴𝘴𝘪𝘰𝘯 class, which enables the execution (both on simulators and real hardware) of a complex hybrid algorithm on a single quantum program, typically parametrized. This approach facilitates the iterative process and allows multiple calls to execution primitives at a minimal overhead, as the execution session preserves relevant context across iterations. For instance, the quantum program is being transpiled to the target hardware just once.⁣⁣

The execution primitives currently include 𝘴𝘢𝘮𝘱𝘭𝘦, the fundamental building block of quantum computation, and 𝘦𝘴𝘵𝘪𝘮𝘢𝘵𝘦, which calculates the expectation value of a specific Hamiltonian. The 𝘦𝘴𝘵𝘪𝘮𝘢𝘵𝘦 primitive is itself a hybrid algorithm which can be implemented by a series of samples, but is included as a primitive due to its vast applicability. Additionally, on statevector simulators, the expectation value can be computed exactly without sampling, improving both execution speed and accuracy. Each primitive also has a 𝘣𝘢𝘵𝘤𝘩_ variant that allows processing multiple sets of parameters in a single job, and a 𝘴𝘶𝘣𝘮𝘪𝘵_ variant that returns the job object immediately without waiting for results.⁣⁣

Now, let’s implement something interesting! In the following little example, a parametric quantum model prepares a state with probability 1/8 for all states except the states |010> and |110>, whose probabilities are controlled via an execution parameter. The method 𝘌𝘹𝘦𝘤𝘶𝘵𝘪𝘰𝘯𝘚𝘦𝘴𝘴𝘪𝘰𝘯.𝘴𝘢𝘮𝘱𝘭𝘦() is used to sample the distribution for different rotation parameter values.

Hybrid quantum algorithms are prominent in the quantum computing world, and extensive research has focused on hybrid schemes to harness the power of quantum computers. Notable examples include QAOA, VQE, QNN, and more. At their core, hybrid algorithms involve an iterative process alternating between classical and quantum computation, where the latter is manifested in the form of sampling quantum circuits, yielding measured state counts.⁣⁣

At Classiq, we provide a method for designing, debugging and executing hybrid algorithms that is both straightforward and efficient. Our Python SDK features the 𝘌𝘹𝘦𝘤𝘶𝘵𝘪𝘰𝘯𝘚𝘦𝘴𝘴𝘪𝘰𝘯 class, which enables the execution (both on simulators and real hardware) of a complex hybrid algorithm on a single quantum program, typically parametrized. This approach facilitates the iterative process and allows multiple calls to execution primitives at a minimal overhead, as the execution session preserves relevant context across iterations. For instance, the quantum program is being transpiled to the target hardware just once.⁣⁣

The execution primitives currently include 𝘴𝘢𝘮𝘱𝘭𝘦, the fundamental building block of quantum computation, and 𝘦𝘴𝘵𝘪𝘮𝘢𝘵𝘦, which calculates the expectation value of a specific Hamiltonian. The 𝘦𝘴𝘵𝘪𝘮𝘢𝘵𝘦 primitive is itself a hybrid algorithm which can be implemented by a series of samples, but is included as a primitive due to its vast applicability. Additionally, on statevector simulators, the expectation value can be computed exactly without sampling, improving both execution speed and accuracy. Each primitive also has a 𝘣𝘢𝘵𝘤𝘩_ variant that allows processing multiple sets of parameters in a single job, and a 𝘴𝘶𝘣𝘮𝘪𝘵_ variant that returns the job object immediately without waiting for results.⁣⁣

Now, let’s implement something interesting! In the following little example, a parametric quantum model prepares a state with probability 1/8 for all states except the states |010> and |110>, whose probabilities are controlled via an execution parameter. The method 𝘌𝘹𝘦𝘤𝘶𝘵𝘪𝘰𝘯𝘚𝘦𝘴𝘴𝘪𝘰𝘯.𝘴𝘢𝘮𝘱𝘭𝘦() is used to sample the distribution for different rotation parameter values.

About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.

If you would like to suggest a guest for the podcast, please contact us.

See Also

No items found.

Start Creating Quantum Software Without Limits

contact us