Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Lmdeploy
Commits
4eb8dd83
Unverified
Commit
4eb8dd83
authored
Nov 14, 2023
by
Li Zhang
Committed by
GitHub
Nov 14, 2023
Browse files
Fix init of batch state (#682)
* fix init of finished buf * fix `finished_count`
parent
b7c88ca8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
src/turbomind/models/llama/LlamaBatch.cc
src/turbomind/models/llama/LlamaBatch.cc
+7
-4
No files found.
src/turbomind/models/llama/LlamaBatch.cc
View file @
4eb8dd83
...
...
@@ -355,7 +355,9 @@ bool LlamaBatch<T>::Initialize()
});
// all blocks are not enough to hold a single sequence
FT_CHECK_WITH_INFO
(
active_end
!=
idxs
.
begin
(),
"No enough blocks."
);
if
(
!
sequences
.
empty
())
{
FT_CHECK_WITH_INFO
(
active_end
!=
idxs
.
begin
(),
"No enough blocks."
);
}
// move swap-ins to the back
auto
swapin_beg
=
std
::
stable_partition
(
idxs
.
begin
(),
active_end
,
[
&
](
int
idx
)
{
...
...
@@ -398,6 +400,8 @@ bool LlamaBatch<T>::Initialize()
ClearState
(
*
incoming_
);
}
FT_CHECK
(
state_
->
size
<=
max_batch_size_
);
/// Update block ptrs when there were
// 1. swap-in or swap-out
// 2. holes in the active buffer
...
...
@@ -810,9 +814,6 @@ auto LlamaBatch<T>::InitializeGeneration() -> GenerationState
// for
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
h_seq_limit_len_
[
i
]
=
state_
->
seq_len_limit
[
i
]
+
(
max_context_len
-
state_
->
h_context_length
[
i
]);
if
(
max_context_len
>=
h_seq_limit_len_
[
i
])
{
// mask finished sequences
state_
->
h_finished
[
i
]
=
true
;
}
}
Copy
(
h_seq_limit_len_
,
batch_size
,
seq_limit_len_
);
Copy
(
state_
->
h_finished
,
batch_size
,
finished_buf_
);
...
...
@@ -1402,6 +1403,8 @@ void LlamaBatch<T>::InternalThreadEntry(int device_id)
shared_state
->
barrier
->
wait
();
auto
modified
=
Initialize
();
// finished sequences is handled by `Initialize()`
finished_count
=
0
;
ContextDecode
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment