Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Update RE application samples to use new features in Q# and azure_quantum #811

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"source": [
"## Analyzing the results\n",
"\n",
"Now that the results have been computed, we display them in a summary table. For this purpose we are creating a reusable `dashboard` function that is creating an HTML display from a pandas data frame and the resource estimation tables."
"Finally, we are presenting the experimental results using a summary table."
]
},
{
Expand All @@ -199,52 +199,7 @@
"source": [
"labels = [\"Gate-based µs, 10⁻³\", \"Gate-based µs, 10⁻⁴\", \"Gate-based ns, 10⁻³\", \"Gate-based ns, 10⁻⁴\", \"Majorana ns, 10⁻⁴\", \"Majorana ns, 10⁻⁶\"]\n",
"\n",
"def dashboard(results):\n",
" def get_row(result):\n",
" # Extract raw data from result dictionary\n",
" logical_qubits = result[\"physicalCounts\"][\"breakdown\"][\"algorithmicLogicalQubits\"]\n",
" logical_depth = result[\"physicalCounts\"][\"breakdown\"][\"logicalDepth\"]\n",
" num_tstates = result[\"physicalCounts\"][\"breakdown\"][\"numTstates\"]\n",
" code_distance = result[\"logicalQubit\"][\"codeDistance\"]\n",
" num_tfactories = result[\"physicalCounts\"][\"breakdown\"][\"numTfactories\"]\n",
" tfactory_fraction = (result[\"physicalCounts\"][\"breakdown\"][\"physicalQubitsForTfactories\"] / result[\"physicalCounts\"][\"physicalQubits\"]) * 100\n",
" physical_qubits = result[\"physicalCounts\"][\"physicalQubits\"]\n",
" runtime = result[\"physicalCounts\"][\"runtime\"]\n",
"\n",
" # Format some entries\n",
" logical_depth_formatted = f\"{logical_depth:.1e}\"\n",
" num_tstates_formatted = f\"{num_tstates:.1e}\"\n",
" tfactory_fraction_formatted = f\"{tfactory_fraction:.1f}%\"\n",
" physical_qubits_formatted = f\"{physical_qubits / 1e6:.2f}M\"\n",
"\n",
" # Make runtime human readable; we find the largest units for which the\n",
" # runtime has a value that is larger than 1.0. For that unit we are\n",
" # rounding the value and append the unit suffix.\n",
" units = [(\"nanosecs\", 1), (\"microsecs\", 1000), (\"millisecs\", 1000), (\"secs\", 1000), (\"mins\", 60), (\"hours\", 60), (\"days\", 24), (\"years\", 365)]\n",
" runtime_formatted = runtime\n",
" for idx in range(1, len(units)):\n",
" if runtime_formatted / units[idx][1] < 1.0:\n",
" runtime_formatted = f\"{round(runtime_formatted) % units[idx][1]} {units[idx - 1][0]}\"\n",
" break\n",
" else:\n",
" runtime_formatted = runtime_formatted / units[idx][1]\n",
"\n",
" # special case for years\n",
" if isinstance(runtime_formatted, float):\n",
" runtime_formatted = f\"{round(runtime_formatted)} {units[-1][0]}\"\n",
"\n",
" # Append all extracted and formatted data to data array\n",
" return (logical_qubits, logical_depth_formatted, num_tstates_formatted, code_distance, num_tfactories, tfactory_fraction_formatted, physical_qubits_formatted, runtime_formatted)\n",
"\n",
" data = [get_row(results.data(index)) for index in range(len(results))]\n",
"\n",
" # Create data frame with explicit column names and configuration names extracted from array\n",
" import pandas as pd\n",
" df = pd.DataFrame(data, columns=[\"Logical qubits\", \"Logical depth\", \"T states\", \"Code distance\", \"T factories\", \"T factory fraction\", \"Physical qubits\", \"Physical runtime\"], index=labels)\n",
"\n",
" return df\n",
"\n",
"dashboard(results)"
"results.summary_data_frame(labels=labels)"
]
},
{
Expand Down Expand Up @@ -303,6 +258,12 @@
"source": [
"In this notebook, you've estimated the quantum computing requirements to calculate the energy of a Hamiltonian. Nice job! 👏🏽\n",
"\n",
"The numbers for the XVIII-cas4-fb-64e-56o instance roughly match the numbers in\n",
"the paper [Assessing requirements for scaling quantum computers to real-world\n",
"impact](https://aka.ms/AQ/RE/Paper), as we incorporated a few improvements in\n",
"the implementation of the double-factorized chemistry algorithm as compared to\n",
"the version used when the paper was published.\n",
"\n",
"We hope that this notebook was helpful to you. Here are some suggestions for next steps:\n",
"* Try to estimate some custom FCIDUMP files\n",
"* Investigate the details of resource estimation by exploring the detailed resource estimation tables\n",
Expand All @@ -327,10 +288,10 @@
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 1
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading