browsermt / bergamot-translator

Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
http://browser.mt
Mozilla Public License 2.0
341 stars 38 forks source link

Documentation on how to activate optimized intgemm #360

Closed jerinphilip closed 2 years ago

jerinphilip commented 2 years ago

I'm working with 9eb2437. I am using Firefox Nightly (2022-02-19; 99.0a1) on Windows 11.

$ git log --oneline | head -n1
9eb2437 Bump version to 0.4.1 (#356)

Using the build-wasm.sh script, which appears to be reporting success patching the "import-intgemm" module thing:

$ bash build-wasm.sh
...
Consolidate compiler generated dependencies of target bergamot-translator-worker
[100%] Built target bergamot-translator-worker
+ '[' false = true ']'
+ bash ../wasm/patch-artifacts-import-gemm-module.sh
Importing integer (8-bit) gemm implementation
SUCCESS
+ exit 0

Now I navigate according to instructions to use the built artefacts:

$ cd wasm/test_page/
$  bash start_server.sh ../../build-wasm/
Copied "../../build-wasm//bergamot-translator-worker.js" to "/home/jerin/code/bergamot-translator/wasm/test_page/js"
Copied "../../build-wasm//bergamot-translator-worker.wasm" to "/home/jerin/code/bergamot-translator/wasm/test_page/js"
npm WARN test_page No description
npm WARN test_page No repository field.
npm WARN test_page No license field.

audited 53 packages in 0.678s
found 0 vulnerabilities

Start httpserver
HTTP and BinaryJS server started on port 9080

See screenshot:

image

Checked about:config for gemm and found the following:

image

Perhaps this is a nightly bug, in any case filing this here as documentation is missing and to be forwarded to the correct place.

cc: @abhi-agg

abhi-agg commented 2 years ago

@jerinphilip This is not a bug but the expected behavior. Because of the security reasons, currently the optimized gemm is only available to the privileged extensions and not to the normal web-pages (like the wasm test page).

Plus, you don't need to do anything to enable optimized gemm. It is on by default.

You can run the latest extension in the same nightly and can observe that optimized gemm is being used there 👍🏾

abhi-agg commented 2 years ago

Closing this one as there is no need for any documentation. Optimized gemm is always on and it runs if it is available in the environment, otherwise fallback gemm runs. All of this is for privileged extensions in Firefox.

jerinphilip commented 2 years ago

Closing this one as there is no need for any documentation. Optimized gemm is always on and it runs if it is available in the environment, otherwise fallback gemm runs. All of this is for privileged extensions in Firefox.

@abhi-agg Perhaps you don't realize this, right now I'm tracking Bugzilla and GitHub issues for what should ideally be documentation. There is only @kpu who knows the complexities of GEMM Mozilla connects, I know partially because of undertaking MozIntGemm (ARM). I'm fairly certain others (at least at Edinburgh) have very little clue on what exactly is going on at this stage. It is expected that you check-in documentation for future users of the optimized gemm, and what the future of features like WORMHOLE, native intrinsic based gemm etc. are.