Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. # mt-model-deploy-dhruva ## TL;DR This repo contains code for python backend CTranslate2 based triton models for the SSMT project. Prerequisites: `python3.xx-venv`, `nvidia-docker` ```bash git clone https://ssmt.iiit.ac.in/meitygit/ssmt/mt-model-deploy-dhruva.git cd mt-model-deploy-dhruva sh make_triton_model_repo.sh "https://ssmt.iiit.ac.in/uploads/data_mining/models.zip" "float16" docker build -t dhruva/ssmt-model-server:1 . nvidia-docker run --gpus=all --rm --shm-size 5g --network=host --name dhruva-ssmt-triton-server -v./ssmt_triton_repo:/models dhruva/ssmt-model-server:1 ``` ## What this repo does * This repo contains the templates and component triton models for the SSMT project. * Also contained is a Dockerfile to construct the triton server instance. * Given a URL and quantization method (those supported by CTranslate2 i.e. `int8`, `int8_float16`, `int8_bfloat16`, `int16`, `float16` and `bfloat16`) it will download, quantize and construct the SSMT Triton Repository in `./ssmt_triton_repo` (disabled, will be enabled once testing is performed on representative hardware). * Dynamic batching and caching is supported and enabled by default. * The repository folder can me mounted to the dhruva ssmt triton server on `/models` and can be queried via a client. * Sample client code is also given as an ipython notebook. * The `model.zip` package needs to contain a folder of `.pt` and `.src` files named `1` through `9` with each file corresponding to the following mapping: `{'en-hi': 1, 'hi-en': 2, 'te-en': 4, 'hi-te': 6, 'te-hi': 7, 'en-gu': 8, 'gu-en': 9}` ## Architecture of the pipeline The pipeline consists of 4 components, executed in order: * Tokenizer - This model is CPU only and tokenizes and applies BPE on the input string. * Model Demuxer - This model is CPU only and depending on the language pair requested, queues up an `InferenceRequest` for the appropriate model and returns it as the response. * Model - This is a GPU based model and it processes the tokenized text and returns the final form of the translated text to the caller. * Pipeline - This is an ensemble model that wraps the above three components together and is the one meant to be exposed to the client. The exact specifications of the model inputs and outputs can be looked at in the corresponding `config.pbtxt` files. One can construct the triton repo like so: ```bash git clone https://ssmt.iiit.ac.in/meitygit/ssmt/mt-model-deploy-dhruva.git cd mt-model-deploy-dhruva sh make_triton_model_repo.sh "https://ssmt.iiit.ac.in/uploads/data_mining/models.zip" "float16" ``` ## Starting the triton server We customize the tritonserver image with the required python packages in a venv and enable the cache in the startup command. After the model repo has beeen built, one can build and run the server like so: ```bash docker build -t dhruva/ssmt-model-server:1 . nvidia-docker run --gpus=all --rm --shm-size 5g --network=host --name dhruva-ssmt-triton-server -v./ssmt_triton_repo:/models dhruva/ssmt-model-server:1 ``` ## Querying the triton server We provide a sample ipython notebook that shows how to concurrently request the client for translations. Prerequisites: `pip install "tritonclient[all]" tqdm numpy wonderwords`