Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
DeepSpeed
提交
f1fab902
D
DeepSpeed
项目概览
Greenplum
/
DeepSpeed
上一次同步 大约 1 年
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeed
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f1fab902
编写于
5月 09, 2023
作者:
L
LiYu Lu
提交者:
GitHub
5月 08, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix spelling error (#3482)
Co-authored-by:
N
Logan Adams
<
114770087+loadams@users.noreply.github.com
>
上级
87edbc8d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
15 addition
and
15 deletion
+15
-15
csrc/transformer/inference/csrc/pt_binding.cpp
csrc/transformer/inference/csrc/pt_binding.cpp
+14
-14
csrc/transformer/inference/includes/inference_context.h
csrc/transformer/inference/includes/inference_context.h
+1
-1
未找到文件。
csrc/transformer/inference/csrc/pt_binding.cpp
浏览文件 @
f1fab902
...
...
@@ -143,7 +143,7 @@ at::Tensor einsum_sec_sm_ecm(at::Tensor& Q, at::Tensor& W)
/*
// Reallocate memory if we received a new prompt
if (!workspace || input.size(1) != 1) {
allocate_workspace<T>(W.size(1), InferenceContext::Instance().GetMaxTokenLeng
ht
(),
allocate_workspace<T>(W.size(1), InferenceContext::Instance().GetMaxTokenLeng
th
(),
Q.size(0), 1, head_size); workspace = (T*)InferenceContext::Instance().GetWorkSpace();
}
*/
...
...
@@ -384,7 +384,7 @@ void attention_unfused(T* prev_key_cont,
workspace
,
CUBLAS_OP_T
,
CUBLAS_OP_N
,
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
()
*
k
,
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
()
*
k
,
seq_len
*
k
,
seq_len
*
soft_len
,
bsz
*
heads
,
...
...
@@ -417,7 +417,7 @@ void attention_unfused(T* prev_key_cont,
(
T
*
)
output
,
CUBLAS_OP_N
,
CUBLAS_OP_N
,
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
()
*
k
,
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
()
*
k
,
seq_len
*
soft_len
,
seq_len
*
k
,
bsz
*
heads
,
...
...
@@ -468,11 +468,11 @@ std::vector<at::Tensor> ds_softmax_context(at::Tensor& query_key_value,
auto
query_cont
=
workspace
+
5
*
buf_size
;
size_t
offset
=
10
*
(
hidden_dim
*
bsz
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
())
+
layer_id
*
2
*
bsz
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
()
*
hidden_dim
;
10
*
(
hidden_dim
*
bsz
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
())
+
layer_id
*
2
*
bsz
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
()
*
hidden_dim
;
unsigned
all_tokens
=
soft_len
;
auto
kv_cache
=
workspace
+
offset
+
(
hidden_dim
/
heads
)
*
(
is_prompt
?
0
:
soft_len
-
1
);
size_t
value_offset
=
bsz
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
()
*
hidden_dim
;
size_t
value_offset
=
bsz
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
()
*
hidden_dim
;
T
*
temp_buf
=
(
T
*
)
output
.
data_ptr
()
+
at
::
numel
(
output
);
launch_bias_add_transform_0213
<
T
>
((
T
*
)
query_cont
,
...
...
@@ -491,7 +491,7 @@ std::vector<at::Tensor> ds_softmax_context(at::Tensor& query_key_value,
rotate_every_two
,
InferenceContext
::
Instance
().
GetCurrentStream
(),
3
,
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
());
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
());
if
(
rotary_dim
>
0
&&
rotate_half
)
launch_apply_rotary_pos_emb
(
query_cont
,
kv_cache
,
...
...
@@ -502,7 +502,7 @@ std::vector<at::Tensor> ds_softmax_context(at::Tensor& query_key_value,
heads
,
bsz
,
InferenceContext
::
Instance
().
GetCurrentStream
(),
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
());
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
());
attention_unfused
<
T
>
(
workspace
+
offset
,
(
T
*
)
query_cont
,
...
...
@@ -533,8 +533,8 @@ std::vector<at::Tensor> ds_softmax_context(at::Tensor& query_key_value,
if
(
layer_id
==
num_layers
-
1
)
InferenceContext
::
Instance
().
advance_tokens
();
auto
prev_key
=
torch
::
from_blob
(
workspace
+
offset
,
{
bsz
,
heads
,
all_tokens
,
k
},
{
hidden_dim
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
(),
k
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
(),
{
hidden_dim
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
(),
k
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
(),
k
,
1
},
options
);
...
...
@@ -542,8 +542,8 @@ std::vector<at::Tensor> ds_softmax_context(at::Tensor& query_key_value,
auto
prev_value
=
torch
::
from_blob
(
workspace
+
offset
+
value_offset
,
{
bsz
,
heads
,
all_tokens
,
k
},
{
hidden_dim
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
(),
k
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
(),
{
hidden_dim
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
(),
k
*
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
(),
k
,
1
},
options
);
...
...
@@ -1861,7 +1861,7 @@ std::vector<at::Tensor> apply_rotary_pos_emb(at::Tensor& mixed_query,
num_heads
,
bsz
,
InferenceContext
::
Instance
().
GetCurrentStream
(),
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
());
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
());
else
launch_apply_rotary_pos_emb
<
__half
>
((
__half
*
)
query_cont
.
data_ptr
(),
(
__half
*
)
key_cont
.
data_ptr
(),
...
...
@@ -1872,7 +1872,7 @@ std::vector<at::Tensor> apply_rotary_pos_emb(at::Tensor& mixed_query,
num_heads
,
bsz
,
InferenceContext
::
Instance
().
GetCurrentStream
(),
InferenceContext
::
Instance
().
GetMaxTokenLeng
ht
());
InferenceContext
::
Instance
().
GetMaxTokenLeng
th
());
return
{
query_cont
,
key_cont
};
}
...
...
csrc/transformer/inference/includes/inference_context.h
浏览文件 @
f1fab902
...
...
@@ -175,7 +175,7 @@ public:
_workSpaceSize
=
workSpaceSize
;
_attention_unfused_workspace_offset
=
workSpaceSize
-
temp_size
;
}
inline
size_t
GetMaxTokenLeng
ht
()
const
{
return
_max_seq_len
;
}
inline
size_t
GetMaxTokenLeng
th
()
const
{
return
_max_seq_len
;
}
cudaEvent_t
GetCompEvent
(
int
id
)
{
return
id
==
1
?
_comp1_event
:
_comp2_event
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录