fixed precision tensor is supposed to work correctly given an int or float to be subtracted from or added to, just like a torch tensor.
for example:
torch.tensor(5) + 5 = tensor(10)
torch.tensor(5) - 5 = tensor(0)
this should be the correct behavior of FPT:
(torch.tensor(5).fix_prec() - torch.tensor(5)).float_prec() = tensor(0)
(torch.tensor(5) + torch.tensor(5).fix_prec()).float_prec() = tensor(10)
but instead we get:
(torch.tensor(5).fix_prec() - torch.tensor(5)).float_prec() = PureFrameworkTensorFoundError
(torch.tensor(5) + torch.tensor(5).fix_prec()).float_prec() = tensor(5.0050)
multiplication also is broken.
any fix should be tested against all arithmetic operations (add, sub, mul, div, ..etc)
I'd like to take this on :)
Formatting the exit condition and setup for easier checking
torch.tensor(5) + 5 = tensor(10)
torch.tensor(5) - 5 = tensor(0)
this should be the correct behavior of FPT:
(torch.tensor(5).fix_prec() - torch.tensor(5)).float_prec() = tensor(0)
(torch.tensor(5) + torch.tensor(5).fix_prec()).float_prec() = tensor(10)
but instead we get:
(torch.tensor(5).fix_prec() - torch.tensor(5)).float_prec() = PureFrameworkTensorFoundError
(torch.tensor(5) + torch.tensor(5).fix_prec()).float_prec() = tensor(5.0050)
@IanQS how it goes with this issue. Did you start work on it?
Heya @gmuraru !
I've started working on it but I'm running into roadblocks. I've solved the
torch.tensor(5) + torch.tensor(5).fix_prec()).float_prec() = tensor(5.0050) but admittedly my solution isn't pretty and I've not run tests to make sure that my changes don't break anything.
I'm not too sure about how to solve the first issue (PureFrameworkTensorFoundError) I'd love some guidance if you've got any insight into it
@gmuraru
I've linked my PR to this. Let me know if you think I'm going down the wrong path. I'd love to get feedback as I go along. I'm still trying to figure out how to address the PureFrameworkTensorFoundError
@IanQS you'd wanna look at the operations of the native tensor, since torch.Tensor+FPT calls the __add__ method of the native tensor (torch.Tensor)
Got it! I'll look into syft.frameworks.torch.tensor.interpreters.Tensor specifically the add! I'll get to it this weekend and will try my best to have something up by Monday.
@IanQS let's review and merge the first fix and make the second one in a separate PR
Hey @abogaziah @gmuraru
I think it might be better for me to unassign myself. I'm really not sure how to fix the issue or where to put the fixes so it might be better for someone else to try and take it on. I'll close out the PR but leave a reference to it
Hi @abogaziah I would like to attempt this if still available
@duggalsu sure, go-ahead
I would like to fix this if still available
Hi @xutongye , I've started to work on this now. Will need a few days. I'll let you know if I cannot finish it.
@LaRiffle I know we discussed yesterday about this behavior.
We throw an exception if:
This was the conclusion, right?
This issue has been marked stale because it has been open 30 days with no activity. Leave a comment or remove the stale label to unmark it. Otherwise, this will be closed in 7 days.