a library for providers to access the quantum computer cloud platform 'gaqqie-sky' in gaqqie suite.
Project description
gaqqie-rainbow: a library for providers to access the quantum computer cloud platform gaqqie-sky in gaqqie suite
This is a beta version.
What is gaqqie-rainbow?
gaqqie-rainbow is a library for providers to access the quantum computer cloud platform gaqqie-sky in gaqqie suite.
For more information on gaqqie, see this.
Installation
pip install gaqqie-rainbow
How to use gaqqie-rainbow
The currently supported quantum programming language is Qiskit.
import json
from qiskit import Aer, execute
from qiskit.assembler import disassemble
from qiskit.qobj import QasmQobj
from gaqqie_rainbow import Gaqqie
from gaqqie_rainbow.rest import Result
url = "https://<api-id>.execute-api.<region>.amazonaws.com/<stage>" # rewrite to the endpoint URL of the provier API
app = Gaqqie(url)
@app.receive_job(device_name="qiskit_simulator", interval=10)
def receive_job(job):
job_id = job.id
print(f"receive_job job_id={job_id}")
# parse circuit
qobj_json = json.loads(job.instructions)
qobj = QasmQobj.from_dict(qobj_json)
circuit = disassemble(qobj)
# execute circuit
backend = Aer.get_backend("qasm_simulator")
aer_job = execute(circuit[0][0], backend)
# parse result
result = aer_job.result()
print(f"result job_id={job_id}, counts={result.get_counts()}")
result_dict = result.to_dict()
result_dict["backend_name"] = job.device_name
result_json = json.dumps(result_dict, indent=2)
# register result
job_result = Result(job_id=job_id, status="SUCCEEDED", results=result_json)
response = app.register_result(job_result)
app.join()
Sample output:
receive_job job_id=6abff77e-4fda-4880-b3a5-ea8f49ff7cf0
result job_id=6abff77e-4fda-4880-b3a5-ea8f49ff7cf0, counts={'00': 482, '11': 542}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gaqqie-rainbow-0.1.0.tar.gz
(21.3 kB
view details)
Built Distribution
File details
Details for the file gaqqie-rainbow-0.1.0.tar.gz
.
File metadata
- Download URL: gaqqie-rainbow-0.1.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 574f651b75897075ab23484f99cdfc981133af98be94005313952a6f69fed061 |
|
MD5 | cbfbbc8f2b12c3bd370e9d17969bea5f |
|
BLAKE2b-256 | 8995eb18fccae2dbb0923e70d44b6aed3c9b1b5fa89a159c056a72ca6b51a7be |
File details
Details for the file gaqqie_rainbow-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: gaqqie_rainbow-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5f5b06a32fdf5192f45b451075abc838f14602ce1207c49e8c0d40bc93c383d |
|
MD5 | 82f0aa23ff1a2f1542fd0f9b041e3aeb |
|
BLAKE2b-256 | 14bc65ad1ef6c2c77f942f4b564ff4373accd3c3b16fc752b08f32633600c877 |