Skip to content

Commit 50bb8e6

Browse files
Fixed D-wave examples breaking when the Advantage_System4 is in a maintenance window
1 parent bb4e90e commit 50bb8e6

17 files changed

+1362
-399
lines changed

examples/braket_features/Getting_Devices_and_Checking_Device_Properties.ipynb

Lines changed: 94 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": 1,
14+
"execution_count": 2,
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
@@ -45,14 +45,18 @@
4545
},
4646
{
4747
"cell_type": "code",
48-
"execution_count": 2,
48+
"execution_count": 3,
4949
"metadata": {},
5050
"outputs": [
5151
{
5252
"data": {
53-
"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)]"
53+
"text/plain": [
54+
"[Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n",
55+
" Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n",
56+
" Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1)]"
57+
]
5458
},
55-
"execution_count": 2,
59+
"execution_count": 3,
5660
"metadata": {},
5761
"output_type": "execute_result"
5862
}
@@ -64,14 +68,24 @@
6468
},
6569
{
6670
"cell_type": "code",
67-
"execution_count": 3,
71+
"execution_count": 4,
6872
"metadata": {},
6973
"outputs": [
7074
{
7175
"data": {
72-
"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)]"
76+
"text/plain": [
77+
"[Device('name': Advantage_system1.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system1),\n",
78+
" Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
79+
" Device('name': Aspen-10, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-10),\n",
80+
" Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11),\n",
81+
" Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n",
82+
" Device('name': Aspen-9, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-9),\n",
83+
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
84+
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
85+
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
86+
]
7387
},
74-
"execution_count": 3,
88+
"execution_count": 4,
7589
"metadata": {},
7690
"output_type": "execute_result"
7791
}
@@ -91,14 +105,16 @@
91105
},
92106
{
93107
"cell_type": "code",
94-
"execution_count": 4,
108+
"execution_count": 5,
95109
"metadata": {},
96110
"outputs": [
97111
{
98112
"data": {
99-
"text/plain": "[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
113+
"text/plain": [
114+
"[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
115+
]
100116
},
101-
"execution_count": 4,
117+
"execution_count": 5,
102118
"metadata": {},
103119
"output_type": "execute_result"
104120
}
@@ -117,21 +133,29 @@
117133
},
118134
{
119135
"cell_type": "code",
120-
"execution_count": 5,
136+
"execution_count": 8,
121137
"metadata": {},
122138
"outputs": [
123139
{
124140
"data": {
125-
"text/plain": "[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4)]"
141+
"text/plain": [
142+
"[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4)]"
143+
]
126144
},
127-
"execution_count": 5,
145+
"execution_count": 8,
128146
"metadata": {},
129147
"output_type": "execute_result"
130148
}
131149
],
132150
"source": [
133151
"# for example, the following name refers to a D-Wave Advantage system.\n",
134-
"AwsDevice.get_devices(names=['Advantage_system4.1'])"
152+
"# Note: Given that the D-Wave Advantage_system4 can\n",
153+
"# be in a maintenance window at some point, it is needed\n",
154+
"# to use the follwing branching logic to find the first \n",
155+
"# Advantage device available\n",
156+
"device_names = [device.name for device in AwsDevice.get_devices(provider_names=[\"D-Wave Systems\"], statuses=[\"ONLINE\"])]\n",
157+
"adv_device_names = list(filter(lambda name: \"Advantage\" in name, device_names))\n",
158+
"AwsDevice.get_devices(names=[adv_device_names[0]])"
135159
]
136160
},
137161
{
@@ -143,14 +167,22 @@
143167
},
144168
{
145169
"cell_type": "code",
146-
"execution_count": 6,
170+
"execution_count": 9,
147171
"metadata": {},
148172
"outputs": [
149173
{
150174
"data": {
151-
"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)]"
175+
"text/plain": [
176+
"[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
177+
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
178+
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
179+
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice),\n",
180+
" Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n",
181+
" Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n",
182+
" Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1)]"
183+
]
152184
},
153-
"execution_count": 6,
185+
"execution_count": 9,
154186
"metadata": {},
155187
"output_type": "execute_result"
156188
}
@@ -162,14 +194,16 @@
162194
},
163195
{
164196
"cell_type": "code",
165-
"execution_count": 7,
197+
"execution_count": 10,
166198
"metadata": {},
167199
"outputs": [
168200
{
169201
"data": {
170-
"text/plain": "[Device('name': Advantage_system3.2, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system3)]"
202+
"text/plain": [
203+
"[Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11)]"
204+
]
171205
},
172-
"execution_count": 7,
206+
"execution_count": 10,
173207
"metadata": {},
174208
"output_type": "execute_result"
175209
}
@@ -188,14 +222,16 @@
188222
},
189223
{
190224
"cell_type": "code",
191-
"execution_count": 8,
225+
"execution_count": 11,
192226
"metadata": {},
193227
"outputs": [
194228
{
195229
"data": {
196-
"text/plain": "[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
230+
"text/plain": [
231+
"[Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
232+
]
197233
},
198-
"execution_count": 8,
234+
"execution_count": 11,
199235
"metadata": {},
200236
"output_type": "execute_result"
201237
}
@@ -214,14 +250,27 @@
214250
},
215251
{
216252
"cell_type": "code",
217-
"execution_count": 9,
253+
"execution_count": 12,
218254
"metadata": {},
219255
"outputs": [
220256
{
221257
"data": {
222-
"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)]"
258+
"text/plain": [
259+
"[Device('name': TN1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/tn1),\n",
260+
" Device('name': SV1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/sv1),\n",
261+
" Device('name': dm1, 'arn': arn:aws:braket:::device/quantum-simulator/amazon/dm1),\n",
262+
" Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
263+
" Device('name': Advantage_system1.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system1),\n",
264+
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
265+
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice),\n",
266+
" Device('name': Aspen-10, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-10),\n",
267+
" Device('name': Aspen-8, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-8),\n",
268+
" Device('name': Aspen-9, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-9),\n",
269+
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
270+
" Device('name': Aspen-11, 'arn': arn:aws:braket:::device/qpu/rigetti/Aspen-11)]"
271+
]
223272
},
224-
"execution_count": 9,
273+
"execution_count": 12,
225274
"metadata": {},
226275
"output_type": "execute_result"
227276
}
@@ -240,14 +289,19 @@
240289
},
241290
{
242291
"cell_type": "code",
243-
"execution_count": 10,
292+
"execution_count": 13,
244293
"metadata": {},
245294
"outputs": [
246295
{
247296
"data": {
248-
"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)]"
297+
"text/plain": [
298+
"[Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4),\n",
299+
" Device('name': Aspen-M-1, 'arn': arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1),\n",
300+
" Device('name': DW_2000Q_6, 'arn': arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6),\n",
301+
" Device('name': IonQ Device, 'arn': arn:aws:braket:::device/qpu/ionq/ionQdevice)]"
302+
]
249303
},
250-
"execution_count": 10,
304+
"execution_count": 13,
251305
"metadata": {},
252306
"output_type": "execute_result"
253307
}
@@ -267,7 +321,7 @@
267321
},
268322
{
269323
"cell_type": "code",
270-
"execution_count": 11,
324+
"execution_count": 14,
271325
"metadata": {},
272326
"outputs": [],
273327
"source": [
@@ -278,7 +332,13 @@
278332
"device = AwsDevice(\"arn:aws:braket:::device/qpu/ionq/ionQdevice\")\n",
279333
"# DWave\n",
280334
"device = AwsDevice(\"arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6\")\n",
281-
"device = AwsDevice(\"arn:aws:braket:::device/qpu/d-wave/Advantage_system4\")\n",
335+
"# Note: Given that the D-Wave Advantage_system4 can\n",
336+
"# be in a maintenance window at some point, it is needed\n",
337+
"# to use the follwing branching logic to find the first \n",
338+
"# Advantage device available\n",
339+
"device_arns = [device.arn for device in AwsDevice.get_devices(provider_names=[\"D-Wave Systems\"], statuses=[\"ONLINE\"])]\n",
340+
"adv_device_arns = list(filter(lambda arn: \"Advantage\" in arn, device_arns))\n",
341+
"device = AwsDevice(adv_device_arns[0])\n",
282342
"# the on-demand simulator SV1\n",
283343
"device = AwsDevice(\"arn:aws:braket:::device/quantum-simulator/amazon/sv1\")\n",
284344
"# the on-demand simulator TN1\n",
@@ -1996,9 +2056,9 @@
19962056
],
19972057
"metadata": {
19982058
"kernelspec": {
1999-
"name": "python3",
2059+
"display_name": "Python 3 (ipykernel)",
20002060
"language": "python",
2001-
"display_name": "Python 3"
2061+
"name": "python3"
20022062
},
20032063
"language_info": {
20042064
"codemirror_mode": {
@@ -2010,7 +2070,7 @@
20102070
"name": "python",
20112071
"nbconvert_exporter": "python",
20122072
"pygments_lexer": "ipython3",
2013-
"version": "3.7.7"
2073+
"version": "3.9.7"
20142074
}
20152075
},
20162076
"nbformat": 4,

examples/quantum_annealing/Dwave_Anatomy.ipynb

Lines changed: 764 additions & 226 deletions
Large diffs are not rendered by default.

examples/quantum_annealing/Dwave_GraphPartitioning.ipynb

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,6 @@
4646
"from dwave.system.composites import EmbeddingComposite"
4747
]
4848
},
49-
{
50-
"cell_type": "code",
51-
"execution_count": 4,
52-
"metadata": {},
53-
"outputs": [
54-
{
55-
"name": "stdout",
56-
"output_type": "stream",
57-
"text": [
58-
"Device: Device('name': Advantage_system4.1, 'arn': arn:aws:braket:::device/qpu/d-wave/Advantage_system4)\n"
59-
]
60-
}
61-
],
62-
"source": [
63-
"# session and device\n",
64-
"device = AwsDevice(\"arn:aws:braket:::device/qpu/d-wave/Advantage_system4\")\n",
65-
"print('Device:', device)"
66-
]
67-
},
6849
{
6950
"cell_type": "markdown",
7051
"metadata": {},
@@ -234,8 +215,13 @@
234215
"# Run the QUBO on Braket\n",
235216
"start = time.time()\n",
236217
"\n",
237-
"sampler = BraketDWaveSampler(device_arn='arn:aws:braket:::device/qpu/d-wave/Advantage_system4')\n",
218+
"# Set sampler\n",
219+
"# Note: If the device ARN is not specified the sampler will use the\n",
220+
"# first available D-Wave device so long as the problem allows it\n",
221+
"sampler = BraketDWaveSampler()\n",
222+
"print(f\"Currently using: {sampler._device_arn}\")\n",
238223
"sampler = EmbeddingComposite(sampler)\n",
224+
"\n",
239225
"response = sampler.sample_qubo(Q, chain_strength=chain_strength, num_reads=num_reads)\n",
240226
"\n",
241227
"# See if the best solution found is feasible, and if so print the number of cut edges.\n",
@@ -396,9 +382,9 @@
396382
],
397383
"metadata": {
398384
"kernelspec": {
399-
"display_name": "conda_braket",
385+
"display_name": "Python 3 (ipykernel)",
400386
"language": "python",
401-
"name": "conda_braket"
387+
"name": "python3"
402388
},
403389
"language_info": {
404390
"codemirror_mode": {
@@ -410,9 +396,9 @@
410396
"name": "python",
411397
"nbconvert_exporter": "python",
412398
"pygments_lexer": "ipython3",
413-
"version": "3.7.9"
399+
"version": "3.9.7"
414400
}
415401
},
416402
"nbformat": 4,
417403
"nbformat_minor": 4
418-
}
404+
}

0 commit comments

Comments
 (0)