No project description provided
Project description
Quantum Serverless client
Client part of quantum serverless project. Installable python library to communicate with provisioned infrastructure.
Table of Contents
Installation
pip install quantum_serverless
or local installation from source
pip install -e .
Usage
from qiskit import QuantumCircuit
from qiskit.circuit.random import random_circuit
from qiskit.quantum_info import SparsePauliOp
from qiskit_ibm_runtime import Estimator
from quantum_serverless import QuantumServerless, run_qiskit_remote, get, put
# 1. let's annotate out function to convert it
# to function that can be executed remotely
# using `run_qiskit_remote` decorator
@run_qiskit_remote()
def my_function(circuit: QuantumCircuit, obs: SparsePauliOp):
return Estimator().run([circuit], [obs]).result().values
# 2. Next let's create out serverless object to control
# where our remote function will be executed
serverless = QuantumServerless()
circuits = [random_circuit(2, 2) for _ in range(3)]
# 3. create serverless context
with serverless:
# 4. let's put some shared objects into remote storage that will be shared among all executions
obs_ref = put(SparsePauliOp(["ZZ"]))
# 4. run our function and get back reference to it
# as now our function it remote one
function_reference = my_function(circuits[0], obs_ref)
# 4.1 or we can run N of them in parallel (for all circuits)
function_references = [my_function(circ, obs_ref) for circ in circuits]
# 5. to get results back from reference
# we need to call `get` on function reference
print("Single execution:", get(function_reference))
print("N parallel executions:", get(function_references))
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
quantum_serverless-0.0.3.tar.gz
(17.6 kB
view details)
Built Distribution
File details
Details for the file quantum_serverless-0.0.3.tar.gz
.
File metadata
- Download URL: quantum_serverless-0.0.3.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3930cca94e7467a2220c2860b1d09dbd56a690ee2c332eac217ff25becc8b762 |
|
MD5 | 68feae2ac6731da45f851c7ad21bfa44 |
|
BLAKE2b-256 | 6a976465c8fa768fc3fe19101956d78e0877d472f2dd3172f7a18fc4f21b72af |
File details
Details for the file quantum_serverless-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: quantum_serverless-0.0.3-py3-none-any.whl
- Upload date:
- Size: 32.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88bb9d01fa386b5c5b1983d6235af52d9c9117186988fb8525e61f20264d01f9 |
|
MD5 | e7d29fcdf2fa0bbedd141ba05f160883 |
|
BLAKE2b-256 | 942761414b0dc3279134bc1d5404656ebebba184390baad04b2e439616672eb1 |