Skip to content

Commit 11f7793

Browse files
authored
SamplerV2 update (#1420)
* Clean version of SamplerV2 update * Added SamplerV2 to primitives_v2 unit tests * linting * linting * linting * Minor fixes in integration tests * linting * linting * Fixes according to code review
1 parent 499dbac commit 11f7793

File tree

3 files changed

+606
-42
lines changed

3 files changed

+606
-42
lines changed

qiskit_ibm_runtime/sampler.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def run(self, pubs: Iterable[SamplerPubLike], *, shots: int | None = None) -> Ru
105105
106106
Returns:
107107
Submitted job.
108+
The result of the job is an instance of
109+
:class:`qiskit.primitives.containers.PrimitiveResult`.
108110
111+
Raises:
112+
ValueError: Invalid arguments are given.
109113
"""
110114
coerced_pubs = [SamplerPub.coerce(pub, shots) for pub in pubs]
111115

@@ -150,19 +154,17 @@ class SamplerV1(BasePrimitiveV1, Sampler, BaseSampler):
150154
from qiskit_ibm_runtime import QiskitRuntimeService, Session, Sampler
151155
152156
service = QiskitRuntimeService(channel="ibm_cloud")
153-
154-
# Bell Circuit
155-
qr = QuantumRegister(2, name="qr")
156-
cr = ClassicalRegister(2, name="cr")
157-
qc = QuantumCircuit(qr, cr, name="bell")
158-
qc.h(qr[0])
159-
qc.cx(qr[0], qr[1])
160-
qc.measure(qr, cr)
157+
quantum_register = QuantumRegister(2, name="qr")
158+
classical_register = ClassicalRegister(2, name="cr")
159+
bell = QuantumCircuit(quantum_register, classical_register, name="bell")
160+
bell.h(quantum_register[0])
161+
bell.cx(quantum_register[0], quantum_register[1])
162+
bell.measure(quantum_register, classical_register)
161163
162164
with Session(service, backend="ibmq_qasm_simulator") as session:
163165
sampler = Sampler(session=session)
164166
165-
job = sampler.run(qc, shots=1024)
167+
job = sampler.run(bell, shots=1024)
166168
print(f"Job ID: {job.job_id()}")
167169
print(f"Job result: {job.result()}")
168170

0 commit comments

Comments
 (0)