Skip to content

Commit

Permalink
fix: run notebooks, update noise model
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeach-aws committed Sep 26, 2024
1 parent 3150cd6 commit ed872de
Show file tree
Hide file tree
Showing 5 changed files with 2,270 additions and 474 deletions.
161 changes: 145 additions & 16 deletions examples/braket_features/Allocating_Qubits_on_QPU_Devices.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,40 @@
"name": "#%%\n"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Measurement counts: Counter({'111': 6, '000': 3, '101': 1})\n",
"The compiled circuit is:\n",
" PRAGMA INITIAL_REWIRING \"NAIVE\"\n",
"DECLARE ro BIT[3]\n",
"PRAGMA PRESERVE_BLOCK\n",
"RX(1.5707963267948966) 5\n",
"RZ(3.141592653589793) 5\n",
"ISWAP 5 12\n",
"RZ(1.5707963267948966) 5\n",
"RX(1.5707963267948966) 5\n",
"RZ(4.71238898038469) 5\n",
"ISWAP 5 12\n",
"RZ(1.5707963267948966) 5\n",
"RZ(3.141592653589793) 12\n",
"ISWAP 5 6\n",
"RX(1.5707963267948966) 12\n",
"RZ(1.5707963267948966) 5\n",
"RX(1.5707963267948966) 5\n",
"RZ(4.71238898038469) 5\n",
"ISWAP 5 6\n",
"RZ(3.141592653589793) 6\n",
"RX(1.5707963267948966) 6\n",
"PRAGMA END_PRESERVE_BLOCK\n",
"MEASURE 12 ro[1]\n",
"MEASURE 5 ro[0]\n",
"MEASURE 6 ro[2]\n"
]
}
],
"source": [
"result = rigetti_rewiring.result()\n",
"counts = result.measurement_counts\n",
Expand Down Expand Up @@ -204,13 +237,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"T : │ 0 │ 1 │\n",
" ┌──────────┐ \n",
"q0 : ─┤ Rz(1.57) ├───●───\n",
" └──────────┘ │ \n",
" ┌─┴─┐ \n",
"q1 : ──────────────┤ X ├─\n",
" └───┘ \n",
" ┌───┐ \n",
"q7 : ────┤ X ├───────────\n",
" └───┘ \n",
"T : │ 0 │ 1 │\n"
]
}
],
"source": [
"# create a random state with neighboring qubits\n",
"q1=random.choice(list(connectivity_graph))\n",
Expand All @@ -225,18 +276,49 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Status of quantum task: QUEUED\n"
]
}
],
"source": [
"print(\"Status of quantum task:\", rigetti_task.state())"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Measurement counts: Counter({'001': 7, '000': 2, '011': 1})\n",
"The compiled circuit is:\n",
" PRAGMA INITIAL_REWIRING \"NAIVE\"\n",
"DECLARE ro BIT[3]\n",
"PRAGMA PRESERVE_BLOCK\n",
"RX(1.5707963267948966) 0\n",
"RX(1.5707963267948966) 7\n",
"RZ(4.71238898038469) 0\n",
"RX(1.5707963267948966) 7\n",
"ISWAP 0 1\n",
"RZ(3.141592653589793) 1\n",
"RX(1.5707963267948966) 1\n",
"PRAGMA END_PRESERVE_BLOCK\n",
"MEASURE 7 ro[2]\n",
"MEASURE 0 ro[0]\n",
"MEASURE 1 ro[1]\n"
]
}
],
"source": [
"result = rigetti_task.result()\n",
"counts = result.measurement_counts\n",
Expand Down Expand Up @@ -268,9 +350,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"['RX', 'RZ', 'CZ', 'ISWAP']"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"native_gates = device.properties.paradigm.nativeGateSet\n",
"gates_uppercase = [gate.upper() for gate in native_gates]\n",
Expand All @@ -279,7 +372,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 11,
"metadata": {
"pycharm": {
"name": "#%%\n"
Expand Down Expand Up @@ -338,13 +431,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The highest fidelity for ISWAP gate is: 0.99312484820244\n",
"And the corresponding qubit pair is: qubit 73 and qubit 74\n",
"T : │ 0 │\n",
" \n",
"q73 : ───●───\n",
"\n",
" ┌─┴─┐ \n",
"q74 : ─┤ Z ├─\n",
" └───┘ \n",
"T : │ 0 │\n"
]
}
],
"source": [
"# the gate must be a native gate\n",
"gate = 'ISWAP'\n",
Expand All @@ -363,9 +473,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Status of quantum task: QUEUED\n"
]
}
],
"source": [
"print(\"Status of quantum task:\", rigetti_task.state())"
]
Expand All @@ -392,9 +510,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Quantum Task Summary\n",
"{<_Rigetti.Ankaa2: 'arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2'>: {'shots': 1020, 'tasks': {'COMPLETED': 2, 'QUEUED': 1}}}\n",
"Note: Charges shown are estimates based on your Amazon Braket simulator and quantum processing unit (QPU) task usage. Estimated charges shown may differ from your actual charges. Estimated charges do not factor in any discounts or credits, and you may experience additional charges based on your use of other services such as Amazon Elastic Compute Cloud (Amazon EC2).\n",
"Estimated cost to run this example: 1.82 USD\n"
]
}
],
"source": [
"print(\"Quantum Task Summary\")\n",
"print(t.quantum_tasks_statistics())\n",
Expand Down
Loading

0 comments on commit ed872de

Please sign in to comment.