Skip to content

Commit 974da94

Browse files
committed
chore: add wasm_par_mq crate for unsafe coop wasm parallelism
1 parent d57b6a5 commit 974da94

Some content is hidden

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

41 files changed

+4117
-11
lines changed

.github/workflows/aws_tfhe_wasm_tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ jobs:
117117
run: |
118118
make install_chrome_browser
119119
make install_chrome_web_driver
120+
make install_firefox_browser
121+
make install_firefox_web_driver
120122
121123
- name: Run fmt checks
122124
run: |
@@ -130,6 +132,11 @@ jobs:
130132
run: |
131133
make test_web_js_api_parallel_chrome_ci
132134
135+
- name: Run wasm_par_mq tests
136+
run: |
137+
make test_wasm_par_mq_chrome_ci
138+
make test_wasm_par_mq_firefox_ci
139+
133140
- name: Run x86_64/wasm zk compatibility tests
134141
run: |
135142
make test_zk_wasm_x86_compat_ci

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ venv/
3232
web-test-runner/
3333
node_modules/
3434
package-lock.json
35+
utils/wasm-par-mq/examples/*/pkg/
3536

3637
# Python .env
3738
.env

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ members = [
1616
"utils/tfhe-backward-compat-data",
1717
"utils/tfhe-backward-compat-data/crates/add_new_version",
1818
"utils/param_dedup",
19+
"utils/wasm-par-mq",
20+
"utils/wasm-par-mq/web_tests",
21+
"utils/wasm-par-mq/examples/msm",
1922
"tests",
2023
"mockups/tfhe-hpu-mockup",
2124
"apps/test-vectors",
@@ -46,6 +49,9 @@ bincode = "=1.3.3"
4649
cmake = "0.1"
4750
pkg-config = "0.3"
4851
clap = { version = "4.5", features = ["derive"] }
52+
js-sys = "0.3"
53+
serde-wasm-bindgen = "0.6.5"
54+
paste = "1.0.15"
4955

5056
[profile.bench]
5157
lto = "fat"

Makefile

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ clippy_param_dedup: install_rs_check_toolchain
534534
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \
535535
-p param_dedup -- --no-deps -D warnings
536536

537+
.PHONY: clippy_wasm_par_mq # Run clippy lints on wasm-par-mq and its examples
538+
clippy_wasm_par_mq: install_rs_check_toolchain
539+
RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets --all-features \
540+
-p wasm-par-mq -p wasm-par-mq-web-tests -p wasm-par-mq-example-msm -- --no-deps -D warnings
541+
537542
.PHONY: clippy_backward_compat_data # Run clippy lints on tfhe-backward-compat-data
538543
clippy_backward_compat_data: install_rs_check_toolchain # the toolchain is selected with toolchain.toml
539544
@# Some old crates are x86 specific, only run in that case
@@ -559,7 +564,7 @@ clippy_test_vectors: install_rs_check_toolchain
559564
clippy_all: clippy_rustdoc clippy clippy_boolean clippy_shortint clippy_integer clippy_all_targets \
560565
clippy_c_api clippy_js_wasm_api clippy_tasks clippy_core clippy_tfhe_csprng clippy_zk_pok clippy_trivium \
561566
clippy_versionable clippy_tfhe_lints clippy_ws_tests clippy_bench clippy_param_dedup \
562-
clippy_test_vectors clippy_backward_compat_data
567+
clippy_test_vectors clippy_backward_compat_data clippy_wasm_par_mq
563568

564569
.PHONY: clippy_fast # Run main clippy targets
565570
clippy_fast: clippy_rustdoc clippy clippy_all_targets clippy_c_api clippy_js_wasm_api clippy_tasks \
@@ -1099,7 +1104,7 @@ test_high_level_api_gpu_fast: install_cargo_nextest # Run all the GPU tests for
10991104
test_high_level_api_gpu: install_cargo_nextest # Run all the GPU tests for high_level_api
11001105
RUSTFLAGS="$(RUSTFLAGS)" cargo nextest run --cargo-profile $(CARGO_PROFILE) \
11011106
--test-threads=4 --features=integer,internal-keycache,gpu,zk-pok -p tfhe \
1102-
-E "test(/high_level_api::.*gpu.*/)"
1107+
-E "test(/high_level_api::.*gpu.*/)"
11031108

11041109
test_list_gpu: install_cargo_nextest
11051110
RUSTFLAGS="$(RUSTFLAGS)" cargo nextest list --cargo-profile $(CARGO_PROFILE) \
@@ -1397,6 +1402,54 @@ test_web_js_api_parallel_firefox_ci: setup_venv
13971402
nvm use $(NODE_VERSION) && \
13981403
$(MAKE) test_web_js_api_parallel_firefox
13991404

1405+
WASM_PAR_MQ_TEST_DIR=utils/wasm-par-mq/web_tests
1406+
1407+
.PHONY: build_wasm_par_mq_tests # Build the wasm-par-mq test WASM package
1408+
build_wasm_par_mq_tests: install_wasm_pack
1409+
cd $(WASM_PAR_MQ_TEST_DIR) && \
1410+
RUSTFLAGS="$(WASM_RUSTFLAGS)" wasm-pack build --target=web --out-dir pkg
1411+
1412+
# This is an internal target, not meant to be called on its own.
1413+
run_wasm_par_mq_tests: build_wasm_par_mq_tests setup_venv
1414+
cd $(WASM_PAR_MQ_TEST_DIR) && npm install && npm run build
1415+
source venv/bin/activate && \
1416+
python ci/webdriver.py \
1417+
--browser-path $(browser_path) \
1418+
--driver-path $(driver_path) \
1419+
--browser-kind $(browser_kind) \
1420+
--server-cmd "npm run server" \
1421+
--server-workdir "$(WASM_PAR_MQ_TEST_DIR)" \
1422+
--index-path "$(WASM_PAR_MQ_TEST_DIR)/index.html" \
1423+
--id-pattern Test
1424+
1425+
test_wasm_par_mq_chrome: browser_path = "$(WEB_RUNNER_DIR)/chrome/chrome-linux64/chrome"
1426+
test_wasm_par_mq_chrome: driver_path = "$(WEB_RUNNER_DIR)/chrome/chromedriver-linux64/chromedriver"
1427+
test_wasm_par_mq_chrome: browser_kind = chrome
1428+
1429+
.PHONY: test_wasm_par_mq_chrome # Run wasm-par-mq tests on Chrome
1430+
test_wasm_par_mq_chrome: run_wasm_par_mq_tests
1431+
1432+
.PHONY: test_wasm_par_mq_chrome_ci # Run wasm-par-mq tests on Chrome in CI
1433+
test_wasm_par_mq_chrome_ci: setup_venv
1434+
source ~/.nvm/nvm.sh && \
1435+
nvm install $(NODE_VERSION) && \
1436+
nvm use $(NODE_VERSION) && \
1437+
$(MAKE) test_wasm_par_mq_chrome
1438+
1439+
test_wasm_par_mq_firefox: browser_path = "$(WEB_RUNNER_DIR)/firefox/firefox/firefox"
1440+
test_wasm_par_mq_firefox: driver_path = "$(WEB_RUNNER_DIR)/firefox/geckodriver"
1441+
test_wasm_par_mq_firefox: browser_kind = firefox
1442+
1443+
.PHONY: test_wasm_par_mq_firefox # Run wasm-par-mq tests on Firefox
1444+
test_wasm_par_mq_firefox: run_wasm_par_mq_tests
1445+
1446+
.PHONY: test_wasm_par_mq_firefox_ci # Run wasm-par-mq tests on Firefox in CI
1447+
test_wasm_par_mq_firefox_ci: setup_venv
1448+
source ~/.nvm/nvm.sh && \
1449+
nvm install $(NODE_VERSION) && \
1450+
nvm use $(NODE_VERSION) && \
1451+
$(MAKE) test_wasm_par_mq_firefox
1452+
14001453
.PHONY: no_tfhe_typo # Check we did not invert the h and f in tfhe
14011454
no_tfhe_typo:
14021455
@./scripts/no_tfhe_typo.sh
@@ -2045,6 +2098,7 @@ pcc_batch_2:
20452098
$(call run_recipe_with_details,check_fmt_js) # This needs to stay there, CI pipeline rely on this recipe to conditionally install Node
20462099
$(call run_recipe_with_details,clippy_test_vectors)
20472100
$(call run_recipe_with_details,check_test_vectors)
2101+
$(call run_recipe_with_details,clippy_wasm_par_mq)
20482102

20492103
.PHONY: pcc_batch_3 # duration: 6'50''
20502104
pcc_batch_3:

backends/tfhe-hpu-backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tracing = "0.1.40"
3131
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
3232
serde = { version = "1", features = ["derive"] }
3333
toml = { version = "0.8", features = [] }
34-
paste = "1.0.15"
34+
paste = { workspace = true }
3535
thiserror = "1.0.61"
3636
bytemuck = { workspace = true }
3737
anyhow = "1.0.82"

tasks/src/check_tfhe_docs_are_tested.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ use std::io::{Error, ErrorKind};
55
// TODO use .gitignore or git to resolve ignored files
66
const DIR_TO_IGNORE: [&str; 3] = [".git", "target", "apps/test-vectors"];
77

8-
const FILES_TO_IGNORE: [&str; 10] = [
8+
const FILES_TO_IGNORE: [&str; 11] = [
99
// This contains fragments of code that are unrelated to TFHE-rs
1010
"tfhe/docs/tutorials/sha256-bool.md",
1111
// TODO: This contains code that could be executed as a trivium docstring
1212
"apps/trivium/README.md",
1313
// TODO: should we test this ?
1414
"utils/tfhe-versionable/README.md",
15+
"utils/wasm-par-mq/README.md",
1516
// TODO: find a way to test the tfhe-fft readme
1617
"tfhe-fft/README.md",
1718
// TODO: find a way to test the tfhe-ntt readme

tfhe-benchmark/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dyn-stack = { workspace = true, features = ["default"] }
2424
itertools = "0.14"
2525
serde = { version = "1.0", default-features = false }
2626
serde_json = "1.0.94"
27-
paste = "1.0.7"
27+
paste = { workspace = true }
2828
rand = { workspace = true }
2929
rayon = { workspace = true }
3030
tfhe = { path = "../tfhe", default-features = false }

tfhe-fft/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pulp = { workspace = true }
1818
serde = { workspace = true, optional = true }
1919

2020
[target.'cfg(target_arch = "wasm32")'.dependencies]
21-
js-sys = "0.3"
21+
js-sys = { workspace = true }
2222

2323
[features]
2424
default = ["std", "avx512"]

tfhe-zk-pok/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ rust-version.workspace = true
1414

1515
[dependencies]
1616
ark-bls12-381 = "0.5.0"
17-
ark-ec = { version = "0.5.0", features = ["parallel"] }
18-
ark-ff = { version = "0.5.0", features = ["parallel"] }
17+
ark-ec = { workspace = true, features = ["parallel"] }
18+
ark-ff = { workspace = true, features = ["parallel"] }
1919
ark-poly = { version = "0.5.0", features = ["parallel"] }
2020
rand = { workspace = true }
2121
rayon = { workspace = true }

tfhe/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pulp = { workspace = true, features = ["default"] }
6969
tfhe-cuda-backend = { version = "0.13.0", path = "../backends/tfhe-cuda-backend", optional = true }
7070
aligned-vec = { workspace = true, features = ["default", "serde"] }
7171
dyn-stack = { workspace = true, features = ["default"] }
72-
paste = "1.0.7"
72+
paste = { workspace = true }
7373
fs2 = { version = "0.4.3", optional = true }
7474
# Used for OPRF in shortint and rerand
7575
sha3 = { version = "0.10", optional = true }
@@ -86,9 +86,9 @@ wasm-bindgen = { workspace = true, features = [
8686
"serde-serialize",
8787
], optional = true }
8888
wasm-bindgen-rayon = { version = "1.3.0", optional = true }
89-
js-sys = { version = "0.3", optional = true }
89+
js-sys = { workspace = true, optional = true }
9090
console_error_panic_hook = { version = "0.1.7", optional = true }
91-
serde-wasm-bindgen = { version = "0.6.0", optional = true }
91+
serde-wasm-bindgen = { workspace = true, optional = true }
9292
getrandom = { workspace = true, optional = true }
9393
bytemuck = { workspace = true }
9494

0 commit comments

Comments
 (0)