# Iterative and batch workloads

> Understanding how Fire Opal can optimize workloads that require multiple jobs

Source: https://docs.q-ctrl.com/fire-opal/execute/submit-jobs/iterative-and-batch-workloads

It’s common for many quantum algorithms to require a large number of circuits that must be split across multiple independent jobs. This scenario is often the case for popular categories of algorithms such as variational algorithms or Quantum Machine Learning (QML).

Typically, workloads that require multiple jobs fall into one of two categories:
1. Variational quantum algorithms (VQAs)
2. Batch workloads

Both of these workflows can be easily accommodated using Fire Opal's `iterate` feature, which is designed for multi-job submission. The benefit of using `iterate` is that it optimizes the submission of multiple jobs to ensure that your pre-processing time is shortened and you don’t lose your place in the device queue.

For example, when you submit jobs to the IBM Quantum Platform with `iterate`, a [Qiskit Runtime session](https://quantum.cloud.ibm.com/docs/en/guides/run-jobs-session) is automatically created and managed in the background. This enables you to execute multiple jobs from a single algorithm run without the interruption of having to rejoin the queue. When you’re finished with your workload, simply call `stop_iterate`, which will promptly close the session. Fire Opal takes care of all of the hardware optimization, session management, and queueing for you.

## Running variational quantum algorithms
Also known as hybrid algorithms, VQAs combine quantum and classical computation. The algorithm alternates between quantum execution and classical optimization, with the latter deciding the next set of inputs to be fed into the quantum execution. This process is repeated until an answer is found that is considered "good enough."

You can design your own variational algorithm, and use the `iterate` function to apply error suppression and run the job. Behind the scenes, Fire Opal will optimize your job execution so that subsequent jobs do not need to rejoin the device queue, if a hardware provider enables this functionality. [Using a parameterized quantum circuit](https://docs.q-ctrl.com/fire-opal/execute/configure-circuits/how-to-run-parameterized-quantum-circuits.md) is highly recommended and will reduce preprocessing time.

Alternatively, you can use [Fire Opal's QAOA Solver](https://docs.q-ctrl.com/fire-opal/execute/configure-circuits/how-to-run-parameterized-quantum-circuits.md) to run the algorithm in a single command, which manages the entire hybrid execution and optimizes for real hardware performance.

Learn [how to run variational algorithms using the `iterate` function](https://docs.q-ctrl.com/fire-opal/execute/run-algorithms/how-to-run-custom-variational-algorithms.md).

## Running batch workloads
Fire Opal enables up to 300 circuits to be sent within a single batch, but many use cases, such as Quantum Machine Learning, will require far more than 300 circuits that must be split across multiple jobs, which make up a "batch". For longer circuits, it's recommended to send fewer circuits per job to avoid exceeding payload limitations.

The `iterate` function connects multiple jobs so that they run in sequence without having to rejoin the device queue, if a hardware provider offers that functionality.

In cases where many circuits are required, you can typically [use a parameterized quantum circuit](https://docs.q-ctrl.com/fire-opal/execute/configure-circuits/how-to-run-parameterized-quantum-circuits.md) with unbound parameters to dramatically reduce total preprocessing time.

Learn [how to run batch workloads using the `iterate` function](https://docs.q-ctrl.com/fire-opal/execute/submit-jobs/how-to-run-batch-workloads.md).
