tuneinsight/lattigo

Question: Parallelization and Key distribution

hkanpak21 opened this issue · 1 comments

Using lattigo v4.1, the issue persists.
I am trying to parallelize a simple neural network that uses lattigo elements. Whenever I try parallelization, the code works fine. However, switching to the encrypted version results in the error code mentioned in the attached file. I was expecting that the code should have worked fine since I am only parallelizing among the input data, where there are no dependencies or possible conflicts.

Added a main.go file that creates the same exact same problem.

main.txt

Use go run main.go train digits -layers=4 -hidden=128,32 -epochs=10 -rate=.1 to run the code.
Please consider only the first 7 functions (including main) regarding to problem. Rest is trivial, unrelated codes for a simple dense neural network.

@hkanpak21 Lattigo is not thread safe, to be able to use concurrency, you need to create a .ShallowCopy() of the structs that are used concurrently.

I will be unable to provide further help because the provided code is based on the v4 and I recall that some bugs related to .ShallowCopy() not working properly were fixed with the v5.

So I first suggest that you update your code to the v5 and see if it fixes the issue. Also it is recommended to not use v5@latest but v5@4cce9a4 (the latest commit on main) as it provides further bug fixes, some being also related concurrency.