Skip to content

Commit 3e53247

Browse files
committed
fix pytket
1 parent 6e6cf02 commit 3e53247

File tree

5 files changed

+43
-52
lines changed

5 files changed

+43
-52
lines changed

braket/main.ipynb

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "151d6c64",
77
"metadata": {},
88
"outputs": [],
@@ -14,69 +14,40 @@
1414
},
1515
{
1616
"cell_type": "code",
17-
"execution_count": 2,
17+
"execution_count": null,
1818
"id": "ff988bb3",
1919
"metadata": {},
2020
"outputs": [],
2121
"source": [
22-
"from braket.circuits import Circuit"
22+
"from braket.circuits import Circuit\n",
23+
"from braket.aws import AwsDevice\n",
24+
"\n",
25+
"device = AwsDevice(\"arn:aws:braket:::device/qpu/ionq/ionQdevice\")"
2326
]
2427
},
2528
{
2629
"cell_type": "code",
27-
"execution_count": 3,
30+
"execution_count": null,
2831
"id": "b7dd4b92",
2932
"metadata": {},
30-
"outputs": [
31-
{
32-
"name": "stdout",
33-
"output_type": "stream",
34-
"text": [
35-
"T : |0|1|\n",
36-
" \n",
37-
"q0 : -H-C-\n",
38-
" | \n",
39-
"q1 : ---X-\n",
40-
"\n",
41-
"T : |0|1|\n"
42-
]
43-
}
44-
],
33+
"outputs": [],
4534
"source": [
4635
"qc = Circuit()\n",
4736
"qc.h(0)\n",
48-
"qc.cnot(control=0, target=1)\n",
37+
"qc.cnot(0, 1)\n",
4938
"\n",
5039
"print(qc)"
5140
]
5241
},
53-
{
54-
"cell_type": "code",
55-
"execution_count": null,
56-
"id": "7c83f913",
57-
"metadata": {},
58-
"outputs": [],
59-
"source": [
60-
"device = AwsDevice(\"arn:aws:braket:::device/qpu/ionq/ionQdevice\")\n",
61-
"\n",
62-
"# Enter the name of S3 bucket you created earlier\n",
63-
"my_bucket = \"amazon-braket-Your-Bucket-Name\" # the name of the bucket\n",
64-
"my_prefix = \"Your-Folder-Name\" # the name of the folder in the bucket\n",
65-
"s3_folder = (my_bucket, my_prefix)"
66-
]
67-
},
6842
{
6943
"cell_type": "code",
7044
"execution_count": null,
7145
"id": "4e02b63e",
7246
"metadata": {},
7347
"outputs": [],
7448
"source": [
75-
"result = device.run(qc, s3_folder, shots=1000).result()\n",
76-
"\n",
77-
"# Get measurement counts\n",
78-
"counts = result.measurement_counts\n",
79-
"print(counts)"
49+
"task = device.run(bell, shots=100)\n",
50+
"print(task.result().measurement_counts)"
8051
]
8152
}
8253
],

pytket/main.ipynb

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 3,
66
"id": "151d6c64",
77
"metadata": {},
88
"outputs": [],
99
"source": [
1010
"%%capture\n",
1111
"\n",
12-
"!pip install pytket"
12+
"!pip install pytket pytket-ionq"
1313
]
1414
},
1515
{
1616
"cell_type": "code",
17-
"execution_count": null,
17+
"execution_count": 7,
1818
"id": "f3042105",
1919
"metadata": {},
2020
"outputs": [],
@@ -27,15 +27,26 @@
2727
"\n",
2828
"# Get your API key from https://cloud.ionq.com/settings/keys\n",
2929
"api_key = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')\n",
30-
"backend = IonQBackend(api_key=api_key, device_name=\"qpu\")"
30+
"backend = IonQBackend(api_key=api_key, device_name=\"simulator\")"
3131
]
3232
},
3333
{
3434
"cell_type": "code",
35-
"execution_count": null,
35+
"execution_count": 8,
3636
"id": "bd2c2829",
3737
"metadata": {},
38-
"outputs": [],
38+
"outputs": [
39+
{
40+
"data": {
41+
"text/plain": [
42+
"[H q[0]; CX q[0], q[1]; Measure q[0] --> c[0]; Measure q[1] --> c[1]; ]"
43+
]
44+
},
45+
"execution_count": 8,
46+
"metadata": {},
47+
"output_type": "execute_result"
48+
}
49+
],
3950
"source": [
4051
"qc = Circuit(2, 2)\n",
4152
"qc.H(0)\n",
@@ -45,12 +56,20 @@
4556
},
4657
{
4758
"cell_type": "code",
48-
"execution_count": null,
59+
"execution_count": 10,
4960
"id": "6aa9658d",
5061
"metadata": {},
51-
"outputs": [],
62+
"outputs": [
63+
{
64+
"name": "stdout",
65+
"output_type": "stream",
66+
"text": [
67+
"Counter({(0, 0): 55, (1, 1): 45})\n"
68+
]
69+
}
70+
],
5271
"source": [
53-
"backend.compile_circuit(qc)\n",
72+
"backend.get_compiled_circuit(qc)\n",
5473
"handle = backend.process_circuit(qc, 100)\n",
5574
"counts = backend.get_result(handle).get_counts()\n",
5675
"print(counts)"

qsharp/main.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
" resourceId=\"the name of your quantum resource\",\n",
2828
" location=\"East US\",\n",
2929
")\n",
30-
"qsharp.azure.target(\"ionq.qpu\")"
30+
"qsharp.azure.target(\"ionq.harmony\")"
3131
]
3232
},
3333
{
@@ -37,7 +37,7 @@
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
40-
"result = qsharp.azure.execute(MeasureEntanglement, shots=1000, jobName=\"Bell\")\n",
40+
"result = qsharp.azure.execute(MeasureEntanglement, shots=100, jobName=\"Bell\")\n",
4141
"print(result)"
4242
]
4343
}

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cuda-quantum
99
amazon-braket-sdk
1010
qsharp
1111
pytket
12+
pytket-ionq
1213
xacc
1314
matplotlib
1415
pylatexenc

xacc/main.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"metadata": {},
3030
"outputs": [],
3131
"source": [
32-
"ionq = xacc.getAccelerator(\"ionq:qpu\")\n",
32+
"ionq = xacc.getAccelerator(\"ionq:simulator\")\n",
3333
"compiler = xacc.getCompiler(\"xasm\")\n",
3434
"ir = compiler.compile(r\"\"\"__qpu__ void bell(qbit q) {\n",
3535
" H(q[0]);\n",

0 commit comments

Comments
 (0)