Skip to content

Commit 8c126d6

Browse files
Sdk version updates (#42)
* initial updates * initial changes for sdk 0.8.3 * update aws quantum jobs notebook * remove output of provider nb
1 parent 8431851 commit 8c126d6

16 files changed

+1184
-805
lines changed

qbraid_lab/quantum_jobs/aws_iqm_quantum_jobs.ipynb

Lines changed: 19 additions & 34 deletions
Large diffs are not rendered by default.

qbraid_lab/quantum_jobs/aws_oqc_quantum_jobs.ipynb

Lines changed: 578 additions & 0 deletions
Large diffs are not rendered by default.

qbraid_lab/quantum_jobs/aws_quantum_jobs.ipynb

Lines changed: 106 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -11,94 +11,150 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": 1,
14-
"id": "ece364ef-f49e-4a56-b32c-77aee1f1912f",
14+
"id": "de7f060e",
1515
"metadata": {},
1616
"outputs": [
1717
{
1818
"name": "stdout",
1919
"output_type": "stream",
2020
"text": [
21-
"\u001b[0;35mSuccessfully enabled qBraid Quantum Jobs in the \u001b[1;35mamazon_braket\u001b[0m\u001b[0;35m environment.\u001b[0m\n",
22-
"\u001b[0;35mEvery \u001b[1;35mAWS\u001b[0m\u001b[0;35m job you run will now be submitted through the qBraid API, so no access keys/tokens are necessary. \u001b[0m\n",
23-
"\n",
24-
"\u001b[0;35mTo disable, run:\u001b[0m `qbraid jobs disable amazon_braket`\n"
21+
"Note: you may need to restart the kernel to use updated packages.\n"
2522
]
2623
}
2724
],
2825
"source": [
29-
"# enable qBraid Quantum Jobs\n",
30-
"!qbraid jobs enable amazon_braket"
26+
"%pip install -q amazon-braket-sdk"
3127
]
3228
},
3329
{
3430
"cell_type": "code",
3531
"execution_count": 2,
32+
"id": "e668cc2b-2107-4f2a-bc65-1aa6da9b72cf",
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"# !qbraid configure magic"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 3,
42+
"id": "829a72b8",
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"%load_ext qbraid_magic"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": 4,
52+
"id": "c962fcc4-6e09-43b9-af3f-13b8bd36bc3e",
53+
"metadata": {},
54+
"outputs": [
55+
{
56+
"name": "stdout",
57+
"output_type": "stream",
58+
"text": [
59+
"qbraid-cli/0.9.0a0\n"
60+
]
61+
}
62+
],
63+
"source": [
64+
"%qbraid --version"
65+
]
66+
},
67+
{
68+
"cell_type": "code",
69+
"execution_count": 5,
70+
"id": "1635d207-9650-4bb5-9f72-9a386021858c",
71+
"metadata": {},
72+
"outputs": [
73+
{
74+
"name": "stdout",
75+
"output_type": "stream",
76+
"text": [
77+
"\n",
78+
"qBraid quantum jobs already \u001b[1;32menabled\u001b[0m for \u001b[35mbraket\u001b[0m.\n",
79+
"\n",
80+
"Check the state of all quantum jobs libraries in this environment with: \n",
81+
"\n",
82+
" $ qbraid jobs state\n",
83+
"\n"
84+
]
85+
}
86+
],
87+
"source": [
88+
"%qbraid jobs enable braket -y"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": 6,
3694
"id": "c2faa670-1fe9-47f2-9cfe-d488517914a3",
3795
"metadata": {},
3896
"outputs": [
3997
{
4098
"name": "stdout",
4199
"output_type": "stream",
42100
"text": [
43-
"# installed environments:\n",
44-
"#\n",
45-
"qsharp /opt/.qbraid/environments/qsharp_b54crn\n",
46-
"default \u001b[0;31mjobs\u001b[0m /opt/.qbraid/environments/qbraid_000000\n",
47-
"qiskit \u001b[0;31mjobs\u001b[0m /home/jovyan/.qbraid/environments/qiskit_9y9siy\n",
48-
"amazon_braket \u001b[0;32mjobs\u001b[0m /home/jovyan/.qbraid/environments/aws_braket_kwx6dl\n",
49-
"intel /opt/.qbraid/environments/intel_zr7hfq\n",
50-
"qbraid_sdk \u001b[0;31mjobs\u001b[0m /home/jovyan/.qbraid/environments/qbraid_sdk_9j9sjy\n",
101+
"Executable: \u001b[35m/opt/.qbraid/environments/qbraid_000000/pyenv/bin/\u001b[0m\u001b[95mpython\u001b[0m\n",
102+
"\n",
103+
"\u001b[1mLibrary State\u001b[0m\n",
104+
"braket \u001b[32menabled\u001b[0m\n",
51105
"\n"
52106
]
53107
}
54108
],
55109
"source": [
56-
"# list installed environments, check jobs keyword is green for Amazon Braket\n",
57-
"!qbraid envs list"
110+
"%qbraid jobs state"
58111
]
59112
},
60113
{
61114
"cell_type": "code",
62-
"execution_count": 3,
115+
"execution_count": 7,
63116
"id": "f17a39b3-74b6-4798-9d8c-164d884e1251",
64117
"metadata": {},
65118
"outputs": [
66119
{
67120
"name": "stdout",
68121
"output_type": "stream",
69122
"text": [
70-
"\u001b[0;35mYou have \u001b[0m1000.00\u001b[0;35m remaining qBraid credits.\u001b[0m\n"
123+
"\n",
124+
"qBraid credits remaining: 1912.9763\n",
125+
"\n",
126+
"For more information, visit: \u001b[4;94mhttps://docs.qbraid.com/home/pricing#credits\u001b[0m\n"
71127
]
72128
}
73129
],
74130
"source": [
75-
"# check qBraid credits\n",
76-
"!qbraid jobs get-credits"
131+
"%qbraid account credits"
77132
]
78133
},
79134
{
80135
"cell_type": "code",
81-
"execution_count": 1,
136+
"execution_count": 8,
82137
"id": "e7fb9ec2-0500-4fd7-b9a5-952805764efc",
83138
"metadata": {},
84139
"outputs": [
85140
{
86141
"name": "stdout",
87142
"output_type": "stream",
88143
"text": [
89-
"T : |0|1|\n",
90-
" \n",
91-
"q0 : -H-C-\n",
92-
" | \n",
93-
"q1 : ---X-\n",
94-
"\n",
95-
"T : |0|1|\n"
144+
"T : │ 0 │ 1 │\n",
145+
" ┌───┐ \n",
146+
"q0 : ─┤ H ├───●───\n",
147+
" └───┘ │ \n",
148+
" ┌─┴─┐ \n",
149+
"q1 : ───────┤ X ├─\n",
150+
" └───┘ \n",
151+
"T : │ 0 │ 1 │\n"
96152
]
97153
}
98154
],
99155
"source": [
100156
"import boto3\n",
101-
"from braket.aws import AwsDevice, AwsQuantumTask\n",
157+
"from braket.aws import AwsDevice\n",
102158
"from braket.circuits import Circuit\n",
103159
"\n",
104160
"# create the Amazon Braket circuit\n",
@@ -109,7 +165,7 @@
109165
},
110166
{
111167
"cell_type": "code",
112-
"execution_count": 2,
168+
"execution_count": 9,
113169
"id": "9319ff25-f872-4cf4-8943-8453aaaa3ada",
114170
"metadata": {},
115171
"outputs": [],
@@ -123,134 +179,72 @@
123179
},
124180
{
125181
"cell_type": "code",
126-
"execution_count": 3,
182+
"execution_count": 10,
127183
"id": "d839f8db-0928-464f-9b26-06d89741bd05",
128184
"metadata": {},
129185
"outputs": [],
130186
"source": [
131187
"# execute the circuit\n",
132-
"task = device.run(bell, shots=10)"
188+
"task = device.run(bell, shots=100)"
133189
]
134190
},
135191
{
136192
"cell_type": "code",
137-
"execution_count": 5,
193+
"execution_count": 11,
138194
"id": "602ae9e2-675f-4a7d-8ad2-8dded3c19ca4",
139195
"metadata": {},
140-
"outputs": [],
141-
"source": [
142-
"# display the results\n",
143-
"print(task.result().measurement_counts)"
144-
]
145-
},
146-
{
147-
"cell_type": "code",
148-
"execution_count": 8,
149-
"id": "fb323eeb-2f53-4fa1-b8e4-d915caf57981",
150-
"metadata": {},
151-
"outputs": [
152-
{
153-
"name": "stdout",
154-
"output_type": "stream",
155-
"text": [
156-
"Fri Apr 21 2023 15:57:10 GMT+0000 (Coordinated Universal Time) arn:aws:braket:::device/quantum-simulator/amazon/sv1 arn:aws:braket:us-east-1:592242689881:quantum-task/ca33820b-987b-42e1-bac5-8b382324fe12\n",
157-
"\n"
158-
]
159-
}
160-
],
161-
"source": [
162-
"# list submitted jobs\n",
163-
"!qbraid jobs list"
164-
]
165-
},
166-
{
167-
"cell_type": "code",
168-
"execution_count": 9,
169-
"id": "2b0a87d2-865b-4d52-a01b-ccc1cf01c707",
170-
"metadata": {},
171196
"outputs": [
172197
{
173198
"name": "stdout",
174199
"output_type": "stream",
175200
"text": [
176-
"\u001b[0;35mYou have \u001b[0m999.60\u001b[0;35m remaining qBraid credits.\u001b[0m\n"
201+
"Counter({'00': 56, '11': 44})\n"
177202
]
178203
}
179204
],
180205
"source": [
181-
"# check remaining qBraid credits\n",
182-
"!qbraid jobs get-credits"
206+
"# display the results\n",
207+
"print(task.result().measurement_counts)"
183208
]
184209
},
185210
{
186211
"cell_type": "code",
187-
"execution_count": 10,
188-
"id": "36e52a6b-35dc-4ec4-8389-adda483fb92f",
212+
"execution_count": 12,
213+
"id": "fb323eeb-2f53-4fa1-b8e4-d915caf57981",
189214
"metadata": {},
190215
"outputs": [],
191216
"source": [
192-
"client = boto3.client(\"braket\")"
217+
"# %qbraid jobs list"
193218
]
194219
},
195220
{
196221
"cell_type": "code",
197-
"execution_count": 11,
198-
"id": "5bf07028-5ea1-4776-9c05-7a2f8872a134",
199-
"metadata": {},
200-
"outputs": [
201-
{
202-
"name": "stdout",
203-
"output_type": "stream",
204-
"text": [
205-
"createdAt: 2023-04-21 15:57:09.862000+00:00\n",
206-
"endedAt: 2023-04-21 15:57:11.556000+00:00\n",
207-
"costEstimate: 0.4000012 credits ~ $0.004000012\n"
208-
]
209-
}
210-
],
211-
"source": [
212-
"# retrieve job data from braket boto3\n",
213-
"boto_data = client.search_quantum_tasks(\n",
214-
" filters=[{\"name\": \"quantumTaskArn\", \"operator\": \"EQUAL\", \"values\": [task.id]}],\n",
215-
")\n",
216-
"\n",
217-
"job_data = boto_data[\"quantumTasks\"][0]\n",
218-
"created = job_data[\"createdAt\"]\n",
219-
"ended = job_data[\"endedAt\"]\n",
220-
"cost = float(job_data[\"tags\"][\"costEstimate\"])\n",
221-
"\n",
222-
"print(f\"createdAt: {created}\")\n",
223-
"print(f\"endedAt: {ended}\")\n",
224-
"print(f\"costEstimate: {cost} credits ~ ${cost/100}\")"
225-
]
226-
},
227-
{
228-
"cell_type": "code",
229-
"execution_count": 12,
230-
"id": "6470f22f-9a07-4c64-b02b-b268d54b80b6",
222+
"execution_count": 13,
223+
"id": "2b0a87d2-865b-4d52-a01b-ccc1cf01c707",
231224
"metadata": {},
232225
"outputs": [
233226
{
234227
"name": "stdout",
235228
"output_type": "stream",
236229
"text": [
237-
"\u001b[0;35mDisable successful. You are now submitting quantum jobs with your own AWS credentials.\u001b[0m\n",
238230
"\n",
239-
"\u001b[0;35mTo re-enable, run:\u001b[0m `qbraid jobs enable amazon_braket`\n"
231+
"qBraid credits remaining: 1909.2263\n",
232+
"\n",
233+
"For more information, visit: \u001b[4;94mhttps://docs.qbraid.com/home/pricing#credits\u001b[0m\n"
240234
]
241235
}
242236
],
243237
"source": [
244-
"# disable qBraid Quantum Jobs\n",
245-
"!qbraid jobs disable amazon_braket"
238+
"# check remaining qBraid credits\n",
239+
"%qbraid account credits"
246240
]
247241
}
248242
],
249243
"metadata": {
250244
"kernelspec": {
251-
"display_name": "Python 3 [Braket]",
245+
"display_name": "Python 3 [Default]",
252246
"language": "python",
253-
"name": "python3_aws_braket_kwx6dl"
247+
"name": "python3"
254248
},
255249
"language_info": {
256250
"codemirror_mode": {
@@ -262,7 +256,7 @@
262256
"name": "python",
263257
"nbconvert_exporter": "python",
264258
"pygments_lexer": "ipython3",
265-
"version": "3.9.10"
259+
"version": "3.11.9"
266260
}
267261
},
268262
"nbformat": 4,

0 commit comments

Comments
 (0)