From 5222624f57aeaa371ac81b122a8b68fd74e9141a Mon Sep 17 00:00:00 2001 From: Dima Fedoriaka Date: Fri, 31 Jul 2026 16:35:04 -0700 Subject: [PATCH 1/4] dollar cost calculator (prototype) --- samples/qre/cost_example.ipynb | 167 +++++++++++++++++++++ samples/qre/example_cost_spec.json | 40 +++++ source/qdk_package/qdk/qre/_dollar_cost.py | 52 +++++++ source/qdk_package/qdk/qre/_estimation.py | 26 +++- 4 files changed, 277 insertions(+), 8 deletions(-) create mode 100644 samples/qre/cost_example.ipynb create mode 100644 samples/qre/example_cost_spec.json create mode 100644 source/qdk_package/qdk/qre/_dollar_cost.py diff --git a/samples/qre/cost_example.ipynb b/samples/qre/cost_example.ipynb new file mode 100644 index 00000000000..36cd7f35503 --- /dev/null +++ b/samples/qre/cost_example.ipynb @@ -0,0 +1,167 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "4d47cb98-6af6-4757-b450-c2209ce8f5df", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
qubitsruntimeerror$ cost
0193520 days 00:00:14.3240040.0080642439.12
1212920 days 00:00:10.7430030.0079781829.34
2251720 days 00:00:07.1620020.0078921219.56
3290520 days 00:00:05.3715060.007849914.67
4386920 days 00:00:04.3767790.007721993.72
5387520 days 00:00:03.5810010.007806813.04
6399640 days 00:00:02.7867980.009849632.73
7778240 days 00:00:02.7862730.009109948.91
\n", + "
" + ], + "text/plain": [ + " qubits runtime error $ cost\n", + "0 19352 0 days 00:00:14.324004 0.008064 2439.12\n", + "1 21292 0 days 00:00:10.743003 0.007978 1829.34\n", + "2 25172 0 days 00:00:07.162002 0.007892 1219.56\n", + "3 29052 0 days 00:00:05.371506 0.007849 914.67\n", + "4 38692 0 days 00:00:04.376779 0.007721 993.72\n", + "5 38752 0 days 00:00:03.581001 0.007806 813.04\n", + "6 39964 0 days 00:00:02.786798 0.009849 632.73\n", + "7 77824 0 days 00:00:02.786273 0.009109 948.91" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from pathlib import Path\n", + "\n", + "import qdk\n", + "from qdk import qsharp\n", + "from qdk.qre import estimate, property_name, instruction_name, PSSPC, LatticeSurgery\n", + "from qdk.qre.models import GateBased, SurfaceCode, RoundBasedFactory\n", + "from qdk.qre.application import QSharpApplication\n", + "\n", + "from qdk.qre.instruction_ids import T, LATTICE_SURGERY\n", + "from qdk.qre.property_keys import NUM_TS_PER_ROTATION\n", + "\n", + "# Evaluate the Q# application into the scope\n", + "qsharp.eval(Path(\"../algorithms/Shor.qs\").read_text(encoding=\"utf-8\"))\n", + "\n", + "# The entry point in the Q# code above is called Main\n", + "app = QSharpApplication(qdk.code.Main)\n", + "\n", + "arch = GateBased(error_rate=1e-4, gate_time=100, measurement_time=500)\n", + "\n", + "results = estimate(\n", + " app,\n", + " arch,\n", + " isa_query=SurfaceCode.q() * RoundBasedFactory.q(),\n", + " trace_query=PSSPC.q() * LatticeSurgery.q(slow_down_factor=[1.0, 1.5, 2.0, 3.0, 4.0]),\n", + " max_error=0.01,\n", + " json_spec_path=\"example_cost_spec.json\"\n", + ")\n", + "results.as_frame()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/samples/qre/example_cost_spec.json b/samples/qre/example_cost_spec.json new file mode 100644 index 00000000000..0ff0a690284 --- /dev/null +++ b/samples/qre/example_cost_spec.json @@ -0,0 +1,40 @@ +{ + "system" : { + "name": "example_cost_spec", + "qubits_per_node": 16000, + "cnot_time": 10000, + "cnot_error_rate": 0.001, + "one_qubit_time": 1000, + "one_qubit_error_rate": 0.0001, + "measurement_time": 1000, + "measurement_error_rate": 0.0001, + "target_year": 2030, + "lifetime_in_years": 10, + "uptime": 0.9, + "control_lines_per_physical_qubit": 1, + "readout_lines_per_physical_qubit": 0, + "fixed_control_lines": 0, + "fixed_readout_lines": 0, + "magical_speedup_factor": 1 + }, + "fixed_units" : [ + { + "name": "Fixed cost of constructing the system", + "cost": 10000000.0, + "quantity": 1, + "eos_factor": 1.0 + } + ], + "scaled_units": [ + { + "name": "Black box cost per qubit", + "cost": 1000000.00, + "units_per_control_line" : 1, + "units_per_readout_line" : 0, + "eos_factor": 1.0 + } + ], + "opex": { + "FTE_Costs": 10000000 + } +} \ No newline at end of file diff --git a/source/qdk_package/qdk/qre/_dollar_cost.py b/source/qdk_package/qdk/qre/_dollar_cost.py new file mode 100644 index 00000000000..ce52ee5ee55 --- /dev/null +++ b/source/qdk_package/qdk/qre/_dollar_cost.py @@ -0,0 +1,52 @@ +import json +import math + +from ._results import EstimationTableEntry + + +def compute_dollar_cost(cost_spec_path: str, result: EstimationTableEntry) -> float: + """Computes cost in dollars.""" + system = None + with open(cost_spec_path, "r") as f: + system = json.load(f) + assert system is not None + + # Build the node cost + qubits_per_node = system["system"]["qubits_per_node"] + control_lines = ( + system["system"]["fixed_control_lines"] + + qubits_per_node * system["system"]["control_lines_per_physical_qubit"] + ) + readout_lines = ( + system["system"]["fixed_readout_lines"] + + qubits_per_node * system["system"]["readout_lines_per_physical_qubit"] + ) + cost_per_control_line = 0 + for unit in system["scaled_units"]: + cost_per_control_line += ( + unit["cost"] * unit["units_per_control_line"] * unit["eos_factor"] + ) + cost_per_readout_line = 0 + for unit in system["scaled_units"]: + cost_per_readout_line += ( + unit["cost"] * unit["units_per_readout_line"] * unit["eos_factor"] + ) + + capex = 0 + for unit in system["fixed_units"]: + capex += unit["cost"] * unit["quantity"] * unit["eos_factor"] + capex += cost_per_control_line * control_lines + capex += cost_per_readout_line * readout_lines + + opex = 0 + for item in system["opex"]: + opex += system["opex"][item] + + number_of_nodes = math.ceil(result.qubits / qubits_per_node) + 1 + runtime_hours = result.runtime / (3600 * 1_000_000_000) # Convert to hours + runtime_hours /= system["system"]["magical_speedup_factor"] + operating_lifetime = system["system"]["lifetime_in_years"] + up_hours_per_year = 8760 * system["system"]["uptime"] + hourly_cost = (opex + capex / operating_lifetime) / up_hours_per_year + dollar_cost = number_of_nodes * hourly_cost * runtime_hours + return math.ceil(dollar_cost * 100) / 100 diff --git a/source/qdk_package/qdk/qre/_estimation.py b/source/qdk_package/qdk/qre/_estimation.py index 6191ac4b455..6c74d9f8a67 100644 --- a/source/qdk_package/qdk/qre/_estimation.py +++ b/source/qdk_package/qdk/qre/_estimation.py @@ -3,34 +3,36 @@ from __future__ import annotations -from typing import cast, Optional, Any +from typing import Any, cast from .. import telemetry_events from ._application import Application from ._architecture import Architecture +from ._dollar_cost import compute_dollar_cost +from ._isa_enumeration import ISAQuery from ._qre import ( - _estimate_parallel, - _estimate_with_graph, - _EstimationCollection, ErrorComposition, Trace, + _EstimationCollection, + _estimate_parallel, + _estimate_with_graph, ) -from ._trace import TraceQuery, PSSPC, LatticeSurgery -from ._isa_enumeration import ISAQuery from ._results import EstimationTable, EstimationTableEntry +from ._trace import LatticeSurgery, PSSPC, TraceQuery def estimate( application: Application, architecture: Architecture, isa_query: ISAQuery, - trace_query: Optional[TraceQuery] = None, + trace_query: TraceQuery | None = None, *, max_error: float = 1.0, post_process: bool = False, use_graph: bool = True, composition: ErrorComposition = ErrorComposition.UnionBound, - name: Optional[str] = None, + name: str | None = None, + json_spec_path: str | None = None, ) -> EstimationTable: """ Estimate the resource requirements for a given application instance and @@ -82,6 +84,8 @@ def estimate( ``1 - prod(1 - p_i)``. name (Optional[str]): An optional name for the estimation. If given, this will be added as a first column to the results table for all entries. + json_spec_path (Optional[str]): Path to the system specification in + JSON format. If provided, a ``$ cost`` column is added to the results. Returns: EstimationTable: A table containing the optimal estimation results. @@ -223,6 +227,12 @@ def estimate( EstimationTableEntry.from_result(result, arch_ctx) for result in collection ) + if json_spec_path is not None: + table.add_column( + "$ cost", + lambda entry: compute_dollar_cost(json_spec_path, entry), + ) + # Fill in the stats for this estimation run table.stats.num_traces = num_traces table.stats.num_isas = num_isas From 827fd53dbb6d88789471165f60e86a1d8feb7a1d Mon Sep 17 00:00:00 2001 From: Dima Fedoriaka Date: Fri, 31 Jul 2026 17:09:55 -0700 Subject: [PATCH 2/4] add json schema --- samples/qre/cost_example.ipynb | 76 ++++------ samples/qre/example_cost_spec.json | 17 ++- source/qdk_package/qdk/qre/_dollar_cost.py | 40 +++--- source/qdk_package/qdk/qre/_json_specs.py | 130 ++++++++++++++++++ .../qdk_package/tests/qre/test_dollar_cost.py | 35 +++++ 5 files changed, 223 insertions(+), 75 deletions(-) create mode 100644 source/qdk_package/qdk/qre/_json_specs.py create mode 100644 source/qdk_package/tests/qre/test_dollar_cost.py diff --git a/samples/qre/cost_example.ipynb b/samples/qre/cost_example.ipynb index 36cd7f35503..e864a8b437e 100644 --- a/samples/qre/cost_example.ipynb +++ b/samples/qre/cost_example.ipynb @@ -36,74 +36,58 @@ " \n", " \n", " 0\n", - " 19352\n", - " 0 days 00:00:14.324004\n", - " 0.008064\n", - " 2439.12\n", + " 18624\n", + " 0 days 00:00:02.729580\n", + " 0.009360\n", + " 464.80\n", " \n", " \n", " 1\n", - " 21292\n", - " 0 days 00:00:10.743003\n", - " 0.007978\n", - " 1829.34\n", + " 24444\n", + " 0 days 00:00:01.819384\n", + " 0.008092\n", + " 309.81\n", " \n", " \n", " 2\n", - " 25172\n", - " 0 days 00:00:07.162002\n", - " 0.007892\n", - " 1219.56\n", + " 29052\n", + " 0 days 00:00:01.754082\n", + " 0.008221\n", + " 298.69\n", " \n", " \n", " 3\n", - " 29052\n", - " 0 days 00:00:05.371506\n", - " 0.007849\n", - " 914.67\n", + " 30264\n", + " 0 days 00:00:01.364538\n", + " 0.006689\n", + " 232.36\n", " \n", " \n", " 4\n", - " 38692\n", - " 0 days 00:00:04.376779\n", - " 0.007721\n", - " 993.72\n", - " \n", - " \n", - " 5\n", " 38752\n", - " 0 days 00:00:03.581001\n", - " 0.007806\n", - " 813.04\n", + " 0 days 00:00:01.169388\n", + " 0.008207\n", + " 265.51\n", " \n", " \n", - " 6\n", + " 5\n", " 39964\n", - " 0 days 00:00:02.786798\n", - " 0.009849\n", - " 632.73\n", - " \n", - " \n", - " 7\n", - " 77824\n", - " 0 days 00:00:02.786273\n", - " 0.009109\n", - " 948.91\n", + " 0 days 00:00:00.909692\n", + " 0.005285\n", + " 206.54\n", " \n", " \n", "\n", "" ], "text/plain": [ - " qubits runtime error $ cost\n", - "0 19352 0 days 00:00:14.324004 0.008064 2439.12\n", - "1 21292 0 days 00:00:10.743003 0.007978 1829.34\n", - "2 25172 0 days 00:00:07.162002 0.007892 1219.56\n", - "3 29052 0 days 00:00:05.371506 0.007849 914.67\n", - "4 38692 0 days 00:00:04.376779 0.007721 993.72\n", - "5 38752 0 days 00:00:03.581001 0.007806 813.04\n", - "6 39964 0 days 00:00:02.786798 0.009849 632.73\n", - "7 77824 0 days 00:00:02.786273 0.009109 948.91" + " qubits runtime error $ cost\n", + "0 18624 0 days 00:00:02.729580 0.009360 464.80\n", + "1 24444 0 days 00:00:01.819384 0.008092 309.81\n", + "2 29052 0 days 00:00:01.754082 0.008221 298.69\n", + "3 30264 0 days 00:00:01.364538 0.006689 232.36\n", + "4 38752 0 days 00:00:01.169388 0.008207 265.51\n", + "5 39964 0 days 00:00:00.909692 0.005285 206.54" ] }, "execution_count": 1, diff --git a/samples/qre/example_cost_spec.json b/samples/qre/example_cost_spec.json index 0ff0a690284..c312a03af19 100644 --- a/samples/qre/example_cost_spec.json +++ b/samples/qre/example_cost_spec.json @@ -1,5 +1,5 @@ { - "system" : { + "system": { "name": "example_cost_spec", "qubits_per_node": 16000, "cnot_time": 10000, @@ -17,7 +17,7 @@ "fixed_readout_lines": 0, "magical_speedup_factor": 1 }, - "fixed_units" : [ + "fixed_units": [ { "name": "Fixed cost of constructing the system", "cost": 10000000.0, @@ -29,12 +29,15 @@ { "name": "Black box cost per qubit", "cost": 1000000.00, - "units_per_control_line" : 1, - "units_per_readout_line" : 0, + "units_per_control_line": 1, + "units_per_readout_line": 0, "eos_factor": 1.0 } ], - "opex": { - "FTE_Costs": 10000000 - } + "opex": [ + { + "name": "FTE costs", + "cost": 10000000 + } + ] } \ No newline at end of file diff --git a/source/qdk_package/qdk/qre/_dollar_cost.py b/source/qdk_package/qdk/qre/_dollar_cost.py index ce52ee5ee55..fe8ec67ee51 100644 --- a/source/qdk_package/qdk/qre/_dollar_cost.py +++ b/source/qdk_package/qdk/qre/_dollar_cost.py @@ -1,52 +1,48 @@ -import json import math +from ._json_specs import JsonSpec from ._results import EstimationTableEntry def compute_dollar_cost(cost_spec_path: str, result: EstimationTableEntry) -> float: """Computes cost in dollars.""" - system = None - with open(cost_spec_path, "r") as f: - system = json.load(f) - assert system is not None + spec = JsonSpec.from_file(cost_spec_path) + system = spec.system # Build the node cost - qubits_per_node = system["system"]["qubits_per_node"] + qubits_per_node = system.qubits_per_node control_lines = ( - system["system"]["fixed_control_lines"] - + qubits_per_node * system["system"]["control_lines_per_physical_qubit"] + system.fixed_control_lines + + qubits_per_node * system.control_lines_per_physical_qubit ) readout_lines = ( - system["system"]["fixed_readout_lines"] - + qubits_per_node * system["system"]["readout_lines_per_physical_qubit"] + system.fixed_readout_lines + + qubits_per_node * system.readout_lines_per_physical_qubit ) cost_per_control_line = 0 - for unit in system["scaled_units"]: + for unit in spec.scaled_units: cost_per_control_line += ( - unit["cost"] * unit["units_per_control_line"] * unit["eos_factor"] + unit.cost * unit.units_per_control_line * unit.eos_factor ) cost_per_readout_line = 0 - for unit in system["scaled_units"]: + for unit in spec.scaled_units: cost_per_readout_line += ( - unit["cost"] * unit["units_per_readout_line"] * unit["eos_factor"] + unit.cost * unit.units_per_readout_line * unit.eos_factor ) capex = 0 - for unit in system["fixed_units"]: - capex += unit["cost"] * unit["quantity"] * unit["eos_factor"] + for unit in spec.fixed_units: + capex += unit.cost * unit.quantity * unit.eos_factor capex += cost_per_control_line * control_lines capex += cost_per_readout_line * readout_lines - opex = 0 - for item in system["opex"]: - opex += system["opex"][item] + opex = sum(item.cost for item in spec.opex) number_of_nodes = math.ceil(result.qubits / qubits_per_node) + 1 runtime_hours = result.runtime / (3600 * 1_000_000_000) # Convert to hours - runtime_hours /= system["system"]["magical_speedup_factor"] - operating_lifetime = system["system"]["lifetime_in_years"] - up_hours_per_year = 8760 * system["system"]["uptime"] + runtime_hours /= system.magical_speedup_factor + operating_lifetime = system.lifetime_in_years + up_hours_per_year = 8760 * system.uptime hourly_cost = (opex + capex / operating_lifetime) / up_hours_per_year dollar_cost = number_of_nodes * hourly_cost * runtime_hours return math.ceil(dollar_cost * 100) / 100 diff --git a/source/qdk_package/qdk/qre/_json_specs.py b/source/qdk_package/qdk/qre/_json_specs.py new file mode 100644 index 00000000000..14944d921c0 --- /dev/null +++ b/source/qdk_package/qdk/qre/_json_specs.py @@ -0,0 +1,130 @@ +from __future__ import annotations + +import json +from collections.abc import Mapping +from dataclasses import dataclass +from typing import Any + + +@dataclass(frozen=True) +class System: + """Hardware and operating assumptions for the quantum system. + + Attributes: + name: Human-readable specification name. + qubits_per_node: Number of physical qubits available in one node. + cnot_time: CNOT gate duration in nanoseconds. + cnot_error_rate: Error probability for a CNOT gate. + one_qubit_time: Single-qubit gate duration in nanoseconds. + one_qubit_error_rate: Error probability for a single-qubit gate. + measurement_time: Measurement duration in nanoseconds. + measurement_error_rate: Error probability for a measurement. + target_year: Calendar year targeted by the specification. + lifetime_in_years: Expected operating lifetime of the system. + uptime: Fraction of each year during which the system is available. + control_lines_per_physical_qubit: Control lines required per qubit. + readout_lines_per_physical_qubit: Readout lines required per qubit. + fixed_control_lines: Control lines required independently of qubit count. + fixed_readout_lines: Readout lines required independently of qubit count. + magical_speedup_factor: Runtime reduction supplied by external assumptions. + """ + + name: str + qubits_per_node: int + cnot_time: int + cnot_error_rate: float + one_qubit_time: int + one_qubit_error_rate: float + measurement_time: int + measurement_error_rate: float + target_year: int + lifetime_in_years: float + uptime: float + control_lines_per_physical_qubit: float + readout_lines_per_physical_qubit: float + fixed_control_lines: int + fixed_readout_lines: int + magical_speedup_factor: float + + +@dataclass(frozen=True) +class FixedUnit: + """A system component whose quantity does not scale with line count. + + Attributes: + name: Human-readable component name. + cost: Cost of one component in dollars. + quantity: Number of components required. + eos_factor: End-of-support multiplier applied to the component cost. + """ + + name: str + cost: float + quantity: float + eos_factor: float + + +@dataclass(frozen=True) +class ScaledUnit: + """A component whose quantity scales with control or readout lines. + + Attributes: + name: Human-readable component name. + cost: Cost of one component in dollars. + eos_factor: End-of-support multiplier applied to the component cost. + units_per_control_line: Components required for each control line. + units_per_readout_line: Components required for each readout line. + """ + + name: str + cost: float + eos_factor: float = 1.0 + units_per_control_line: int = 0 + units_per_readout_line: int = 0 + + +@dataclass(frozen=True) +class OpExUnit: + """A recurring annual operating expense. + + Attributes: + name: Human-readable expense name. + cost: Annual cost in dollars. + """ + + name: str + cost: float + + +@dataclass(frozen=True) +class JsonSpec: + """Typed representation of a complete system cost specification. + + Attributes: + system: Hardware and operating assumptions. + fixed_units: Components whose quantities are fixed per node. + scaled_units: Components whose quantities scale with system lines. + opex: Recurring annual operating expenses. + """ + + system: System + fixed_units: list[FixedUnit] + scaled_units: list[ScaledUnit] + opex: list[OpExUnit] + + # TODO: use dataclasses-json instead. + @classmethod + def from_dict(cls, data: Mapping[str, Any]) -> JsonSpec: + """Create a specification from decoded JSON data.""" + return cls( + system=System(**data["system"]), + fixed_units=[FixedUnit(**item) for item in data["fixed_units"]], + scaled_units=[ScaledUnit(**item) for item in data["scaled_units"]], + opex=[OpExUnit(**item) for item in data["opex"]], + ) + + @classmethod + def from_file(cls, path: str) -> JsonSpec: + """Load a specification from a JSON file.""" + with open(path, encoding="utf-8") as file: + return cls.from_dict(json.load(file)) diff --git a/source/qdk_package/tests/qre/test_dollar_cost.py b/source/qdk_package/tests/qre/test_dollar_cost.py new file mode 100644 index 00000000000..42c172ba4d4 --- /dev/null +++ b/source/qdk_package/tests/qre/test_dollar_cost.py @@ -0,0 +1,35 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +from pathlib import Path + +from qdk.qre._dollar_cost import compute_dollar_cost +from qdk.qre._instruction import InstructionSource +from qdk.qre._json_specs import JsonSpec, OpExUnit, ScaledUnit, System +from qdk.qre._results import EstimationTableEntry + + +COST_SPEC_PATH = Path(__file__).resolve().parents[4] / "samples/qre/example_cost_spec.json" + + +def test_json_spec_from_file(): + spec = JsonSpec.from_file(str(COST_SPEC_PATH)) + + assert isinstance(spec.system, System) + assert spec.system.name == "example_cost_spec" + assert spec.system.qubits_per_node == 16_000 + assert isinstance(spec.scaled_units[0], ScaledUnit) + assert spec.scaled_units[0].units_per_control_line == 1 + assert isinstance(spec.opex[0], OpExUnit) + assert spec.opex[0].cost == 10_000_000 + + +def test_compute_dollar_cost_from_json_spec(): + entry = EstimationTableEntry( + qubits=16_000, + runtime=3_600_000_000_000, + error=0.0, + source=InstructionSource(), + ) + + assert compute_dollar_cost(str(COST_SPEC_PATH), entry) == 408_675.80 From c5e847d0f649d53cc10e1ddd830a0c39693b889b Mon Sep 17 00:00:00 2001 From: Dima Fedoriaka Date: Fri, 31 Jul 2026 17:33:25 -0700 Subject: [PATCH 3/4] rename --- source/qdk_package/qdk/qre/_estimation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/qdk_package/qdk/qre/_estimation.py b/source/qdk_package/qdk/qre/_estimation.py index 6c74d9f8a67..2050a2aae53 100644 --- a/source/qdk_package/qdk/qre/_estimation.py +++ b/source/qdk_package/qdk/qre/_estimation.py @@ -32,7 +32,7 @@ def estimate( use_graph: bool = True, composition: ErrorComposition = ErrorComposition.UnionBound, name: str | None = None, - json_spec_path: str | None = None, + cost_spec_path: str | None = None, ) -> EstimationTable: """ Estimate the resource requirements for a given application instance and From 29632ba17afc13b8d6b293e025e3cbd0d73b9183 Mon Sep 17 00:00:00 2001 From: Dima Fedoriaka Date: Fri, 31 Jul 2026 17:34:34 -0700 Subject: [PATCH 4/4] update notebook --- samples/qre/cost_example.ipynb | 50 +++++++++++------------ source/qdk_package/qdk/qre/_estimation.py | 4 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/samples/qre/cost_example.ipynb b/samples/qre/cost_example.ipynb index e864a8b437e..51ba5ae0806 100644 --- a/samples/qre/cost_example.ipynb +++ b/samples/qre/cost_example.ipynb @@ -37,44 +37,44 @@ " \n", " 0\n", " 18624\n", - " 0 days 00:00:02.729580\n", - " 0.009360\n", - " 464.80\n", + " 0 days 00:00:02.788569\n", + " 0.009573\n", + " 474.85\n", " \n", " \n", " 1\n", " 24444\n", - " 0 days 00:00:01.819384\n", - " 0.008092\n", - " 309.81\n", + " 0 days 00:00:01.858696\n", + " 0.008309\n", + " 316.51\n", " \n", " \n", " 2\n", " 29052\n", - " 0 days 00:00:01.754082\n", - " 0.008221\n", - " 298.69\n", + " 0 days 00:00:01.791981\n", + " 0.008555\n", + " 305.15\n", " \n", " \n", " 3\n", " 30264\n", - " 0 days 00:00:01.364538\n", - " 0.006689\n", - " 232.36\n", + " 0 days 00:00:01.394022\n", + " 0.006875\n", + " 237.38\n", " \n", " \n", " 4\n", " 38752\n", - " 0 days 00:00:01.169388\n", - " 0.008207\n", - " 265.51\n", + " 0 days 00:00:01.194651\n", + " 0.008540\n", + " 271.24\n", " \n", " \n", " 5\n", " 39964\n", - " 0 days 00:00:00.909692\n", - " 0.005285\n", - " 206.54\n", + " 0 days 00:00:00.929348\n", + " 0.005442\n", + " 211.01\n", " \n", " \n", "\n", @@ -82,12 +82,12 @@ ], "text/plain": [ " qubits runtime error $ cost\n", - "0 18624 0 days 00:00:02.729580 0.009360 464.80\n", - "1 24444 0 days 00:00:01.819384 0.008092 309.81\n", - "2 29052 0 days 00:00:01.754082 0.008221 298.69\n", - "3 30264 0 days 00:00:01.364538 0.006689 232.36\n", - "4 38752 0 days 00:00:01.169388 0.008207 265.51\n", - "5 39964 0 days 00:00:00.909692 0.005285 206.54" + "0 18624 0 days 00:00:02.788569 0.009573 474.85\n", + "1 24444 0 days 00:00:01.858696 0.008309 316.51\n", + "2 29052 0 days 00:00:01.791981 0.008555 305.15\n", + "3 30264 0 days 00:00:01.394022 0.006875 237.38\n", + "4 38752 0 days 00:00:01.194651 0.008540 271.24\n", + "5 39964 0 days 00:00:00.929348 0.005442 211.01" ] }, "execution_count": 1, @@ -121,7 +121,7 @@ " isa_query=SurfaceCode.q() * RoundBasedFactory.q(),\n", " trace_query=PSSPC.q() * LatticeSurgery.q(slow_down_factor=[1.0, 1.5, 2.0, 3.0, 4.0]),\n", " max_error=0.01,\n", - " json_spec_path=\"example_cost_spec.json\"\n", + " cost_spec_path=\"example_cost_spec.json\"\n", ")\n", "results.as_frame()" ] diff --git a/source/qdk_package/qdk/qre/_estimation.py b/source/qdk_package/qdk/qre/_estimation.py index 2050a2aae53..b7af505fea3 100644 --- a/source/qdk_package/qdk/qre/_estimation.py +++ b/source/qdk_package/qdk/qre/_estimation.py @@ -227,10 +227,10 @@ def estimate( EstimationTableEntry.from_result(result, arch_ctx) for result in collection ) - if json_spec_path is not None: + if cost_spec_path is not None: table.add_column( "$ cost", - lambda entry: compute_dollar_cost(json_spec_path, entry), + lambda entry: compute_dollar_cost(cost_spec_path, entry), ) # Fill in the stats for this estimation run