Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed D-wave examples breaking when the Advantage_System4 is in a maintenance window #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -45,14 +45,18 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1)]"
"text/plain": [
"[Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n",
" Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n",
" Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1)]"
]
},
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -64,14 +68,24 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': Advantage_system1.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system1),\n Device('name': Advantage_system3.2, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system3),\n Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n Device('name': Aspen-10, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-10),\n Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11),\n Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n Device('name': Aspen-9, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-9),\n Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
"text/plain": [
"[Device('name': Advantage_system1.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system1),\n",
" Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
" Device('name': Aspen-10, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-10),\n",
" Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11),\n",
" Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n",
" Device('name': Aspen-9, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-9),\n",
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
]
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -91,14 +105,16 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
"text/plain": [
"[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
]
},
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -117,21 +133,29 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4)]"
"text/plain": [
"[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4)]"
]
},
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# for example, the following name refers to a D-Wave Advantage system.\n",
"AwsDevice.get_devices(names=['Advantage_system4.1'])"
"# Note: Given that the D-Wave Advantage_system4 can\n",
"# be in a maintenance window at some point, it is needed\n",
"# to use the follwing branching logic to find the first \n",
"# Advantage device available\n",
"device_names = [device.name for device in AwsDevice.get_devices(provider_names=[\"D-Wave Systems\"], statuses=[\"ONLINE\"])]\n",
"adv_device_names = list(filter(lambda name: \"Advantage\" in name, device_names))\n",
"AwsDevice.get_devices(names=[adv_device_names[0]])"
]
},
{
Expand All @@ -143,14 +167,22 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11),\n Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice),\n Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1)]"
"text/plain": [
"[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice),\n",
" Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n",
" Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n",
" Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1)]"
]
},
"execution_count": 6,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -162,14 +194,16 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': Advantage_system3.2, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system3)]"
"text/plain": [
"[Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11)]"
]
},
"execution_count": 7,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -188,14 +222,16 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
"text/plain": [
"[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
]
},
"execution_count": 8,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -214,14 +250,27 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1),\n Device('name': Advantage_system3.2, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system3),\n Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n Device('name': Advantage_system1.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system1),\n Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice),\n Device('name': Aspen-10, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-10),\n Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n Device('name': Aspen-9, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-9),\n Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11)]"
"text/plain": [
"[Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n",
" Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n",
" Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1),\n",
" Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
" Device('name': Advantage_system1.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system1),\n",
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice),\n",
" Device('name': Aspen-10, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-10),\n",
" Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n",
" Device('name': Aspen-9, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-9),\n",
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
" Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11)]"
]
},
"execution_count": 9,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -240,14 +289,19 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11),\n Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
"text/plain": [
"[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
]
},
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -267,7 +321,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -278,7 +332,13 @@
"device = AwsDevice(\"arn:aws:braket:::device/qpu/ionq/ionQdevice\")\n",
"# DWave\n",
"device = AwsDevice(\"arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6\")\n",
"device = AwsDevice(\"arn:aws:braket:::device/qpu/d-wave/Advantage_system4\")\n",
"# Note: Given that the D-Wave Advantage_system4 can\n",
"# be in a maintenance window at some point, it is needed\n",
"# to use the follwing branching logic to find the first \n",
"# Advantage device available\n",
"device_arns = [device.arn for device in AwsDevice.get_devices(provider_names=[\"D-Wave Systems\"], statuses=[\"ONLINE\"])]\n",
"adv_device_arns = list(filter(lambda arn: \"Advantage\" in arn, device_arns))\n",
"device = AwsDevice(adv_device_arns[0])\n",
"# the on-demand simulator SV1\n",
"device = AwsDevice(\"arn:aws:braket:::device/quantum-simulator/amazon/sv1\")\n",
"# the on-demand simulator TN1\n",
Expand Down Expand Up @@ -1996,9 +2056,9 @@
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"display_name": "Python 3"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -2010,7 +2070,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
990 changes: 764 additions & 226 deletions examples/quantum_annealing/Dwave_Anatomy.ipynb

Large diffs are not rendered by default.

34 changes: 10 additions & 24 deletions examples/quantum_annealing/Dwave_GraphPartitioning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,6 @@
"from dwave.system.composites import EmbeddingComposite"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Device: Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4)\n"
]
}
],
"source": [
"# session and device\n",
"device = AwsDevice(\"arn:aws:braket:::device/qpu/d-wave/Advantage_system4\")\n",
"print('Device:', device)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -234,8 +215,13 @@
"# Run the QUBO on Braket\n",
"start = time.time()\n",
"\n",
"sampler = BraketDWaveSampler(device_arn='arn:aws:braket:::device/qpu/d-wave/Advantage_system4')\n",
"# Set sampler\n",
"# Note: If the device ARN is not specified the sampler will use the\n",
"# first available D-Wave device so long as the problem allows it\n",
"sampler = BraketDWaveSampler()\n",
"print(f\"Currently using: {sampler._device_arn}\")\n",
"sampler = EmbeddingComposite(sampler)\n",
"\n",
"response = sampler.sample_qubo(Q, chain_strength=chain_strength, num_reads=num_reads)\n",
"\n",
"# See if the best solution found is feasible, and if so print the number of cut edges.\n",
Expand Down Expand Up @@ -396,9 +382,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "conda_braket",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "conda_braket"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -410,9 +396,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}
Loading