[Bug]: hello, could you please tell me some advice on the code location of "Ditto: Quantization-aware Secure Inference of Transformers upon MPC"
Issue Type
Others
Modules Involved
Others
Have you reproduced the bug with SPU HEAD?
Yes
Have you searched existing issues?
Yes
SPU Version
spu0.5.0
OS Platform and Distribution
linux18.04
Python Version
3.11
Compiler Version
GCC9.4.0
Current Behavior?
Since iam curious about the encrypted computation, so I read the paper "Ditto: Quantization-aware Secure Inference of Transformers upon MPC". It showed the code is available at spu. Could you please tell me some advice on the code location. Thanks very much !!!
Standalone code to reproduce the issue
a
Relevant log output
No response
Hi @llCurious
Feel free to comment on things to notice :D
@zhangwaer The related codes are: experimental_mp and backend impl.
You can also run the test script to have a try on dynamic ring computations.
Hi @llCurious
Feel free to comment on things to notice :D
Thanks very much!!!
@zhangwaer The related codes are: experimental_mp and backend impl.
You can also run the test script to have a try on dynamic ring computations.
Thanks very much!!!
@zhangwaer The related codes are: experimental_mp and backend impl.
You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in Ditto's work.
For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work.For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.
Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work. For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
SPU supports datatype conversion since day 1.
In normal SPU, the conversion is not optimal, Ditto introduced a more plaintext-like and optimal datatype conversion.
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work. For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
SPU supports datatype conversion since day 1.
In normal SPU, the conversion is not optimal,
Dittointroduced a more plaintext-like and optimal datatype conversion.
Thanks very much!!! So can i understand it as ditto improve the normal spu greatly, the new spu is optimal datatype conversion. and the new spu is shown in "https://github.com/secretflow/spu/tree/ditto_icml24".
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work. For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
SPU supports datatype conversion since day 1. In normal SPU, the conversion is not optimal,
Dittointroduced a more plaintext-like and optimal datatype conversion.Thanks very much!!! So can i understand it as ditto improve the normal spu greatly, the new spu is optimal datatype conversion. and the new spu is shown in "https://github.com/secretflow/spu/tree/ditto_icml24".
When i use the code "https://www.secretflow.org.cn/zh-CN/docs/secretflow/v1.8.0b0/tutorial/gpt2_with_puma" and change the code "self.low_dtype = jnp.float16 self.blocks = [ FlaxGPT2Block(self.config, name=str(i), dtype=self.low_dtype) for i in range(self.config.num_hidden_layers) ] " it report errors as follows: [Enforce fail at libspu/kernel/hal/type_cast.cc:102] (to_type == DT_F32 || to_type == DT_F64). expect to_type FXP, got F16
when i install dittospu as "https://github.com/secretflow/spu/tree/ditto_icml24/examples/python/ml/experimental_mp",
when i prepared "Install gcc>=11.2, cmake>=3.18, ninja, nasm>=2.15, python==3.8, bazel==6.2.1, golang"
and go to the step "python setup.py bdist_wheel"
it report the following answers, hope to get your advice, thanks!!!!!
ERROR: Skipping '//spu:init': error loading package 'spu': at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/defs.bzl:17:6: at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/py_binary.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined.
ERROR: error loading package 'spu': at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/defs.bzl:17:6: at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/py_binary.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined.
INFO: Elapsed time: 2.117s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
currently loading: spu/utils ... (2 packages)
Fetching repository @rules_cc; Restarting.
Traceback (most recent call last):
File "setup.py", line 242, in
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work. For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
SPU supports datatype conversion since day 1. In normal SPU, the conversion is not optimal,
Dittointroduced a more plaintext-like and optimal datatype conversion.Thanks very much!!! So can i understand it as ditto improve the normal spu greatly, the new spu is optimal datatype conversion. and the new spu is shown in "https://github.com/secretflow/spu/tree/ditto_icml24".
When i use the code "https://www.secretflow.org.cn/zh-CN/docs/secretflow/v1.8.0b0/tutorial/gpt2_with_puma" and change the code "self.low_dtype = jnp.float16 self.blocks = [ FlaxGPT2Block(self.config, name=str(i), dtype=self.low_dtype) for i in range(self.config.num_hidden_layers) ] " it report errors as follows: [Enforce fail at libspu/kernel/hal/type_cast.cc:102] (to_type == DT_F32 || to_type == DT_F64). expect to_type FXP, got F16
This line of enforce does not exist on ditto branch, please make sure you are using the right version to do experiments.
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work. For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
SPU supports datatype conversion since day 1. In normal SPU, the conversion is not optimal,
Dittointroduced a more plaintext-like and optimal datatype conversion.Thanks very much!!! So can i understand it as ditto improve the normal spu greatly, the new spu is optimal datatype conversion. and the new spu is shown in "https://github.com/secretflow/spu/tree/ditto_icml24".
When i use the code "https://www.secretflow.org.cn/zh-CN/docs/secretflow/v1.8.0b0/tutorial/gpt2_with_puma" and change the code "self.low_dtype = jnp.float16 self.blocks = [ FlaxGPT2Block(self.config, name=str(i), dtype=self.low_dtype) for i in range(self.config.num_hidden_layers) ] " it report errors as follows: [Enforce fail at libspu/kernel/hal/type_cast.cc:102] (to_type == DT_F32 || to_type == DT_F64). expect to_type FXP, got F16
This line of enforce does not exist on ditto branch, please make sure you are using the right version to do experiments.
Thanks very much, but when i install dittospu as "https://github.com/secretflow/spu/tree/ditto_icml24/examples/python/ml/experimental_mp", when i prepared "Install gcc>=11.2, cmake>=3.18, ninja, nasm>=2.15, python==3.8, bazel==6.2.1, golang" and go to the step "python setup.py bdist_wheel" it report the following answers, hope to get your advice, thanks!!!!! ERROR: Skipping '//spu:init': error loading package 'spu': at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/defs.bzl:17:6: at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/py_binary.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined. ERROR: error loading package 'spu': at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/defs.bzl:17:6: at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/py_binary.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined. INFO: Elapsed time: 2.117s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded) currently loading: spu/utils ... (2 packages) Fetching repository @rules_cc; Restarting. Traceback (most recent call last): File "setup.py", line 242, in setuptools.setup( File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/init.py", line 104, in setup return distutils.core.setup(**attrs) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 184, in setup return run_commands(dist) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 200, in run_commands dist.run_commands() File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 368, in run self.run_command("build") File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/command/build.py", line 132, in run self.run_command(cmd_name) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "setup.py", line 216, in run return pip_run(self) File "setup.py", line 193, in pip_run build(True, True) File "setup.py", line 159, in build return bazel_invoke( File "setup.py", line 120, in bazel_invoke result = invoker(['bazel'] + cmdline, *args, **kwargs) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['bazel', 'build', '--verbose_failures', '-c', 'opt', '--config=linux-release', '--config=avx', '--', '//spu:init', '//spu/utils:distributed', '//spu:api']' returned non-zero exit status 1.
@zhangwaer The related codes are: experimental_mp and backend impl. You can also run the test script to have a try on dynamic ring computations.
thanks very much, the code is so excellent, i hava two questions hoping to get some teaching. The first is that i know the spu support datatype conversion, i wanna know whether the secretflow support it. The second is that i know that "jnp.float16 and jnp.float32 for low-, and high-precision, which correspond to 32-bit ring and 64-bit ring". what about the 128-bit ring. Thanks very much!!!
Mapping float16 and float32 to different rings is an experimental feature only available in
Ditto's work. For secretflow or normal SPU, datatype conversion will not actually increase or decrease ring size.Thanks very much!!! so the spu in "https://github.com/secretflow/spu/tree/ditto_icml24" is not the new version that support datatype conversion? And the the data conversion is not support to other models such as resnet and only support for ditto?
SPU supports datatype conversion since day 1. In normal SPU, the conversion is not optimal,
Dittointroduced a more plaintext-like and optimal datatype conversion.Thanks very much!!! So can i understand it as ditto improve the normal spu greatly, the new spu is optimal datatype conversion. and the new spu is shown in "https://github.com/secretflow/spu/tree/ditto_icml24".
When i use the code "https://www.secretflow.org.cn/zh-CN/docs/secretflow/v1.8.0b0/tutorial/gpt2_with_puma" and change the code "self.low_dtype = jnp.float16 self.blocks = [ FlaxGPT2Block(self.config, name=str(i), dtype=self.low_dtype) for i in range(self.config.num_hidden_layers) ] " it report errors as follows: [Enforce fail at libspu/kernel/hal/type_cast.cc:102] (to_type == DT_F32 || to_type == DT_F64). expect to_type FXP, got F16
This line of enforce does not exist on ditto branch, please make sure you are using the right version to do experiments.
Thanks very much, but when i install dittospu as "https://github.com/secretflow/spu/tree/ditto_icml24/examples/python/ml/experimental_mp", when i prepared "Install gcc>=11.2, cmake>=3.18, ninja, nasm>=2.15, python==3.8, bazel==6.2.1, golang" and go to the step "python setup.py bdist_wheel" it report the following answers, hope to get your advice, thanks!!!!! ERROR: Skipping '//spu:init': error loading package 'spu': at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/defs.bzl:17:6: at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/py_binary.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined. ERROR: error loading package 'spu': at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/defs.bzl:17:6: at /root/.cache/bazel/_bazel_root/5fb069ff7e8788e0e7d803c89624f2bc/external/rules_python/python/py_binary.bzl:17:6: Unable to find package for @rules_python_internal//:rules_python_config.bzl: The repository '@rules_python_internal' could not be resolved: Repository '@rules_python_internal' is not defined. INFO: Elapsed time: 2.117s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded) currently loading: spu/utils ... (2 packages) Fetching repository @rules_cc; Restarting. Traceback (most recent call last): File "setup.py", line 242, in setuptools.setup( File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/init.py", line 104, in setup return distutils.core.setup(**attrs) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 184, in setup return run_commands(dist) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 200, in run_commands dist.run_commands() File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 368, in run self.run_command("build") File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/command/build.py", line 132, in run self.run_command(cmd_name) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "setup.py", line 216, in run return pip_run(self) File "setup.py", line 193, in pip_run build(True, True) File "setup.py", line 159, in build return bazel_invoke( File "setup.py", line 120, in bazel_invoke result = invoker(['bazel'] + cmdline, *args, **kwargs) File "/usr/local/miniconda3/envs/sfz/lib/python3.8/subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['bazel', 'build', '--verbose_failures', '-c', 'opt', '--config=linux-release', '--config=avx', '--', '//spu:init', '//spu/utils:distributed', '//spu:api']' returned non-zero exit status 1.
Hi @zhangwaer
There were some code syncing issues, just pushed a fix. Please try build again.