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:
EX Engine
2026-08-10 02:53:54 +00:00
parent 9e4fb3712f
commit 002f9879b2
2179 changed files with 494021 additions and 79 deletions

View 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%**