experiment moe router topk softmax

This commit is contained in:
2026-07-15 04:19:56 +08:00
parent 16d52b469c
commit eea0653ace
3 changed files with 179 additions and 6 deletions

View File

@@ -1014,3 +1014,51 @@ KeyError: 'invalid tool call parser: qwen3_coder (chose from { hermes,internlm,l
2. 快速性能迭代优先用 100K/cap40K 官方相似数据,减少单轮成本。
3. 确定有效优化后,再回到 245K 配置做确认。
4. 当前离目标最大的差距仍是 prefill/cache 吞吐和 decode MoE 吞吐,而不是缓存命中率或请求成功率。
## 2026-07-15MoE router top-k softmax 实验
### 改动
尝试把 MoE router 从:
```python
routing_weights = torch.softmax(router_logits.float(), dim=-1)
topk_weights, topk_ids = torch.topk(routing_weights, self.top_k, dim=-1)
topk_weights = topk_weights / topk_weights.sum(dim=-1, keepdim=True)
```
改为:
```python
topk_logits, topk_ids = torch.topk(router_logits.float(), self.top_k, dim=-1)
topk_weights = torch.softmax(topk_logits, dim=-1)
```
数学上这等价于 “full softmax -> topk -> renormalize”但避免了完整 `(T, num_experts)` softmax。预期收益主要来自减少每层 decode 路由开销。
### 结果
本地归档:
- `worklogs/remote_results/2026-07-15-official-like-baseline/eager_100k_router_topk_c1_r8_t256_cap40k.json`
| 指标 | 100K 基线 | router top-k softmax | 目标 |
| --- | ---: | ---: | ---: |
| Success Rate | 100.00% | 100.00% | >= 99% |
| Cache Hit Rate | 74.17% | 74.17% | >= 50% |
| TTFT P90 | 9.803s | 13.048s | <= 5s |
| Output TPS P10 | 5.825 | 5.664 | >= 20 |
| Aggregate Output TPS | 5.789 | 5.379 | - |
| Uncached Input TPS | 178.330 | 172.454 | - |
| Cache TPS | 512.015 | 495.142 | - |
| Weighted Throughput | 883.109 | 850.328 | >= 8000 |
### 结论
该改动没有带来收益,反而略降。可能原因:
- full softmax 相对 expert GEMM 和 TP all-reduce 占比很小;
- topk logits 后 softmax 改变了 kernel 调度形态,但没有减少主瓶颈;
- 小样本中输出 token 数不同,仍需看趋势而不是单条。
操作结论:不保留该代码改动,回退到 full-softmax router。下一步继续围绕 MoE expert GEMM、all-reduce、prefill/cache 路径做实验。