@@ -231,6 +231,25 @@ def depolarizing2(
231231 pz : float ,
232232 status : Optional [float ] = None ,
233233 ) -> float :
234+ """
235+ Apply a depolarizing channel to the circuit in a Monte Carlo way.
236+ For each call, one of the Pauli gates (X, Y, Z) or an Identity gate is applied to the qubit
237+ at the given index based on the probabilities `px`, `py`, and `pz`.
238+
239+ :param index: The index of the qubit to apply the depolarizing channel on.
240+ :type index: int
241+ :param px: The probability of applying an X gate.
242+ :type px: float
243+ :param py: The probability of applying a Y gate.
244+ :type py: float
245+ :param pz: The probability of applying a Z gate.
246+ :type pz: float
247+ :param status: A random number between 0 and 1 to determine which gate to apply. If None,
248+ a random number is generated automatically. Defaults to None.
249+ :type status: Optional[float], optional
250+ :return: Returns 0.0. The function modifies the circuit in place.
251+ :rtype: float
252+ """
234253 if status is None :
235254 status = backend .implicit_randu ()[0 ]
236255 g = backend .cond (
@@ -323,6 +342,35 @@ def unitary_kraus2(
323342 status : Optional [float ] = None ,
324343 name : Optional [str ] = None ,
325344 ) -> Tensor :
345+ """
346+ Apply a unitary Kraus channel to the circuit using a Monte Carlo approach. This method is functionally
347+ similar to `unitary_kraus` but uses `backend.switch` for selecting the Kraus operator, which can have
348+ different performance characteristics on some backends.
349+
350+ A random Kraus operator from the provided list is applied to the circuit based on the given probabilities.
351+ This method is jittable and suitable for simulating noisy quantum circuits where the noise is represented
352+ by unitary Kraus operators.
353+
354+ .. warning::
355+ This method may have issues with `vmap` due to potential concurrent access locks, potentially related with
356+ `backend.switch`. `unitary_kraus` is generally recommended.
357+
358+ :param kraus: A sequence of `Gate` objects representing the unitary Kraus operators.
359+ :type kraus: Sequence[Gate]
360+ :param index: The qubit indices on which to apply the Kraus channel.
361+ :type index: int
362+ :param prob: A sequence of probabilities corresponding to each Kraus operator. If None, probabilities
363+ are derived from the operators themselves. Defaults to None.
364+ :type prob: Optional[Sequence[float]], optional
365+ :param status: A random number between 0 and 1 to determine which Kraus operator to apply. If None,
366+ a random number is generated automatically. Defaults to None.
367+ :type status: Optional[float], optional
368+ :param name: An optional name for the operation. Defaults to None.
369+ :type name: Optional[str], optional
370+ :return: A tensor indicating which Kraus operator was applied.
371+ :rtype: Tensor
372+ """
373+
326374 # dont use, has issue conflicting with vmap, concurrent access lock emerged
327375 # potential issue raised from switch
328376 # general impl from Monte Carlo trajectory depolarizing above
0 commit comments