From 1c2a492041f97e03dfddc7bc49555efc8d2d1e91 Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:30:25 -0400 Subject: [PATCH 1/2] Add missing commas for Sampler v2 invocation --- docs/api/migration-guides/v2-primitives.mdx | 4 ++-- docs/build/bit-ordering.mdx | 2 +- docs/run/primitives-examples.mdx | 4 ++-- docs/run/primitives-get-started.mdx | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api/migration-guides/v2-primitives.mdx b/docs/api/migration-guides/v2-primitives.mdx index a7ecc6db6c9..242ecd41adb 100644 --- a/docs/api/migration-guides/v2-primitives.mdx +++ b/docs/api/migration-guides/v2-primitives.mdx @@ -1109,8 +1109,8 @@ backend = service.least_busy(operational=True, simulator=False, min_num_qubits=1 with Session(service=service, backend=backend) as session: sampler = Sampler(session=session) - job = sampler.run([(isa_circuit)]) - another_job = sampler.run([(another_isa_circuit)]) + job = sampler.run([(isa_circuit,)]) + another_job = sampler.run([(another_isa_circuit,)]) result = job.result() another_result = another_job.result() diff --git a/docs/build/bit-ordering.mdx b/docs/build/bit-ordering.mdx index 560ed692774..81adca6adfd 100644 --- a/docs/build/bit-ordering.mdx +++ b/docs/build/bit-ordering.mdx @@ -63,7 +63,7 @@ decimal integer `2` (measured with probability `1.0`). from qiskit.primitives import Samplerv2 as Sampler qc.measure_all() -job = sampler.run([(qc)]) +job = sampler.run([(qc,)]) result = job.result() print(f" > Counts: {result[0].data.meas.get_counts()}") ``` diff --git a/docs/run/primitives-examples.mdx b/docs/run/primitives-examples.mdx index 899b3c0d0a3..197baec8b7c 100644 --- a/docs/run/primitives-examples.mdx +++ b/docs/run/primitives-examples.mdx @@ -627,8 +627,8 @@ another_isa_circuit = pm.run(another_circuit) with Session(service=service, backend=backend) as session: sampler = Sampler(session=session) - job = sampler.run([(isa_circuit)]) - another_job = sampler.run([(another_isa_circuit)]) + job = sampler.run([(isa_circuit,)]) + another_job = sampler.run([(another_isa_circuit,)]) result = job.result() another_result = another_job.result() diff --git a/docs/run/primitives-get-started.mdx b/docs/run/primitives-get-started.mdx index 7ea93c317ca..fbe4161ccf2 100644 --- a/docs/run/primitives-get-started.mdx +++ b/docs/run/primitives-get-started.mdx @@ -205,7 +205,7 @@ For Sampler V2, the circuit and optional parameter value sets are input as *prim ```python -job = sampler.run([(isa_circuit)]) +job = sampler.run([(isa_circuit,)]) print(f">>> Job ID: {job.job_id()}") print(f">>> Job Status: {job.status()}") ``` From 16ff684d09a12234406c2b0abca70a396c9d9ea1 Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:24:08 -0400 Subject: [PATCH 2/2] Use simplified interface --- docs/api/migration-guides/v2-primitives.mdx | 19 +++++++++++-------- docs/build/bit-ordering.mdx | 2 +- docs/run/advanced-runtime-options.mdx | 4 ++-- docs/run/estimate-job-run-time.mdx | 2 +- docs/run/primitives-examples.mdx | 6 +++--- docs/run/primitives-get-started.mdx | 2 +- docs/run/primitives.mdx | 5 ++++- docs/run/quantum-serverless.mdx | 2 +- docs/run/run-jobs-in-session.mdx | 2 +- docs/start/setup-channel.mdx | 4 ++-- 10 files changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/api/migration-guides/v2-primitives.mdx b/docs/api/migration-guides/v2-primitives.mdx index 242ecd41adb..d9f6ab08c0f 100644 --- a/docs/api/migration-guides/v2-primitives.mdx +++ b/docs/api/migration-guides/v2-primitives.mdx @@ -90,12 +90,15 @@ Sampler V2 example that uses shots in `run()`: ```python # Sample two circuits at 128 shots each. -sampler.run([(circuit1,), (circuit2,)], shots=128) +sampler.run([circuit1, circuit2], shots=128) -# Sample two circuits at different amounts of shots. The "None"s are necessary -# as placeholders +# Sample two circuits at different amounts of shots. +# The "None"s are necessary as placeholders # for the lack of parameter values in this example. -sampler.run([(circuit1, None, 123), (circuit2, None, 456)]) +sampler.run([ + (circuit1, None, 123), + (circuit2, None, 456), +]) ``` #### Output @@ -226,7 +229,7 @@ pm = generate_preset_pass_manager(backend=backend, optimization_level=1) isa_circuit = pm.run(circuit) sampler = Sampler(backend) -job = sampler.run([(isa_circuit,)]) +job = sampler.run([isa_circuit]) result = job.result() # Get results for the first (and only) PUB pub_result = result[0] @@ -886,7 +889,7 @@ pm = generate_preset_pass_manager(backend=backend, optimization_level=1) isa_circuit = pm.run(circuit) sampler = Sampler(backend) -job = sampler.run([(isa_circuit,)]) +job = sampler.run([isa_circuit]) result = job.result() ``` @@ -1109,8 +1112,8 @@ backend = service.least_busy(operational=True, simulator=False, min_num_qubits=1 with Session(service=service, backend=backend) as session: sampler = Sampler(session=session) - job = sampler.run([(isa_circuit,)]) - another_job = sampler.run([(another_isa_circuit,)]) + job = sampler.run([isa_circuit]) + another_job = sampler.run([another_isa_circuit]) result = job.result() another_result = another_job.result() diff --git a/docs/build/bit-ordering.mdx b/docs/build/bit-ordering.mdx index 81adca6adfd..a355e37ecc4 100644 --- a/docs/build/bit-ordering.mdx +++ b/docs/build/bit-ordering.mdx @@ -63,7 +63,7 @@ decimal integer `2` (measured with probability `1.0`). from qiskit.primitives import Samplerv2 as Sampler qc.measure_all() -job = sampler.run([(qc,)]) +job = sampler.run([qc]) result = job.result() print(f" > Counts: {result[0].data.meas.get_counts()}") ``` diff --git a/docs/run/advanced-runtime-options.mdx b/docs/run/advanced-runtime-options.mdx index f3a93cf135a..bd764df4455 100644 --- a/docs/run/advanced-runtime-options.mdx +++ b/docs/run/advanced-runtime-options.mdx @@ -123,7 +123,7 @@ You can pass in options by using the `run()` method. This overwrites the options In V2, the only options you can pass to `run()` are options defined in the interface. That is, `shots` for Sampler and `precision` for Estimator. ```python # Sample two circuits at 128 shots each. -sampler.run([(circuit1,), (circuit2,)], shots=128) +sampler.run([circuit1, circuit2], shots=128) ``` @@ -162,7 +162,7 @@ sampler.options.default_shots=2000 sampler.options.update(default_shots=1024, dynamical_decoupling={"sequence_type": "XpXm"}) # Sample two circuits at 128 shots each. -sampler.run([(circuit1,), (circuit2,)], shots=128) +sampler.run([circuit1, circuit2], shots=128) ``` diff --git a/docs/run/estimate-job-run-time.mdx b/docs/run/estimate-job-run-time.mdx index cfcd511dc96..9a91c4fcbd9 100644 --- a/docs/run/estimate-job-run-time.mdx +++ b/docs/run/estimate-job-run-time.mdx @@ -61,7 +61,7 @@ isa_circuit = pm.run(qc) sampler = Sampler(backend) # Submit the circuit to the sampler -job = sampler.run([(isa_circuit,)]) +job = sampler.run([isa_circuit]) print(job.usage_estimation) ``` diff --git a/docs/run/primitives-examples.mdx b/docs/run/primitives-examples.mdx index 197baec8b7c..223b696a479 100644 --- a/docs/run/primitives-examples.mdx +++ b/docs/run/primitives-examples.mdx @@ -408,7 +408,7 @@ pm = generate_preset_pass_manager(backend=backend, optimization_level=1) isa_circuit = pm.run(circuit) sampler = Sampler(backend) -job = sampler.run([(isa_circuit,)]) +job = sampler.run([isa_circuit]) result = job.result() ``` @@ -627,8 +627,8 @@ another_isa_circuit = pm.run(another_circuit) with Session(service=service, backend=backend) as session: sampler = Sampler(session=session) - job = sampler.run([(isa_circuit,)]) - another_job = sampler.run([(another_isa_circuit,)]) + job = sampler.run([isa_circuit]) + another_job = sampler.run([another_isa_circuit]) result = job.result() another_result = another_job.result() diff --git a/docs/run/primitives-get-started.mdx b/docs/run/primitives-get-started.mdx index fbe4161ccf2..32e9f6a51de 100644 --- a/docs/run/primitives-get-started.mdx +++ b/docs/run/primitives-get-started.mdx @@ -205,7 +205,7 @@ For Sampler V2, the circuit and optional parameter value sets are input as *prim ```python -job = sampler.run([(isa_circuit,)]) +job = sampler.run([isa_circuit]) print(f">>> Job ID: {job.job_id()}") print(f">>> Job Status: {job.status()}") ``` diff --git a/docs/run/primitives.mdx b/docs/run/primitives.mdx index f7ddd45abf1..13681f636fa 100644 --- a/docs/run/primitives.mdx +++ b/docs/run/primitives.mdx @@ -209,7 +209,10 @@ sampler.run([circuit1, circuit2, ...],[observable1, observable2, ...],[param_val Example: ```python -sampler.run([(circuit1, param_values1, shots1),(circuit2, param_values2, shots_2) ]) +sampler.run([ + (circuit1, param_values1, shots1), + (circuit2, param_values2, shots_2), +]) ``` ## Estimator diff --git a/docs/run/quantum-serverless.mdx b/docs/run/quantum-serverless.mdx index b2fad31537d..d5c25604aca 100644 --- a/docs/run/quantum-serverless.mdx +++ b/docs/run/quantum-serverless.mdx @@ -166,7 +166,7 @@ target_circuit = selector.optimized_circuit # Step 3: Execute the target circuit sampler = Sampler(backend=backend, options={"default_shots": 1024}) -job = sampler.run([(target_circuit,)]) +job = sampler.run([target_circuit]) result = job.result() # Step 4: Postprocess the results diff --git a/docs/run/run-jobs-in-session.mdx b/docs/run/run-jobs-in-session.mdx index 775b98be4bc..c84f5e65c24 100644 --- a/docs/run/run-jobs-in-session.mdx +++ b/docs/run/run-jobs-in-session.mdx @@ -175,7 +175,7 @@ with Session(backend=backend): sampler = Sampler() estimator = Estimator() - job = sampler.run([(sampler_circuit,)]) + job = sampler.run([sampler_circuit]) result = job.result() print(f" > Counts: {result[0].data.meas.get_counts()}") diff --git a/docs/start/setup-channel.mdx b/docs/start/setup-channel.mdx index 60126855b59..1bae4663663 100644 --- a/docs/start/setup-channel.mdx +++ b/docs/start/setup-channel.mdx @@ -101,7 +101,7 @@ service = QiskitRuntimeService() backend = service.backend("ibmq_qasm_simulator") sampler = Sampler(backend) -job = sampler.run([(example_circuit,)]) +job = sampler.run([example_circuit]) print(f"job id: {job.job_id()}") result = job.result() print(result) @@ -173,7 +173,7 @@ print(result) service = QiskitRuntimeService() backend = service.backend("ibmq_qasm_simulator") sampler = Sampler(backend) - job = sampler.run([(example_circuit,)]) + job = sampler.run([example_circuit]) print(f"job id: {job.job_id()}") result = job.result() print(result)