Skip to content

Baichuan V2 13B,INT4 weight only, 输出可能有问题 #37

Closed

Description

Baichuan V2 13B
--max_output_len=1024
a single GPU
INT4 weight-only quantization

如上的一些配置,在执行 run.py的时候,会输出类似的结果,没有 Output
Input: "世界上第一高的山峰是哪座?" Output: "</s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s>

其他的一些组合配置,没有发现这个问题

Activity

  1. byshiue commented on Oct 20, 2023

    @byshiue
    Collaborator

    Can you provide more information and reproduced steps? For example, how do you convert weight, building engine and run the test script?

  2. jdemouth-nvidia commented on Oct 20, 2023

    @jdemouth-nvidia
    Collaborator

    To be more specific, we will need the following:

    • The conversion command to create the INT4 weights,
    • The command to build the engine build.py,
    • The command to run the engine run.py (or the Triton Server launch command).

    Thanks!

  3. callmezhangchenchenokay commented on Oct 20, 2023

    @callmezhangchenchenokay
    Author

    build.py 和 run.py 都没有动

    `python examples/baichuan/build.py --model_version v2_13b --model_dir ./models/Baichuan2-13B-Chat/ --dtype float16 --use_gemm_plugin float16 --use_gpt_attention_plugin float16 --use_weight_only --weight_only_precision int4 --output_dir ./models/tmp/baichuan_v2_13b/trt_engines/int4_weight_only/1-gpu/

    python examples/baichuan/run.py --model_version v2_13b --max_output_len=1024 --tokenizer_dir=./models/Baichuan2-13B-Chat/ --engine_dir=./models/tmp/baichuan_v2_13b/trt_engines/int4_weight_only/1-gpu/`

  4. jdemouth-nvidia commented on Oct 20, 2023

    @jdemouth-nvidia
    Collaborator

    Thanks a lot - we'll investigate and keep you posted.

  5. jdemouth-nvidia commented on Oct 20, 2023

    @jdemouth-nvidia
    Collaborator

    FYI, we are seeing some weird results as well. I've created an internal bug to track the issue in our system. One member of our team is going to investigate next week and we'll let you know as soon as we know more.

  6. callmezhangchenchenokay commented on Oct 20, 2023

    @callmezhangchenchenokay
    Author

    好哒! 幸苦

  7. tiandiao123 commented on Oct 20, 2023

    @tiandiao123

    好哒! 幸苦

    better use English over here since other users around the world can understand it.

  8. byshiue commented on Oct 24, 2023

    @byshiue
    Collaborator

    @callmezhangchenchenokay Sorry for late response. After investigation, we think it is not a bug. The model capacity of pure int4 weight only is not good enough.

    A way to enhance the accuracy on int4 is AWQ. This feature is supported on LLaMa, but it is not supported on Baichuan now. We will add it soon. You can try using int8 weight only first.

  9. self-assigned this
    on Oct 24, 2023
  10. callmezhangchenchenokay commented on Oct 24, 2023

    @callmezhangchenchenokay
    Author

    Okay! luckily bitter ^_^ !

  11. npuichigo commented on Oct 30, 2023

    @npuichigo

    @byshiue Since baichuan already prevides a pre-quantized Baichuan2-7B-Chat-4bits which is good to use with model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan2-7B-Chat-4bits", device_map="auto", trust_remote_code=True), can we leverage that in TensorRT-LLM?

  12. npuichigo commented on Oct 30, 2023

    @npuichigo

    @byshiue I used int8 weight-only and the results sometimes are good while sometimes are still </s>. Here's the result after deploying to triton, the difference here is only the question mark.

    (base) ➜  tensorrtllm_backend curl -X POST localhost:8000/v2/models/ensemble/generate -d '{"text_input": "你会做什么?", "max_tokens": 300, "bad_words": "", "stop_words": ""}'
    {"model_name":"ensemble","model_version":"1","sequence_end":false,"sequence_id":0,"sequence_start":false,"text_output":" 你会做什么?</s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s>"}
    
    (base) ➜  tensorrtllm_backend curl -X POST localhost:8000/v2/models/ensemble/generate -d '{"text_input": "你会做什么", "max_tokens": 300, "bad_words": "", "stop_words": ""}'
    {"model_name":"ensemble","model_version":"1","sequence_end":false,"sequence_id":0,"sequence_start":false,"text_output":" 你会做什么样的工作?\n作为一个大语言模型,我可以在许多领域提供帮助。以下是一些我可以从事的工作类型:\n\n1. 数据分析:我可以帮助您分析数据,找出趋势和模式,以便您做出更明智的决策。\n\n2. 项目管理:我可以帮助您规划项目,分配资源,跟踪进度并确保按时完成。\n\n3. 客户服务:我可以作为您的虚拟助手,回答客户问题,解决问题并提供支持。\n\n4.  市场营销:我可以帮助您创建和优化营销策略,提高品牌知名度和吸引潜在客户。\n\n5. 内容创作:我可以帮助您撰写文章、博客、广告文案等,以吸引和保留受众。\n\n6. 翻译:我可以帮助您翻译文本,让您能够与不同语言背景的人进行沟通。\n\n7. 教育辅导:我可以帮助您学习新技能或提高现有技能,提供个性化的学习资源和建议。\n\n8. 财务管理:我可以帮助您跟踪支出、制定预算并确保您的财务状况健康。\n\n9. 人力资源:我可以帮助您管理员工,包括招聘、培训、评估和提供反馈。\n\n10. 个人助手:我可以帮助您管理日常任务,如安排会议、提醒事项和管理日程。\n\n这些只是我可以帮助您的 一些例子。如果您有特定的需求或问题,请随时告诉我,我会尽力提供帮助。</s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s>"}
    
  13. byshiue commented on Oct 30, 2023

    @byshiue
    Collaborator

    :"ensembl

    </s> is end token, which is filled in the output_ids to initialize the buffer.

  14. npuichigo commented on Oct 30, 2023

    @npuichigo

    @byshiue Yes. But many cases stop so early and didn't match the output of huggingface.
    For example, for int8 weight-only:

    huggingface transformer

    tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan2-13B-Chat", use_fast=False, trust_remote_code=True)
    model = AutoModelForCausalLM.from_pretrained("tensorrt_llm/examples/baichuan/Baichuan2-13B-Chat/", load_in_8bit=True, device_map="auto", trust_remote_code=True)
    inputs = tokenizer('你会做什么?', return_tensors='pt').to('cuda')
    pred = model.generate(**inputs, max_new_tokens=300)
    print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=False))
    
     你会做什么?”
    “我会做很多事情,比如编程、设计网站、开发手机应用等等。我还可以帮助你解决一些技术问题。你有什么需要我帮忙的吗?”</s>
    

    tensorrt llm:

    (base) ➜  tensorrtllm_backend curl -X POST localhost:8000/v2/models/ensemble/generate -d '{"text_input": "你会做什么?", "max_tokens": 300, "bad_words": "", "stop_words": ""}'
    {"model_name":"ensemble","model_version":"1","sequence_end":false,"sequence_id":0,"sequence_start":false,"text_output":" 你会做什么?</s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s></s>"}
    
  15. jdemouth-nvidia commented on Oct 30, 2023

    @jdemouth-nvidia
    Collaborator

    Is that with the main branch? If it is, please, give us the command lines to reproduce the issue and we will investigate.

  16. npuichigo commented on Oct 30, 2023

    @npuichigo

    @jdemouth-nvidia I use release/0.5.0 for building, and use 23.10-trtllm-python-py3 NGC docker for serving.

    # Build the Baichuan V2 7B model using a single GPU and FP16.
    python build.py --model_version v2_7b \
                    --model_dir baichuan-inc/Baichuan2-7B-Chat \
                    --dtype float16 \
                    --use_gemm_plugin float16 \
                    --use_gpt_attention_plugin float16 \
                    --output_dir ./tmp/baichuan_v2_7b/trt_engines/fp16/1-gpu/
    
    # Serving
    # First: https://github.com/triton-inference-server/tensorrtllm_backend#modify-the-model-configuration
    
    # Second: Launch the Triton container
    docker run --rm -it --net host --shm-size=2g --ulimit memlock=-1 --ulimit stack=67108864 --gpus all -v /path/to/tensorrtllm_backend:/tensorrtllm_backend nvcr.io/nvidia/tritonserver:23.10-trtllm-python-py3 bash
    
    cd /tensorrtllm_backend
    # --world_size is the number of GPUs you want to use for serving
    python3 scripts/launch_triton_server.py --model_repo=/tensorrtllm_backend/triton_model_repo
    
    # Third: Send request
    tensorrtllm_backend curl -X POST localhost:8000/v2/models/ensemble/generate -d '{"text_input": "你会做什么?", "max_tokens": 300, "bad_words": "", "stop_words": "</s>"}'
    
  17. jdemouth-nvidia commented on Oct 31, 2023

    @jdemouth-nvidia
    Collaborator

    Can you try with the main branch please?

  18. npuichigo commented on Oct 31, 2023

    @npuichigo

    @jdemouth-nvidia what's the version in NGC docker. maybe I need to build an own one?

  19. 77h2l commented on Nov 14, 2023

    @77h2l

    @callmezhangchenchenokay Sorry for late response. After investigation, we think it is not a bug. The model capacity of pure int4 weight only is not good enough.

    A way to enhance the accuracy on int4 is AWQ. This feature is supported on LLaMa, but it is not supported on Baichuan now. We will add it soon. You can try using int8 weight only first.

    @byshiue Has this been supported now yet? Since the int4 model acc drops rather much and its necessary under few memory-poor situation to run big size llms.

  20. byshiue commented on Nov 14, 2023

    @byshiue
    Collaborator

    Not yet.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriagedIssue has been triaged by maintainers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions