ref(upstream): FULL TREE — Deep-Spark xllm (1470) + ds_vllm csrc/models (703)
Replaces cherry-picked upstream_ref with complete source trees. xllm/ — Iluvatar official C++ inference engine (15MB, 1470 files) Complete: kernels → layers → models → runtime → scheduler → api Excluded: .git, binary images, third_party submodule checkouts ds_vllm/ — Iluvatar official vllm fork (8MB, 703 files) Included: csrc/ (ALL CUDA kernels), fused_moe/, qwen3_5 model, _custom_ops Excluded: tests, benchmarks, docs, examples (not needed for reference) Critical call chains now fully traceable: MoE: moe_topk_softmax_kernels.cuh → ixformer.h → fused_moe.cpp → layer GDN: qwen3_gated_delta_net_base.cpp → qwen3_5_gated_delta_net.cpp Attention: ixformer.h → xllm_paged_attention → attention.cpp
This commit is contained in:
27
upstream_ref/xllm/docs/zh/features/topk_topP.md
Normal file
27
upstream_ref/xllm/docs/zh/features/topk_topP.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Topk&Topp算子优化
|
||||
|
||||
## 背景
|
||||
在自然语言生成任务中,topK和topP采样策略被广泛应用于控制生成文本的多样性和质量。然而,在小模型中,这两种策略的计算耗时相对较长。这主要是由于小模型的参数较少,导致在处理概率分布时,排序和筛选的效率降低,从而影响了生成速度。因此,优化小模型中topK和topP的实现,可以提升其采样效率。
|
||||
|
||||
|
||||
## 功能介绍
|
||||
|
||||
topKtopP算子的实现将排序、topK、softmax和topP等多个小算子融合为一个大算子,从而提高了计算效率和性能。
|
||||
|
||||
|
||||
## 用户接口
|
||||
### 算子调用API
|
||||
```c++
|
||||
void top_k_top_p(torch::Tensor& logits,
|
||||
const torch::Tensor& topK,
|
||||
const torch::Tensor& topP);
|
||||
```
|
||||
|
||||
- `logits`: 输入的logits张量,包含模型的输出分数。
|
||||
- `topK`: 用于选择的前K个概率的阈值张量。
|
||||
- `topP`: 用于选择的累积概率的阈值张量。
|
||||
|
||||
|
||||
## 性能效果
|
||||
|
||||
* 使用topKtopP融合算子后,在qwen2-0.5B模型中,TTOT **下降37%**,TTFT **提升10%**。
|
||||
Reference in New Issue
Block a user