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

Using multiple block mode did not result in a speed increase.

Open kmati-dev opened this issue 2 years ago • 5 comments

Environment CPU architecture X86_64 (EC2 G5.12xlarge) CPU/Host memory size 192GB, 8GB Swap GPU properties GPU name A10Gx4 GPU memory size 24GBx4

Libraries TensorRT-LLM branch or tag main TensorRT-LLM commit 6cc5e177ff2fb60b1aab3b03fa0534b5181cf0f1 Container used

I use this script 
git submodule update --init --recursive && git lfs install && git lfs pull && make -C docker release_build CUDA_ARCHS="86-real" && make -C docker release_run

NVIDIA driver version 535.104.12 OS Ubuntu 20.04 (IAM ami-095ff65813edaa529)

Reproduction Steps

  1. Load Llama2-13b Model
huggingface-cli login --token <Token> && huggingface-cli download meta-llama/Llama-2-13b-chat-hf 
  1. Build TRT engine
python build.py --model_dir /root/.cache/huggingface/hub/models--meta-llama--Llama-2-13b-chat-hf/snapshots/c2f3ec81aac798ae26dcc57799a994dfbf521496 \
                --dtype float16 \
                --remove_input_padding \
                --use_gpt_attention_plugin float16 \
                --enable_context_fmha \
                --use_gemm_plugin float16 \
                --max_batch_size 64 \
                --max_input_len 4096 \
                --max_output_len 4096 \
                --world_size 4 \
                --tp_size 4 \
                --use_weight_only \
                --weight_only_precision int4 \
                --parallel_build \
                --multi_block_mode \
                --output_dir ./trt_engines_temp/
  1. Run benchmark
mpirun --allow-run-as-root -n 4 python benchmark.py \
    --mode plugin \
    -m llama_13b \
    --engine_dir "/code/tensorrt_llm/examples/llama/trt_engines_temp/" \
    --max_batch_size 64 \
    --batch_size "1;8;16;32;64" \
    --duration 2 \
    --num_runs 1 \
    --csv \
    --max_output_len 4096 \
    --max_input_len 4096 \
    --input_output_len "1024,128;1024,256;1024,512;1024,1024;1024,2048;1024,4096;2048,128;2048,256;2048,512;2048,1024;2048,2048;2048,4096;4096,128;4096,256;4096,512;4096,1024;4096,2048;4096,4096"

Expected Behavior

--multi_block_mode should decoding faster than unused.

Actual Behavior

--multi_block_mode. Give performance same speed with unused.

Additional Notes

Token per sec.

Batch size Input_size Output_size Normal + Multi block mode
1 1024 1024 129.27 133.129
16 1024 1024 660.77 656.1
1 2048 2048 115.02 122.02
1 4096 4096 95.51 104.36

kmati-dev avatar Jan 04 '24 05:01 kmati-dev

Thanks for reporting this. I will see if I can reproduce, and find what it is going on.

PerkzZheng avatar Jan 04 '24 13:01 PerkzZheng

@matichon-vultureprime In the cases you have listed, generation-phase multi-head-attention (MMHA) only takes a small proportion of the e2e time. Take bs = 1, input length = 1024, output length = 1024 as an example, MMHA only takes about 20% e2e time. Weight-only kernels and all reduce kernels are the main bottlenecks.

Multi-block-mode disabled image

Multi-block-mode enabled image

PerkzZheng avatar Jan 09 '24 09:01 PerkzZheng

@PerkzZheng Thank you for investigating.

Does that mean Multi-block mode could perform better in FP16 than the quantized model? Right?

Another question: Are you using NVIDIA Nsight?

kmati-dev avatar Jan 09 '24 09:01 kmati-dev

Does that mean Multi-block mode could perform better in FP16 than the quantized model? Right?

The attention part will remain the same (always in FP16) for either weight only or FP16, so it is just that the relative proportion of the attention kernels have been changed.

Another question: Are you using NVIDIA Nsight?

yes, it is the nsight system.

PerkzZheng avatar Jan 09 '24 09:01 PerkzZheng

Done.

kmati-dev avatar Jan 09 '24 09:01 kmati-dev