Skip to content

Commit b0e4dee

Browse files
backend.run is deprecated
1 parent 304f19f commit b0e4dee

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

shor_algorithm.ipynb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,34 @@
305305
},
306306
{
307307
"cell_type": "code",
308-
"execution_count": 14,
308+
"execution_count": null,
309+
"id": "5d352c1f",
310+
"metadata": {},
311+
"outputs": [],
312+
"source": [
313+
"from qiskit_ibm_runtime import SamplerV2 as Sampler, QiskitRuntimeService\n",
314+
" \n",
315+
"# Define the service. This allows you to access IBM QPUs.\n",
316+
"service = QiskitRuntimeService()\n",
317+
" \n",
318+
"# Get a backend\n",
319+
"backend = service.least_busy(operational=True, simulator=False)\n",
320+
" \n",
321+
"# Define Sampler\n",
322+
"sampler = Sampler(mode=backend)\n",
323+
"\n",
324+
"# transpile the circuit\n",
325+
"t_qc = transpile(qc, backend)\n",
326+
"\n",
327+
"# Run calculation\n",
328+
"job = sampler.run([t_qc])\n",
329+
" \n",
330+
"result = job.result()"
331+
]
332+
},
333+
{
334+
"cell_type": "code",
335+
"execution_count": null,
309336
"id": "b0f150c9-e608-46b5-b020-51c3ffd34fb4",
310337
"metadata": {
311338
"tags": []
@@ -339,10 +366,7 @@
339366
}
340367
],
341368
"source": [
342-
"#aer_sim = Aer.get_backend('aer_simulator')\n",
343-
"#t_qc = transpile(qc, aer_sim)\n",
344-
"#transpile quantum circuit qc using real quantum backend\n",
345-
"t_qc = transpile(qc, backend)\n",
369+
"# Get the counts\n",
346370
"counts = backend.run(t_qc).result().get_counts()\n",
347371
"plot_histogram(counts)"
348372
]

0 commit comments

Comments
 (0)