前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >VLLM推理流程解析

VLLM推理流程解析

作者头像
BBuf
发布2023-08-22 09:20:29
1.6K0
发布2023-08-22 09:20:29
举报
文章被收录于专栏:GiantPandaCV

0x0. 前言

本文在对VLLM进行解析时只关注单卡情况,忽略基于ray做分布式推理的所有代码。

0x1. 运行流程梳理

先从使用VLLM调用opt-125M模型进行推理的脚本看起:

代码语言:javascript
复制
from vllm import LLM, SamplingParams

# Sample prompts.
prompts = [
    "Hello, my name is",
    "The president of the United States is",
    "The capital of France is",
    "The future of AI is",
]
# Create a sampling params object.
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)

# Create an LLM.
llm = LLM(model="facebook/opt-125m")
# Generate texts from the prompts. The output is a list of RequestOutput objects
# that contain the prompt, generated text, and other information.
outputs = llm.generate(prompts, sampling_params)
# Print the outputs.
for output in outputs:
    prompt = output.prompt
    generated_text = output.outputs[0].text
    print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")

...

完整文章清移步知乎,这个是最近有空时逐步走读了下vllm的流程,还不包含paged attention的实现具体解析,后续有空会把这paged attention这一节的 kernel 实现细节补一下

地址:https://zhuanlan.zhihu.com/p/649974825 & https://zhuanlan.zhihu.com/p/649977422

参考:https://zhuanlan.zhihu.com/p/641999400

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-08-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 GiantPandaCV 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 0x0. 前言
  • 0x1. 运行流程梳理
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档