mqt.problemsolver.resource_estimation.error_budget_optimization

Submodules

Package Contents

evaluate(x: numpy.typing.NDArray[numpy.float64], y: numpy.typing.NDArray[numpy.float64], total_budget: float) → list[float][source]

Evaluates the impact of different error budget partitions on quantum resource estimates.

Parameters:
  • x – A 2D array where each row contains quantum circuit logical counts (numQubits, tCount, rotationCount, etc.).

  • y – A 2D array where each row contains error budgets for logical, t_states, and rotations.

  • total_budget – The total error budget to be distributed among components.

Returns:

List of relative differences in the product of qubits and runtime compared to the default budget distribution.

plot_results(product_diffs: list[float], product_diffs_optimal: list[float], legend: bool = False, bin_width: int = 4) → None[source]

Plots histograms comparing predicted and optimal space-time differences.

This function visualizes the distribution of space-time differences (in percent) for predicted and optimal product distributions. It overlays two histograms for comparison and customizes axis ticks, labels, and legend.

Parameters:
  • product_diffs – List of space-time differences for predicted distributions.

  • product_diffs_optimal – List of space-time differences for best found distributions.

  • legend – Whether to display the legend on the plot. Defaults to False.

  • bin_width – Width of histogram bins. Defaults to 4.

generate_data(total_error_budget: float, number_of_randomly_generated_distributions: int, path: str | Path | None = None, benchmarks_and_sizes: list[tuple[str, list[int]]] | None = None, logical_counts: list[OrderedDict[str, int]] | None = None) → list[OrderedDict[str, float | int]][source]

Generates a dataset consisting of logical counts of quantum circuits and respective optimized error budgets.

This function searches for QASM files in the given directory, loads each circuit, estimates its logical counts, and computes optimized error budget partitions using random sampling. For each circuit, it collects relevant counts and the optimal error budget distribution, appending the results to a list.

Parameters:
  • total_error_budget – The total error budget to be distributed among error types.

  • number_of_randomly_generated_distributions – The number of random distributions to try.

  • path – Path to a directory with .qasm files or a .zip file containing them.

  • benchmarks_and_sizes – A list of benchmark specifications to generate circuits on the fly.

  • logical_counts – A list of logical counts dictionaries to process directly.

Returns:

A list of lists, where each inner list contains circuit-specific counts and the corresponding optimized error budget partition.

train(data: list[OrderedDict[str, float | int]]) → tuple[sklearn.ensemble.RandomForestRegressor, numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]][source]

Trains a Random Forest Regressor on the provided data.

The function processes the input data to separate features and targets, splits the data into training and testing sets, and then trains a Random Forest Regressor on the training set.

Parameters:

data – Training data generated by generate_data().

Returns:

  • The trained Random Forest Regressor.

  • The testing set features.

  • The testing set targets.