requsim.noise module

Classes:

NoiseChannel(n_qubits, channel_function)

Standardized way to define noise channels.

NoiseModel([channel_before, map_replace, ...])

Class for describing noise in a standardized way.

Functions:

freeze_noise_channel(noise_channel, *args, ...)

DEPRECATED, instead use NoiseChannel.freeze(*args, **kwargs).

class requsim.noise.NoiseChannel(n_qubits, channel_function)

Bases: object

Standardized way to define noise channels.

This class can be simply called to apply this channel on a state of the correct number of qubits, or you can use the apply_to method to let the noise channel handle its application for you.

Parameters:
  • n_qubits (int) – This noise channel acts on n_qubits input qubits.

  • channel_function (callable) – The function describing the channel, which takes a n_qubit-state as input and returns a state as output.

Methods:

__call__(rho, *args, **kwargs)

Calls the underlying channel_function directly.

apply_to(rho, qubit_indices, *args, **kwargs)

Apply the noise channel to specified qubits of a state rho .

freeze(*args, **kwargs)

Turn NoiseChannel with variable arguments into a static noise channel.

Attributes:

n_qubits

Return n_qubits.

__call__(rho, *args, **kwargs)

Calls the underlying channel_function directly.

This can be useful when defining a NoiseChannel in terms of another NoiseChannel or as composition of NoiseChannels.

Parameters:
  • rho (np.ndarray) – A n_qubit density matrix with shape (2**n_qubit, 2**n_qubit). The channel is applied to this input state.

  • *args (any) – args are passed through to channel_function

  • **kwargs (any) – kwargs are passed through to channel_function

Returns:

np.ndarray – The output state after the channel.

property n_qubits

Return n_qubits.

apply_to(rho, qubit_indices, *args, **kwargs)

Apply the noise channel to specified qubits of a state rho .

Parameters:
  • rho (np.ndarray) – The density matrix the channel is applied to.

  • qubit_indices (list of ints) – Numbering of qubits runs from 0…n-1

  • *args (are handed through to the appropriate function)

  • **kwargs (are handed through to the appropriate function)

Returns:

np.ndarray – The state after the channel has been applied.

freeze(*args, **kwargs)

Turn NoiseChannel with variable arguments into a static noise channel.

This is useful when the application of the channel is delayed, so the args and kwargs do not need to be stored separately until that happens.

Parameters:
  • *args (any) – Any args the channel should be called with when it is finally applied.

  • **kwargs (any) – Any kwargs the channel should be called with when it is finally applied.

Returns:

NoiseChannel – The frozen NoiseChannel.

class requsim.noise.NoiseModel(channel_before: NoiseChannel | None = None, map_replace: callable | None = None, channel_after: NoiseChannel | None = None)

Bases: object

Class for describing noise in a standardized way.

Parameters:
  • channel_before (NoiseChannel or None) – Channel that is applied before the operation. Default: None

  • map_replace (callable or None) – This noisy callable replaces whatever the operation tries to do. Default: None (May not be supported by all processes.)

  • channel_after (NoiseChannel or None) – Channel that is applied after the operation. Default: None

Variables:

Attributes:

channel_before

map_replace

channel_after

channel_before: NoiseChannel | None = None
map_replace: callable | None = None
channel_after: NoiseChannel | None = None
requsim.noise.freeze_noise_channel(noise_channel, *args, **kwargs)

DEPRECATED, instead use NoiseChannel.freeze(*args, **kwargs).

Deprecated because not compatible with extensions of different noise models.

Turn NoiseChannel with variable arguments into a static noise channel.

This is useful when the application of the channel is delayed, so the args and kwargs do not need to be stored separately until that happens.

Parameters:
  • noise_channel (NoiseChannel) – The NoiseChannel to freeze.

  • *args (any) – Any args the channel should be called with when it is finally applied.

  • **kwargs (any) – Any kwargs the channel should be called with when it is finally applied.

Returns:

NoiseChannel – The frozen NoiseChannel.