|
305 | 305 | }, |
306 | 306 | { |
307 | 307 | "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, |
309 | 336 | "id": "b0f150c9-e608-46b5-b020-51c3ffd34fb4", |
310 | 337 | "metadata": { |
311 | 338 | "tags": [] |
|
339 | 366 | } |
340 | 367 | ], |
341 | 368 | "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", |
346 | 370 | "counts = backend.run(t_qc).result().get_counts()\n", |
347 | 371 | "plot_histogram(counts)" |
348 | 372 | ] |
|
0 commit comments