uniqc.pytorch.batch_executor module#

Batch execution utilities for quantum circuits.

Provides parallel execution of multiple circuits using ThreadPoolExecutor or multiprocessing for performance optimization.

uniqc.pytorch.batch_executor.batch_execute(circuits, executor, n_workers=4)[source]#

Execute multiple circuits in parallel.

Parameters:
  • circuits (list[Circuit]) – List of circuits to execute

  • executor (Callable[[Circuit], np.ndarray]) – Function that executes a single circuit and returns results

  • n_workers (int) – Number of parallel workers (threads)

Returns:

List of results from each circuit execution

Return type:

list[np.ndarray]

Example

>>> def simulate(c):
...     sim = OriginIR_Simulator()
...     return sim.simulate(c.originir)
>>> results = batch_execute([c1, c2, c3], simulate, n_workers=4)
uniqc.pytorch.batch_executor.batch_execute_with_params(circuit_template, param_values, executor, n_workers=4)[source]#

Execute a circuit template with different parameter bindings.

Creates multiple bound circuits from a template and executes them in parallel.

Parameters:
  • circuit_template (Circuit) – Circuit template with symbolic parameters

  • param_values (list[dict[str, float]]) – List of parameter value dictionaries to bind

  • executor (Callable[[Circuit], np.ndarray]) – Function that executes a single circuit

  • n_workers (int) – Number of parallel workers

Returns:

List of results from each parameter binding

Return type:

list[np.ndarray]

Example

>>> params = [{'theta': 0.1}, {'theta': 0.2}, {'theta': 0.3}]
>>> results = batch_execute_with_params(circuit, params, simulate)