README.md 8.07 KB
Newer Older
dengjb's avatar
update  
dengjb committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Kimi-K2.6
## 论文
[Kimi-K2.6](https://www.kimi.com/blog/kimi-k2-6)

## 模型简介
Kimi K2.6 是一个开源的原生多模态智能体模型,在长周期编程、以编程驱动的设计、主动自主执行以及基于智能体集群的任务编排等实际能力方面取得了显著进展。

**主要特点**
- 长周期编程:K2.6 在复杂的端到端编程任务上实现了显著提升,能够稳健地泛化至多种编程语言(Rust、Go、Python)以及前端、DevOps 和性能优化等多个领域。
- 编程驱动设计:K2.6 能够将简单的文本提示和视觉输入转化为可直接投入生产的界面和轻量级全栈工作流,精准生成结构化布局、交互元素和丰富的动画效果。
- 增强型智能体集群:支持横向扩展至 300 个子智能体并行执行 4,000 个协调步骤,K2.6 能动态地将任务分解为多个并行、领域专用的子任务,在单次自主运行中即可完成从文档、网站到电子表格的端到端输出。
- 主动式开放编排:在自主任务方面,K2.6 展现出强大能力,可驱动持久运行的 24/7 后台智能体,无需人工干预即可主动管理日程、执行代码,并协调跨平台操作。

<div align=center>
    <img src="./doc/kimi-bar-chart.png"/>
</div>

## 环境依赖
| 软件 |                    版本                     |
| :------: |:-----------------------------------------:|
| DTK |                   26.04                   |
22
| Python |                  3.10.12                  |
dengjb's avatar
update  
dengjb committed
23
24
| Transformers |                4.57.6                 |
| vLLM |       0.15.1+das.opt1.alpha.dtk2604.20260220.g2799735a       |
25
| SGLang | 0.5.10rc0+das.opt2.alpha.dtk2604 |
dengjb's avatar
update  
dengjb committed
26

27
28
- **vLLM推理请使用:** harbor.sourcefind.cn:5443/dcu/admin/base/custom:vllm0.15.1-ubuntu22.04-dtk26.04-0130-py3.10-20260220
- **SGLang推理请使用:** harbor.sourcefind.cn:5443/dcu/admin/base/custom:sglang0.5.10rc0-ubuntu22.04-dtk26.04-py3.10-20260428
dengjb's avatar
update  
dengjb committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

- 挂载地址`-v` 根据实际模型情况修改
```bash
docker run -it \
    --shm-size 200g \
    --network=host \
    --name Kimi-K2.6 \
    --privileged \
    --device=/dev/kfd \
    --device=/dev/dri \
    --device=/dev/mkfd \
    --group-add video \
    --cap-add=SYS_PTRACE \
    --security-opt seccomp=unconfined \
    -u root \
    -v /opt/hyhal/:/opt/hyhal/:ro \
    -v /path/your_code_data/:/path/your_code_data/ \
    harbor.sourcefind.cn:5443/dcu/admin/base/custom:vllm0.15.1-ubuntu22.04-dtk26.04-0130-py3.10-20260220 bash
```
更多镜像可前往[光源](https://sourcefind.cn/#/service-list)下载使用。

关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.sourcefind.cn/tool/)开发者社区下载安装,pycountry库需要单独安装:
```
pip install pycountry
```

55
56
57
58
59
## 预训练权重
**请根据`支持的DCU型号`选择对应模型下载,FP8模型仅在BW1100/BW1101上支持,其他型号请勿使用!**

| 模型名称 | 权重大小 | 数据类型 | 支持的DCU型号 | 最低卡数需求 | 下载地址 |
|:-----:|:----------:|:----------:|:----------:|:---------------------:|:----------:|
weishb's avatar
weishb committed
60
61
| Kimi-K2.6 | 1.1T | INT4 | BW1000 | 16 | [Hugging Face](https://huggingface.co/moonshotai/Kimi-K2.6)  |
| Kimi-K2.6 | 1.1T | INT4 | BW1100 | 8 | [Hugging Face](https://huggingface.co/moonshotai/Kimi-K2.6) |
62

dengjb's avatar
update  
dengjb committed
63
64
65
66
67
68
69
## 数据集
暂无

## 训练
暂无

## 推理
dengjb's avatar
update  
dengjb committed
70
### vLLM
dengjb's avatar
update  
dengjb committed
71
72
73
74
75
76
#### 单机推理
1.启动vllm server
```bash
## serve启动

vllm serve moonshotai/Kimi-K2.6 \
dengjb's avatar
update  
dengjb committed
77
    -tp 8 \
dengjb's avatar
update  
dengjb committed
78
79
80
81
82
83
84
85
86
87
88
89
    --gpu-memory-utilization 0.95 \
    --mm-encoder-tp-mode data \
    --trust-remote-code \
    --tool-call-parser kimi_k2 \
    --reasoning-parser kimi_k2

## client访问
curl http://localhost:8000/v1/chat/completions   \
    -H "Content-Type: application/json"  \
    -d '{
        "model": "moonshotai/Kimi-K2.6",
        "messages": [
dengjb's avatar
update  
dengjb committed
90
          {"role": "user", "content": "which one is bigger, 9.11 or 9.9? think carefully"}
dengjb's avatar
update  
dengjb committed
91
92
93
94
95
        ],
        "temperature": 0.6
    }'
```

dengjb's avatar
update  
dengjb committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#### 多机推理
1. 加入环境变量
> 请注意:
> 每个节点上的环境变量都写到.sh文件中,保存后各个计算节点分别source`.sh`文件
>
> VLLM_HOST_IP:节点本地通信口ip,尽量选择IB网卡的IP,**避免出现rccl超时问题**
>
> NCCL_SOCKET_IFNAME和 GLOO_SOCKET_IFNAME:节点本地通信网口ip对应的名称
>
> 通信口和ip查询方法:ifconfig
>
> IB口状态查询:ibstat  !!!一定要active激活状态才可用,各个节点要保持统一

```bash
export ALLREDUCE_STREAM_WITH_COMPUTE=1
export VLLM_HOST_IP=x.x.x.x # 对应计算节点的IP,选择IB口SOCKET_IFNAME对应IP地址
export NCCL_SOCKET_IFNAME=ibxxxx
export GLOO_SOCKET_IFNAME=ibxxxx
export NCCL_IB_HCA=mlx5_0:1 # 环境中的IB网卡名字
unset NCCL_ALGO
export NCCL_MIN_NCHANNELS=16
export NCCL_MAX_NCHANNELS=16
export NCCL_NET_GDR_READ=1
export HIP_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export VLLM_SPEC_DECODE_EAGER=1
export VLLM_MLA_DISABLE=0
export VLLM_USE_FLASH_MLA=1
export VLLM_RPC_TIMEOUT=1800000

# 海光CPU绑定核
export VLLM_NUMA_BIND=1
export VLLM_RANK0_NUMA=0
export VLLM_RANK1_NUMA=1
export VLLM_RANK2_NUMA=2
export VLLM_RANK3_NUMA=3
export VLLM_RANK4_NUMA=4
export VLLM_RANK5_NUMA=5
export VLLM_RANK6_NUMA=6
export VLLM_RANK7_NUMA=7
```

2. 启动RAY集群
> x.x.x.x 对应第一步 VLLM_HOST_IP

```bash
# head节点执行
ray start --head --node-ip-address=x.x.x.x --port=6379 --num-gpus=8 --num-cpus=32
# worker节点执行
ray start --address='x.x.x.x:6379' --num-gpus=8 --num-cpus=32
```

3. 启动vllm server

```bash
## serve启动

vllm serve moonshotai/Kimi-K2.6 \
    -tp 16 \
    --distributed-executor-backend ray \
    --gpu-memory-utilization 0.95 \
    --mm-encoder-tp-mode data \
    --trust-remote-code \
    --tool-call-parser kimi_k2 \
    --reasoning-parser kimi_k2

## client访问
curl http://localhost:8000/v1/chat/completions   \
    -H "Content-Type: application/json"  \
    -d '{
        "model": "moonshotai/Kimi-K2.6",
        "messages": [
          {"role": "user", "content": "which one is bigger, 9.11 or 9.9? think carefully"}
        ],
        "temperature": 0.6
    }'
```

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
### SGLang
#### 单机推理
```bash
#serve启动
export HIP_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export SGLANG_USE_LIGHTOP=1
export SGLANG_USE_OPT_CAT=1
export USE_DCU_CUSTOM_ALLREDUCE=1
export SGL_CHUNKED_PREFIX_CACHE_THRESHOLD=0
export SGLANG_DISAGGREGATION_BOOTSTRAP_TIMEOUT=1200
export GLIBC_TUNABLES=glibc.rtld.optional_static_tls=0x40000
export HIP_GRAPH_ACCUMULATE_DISPATCH=0
export SGLANG_TORCH_PROFILER_DIR=/workspace/profiling
export SGLANG_KVALLOC_KERNEL=1
export SGLANG_CREATE_EXTEND_AFTER_DECODE_SPEC_INFO=1
export SGLANG_ASSIGN_EXTEND_CACHE_LOCS=1
export SGLANG_ASSIGN_REQ_TO_TOKEN_POOL=1
export SGLANG_GET_LAST_LOC=1
export SGLANG_CREATE_FLASHMLA_KV_INDICES_TRITON=1
export SGLANG_CREATE_CHUNKED_PREFIX_CACHE_KV_INDICES=1
export NCCL_MAX_NCHANNELS=16
export NCCL_MIN_NCHANNELS=16
export ALLREDUCE_STREAM_WITH_COMPUTE=1

python3 -m sglang.launch_server \
  --model-path /path/to/model/Kimi-K2.5 \
  --kv-cache-dtype fp8_e4m3 \
  --host $(hostname -I | awk '{print $1}') \
  --port 30000 \
  --trust-remote-code \
  --page-size 64 \
  --dist-init-addr $(hostname -I | awk '{print $1}'):5001 \
  --reasoning-parser kimi_k2 \
  --tool-call-parser kimi_k2 \
  --nnodes 1 \
  --node-rank 0 \
  --dtype bfloat16 \
  --tp-size 8 \
  --pp-size 1 \
  --mem-fraction-static 0.98 \
  --attention-backend dcu_mla \
  --enable-torch-compile \
  --numa-node 0 0 0 0 1 1 1 1 \
  --chunked-prefill-size -1 \
  --max-running-requests 512 \
  --context-length 65536

## client访问
curl http://10.16.1.15:30000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
      "model": "/path/to/model/Kimi-K2.5 ",
      "messages": [
        {"role": "user", "content": "你好,请用一句话介绍你自己。"}
      ],
      "max_tokens": 128,
      "temperature": 0.6
    }'
```

dengjb's avatar
update  
dengjb committed
233
234
235
236
237
238
## 效果展示
<div align=center>
    <img src="./doc/result-dcu.png"/>
</div>

### 精度
239
DCU与GPU精度一致,推理框架:vllm,sglang
dengjb's avatar
update  
dengjb committed
240
241
242
243
244

## 源码仓库及问题反馈
- https://developer.sourcefind.cn/codes/modelzoo/kimi-k2.6

## 参考资料
dengjb's avatar
update  
dengjb committed
245
- https://www.modelscope.cn/models/moonshotai/Kimi-K2.6/summary