当前位置: 首页 > news >正文

大模型推理引擎vLLM(10): vLLM 分布式推理源码结构解析

文章目录

  • 1 why distributed inference
  • 2 DP EP PP TP
    • 2.1 TP
      • 2.1.1 工程层面怎么通信
      • 2.1.2 算法层面
    • 2.2 PP
    • 2.3 EP
    • 2.4 DP
  • 参考文献

这篇博客是在看[EP02][精剪版]分布式推理优化,vllm源码解读这个学习视频时做的简单笔记,感兴趣的可以直接去看原视频。

1 why distributed inference

其实就是因为一张卡跑大模型跑不开了,还有其他原因就是分布式推理能够加快模型的推理优化。

2 DP EP PP TP

2.1 TP

vllm/vllm/distributed/parallel_state.py这个文件里面有为传统的parallel提供的一系列接口,
下面的这个数据结构就是用来分布式通信的

# message queue broadcaster is only used in tensor model parallel group_TP=init_model_parallel_group(group_ranks,get_world_group().local_rank,backend,use_message_queue_broadcaster=True,group_name="tp")

然后实际上用的是这个类class GroupCoordinator:
下面的参数是他的属性

# available attributes:rank:int# global rankranks:list[int]# global ranks in the groupworld_size:int# size of the group# difference between `local_rank` and `rank_in_group`:# if we have a group of size 4 across two nodes:# Process | Node | Rank | Local Rank | Rank in Group# 0 | 0 | 0 | 0 | 0# 1 | 0 | 1 | 1 | 1# 2 | 1 | 2 | 0 | 2# 3 | 1 | 3 | 1 | 3local_rank:int# local rank used to assign devicesrank_in_group:int# rank inside the groupcpu_group:ProcessGroup# group for CPU communicationdevice_group:ProcessGroup# group for device communicationuse_device_communicator:bool# whether to use device communicatordevice_communicator:DeviceCommunicatorBase# device communicatormq_broadcaster:Optional[Any]# shared memory broadcaster

2.1.1 工程层面怎么通信

2.1.2 算法层面

vllm/vllm/distributed/device_communicators这个目录里面是通信相关的代码,
还可以看一下vllm/vllm/model_executor/models/llama.py这里面的管宇TP PP的代码,初学者学代码先用llama要比用deepseek更好,
deepseek模型结构更复杂

2.2 PP

2.3 EP

2.4 DP

参考文献

[EP02][精剪版]分布式推理优化,vllm源码解读

http://www.jsqmd.com/news/399175/

相关文章:

  • 大专数据可视化技术专业学习数据分析的价值
  • 高职统计与会计核算专业学数据分析的价值分析
  • Manim CE v0.20.0 发布:动画构建更丝滑,随机性终于“可控”了!
  • 2026年苏州可靠的家教机构怎么收费,家教/全托补习班/一对一家教试听课/上门家教/师范家教/全托冲刺,家教机构有哪些 - 品牌推荐师
  • k8s服务发现
  • Verify-in-the-Graph 利用交互式图表示增强实体消歧的复杂声明验证方法
  • nsq阅读(2)——diskqueue
  • golang sync包源码阅读
  • CausalMamba 面向时序谣言因果关系的可解释状态空间建模
  • 质数筛小记
  • 请不要再称数据库是CP或者AP (Please stop calling databases CP or AP)
  • TARD 基于测试时自适应的分布外谣言检测
  • 堆 vs 胜者树 vs 败者树
  • nsq阅读(3)——nsqd
  • 什么是“梯度消失”和“梯度爆炸”?
  • tcmalloc小记
  • 分布式事务综述
  • Golang http源码阅读
  • 场景
  • nsq阅读(1)——概述
  • 向量数据库概述
  • python private属性
  • HyperLogLog原理
  • 字节RPC框架kitex源码阅读(一)
  • 参考文献崩了?一键生成论文工具 千笔·专业学术智能体 VS Checkjie 专科生写作神器
  • gRPC阅读(1)—— 服务端
  • 银行纷纷盯上了压岁钱,儿童金融会是银行的新蓝海吗?
  • 阅读清单
  • jekyll chrispy主题的语法