-
Notifications
You must be signed in to change notification settings - Fork 108
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
MPC Quantized Machine Learning- Jacobi SVD #952
base: main
Are you sure you want to change the base?
Conversation
MPC Quantized Machine Learning- Jacobi SVD
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Stale pull request message. Please comment to remove stale tag. Otherwise this pr will be closed soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 需要在tests文件夹内增加jacobi_test.py文件
- python文件请格式化,推荐的工具参考这里
S = (A + A.T) / 2 | ||
return S | ||
|
||
n = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
算法实现的文件中不要出现这种全局的测试,你可以在tests/jacobi_test.py中测试明文实现 或者 密态精度
A, _, final_iterations = lax.fori_loop(0, max_iter, body_fun, (A, max_off_diag, iterations)) | ||
|
||
singular_values = jnp.abs(jnp.diag(A)) | ||
idx = jnp.argsort(-singular_values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我理解你就只是要把特征值从大到小排序,直接sort就行啊?
singular_values[idx]
还会做一次secret index,没有必要
idx = jnp.argsort(-singular_values) | ||
singular_values = singular_values[idx] | ||
|
||
return singular_values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议增加一个参数 来指定是否返回特征向量
return A | ||
|
||
@jit | ||
def jacobi_svd(A, tol=1e-10, max_iter=5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
麻烦增加一些必要的注释信息,起码需要包括:
- 明文下原始算法名称(最好包括ref)
- (optional)若有与明文算法不同处,可以简单概括并说明一下
- 涉及的参数介绍 以及 返回值介绍
print("Start Jacobi SVD emulation.") | ||
|
||
def proc_transform(A): | ||
singular_values = jacobi_svd(A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tips:默认配置下,FM64的fxp_bits = 18, 故最小的非0正数为2**-18,如果有稳定性问题,可以试试把tol改大一些?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请尽量把算法实现定义在jacobi_svd.py
中,在emul文件中仅需要import即可
PLUS: SPU重构了构建系统,python代码的构建推荐使用wrapper函数 |
|
||
n = 10 | ||
|
||
A_jax = generate_symmetric_matrix(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个算法只适用于对称矩阵么?如果是的话也可以直接在docstring里注明一下。。
MPC Quantized Machine Learning- Jacobi SVD
Pull Request
What problem does this PR solve?
Issue Number: Fixed #
Possible side effects?
Performance:
Backward compatibility: