Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to control the maximum vector size in EVA?? #12

Open
2w21234 opened this issue Apr 28, 2021 · 2 comments
Open

How to control the maximum vector size in EVA?? #12

2w21234 opened this issue Apr 28, 2021 · 2 comments

Comments

@2w21234
Copy link

2w21234 commented Apr 28, 2021

Hi, I'm running EVA with 16384-length per a individual(sample) data for a simple model.
In the end of the execution, I had the following warning message,

'WARNING: Program uses vector size 16384 while only 4096 slots are required for security. This does not affect correctness, but higher performance may be available with a smaller vector size.'

So, I tried changing some parameters such as 'model.set_input_scales' and 'model.set_output_ranges',
and the required slots (4096 above) has changed to 16384 (maximum case in my case).

If I want use more samples (a vector with length 16384*2 ), then 16384 slots are still less to avoid that warning message.

I have two quenstions.

  1. Is there any way to control the maximum slots (acceptable length of input vector)?
  2. Does the warning message mean that the the security is loosened mathematically?

Thank you in advance for your reply :)

@olsaarik
Copy link
Contributor

olsaarik commented May 3, 2021

The warning is more of a performance hint than a problem to be fixed. What it is saying is that using smaller vectors (down to that 4096) would allow each individual operation in the program to be faster. So if it would be possible in your program to split your 16384 sized vectors into four smaller ones, then you might get better end-to-end performance. Whether this is possible depends on your program, for example if you need to do many rotations by numbers that are not a multiple of 4096, then it is not easy to do such a transformation. It is fully fine to just ignore this warning.

You can turn the warning off by passing "warn_vec_size":"false" to the config of the compiler as is done for example here: https://github.com/microsoft/EVA/blob/main/tests/large_programs.py#L137

To answer your questions:

  1. The 4096 number of slots is actually the minimum required for security. Larger ones are acceptable. This minimum is essentially determined by the multiplicative depth of the program and is affected by the scales you set (as you found). Both reducing the depth of the program in multiplications and reducing the scales will lower this (and generally result in better performance).
  2. The security is always guaranteed. In fact if you use a vec_size lower than that minimum, EVA will emulate that smaller vec_size with a larger one to meet the security guarantees. It will also give you a similar warning indicating that you could use a larger vec_size for no additional cost.

Also thank you for filing an issue. This warning is clearly something we could improve the wording in.

@2w21234
Copy link
Author

2w21234 commented May 4, 2021

I really want to thank you for your help. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants