Skip to content

Commit e533801

Browse files
w-gctongke6
andauthored
repo-sync-2025-01-02T18:56:23+0800 (#954)
- [SPU] Migrating to Bazel Modules and update minimum Python version to 3.10. - [Feature] Add soPRF (LowMC cipher) for SEMI2K - [API] Add Permute/InvPermute support in HLO - [Feature] Add SSL configuration to the TTP server - [Feature] Support quick sort for semi2k and aby3 --------- Co-authored-by: tongke6 <[email protected]>
1 parent eb25d5e commit e533801

File tree

197 files changed

+8346
-9623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+8346
-9623
lines changed

.bazeliskrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
USE_BAZEL_VERSION=7.4.1

.bazelrc

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
common --experimental_repo_remote_exec
1616
common --experimental_cc_shared_library
1717

18+
common --registry=https://raw.githubusercontent.com/secretflow/bazel-registry/main
19+
common --registry=https://bcr.bazel.build
20+
common --registry=https://baidu.github.io/babylon/registry
21+
1822
# Required by OpenXLA
1923
build --nocheck_visibility
2024

@@ -64,3 +68,6 @@ build:macos --action_env MACOSX_DEPLOYMENT_TARGET=13.0
6468

6569
build:linux --copt=-fopenmp
6670
build:linux --linkopt=-fopenmp
71+
72+
# NOTE: fix build on linux_aarch64, since `build:linux_aarch64` works only if `--config linux_aarch64` option included.
73+
build:linux --cxxopt=-Wno-mismatched-new-delete

.bazelversion

-1
This file was deleted.

.circleci/asan-config.yml

-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ jobs:
4646
- run:
4747
name: Checkout devtools
4848
command: git clone https://github.com/secretflow/devtools.git ../devtools
49-
- run:
50-
name: "Install dependencies"
51-
command: |
52-
python3 -m pip install numpy
5349
- run:
5450
name: "test"
5551
command: |

.circleci/benchmark-config.yml

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ jobs:
4747
"python3 -m pip install -U pip && \
4848
python3 -m pip install spu && \
4949
cd /home/admin/dev/ && \
50-
python3 -m pip install -r requirements-dev.txt && \
51-
python3 -m pip install -r examples/python/ml/requirements.txt && \
5250
export PYTHONPATH="${PWD}:$PYTHONPATH" && \
5351
bash .circleci/run-nn.sh" | tee benchmark_results.log
5452
- run:

.circleci/continue-config.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,17 @@ commands:
5252
- run:
5353
name: Checkout devtools
5454
command: git clone https://github.com/secretflow/devtools.git ../devtools
55-
- run:
56-
name: "Install dependencies"
57-
command: |
58-
python3 -m pip install -r requirements.txt
59-
python3 -m pip install -r requirements-dev.txt
6055
- run:
6156
name: Setup GCS
6257
command: |
6358
echo ${gcs_content} > ../gcs.data
6459
../devtools/bazel_cache_setup.py --in_file=../gcs.data --out_file=../gcs.json --min_download
6560
- run:
6661
name: "build"
67-
command: bazel build <<parameters.targets>> -c opt --ui_event_filters=-info,-debug,-warning
62+
command: |
63+
bazel --version && python3 --version
64+
if [ ! -e "/usr/bin/python3" ]; then ln -s `which python3` /usr/bin/python3; fi
65+
bazel run //:requirements-dev.update && bazel build <<parameters.targets>> -c opt --ui_event_filters=-info,-debug,-warning
6866
- run:
6967
name: "test"
7068
command: |
@@ -114,7 +112,6 @@ jobs:
114112
name: Install extra deps
115113
command: |
116114
python3 -m pip install tzdata
117-
python3 -m pip install -r examples/python/ml/requirements.txt
118115
- build_and_test:
119116
targets: //examples/python/ml:ml_test
120117
extra_bazel_test_args: --test_env LD_LIBRARY_PATH=/root/miniconda3/lib/
@@ -134,8 +131,6 @@ jobs:
134131
bash ~/miniconda.sh -b -p $HOME/miniconda
135132
source $HOME/miniconda/bin/activate
136133
conda init bash zsh
137-
pip install -r requirements.txt
138-
pip install -r requirements-dev.txt
139134
- build_and_test
140135
# Invoke jobs via workflows
141136
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows

.circleci/release-config.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ commands:
5252
conda create -n build python=<< parameters.python_ver >> -y
5353
conda activate build
5454
55-
sh ./build_wheel_entrypoint.sh
55+
bazel build //:spu_wheel -c opt --@rules_python//python/config_settings:python_version=<< parameters.python_ver >>
5656
python3 -m pip install twine
57-
ls dist/*.whl
57+
ls bazel-bin/spu*.whl
5858
59-
python3 -m twine upload -r pypi -u __token__ -p ${PYPI_TWINE_TOKEN} dist/*.whl
59+
python3 -m twine upload -r pypi -u __token__ -p ${PYPI_TWINE_TOKEN} bazel-bin/spu*.whl
6060
6161
# Define a job to be invoked later in a workflow.
6262
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
@@ -103,15 +103,15 @@ workflows:
103103
- linux_publish:
104104
matrix:
105105
parameters:
106-
python_ver: ["3.9", "3.10", "3.11"]
106+
python_ver: ["3.10", "3.11"]
107107
executor: ["linux_x64_executor", "linux_aarch64_executor"]
108108
filters:
109109
tags:
110110
only: /.*(?<!dev\d{8})$/
111111
- macOS_publish:
112112
matrix:
113113
parameters:
114-
python_ver: ["3.9", "3.10", "3.11"]
114+
python_ver: ["3.10", "3.11"]
115115
filters:
116116
tags:
117117
only: /.*(?<!dev\d{8})$/

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ _build
2525

2626
# bazel
2727
/bazel-*
28+
MODULE.bazel.lock
2829

2930
# cmake related
3031
abseil-cpp

.licenserc.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ header: # <1>
4343
- 'libspu/compiler/tests/interpret/template/**.template'
4444
- 'LICENSE'
4545
- 'NOTICE'
46-
- '.bazelversion'
46+
- 'MODULE.bazel.lock'
47+
- '.bazeliskrc'
4748
- '.clang-format'
4849
- '.clang-tidy'
4950
- '.gitattributes'
5051
- '.gitignore'
5152
- '.gitmodules'
5253
- 'pyproject.toml'
53-
- 'setup.cfg'
5454
- 'libspu/core/half.h' # MIT
5555

5656
comment: never # <9>

BUILD.bazel

+111
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,114 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
load("@python_versions//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
16+
load("@python_versions//3.11:defs.bzl", compile_pip_requirements_3_11 = "compile_pip_requirements")
17+
18+
# load("@python_versions//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
19+
load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")
20+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
21+
load("//:version.bzl", "SPU_VERSION")
22+
23+
# compile_pip_requirements_3_9(
24+
# name = "requirements_3_9",
25+
# src = "requirements_3_9.txt",
26+
# requirements_txt = "requirements_lock_3_9.txt",
27+
# tags = ["manual"],
28+
# )
29+
30+
compile_pip_requirements_3_10(
31+
name = "requirements_3_10",
32+
src = "requirements.txt",
33+
requirements_txt = "requirements_lock_3_10.txt",
34+
tags = ["manual"],
35+
)
36+
37+
compile_pip_requirements_3_11(
38+
name = "requirements_3_11",
39+
src = "requirements.txt",
40+
requirements_txt = "requirements_lock_3_11.txt",
41+
tags = ["manual"],
42+
)
43+
44+
compile_pip_requirements(
45+
name = "requirements-dev",
46+
src = "requirements-dev.txt",
47+
requirements_txt = "requirements_dev_lock.txt",
48+
tags = ["manual"],
49+
)
50+
51+
exports_files([
52+
"README.md",
53+
])
54+
55+
# https://rules-python.readthedocs.io/en/latest/api/rules_python/python/packaging.html#py_wheel_rule
56+
py_wheel(
57+
name = "spu_wheel",
58+
abi = select(
59+
{
60+
"@rules_python//python/config_settings:is_python_3.10": "cp310",
61+
"@rules_python//python/config_settings:is_python_3.11": "cp311",
62+
# "@rules_python//python/config_settings:is_python_3.9": "cp39",
63+
"//conditions:default": "none",
64+
},
65+
),
66+
author = "SecretFlow Team",
67+
author_email = "[email protected]",
68+
classifiers = [
69+
"Programming Language :: Python :: 3.9",
70+
"Programming Language :: Python :: 3.10",
71+
"Programming Language :: Python :: 3.11",
72+
],
73+
description_content_type = "text/markdown",
74+
description_file = "README.md",
75+
distribution = "spu",
76+
extra_distinfo_files = {
77+
"//:LICENSE": "LICENSE",
78+
},
79+
homepage = "https://github.com/secretflow/spu",
80+
license = "Apache License 2.0",
81+
# TODO: add other fields.
82+
platform = select(
83+
{
84+
"@bazel_tools//src/conditions:linux_x86_64": "manylinux2014_x86_64",
85+
"@bazel_tools//src/conditions:darwin_arm64": "macosx_13_0_arm64",
86+
"@bazel_tools//src/conditions:linux_aarch64": "manylinux_2_28_aarch64",
87+
"//conditions:default": "any",
88+
},
89+
),
90+
python_requires = ">=3.9",
91+
python_tag = select(
92+
{
93+
"@rules_python//python/config_settings:is_python_3.10": "cp310",
94+
"@rules_python//python/config_settings:is_python_3.11": "cp311",
95+
# "@rules_python//python/config_settings:is_python_3.9": "cp39",
96+
"//conditions:default": "py3",
97+
},
98+
),
99+
requires_file = "requirements.txt",
100+
summary = "SPU aims to be a 'provable', 'measurable' secure computation device.",
101+
tags = ["manual"],
102+
twine = None,
103+
version = SPU_VERSION,
104+
deps = [
105+
":spu_pkg",
106+
],
107+
)
108+
109+
py_package(
110+
name = "spu_pkg",
111+
packages = [
112+
"libspu",
113+
"spu",
114+
],
115+
visibility = ["//visibility:private"],
116+
deps = [
117+
"//spu:api",
118+
"//spu:init",
119+
"//spu:libpsi",
120+
"//spu:libspu",
121+
"//spu/ops/groupby",
122+
"//spu/utils:distributed",
123+
],
124+
)

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
>
1111
> please add your unreleased change here.
1212
13+
- [SPU] Migrating to Bazel Modules and update minimum Python version to 3.10.
14+
- [Feature] Add soPRF (LowMC cipher) for SEMI2K
15+
- [API] Add Permute/InvPermute support in HLO
16+
- [Feature] Add SSL configuration to the TTP server
17+
- [Feature] Support quick sort for semi2k and aby3
18+
1319
## 20241219
1420

1521
- [SPU] 0.9.3b0 release

CONTRIBUTING.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ docker exec -it spu-dev-$(whoami) bash
6262
Install gcc>=11.2, cmake>=3.26, ninja, nasm>=2.15, python>=3.9, bazelisk, xxd, lld
6363
```
6464

65-
About the commands used to install the above dependencies, you can follow [Ubuntu docker file](https://github.com/secretflow/devtools/blob/main/dockerfiles/ubuntu-base-ci.DockerFile).
66-
67-
```sh
68-
python3 -m pip install -r requirements.txt
69-
python3 -m pip install -r requirements-dev.txt
70-
```
71-
7265
#### macOS
7366

7467
```sh
@@ -90,10 +83,6 @@ brew install bazelisk cmake ninja libomp wget
9083

9184
# For Intel mac only
9285
brew install nasm
93-
94-
# Install python dependencies
95-
pip install -r requirements.txt
96-
pip install -r requirements-dev.txt
9786
```
9887

9988
### Build & UnitTest
@@ -117,6 +106,7 @@ bazel test //... --features=ubsan
117106

118107
- `--define gperf=on` enable gperf
119108
- `--define tracelog=on` enable link trace log.
109+
- `--@rules_python//python/config_settings:python_version=3.10` set the Python version as 3.10, the default version is 3.11
120110

121111
### Build docs
122112

INSTALLATION.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pip install spu
3838
- At the root of repo, run
3939

4040
```bash
41-
python setup.py bdist_wheel
42-
pip install dist/*.whl --force-reinstall
41+
bazel build //:spu_wheel -c opt
42+
pip install bazel-bin/spu-*.whl --force-reinstall
4343
```
4444

4545
- Once GCC/bazel/python/Xcode version or other environment settings have changed, please run the following command to ensure a clean build
@@ -51,5 +51,15 @@ bazel clean --expunge
5151
#### Build with GPU support
5252

5353
```bash
54-
export ENABLE_GPU_BUILD=1 && python setup.py bdist_wheel
54+
bazel build //:spu_wheel -c opt --config=gpu
55+
```
56+
57+
#### Build with specified python version
58+
59+
```bash
60+
# build with python 3.10
61+
bazel build //:spu_wheel -c opt --@rules_python//python/config_settings:python_version=3.10
62+
63+
# build with python 3.11
64+
bazel build //:spu_wheel -c opt --@rules_python//python/config_settings:python_version=3.11
5565
```

0 commit comments

Comments
 (0)