-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port marian to WASM for inference #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before submitting pull requests please make sure that
- all changes are properly documented in CHANGELOG.md
- all regression tests pass
- all files with changes have clutter / commented-out code removed (or contain a convincing explanation why the commented-out code should be kept around
Without at least these three conditions having been met, chances of approval are very slim.
Yes, as this is only usable if we use MKL (which we can't)
…On Tue, Mar 9, 2021 at 6:19 PM abhi-agg ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/tensors/cpu/prod.cpp
<#24 (comment)>:
> + //}
+ /*
@XapaJIaMnu <https://github.com/XapaJIaMnu> Just to be sure, I can remove this
dead code
<https://github.com/browsermt/marian-dev/blob/wasm/src/tensors/cpu/prod.cpp#L203-L280>
as well?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPO5VPPE4JUUJJ53PZTQGTTCZREDANCNFSM4YS7KLFA>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left 2 comments.
Could you please answer all @ugermann's concerns about the disabled exceptions before merging.
Also, all regression tests should pass before a merge into master, and all changes need to be documented in CHANGELOG.md. Otherwise, there's no chance in hell we'll ever get this past the upstream code masters for an upstream merge. |
dab5435
to
5486ba4
Compare
@ugermann @kpu @XapaJIaMnu I have made lot of improvements, answered most of your concerns in the comments and added commits to resolve them. I just need to run regression tests now. It would be great if you can review again. It looks in much better shape now 👍 |
- unistd.h should be included for unix system as well - Otherwise, the compilation fails on WASM
- Disabled code (by compile definition DECODER_ONLY) that is not required for inference and doesn't compile on wasm - Introduced cmake option "COMPILE_DECODER_ONLY" to build only marian decoder
- onnxjs compiles on wasm
- CMAKE modifications -- onnxjs is added as a target to be linked if a wasm compatible sgemm routine is to be used -- It's compilation is protected by cmake option USE_WASM_COMPATIBLE_BLAS (by default off) - source file modifications to call appropriate sgemm routine of onnxjs
- It compiles successfully as wasm target using emscripten toolchain - It contains changes to use wasm wormhole
- wasm compilation can be enabled by cmake option COMPILE_WASM - cmake changes - source changes
…ian-nmt#779) * copy changes from commit 4df92f2 * add comments for better understanding * restore the newline at the end of file and add this changes in changelog.md
- COMPILE_WITH_PTHREADS cmake option to enable/disable compiling the multi-threaded version of marian
- It is deprecated begining C++17
- It avoids building unwanted targets
- Compile only static library required for inference
I have rebased this PR on
I am getting the exact same status for both of them which is following:
1st test is failing because I have CUDA-11 and 2nd test failure is already known. For the sake of completeness, I am sharing the failure logs for the 1st test case 👍 Failure logs for test_unit_tests.sh
TL;DR: This PR doesn't introduce any additional regression test failures to current master. @ugermann @kpu Please review the PR as all the changes that you requested are in. I would like to merge it asap. |
It does not strictly suffice here. Plenty of (CMake) switches in this branch has previously led to failure in linkages (quantizer.cpp for example), from bergamot-translator switches. Someone trying to build shouldn't be able to mess with switches and get a non-working build. Normally Makefiles for separate architectures (Makefile, Makefile.mingw) etc are supposed to be loaded or unloaded as a whole, but this PR makes it goes through a lot many switches making it painful to review. I would personally be scared to branch off browsermt/marian-dev for development if this gets merged in (due to the sheer complexity it induces on the build files which will be tricky to edit after). Your use case is only target WASM architecture (which you're testing and reporting), but the build logic change seems to generalize many other combinations - decoder only, no exceptions, etc etc.
For all complaints of big PR elsewhere with even tinier set of changes, this is quite interesting. |
- Dockerfile cleanup - README cleanup - benchmark script cleanup
- COMPILE_WASM encapsulates all cmake options specific to wasm builds
@jerinphilip The recent commits in this PR addresses your concerns 👍
The changes in this PR has been a result of the wasm exploration that started 5 months ago. I had no option but to create a single PR as the technical debt is too much. Additionally, this PR doesn't add implementation in source files (as happened "elsewhere"). It mostly adds bunch of pre-processor directives (which are easier to review) and some cmake changes. PS: I don't like this PR myself but I have no option here 👍 |
set(BLAS_VENDOR "ONNX-SGEMM") | ||
add_compile_definitions(COMPILE_CPU BLAS_FOUND WASM_COMPATIBLE_BLAS) | ||
else(USE_WASM_COMPATIBLE_BLAS) | ||
set(EXT_LIBS ${EXT_LIBS} intgemm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit could have been outside the if statement
@@ -5,7 +5,9 @@ | |||
#ifndef LIBCNPY_H_ | |||
#define LIBCNPY_H_ | |||
|
|||
#if !defined(WASM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact: now that @XapaJIaMnu has binary working, you can get rid of cnpy entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but for compilation we will still have to keep this ifdef. Right?
@kpu I made the final changes addressing all your concerns. A quick final review and approval will be much appreciated 👍 |
@ugermann Could you please approve the PR as I already addressed all your review comments? |
I'd suggest a squashed merge. |
This PR is also connected to the #5 |
Description
This PR enables capability to build and use marian as a WASM module for doing inference.
It is related to issues: #23
List of changes:
Added dependencies: onnxjs submodule
How to test
To run and test, follow the README
Checklist