IBM / aihwkit

IBM Analog Hardware Acceleration Kit
https://aihwkit.readthedocs.io
Apache License 2.0
349 stars 145 forks source link

undefined read noise in PCM inference model #660

Closed matifali closed 4 months ago

matifali commented 4 months ago

Description

https://github.com/IBM/aihwkit/blob/master/src/aihwkit/inference/noise/pcm.py#L153-L160

  # expected accumulated 1/f noise since start of programming at t=0
  if t > 0:
      q_s = (0.0088 / ((torch_abs(g_prog) / self.g_max) ** 0.65).clamp(min=1e-3)).clamp(
          max=0.2
      )
      sig_noise = q_s * sqrt(numpy_log((t + self.t_read) / (2 * self.t_read)))
      g_final = g_drift + torch_abs(g_drift) * self.read_noise_scale * sig_noise * randn_like(
          g_prog
      )

When t > 0 and t < t_read, this expression becomes undefined as the argument of the log is less than 1, which makes the argument of sqrt negative.

How to reproduce

use t = 50e-9

Expected behavior

There should be an additional condition on t to make sure its greater than t_read

Other information

matifali commented 4 months ago

Closing as I just noted, t = t_infernce + t_0 which makes it at least 20s