|
27 | 27 |
|
28 | 28 | @primitive_dataclass |
29 | 29 | class TwirlingOptions: |
30 | | - """Twirling options. This is only used by V2 primitives. |
| 30 | + """Twirling options.""" |
31 | 31 |
|
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 | + """ |
34 | 36 |
|
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. |
38 | 39 |
|
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 | + """ |
41 | 43 |
|
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. |
46 | 46 |
|
47 | | - Default: "auto". |
| 47 | + If ``num_randomizations`` is "auto", for every pub executed ``shots`` times: |
48 | 48 |
|
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)``. |
51 | 53 |
|
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. |
56 | 65 |
|
57 | | - Default: "auto". |
| 66 | + If "auto", for every pub executed ``shots`` times: |
58 | 67 |
|
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)``. |
61 | 72 |
|
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". |
70 | 74 |
|
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``. |
72 | 80 | """ |
73 | 81 |
|
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 |
78 | 82 | 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 | + """ |
79 | 98 |
|
80 | 99 | _ge1 = make_constraint_validator("num_randomizations", "shots_per_randomization", ge=1) |
0 commit comments