I’m trying to convert the LSTM example (hnp-examples/LSTM.ipynb at main · zama-ai/hnp-examples · GitHub) from hpn to concrete-numpy. I have managed to solve a few problems on my own, but now I have one that seems to indicate that the Tracer doesn’t know the np.exp function.
I have the following error:

AttributeError Traceback (most recent call last)
AttributeError: ‘NPTracer’ object has no attribute ‘exp’
The above exception was the direct cause of the following exception:

This is quite challenging to do this port, since Concrete Numpy is not meant to be a replacement of HNP. Indeed, we’ve done a pivot in Zama, because of some precision problems in HNP.

I reproduced the error with the notebook in your repository. Here is why you are getting the error. You are calling self.W_ii.dot(x) and NumPy executes its dot product logic instead of our tracing logic. We’ll investigate ways to support your usage in the future. To get around it, you need to use np.dot(self.W_ii, x) for the time being.

Unfortunately, this leads to another error because of some limitations of concrete-numpy on np.dot(...). In the upcoming releases, np.dot(...) will be fully supported. For now, you can try to use np.matmul(...). If it works, great! If it doesn’t let us know and we’ll notify you under this thread when the functionality you require is available.

Thanks for the quick answer. Replacing np.dot() by np.matmul() did the trick.

I now have an error regarding the fact that the matrices elements are float64. Looking at the doc, I’m assuming that I need to quantize the model to int8 before using concrete-numpy. I’ll will experiment and see.

I’m aware that this will be challenging. To put some context, I’m partner of Zama in the CRYPTECS research project with the objective to evaluate privacy enhancing technologies on concrete industrial use cases. Honestly I was not, and still not expecting everything to be smooth. But it is a good way to uncover shortcomings either from the theoretical side, or the implementation.