华为云用户手册

  • 步骤二:非sharegpt格式数据集转换(可选) 如果数据集json文件不是sharegpt格式,而是常见的如下格式,则需要执行convert_to_sharegpt.py 文件将数据集转换为share gpt格式。 {"prefix": "AAA""input": "BBB","output": "CCC"} 执行convert_to_sharegpt.py 文件。 python convert_to_sharegpt.py \ --input_file_path data_test.json \ --out_file_name ./data_for_sharegpt.json \ --prefix_name instruction \ --input_name input \ --output_name output \ --code_type utf-8 其中: input_file_path:预训练json文件地址。 out_file_name:输出的sharegpt格式文件地址。 prefix_name:预训练json文件的前缀字段名称,例如:您是一个xxx专家,您需要回答下面问题。prefix_name可设置为None,此时预训练数据集只有input和output两段输入。 input_name:预训练json文件的指令输入字段名称,例如:请问苹果是什么颜色。 output_name output:预训练json文件的output字段名称,例如:苹果是红色的。 code_type:预训练json文件编码,默认utf-8。 当转换为sharegpt格式时,prefix和input会拼接成一段文字,作为human字段,提出问题,而output字段会作为gpt字段,做出回答。
  • 步骤四:执行训练 安装完成后,执行: accelerate launch -m --mixed_precision=bf16 eagle.train.main \--tmpdir [path of data] \--cpdir [path of checkpoints] \--configpath [path of config file] \--basepath [path of base_model]--bs [batch size] tmpdir:即为步骤三中的outdir,训练data地址 cpdir:为训练生成权重的地址 configpath:为模型config文件的地址 basepath:为大模型权重地址 bs:为batch大小 其中,要获取模型config文件, 首先到https://github.com/SafeAILab/EAGLE/页找到对应eagle模型地址。 图1 EAGLE Weights 以llama2-chat-7B为例,单击进入后 ,如下图所示config文件,即为对应模型的eagle config文件。 图2 eagle config文件
  • 附录:基于vLLM不同模型推理支持最小卡数和最大序列说明 基于vLLM(v0.6.0)部署推理服务时,不同模型推理支持的最小昇腾卡数和对应卡数下的max-model-len长度说明,如下面的表格所示。 以下值是在gpu-memory-utilization为0.9时测试得出,为服务部署所需的最小昇腾卡数及该卡数下推荐的最大max-model-len长度,不代表最佳性能。 以llama2-13b为例,NPU卡显存为32GB时,至少需要2张卡运行推理业务,2张卡运行的情况下,推荐的最大序列max-model-len长度最大是16K,此处的单位K是1024,即16*1024。 测试方法:gpu-memory-utilization为0.9下,以4k、8k、16k递增max-model-len,直至达到能执行静态benchmark下的最大max-model-len。 表1 基于vLLM不同模型推理支持最小卡数和最大序列说明 序号 模型名 32GB显存 64GB显存 最小卡数 最大序列(K) max-model-len 最小卡数 最大序列(K) max-model-len 1 llama-7b 1 16 1 32 2 llama-13b 2 16 1 16 3 llama-65b 8 16 4 16 4 llama2-7b 1 16 1 32 5 llama2-13b 2 16 1 16 6 llama2-70b 8 32 4 64 7 llama3-8b 1 32 1 128 8 llama3-70b 8 32 4 64 9 qwen-7b 1 8 1 32 10 qwen-14b 2 16 1 16 11 qwen-72b 8 8 4 16 12 qwen1.5-0.5b 1 128 1 256 13 qwen1.5-7b 1 8 1 32 14 qwen1.5-1.8b 1 64 1 128 15 qwen1.5-14b 2 16 1 16 16 qwen1.5-32b 4 32 2 64 17 qwen1.5-72b 8 8 4 16 18 qwen1.5-110b -- 8 128 19 qwen2-0.5b 1 128 1 256 20 qwen2-1.5b 1 64 1 128 21 qwen2-7b 1 8 1 32 22 qwen2-72b 8 32 4 64 23 chatglm2-6b 1 64 1 128 24 chatglm3-6b 1 64 1 128 25 glm-4-9b 1 32 1 128 26 baichuan2-7b 1 8 1 32 27 baichuan2-13b 2 4 1 4 28 yi-6b 1 64 1 128 29 yi-9b 1 32 1 64 30 yi-34b 4 32 2 64 31 deepseek-llm-7b 1 16 1 32 32 deepseek-coder-instruct-33b 4 32 2 64 33 deepseek-llm-67b 8 32 4 64 34 mistral-7b 1 32 1 128 35 mixtral-8x7b 4 8 2 32 36 gemma-2b 1 64 1 128 37 gemma-7b 1 8 1 32 38 falcon-11b 1 8 1 64 父主题: 主流开源大模型基于Standard适配PyTorch NPU推理指导(6.3.909)
  • 模型软件包结构说明 本教程需要使用到的AscendCloud-6.3.911中的AscendCloud-LLM-xxx.zip软件包和算子包AscendCloud-OPP,AscendCloud-LLM关键文件介绍如下。 |——AscendCloud-LLM ├──llm_inference # 推理代码 ├──ascend_vllm ├── vllm_npu # 推理源码 ├── ascend_vllm-0.6.3-py3-none-any.whl # 推理安装包 ├── build.sh # 推理构建脚本 ├── vllm_install.patch # 社区昇腾适配的补丁包 ├── Dockerfile # 推理构建镜像dockerfile ├── build_image.sh # 推理构建镜像启动脚本 ├──llm_tools # 推理工具包 ├──AutoSmoothQuant # W8A8量化工具 ├── ascend_autosmoothquant_adapter # 昇腾量化使用的算子模块 ├── autosmoothquant_ascend # 量化代码 ├── build.sh # 安装量化模块的脚本 ├──AutoAWQ # W4A16量化工具 ├──convert_awq_to_npu.py # awq权重转换脚本 ├──quantize.py # 昇腾适配的量化转换脚本 ├──build.sh # 安装量化模块的脚本 ├──llm_evaluation # 推理评测代码包 ├──benchmark_tools #性能评测 ├── benchmark.py # 可以基于默认的参数跑完静态benchmark和动态benchmark ├── benchmark_parallel.py # 评测静态性能脚本 ├── benchmark_serving.py # 评测动态性能脚本 ├── benchmark_utils.py # 抽离的工具集 ├── generate_datasets.py # 生成自定义数据集的脚本 ├── requirements.txt # 第三方依赖 ├──benchmark_eval #精度评测 ├──opencompass.sh #运行opencompass脚本 ├──install.sh #安装opencompass脚本 ├──vllm_api.py #启动vllm api服务器 ├──vllm.py #构造vllm评测配置脚本名字
  • 支持的模型列表和权重文件 本方案支持vLLM的v0.6.3版本。不同vLLM版本支持的模型列表有差异,具体如表3所示。 表3 支持的模型列表和权重获取地址 序号 模型名称 是否支持fp16/bf16推理 是否支持W4A16量化 是否支持W8A8量化 是否支持W8A16量化 是否支持 kv-cache-int8量化 开源权重获取地址 1 llama-7b √ √ √ √ √ https://huggingface.co/huggyllama/llama-7b 2 llama-13b √ √ √ √ √ https://huggingface.co/huggyllama/llama-13b 3 llama-65b √ √ √ √ √ https://huggingface.co/huggyllama/llama-65b 4 llama2-7b √ √ √ √ √ https://huggingface.co/meta-llama/Llama-2-7b-chat-hf 5 llama2-13b √ √ √ √ √ https://huggingface.co/meta-llama/Llama-2-13b-chat-hf 6 llama2-70b √ √ √ √ √ https://huggingface.co/meta-llama/Llama-2-70b-hf https://huggingface.co/meta-llama/Llama-2-70b-chat-hf (推荐) 7 llama3-8b √ √ √ √ √ https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct 8 llama3-70b √ √ √ √ √ https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct 9 yi-6b √ √ √ √ √ https://huggingface.co/01-ai/Yi-6B-Chat 10 yi-9b √ √ √ √ √ https://huggingface.co/01-ai/Yi-9B 11 yi-34b √ √ √ √ √ https://huggingface.co/01-ai/Yi-34B-Chat 12 deepseek-llm-7b √ x x x x https://huggingface.co/deepseek-ai/deepseek-llm-7b-chat 13 deepseek-coder-33b-instruct √ x x x x https://huggingface.co/deepseek-ai/deepseek-coder-33b-instruct 14 deepseek-llm-67b √ x x x x https://huggingface.co/deepseek-ai/deepseek-llm-67b-chat 15 qwen-7b √ √ √ √ x https://huggingface.co/Qwen/Qwen-7B-Chat 16 qwen-14b √ √ √ √ x https://huggingface.co/Qwen/Qwen-14B-Chat 17 qwen-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen-72B-Chat 18 qwen1.5-0.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-0.5B-Chat 19 qwen1.5-7b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-7B-Chat 20 qwen1.5-1.8b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat 21 qwen1.5-14b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-14B-Chat 22 qwen1.5-32b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-32B/tree/main 23 qwen1.5-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-72B-Chat 24 qwen1.5-110b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-110B-Chat 25 qwen2-0.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2-0.5B-Instruct 26 qwen2-1.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2-1.5B-Instruct 27 qwen2-7b √ √ x √ x https://huggingface.co/Qwen/Qwen2-7B-Instruct 28 qwen2-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen2-72B-Instruct 29 qwen2.5-0.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct 30 qwen2.5-1.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct 31 qwen2.5-3b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-3B-Instruct 32 qwen2.5-7b √ √ x √ x https://huggingface.co/Qwen/Qwen2.5-7B-Instruct 33 qwen2.5-14b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-14B-Instruct 34 qwen2.5-32b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-32B-Instruct 35 qwen2.5-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-72B-Instruct 36 baichuan2-7b √ x x √ x https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat 37 baichuan2-13b √ x x √ x https://huggingface.co/baichuan-inc/Baichuan2-13B-Chat 38 gemma-2b √ x x x x https://huggingface.co/google/gemma-2b 39 gemma-7b √ x x x x https://huggingface.co/google/gemma-7b 40 chatglm2-6b √ x x x x https://huggingface.co/THUDM/chatglm2-6b 41 chatglm3-6b √ x x x x https://huggingface.co/THUDM/chatglm3-6b 42 glm-4-9b √ x x x x https://huggingface.co/THUDM/glm-4-9b-chat 43 mistral-7b √ x x x x https://huggingface.co/mistralai/Mistral-7B-v0.1 44 mixtral-8x7b √ x x x x https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1 45 falcon-11b √ x x x x https://huggingface.co/tiiuae/falcon-11B/tree/main 46 qwen2-57b-a14b √ x x x x https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct 47 llama3.1-8b √ √ √ √ x https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct 48 llama3.1-70b √ √ √ √ x https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct 49 llama-3.1-405B √ √ x x x https://huggingface.co/hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4 50 llama-3.2-1B √ x x x x Llama-3.2-1B-Instruct · 模型库 (modelscope.cn) 51 llama-3.2-3B √ x x x x Llama-3.2-3B-Instruct · 模型库 (modelscope.cn) 52 llava-1.5-7b √ x x x x https://huggingface.co/llava-hf/llava-1.5-7b-hf/tree/main 53 llava-1.5-13b √ x x x x https://huggingface.co/llava-hf/llava-1.5-13b-hf/tree/main 54 llava-v1.6-7b √ x x x x https://huggingface.co/llava-hf/llava-v1.6-vicuna-7b-hf/tree/main 55 llava-v1.6-13b √ x x x x https://huggingface.co/llava-hf/llava-v1.6-vicuna-13b-hf/tree/main 56 llava-v1.6-34b √ x x x x https://huggingface.co/llava-hf/llava-v1.6-34b-hf/tree/main 57 internvl2-8B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-8B/tree/main 58 internvl2-26B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-26B/tree/main 59 internvl2-40B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-40B/tree/main 60 internVL2-Llama3-76B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-Llama3-76B/tree/main 61 MiniCPM-v2.6 √ x x x x https://huggingface.co/openbmb/MiniCPM-V-2_6/tree/main 62 deepseek-v2-236b x x √ x x https://huggingface.co/deepseek-ai/DeepSeek-V2 63 deepseek-v2-lite-16b √ x √ x x https://huggingface.co/deepseek-ai/DeepSeek-V2-Lite 64 qwen2-vl-2B √ x x x x https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct/tree/main 65 qwen2-vl-7B √ x x x x https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct/tree/main 66 qwen2-vl-72B √ x x x x https://huggingface.co/Qwen/Qwen2-VL-72B-Instruct/tree/main 67 qwen-vl √ x x x x https://huggingface.co/Qwen/Qwen-VL 68 qwen-vl-chat √ x x x x https://huggingface.co/Qwen/Qwen-VL-Chat 69 MiniCPM-v2 √ x x x x https://huggingface.co/HwwwH/MiniCPM-V-2 注意:需要修改源文件site-packages/timm/layers/pos_embed.py,在第46行上面新增一行代码,如下: posemb = posemb.contiguous() #新增 posemb = F.interpolate(posemb, size=new_size, mode=interpolation, antialias=antialias) 各模型支持的卡数请参见附录:基于vLLM不同模型推理支持最小卡数和最大序列说明章节。
  • 约束限制 本方案目前仅适用于部分企业客户。 本文档适配昇腾云ModelArts 6.3.911版本,请参考软件配套版本获取配套版本的软件包,请严格遵照版本配套关系使用本文档。 资源规格推荐使用“西南-贵阳一”Region上的DevServer和昇腾Snt9B资源。 推理部署使用的服务框架是vLLM。vLLM支持v0.6.3版本。 支持FP16和BF16数据类型推理。 适配的CANN版本是cann_8.0.rc3。 DevServer驱动版本要求23.0.6。
  • 镜像版本 本教程中用到基础镜像地址和配套版本关系如下表所示,请提前了解。 表1 基础容器镜像地址 镜像用途 镜像地址 配套版本 基础镜像 swr.cn-southwest-2.myhuaweicloud.com/atelier/pytorch_2_1_ascend:pytorch_2.1.0-cann_8.0.rc3-py_3.9-hce_2.0.2409-aarch64-snt9b-20241112192643-c45ac6b cann_8.0.rc3
  • 资源规格要求 本文档中的模型运行环境是ModelArts Lite的DevServer。推荐使用“西南-贵阳一”Region上的资源和Ascend Snt9B。 如果使用DevServer资源,请参考DevServer资源开通,购买DevServer资源,并确保机器已开通,密码已获取,能通过SSH登录,不同机器之间网络互通。 当容器需要提供服务给多个用户,或者多个用户共享使用该容器时,应限制容器访问Openstack的管理地址(169.254.169.254),以防止容器获取宿主机的元数据。具体操作请参见禁止容器获取宿主机元数据。
  • 软件配套版本 本方案支持的软件配套版本和依赖包获取地址如表2所示。 表2 软件配套版本和获取地址 软件名称 说明 下载地址 AscendCloud-6.3.911-xxx.zip 说明: 软件包名称中的xxx表示时间戳。 包含了本教程中使用到的推理部署代码和推理评测代码、推理依赖的算子包。代码包具体说明请参见模型软件包结构说明。 获取路径:Support-E,在此路径中查找下载ModelArts 6.3.911 版本。 说明: 如果上述软件获取路径打开后未显示相应的软件信息,说明您没有下载权限,请联系您所在企业的华为方技术支持下载获取。
  • 步骤二 权重格式离线转换(可选) 在GPU上AutoAWQ量化完成后,使用int32对int4的权重进行打包。昇腾上使用int8对权重进行打包,在线转换会增加启动时间,可以提前对权重进行转换以减少启动时间,转换步骤如下: 进入llm_tools/AutoAWQ代码目录下执行以下脚本: 执行时间预计10分钟。执行完成后会将权重路径下的原始权重替换成转换后的权重。如需保留之前权重格式,请在转换前备份。 python convert_awq_to_npu.py --model /home/ma-user/Qwen1.5-72B-Chat-AWQ 参数说明: model:模型路径。
  • 准备Notebook ModelArts Notebook云上云下,无缝协同,更多关于ModelArts Notebook的详细资料请查看Notebook使用场景介绍。本案例中使用ModelArts的开发环境Notebook部署推理服务进行调试,请按照以下步骤完成Notebook的创建。 登录ModelArts控制台,在贵阳一区域,进入开发环境的Notebook界面,单击右上角“创建”,创建一个开发环境。创建Notebook的详细介绍可以参考创建Notebook实例,此处仅介绍关键步骤。 图1 创建Notebook 创建Notebook时,选择 自定义镜像 ,并选择Step8 注册镜像章中注册的镜像。 图2 选择自定义镜像 资源类型推荐使用专属资源池,规格选到Asecnd snt9b,显存规格建议选择64G以上的规格,磁盘规格建议选择500GB及以上。 创建完Notebook后,待Notebook状态变为“运行中”时,打开Notebook,可参考后续章节在Notebook调试环境中部署推理服务。 父主题: 准备工作
  • 步骤一:配置精度测试环境 获取精度测试代码。精度测试代码存放在代码包AscendCloud-LLM的llm_tools/llm_evaluation目录中,代码目录结构如下。目前使用的opencompass版本是0.2.6 benchmark_eval├──opencompass.sh #运行opencompass脚本├──install.sh #安装opencompass脚本├──vllm_api.py #启动vllm api服务器├──vllm.py #构造vllm评测配置脚本名字├──vllm_ppl.py #ppl精度测试脚本 精度评测切换conda环境,确保之前启动服务为vllm接口,进入到benchmark_eval目录下,执行如下命令。 conda activate python-3.9.10 bash install.sh 在/home/ma-user/AscendCloud/AscendCloud-LLM/llm_tools/llm_evaluation/benchmark_eval目录下安装依赖。 cd opencompass #在benchmark_eval目录下pip install -e . #下载对应依赖cd ../human-eval #在benchmark_eval目录下 (可选,如果选择使用humaneval数据集)pip install -e . # 可选,如果选择使用humaneval数据集pip install huggingface-hub==0.25.1 (可选)如果需要在humaneval数据集上评估模型代码能力,请执行此步骤,否则忽略这一步。原因是通过opencompass使用humaneval数据集时,需要执行模型生成的代码。请仔细阅读human_eval/execution.py文件第48-57行的注释,内容参考如下。了解执行模型生成代码可能存在的风险,如果接受这些风险,请取消第58行的注释,执行下面步骤5进行评测。 # WARNING# This program exists to execute untrusted model-generated code. Although# it is highly unlikely that model-generated code will do something overtly# malicious in response to this test suite, model-generated code may act# destructively due to a lack of model capability or alignment.# Users are strongly encouraged to sandbox this evaluation suite so that it # does not perform destructive actions on their host or network. For more # information on how OpenAI sandboxes its code, see the accompanying paper.# Once you have read this disclaimer and taken appropriate precautions, # uncomment the following line and proceed at your own risk:# exec(check_program, exec_globals) #第58行 执行精度测试启动脚本opencompass.sh,具体操作命令如下,可以根据参数说明修改参数。请确保${work_dir} 已经通过export设置。 vllm_path=${vllm_path} \host=$host \service_port=${service_port} \max_out_len=${max_out_len} \batch_size=${batch_size} \eval_datasets=${eval_datasets} \model_name=${model_name} \benchmark_type=${benchmark_type} \bash -x opencompass.sh 参数说明: vllm_path:构造vllm评测配置脚本名字,默认为vllm。 host:与起服务的host保持一致,比如起服务为0.0.0.0,host设置也为0.0.0.0。 service_port:服务端口,与启动服务时的端口保持,比如8080。 max_out_len:在运行类似mmlu、ceval等判别式回答时,max_out_len建议设置小一些,比如16。在运行human_eval等生成式回答(生成式回答是对整体进行评测,少一个字符就可能会导致判断错误)时,max_out_len设置建议长一些,比如512,至少包含第一个回答的全部字段。 batch_size:输入的batch_size大小,不影响精度,只影响得到结果速度。 eval_datasets:评测数据集和评测方法,比如ceval_gen、mmlu_gen,不同数据集可以详见opencompass下面data目录。 model_name:评测模型名称,不需要与启动服务时的模型参数保持一致。 benchmark_type:作为一个保存log结果中的一个变量名,默认选eval。 参考命令: vllm_path=vllm host=0.0.0.0 service_port=8080 max_out_len=16 batch_size=2 eval_datasets=mmlu_gen model_name=llama_7b benchmark_type=eval bash -x opencompass.sh (可选)如果同时运行多个数据集,需要将不同数据集通过空格分开,加入到eval_datasets中,比如eval_datasets=ceval_gen mmlu_gen。运行命令如下所示。 cd opencompasspython run.py --models vllm --datasets mmlu_gen ceval_gen --debug -w ${output_path} output_path: 要保存的结果路径。 (可选)创建新conda环境,安装vllm和opencompass。执行完之后,在 opencompass/configs/models/vllm/vllm_ppl.py 里是ppl的配置项。由于离线执行推理,消耗的显存相当庞大。其中以下参数需要根据实际来调整。 batch_size,推理时传入的prompts数量,可配合后面的参数适当减少 offline,是否启动离线模型,使用ppl时必须为True tp_size,使用推理的卡数 max_seq_len,推理的上下文长度,和消耗的显存直接相关,建议稍微高于prompts。其中,mmlu和ceval 建议 3200 另外,在 opencompass/opencompass/models/vllm_api.py 中,可以适当调整 gpu_memory_utilization。如果还是 oom,建议适当往下调整。 最后,如果执行报错提示oom,建议修改数据集的shot配置。例如mmlu,可以修改文件 opencompass/configs/datasets/mmlu/mmlu_ppl_ac766d.py 中的 fix_id_list, 将最大值适当调低。 ppl困惑度评测一般用于base权重测评,会将n个选项上拼接上下文,形成n个序列,再计算这n个序列的困惑度(perplexity)。其中,perplexity最小的序列所对应的选项即为这道题的推理结果。运行时间比较长,例如llama3_8b 跑完mmlu要2~3小时。 在npu卡上,使用多卡进行推理时,需要预置变量 export PYTORCH_NPU_ALLOC_CONF=expandable_segments:False 执行脚本如下: python run.py --models vllm_ppl --datasets mmlu_ppl -w ${output_path} output_path 指定保存结果的路径。 参考模型llama3系列模型,数据集mmlu为例,配置如下: 表1 参数配置 模型 max_seq_len batch_size shot数 llama3_8b 3200 8 采用默认值 llama3_70b 3200 4 [0, 1, 2] (可选) opencompass也支持通过本地权重来进行ppl精度测试。本质上使用transformers进行推理,因为没有框架的优化,执行时间最长。另一方面,由于是使用transformers推理,结果也是最稳定的。对单卡运行的模型比较友好,算力利用率比较高。对多卡运行的推理,缺少负载均衡,利用率低。 在昇腾卡上执行时,需要在 opencompass/opencompass/runners/local.py 中添加如下代码 import torchimport torch_npufrom torch_npu.contrib import transfer_to_npu 执行脚本如下 # for llama3_8bpython run.py --datasets mmlu_ppl \ --hf-type base --hf-path {hf-path} \ --max-seq-len 3200 --max-out-len 16 --hf-num-gpus 1 --batch-size 4 \ -w {output_path} --debug 参数说明如下: --datasets:评测的数据集及评测方法,其中 mmlu 是数据集,ppl 是评测方法。 --hf-type:HuggingFace模型权重类型(base,chat),默认为chat,依据实际的模型选择。 --hf-path:本地 HuggingFace 权重的路径,比如/home/ma-user/nfs/model/Meta-Llama-3-8B。 --max-seq-len:模型的最大序列长度。 --max-out-len:模型的最大输出长度。 --hf-num-gpus:需要使用的卡数。 --batch-size:推理每次处理的输入数目。 -w:存放输出结果的目录。
  • 使用SmoothQuant量化工具转换权重 SmoothQuant(W8A8)量化方案能降低模型显存以及需要部署的卡数。也能同时降低首token时延和增量推理时延。支持SmoothQuant(W8A8)量化的模型列表请参见支持的模型列表和权重文件。 本章节介绍如何在Notebook使用SmoothQuant量化工具实现推理量化。 SmoothQuant量化工具使用到的脚本存放在代码包AscendCloud-LLM-x.x.x.zip的llm_tools目录下。 代码目录如下: AutoSmoothQuant #量化工具 ├── ascend_autosmoothquant_adapter # 昇腾量化使用的算子模块 ├── autosmoothquant # 量化代码 ├── build.sh # 安装量化模块的脚本 ... 具体操作如下: 配置需要使用的NPU卡,例如:实际使用的是第1张和第2张卡,此处填写为“0,1”,以此类推。 export ASCEND_RT_VISIBLE_DEVI CES =0,1 NPU卡编号可以通过命令npu-smi info查询。 执行权重转换。 cd autosmoothquant/examples/python smoothquant_model.py --model-path /home/ma-user/llama-2-7b/ --quantize-model --generate-scale --dataset-path /data/nfs/user/val.jsonl --scale-output scales/llama2-7b.pt --model-output quantized_model/llama2-7b --per-token --per-channel 参数说明: --model-path:原始模型权重路径。 --quantize-model:体现此参数表示会生成量化模型权重。不需要生成量化模型权重时,不体现此参数 --generate-scale:体现此参数表示会生成量化系数,生成后的系数保存在--scale-output参数指定的路径下。如果有指定的量化系数,则不需此参数,直接读取--scale-input参数指定的量化系数输入路径即可。 --dataset-path:数据集路径,推荐使用:https://huggingface.co/datasets/mit-han-lab/pile-val-backup/resolve/main/val.jsonl.zst。 --scale-output:量化系数保存路径。 --scale-input:量化系数输入路径,如果之前已生成过量化系数,则可指定该参数,跳过生成scale的过程。 --model-output:量化模型权重保存路径。 --smooth-strength:平滑系数,推荐先指定为0.5,后续可以根据推理效果进行调整。 --per-token:激活值量化方法,如果指定则为per-token粒度量化,否则为per-tensor粒度量化。 --per-channel:权重量化方法,如果指定则为per-channel粒度量化,否则为per-tensor粒度量化。 启动smoothQuant量化服务。 参考Step3 启动推理服务,启动推理服务时添加如下命令。 -q smoothquant 或者 --quantization smoothquant--dtype=float16 父主题: 推理模型量化
  • 问题2:在推理预测过程中遇到ValueError:User-specified max_model_len is greater than the drived max_model_len 解决方法: 修改config.json文件中的"seq_length"的值,"seq_length"需要大于等于 --max-model-len的值。config.json存在模型对应的路径下,例如:/data/nfs/benchmark/tokenizer/chatglm3-6b/config.json
  • 问题3:使用llama3.1系列模型进行推理时报错 使用llama3.1系模型进行推理时报错:ValueError: 'rope_scaling' must be a dictionary with two fields, 'type' and 'factor', got {'factor': 8.0, 'low_freq_factor': 1.0, 'high_freq_factor': 4.0, 'original_max_position_embeddings': 8192, 'rope_type': 'llama3'}
  • 问题8:使用benchmark-tools对GLM系列模型进行性能测试报错 使用benchmark-tools对GLM系列模型进行性能测试报错TypeError: _pad() got an unexpected keyword argument 'padding_side' 解决方法: 1、下载最新的tokenization_chatglm.py,替换原来权重里的tokenization_chatglm.py。 https://huggingface.co/THUDM/glm-4-9b-chat/blob/main/tokenization_chatglm.py https://huggingface.co/THUDM/chatglm3-6b/blob/main/tokenization_chatglm.py 或者2、修改tokenization_chatglm.py,在266行增加padding_side: str = "left",如图1所示。 图1 tokenization_chatglm.py
  • 问题4:使用SmoothQuant进行W8A8进行模型量化时报错 使用SmoothQuant进行W8A8进行模型量化时报错:AttributeError: type object 'LlamaAttention' has no attribute '_init_rope' 解决方法:降低transformers版本到4.42 pip install transformers==4.42 --upgrade
  • 问题13:使用SmoothQuant做权重转换时报错 图8 权重转换报错 涉及模型:qwen2-1.5b, qwen2-0.5b 解决方法:修改AscendCloud/AscendCloud-LLM/llm_tools/AutoSmoothQuant/autosmoothquant/examples/smoothquant_model.py中的main函数,保存模型时将safe_serialization指定为False int8_model.save_pretrained(output_path,safe_serialization=False)
  • 问题9:使用benchmark-tools访问推理服务返回报错 使用benchmark-tools访问推理服务时,输入输出的token和大于max_model_len,服务端返回报错Response payload is not completed,见图2。 再次设置输入输出的token和小于max_model_len访问推理服务,服务端响应200,见图3。 客户端仍返回报错Response payload is not completed,见图4。 图2 服务端返回报错Response payload is not completed 图3 服务端响应200 图4 仍返回报错Response payload is not completed 解决方法: 安装brotlipy后返回正确报错 pip install brotlipy
  • 问题5:使用AWQ转换llama3.1系列模型权重出现报错 使用AWQ转换llama3.1系列模型权重出现报错:ValueError: 'rope_scaling' must be a dictionary with two fields, 'type' and 'factor' 解决方法: 该问题通过将transformers升级到4.44.0,修改对应transformers中的transformers/models/llama/modeling_llama.py,在class LlamaRotaryEmbedding中的forward函数中增加self.inv_freq = self.inv_freq.npu()
  • 问题12:使用SmoothQuant做权重转换时,scale显示为nan或推理时精度异常 图7 权重转换scale显示为nan 涉及模型:qwen2-1.5b, qwen2-7b 解决方法:修改AscendCloud/AscendCloud-LLM/llm_tools/AutoSmoothQuant/autosmoothquant/utils/utils.py中的build_model_and_tokenizer函数,将torch_dtype类型从torch.float16改成torch.bfloat16 kwargs = {"torch_dtype": torch.bfloat16, "device_map": "auto"}
  • 准备Notebook ModelArts Notebook云上云下,无缝协同,更多关于ModelArts Notebook的详细资料请查看Notebook使用场景介绍。本案例中使用ModelArts的开发环境Notebook部署推理服务进行调试,请按照以下步骤完成Notebook的创建。 登录ModelArts控制台,在贵阳一区域,进入开发环境的Notebook界面,单击右上角“创建”,创建一个开发环境。创建Notebook的详细介绍可以参考创建Notebook实例,此处仅介绍关键步骤。 图1 创建Notebook 创建Notebook时,选择自定义镜像,并选择Step8 注册镜像章中注册的镜像。 图2 选择自定义镜像 资源类型推荐使用专属资源池,规格选到Ascend snt9b,显存规格建议选择64G以上的规格,磁盘规格建议选择500GB及以上。 创建完Notebook后,待Notebook状态变为“运行中”时,打开Notebook,可参考后续章节在Notebook调试环境中部署推理服务。 父主题: 准备工作
  • Step4 调用在线服务 进入在线服务详情页面,选择“预测”。 如果以vllm接口启动服务,设置请求路径:“/generate”,输入预测代码“{"prompt": "你好", "temperature":0, "max_tokens":20}”,单击“预测”即可看到预测结果。 图8 预测-vllm 如果以openai接口启动服务,设置请求路径:“/v1/completions”,输入预测代码“{"prompt": "你是谁","model": "${model_path}","max_tokens": 50,"temperature":0}”,单击“预测”即可看到预测结果。 图9 预测-openai 在线服务的更多内容介绍请参见文档查看服务详情。
  • 操作流程 图1 操作流程图 表2 操作任务流程说明 阶段 任务 说明 准备工作 准备资源 本教程案例是基于ModelArts Standard运行,需要购买ModelArts专属资源池。 准备权重 准备对应模型的权重文件。 准备代码 准备AscendCloud-6.3.911-xxx.zip。 准备镜像 准备推理模型适用的容器镜像。 准备Notebook 本案例在Notebook上部署推理服务进行调试,因此需要创建Notebook。 部署推理服务 在Notebook调试环境中部署推理服务 介绍如何在Notebook中配置NPU环境,部署并启动推理服务,完成精度测试和性能测试。 如果需要部署量化模型,需在Notebook中进行模型权重转换后再部署推理服务。 在推理生产环境中部署推理服务 介绍如何在创建AI应用,部署并启动推理服务,在线预测在线服务。
  • 支持的模型列表和权重文件 本方案支持vLLM的v0.6.3版本。不同vLLM版本支持的模型列表有差异,具体如表1所示。 表1 支持的模型列表和权重获取地址 序号 模型名称 是否支持fp16/bf16推理 是否支持W4A16量化 是否支持W8A8量化 是否支持W8A16量化 是否支持 kv-cache-int8量化 开源权重获取地址 1 llama-7b √ √ √ √ √ https://huggingface.co/huggyllama/llama-7b 2 llama-13b √ √ √ √ √ https://huggingface.co/huggyllama/llama-13b 3 llama-65b √ √ √ √ √ https://huggingface.co/huggyllama/llama-65b 4 llama2-7b √ √ √ √ √ https://huggingface.co/meta-llama/Llama-2-7b-chat-hf 5 llama2-13b √ √ √ √ √ https://huggingface.co/meta-llama/Llama-2-13b-chat-hf 6 llama2-70b √ √ √ √ √ https://huggingface.co/meta-llama/Llama-2-70b-hf https://huggingface.co/meta-llama/Llama-2-70b-chat-hf (推荐) 7 llama3-8b √ √ √ √ √ https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct 8 llama3-70b √ √ √ √ √ https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct 9 yi-6b √ √ √ √ √ https://huggingface.co/01-ai/Yi-6B-Chat 10 yi-9b √ √ √ √ √ https://huggingface.co/01-ai/Yi-9B 11 yi-34b √ √ √ √ √ https://huggingface.co/01-ai/Yi-34B-Chat 12 deepseek-llm-7b √ x x x x https://huggingface.co/deepseek-ai/deepseek-llm-7b-chat 13 deepseek-coder-33b-instruct √ x x x x https://huggingface.co/deepseek-ai/deepseek-coder-33b-instruct 14 deepseek-llm-67b √ x x x x https://huggingface.co/deepseek-ai/deepseek-llm-67b-chat 15 qwen-7b √ √ √ √ x https://huggingface.co/Qwen/Qwen-7B-Chat 16 qwen-14b √ √ √ √ x https://huggingface.co/Qwen/Qwen-14B-Chat 17 qwen-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen-72B-Chat 18 qwen1.5-0.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-0.5B-Chat 19 qwen1.5-7b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-7B-Chat 20 qwen1.5-1.8b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat 21 qwen1.5-14b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-14B-Chat 22 qwen1.5-32b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-32B/tree/main 23 qwen1.5-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-72B-Chat 24 qwen1.5-110b √ √ √ √ x https://huggingface.co/Qwen/Qwen1.5-110B-Chat 25 qwen2-0.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2-0.5B-Instruct 26 qwen2-1.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2-1.5B-Instruct 27 qwen2-7b √ √ x √ x https://huggingface.co/Qwen/Qwen2-7B-Instruct 28 qwen2-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen2-72B-Instruct 29 qwen2.5-0.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct 30 qwen2.5-1.5b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct 31 qwen2.5-3b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-3B-Instruct 32 qwen2.5-7b √ √ x √ x https://huggingface.co/Qwen/Qwen2.5-7B-Instruct 33 qwen2.5-14b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-14B-Instruct 34 qwen2.5-32b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-32B-Instruct 35 qwen2.5-72b √ √ √ √ x https://huggingface.co/Qwen/Qwen2.5-72B-Instruct 36 baichuan2-7b √ x x √ x https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat 37 baichuan2-13b √ x x √ x https://huggingface.co/baichuan-inc/Baichuan2-13B-Chat 38 gemma-2b √ x x x x https://huggingface.co/google/gemma-2b 39 gemma-7b √ x x x x https://huggingface.co/google/gemma-7b 40 chatglm2-6b √ x x x x https://huggingface.co/THUDM/chatglm2-6b 41 chatglm3-6b √ x x x x https://huggingface.co/THUDM/chatglm3-6b 42 glm-4-9b √ x x x x https://huggingface.co/THUDM/glm-4-9b-chat 43 mistral-7b √ x x x x https://huggingface.co/mistralai/Mistral-7B-v0.1 44 mixtral-8x7b √ x x x x https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1 45 falcon-11b √ x x x x https://huggingface.co/tiiuae/falcon-11B/tree/main 46 qwen2-57b-a14b √ x x x x https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct 47 llama3.1-8b √ √ √ √ x https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct 48 llama3.1-70b √ √ √ √ x https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct 49 llama-3.1-405B √ √ x x x https://huggingface.co/hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4 50 llama-3.2-1B √ x x x x Llama-3.2-1B-Instruct · 模型库 (modelscope.cn) 51 llama-3.2-3B √ x x x x Llama-3.2-3B-Instruct · 模型库 (modelscope.cn) 52 llava-1.5-7b √ x x x x https://huggingface.co/llava-hf/llava-1.5-7b-hf/tree/main 53 llava-1.5-13b √ x x x x https://huggingface.co/llava-hf/llava-1.5-13b-hf/tree/main 54 llava-v1.6-7b √ x x x x https://huggingface.co/llava-hf/llava-v1.6-vicuna-7b-hf/tree/main 55 llava-v1.6-13b √ x x x x https://huggingface.co/llava-hf/llava-v1.6-vicuna-13b-hf/tree/main 56 llava-v1.6-34b √ x x x x https://huggingface.co/llava-hf/llava-v1.6-34b-hf/tree/main 57 internvl2-8B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-8B/tree/main 58 internvl2-26B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-26B/tree/main 59 internvl2-40B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-40B/tree/main 60 internVL2-Llama3-76B √ x x x x https://huggingface.co/OpenGVLab/InternVL2-Llama3-76B/tree/main 61 MiniCPM-v2.6 √ x x x x https://huggingface.co/openbmb/MiniCPM-V-2_6/tree/main 62 deepseek-v2-236b x x √ x x https://huggingface.co/deepseek-ai/DeepSeek-V2 63 deepseek-v2-lite-16b √ x √ x x https://huggingface.co/deepseek-ai/DeepSeek-V2-Lite 64 qwen2-vl-2B √ x x x x https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct/tree/main 65 qwen2-vl-7B √ x x x x https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct/tree/main 66 qwen2-vl-72B √ x x x x https://huggingface.co/Qwen/Qwen2-VL-72B-Instruct/tree/main 67 qwen-vl √ x x x x https://huggingface.co/Qwen/Qwen-VL 68 qwen-vl-chat √ x x x x https://huggingface.co/Qwen/Qwen-VL-Chat 69 MiniCPM-v2 √ x x x x https://huggingface.co/HwwwH/MiniCPM-V-2 注意:需要修改源文件site-packages/timm/layers/pos_embed.py,在第46行上面新增一行代码,如下: posemb = posemb.contiguous() #新增 posemb = F.interpolate(posemb, size=new_size, mode=interpolation, antialias=antialias) 各模型支持的卡数请参见附录:基于vLLM不同模型推理支持最小卡数和最大序列说明章节。
  • 约束限制 本方案目前仅适用于部分企业客户。 本文档适配昇腾云ModelArts 6.3.911版本,请参考软件配套版本获取配套版本的软件包,请严格遵照版本配套关系使用本文档。 推理部署使用的服务框架是vLLM。vLLM支持v0.6.3版本。 仅支持FP16和BF16数据类型推理。 本案例仅支持在专属资源池上运行。 专属资源池驱动版本要求23.0.6。 适配的CANN版本是cann_8.0.rc3。
  • Step3 启动kv-cache-int8量化服务 参考Step3 启动推理服务,启动推理服务时添加如下命令。 --kv-cache-dtype int8 #只支持int8,表示kvint8量化--quantization-param-path kv_cache_scales.json #输入Step2 抽取kv-cache量化系数生成的json文件路径; 如果只测试推理功能和性能,不需要此json文件,此时scale系数默认为1,但是可能会造成精度下降。
  • Step1使用tensorRT量化工具进行模型量化 在GPU机器上使用tensorRT 0.9.0版本工具进行模型量化,工具下载使用指导请参见https://github.com/NVIDIA/TensorRT-LLM/tree/v0.9.0。 执行如下脚本进行权重转换生成量化系数,详细参数解释请参见https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/llama#int8-kv-cache) python convert_checkpoint.py \--model_dir ./llama-models/llama-7b-hf \--output_dir ./llama-models/llama-7b-hf/int8_kv_cache/ \--dtype float16 \--int8_kv_cache 运行完成后,会在output_dir下生成量化后的权重。量化后的权重包括原始权重和kvcache的scale系数。
  • 使用SmoothQuant量化 SmoothQuant(W8A8)量化方案能降低模型显存以及需要部署的卡数。也能同时降低首token时延和增量推理时延。支持SmoothQuant(W8A8)量化的模型列表请参见支持的模型列表和权重文件。 本章节介绍如何使用SmoothQuant量化工具实现推理量化。 SmoothQuant量化工具使用到的脚本存放在代码包AscendCloud-LLM-x.x.x.zip的llm_tools目录下。 代码目录如下: AutoSmoothQuant #量化工具 ├── ascend_autosmoothquant_adapter # 昇腾量化使用的算子模块 ├── autosmoothquant # 量化代码 ├── build.sh # 安装量化模块的脚本 ... 具体操作如下: 参考Step1 环境准备创建pod准备量化环境。 执行如下命令进入容器,并进入AutoSmoothQuant目录下 kubectl exec -it {pod_name} bashcd /home/ma-user/AscendCloud/AscendCloud-LLM/llm_tools/AutoSmoothQuant/autosmoothquant/examples 配置需要使用的NPU卡,例如:实际使用的是第1张和第2张卡,此处填写为“0,1”,以此类推。 export ASCEND_RT_VISIBLE_DEVICES=0,1 通过命令npu-smi info查询NPU卡为容器中的第几张卡。例如下图查询出两张卡,如果希望使用第一和第二张卡,则“export ASCEND_RT_VISIBLE_DEVICES=0,1”,注意编号不是填4、5。 图1 查询结果 执行权重转换。 cd autosmoothquant/examples/python smoothquant_model.py --model-path /home/ma-user/llama-2-7b/ --quantize-model --generate-scale --dataset-path /data/nfs/user/val.jsonl --scale-output scales/llama2-7b.pt --model-output quantized_model/llama2-7b --per-token --per-channel 参数说明: --model-path:原始模型权重路径。 --quantize-model:体现此参数表示会生成量化模型权重。不需要生成量化模型权重时,不体现此参数 --generate-scale:体现此参数表示会生成量化系数,生成后的系数保存在--scale-output参数指定的路径下。如果有指定的量化系数,则不需此参数,直接读取--scale-input参数指定的量化系数输入路径即可。 --dataset-path:数据集路径,推荐使用:https://huggingface.co/datasets/mit-han-lab/pile-val-backup/resolve/main/val.jsonl.zst。 --scale-output:量化系数保存路径。 --scale-input:量化系数输入路径,如果之前已生成过量化系数,则可指定该参数,跳过生成scale的过程。 --model-output:量化模型权重保存路径。 --smooth-strength:平滑系数,推荐先指定为0.5,后续可以根据推理效果进行调整。 --per-token:激活值量化方法,如果指定则为per-token粒度量化,否则为per-tensor粒度量化。 --per-channel:权重量化方法,如果指定则为per-channel粒度量化,否则为per-tensor粒度量化。 启动smoothQuant量化服务。 参考部署推理服务,使用量化后权重部署AWQ量化服务。 注:Step3 创建服务启动脚本启动脚本中,服务启动命令需添加如下命令。 -q smoothquant 或者 --quantization smoothquant--dtype=float16 父主题: 推理模型量化
  • 步骤一:配置精度测试环境 精度评测可以在原先conda环境,进入到一个固定目录下,执行如下命令。 rm -rf lm-evaluation-harness/ git clone https://github.com/EleutherAI/lm-evaluation-harness.gitcd lm-evaluation-harnessgit checkout 383bbd54bc621086e05aa1b030d8d4d5635b25e6pip install -e . 执行如下精度测试命令,可以根据参数说明修改参数。 lm_eval --model vllm --model_args pretrained=${vllm_path},dtype=auto,tensor_parallel_size=${tensor_parallel_size},gpu_memory_utilization=${gpu_memory_utilization},add_bos_token=True,max_model_len=${max_model_len},quantization=${quantization} \--tasks ${task} --batch_size ${batch_size} --log_samples --cache_requests true --trust_remote_code --output_path ${output_path} 参数说明: model_args:标志向模型构造函数提供额外参数,比如指定运行模型的数据类型; vllm_path是模型权重路径; max_model_len 是最大模型长度,默认设置为4096; gpu_memory_utilization是gpu利用率,如果模型出现oom报错,调小参数; tensor_parallel_size是使用的卡数; quantization是量化参数,使用非量化权重,去掉quantization参数;如果使用awq、smoothquant或者gptq加载的量化权重,根据量化方式选择对应参数,可选awq,smoothquant,gptq。 model:模型启动模式,可选vllm,openai或hf,hf代表huggingface。 tasks:评测数据集任务,比如openllm。 batch_size:输入的batch_size大小,不影响精度,只影响得到结果速度,默认使用auto,代表自动选择batch大小。 output_path:结果保存路径。 使用lm-eval,比如加载非量化或者awq量化,llama3.2-1b模型的权重,参考命令: lm_eval --model vllm --model_args pretrained="/data/nfs/benchmark/tokenizer/Llama-3.2-1B-Instruct/",dtype=auto,tensor_parallel_size=1,gpu_memory_utilization=0.7,add_bos_token=True,max_model_len=4096 \--tasks openllm --batch_size auto --log_samples --cache_requests true --trust_remote_code --output_path ./ 使用lm-eval,比如smoothquant量化,llama3.1-70b模型的权重,参考命令: lm_eval --model vllm --model_args pretrained="/data/nfs/benchmark/tokenizer_w8a8/llama3.1-70b/",dtype=auto,tensor_parallel_size=4,gpu_memory_utilization=0.7,add_bos_token=True,max_model_len=4096,quantization="smoothquant" \--tasks openllm --batch_size auto --log_samples --cache_requests true --trust_remote_code --output_path ./
共99354条