Today, let's start programming a quantum computer using the blueqat cloud.
blueqat is an original SDK (Software Development Kit) for quantum computers, and by using blueqat cloud, you can get started with no installation required.
First, let's see how to write a quantum circuit.
from blueqat import Circuit
Circuit().h[0].m[:].run(shots=100)
Counter({'1': 49, '0': 51})
The first step is to initialize the circuit. Then we write an operation called a quantum gate, where m is a measurement. In a quantum computer, the measurement is performed after the calculation. Finally, it decides how many times to run the operation and executes it.
Ha
In this case, the circuit with the Hadamar gate applied to the 0th qubit was calculated 100 times, and the results were obtained in the simulator.
Run on IonQ with API key
By using an API key, you can throw a task to an IonQ machine in the US. The api key can be obtained from the user settings menu after you logged in to blueqat.com.
from bqcloud import register_api
api = register_api("your api key")
From the second time onwards, calculations can be done by calling the registered API key. You can run 1shot for 50 blueqat credit.
from bqcloud import load_api
api = load_api()
from bqcloud import Device
# circuit, device, number of trial
task = api.execute(Circuit().h[0], Device.IonQDevice, 10)
You can check the status of your tasks.
print(task.status())
Status.COMPLETED
# Wait 10 sec. If complete, result is returned, otherwise, None is returned.
result = task.wait(timeout=10)
if result:
print(result.shots())
else:
print("timeout")
Counter({'1': 7, '0': 3})
You were able to start programming a quantum computer very easily and run applications. I encourage you to try harder problems.