Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
ai
chatCSDN
提交
00e7b66f
C
chatCSDN
项目概览
CSDN 技术社区
/
ai
/
chatCSDN
通知
107
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
chatCSDN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
00e7b66f
编写于
3月 20, 2023
作者:
U
u010280923
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt ppo model
上级
ade381c4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
17 deletion
+15
-17
src/model.py
src/model.py
+2
-3
src/rlhf/ppo.py
src/rlhf/ppo.py
+0
-1
train_ppo.py
train_ppo.py
+13
-13
未找到文件。
src/model.py
浏览文件 @
00e7b66f
...
...
@@ -503,10 +503,9 @@ class RWKV(pl.LightningModule):
pad_value
=
0.
,
eos_token
=
None
,
return_seq_without_prompt
=
True
,
use_tqdm
=
False
,
**
kwargs
use_tqdm
=
False
):
'''
'''
生成 response,用于 ppo 模型的训练
'''
prompt
,
leading_dims
=
pack
([
prompt
],
'* n'
)
...
...
src/rlhf/ppo.py
浏览文件 @
00e7b66f
...
...
@@ -453,7 +453,6 @@ class RLHF(pl.LightningModule):
return
{
'actor_loss'
:
actor_loss
.
item
(),
'critic_loss'
:
critic_loss
.
item
()}
@
torch
.
no_grad
()
def
make_experience
(
self
,
prompts
,
eos_token
=
None
,
temperature
=
1
):
''' 通过与 environment 交互产生训练数据
'''
...
...
train_ppo.py
浏览文件 @
00e7b66f
...
...
@@ -296,6 +296,19 @@ if __name__ == "__main__":
callbacks
=
[
rlhf_train_callback
(
args
)],
)
if
trainer
.
global_rank
==
0
:
for
n
in
rlhf_model
.
state_dict
():
shape
=
rlhf_model
.
state_dict
()[
n
].
shape
shape
=
[
i
for
i
in
shape
if
i
!=
1
]
if
len
(
shape
)
>
1
:
print
(
f
"
{
str
(
shape
[
0
]).
ljust
(
5
)
}
{
str
(
shape
[
1
]).
ljust
(
5
)
}
{
n
}
"
)
else
:
print
(
f
"
{
str
(
shape
[
0
]).
ljust
(
5
)
}
{
n
}
"
)
if
"deepspeed"
in
args
.
strategy
:
trainer
.
strategy
.
config
[
"zero_optimization"
][
"allgather_bucket_size"
]
=
args
.
ds_bucket_mb
*
1000
*
1000
trainer
.
strategy
.
config
[
"zero_optimization"
][
"reduce_bucket_size"
]
=
args
.
ds_bucket_mb
*
1000
*
1000
time_cnt
=
0
for
eps
in
tqdm
(
range
(
args
.
num_episodes
),
desc
=
'episodes'
):
for
timestep
in
range
(
args
.
max_timesteps
):
...
...
@@ -307,19 +320,6 @@ if __name__ == "__main__":
# learn from the stored memories
if
time_cnt
%
args
.
update_timesteps
==
0
:
if
trainer
.
global_rank
==
0
:
for
n
in
rlhf_model
.
state_dict
():
shape
=
rlhf_model
.
state_dict
()[
n
].
shape
shape
=
[
i
for
i
in
shape
if
i
!=
1
]
if
len
(
shape
)
>
1
:
print
(
f
"
{
str
(
shape
[
0
]).
ljust
(
5
)
}
{
str
(
shape
[
1
]).
ljust
(
5
)
}
{
n
}
"
)
else
:
print
(
f
"
{
str
(
shape
[
0
]).
ljust
(
5
)
}
{
n
}
"
)
if
"deepspeed"
in
args
.
strategy
:
trainer
.
strategy
.
config
[
"zero_optimization"
][
"allgather_bucket_size"
]
=
args
.
ds_bucket_mb
*
1000
*
1000
trainer
.
strategy
.
config
[
"zero_optimization"
][
"reduce_bucket_size"
]
=
args
.
ds_bucket_mb
*
1000
*
1000
train_data
=
PPODataset
(
memory
)
data_loader
=
DataLoader
(
train_data
,
shuffle
=
False
,
pin_memory
=
True
,
batch_size
=
args
.
micro_bsz
,
num_workers
=
1
,
persistent_workers
=
False
,
drop_last
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录