Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c6420a2
Initial changes to store extra metrics.
Jul 16, 2025
d443c16
Tested extra metrics with Bernstein-Vazirani.
Jul 16, 2025
e446da4
Fixed polling without additional metrics.
Jul 16, 2025
bb0018e
Updated code comments.
Jul 16, 2025
728b38c
Added "extra_metrics" parameter to benchmarks and tested each.
Jul 16, 2025
6165846
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 16, 2025
6d5eb92
Rewording code comments.
Jul 16, 2025
f47863e
Added core code to plot the metrics.
Jul 16, 2025
eb092fa
Changing plot's name from Qiskit to qBraid.
Jul 16, 2025
a588c19
Fixed title for generated plots.
Jul 16, 2025
5440801
Added filters to remove create and execution time plots.
Jul 16, 2025
87cf987
Added the option to plot and tested with Bernstein-Vazirani.
Jul 16, 2025
08bc3df
Added plot_metrics parameter to other QED-C benchmarks.
Jul 16, 2025
cf38cee
Git ignoring local plot files.
Jul 16, 2025
dd3bc6b
Filtering plots when extra_metrics is false.
Jul 17, 2025
8c51e39
Code reformatting.
Jul 17, 2025
e1d9b00
Updated QEDC_Metrics data type example.
Jul 17, 2025
f05707d
Rewording comment.
Jul 17, 2025
b36d247
Updated code comments.
Jul 17, 2025
ab7ece1
Updated code comment.
Jul 17, 2025
5dcae25
Code cleaning.
Jul 18, 2025
291dc19
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 21, 2025
93da543
Fixing [nit]
Neerpatel125 Jul 21, 2025
6e464d1
Fixing [nit]
Neerpatel125 Jul 21, 2025
9e2ce46
Fixing [nit]
Neerpatel125 Jul 21, 2025
47d1159
Fixing [nit]
Neerpatel125 Jul 21, 2025
8cf03ee
Fixing [nit]
Jul 21, 2025
9886507
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 22, 2025
c5a8449
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 25, 2025
6b6d8c9
Merge remote-tracking branch 'upstream/main' into Supporting-Addition…
Jul 28, 2025
4681ab9
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 28, 2025
2231984
Cleaning plot filters code.
Jul 30, 2025
3fbb1cd
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 30, 2025
da766a9
Removed `extra_metrics` and `plot_metrics` from schemas.
Jul 30, 2025
ec28dfb
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Jul 31, 2025
79d68d0
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 4, 2025
b50a365
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 7, 2025
c328f1b
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 8, 2025
596f8d5
Updated example schemas.
Aug 11, 2025
dacbbd8
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 12, 2025
986ad54
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 13, 2025
f931178
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 14, 2025
2007c4c
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 15, 2025
a349bf6
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 15, 2025
797a221
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 18, 2025
202581b
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 20, 2025
b1432ef
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 21, 2025
d4a1371
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 26, 2025
be83db7
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Aug 29, 2025
1f8b104
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Sep 8, 2025
8ba3b88
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Sep 10, 2025
66d03e9
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Sep 12, 2025
825e1a6
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Sep 16, 2025
dfb7882
Merge branch 'unitaryfoundation:main' into Supporting-Additional-QEDC…
Neerpatel125 Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ docs/_build/

# mypy
.mypy_cache/

# QC-App-Oriented-Benchmarks
__data/
__images/
72 changes: 54 additions & 18 deletions metriq_gym/benchmarks/qedc_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from metriq_gym.helpers.task_helpers import flatten_counts

from _common import metrics
from _common.qiskit import execute as ex


QEDC_BENCHMARK_IMPORTS: dict[JobType, str] = {
Expand All @@ -32,36 +33,34 @@
Type: QEDC_Metrics
Description:
The structure for all returned QED-C circuit metrics.
The first key represents the number of qubits for the group of circuits.
The second key represents the unique identifier for a circuit in the group.

1. The first key represents the number of qubits for the group of circuits or the subtitle.
2. The second key represents the unique identifier for a circuit in the group.
- This may be a secret string for Bernstein-Vazirani, theta value for Phase-Estimation,
and so on. Benchmark specific documentation can be found in QED-C's
QC-App-Oriented-Benchmarks repository.
The third key represents the metric being stored.
3. The third key represents the metric being stored.

Example for Bernstein-Vazirani:
{
'3': {
'1': {'create_time': 0.16371703147888184,
'fidelity': 1.0,
'1': {'fidelity': 1.0,
'hf_fidelity': 1.0},
'2': {'create_time': 0.0005087852478027344,
'fidelity': 1.0,
'2': {'fidelity': 1.0,
'hf_fidelity': 1.0}
},
'4': {
'1': {'create_time': 0.0005209445953369141,
'fidelity': 1.0,
'1': {'fidelity': 1.0,
'hf_fidelity': 1.0},
'3': {'create_time': 0.00047206878662109375,
'fidelity': 1.0,
'3': {'fidelity': 1.0,
'hf_fidelity': 1.0},
'5': {'create_time': 0.0005078315734863281,
'fidelity': 1.0,
'5': {'fidelity': 1.0,
'hf_fidelity': 1.0}
}
'subtitle': "device = X"
}
"""
QEDC_Metrics = dict[str, dict[str, dict[str, float]]]
QEDC_Metrics = dict[str, dict[str, dict[str, float]] | str]


@dataclass
Expand Down Expand Up @@ -141,7 +140,7 @@ def get_counts(self, _):
benchmark_name = str(params["benchmark_name"])
benchmark = import_benchmark_module(benchmark_name)

# Restore circuit metrics dictionary from the dispatch data
# Restore circuit metrics from the dispatch data
metrics.circuit_metrics = job_data.circuit_metrics

# Iterate and get the metrics for each circuit in the list.
Expand Down Expand Up @@ -171,8 +170,32 @@ def get_counts(self, _):
None, result_object, int(num_qubits), int(circuit_id), params["num_shots"]
)

# Store the fidelity.
metrics.store_metric(num_qubits, circuit_id, "fidelity", fidelity)

# Code below plots the metrics:

# Compute statistics for metrics.
metrics.aggregate_metrics()

# Set backend information for plot titles.
provider_name = "qBraid"
device_name = "<unknown>"

# Set plot titles.
benchmark_title = f"{benchmark_name} ({params.get('method', '1')})"
subtitle = f"Benchmark Results - {benchmark_title} - {provider_name}"
metrics.circuit_metrics["subtitle"] = f"device = {device_name}"

# Determine which metrics to plot.
filters = ["fidelity", "hf_fidelity", "depth", "2q", "vbplot"]

# Plot the metrics.
metrics.plot_metrics(subtitle, filters=filters)

# Remove subtilte key.
metrics.circuit_metrics.pop("subtitle", None)

return metrics.circuit_metrics


Expand All @@ -184,7 +207,8 @@ def get_circuits_and_metrics(
Uses QED-C submodule to obtain circuits and circuit metrics.

Args:
params: the parameters to run the benchmark with, also includes benchmark_name.
benchmark_name: the name of the benchmark.
params: the parameters to run the benchmark with.

Returns:
circuits: the list of quantum circuits for the benchmark.
Expand All @@ -201,9 +225,12 @@ def get_circuits_and_metrics(
get_circuits=True,
)

# Remove the subtitle key to keep our desired format.
# Remove the subtitle key for iterating purposes.
circuit_metrics.pop("subtitle", None)

# Copy any initial creation metrics (i.e. create_time).
metrics.circuit_metrics = circuit_metrics

# Store the circuit identifiers and a flat list of circuits.
circuit_identifiers = []
flat_circuits = []
Expand All @@ -212,7 +239,16 @@ def get_circuits_and_metrics(
circuit_identifiers.append((num_qubits, circuit_id))
flat_circuits.append(circuits[num_qubits][circuit_id])

return flat_circuits, circuit_metrics, circuit_identifiers
# Compute circuit properties (depth, etc.) and store to metrics.
ex.compute_and_store_circuit_info(
circuits[num_qubits][circuit_id],
str(num_qubits),
str(circuit_id),
do_transpile_metrics=True,
use_normalized_depth=True,
)

return flat_circuits, metrics.circuit_metrics, circuit_identifiers


class QEDCBenchmark(Benchmark):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"benchmark_name": "Bernstein-Vazirani",
"num_shots": 1000,
"min_qubits": 2,
"max_qubits": 6,
"max_qubits": 10,
"skip_qubits": 1,
"max_circuits": 3,
"method": 1
Expand Down
2 changes: 1 addition & 1 deletion metriq_gym/schemas/examples/hidden_shift.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"benchmark_name": "Hidden Shift",
"num_shots": 1000,
"min_qubits": 2,
"max_qubits": 6,
"max_qubits": 10,
"skip_qubits": 1,
"max_circuits": 3,
"method": 1
Expand Down
2 changes: 1 addition & 1 deletion metriq_gym/schemas/examples/phase_estimation.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"benchmark_name": "Phase Estimation",
"num_shots": 1000,
"min_qubits": 2,
"max_qubits": 6,
"max_qubits": 10,
"skip_qubits": 1,
"max_circuits": 3,
"method": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"benchmark_name": "Quantum Fourier Transform",
"num_shots": 1000,
"min_qubits": 2,
"max_qubits": 6,
"max_qubits": 10,
"skip_qubits": 1,
"max_circuits": 3,
"method": 1,
Expand Down
1 change: 0 additions & 1 deletion metriq_gym/schemas/phase_estimation.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"description": "Creates circuits with mid-circuit measurements.",
"default": false,
"examples": [true]

}
},
"required": ["benchmark_name"],
Expand Down
1 change: 0 additions & 1 deletion metriq_gym/schemas/quantum_fourier_transform.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"description": "Creates circuits with mid-circuit measurements.",
"default": false,
"examples": [true]

}
},
"required": ["benchmark_name"],
Expand Down