aihwkit.inference.noise.base module

Base class for the phenomenological noise models for inference.

class aihwkit.inference.noise.base.BaseNoiseModel(g_converter=None)[source]

Bases: object

Base class for phenomenological noise models for inference.

Parameters:

g_converter (BaseConductanceConverter | None) –

apply_drift_noise(weights, drift_noise_parameters, t_inference)[source]

Apply the expected drift noise to weights.

Uses the apply_drift_noise_to_conductances() on each of the conductance slices.

Parameters:
  • weights (Tensor) – weights tensor (usually with programming noise already applied)

  • drift_noise_parameters (List[Tensor | None]) – list of drift nu for each conductance slice

  • t_inference (float) – assumed time of inference (in sec)

Returns:

weight tensor with drift noise applied

Return type:

Tensor

apply_drift_noise_to_conductance(g_prog, drift_noise_param, t_inference)[source]

Apply the noise and drift up to the assumed inference time point.

Parameters:
  • g_prog (Tensor) – Tensor of conductance values after programming (in \(\muS\))

  • drift_noise_param (Tensor | None) – typically drift nu

  • t_inference (float) – assumed time of inference (in sec)

Returns:

conductance Tensor with applied noise and drift

Return type:

Tensor

apply_noise(weights, t_inference)[source]

Apply the expected noise.

Applies the noise to a non-perturbed conductance matrix weights at time of inference t_inference (in seconds) where 0 sec refers to the time when weight programming has finished.

Note

The drift coefficients and intermediate noises etc. are sampled for each application of this function anew from the distributions, thus it samples the expected noise and drift behavior at time t_inference but not a continual trajectory of a given device instance over time (having e.g. constant drift coefficients).

Parameters:
  • weights (Tensor) –

  • t_inference (float) –

Return type:

Tensor

apply_programming_noise(weights)[source]

Apply the expected programming noise to weights.

Uses the apply_programming_noise_to_conductances() on each of the conductance slices.

Parameters:

weights (Tensor) – weights tensor

Returns:

weight tensor with programming noise applied, and tuple of all drift coefficients (per conductances slice) that are determined during programming.

Return type:

Tuple[Tensor, List[Tensor]]

apply_programming_noise_to_conductance(g_target)[source]

Apply programming noise to a target conductance Tensor.

Parameters:

g_target (Tensor) – Target conductances

Returns:

Tensor of sampled drift coefficients \(\nu\), one for each target conductance value.

Return type:

Tensor

generate_drift_coefficients(g_target)[source]

Generate drift coefficients.

Generate coefficients once and passed through when long-term noise and drift is applied. Typical nu_drift.

Parameters:

g_target (Tensor) – Target conductances

Returns:

When not overriden, it simply returns None.

Return type:

Tensor | None