Lumaktaw sa pangunahing nilalaman

I-integrate ang mga external na quantum resources sa Qiskit

Ang Qiskit SDK ay dinisenyo para suportahan ang mga third party sa paglikha ng mga external na provider ng quantum resources.

Ibig sabihin, ang anumang organisasyon na nag-develop o nag-deploy ng quantum compute resources ay maaaring i-integrate ang kanilang mga serbisyo sa Qiskit at mapakinabangan ang nito userbase.

Para magawa ito, kailangan gumawa ng package na sumusuporta sa mga kahilingan para sa quantum compute resources at ibinabalik ang mga ito sa user.

Bukod pa rito, ang package ay dapat payagan ang mga user na mag-submit ng mga job at makuha ang kanilang mga resulta sa pamamagitan ng implementasyon ng mga qiskit.primitives na object.

Pagbibigay ng access sa mga backend​

Para ma-transpile at ma-execute ng mga user ang mga QuantumCircuit na object gamit ang mga external na resources, kailangan nilang mag-instantiate ng object na naglalaman ng Target na nagbibigay ng impormasyon tungkol sa mga limitasyon ng isang QPU gaya ng koneksyon nito, basis gates, at bilang ng mga qubit. Maaari itong ibigay sa pamamagitan ng isang interface na katulad ng QiskitRuntimeService kung saan maaaring gumawa ng mga kahilingan ang user para sa isang QPU. Ang object na ito ay dapat, sa pinakamababa, maglaman ng isang Target, ngunit ang mas simpleng paraan ay ang magbalik ng instance ng BackendV2.

Ang isang halimbawa ng implementasyon ay maaaring magmukhang ganito:

from qiskit.transpiler import Target
from qsikit.providers import BackendV2

class ProviderService:
""" Class for interacting with a provider's service"""

def __init__(
self,
#Receive arguments for authentication/instantiation
):
""" Initiate a connection with the provider service, given some method
of authentication """

def return_target(name: Str) -> Target:
""" Interact with the service and return a Target object """
return target

def return_backend(name: Str) -> BackendV2:
""" Interact with the service and return a BackendV2 object """
return backend

Pagbibigay ng interface para sa pagpapatakbo​

Bukod sa pagbibigay ng serbisyo na nagbabalik ng mga hardware configuration, ang isang serbisyo na nagbibigay ng access sa mga external na QPU resources ay maaari ding suportahan ang pagpapatakbo ng mga quantum workload. Maaaring ilabas ang kakayahang iyon sa pamamagitan ng paglikha ng mga implementasyon ng mga Qiskit primitives interfaces; halimbawa ang BasePrimitiveJob, BaseEstimatorV2 at BaseSamplerV2 bukod sa iba pa. Sa pinakamababa, ang mga interface na ito ay dapat makapagbigay ng paraan para sa pagpapatakbo, pag-query ng status ng job, at pagbabalik ng mga resulta ng job.

Para hawakan ang status at resulta ng job, ang Qiskit SDK ay nagbibigay ng mga object na DataBin, PubResult, PrimitiveResult, at BasePrimitiveJob na dapat gamitin.

Tingnan ang qiskit.primitives na API documentation pati na rin ang mga reference implementation na BackendEstimatorV2 at BackendSampleV2 para sa karagdagang impormasyon.

Ang isang halimbawa ng implementasyon ng Estimator primitive ay maaaring magmukhang ganito:

from qiskit.primitives import BaseEstimatorV2, BaseSamplerV2, EstimatorPubLike
from qiskit.primitives import DataBin, PubResult, PrimitiveResult, BasePrimitiveJob
from qiskit.providers import BackendV2

class EstimatorImplementation(BaseEstimatorV2):
""" Class for interacting with the provider's Estimator service """

def __init__(
self,
*,
backend: BackendV2,
options: dict
# Receive other arguments to instantiate an Estimator primitive with the service
):
self._backend = backend
self._options = options
self._default_precision = 0.01

@property
def backend(self) -> BackendV2:
""" Return the backend """
return self._backend

def run(
self, pubs: Iterable[EstimatorPubLike], *, precision: float | None = None
) -> BasePrimitiveJob[PrimitiveResult[PubResult]]:
""" Steps to implement:
1. Define a default precision if none is given
2. Validate pub format
3. Instantiate an object which inherits from BasePrimitiveJob
containing pub and runtime information
4. Send the job to the execution service of the provider
"""
job = BasePrimitiveJob(pubs, precision)
job_with_results = job.submit()
return job_with_results

At ang isang implementasyon ng Sampler primitive ay maaaring magmukhang ganito:

class SamplerImplementation(BaseSamplerV2):
""" Class for interacting with the provider's Sampler service """

def __init__(
self,
*,
backend: BackendV2,
options: dict
# Receive other arguments to instantiate an Estimator primitive with the service
):
self._backend = backend
self._options = options
self._default_shots = 1024

@property
def backend(self) -> BackendV2:
""" Return the Sampler's backend """
return self._backend

def run(
self, pubs: Iterable[SamplerPubLike], *, shots: int | None = None
) -> BasePrimitiveJob[PrimitiveResult[SamplerPubResult]]:
""" Steps to implement:
1. Define a default number of shots if none is given
2. Validate pub format
3. Instantiate an object which inherits from BasePrimitiveJob
containing pub and runtime information
4. Send the job to the execution service of the provider
5. Return the data in some format
"""
job = BasePrimitiveJob(pubs, shots)
job_with_results = job.submit()
return job_with_results