qcmet.benchmarks.QFT#

class qcmet.benchmarks.QFT(qubits, save_path=None, seed=0)[source]#

Implementation of the Quantum Fourier Transform (QFT) metric.

This class generates random initial states, applies QFT and inverse QFT with intermediate rotations, measures the output, and computes the fidelity between the device output distribution, against the exact distribution.

__init__(qubits, save_path=None, seed=0)[source]#

Initialize the QFT benchmark.

Parameters:
  • qubits (int | List[int]) – The number of qubits as either a list of qubit indices or int specifying number of qubits.

  • save_path (str | Path | FileManager | None, optional) – Directory path to save results. Defaults to None.

  • seed (int, optional) – Random seed for state initialization. Defaults to 0.

Methods

__init__(qubits[, save_path, seed])

Initialize the QFT benchmark.

analyze()

Analyze measurements to return benchmark results.

convert_binary_keys_to_decimal(dictionary)

Convert dictionary keys from binary strings to decimal integers.

generate_circuits()

Generate benchmark circuits, user facing.

get_exact_probs()

Compute theoretical probabilities based on random initializations.

has_plotting()

Check if _plot function is implemented in benchmark.

load_circuit_measurements(circuit_measurements)

Load measurement counts into the experiment_data DataFrame.

measurements_to_probabilities()

Convert raw measurement counts to normalized probabilities.

order_meas_probs_by_bitstring_decimal_value()

Order measured probabilities by increasing bitstring decimal value.

plot([axes])

Plot benchmark result, user facing.

run([device, num_shots, max_circs_per_job])

Run benchmark.

save()

Save benchmark current state.

set_save_path(save_path)

Set benchmark save path if not set in class constructor.

Attributes

circuits

Gets all benchmark circuits.

experiment_data

Getter for experiment_data dataframe.

num_qubits

Number of qubits in this benchmark.

static convert_binary_keys_to_decimal(dictionary)[source]#

Convert dictionary keys from binary strings to decimal integers.

Parameters:

dictionary (dict) – Mapping of binary-string keys (e.g. ‘0101’) to values.

Returns:

Mapping of decimal integer keys to the same values.

Return type:

dict

Raises:

ValueError – If the input is not a dictionary.

get_exact_probs()[source]#

Compute theoretical probabilities based on random initializations.

Applies the _exact_prob_vector_from_initial_state method to each entry in the random_initialization column of experiment_data. Stores the resulting exact (ideal) probabilities in a new column called exact_probs.

Returns:

The method updates experiment_data in place.

Return type:

None

order_meas_probs_by_bitstring_decimal_value()[source]#

Order measured probabilities by increasing bitstring decimal value.

Converts binary measurement outcomes from meas_prob into their decimal representations. Then constructs a new array ordered_probs where each index corresponds to the decimal value of a bitstring. Missing keys are treated as zero-probability.

Adds two columns to experiment_data: - decimal_probs: a dict mapping int keys (decimal) to probabilities. - ordered_probs: a NumPy array of length 2**num_qubits, ordered by key.

Returns:

The method modifies experiment_data in place.

Return type:

None