TensorRT-LLM icon indicating copy to clipboard operation
TensorRT-LLM copied to clipboard

RecurrentGemma doesn't support ModelRunnerCpp?

Open daiwk opened this issue 2 years ago • 6 comments

https://github.com/NVIDIA/TensorRT-LLM/blob/v0.10.0/examples/recurrentgemma/README.md it seems that all demos are using --use_py_session, dose it mean that recurrentgemma dosen't support ModelRunnerCpp? RecurrentGemma doesn't support ModelRunnerCpp?

daiwk avatar Jul 05 '24 17:07 daiwk

ModelRunnerCpp can support RecurrentGemma models. You can run those examples without --use_py_session.

lfr-0531 avatar Jul 08 '24 03:07 lfr-0531

@lfr-0531 when i use ModelRunnerCpp, I found the infer speed is much slower: i tried max_seq_len=512 & max_batch_size=1024

  • use_py_session: avg latency is 9~10s
  • not use_py_session: avg latency is 16s+

so I have the question that maybe recurrentgemma doesn't support cpp so well?

ModelRunnerCpp can support RecurrentGemma models. You can run those examples without --use_py_session.

daiwk avatar Jul 08 '24 07:07 daiwk

I cannot reproduce your results with cmd:

python3 ../summarize.py --test_trt_llm \
                        --use_py_session \
                        --engine_dir ${ENGINE_2B_PATH} \
                        --batch_size 8 \
                        --max_attention_window_size 2048 \
                        --tokenizer_dir ${TOKENIZER_DIR_2B_PATH}

and

python3 ../summarize.py --test_trt_llm \
                        --engine_dir ${ENGINE_2B_PATH} \
                        --batch_size 8 \
                        --max_attention_window_size 2048 \
                        --tokenizer_dir ${TOKENIZER_DIR_2B_PATH}

I got results:

[TRT-LLM] [I] TensorRT-LLM (total latency: 11.526382207870483 sec)

and

[TRT-LLM] [I] TensorRT-LLM (total latency: 10.530988693237305 sec)

respectively.

For more accurate results, you can try to benchmark the model with two different runtimes.

lfr-0531 avatar Jul 08 '24 08:07 lfr-0531

@lfr-0531 I run summarize.py using my finetuned model(recurrentgemma), and got the similar results as yours, which shows cpp is faster than python:

summ.cpp.res:[07/08/2024-19:30:36] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.081711769104004 sec)
summ.py.res:[07/08/2024-19:29:16] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.492124319076538 sec)

The 16s vs 10s' results come from my infer code, partially copied from the run.py, maybe my code has some bugs or misses some args, I'll review the codes later. Many thanks!

daiwk avatar Jul 08 '24 11:07 daiwk

@lfr-0531 when I increase batchsize I got the following results:

batchsize=16:

summ.cpp.res:[07/08/2024-22:01:45] [TRT-LLM] [I] TensorRT-LLM (total latency: 10.173615217208862 sec)
summ.py.res:[07/08/2024-22:00:23] [TRT-LLM] [I] TensorRT-LLM (total latency: 10.66978669166565 sec)

batchsize=32:

summ.cpp.res:[07/08/2024-21:57:13] [TRT-LLM] [I] TensorRT-LLM (total latency: 14.952418565750122 sec)
summ.py.res:[07/08/2024-21:55:46] [TRT-LLM] [I] TensorRT-LLM (total latency: 14.795913219451904 sec)

batchsize=128:

summ.cpp.res:[07/08/2024-21:47:33] [TRT-LLM] [I] TensorRT-LLM (total latency: 46.65815091133118 sec)
summ.py.res:[07/08/2024-21:45:31] [TRT-LLM] [I] TensorRT-LLM (total latency: 41.39437389373779 sec)

batchsize=512:

summ.cpp.res:[07/08/2024-21:36:10] [TRT-LLM] [I] TensorRT-LLM (total latency: 213.09781408309937 sec)
summ.py.res:[07/08/2024-21:31:19] [TRT-LLM] [I] TensorRT-LLM (total latency: 154.4915840625763 sec)

maybe cpp cannot perform well in larger batchsizes?

daiwk avatar Jul 08 '24 13:07 daiwk

This number is not very accurate. To compare the performance between cpp_runtime and python_runtime, you can refer to the cpp benchmark and python benchmark for more accurate performance results. Usually cpp_runtime performs better.

lfr-0531 avatar Jul 12 '24 03:07 lfr-0531