Skip to content

Commit

Permalink
Merge 6a707dc into 2b8a48f
Browse files Browse the repository at this point in the history
  • Loading branch information
airwoodix committed May 7, 2024
2 parents 2b8a48f + 6a707dc commit 2b32199
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qiskit_aqt_provider/primitives/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def __init__(
):
"""Initialize an ``Estimator`` primitive using an AQT backend.
See :class:`AQTSampler <qiskit_aqt_provider.primitives.sampler.AQTSampler>` for
examples configuring run options.
Args:
backend: AQT resource to evaluate circuits on.
options: options passed to through to the underlying
Expand Down
41 changes: 41 additions & 0 deletions qiskit_aqt_provider/primitives/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,47 @@ def __init__(
:class:`BackendSampler <qiskit.primitives.BackendSampler>`.
skip_transpilation: if :data:`True`, do not transpile circuits
before passing them to the execution backend.
Examples:
Initialize a :class:`Sampler <qiskit.primitives.BaseSamplerV1>` primitive
on a AQT offline simulator:
>>> import qiskit
>>> from qiskit_aqt_provider import AQTProvider
>>> from qiskit_aqt_provider.primitives import AQTSampler
>>>
>>> backend = AQTProvider("").get_backend("offline_simulator_no_noise")
>>> sampler = AQTSampler(backend)
Configuring :class:`options <qiskit_aqt_provider.aqt_options.AQTOptions>`
on the backend will affect all circuit evaluations triggered by
the `Sampler` primitive:
>>> qc = qiskit.QuantumCircuit(2)
>>> _ = qc.cx(0, 1)
>>> _ = qc.measure_all()
>>>
>>> sampler.run(qc).result().metadata[0]["shots"]
100
>>> backend.options.shots = 123
>>> sampler.run(qc).result().metadata[0]["shots"]
123
The same effect is achieved by passing options to the
:class:`AQTSampler` initializer:
>>> sampler = AQTSampler(backend, options={"shots": 120})
>>> sampler.run(qc).result().metadata[0]["shots"]
120
Passing the option in the
:meth:`AQTSampler.run <qiskit.primitives.BaseSamplerV1.run>` call
restricts the effect to a single evaluation:
>>> sampler.run(qc, shots=130).result().metadata[0]["shots"]
130
>>> sampler.run(qc).result().metadata[0]["shots"]
120
"""
# Signal the transpiler to disable passes that require bound
# parameters.
Expand Down

0 comments on commit 2b32199

Please sign in to comment.