Skip to content

Commit

Permalink
Remove wormhole references (#459)
Browse files Browse the repository at this point in the history
* Remove warmhole references

* Remove more references to the WORMHOLE

* Update marian to wormhole removed marian

* Whoops

---------

Co-authored-by: Jelmer van der Linde <[email protected]>
  • Loading branch information
XapaJIaMnu and jelmervdl authored Aug 14, 2023
1 parent ca95467 commit 534ed37
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 159 deletions.
69 changes: 8 additions & 61 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,6 @@
version: 2.1
jobs:
build-with-wormhole:
docker:
- image: 'emscripten/emsdk:3.1.8'
resource_class: medium

working_directory: ~/checkout

steps:
- checkout

- run:
name: Build WASM WORMHOLE
command: |
bash build-wasm.sh WORMHOLE
- run:
name: Check artifacts
working_directory: build-wasm
command: |
ARTIFACT_BASE="bergamot-translator-worker"
ARTIFACT_SUFFIX="with-wormhole"
ARTIFACT_FINAL=$ARTIFACT_BASE-$ARTIFACT_SUFFIX
if [[ -f "$ARTIFACT_BASE.js" && -f "$ARTIFACT_BASE.wasm" ]]; then
echo "Artifacts Successfully Generated"
mkdir ../artifacts
cp $ARTIFACT_BASE.wasm ../artifacts/$ARTIFACT_FINAL.wasm
cp $ARTIFACT_BASE.js ../artifacts/$ARTIFACT_FINAL.js
cd ../artifacts
shasum -a 256 $ARTIFACT_FINAL.wasm $ARTIFACT_FINAL.js >> sha256-filesize-$ARTIFACT_SUFFIX
ls -lsa $ARTIFACT_FINAL.wasm $ARTIFACT_FINAL.js >> sha256-filesize-$ARTIFACT_SUFFIX
cp ../BERGAMOT_VERSION .
else
echo "Failure: Artifacts Not Present"
exit 1
fi
- persist_to_workspace:
root: .
paths:
- artifacts/*

- store_artifacts:
path: "artifacts"
destination: "wasm-wormhole"

build-without-wormhole:
build:
docker:
- image: 'emscripten/emsdk:3.1.8'
resource_class: medium
Expand All @@ -66,17 +20,16 @@ jobs:
working_directory: build-wasm
command: |
ARTIFACT_BASE="bergamot-translator-worker"
ARTIFACT_SUFFIX="without-wormhole"
ARTIFACT_FINAL=$ARTIFACT_BASE-$ARTIFACT_SUFFIX
ARTIFACT_FINAL=$ARTIFACT_BASE
if [[ -f "$ARTIFACT_BASE.js" && -f "$ARTIFACT_BASE.wasm" ]]; then
echo "Artifacts Successfully Generated"
mkdir ../artifacts
cp $ARTIFACT_BASE.wasm ../artifacts/$ARTIFACT_FINAL.wasm
cp $ARTIFACT_BASE.js ../artifacts/$ARTIFACT_FINAL.js
cd ../artifacts
shasum -a 256 $ARTIFACT_FINAL.wasm $ARTIFACT_FINAL.js >> sha256-filesize-$ARTIFACT_SUFFIX
ls -lsa $ARTIFACT_FINAL.wasm $ARTIFACT_FINAL.js >> sha256-filesize-$ARTIFACT_SUFFIX
shasum -a 256 $ARTIFACT_FINAL.wasm $ARTIFACT_FINAL.js >> sha256-filesize
ls -lsa $ARTIFACT_FINAL.wasm $ARTIFACT_FINAL.js >> sha256-filesize
else
echo "Failure: Artifacts Not Present"
exit 1
Expand All @@ -89,7 +42,7 @@ jobs:

- store_artifacts:
path: "artifacts"
destination: "wasm-without-wormhole"
destination: "wasm"

publish_to_github:
docker:
Expand All @@ -106,18 +59,13 @@ jobs:
name: "Publish Release on GitHub"
command: |
export TAG_VERSION=$(cat ./artifacts/BERGAMOT_VERSION)
cat ./artifacts/sha256-filesize-without-wormhole ./artifacts/sha256-filesize-with-wormhole >> ./artifacts/sha256-filesize
rm ./artifacts/sha256-filesize-without-wormhole ./artifacts/sha256-filesize-with-wormhole ./artifacts/BERGAMOT_VERSION
rm ./artifacts/BERGAMOT_VERSION
ghr -t ${GHTOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${TAG_VERSION} ./artifacts/
workflows:
build:
jobs:
- build-with-wormhole:
filters:
tags:
only: /^v.*/
- build-without-wormhole:
- build:
filters:
tags:
only: /^v.*/
Expand All @@ -128,7 +76,6 @@ workflows:
branches:
ignore: /.*/
requires:
- build-without-wormhole
- build-with-wormhole
- build


3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ jobs:
run: |
mkdir -p build-wasm
cd build-wasm
emcmake cmake -DCOMPILE_WASM=on -DWORMHOLE=off ..
emcmake cmake -DCOMPILE_WASM=on ..
- name: "Compile"
Expand Down Expand Up @@ -276,7 +276,6 @@ jobs:
name: wasm-artefacts
if-no-files-found: error
path: |
# Without wormhole
${{github.workspace}}/build-wasm/bergamot-translator-worker.js
${{github.workspace}}/build-wasm/bergamot-translator-worker.wasm
${{github.workspace}}/build-wasm/bergamot-translator-worker.js.bak
Expand Down
2 changes: 1 addition & 1 deletion 3rd_party/marian-dev
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ message(STATUS "Project version: ${PROJECT_VERSION_STRING_FULL}")

if(COMPILE_WASM)
# See https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
set(WORMHOLE ON CACHE BOOL "Use WASM wormhole in intgemm https://bugzilla.mozilla.org/show_bug.cgi?id=1672160")
list(APPEND WASM_COMPILE_FLAGS
-O3
# Preserve whitespaces in JS even for release builds; this doesn't increase wasm binary size
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ To build a version that translates with higher speeds on Firefox Nightly browser

The wasm artifacts (.js and .wasm files) will be available in the build directory ("build-wasm" in this case).

2. Enable SIMD Wormhole via Wasm instantiation API in generated artifacts
```bash
bash ../wasm/patch-artifacts-enable-wormhole.sh
```

3. Patch generated artifacts to import GEMM library from a separate wasm module
2. Patch generated artifacts to import GEMM library from a separate wasm module
```bash
bash ../wasm/patch-artifacts-import-gemm-module.sh
```
Expand All @@ -57,7 +52,7 @@ To build a version that runs on all browsers (including Firefox Nightly) but tra
```bash
mkdir build-wasm
cd build-wasm
emcmake cmake -DCOMPILE_WASM=on -DWORMHOLE=off ../
emcmake cmake -DCOMPILE_WASM=on ../
emmake make -j2
```

Expand Down
41 changes: 2 additions & 39 deletions build-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,6 @@
set -e
set -x

# Usage
Usage="Build translator to wasm (with/without wormhole).
Usage: $(basename "$0") [WORMHOLE]
where:
WORMHOLE An optional string argument
- when specified on command line, builds wasm artifacts with wormhole
- when not specified (the default behaviour), builds wasm artifacts without wormhole."

if [ "$#" -gt 1 ]; then
echo "Illegal number of parameters passed"
echo "$Usage"
exit
fi

WORMHOLE=false

if [ "$#" -eq 1 ]; then
if [ "$1" = "WORMHOLE" ]; then
WORMHOLE=true
else
echo "Illegal parameter passed"
echo "$Usage"
exit
fi
fi

# Run script from the context of the script-containing directory
cd "$(dirname $0)"

Expand Down Expand Up @@ -66,19 +38,10 @@ if [ ! -d ${BUILD_DIRECTORY} ]; then
fi
cd ${BUILD_DIRECTORY}

if [ "$WORMHOLE" = true ]; then
emcmake cmake -DCOMPILE_WASM=on ../
else
emcmake cmake -DCOMPILE_WASM=on -DWORMHOLE=off ../
fi
emcmake cmake -DCOMPILE_WASM=on ../
emmake make -j2

# 2. Enable SIMD Wormhole via Wasm instantiation API in generated artifacts
if [ "$WORMHOLE" = true ]; then
bash ../wasm/patch-artifacts-enable-wormhole.sh
fi

# 3. Import GEMM library from a separate wasm module
# 2. Import GEMM library from a separate wasm module
bash ../wasm/patch-artifacts-import-gemm-module.sh

# The artifacts (.js and .wasm files) will be available in the build directory
Expand Down
14 changes: 2 additions & 12 deletions wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,8 @@ Alternatively refer to the file `test_page/js/worker.js` that demonstrates how t

Provide the folder containing the wasm artifacts as the first argument of `start_server.sh` script (`../../build-wasm` in this case).

* Open any of the browsers below
* Firefox Nightly +87: make sure the following prefs are on (about:config)
```
dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled = true
javascript.options.wasm_simd = true
javascript.options.wasm_simd_wormhole = true
```

* Chrome Canary +90: start with the following argument
```
--js-flags="--experimental-wasm-simd"
```
* Open any browser (tested with latest Chrome/Firefox/Safari)


* Browse to the following page:
```
Expand Down
36 changes: 0 additions & 36 deletions wasm/patch-artifacts-enable-wormhole.sh

This file was deleted.

0 comments on commit 534ed37

Please sign in to comment.