Skip to content

Support InternLM models (deprecated and move to #266) - #123

Closed
wangruohui wants to merge 22 commits into
NVIDIA:release/0.5.0from
wangruohui:internlm
Closed

wangruohui wants to merge 22 commits into
NVIDIA:release/0.5.0from
wangruohui:internlm

Conversation

@wangruohui

Copy link
Copy Markdown
Contributor

This is an on-going work to support InternLM models in TRL-LLM.

As InternLM shares some similarity with llama, codes provided here is mainly based on examples/llama and tensorrt_llm/models/llama, with automatic renaming and specific modification to difference on model structures, chat template etc.

Currently based on my test, simply building / inferencing FP16/BF16 on single GPU works and the output (of FP16 engines) is aligned with HuggingFace version. But tensor/pipeline parallelism and quantization are remained undeveloped and untested.

I have commented out docs of undeveloped part and would unlocking progressively.

@wangruohui
wangruohui marked this pull request as draft October 25, 2023 14:08
@jdemouth-nvidia

Copy link
Copy Markdown
Collaborator

Thanks a lot @wangruohui - is there a way we can help you? Or, should we just wait for your PR to be ready and take it to integrate into our internal repo, then push the changes?

@jdemouth-nvidia jdemouth-nvidia added the feature request New feature or request. This includes new model, dtype, functionality support label Oct 25, 2023
@wangruohui

Copy link
Copy Markdown
Contributor Author

Hello @jdemouth-nvidia , thanks for your help. I can first go through features that already covered in examples and will reach for your help on difficulties.

@jdemouth-nvidia

Copy link
Copy Markdown
Collaborator

Perfect! Thanks a lot!

@wangruohui

Copy link
Copy Markdown
Contributor Author

Hi @jdemouth-nvidia ,

I think I have finished basic parts on both variant of InternLM, namely the 7B and the 20B model, and updated the docs covering this part, including:

  • FP16 & BF16, single GPU, output aligned with HF model, excluding rare mismatch on single words)
  • tensor parallel and pipeline parallel with FP16 or BF16, outputs aligned as above
  • int4/8 weight only, single GPU, both giving reasonable outputs
  • int8 weight only + int8 kv cache, single GPU, both giving reasonable outputs
  • smooth quant, single GPU, both giving reasonable outputs

Something left including:

  • FP8, I don't have hardware supporting it. I may need your help on this.
  • multi-node, it's mentioned in the doc (at the start of llama), but I don't see instructions on this. Is this supported by simply launching MPI on multi-nodes?
  • Strongly typed, as mentioned in the support matrix (of llama), not sure how to configure or test this.
  • Other quantization modes including AWQ & GPTQ. InternLM also provides checkpoints on int4-AWQ but not the compatible format (with quantized weights saved in pytorch format and scales saved separately). It may require some more effort to convert & set the weights to TRT models. Maybe left as future work?

@wangruohui
wangruohui marked this pull request as ready for review October 30, 2023 09:21
@jdemouth-nvidia

Copy link
Copy Markdown
Collaborator

Hi @wangruohui ,

Thanks so much for that amazing contribution! We really appreciate. We will ask an engineer from our team to start the integration into our internal repo and validate that the model works as expected. We will keep you posted and we will publish it as soon as it’s ready (and, of course, credit you for the work). Does that work for you?

Thanks,
Julien

@juney-nvidia

Copy link
Copy Markdown
Collaborator

@wangruohui

As Julien mentioned above, we are happy to integrate your great work into our internal repo and then publish to this github repo. I think we don't need to add full feature support for the InternLM model for now and can firstly integrate the existing implementation as the beginning.

If you think the current MR is ready enough based on your local validation, then we can start the integration work.

Waiting for your feedback.

Thanks
June

@wangruohui

Copy link
Copy Markdown
Contributor Author

Hi @jdemouth-nvidia and @juney-nvidia ,

Sure, you can start to integrate the codes based on your workflow and test them. Features mentioned above works well based on my local test. And if some feature (like FP8) directly works on your test infra without modifying current codes, you can also uncomment corresponding lines in the README.

BTW, I would like to know some detail on the workflow. It sounds that you will not directly work on Github but merge the code in your internal repo and finally publish them back on Github in some future release? If so, will this PR finally appears, e.g. as one squashed commit, in the commit history?

@jdemouth-nvidia

Copy link
Copy Markdown
Collaborator

Our workflow is the following one: We have an internal repo in which we develop TensorRT-LLM. It’s our reference code. When PR are made on our public GitHub, we will integrate the code into our internal repository and push the updated code to the public repo in the future.

It has not been decided yet if your PR will be translated into a single commit squashed with other code changes (from us or from other PRs) or if we will have an explicit commit dedicated to your work in the main branch. I guess the latter would be better for you. Is that right?

We value your work and want to make it clear that you made the contribution. So, we have to find the best way and feedback is welcome.

@wangruohui

Copy link
Copy Markdown
Contributor Author

Hi @jdemouth-nvidia ,

Either git workflow is good for me. Just hoping myself would finally appears in the git commit history as a proof of my work. Thank you!

@jdemouth-nvidia

Copy link
Copy Markdown
Collaborator

I’ll discuss with the rest of the team but we might be able to come up with something to have you appear in the commit history. We’ll get back to you with a proposal.

I want proper credit to go where it is due. It’s very important to us.

@nv-guomingz

nv-guomingz commented Nov 1, 2023 •

Copy link
Copy Markdown
Collaborator

Hi @wangruohui ,

I've verified your PR on H100/A100 w/ per README.md instructions.

  • fp16/bf16/int8 weight only + int8 kv cache works well and the rouge scores are good
  • int8 smooth quant rough score is not good both on H100 and A100. Would u please double check the result?
  • I noticed that internlm is very similar to llama and it seems the only difference is attention part bias from model structrue perspective. And I'm Ok to merge your PR firstly once the int8 sq issue fixed. However, we may make some furthre changes to reduce duplicate implementation(e.g, smoothquant.py and quantized.py are identical to the ones in llama model). Is that ok for you?

Thanks,
Guoming

@wangruohui

wangruohui commented Nov 1, 2023 •

Copy link
Copy Markdown
Contributor Author

Hi @nv-guomingz ,

  • int8 smooth quant rough score is not good both on H100 and A100. Would u please double check the result?

The drop of rouge number seems to be large especially for 7B model in per-tensor mode. I tried different sq parameters and -sq 0.5 gave best results as follow. Is this acceptable?

  • internlm 7b per-tensor --sq 0.5

    [11/01/2023-10:24:41] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.357639789581299 sec)
    [11/01/2023-10:24:41] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rouge1 : 23.437972163566066
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rouge2 : 7.04797569045473
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rougeL : 17.21923001459256
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rougeLsum : 19.39498561794118
    [11/01/2023-10:24:42] [TRT-LLM] [I] Hugging Face (total latency: 30.914791345596313 sec)
    [11/01/2023-10:24:42] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rouge1 : 24.12297379094552
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rouge2 : 9.254277981150196
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rougeL : 18.141824087385494
    [11/01/2023-10:24:42] [TRT-LLM] [I]   rougeLsum : 21.100177758785833
    
  • internlm 7b per-token + per-channel --sq 0.5

    [11/01/2023-10:57:42] [TRT-LLM] [I] TensorRT-LLM (total latency: 9.170615434646606 sec)
    [11/01/2023-10:57:42] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-10:57:42] [TRT-LLM] [I]   rouge1 : 26.069166045899117
    [11/01/2023-10:57:42] [TRT-LLM] [I]   rouge2 : 7.69281720672978
    [11/01/2023-10:57:42] [TRT-LLM] [I]   rougeL : 18.81554759701659
    [11/01/2023-10:57:42] [TRT-LLM] [I]   rougeLsum : 21.152966740494538
    [11/01/2023-10:57:42] [TRT-LLM] [I] Hugging Face (total latency: 31.03088665008545 sec)
    [11/01/2023-10:57:42] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-10:57:43] [TRT-LLM] [I]   rouge1 : 24.12297379094552
    [11/01/2023-10:57:43] [TRT-LLM] [I]   rouge2 : 9.254277981150196
    [11/01/2023-10:57:43] [TRT-LLM] [I]   rougeL : 18.141824087385494
    [11/01/2023-10:57:43] [TRT-LLM] [I]   rougeLsum : 21.100177758785833
    

Rouge number on 20B model with current config seems good (rouge1 > 20) but I am still trying to get some better one, will update here if anything better.

Rouge number on 20B models also gain with sq=0.5, shown as below.

  • per tensor

    [11/01/2023-17:10:51] [TRT-LLM] [I] TensorRT-LLM (total latency: 23.345258951187134 sec)
    [11/01/2023-17:10:51] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rouge1 : 22.48137541596798
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rouge2 : 5.816597235971107
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rougeL : 17.15271187427868
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rougeLsum : 19.714498068762374
    [11/01/2023-17:10:51] [TRT-LLM] [I] Hugging Face (total latency: 76.56903982162476 sec)
    [11/01/2023-17:10:51] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rouge1 : 28.455200178453477
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rouge2 : 11.533357086387888
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rougeL : 22.566214437479825
    [11/01/2023-17:10:51] [TRT-LLM] [I]   rougeLsum : 24.281668135629893
    
  • 20B per token + per channel

    [TRT-LLM] [I] TensorRT-LLM (total latency: 26.287899017333984 sec)
    [11/01/2023-17:30:55] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rouge1 : 28.3509145230808
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rouge2 : 11.335967290176383
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rougeL : 22.362330518009195
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rougeLsum : 24.69876720880287
    [11/01/2023-17:30:55] [TRT-LLM] [I] Hugging Face (total latency: 76.4976921081543 sec)
    [11/01/2023-17:30:55] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rouge1 : 28.455200178453477
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rouge2 : 11.533357086387888
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rougeL : 22.566214437479825
    [11/01/2023-17:30:55] [TRT-LLM] [I]   rougeLsum : 24.281668135629893
    

But as comparison, I also tested llama following its readme. It seems the drop is even larger.

  • llama 7B v1, per tensor sq=0.8

    [11/01/2023-08:23:00] [TRT-LLM] [I] TensorRT-LLM (total latency: 15.577601909637451 sec)
    [11/01/2023-08:23:00] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rouge1 : 5.696334124375894
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rouge2 : 1.0618001622780098
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rougeL : 5.397129364125945
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rougeLsum : 5.589489078314134
    [11/01/2023-08:23:00] [TRT-LLM] [I] Hugging Face (total latency: 56.059937953948975 sec)
    [11/01/2023-08:23:00] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rouge1 : 20.40929594904702
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rouge2 : 5.908990642427753
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rougeL : 15.267334489726137
    [11/01/2023-08:23:00] [TRT-LLM] [I]   rougeLsum : 18.126636611873682
    
  • llama 7B v2, per tensor, sq=0.8

    [11/01/2023-09:00:57] [TRT-LLM] [I] TensorRT-LLM (total latency: 15.812088966369629 sec)
    [11/01/2023-09:00:57] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rouge1 : 11.407755033037914
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rouge2 : 2.6051717653486186
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rougeL : 9.18232616187596
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rougeLsum : 9.920670451368807
    [11/01/2023-09:00:57] [TRT-LLM] [I] Hugging Face (total latency: 57.39634609222412 sec)
    [11/01/2023-09:00:57] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rouge1 : 17.549264977108898
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rouge2 : 3.762233692162413
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rougeL : 12.50595106364614
    [11/01/2023-09:00:57] [TRT-LLM] [I]   rougeLsum : 15.319692950697606
    
  • llama v2 7B chat, per-tensor, sq=0.8

    [11/01/2023-09:22:17] [TRT-LLM] [I] TensorRT-LLM (total latency: 13.549078226089478 sec)
    [11/01/2023-09:22:17] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/01/2023-09:22:17] [TRT-LLM] [I]   rouge1 : 13.344552865080118
    [11/01/2023-09:22:17] [TRT-LLM] [I]   rouge2 : 2.344486651449821
    [11/01/2023-09:22:17] [TRT-LLM] [I]   rougeL : 9.852372374928105
    [11/01/2023-09:22:17] [TRT-LLM] [I]   rougeLsum : 10.71991485426911
    [11/01/2023-09:22:17] [TRT-LLM] [I] Hugging Face (total latency: 48.06499743461609 sec)
    [11/01/2023-09:22:17] [TRT-LLM] [I] HF beam 0 result
    [11/01/2023-09:22:18] [TRT-LLM] [I]   rouge1 : 28.13396254243681
    [11/01/2023-09:22:18] [TRT-LLM] [I]   rouge2 : 8.629722111652855
    [11/01/2023-09:22:18] [TRT-LLM] [I]   rougeL : 20.091969556621848
    [11/01/2023-09:22:18] [TRT-LLM] [I]   rougeLsum : 23.796465528952673
    

@wangruohui

Copy link
Copy Markdown
Contributor Author
  • I noticed that internlm is very similar to llama and it seems the only difference is attention part bias from model structrue perspective.

Yes.

However, we may make some furthre changes to reduce duplicate implementation(e.g, smoothquant.py and quantized.py are identical to the ones in llama model). Is that ok for you?

It's OK for me to accept modifications that improve code quality. But I think smoothquant.py is used when enabling int8 kvcache or smoothquant because functions are imported and used in hf_internlm_convert.py. Should this one be kept here or do you want some refactor to merge common codes?

@nv-guomingz

Copy link
Copy Markdown
Collaborator

thanks @wangruohui for updating.

However, I can't reproduce your results locally.

Below is my results with your latest commit(f2aaeef)

  • internlm 7b per-tensor --sq 0.5 + H100 + cuda 12.2
    [11/02/2023-03:14:46] [TRT-LLM] [I] TensorRT-LLM (total latency: 6.59701943397522 sec)
    [11/02/2023-03:14:46] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/02/2023-03:14:46] [TRT-LLM] [I] rouge1 : 16.104863400623913
    [11/02/2023-03:14:46] [TRT-LLM] [I] rouge2 : 3.3900018308554825
    [11/02/2023-03:14:46] [TRT-LLM] [I] rougeL : 11.620832154801713
    [11/02/2023-03:14:46] [TRT-LLM] [I] rougeLsum : 13.27390554799307
    [11/02/2023-03:14:46] [TRT-LLM] [I] Hugging Face (total latency: 33.64771342277527 sec)
    [11/02/2023-03:14:46] [TRT-LLM] [I] HF beam 0 result
    [11/02/2023-03:14:47] [TRT-LLM] [I] rouge1 : 21.57157950242294
    [11/02/2023-03:14:47] [TRT-LLM] [I] rouge2 : 6.690868099205619
    [11/02/2023-03:14:47] [TRT-LLM] [I] rougeL : 16.741412741379225
    [11/02/2023-03:14:47] [TRT-LLM] [I] rougeLsum : 17.95322378328744

  • internlm 7b per-token + per-channel --sq 0.5 + H100 + cuda 12.2
    [11/02/2023-03:27:26] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.2882208824157715 sec)
    [11/02/2023-03:27:26] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/02/2023-03:27:26] [TRT-LLM] [I] rouge1 : 20.01642893605639
    [11/02/2023-03:27:26] [TRT-LLM] [I] rouge2 : 4.7420653352416755
    [11/02/2023-03:27:26] [TRT-LLM] [I] rougeL : 15.41357330860172
    [11/02/2023-03:27:26] [TRT-LLM] [I] rougeLsum : 16.502921973817937
    [11/02/2023-03:27:26] [TRT-LLM] [I] Hugging Face (total latency: 33.8012261390686 sec)
    [11/02/2023-03:27:26] [TRT-LLM] [I] HF beam 0 result
    [11/02/2023-03:27:26] [TRT-LLM] [I] rouge1 : 21.57157950242294
    [11/02/2023-03:27:26] [TRT-LLM] [I] rouge2 : 6.690868099205619
    [11/02/2023-03:27:26] [TRT-LLM] [I] rougeL : 16.741412741379225
    [11/02/2023-03:27:26] [TRT-LLM] [I] rougeLsum : 17.95322378328744

I'll update intenlm 20b data later.

May I know your env config detalis, like device/cuda version,etc.

For llama accuracy issue, thanks for reporting. We'll have a look later.

@wangruohui

Copy link
Copy Markdown
Contributor Author

I noticed that the Rouge score of your HuggingFace model is also lower than mine.

I use A100 and CUDA 12.2. The software stack is based on docker provided in the doc + pip install -r requirements.txt from internlm example.

The model is from https://huggingface.co/internlm/internlm-chat-7b , with latest commit d4fa2db. Please note the chat in model name. There is another model named internlm-7b without chat, which is not finetuned for better ability. Are you using this one instead?

Other Huggingface related pip modules:

datasets                  2.14.5
sentencepiece             0.1.99
rouge-score               0.1.2
transformer-engine        0.11.0+3f01b4f
transformers              4.31.0

Full list of pip list as attached for reference: pip.txt

Commands to run for per-tensor tensor mode:

python hf_internlm_convert.py -i ./internlm-chat-7b -o ./internlm-chat-7b/smooth_internlm/sq0.5/ -sq 0.5 --tensor-parallelism 1 --storage-type fp16
python build.py --ft_model_dir=./internlm-chat-7b/smooth_internlm/sq0.5/1-gpu/ \
                --use_smooth_quant \
                --output_dir ./internlm-chat-7b/trt_engines/smoothquant/1-gpu
python summarize.py --test_trt_llm --test_hf \
                    --hf_model_location ./internlm-chat-7b \
                    --data_type fp16 \
                    --engine_dir ./internlm-chat-7b/trt_engines/smoothquant/1-gpu

Summaries generated by trt

[11/02/2023-04:54:56] [TRT-LLM] [I] 
 Highlights : ['James Best, who played the sheriff on "The Dukes of Hazzard," died Monday at 88 .\n"Hazzard" ran from 1979 to 1985 and was among the most popular shows on TV .']
[11/02/2023-04:54:56] [TRT-LLM] [I] 
 Summary : [[' James Best, who played Sheriff Rosco P. Coltrane on TV\'s "The Dukes of Hazzard," died Monday after a brief illness. He was 88.<eoa>\n']]

and by hf

[11/02/2023-04:54:59] [TRT-LLM] [I] 
 Highlights : ['James Best, who played the sheriff on "The Dukes of Hazzard," died Monday at 88 .\n"Hazzard" ran from 1979 to 1985 and was among the most popular shows on TV .']
[11/02/2023-04:54:59] [TRT-LLM] [I] 
 Summary : [[' James "Jimmie" Best, best known for his role as Rosco P. Coltrane on "The Dukes of Hazzard," died Monday at 88. Best died in hospice in Hickory, North']]

@nv-guomingz

nv-guomingz commented Nov 2, 2023 •

Copy link
Copy Markdown
Collaborator

Yes, the model I was testing earlier is not internlm-chat-7b but internlm-7b.

After switch to internlm-chat-7b, I remeasured the sq accuracy again and got below data:

- H100/internlm-chat-7b/pet tensor/sq 0.5
[11/02/2023-07:05:18] [TRT-LLM] [I] TensorRT-LLM (total latency: 5.23417329788208 sec)
[11/02/2023-07:05:18] [TRT-LLM] [I] TensorRT-LLM beam 0 result
[11/02/2023-07:05:18] [TRT-LLM] [I] rouge1 : 25.324026663074566
[11/02/2023-07:05:18] [TRT-LLM] [I] rouge2 : 6.581871925251423
[11/02/2023-07:05:18] [TRT-LLM] [I] rougeL : 17.932441592836163
[11/02/2023-07:05:18] [TRT-LLM] [I] rougeLsum : 21.339142206321938
[11/02/2023-07:05:18] [TRT-LLM] [I] Hugging Face (total latency: 25.20965051651001 sec)
[11/02/2023-07:05:18] [TRT-LLM] [I] HF beam 0 result
[11/02/2023-07:05:18] [TRT-LLM] [I] rouge1 : 24.66613208981564
[11/02/2023-07:05:18] [TRT-LLM] [I] rouge2 : 9.467174349276867
[11/02/2023-07:05:18] [TRT-LLM] [I] rougeL : 17.986853180424394
[11/02/2023-07:05:18] [TRT-LLM] [I] rougeLsum : 20.77263021254249
- H100/internlm-chat-7b/pet channel + per token/sq 0.5
[11/02/2023-06:51:05] [TRT-LLM] [I] TensorRT-LLM (total latency: 5.639718532562256 sec)
[11/02/2023-06:51:05] [TRT-LLM] [I] TensorRT-LLM beam 0 result
[11/02/2023-06:51:05] [TRT-LLM] [I] rouge1 : 25.511426856712298
[11/02/2023-06:51:05] [TRT-LLM] [I] rouge2 : 8.204264158262422
[11/02/2023-06:51:05] [TRT-LLM] [I] rougeL : 17.85726827232065
[11/02/2023-06:51:05] [TRT-LLM] [I] rougeLsum : 21.265916230187194
[11/02/2023-06:51:05] [TRT-LLM] [I] Hugging Face (total latency: 25.73670721054077 sec)
[11/02/2023-06:51:05] [TRT-LLM] [I] HF beam 0 result
[11/02/2023-06:51:06] [TRT-LLM] [I] rouge1 : 24.66613208981564
[11/02/2023-06:51:06] [TRT-LLM] [I] rouge2 : 9.467174349276867
[11/02/2023-06:51:06] [TRT-LLM] [I] rougeL : 17.986853180424394
[11/02/2023-06:51:06] [TRT-LLM] [I] rougeLsum : 20.77263021254249
- A100/internlm-chat-7b/pet tensor/sq 0.5
[11/02/2023-08:16:39] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.248831033706665 sec)
[11/02/2023-08:16:39] [TRT-LLM] [I] TensorRT-LLM beam 0 result
[11/02/2023-08:16:39] [TRT-LLM] [I] rouge1 : 18.6196762667783
[11/02/2023-08:16:39] [TRT-LLM] [I] rouge2 : 2.61289454703023
[11/02/2023-08:16:39] [TRT-LLM] [I] rougeL : 12.74279361772207
[11/02/2023-08:16:39] [TRT-LLM] [I] rougeLsum : 14.96588875403037
[11/02/2023-08:16:39] [TRT-LLM] [I] Hugging Face (total latency: 30.972843647003174 sec)
[11/02/2023-08:16:39] [TRT-LLM] [I] HF beam 0 result
[11/02/2023-08:16:39] [TRT-LLM] [I] rouge1 : 24.12297379094552
[11/02/2023-08:16:39] [TRT-LLM] [I] rouge2 : 9.254277981150196
[11/02/2023-08:16:39] [TRT-LLM] [I] rougeL : 18.141824087385494
[11/02/2023-08:16:39] [TRT-LLM] [I] rougeLsum : 21.100177758785833

- A100/internlm-chat-7b/pet channel + per token/sq 0.5
-[11/02/2023-08:29:20] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.375360727310181 sec)
[11/02/2023-08:29:20] [TRT-LLM] [I] TensorRT-LLM beam 0 result
[11/02/2023-08:29:20] [TRT-LLM] [I] rouge1 : 22.78713666503998
[11/02/2023-08:29:20] [TRT-LLM] [I] rouge2 : 7.092303146387568
[11/02/2023-08:29:20] [TRT-LLM] [I] rougeL : 17.05556366506964
[11/02/2023-08:29:20] [TRT-LLM] [I] rougeLsum : 19.4236191592979
[11/02/2023-08:29:20] [TRT-LLM] [I] Hugging Face (total latency: 31.14124298095703 sec)
[11/02/2023-08:29:20] [TRT-LLM] [I] HF beam 0 result
[11/02/2023-08:29:20] [TRT-LLM] [I] rouge1 : 24.12297379094552
[11/02/2023-08:29:20] [TRT-LLM] [I] rouge2 : 9.254277981150196
[11/02/2023-08:29:20] [TRT-LLM] [I] rougeL : 18.141824087385494
[11/02/2023-08:29:20] [TRT-LLM] [I] rougeLsum : 21.100177758785833

It seems that for int8 sq results, I still can't reproduce your results and now we're align on hf scores.

All those above scores are measured with same pip modules

datasets                  2.14.5
sentencepiece             0.1.99
rouge-score               0.1.2
transformer-engine        0.11.0+3f01b4f
transformers              4.31.0

@nv-guomingz

Copy link
Copy Markdown
Collaborator

And I noticed that this PR's target is 0.5.0 branch, could u please refresh this PR and set its target to main branch?
Sorry for we didn't mention it in our doc since we won't update release branch any more.

And let's remeasure the int8 acc after pr updated.
If the scores still have some issues, we can disable the int8 and debug it offline later. Let's merge fp16/bf16 part fisrtly, what do u think about such suggestion?

@wangruohui
wangruohui changed the base branch from release/0.5.0 to main November 2, 2023 11:01
@wangruohui
wangruohui changed the base branch from main to release/0.5.0 November 2, 2023 11:15
@wangruohui

Copy link
Copy Markdown
Contributor Author

Hello @nv-guomingz ,

It seems release-0.5.0 and main diverge somewhere before my commits and directly changing the target of this PR cause lots of conflicts but irrelevant to InternLM.

To make things easier, I create another branch with commits rebased onto main https://github.com/wangruohui/TensorRT-LLM/tree/internlm-main. If tests pass, I can create another PR or just force push to this one.

Moreover I noticed that some .a files (under cpp/tensorrt_llm/batch_manager) are updated in main. Did you previously test my branch with recompiling on the old branch?

@nv-guomingz

nv-guomingz commented Nov 2, 2023 •

Copy link
Copy Markdown
Collaborator

Hello @nv-guomingz ,

It seems release-0.5.0 and main diverge somewhere before my commits and directly changing the target of this PR cause lots of conflicts but irrelevant to InternLM.

To make things easier, I create another branch with commits rebased onto main https://github.com/wangruohui/TensorRT-LLM/tree/internlm-main. If tests pass, I can create another PR or just force push to this one.

Moreover I noticed that some .a files (under cpp/tensorrt_llm/batch_manager) are updated in main. Did you previously test my branch with recompiling on the old branch?

Ok, I'll take a look on new branch.

I did recompile completely when I switch to new hw platform(h100->a100, or vice versa).

@wangruohui

wangruohui commented Nov 2, 2023 •

Copy link
Copy Markdown
Contributor Author

I made some update to compatible with main branch and recompile, the rouge number becomes a little bit different, but at same level. Shown as below. As quantization usually decreases accuracies, I think the result is acceptable.

  • internlm chat 7b, A100, sq 0.5, pertensor
    [11/02/2023-13:28:45] [TRT-LLM] [I] TensorRT-LLM (total latency: 7.235369920730591 sec)
    [11/02/2023-13:28:45] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/02/2023-13:28:45] [TRT-LLM] [I]   rouge1 : 22.45086743713088
    [11/02/2023-13:28:45] [TRT-LLM] [I]   rouge2 : 6.757145253819879
    [11/02/2023-13:28:45] [TRT-LLM] [I]   rougeL : 18.273746911002466
    [11/02/2023-13:28:45] [TRT-LLM] [I]   rougeLsum : 19.29913396145216
    [11/02/2023-13:28:45] [TRT-LLM] [I] Hugging Face (total latency: 30.66166400909424 sec)
    [11/02/2023-13:28:45] [TRT-LLM] [I] HF beam 0 result
    [11/02/2023-13:28:46] [TRT-LLM] [I]   rouge1 : 24.12297379094552
    [11/02/2023-13:28:46] [TRT-LLM] [I]   rouge2 : 9.254277981150196
    [11/02/2023-13:28:46] [TRT-LLM] [I]   rougeL : 18.141824087385494
    [11/02/2023-13:28:46] [TRT-LLM] [I]   rougeLsum : 21.100177758785833
    
  • internlm chat 7b, A100, sq 0.5, per channel + per token
    [11/02/2023-13:52:24] [TRT-LLM] [I] TensorRT-LLM (total latency: 10.30534052848816 sec)
    [11/02/2023-13:52:24] [TRT-LLM] [I] TensorRT-LLM beam 0 result
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rouge1 : 26.403443536401255
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rouge2 : 8.51525226310495
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rougeL : 18.0179325062827
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rougeLsum : 21.30214911105954
    [11/02/2023-13:52:24] [TRT-LLM] [I] Hugging Face (total latency: 32.334322690963745 sec)
    [11/02/2023-13:52:24] [TRT-LLM] [I] HF beam 0 result
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rouge1 : 24.12297379094552
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rouge2 : 9.254277981150196
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rougeL : 18.141824087385494
    [11/02/2023-13:52:24] [TRT-LLM] [I]   rougeLsum : 21.100177758785833
    

It seems from your result that score on H100 is good but suboptimal on A100. But I am a little bit curious about the difference. Since int8 weights are computed from python side and stored to file system prior to engine building. This means that different GPU builds the engine using the same set of int8 weight. Then the built engine on different GPU model should not differ a lot but the rouge number on A100 is much lower than that on H100 based on your result. Do you have any idea on this?

@nv-guomingz

Copy link
Copy Markdown
Collaborator

Hi @wangruohui

I re-measured your latest branch and got the identical acc results.

  • internlm-chat-7b/a100/per-tensor/sq 0.5
image
  • internlm-chat-7b/a100/per-channel+per_token/sq 0.5
image

It means we can reproduce your work at our side finally.

As we discussed above, let's merge your PR firstly to make sure credit you for the work.

And we may make further optimization/code refactor base on your initial commit later.

Is that ok for you?

If so, I suggest we can start merge process internally now.
cc @juney-nvidia @jdemouth-nvidia

Finally, thank you for your great contribution.

Thanks,
Guoming

@nv-guomingz

Copy link
Copy Markdown
Collaborator

It seems from your result that score on H100 is good but suboptimal on A100. But I am a little bit curious about the difference. Since int8 weights are computed from python side and stored to file system prior to engine building. This means that different GPU builds the engine using the same set of int8 weight. Then the built engine on different GPU model should not differ a lot but the rouge number on A100 is much lower than that on H100 based on your result. Do you have any idea on this?

Yes, it doesn't make sense that different hw platform generated different acc/scores, we'll take a look it.

@wangruohui

Copy link
Copy Markdown
Contributor Author

As we discussed above, let's merge your PR firstly to make sure credit you for the work.

And we may make further optimization/code refactor base on your initial commit later.

Is that ok for you?

Happy to hear that. Please move on and make sure to use the updated branch. Do I need to create another PR with the new branch?

@nv-guomingz

Copy link
Copy Markdown
Collaborator

e sure to us

Yes, please file a clean MR.

@wangruohui wangruohui mentioned this pull request Nov 3, 2023
5 tasks done
@wangruohui

Copy link
Copy Markdown
Contributor Author

Here you are #266 .

@wangruohui wangruohui changed the title Support InternLM models in TensorRT-LLM Support InternLM models (deprecated and move to #266) Nov 3, 2023
@nv-guomingz

Copy link
Copy Markdown
Collaborator

Close this one since we've merged #266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request. This includes new model, dtype, functionality support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants