-
-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Description
When multiply two large (relative to ring_size) values, the reconstructed result is wrong.
As I see it, when:
- a wraparound (or say
modoperation) happens in the computation process, - and the scale of the encoder is greater than 1,
then the result will be wrong.
How to Reproduce
Please run the following code, there are two examples showing this bug.
sy.logger.remove()
import torch
from sympc.session import Session
from sympc.config import Config
from sympc.session import SessionManager
from sympc.tensor import MPCTensor
parties = [sy.VirtualMachine(name=n).get_root_client() for n in ["alice", "bob"]]
# Example 1:
session = Session(parties=parties)
SessionManager.setup_mpc(session)
x_secret = torch.Tensor([1<<30])
x = x_secret.share(session=session)
z = x * 3
print(f"expect {x_secret*3}, but get {z.reconstruct()}")
# Example 2:
session = Session(parties=parties, ring_size=256, config=Config(encoder_base=10, encoder_precision=1))
SessionManager.setup_mpc(session)
x_secret = torch.Tensor([[0.1, -1], [-4, 4]])
x = x_secret.share(session=session)
z = x * 3
print(f"expect {x_secret*3}, but get {z.reconstruct()}")Metadata
Metadata
Assignees
Labels
No labels