《王玺源《基于昇腾CANN的训推开源软件支持与实践》.pdf》由会员分享,可在线阅读,更多相关《王玺源《基于昇腾CANN的训推开源软件支持与实践》.pdf(32页珍藏版)》请在三个皮匠报告上搜索。
1、基于昇腾CANN的训推开源软件支持与实践演讲人:王玺源能运行 权重文件 模型结构 运行脚本能复现训练数据训练方法随机种子能落地加速技术调优方法集群部署开源大模型开源了什么易用、高性能的开源全栈推理服务框架开源时间:2023年6月开源组织:伯克利Sky Computing Lab(前RISELab、AMPLab),曾孵 化出了Apache Spark、Ray、Alluxio等著名开源项目。项目介绍:vLLM 以PagedAttention 为核心算法提升内存利用率,支持 100+生成式大语言模型,能够做到与 Hugging Face Transformers 相比 24 倍的吞吐量。竞争力特性:
2、PagedAttetion为起点,逐渐新增主流推理特性,学习Pytorch,以易用性和多样性为主打卖点。能运行权重文件:基于pytorch和HF safetensor,原生支持,无需转换模型结构:基于Pytorch重写,原生支持HF transformers运行脚本:vLLM自研实现多种运行方式能落地加速技术:自研支持Paged Attention算法,支持Chunked Prefil、Prefix Cache、PD分离等加速技术,支持各种量化算法,支持pile图模式,支持trition等自定义算子调优方法:支持多种Lora微调方法,支持海量自定义参数,支持benchmark打点分析。集群部署
3、:支持在线/离线,支持多机多卡,支持MP、Ray、Kubernetes多种部署方式from vllm import LLM,SamplingParams#用户输入prompts=Hello,my name is,The president of the United States is,The capital of France is,The future of AI is,#初始化vLLM,载入模型llm=LLM(model=Qwen/Qwen2.5-0.5B-Instruct)#执行推理outputs=llm.generate(prompts,sampling_params)#打印输出fo
4、r output in outputs:prompt=output.promptgenerated_text=output.outputs0.textprint(fPrompt:prompt!r,Generated text:generated_text!r)config.jsonqwen.safetensorQwen2ForCausalLM1.读取config.json,获取模型结构名称2.初始化模型,载入模型权重https:/huggingface.co/Qwen/Qwen2.5-0.5B-Instructclass Qwen2ForCausalLMself.model=Qwen2Mode
5、lself.logits_processorself.samplerclass Qwen2Modelself.embed_tokensself.layers=Qwen2DecoderLayer,Qwen2DecoderLayer,.self.normclass Qwen2DecoderLayerself.self_attn=Qwen2Attentionself.mlp=Qwen2MLPself.input_layernormself.post_attention_layernormclass Qwen2Attentionself.attn=Attentionself.qkv_projself.
6、o_projself.rotary_embclass Qwen2MLPself.act_fn=SiluAndMulself.gate_up_projself.down_projhttps:/ vllm import LLM,SamplingParams#用户输入prompts=Hello,my name is,The president of the United States is,The capital of France is,The future of AI is,#初始化vLLM,载入模型llm=LLM(model=Qwen/Qwen2.5-0.5B-Instruct)#执行推理ou