Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 29 additions & 11 deletions docs/guides/algorithmiq-tem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,24 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "cc0a8093",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from qiskit_ibm_catalog import QiskitFunctionsCatalog\n",
"\n",
"tem_function_name = \"algorithmiq/tem\"\n",
"\n",
"catalog = QiskitFunctionsCatalog(channel=\"ibm_quantum_platform\")\n",
"# Set IBM Quantum credentials and backend configuration\n",
"personal_token = os.environ.get(\n",
" \"QISKIT_IBM_TOKEN\", \"<API-KEY>\"\n",
") # Replace with your personal token or set the environment variable\n",
"channel = \"ibm_quantum_platform\"\n",
"crn = \"your_crn\" # Replace with the Cloud Resource Name (CRN)\n",
"\n",
"catalog = QiskitFunctionsCatalog(channel=channel, instance=crn, token=personal_token)\n",
"\n",
"# Load your function\n",
"tem = catalog.load(tem_function_name)"
Expand All @@ -188,7 +196,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "ab05b87f",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -220,6 +228,7 @@
"# Define backend to use. TEM will choose the least-busy device reported by IBM if not specified\n",
"backend_name = \"ibm_marrakesh\"\n",
"\n",
"# Run the TEM function (uses around 3 minutes of QPU time)\n",
"job = tem.run(pubs=[pub], backend_name=backend_name, options=options)"
]
},
Expand All @@ -233,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "47b0db71",
"metadata": {},
"outputs": [
Expand All @@ -259,13 +268,22 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"id": "ad5b9a53",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.10229839785546409\n"
]
}
],
"source": [
"result = job.result()\n",
"evs = result[0].data.evs"
"evs = result[0].data.evs\n",
"print(evs[0])"
]
},
{
Expand Down Expand Up @@ -373,15 +391,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "0433171c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(1,), dtype=float64>), stds=np.ndarray(<shape=(1,), dtype=float64>)), metadata={'evs_non_mitigated': array([0.06979321]), 'stds_non_mitigated': array([0.05510763]), 'evs_mitigated_no_readout_mitigation': array([0.07031416]), 'stds_mitigated_no_readout_mitigation': array([0.05566318]), 'evs_non_mitigated_with_readout_mitigation': array([0.08313754]), 'stds_non_mitigated_with_readout_mitigation': array([0.05702442])})], metadata={'resource_usage': {'RUNNING: OPTIMIZING_FOR_HARDWARE': {'CPU_TIME': 0.966265}, 'RUNNING: WAITING_FOR_QPU': {'CPU_TIME': 11.436938}, 'RUNNING: POST_PROCESSING': {'CPU_TIME': 10.379288999999998}, 'RUNNING: EXECUTING_QPU': {'QPU_TIME': 171.0}}})\n"
"PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(1,), dtype=float64>), stds=np.ndarray(<shape=(1,), dtype=float64>)), metadata={'evs_non_mitigated': array([0.09305761]), 'stds_non_mitigated': array([0.05499456]), 'evs_mitigated_no_readout_mitigation': array([0.09371257]), 'stds_mitigated_no_readout_mitigation': array([0.05546237]), 'evs_non_mitigated_with_readout_mitigation': array([0.10156985]), 'stds_non_mitigated_with_readout_mitigation': array([0.05788876])})], metadata={'resource_usage': {'RUNNING: OPTIMIZING_FOR_HARDWARE': {'CPU_TIME': 1.018068}, 'RUNNING: WAITING_FOR_QPU': {'CPU_TIME': 411.145994}, 'RUNNING: POST_PROCESSING': {'CPU_TIME': 10.018932999999997}, 'RUNNING: EXECUTING_QPU': {'QPU_TIME': 187.0}}})\n"
]
}
],
Expand Down Expand Up @@ -423,7 +441,7 @@
"metadata": {
"description": "Introduction to TEM, a Qiskit Function by Algorithmiq, to compute estimations with software post-processing error mitigation using tensor networks.",
"kernelspec": {
"display_name": "Python 3",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -437,7 +455,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3"
"version": "3.12.3"
},
"title": "Tensor-network error mitigation (TEM) - A Qiskit Function by Algorithmiq"
},
Expand Down
Loading