qcmet.benchmarks.UpperBoundOnVD#
- class qcmet.benchmarks.UpperBoundOnVD(target_circuit, mu=0.1, eta=0.95, qubits=None, seed=None, save_path=None)[source]#
Implementation of the upper bound on the variation distance (VD) metric.
This class generates a number of trap circuits with similar structure to that of a given target circuit, according to the quantum accreditation protocol (AP). The trap circuits should output zero states in the noiseless case, thereby the number of non-zero outputs is used to compute the upper bound on the VD.
- __init__(target_circuit, mu=0.1, eta=0.95, qubits=None, seed=None, save_path=None)[source]#
Initialize the upper bound on the VD benchmark.
- Parameters:
target_circuit (QuantumCircuit) – A target circuit to estimate the upper bound on VD for. The target circuit must follow the restriction such that it has alternating cycles of one-qubit and two-qubit gates, and the two-qubit gates must be CZ gates.
mu (float, optional) – The desired accuracy of the benchmark ∈ (0, 1). Defaults to 0.1.
eta (float, optional) – The desired confidence of the benchmark ∈ (0, 1). Defaults to 0.95.
qubits (int | List[int]) – The number of qubits as either a list of qubit indices or int specifying number of qubits. Defaults to number of qubits in target circuit.
seed (int, optional) – Random seed to use for randomisations. Defaults to None.
save_path (str | Path | FileManager | None, optional) – Directory path to save results. Defaults to None.
Methods
__init__(target_circuit[, mu, eta, qubits, ...])Initialize the upper bound on the VD benchmark.
analyze()Analyze measurements to return benchmark results.
generate_circuits()Generate benchmark circuits, user facing.
generate_example_target_circuit(num_qubits, ...)Randomly generate an example target circuit that satisfies the restriction.
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.
parse_target_circuit(target_circuit)Parse the target circuit's structure.
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
circuitsGets all benchmark circuits.
experiment_dataGetter for experiment_data dataframe.
num_qubitsNumber of qubits in this benchmark.
- parse_target_circuit(target_circuit)[source]#
Parse the target circuit’s structure.
This method breaks down the circuit structure in terms of alternating cycles of one- and two-qubit gates. Each cycle starts with one-qubit gate(s) and ends with (possibly parallel) two-qubit gate(s). Gates up to the next non-parallel two-qubit gate becomes the next cycle. A dictionary is generated for each cycle, which tells for each qubit in this cycle whether one-qubit gate(s) or a two-qubit gate is existent on this qubit. This information is later used for constructing trap circuits.
- Parameters:
target_circuit (QuantumCircuit) – The target circuit to parse.
- Returns:
The list of circuit structure information, one element for each cycle. Each element is a dict: { “1q”: [bool], “2q”: [[int, int, CircuitInstruction]] }. The 1q list in dict has length equal to the number of qubits, which tells whether a one-qubit gate exists for each qubit. The 2q list has length equal to the number of parallel two-qubit gates in this cycle, and contains the qubit indices and the 2q gate itself.
- Return type: