How to run parameterized quantum circuits

Running parameterized quantum circuits with Fire Opal

Fire Opal supports the input of a parameterized quantum circuit (PQC) and associated parameter values, delivering huge time and cost savings for key applications. By executing PQCs via Fire Opal, you get all the benefits of the AI-driven error suppression pipeline, while saving compilation time.

A parameterized quantum circuit is a circuit where some gates or operations are defined with a tunable element that may be undefined initially but can be adjusted during computation. These parameters serve as variables that can be adjusted to perform specific tasks or solve particular problems.

PQCs are particularly useful in quantum machine learning, optimization, and other variational algorithms. In these applications, the parameters are often optimized to minimize a cost function, maximize some objective, or solve a specific problem. Classical optimization routines are commonly used to adjust the parameters to achieve the desired outcome. Specifying parameter values to be bound at runtime drastically reduces preprocessing time.

You can input PQCs to either the execute or iterate functions. Both functions accept parameterized quantum circuits and optional lists of dicts, where parameter names are mapped to values.

Fire Opal accepts the following combinations of circuits and parameter dicts:

  • One circuit, multiple parameter dictionaries
  • Many circuits, one parameter dictionary
  • Many circuits and parameter dictionaries (each of the same length)

Example: Running a parameterized quantum circuit

1. Import libraries and set up credentials

import fireopal
from qiskit.circuit import Parameter
from qiskit import QuantumCircuit
from qiskit import qasm3
# These are the properties for the publicly available provider for IBM backends.
# If you have access to a private provider and wish to use it, replace these values.
hub = "ibm-q"
group = "open"
project = "main"
token = "YOUR_IBM_TOKEN"
credentials = fireopal.credentials.make_credentials_for_ibmq(
    token=token, hub=hub, group=group, project=project

2. Define the circuit and parameter values

Fire Opal accepts parameter values as an array of dicts, where each dictionary holds one set of parameters to bind.

# Define circuit and parameter
theta = Parameter("θ")
param_qc = QuantumCircuit(2)
param_qc.ry(theta, 0), 1)

# Define parameter values dict
parameter_values = [{"θ": 0.0}, {"θ": float(np.pi / 6)}, {"θ": float(np.pi / 2)}]
# Set shot count and define backend
# To get a list of supported backends, run fireopal.show_supported_devices(credentials)
shot_count = 2048
backend_name = "desired_backend"

3. Run the circuit

Run the circuit using the execute function if assigning up to 300 parameter dicts. If using more parameters, try submitting multiple jobs using the iterate function.

circuits = [qasm3.dumps(param_qc)]
results = fireopal.execute(

for i in range(3):
    print(f"Parameter: {parameter_values[i][0]:.5f}\t Probabilities: {results[i]}")

Combining the iterate function with parameterized quantum circuits is a simple way to run variational algorithms optimized for device execution and performance.

Was this useful?

cta background

New to Fire Opal?

Get access to everything you need to automate and optimize quantum hardware performance at scale.