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.4.tar.gz
(20.0 kB
view hashes)
Built Distribution
Close
Hashes for quantum_serverless-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05a22a6591496b39addff70c8216487f0ab8bbbf79ac07b1446b10a59507c792 |
|
MD5 | f44d9aea31b2251072a7d9098104d864 |
|
BLAKE2b-256 | 24d58a66bd0e22bd28f1cd570c786429d8304b9ec81268d8b51f30be11fa3ae5 |