Skip to content
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

Collapse Service #62

Merged
merged 22 commits into from
Mar 23, 2021
Merged

Collapse Service #62

merged 22 commits into from
Mar 23, 2021

Conversation

jerinphilip
Copy link
Contributor

@jerinphilip jerinphilip commented Mar 22, 2021

For #61.

  • Collapses Service to a single class, we have ifdefs back.
  • Service has a constructor which directly takes in a string config and calls second constructor after parsing string into options. This is now connected to TranslationModel to ensure tests cover this all constructors.
  • WASM builds are succeeding.
  • Doxygen compatible documentation/comments on Service.
  • Passes bergamot-translator-tests
  • There are untested code-paths (NOT WITH_PTHREADS and not wasm) not covered currently by bergamot-regression-tests.

@jerinphilip jerinphilip added the high-priority Needs to be done at the earliest label Mar 22, 2021
Jerin Philip added 2 commits March 22, 2021 18:50
To reduce tax for bytebuffer loads, initialize batchtranslator only at
one place.
src/translator/CMakeLists.txt Outdated Show resolved Hide resolved
src/translator/CMakeLists.txt Outdated Show resolved Hide resolved
src/translator/service.h Outdated Show resolved Hide resolved
src/translator/service.h Show resolved Hide resolved
src/translator/service.h Outdated Show resolved Hide resolved
src/translator/service.h Outdated Show resolved Hide resolved
src/translator/service.cpp Show resolved Hide resolved
@jerinphilip
Copy link
Contributor Author

jerinphilip commented Mar 23, 2021

WASM builds are now succeeding (once again, after breaking with WASM_HIDE_THREADS).

Bergamot translator regression-tests:

Simple tests: bergamot-translator-app (single thread), service-cli (multi-thread) - PASS

jphilip@var:~/code/bergamot-translator-test-scripts$ MARIAN=/mnt/Storage/jphilip/bergamot-build/ ./run_brt.sh
[03/23/2021 01:07:35] Running on var as process 64934
[03/23/2021 01:07:35] Using Marian binary: /mnt/Storage/jphilip/bergamot-build/marian
[03/23/2021 01:07:35] Version: v1.9.56 370fdb5a 2021-03-10 17:12:37 +0000
[03/23/2021 01:07:35] Build type: Release
[03/23/2021 01:07:35] Using compiler: /usr/bin/c++
[03/23/2021 01:07:35] Using MKL: COMPILE_CPU=on
[03/23/2021 01:07:35] Using CUDNN:
[03/23/2021 01:07:35] Using SentencePiece: USE_SENTENCEPIECE=ON
[03/23/2021 01:07:35] Using FBGEMM:
[03/23/2021 01:07:35] Unit tests:
[03/23/2021 01:07:35] Using CUDA visible devices:
[03/23/2021 01:07:35] Using number of GPU devices: 1
[03/23/2021 01:07:35] Using time out: 5m
[03/23/2021 01:07:35] Checking directory: tests
[03/23/2021 01:07:35] Checking directory: tests/basic
[03/23/2021 01:07:35] Running tests/basic/test_bergamot_translator_app_intgemm_8bit.cpu-threads.0.sh ... OK
[03/23/2021 01:07:37] Test took 00:00:1.571s
[03/23/2021 01:07:37] Running tests/basic/test_service-cli_intgemm_8bit.cpu-threads.4.sh ... OK
[03/23/2021 01:07:40] Test took 00:00:2.875s
---------------------
Ran 2 tests in 00:00:4.539s, 2 passed, 0 skipped, 0 failed

Speed test: 48 threads, 1M lines - PASS, no segfaults.

jphilip@var:~/code/bergamot-translator-test-scripts$ MARIAN=/mnt/Storage/jphilip/bergamot-build/ TIMEOUT=45m BRT_THREADS=48 BRT_EXPECTED_MAXTIME=500 ./run_brt.sh speed-tests/test_wngt20_perf.sh

[03/23/2021 01:07:43] Running on var as process 65087
[03/23/2021 01:07:43] Using Marian binary: /mnt/Storage/jphilip/bergamot-build/marian
[03/23/2021 01:07:43] Version: v1.9.56 370fdb5a 2021-03-10 17:12:37 +0000
[03/23/2021 01:07:43] Build type: Release
[03/23/2021 01:07:43] Using compiler: /usr/bin/c++
[03/23/2021 01:07:43] Using MKL: COMPILE_CPU=on
[03/23/2021 01:07:43] Using CUDNN:
[03/23/2021 01:07:43] Using SentencePiece: USE_SENTENCEPIECE=ON
[03/23/2021 01:07:43] Using FBGEMM:
[03/23/2021 01:07:43] Unit tests:
[03/23/2021 01:07:43] Using CUDA visible devices:
[03/23/2021 01:07:43] Using number of GPU devices: 1
[03/23/2021 01:07:43] Using time out: 45m
[03/23/2021 01:07:43] Checking directory: speed-tests
[03/23/2021 01:07:44] Running speed-tests/test_wngt20_perf.sh ... OK
[03/23/2021 01:16:48] Test took 00:09:4.806s
---------------------
Ran 1 tests in 00:09:4.857s, 1 passed, 0 skipped, 0 failed

CMakeLists.txt Outdated Show resolved Hide resolved
@XapaJIaMnu
Copy link
Collaborator

Can we also put the batch_translator inside the service? Nobody uses the batch translator by itself, as far as I can tell.

@jerinphilip
Copy link
Contributor Author

jerinphilip commented Mar 23, 2021

I'm currently not in favour of this, as Service will move towards becoming a god class. With concurrency coming in, I'd have more and more functions packed. I want Service to handle the building and interactions (async or blocking) between constituent components (text-processsing, batching, translating, building-response).

Kenneth told me this can be functions instead, I haven't strictly understood how that happens either. My idea is store the graph and translation-related components (data), and translate a batch feature (function) there ensuring it's the unit which handles 'translation' and translation only. It's a functor in essence, which handles translation of a "Batch".

Maybe I am missing something, can you elaborate on how I can cleanly add it in Service without making Service something of a God class?

kpu
kpu previously approved these changes Mar 23, 2021
@jerinphilip
Copy link
Contributor Author

Regression tests with latest source, both seem passing.

jphilip@var:~/code/bergamot-translator-test-scripts$ MARIAN=/mnt/Storage/jphilip/bergamot-build/ ./run_brt.sh
[03/23/2021 13:03:51] Running on var as process 70614
[03/23/2021 13:03:51] Using Marian binary: /mnt/Storage/jphilip/bergamot-build/marian
[03/23/2021 13:03:51] Version: v1.9.56 370fdb5a 2021-03-10 17:12:37 +0000
[03/23/2021 13:03:51] Build type: Release
[03/23/2021 13:03:51] Using compiler: /usr/bin/c++
[03/23/2021 13:03:51] Using MKL: COMPILE_CPU=on
[03/23/2021 13:03:51] Using CUDNN:
[03/23/2021 13:03:51] Using SentencePiece: USE_SENTENCEPIECE=ON
[03/23/2021 13:03:51] Using FBGEMM:
[03/23/2021 13:03:51] Unit tests:
[03/23/2021 13:03:51] Using CUDA visible devices:
[03/23/2021 13:03:51] Using number of GPU devices: 1
[03/23/2021 13:03:51] Using time out: 5m
[03/23/2021 13:03:51] Checking directory: tests
[03/23/2021 13:03:51] Checking directory: tests/basic
[03/23/2021 13:03:52] Running tests/basic/test_bergamot_translator_app_intgemm_8bit.cpu-threads.0.sh ... OK
[03/23/2021 13:03:53] Test took 00:00:1.546s
[03/23/2021 13:03:53] Running tests/basic/test_service-cli_intgemm_8bit.cpu-threads.4.sh ... OK
[03/23/2021 13:03:56] Test took 00:00:3.029s
---------------------
Ran 2 tests in 00:00:4.667s, 2 passed, 0 skipped, 0 failed
jphilip@var:~/code/bergamot-translator-test-scripts$ MARIAN=/mnt/Storage/jphilip/bergamot-build/ TIMEOUT=45m BRT_THREADS=48 BRT_EXPECTED_MAXTIME=500 ./run_brt.sh speed-tests/test_wngt20_perf.sh

[03/23/2021 13:04:09] Running on var as process 70784
[03/23/2021 13:04:09] Using Marian binary: /mnt/Storage/jphilip/bergamot-build/marian
[03/23/2021 13:04:09] Version: v1.9.56 370fdb5a 2021-03-10 17:12:37 +0000
[03/23/2021 13:04:09] Build type: Release
[03/23/2021 13:04:09] Using compiler: /usr/bin/c++
[03/23/2021 13:04:09] Using MKL: COMPILE_CPU=on
[03/23/2021 13:04:09] Using CUDNN:
[03/23/2021 13:04:09] Using SentencePiece: USE_SENTENCEPIECE=ON
[03/23/2021 13:04:09] Using FBGEMM:
[03/23/2021 13:04:09] Unit tests:
[03/23/2021 13:04:09] Using CUDA visible devices:
[03/23/2021 13:04:09] Using number of GPU devices: 1
[03/23/2021 13:04:09] Using time out: 45m
[03/23/2021 13:04:09] Checking directory: speed-tests
[03/23/2021 13:04:09] Running speed-tests/test_wngt20_perf.sh ... OK
[03/23/2021 13:13:13] Test took 00:09:3.967s
---------------------
Ran 1 tests in 00:09:4.018s, 1 passed, 0 skipped, 0 failed

Copy link
Contributor

@abhi-agg abhi-agg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerinphilip The code looks fine to me. I left a comment regarding the usage of __EMSCRIPTEN__ pre-prcoessor 👍

Copy link
Member

@kpu kpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the only change is to the macro...

@jerinphilip
Copy link
Contributor Author

jerinphilip commented Mar 23, 2021

I thank the creators of grep -R, cut, sort, uniq, xargs and sed -i. Can I get the final approval, now that builds are passing? Here are regression-tests passing for some cherry-on-top:

Regression tests: Pass

jphilip@var:~/code/bergamot-translator-test-scripts$ MARIAN=/mnt/Storage/jphilip/bergamot-build/ ./run_brt.sh
[03/23/2021 15:05:22] Running on var as process 74335
[03/23/2021 15:05:22] Using Marian binary: /mnt/Storage/jphilip/bergamot-build/marian
[03/23/2021 15:05:22] Version: v1.9.56 370fdb5a 2021-03-10 17:12:37 +0000
[03/23/2021 15:05:22] Build type: Release
[03/23/2021 15:05:22] Using compiler: /usr/bin/c++
[03/23/2021 15:05:22] Using MKL: COMPILE_CPU=on
[03/23/2021 15:05:22] Using CUDNN:
[03/23/2021 15:05:22] Using SentencePiece: USE_SENTENCEPIECE=ON
[03/23/2021 15:05:22] Using FBGEMM:
[03/23/2021 15:05:22] Unit tests:
[03/23/2021 15:05:22] Using CUDA visible devices:
[03/23/2021 15:05:22] Using number of GPU devices: 1
[03/23/2021 15:05:22] Using time out: 5m
[03/23/2021 15:05:22] Checking directory: tests
[03/23/2021 15:05:22] Checking directory: tests/basic
[03/23/2021 15:05:22] Running tests/basic/test_bergamot_translator_app_intgemm_8bit.cpu-threads.0.sh ... OK
[03/23/2021 15:05:23] Test took 00:00:1.514s
[03/23/2021 15:05:23] Running tests/basic/test_service-cli_intgemm_8bit.cpu-threads.4.sh ... OK
[03/23/2021 15:05:26] Test took 00:00:2.823s
---------------------
Ran 2 tests in 00:00:4.431s, 2 passed, 0 skipped, 0 failed
jphilip@var:~/code/bergamot-translator-test-scripts$ MARIAN=/mnt/Storage/jphilip/bergamot-build/ TIMEOUT=45m BRT_THREADS=48 BRT_EXPECTED_MAXTIME=500 ./run_brt.sh speed-tests/test_wngt20_perf.sh

[03/23/2021 15:05:28] Running on var as process 74488
[03/23/2021 15:05:28] Using Marian binary: /mnt/Storage/jphilip/bergamot-build/marian
[03/23/2021 15:05:28] Version: v1.9.56 370fdb5a 2021-03-10 17:12:37 +0000
[03/23/2021 15:05:28] Build type: Release
[03/23/2021 15:05:28] Using compiler: /usr/bin/c++
[03/23/2021 15:05:28] Using MKL: COMPILE_CPU=on
[03/23/2021 15:05:28] Using CUDNN:
[03/23/2021 15:05:28] Using SentencePiece: USE_SENTENCEPIECE=ON
[03/23/2021 15:05:28] Using FBGEMM:
[03/23/2021 15:05:28] Unit tests:
[03/23/2021 15:05:28] Using CUDA visible devices:
[03/23/2021 15:05:28] Using number of GPU devices: 1
[03/23/2021 15:05:28] Using time out: 45m
[03/23/2021 15:05:28] Checking directory: speed-tests
[03/23/2021 15:05:28] Running speed-tests/test_wngt20_perf.sh ... OK
[03/23/2021 15:14:15] Test took 00:08:47.155s
---------------------
Ran 1 tests in 00:08:47.206s, 1 passed, 0 skipped, 0 failed

@jerinphilip jerinphilip linked an issue Mar 23, 2021 that may be closed by this pull request
@abhi-agg abhi-agg self-requested a review March 23, 2021 16:32
@kpu kpu merged commit 34228d3 into main Mar 23, 2021
@kpu kpu deleted the collapse-service branch March 23, 2021 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high-priority Needs to be done at the earliest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collapse Service to one class
4 participants