Hello, I will try using the latest quantum computer.
I used the Aria1 processor on Amazon Braket. It's the latest ion trap with 25 qubits.
Loading the tools.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import string
import time
from braket.circuits import Circuit, Gate, Observable, FreeParameter
from braket.devices import LocalSimulator
from braket.aws import AwsDevice, AwsQuantumTask
First, let's start with a simple entangled circuit.
bell = Circuit().h(0).cnot(0, 1)
print(bell)
I will draw the circuit.
T : |0|1|
q0 : -H-C-
|
q1 : ---X-
T : |0|1|
First, I will view the results using a simulator.
device = LocalSimulator()
result = device.run(bell, shots=1000).result()
counts = result.measurement_counts
print(counts)
Counter({'11': 505, '00': 495})
plt.bar(counts.keys(), counts.values())
plt.xlabel('bitstrings')
plt.ylabel('counts')
Next, we will try Aria1 instead of a local simulator
aria = AwsDevice("arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1")
aria.queue_depth().quantum_tasks
we post the job
aria_task = aria.run(bell, shots=1000)
aria_task_id = aria_task.id
aria_status = aria_task.state()
print('Status of quantum task:', aria_status)
Status of quantum task: CREATED
now on amazon braket we can get the queue position
aria_task.queue_position().queue_position
And once it finished we can get the job result.
task_load_aria = AwsQuantumTask(arn=aria_task_id)
status_aria = task_load_aria.state()
print('Status of (reconstructed) quantum task:', status_aria)
if status_aria == 'COMPLETED':
results = task_load_aria.result()
metadata = task_load_aria.metadata()
shots = metadata['shots']
machine = metadata['deviceArn']
print("{} shots taken on machine {}.".format(shots, machine))
counts = results.measurement_counts
print('Measurement counts:', counts)
plt.bar(counts.keys(), counts.values())
plt.xlabel('bitstrings')
plt.ylabel('counts')
plt.tight_layout()
plt.savefig('bell_ionq.png', dpi=700)
elif status in ['FAILED', 'CANCELLED']:
print('Your quantum task is in terminal status, but has not completed.')
else:
print('Sorry, your quantum task is still being processed and has not been finalized yet.')
After waiting for a while, the results came out. They are roughly the same as the simulator. There are few errors.
Status of (reconstructed) quantum task: COMPLETED
1000 shots taken on machine arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1.
Measurement counts: Counter({'11': 496, '00': 478, '01': 17, '10': 9})
Next, I'll try with a slightly larger circuit.
ghz = Circuit().h(0)
for i in range(24):
ghz.cnot(i, i+1)
print(ghz)
T : |0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
q0 : -H-C--------------------------------------------------------------
|
q1 : ---X-C------------------------------------------------------------
|
q2 : -----X-C----------------------------------------------------------
|
q3 : -------X-C--------------------------------------------------------
|
q4 : ---------X-C------------------------------------------------------
|
q5 : -----------X-C----------------------------------------------------
|
q6 : -------------X-C--------------------------------------------------
|
q7 : ---------------X-C------------------------------------------------
|
q8 : -----------------X-C----------------------------------------------
|
q9 : -------------------X-C--------------------------------------------
|
q10 : ---------------------X--C-----------------------------------------
|
q11 : ------------------------X--C--------------------------------------
|
q12 : ---------------------------X--C-----------------------------------
|
q13 : ------------------------------X--C--------------------------------
|
q14 : ---------------------------------X--C-----------------------------
|
q15 : ------------------------------------X--C--------------------------
|
q16 : ---------------------------------------X--C-----------------------
|
q17 : ------------------------------------------X--C--------------------
|
q18 : ---------------------------------------------X--C-----------------
|
q19 : ------------------------------------------------X--C--------------
|
q20 : ---------------------------------------------------X--C-----------
|
q21 : ------------------------------------------------------X--C--------
|
q22 : ---------------------------------------------------------X--C-----
|
q23 : ------------------------------------------------------------X--C--
|
q24 : ---------------------------------------------------------------X--
T : |0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|
First on a local simulator
result = device.run(ghz, shots=1000).result()
counts = result.measurement_counts
print(counts)
Counter({'0000000000000000000000000': 507, '1111111111111111111111111': 493})
And next we try Aria1
ionq_task_ghz = ionq.run(ghz, shots=1000)
ionq_task_id_ghz = ionq_task_ghz.id
ionq_status_ghz = ionq_task_ghz.state()
print('Status of quantum task:', ionq_status_ghz)
The results are quite shocking for a 25-qubit system... The accuracy is really good!
Status of (reconstructed) quantum task: COMPLETED
1000 shots taken on machine arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1.
Measurement counts: Counter({'0000000000000000000000000': 285, '1111111111111111111111111': 276, '0000000000000000010000000': 11, '1111111111111111110000000': 11, '0000000000000000000000010': 10, '1111111111110000000000000': 9, '0111111111111111111111111': 9, '0000000000000000000111111': 8, '1111111111111111101111111': 8, '0000000000111111111111111': 8, '1111111111111111100000000': 7, '1111111111111111111000000': 7, '0000000000000000000001000': 7, '1111111111111111111111110': 7, '1111111111111000000000000': 6, '0000000000000000000000011': 6, '1111111111111111111011111': 6, '0000000000000000001111111': 6, '1111111111110111111111111': 6, '0000000000001111111111111': 6, '0000001000000000000000000': 5, '0000000000001000000000000': 5, '0000000000000000100000000': 5, '0000000000000000000000001': 5, '1111111111111111110111111': 5, '1111111111111111011111111': 5, '1111111111111110111111111': 5, '0000100000000000000000000': 4, '0000010000000000000000000': 4, '0000000000100000000000000': 4, '0000000000000000001000000': 4, '0000000000000000000100000': 4, '0000000000000000000010000': 4, '0000000000000000000000111': 4, '1111111111111111111110111': 4, '1111111111111111111101111': 4, '1111111111111101111111111': 4, '1111111111111011111111111': 4, '0000000000000111111111111': 4, '1111111111011111111111111': 4, '1101111111111111111111111': 4, '0011111111111111111111111': 4, '0100000000000000000000000': 3, '1110000000000000000000000': 3, '0001000000000000000000000': 3, '0000000010000000000000000': 3, '1111111111000000000000000': 3, '1111111111100000000000000': 3, '0000000000000100000000000': 3, '0000000000000001000000000': 3, '1111111111111111111111000': 3, '1111111111111111111111100': 3, '0000000000000000000011111': 3, '0000000000000000011111111': 3, '1111111111101111111111111': 3, '0000000000011111111111111': 3, '0000000001111111111111111': 3, '1111110111111111111111111': 3, '1110111111111111111111111': 3, '1011111111111111111111111': 3, '1100000000000000000000000': 2, '1111110000000000000000000': 2, '0000000100000000000000000': 2, '0000000000010000000000000': 2, '0000000000000010000000000': 2, '1111111111111111000000000': 2, '0000000000100000010000000': 2, '0111111111111111111000000': 2, '0000000000000000000000100': 2, '0111111111111111111111101': 2, '1111111111111111111111101': 2, '0000000000000000010000011': 2, '1111111111110000000000111': 2, '1111111111111111011011111': 2, '0000000000000001111111111': 2, '1111111101111111111111111': 2, '1111111011111111111111111': 2, '1111011111111111111111111': 2, '1000000000000000000000000': 1, '0010000000000000000000000': 1, '1111111100000000000000000': 1, '1000000010000000000000000': 1, '1110111110000000000000000': 1, '1111111110000000000000000': 1, '0000000001000000000000000': 1, '1111101111000000000000000': 1, '0001000000100000000000000': 1, '1101111111100000000000000': 1, '0010000000010000000000000': 1, '0000000001111100000000000': 1, '1111111111111100000000000': 1, '1000000000000010000000000': 1, '0100000000000010000000000': 1, '0000000001000110000000000': 1, '0000001000000001000000000': 1, '0000000000001111000000000': 1, '1000000000000000100000000': 1, '1000000010000000100000000': 1, '1111111111111101100000000': 1, '0000000000011111100000000': 1, '0000001000000000010000000': 1, '0000000010000000010000000': 1, '0000000000010000010000000': 1, '1111111111111010110000000': 1, '0000000000001111110000000': 1, '0001111111101111110000000': 1, '1111111111101111110000000': 1, '0000000000011111110000000': 1, '0000000000000001001000000': 1, '0000000000000000011000000': 1, '0000000000001000011000000': 1, '1111111111111111011000000': 1, '1111111111101111111000000': 1, '0001111111111111111000000': 1, '0000000000000100000100000': 1, '0000000000000000100100000': 1, '1111111111111111111100000': 1, '1111111111111111111110000': 1, '1100000000001000000001000': 1, '0000000000000010000001000': 1, '0000111111111111110001000': 1, '0101000011001011111101000': 1, '0000000000000000000011000': 1, '0000000000000000111111000': 1, '0000000000111111111111000': 1, '0111111111111111111111000': 1, '0000000000000100000000100': 1, '1111111111111111111101100': 1, '1111111111110110111111100': 1, '1111111111111110111111100': 1, '1000000000000000000000010': 1, '0000000001000000000000010': 1, '1011111111111110100000010': 1, '1111111111111111110000010': 1, '0000000001111111111111010': 1, '0000000000011000000000110': 1, '0000000000000010000001110': 1, '0000000010000000000011110': 1, '0000000000000001000011110': 1, '0000000000000000011111110': 1, '0000000000000111111111110': 1, '0001000000000000000000001': 1, '1111111111100000000000001': 1, '1101111111110000000000001': 1, '1111111111111010000000001': 1, '1111111111111111111001101': 1, '1111111111111111110111101': 1, '0000000000001111111111101': 1, '1111111111111000000000011': 1, '1111111111111111111000011': 1, '0000000000011111111110011': 1, '1111111111111111010111011': 1, '0000000111111111101111011': 1, '1111111111111111111111011': 1, '0010000000000000000000111': 1, '0000000010000000000000111': 1, '1111111111100000010110111': 1, '0000000000000000011110111': 1, '1111111111101111111110111': 1, '1011111111111111111110111': 1, '0000000000000000000001111': 1, '0010000000000000000001111': 1, '0000000000000000000101111': 1, '1111111110111111111101111': 1, '1111111111111111110011111': 1, '1101111111111111111011111': 1, '1000000000000000000111111': 1, '0001100000000000000111111': 1, '1111111111111000000111111': 1, '1100000000000000001111111': 1, '1111111111011100001111111': 1, '1111111111111110101111111': 1, '0000000000000111101111111': 1, '0000000001000000011111111': 1, '1111111111000000011111111': 1, '0000000000001000111111111': 1, '0000000000011101111111111': 1, '0000000000011011111111111': 1, '1111110000000111111111111': 1, '0000000001110111111111111': 1, '0000001111110111111111111': 1, '1111000000001111111111111': 1, '0000000000101111111111111': 1, '1111110111101111111111111': 1, '0000000100011111111111111': 1, '1111110111011111111111111': 1, '1001111111011111111111111': 1, '1000000000111111111111111': 1, '1111111110111111111111111': 1, '0111111101111111111111111': 1, '0000000111111111111111111': 1, '1111101111111111111111111': 1, '0000011111111111111111111': 1, '0001111111111111111111111': 1})
You can clearly see that the GHZ is properly executed on both sides. It's quite revolutionary and impressive. It seems quantum computers are steadily advancing in development.