Skip to content

Commit

Permalink
Add osaka access and prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ElePT committed Mar 3, 2024
1 parent 9b1bb17 commit 6d93aef
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 4 deletions.
10 changes: 6 additions & 4 deletions demos/qiskit_patterns/2_qiskit_patterns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,13 @@
"metadata": {},
"outputs": [],
"source": [
"service = QiskitRuntimeService(channel='ibm_quantum')\n",
"\n",
"if team == 1:\n",
" backend = service.get_backend('ibm_sherbrooke')\n",
" # Eagle = Osaka\n",
" service = QiskitRuntimeService(channel='ibm_quantum', instance=\"ibm-tech-event/ibm-tech-2024/team-1\")\n",
" backend = service.get_backend('ibm_osaka')\n",
"elif team == 2:\n",
" # Heron = Torino\n",
" service = QiskitRuntimeService(channel='ibm_quantum', instance=\"ibm-tech-event/ibm-tech-2024/team-2\")\n",
" backend = service.get_backend('ibm_torino')"
]
},
Expand Down Expand Up @@ -1343,4 +1345,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Binary file not shown.
Binary file not shown.
159 changes: 159 additions & 0 deletions demos/qiskit_patterns/qiskit_patterns_prep.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "1641ab1b",
"metadata": {},
"outputs": [],
"source": [
"# Eagle circuits are transpiled for Sherbrooke, but we need Osaka"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9b61bc04",
"metadata": {},
"outputs": [],
"source": [
"from qiskit import qpy # QPY is the circuit serializer in Qiskit.\n",
"\n",
"# Depth zero-circuit\n",
"with open(f\"data/125node_eagle_depth_zero.qpy\", \"rb\") as fd:\n",
" depth_zero_circuit = qpy.load(fd)[0]\n",
"\n",
"# Depth one-circuit\n",
"with open(f\"data/125node_eagle_depth_one.qpy\", \"rb\") as fd:\n",
" depth_one_circuit = qpy.load(fd)[0]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "e5f33c4b",
"metadata": {},
"outputs": [],
"source": [
"from qiskit_ibm_runtime import QiskitRuntimeService\n",
"\n",
"service = QiskitRuntimeService(channel=\"ibm_quantum\", instance = \"ibm-tech-event/ibm-tech-2024/team-1\")\n",
"\n",
"osaka = service.get_backend(\"ibm_osaka\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "5d49d2d5",
"metadata": {},
"outputs": [],
"source": [
"from qiskit import transpile\n",
"\n",
"new_depth_zero_circuit = transpile(depth_zero_circuit, backend = osaka, optimization_level=0)\n",
"new_depth_one_circuit = transpile(depth_one_circuit, backend = osaka ,optimization_level=0)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "3de98512",
"metadata": {},
"outputs": [],
"source": [
"# Depth zero-circuit\n",
"with open(f\"data/125node_eagle_depth_zero_osaka.qpy\", \"wb\") as fd:\n",
" qpy.dump(new_depth_zero_circuit, fd)\n",
"\n",
"# Depth one-circuit\n",
"with open(f\"data/125node_eagle_depth_one_osaka.qpy\", \"wb\") as fd:\n",
" qpy.dump(new_depth_one_circuit, fd)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "7c6cf811",
"metadata": {},
"outputs": [],
"source": [
"from qiskit_ibm_runtime import Sampler, Options\n",
"from qiskit import QuantumCircuit\n",
"\n",
"options = Options()\n",
"options.transpilation.skip_transpilation = True\n",
"sampler = Sampler(backend=osaka, options=options)\n",
"job = sampler.run(new_depth_one_circuit, [0,1], shots=1)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "86f2467d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<bound method JobV1.job_id of <RuntimeJob('cqj12305wd50008zddxg', 'sampler')>>"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"job.job_id"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "1b7b2b0b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SamplerResult(quasi_dists=[{9583798905619508744817906166877101836: 1.0}], metadata=[{'shots': 1, 'circuit_metadata': {}, 'readout_mitigation_overhead': 1.0, 'readout_mitigation_time': 0.10171344131231308, 'warning': 'Optimization level clipped from 3 to 1'}])\n"
]
}
],
"source": [
"print(job.result())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0016c79",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "ibm_tech_clean",
"language": "python",
"name": "ibm_tech_clean"
},
"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.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 6d93aef

Please sign in to comment.