mpc-msri / ezpc Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Multiplication gives incorrect result.
Reproduce error:
pytest -rs . -k "test_arith_binop[multiply-a_shape0-b_shape0-float32]" --backend="2PC_OT"
Today if signed ints are used in output statement, their unsigned versions are output.
For example,
def void main(){
int32_al x = -1;
output(SERVER, x);
}
The above function will print (1<<32)-1 and not -1.
Solution:
Fix ezpc.h so that output queue has output variable type in account.
We currently only take argmax only the last dimension. Support full semantics for tf.argmax
Reproduce error:
pytest -rs . -k "test_argmax" --backend="CPP"
Reproduce error:
pytest -rs -k "test_fill" --backend="2PC_HE"
Change debug=True for generate_code in utils.py:compile_and_run.
Party 2 runs into seg fault, party 1 is killed by pytest after timeout.
Hello,
I am trying to run a 64 bit ezpc program to find input 'a' raised to exponent 'b' Mod 998244353 where 'b' is also input. I wrote a fast exponentiation algorithm to do so similar to .This algorithm in Geeksforgeeks But i need modular exponentiation, so I incorporated the library function unsignedmodbl(uint64_bl x, uint64_bl y) which uses the function longDivision(uint64_bl x, uint64_bl y, bool_pl getQuotient) which is defined in EZPC/library/Library64.ezpc to take mod operation , I am able to compile the program ,but on running the client/server, it gives me the following error:
Reproduce error: test_div test case, (tf.truncatediv, -7, 5)
Reproduce error : pytest -rs . -k "test_conv" --backend="2PC_HE"
Add support for "SYMMETRIC" mode for tf.pad
Test case: test_pad
Reproduce error;
pytest -rs . -k "test_pool[avg_pool-float32-a_shape1-ksize1-strides1-SAME-NHWC]" --backend="CPP"
pytest -rs . -k "test_pool[max_pool-float32-a_shape1-ksize1-strides1-SAME-NHWC]" --backend="CPP"
Expected output:
[ 0.09, -0.44, -0.06, -0.72, 0.02, 1.31, 1. , -1.01, -0.4 ]
Actual output:
[ 0.09, -0.44, -0.03, -0.72, 0.02, 0.66, 0.5 , -0.51, -0.1 ]
Reproduce error: test_cast, test_fill, test_uop(shape)
I'm getting the following error after running the instructions in the ResNet readme and then ./CompileTF.sh -f Networks/ResNet/ResNet_main.py
in Athos
:
Traceback (most recent call last):
File "SeeDot.py", line 94, in <module>
obj.runCompilerDriver()
File "SeeDot.py", line 88, in runCompilerDriver
obj.run()
File "/home/marcel/EzPC/Athos/SeeDot/Compiler.py", line 124, in run
GC.run([mtdAST])
File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 173, in run
self.visit(self.ast, args)
File "/home/marcel/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 114, in visit
return self.visitLet(node, args)
File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 188, in visitLet
self.visit(node.expr, args)
(...)
File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 188, in visitLet
self.visit(node.expr, args)
File "/home/marcel/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 114, in visit
return self.visitLet(node, args)
File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 192, in visitLet
assert False, " visit of {} not implemented in GarbageCollector pass".format(str(type(node.decl)))
AssertionError: visit of <class 'AST.AST.FusedBatchNorm'> not implemented in GarbageCollector pass
We need to add general support for tf.squeeze
A squeeze of a tensor of shape [1, 2, 1, 3, 1, 1] should result in a tensor of shape [2,3].
Squeeze also has an axis dim where we can specify to collapse only specified dims. Add support for that to.
Currently we only support squeeze of 4D->2D, 4D->3D, 3D->2D in Library_common.ezpc. We should generate squeeze code instead of using library functions.
Assertion error for 2PC_HE: FCField::matrix_multiplication Assertion `num_cols == 1' failed.
pytest -rs . -k "test_matmul" --backend="2PC_HE"
Currently we only support padding with 0. However tf.pad allows padding with arbitrary constants. Add support for that.
Test case: test_pad
Add support for "REFLECT" mode for tf.pad
Test case: test_pad
Add support for "NC.." data format for bias_add node.
For tf.nn.bias_add(value, bias)
bias is a 1-D vector with shape equal to that of channel dimension.
We currently support broadcasting when value is "N..C". This falls in the normal broadcasting rules of numpy, ([1,250,250,3] + [3])
However when value is "NC..", then normal broadcasting doesn't work. eg: [1,3,250,250] + [3].
Failing test case: test_bias_add
Hello EzPC team,
I'm following the instructions in the SCI directory trying to compile the library. I am running ubuntu on a docker image.
I have the first two commands working,
mkdir build && cd build
cmake .. [-DBUILD_TESTS=ON] [-DBUILD_NETWORKS=ON]
but when running the make command after I get the following error.
I have libomp installed, so I am not sure why the error comes up.
I have all the required packages downloaded and in the correct version.
Any help would be welcomed. Thanks!
Add support for Floor1 in ezpc lib.
Reproduce error:
pytest -rs . -k "test_uop[floor-float32-a_shape1]" --backend="CPP"
Reproduce error:
pytest -rs . -k "test_reduce[reduce_mean_v1-float32-a_shape0-None-False" --backend="CPP"
Assertion Failure: "Expecting one of A or B to be an input by the server (model weight)."
Reproduce error: pytest -rs . -k "test_matmul" --backend="CPP"
ElemWiseSecretSharedVectorMult is not implemented. Add support for it.
Reproduce error: pytest -rs . -k "test_uop[square-float32-a_shape0]" --backend="2PC_OT"
Thanks for your great work! I wonder if there are any references for coding except your paper in EuroS&P2019, which contains not enough coding examples. Thank you.
In the below EzPC code,
def int64_bl expSigmoidA(int64_bl index)
{
return 0L;
}
def int64_bl expSigmoidB(int64_bl index)
{
return 0L;
}
def int64_bl expSigmoidC(int64_bl index)
{
return 0L;
}
def int64_bl expSigmoidD(int64_bl index)
{
return 0L;
}
def int64_bl expSigmoid(int64_bl x, int64_pl scaleIn, int64_pl scaleOut)
{
bool_bl cond = ((x < ( (-20L)*(33554432L) )) || (x > 0L) );
x = (x == (-2147483648L))?(2147483647L):(0L - x);
int64_bl val1 = (x & (127L));
int64_bl expVal1 = expSigmoidA(val1);
x = (x>>7L);
int64_bl val2 = (x & (255L));
int64_bl expVal2 = expSigmoidB(val2);
x = (x>>8L);
int64_bl val3 = (x & (255L));
int64_bl expVal3 = expSigmoidC(val3);
x = (x>>8L);
int64_bl val4 = (x & (255L));
int64_bl expVal4 = expSigmoidD(val4);
int64_bl t1 = expVal1 * expVal2;
t1 = t1 >> scaleOut;
int64_bl t2 = expVal3 * expVal4;
t2 = t2 >> scaleOut;
int64_bl t3 = t1 * t2;
t3 = t3 >> scaleOut;
return (cond?(0L):t3);
}
def void main(){
int64_bl var;
int64_bl sigvar;
sigvar = expSigmoid(var, 25L, 30L);
output(ALL, sigvar);
}
, particularly in the part
int64_bl expVal3 = expSigmoidC(val3);
x = (x>>8L);
the ABY code generated should be
x = signedarshiftbl(x, (int64_t)8);
However, the code generated is x = x;
.
I have fetched the source and installed the docker as instruction. After ensuring that ABY and EzPC compiler have been built in the docker, I tried to follow README in https://github.com/mpc-msri/EzPC/tree/master/Athos to see how the program works. The first several steps are quite smooth, until I tried to compile the model into Porthos by executing the script ./CompileTF.sh -b 64 -s 12 -t PORTHOS -f ./Networks/ResNet/ResNet_main.py
, I got following error log:
......[many lines of error trace back]......
File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
return self.visitLet(node, args)
File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
(prog_2, expr_2) = self.visit(node.expr)
File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
return self.visitLet(node, args)
File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
(prog_2, expr_2) = self.visit(node.expr)
File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
return self.visitLet(node, args)
File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
(prog_2, expr_2) = self.visit(node.expr)
File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
return self.visitLet(node, args)
File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
(prog_2, expr_2) = self.visit(node.expr)
File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
return self.visitLet(node, args)
File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 862, in visitLet
self.name_mapping[idf] = expr_1.idf
AttributeError: 'Int' object has no attribute 'idf'
[WARNING] Running as root is not recommended
Traceback (most recent call last):
File "./HelperScripts/AthosToPorthosTemp.py", line 31, in <module>
with open(filename, 'r') as ff:
FileNotFoundError: [Errno 2] No such file or directory: '/ezpc-workdir/EzPC/Athos/Networks/ResNet/ResNet_main_64_porthos0.cpp'
I guess the error might raise due to an incorrect software version or incorrect input. Can anyone provide some suggestions on how can I proceed to next step? Thanks
Reproduce error:
pytest -rs . -k "test_reduce[reduce_sum_v1-float32-a_shape2-0-False]" --backend="CPP"
pytest -rs . -k "test_reduce[reduce_mean_v1-float32-a_shape2-0-False]" --backend="CPP"
Hi,
some of the intrinsics used are from the AVX2 instruction set., e.g., _mm256_extracti128_si256
.
However, in the CMakeLists.txt
, only the AESNI instructions are required with -maes
is specified, but not AVX2 via -mavx2
.
Line 31 in 0918d6e
So that results in compilation errors if the current machine does not support AVX2:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/avx2intrin.h: In function ‘void sci::_mm256_storeu2_m128i(__m128i*, __m128i*, __m256i)’:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/avx2intrin.h:1093:1: error: inlining failed in call to ‘always_inline’ ‘__m128i _mm256_extracti128_si256(__m256i, int)’: target specific option mismatch
1093 | _mm256_extracti128_si256 (__m256i __X, const int __M)
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /path/to/EzPC/SCI/src/utils/io_channel.h:30,
from /path/to/EzPC/SCI/src/utils/net_io_channel.h:33,
from /path/to/EzPC/SCI/src/globals.h:232,
from /path/to/EzPC/SCI/tests/test_field_maxpool.cpp:24:
/path/to/EzPC/SCI/src/utils/block.h:54:19: note: called from here
54 | _mm_storeu_si128(hiaddr, _mm256_extracti128_si256(a, 1));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At other places in the code, functions are tagged with the attribute target("avx")
while using AVX2 intrinsics.
Lines 118 to 122 in 7c325fc
It would be nice, if the required instruction sets were documented somewhere.
Currently we support grouped conv only in the onnx frontend.
The behavior of output changes according to whether I provide server inputs first or client inputs first. Sometimes the outputs are shown only to client with ALL if server inputs are provided first.
Grappler doesn't optimise floordiv into a mul with a constant followed by a floor.
We can do this in Athos in simplifyGraph function.
Reproduce error: test_div test case,: tf.floordiv, [7, -7], 5
Reproduce: pytest -rs . -k "test_pool" --backend="CPP"
Expected output:
[-0.35, -0.32, -0.56, 0.7 , -0.4 , -0.92, 0.03, -0.49, 2.34]
Actual output:
[-0.35, -0.32, -0.28, 0.7 , -0.4 , -0.46, 0.02, -0.24, 0.58]
Add support for conv3d in SCI.
Reproduce error: pytest -rs . -k "test_conv" --backend="2PC_HE"
Hi,
I have two questions.
First, in the README, you show how to run networks.
But in which format do the binaries expect their input? I.e., what is the expected file format of the <model_file>
and <image_file>
files mentioned in the code snippet?
Second, how can I build the SCI_OT implementation?
If I just add -DSCI_OT
to the CMAKE_CXX_FLAGS
, I get an undefined reference errors, e.g.:
/usr/bin/ld: CMakeFiles/minionn_field64.dir/main_minionn_field64.cpp.o: in function `Conv2DWrapper(long, long, long, long, long, long, long, long, long, long, long, long, long, unsigned long*, unsigned long*, unsigned long*)':
main_minionn_field64.cpp:(.text+0x21c37): undefined reference to `Conv2D(int, int, int, int, int, int, int, int, int, int, int, int, int, unsigned long*, unsigned long*, unsigned long*)'
Thanks!
We have a node for tf.tile in Athos but haven't implemented the functionality.
Cast implementation currently acts as an identity op.
Add support for casting from float32 to int.
Reproduce error: pytest -rs . -k "test_cast" --backend="CPP"
Currently we only have support for padding of 4D and 5D tensors using Library functions.
Add support for ND tensors. We could simply add Pad1, Pad2, Pad3 functions but since we need to add support for reflect and symmetric padding too, it is better to just generate code instead of using library functions.
Test case: test_pad
Reproduce error:
pytest -rs . -k "test_pool[max_pool-float32-a_shape0-ksize0-strides0-VALID-NHWC]" --backend="2PC_OT"
We expect
[0.74, 0.94, 1.24, 1.15]
We get
[0.74, 0. , 1.24, 1.15]
It's always the second element in the result that is zero.
Hello,
I am trying to install and run EzPC with the docker method on Ubuntu. When I run sudo docker build -t ezpc_image . it works well but then ends at step 32/38.
in red it states
EzPC/EzPC/ABY_example/*': No such file or directory (second last line in image)
See the attached image. Thank you so much for any help you can provide!
To reproduce error run the test_div, test_cast test case.
Error: Invalid dtype found while parsing Value.
Currently splitting of tensor of size [2, 10] into 5 pieces along axis=1 results in 5 tensors of size [2,2]. This lowers to Split
which we currently support.
However tf.split also has support for splitting into specific sizes.
tf.split(a, num_or_size_splits=[2,3,7], axis=1)
would result in 3 tensors of size [2,2], [2,3] and [2,7].
We need to add support for the above which lowers to SplitV
Unit test: test_split
Thank you very much for this amazing work! I was wondering whether there is any tutorial on using the tools here in an end-to-end fashion. For example, if I have a pre-trained Tensorflow model, how should I create a secure 2-party system based on it using your toolset?
Thanks in advance for your time!
Consider this code:
def uint32_al foo(){
input(CLIENT, y, uint32_al);
return y;
}
def void bar(uint32_al x){
output(ALL, x);
}
def void main(){
uint32_al x = foo();
bar(x);
}
When compiled with ABY backend, ezpc compiles fine - but ABY itself doesn't compile.
This is because input/output statements use a variable called role, which is currently only being defined in main - if used in other functions, it results in error.
A solution can be to define role as a global variable and assign it in main.
1 + 2*3
is currently parsed as (1+2)*3
. This should instead be parsed as 1 + (2*3)
.
Fix needed in setting operator precedence in parser.mly. Need to discuss before implementing.
Reproduce error: pytest -rs . -k "test_conv_transpose" --backend="CPP"
We have a node in the Athos compiler for expand_dims function but it isn't implemented.
Test case: test_expand_dims
I am very interested in your work about your paper, CrypTFlow2: Practical 2-Party Secure Inference . This article is very valuable in both theory and practice. But I encountered some coding problems about it.
The First Question:
Whether the implementation of Algorithm 6, i.e., Multiplexer is void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp, or not.
The Second Question:
What is the meaning of row_batching = True/False in void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp ?
What is the meaning of accumulate = True/False in void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp ?
What is the maening of dim1, dim2 and dim3 in void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp ?
The Third Question:
Here, bwA and bwB is the bitwidth of A and B. assert(bwA == 1 || bwB == 1) ensures that the bitwidth of either A or B is 1, otherwise, the program will abort.
Whether A or B with a bitwidth of 1 is the choice bit for OT in Multiplexer or not?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.