Skip to content

Commit 8c612d1

Browse files
authored
Docs: clarify shots, default_shots, and twirling shots (#1884)
* clarify shots used * fix pea typo
1 parent fa30262 commit 8c612d1

File tree

2 files changed

+55
-36
lines changed

2 files changed

+55
-36
lines changed

qiskit_ibm_runtime/options/twirling_options.py

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,54 +27,73 @@
2727

2828
@primitive_dataclass
2929
class TwirlingOptions:
30-
"""Twirling options. This is only used by V2 primitives.
30+
"""Twirling options."""
3131

32-
Args:
33-
enable_gates: Whether to apply 2-qubit Clifford gate twirling. Default: False.
32+
enable_gates: Union[UnsetType, bool] = Unset
33+
r"""Whether to apply 2-qubit Clifford gate twirling.
34+
Default: False.
35+
"""
3436

35-
enable_measure: Whether to enable twirling of measurements. Twirling will only be applied to
36-
those measurement registers not involved within a conditional logic.
37-
Default: True for Estimator, false for Sampler.
37+
enable_measure: Union[UnsetType, bool] = Unset
38+
r"""Whether to enable twirling of measurements.
3839
39-
num_randomizations: The number of random samples to use when twirling or peforming sampled
40-
mitigation. If ``num_randomizations`` is "auto", for every pub executed ``shots`` times:
40+
Twirling will only be applied to those measurement registers not involved within a
41+
conditional logic. Default: True for Estimator, false for Sampler.
42+
"""
4143

42-
* If ``shots_per_randomization`` is also "auto", ``shots_per_randomization`` is set first
43-
as described below, then ``num_randomizations`` is set as
44-
``ceil(shots/shots_per_randomization)``, where ``ceil`` is the ceiling function.
45-
* Otherwise, the value is set to ``ceil(shots/shots_per_randomization)``.
44+
num_randomizations: Union[UnsetType, int, Literal["auto"]] = Unset
45+
r"""The number of random samples to use when twirling or peforming sampled mitigation.
4646
47-
Default: "auto".
47+
If ``num_randomizations`` is "auto", for every pub executed ``shots`` times:
4848
49-
shots_per_randomization: The number of shots to run for each random sample. If "auto", for
50-
every pub executed ``shots`` times:
49+
* If ``shots_per_randomization`` is also "auto", ``shots_per_randomization`` is set first
50+
as described below, then ``num_randomizations`` is set as
51+
``ceil(shots/shots_per_randomization)``, where ``ceil`` is the ceiling function.
52+
* Otherwise, the value is set to ``ceil(shots/shots_per_randomization)``.
5153
52-
* If ``num_randomizations`` is also "auto", the value is set to ``64`` for PEC mitigation
53-
or to ``max(64, ceil(shots / 32))`` in all other cases, where ``ceil`` is the ceiling
54-
function.
55-
* Otherwise, the value is set to ``ceil(shots/num_randomizations)``.
54+
Default: "auto".
55+
56+
.. note::
57+
The ``shots`` value specified in a PUB or in the ``run()`` method is considered part of the
58+
primitive execution interface and therefore is always obeyed. ``default_shots``, on the other hand,
59+
is considered a Qiskit Runtime specific option. Therefore, the product of
60+
``num_randomizations`` and ``shots_per_randomization`` takes precedence over ``default_shots``.
61+
"""
62+
63+
shots_per_randomization: Union[UnsetType, int, Literal["auto"]] = Unset
64+
r"""The number of shots to run for each random sample.
5665
57-
Default: "auto".
66+
If "auto", for every pub executed ``shots`` times:
5867
59-
strategy: Specify the strategy of twirling qubits in identified layers of
60-
2-qubit twirled gates. Allowed values are
68+
* If ``num_randomizations`` is also "auto", the value is set to ``64`` for PEC mitigation
69+
or to ``max(64, ceil(shots / 32))`` in all other cases, where ``ceil`` is the ceiling
70+
function.
71+
* Otherwise, the value is set to ``ceil(shots/num_randomizations)``.
6172
62-
* If ``"active"`` only the instruction qubits in each individual twirled
63-
layer will be twirled.
64-
* If ``"active-circuit"`` the union of all instruction qubits in the circuit
65-
will be twirled in each twirled layer.
66-
* If ``"active-accum"`` the union of instructions qubits in the circuit up to
67-
the current twirled layer will be twirled in each individual twirled layer.
68-
* If ``"all"`` all qubits in the input circuit will be twirled in each
69-
twirled layer.
73+
Default: "auto".
7074
71-
Default: "active-accum".
75+
.. note::
76+
The ``shots`` value specified in a PUB or in the ``run()`` method is considered part of the
77+
primitive execution interface and therefore is always obeyed. ``default_shots``, on the other hand,
78+
is considered a Qiskit Runtime specific option. Therefore, the product of
79+
``num_randomizations`` and ``shots_per_randomization`` takes precedence over ``default_shots``.
7280
"""
7381

74-
enable_gates: Union[UnsetType, bool] = Unset
75-
enable_measure: Union[UnsetType, bool] = Unset
76-
num_randomizations: Union[UnsetType, int, Literal["auto"]] = Unset
77-
shots_per_randomization: Union[UnsetType, int, Literal["auto"]] = Unset
7882
strategy: Union[UnsetType, TwirlingStrategyType] = Unset
83+
r"""Specify the strategy of twirling qubits in identified layers of 2-qubit twirled gates.
84+
85+
Allowed values are:
86+
87+
* If ``"active"`` only the instruction qubits in each individual twirled
88+
layer will be twirled.
89+
* If ``"active-circuit"`` the union of all instruction qubits in the circuit
90+
will be twirled in each twirled layer.
91+
* If ``"active-accum"`` the union of instructions qubits in the circuit up to
92+
the current twirled layer will be twirled in each individual twirled layer.
93+
* If ``"all"`` all qubits in the input circuit will be twirled in each
94+
twirled layer.
95+
96+
Default: "active-accum".
97+
"""
7998

8099
_ge1 = make_constraint_validator("num_randomizations", "shots_per_randomization", ge=1)

qiskit_ibm_runtime/options/zne_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ZneOptions:
8383
* `"gate_folding_back"` uses 2-qubit gate folding to amplify noise. If the noise
8484
factor requires amplifying only a subset of the gates, then these gates are selected
8585
from the back of the topologically ordered DAG circuit.
86-
* `"pea"` uses a technique called probabalistic error amplification (`PEA
86+
* `"pea"` uses a technique called Probabilistic Error Amplification (`PEA
8787
<https://www.nature.com/articles/s41586-023-06096-3>`_) to amplify
8888
noise.
8989

0 commit comments

Comments
 (0)