README.md 3.46 KB
Newer Older
luopl's avatar
luopl committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
## DeepSeek-V4
## 论文
[DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro/blob/main/DeepSeek_V4.pdf)

## 模型简介
DeepSeek-V4 系列的预览版本,包含两款强大的混合专家(Mixture-of-Experts, MoE)语言模型:DeepSeek-V4-Pro(总参数量 1.6T,激活参数量 49B)和 DeepSeek-V4-Flash(总参数量 284B,激活参数量 13B),两者均支持 百万 token 的上下文长度。

DeepSeek-V4 系列在架构与优化方面引入了多项关键升级:

- 混合注意力架构:设计了一种混合注意力机制,结合压缩稀疏注意力(Compressed Sparse Attention, CSA)与重度压缩注意力(Heavily Compressed Attention, HCA),显著提升长上下文处理效率。在百万 token 上下文场景下,DeepSeek-V4-Pro 相比 DeepSeek-V3.2 仅需 27% 的单 token 推理 FLOPs 和 10% 的 KV 缓存。
- 流形约束超连接(Manifold-Constrained Hyper-Connections, mHC):在传统残差连接基础上引入 mHC,增强跨层信号传播的稳定性,同时保留模型的表达能力。
- Muon 优化器:采用 Muon 优化器,以实现更快的收敛速度和更高的训练稳定性。

## 环境依赖
| 软件 |   版本    |
| :------: |:-------:|
|     DTK      |  26.04  |
|    python    | 3.10.12 |
|    torch     |  2.9.0+das.opt1.dtk2604.20260331.g4e3c1e7  |
|    tilelang     |  0.1.7.post3+cpu.git52700923  |


luopl's avatar
luopl committed
23
当前仅支持镜像:harbor.sourcefind.cn:5443/dcu/admin/base/custom:torch-2.9.0-ubuntu22.04-dtk26.04-deepseek-v4-0425
luopl's avatar
luopl committed
24
25
26
27
28
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
55

- 挂载地址`-v`根据实际模型情况修改

```bash
docker run -it \
    --shm-size 200g \
    --network=host \
    --name deepseek-v4 \
    --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:torch-2.9.0-ubuntu22.04-dtk26.04-deepseek-v4-0425 bash
```

更多镜像可前往[光源](https://sourcefind.cn/#/service-list)下载使用。

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

## 数据集
`暂无`

## 训练
`暂无`

## 推理
luopl's avatar
luopl committed
56
### Pytorch
luopl's avatar
luopl committed
57
58
59
60
61
62
63
64
65
66
67
68
69
#### 单机推理
1. 模型转换与切分

```bash
#注意将脚本中对应的路径及参数设置成用户实际值
#其中:INPUT_FP8_HF_PATH为模型下载路径;OUTPUT_BF16_HF_PATH为bf16模型存放路径;SAVE_PATH为切分好的模型路径;mp根据实际卡数调整
cd convert_weight
bash convert_weight.sh
```

2. 启动对话推理
```bash
#注意将脚本中对应的路径及参数设置成用户实际值
luopl's avatar
luopl committed
70
cd ../inference
luopl's avatar
luopl committed
71
72
73
74
sh start_torch.sh
```

## 效果展示
luopl's avatar
luopl committed
75
76
77

**注意**:首次对话时由于kernel编译,可能会出现dtk hipcc编译警告,属于正常现象

luopl's avatar
luopl committed
78
79
80
81
82
83
84
85
86
87
<div align=center>
    <img src="./doc/result_dcu.png"/>
</div>

### 精度
`DCU与GPU精度一致,推理框架:pytorch。`

## 预训练权重
| 模型名称  | 权重大小 | DCU型号  | 最低卡数需求 |下载地址|
|:-----:|:----:|:------:|:------:|:----------:|
luopl's avatar
luopl committed
88
| DeepSeek-V4-Flash | 284B | BW1100 |   8    | [Hugging Face](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash) |
luopl's avatar
luopl committed
89
90
91
92
93
94

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

## 参考资料
- https://github.com/deepseek-ai