Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix] Fix bugs in testing continuous batching #5270

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix bugs
  • Loading branch information
CjhHa1 committed Jan 16, 2024
commit 7c7bf94cc89f93058eb02e9348ae8ba9db375d94
1 change: 1 addition & 0 deletions colossalai/inference/core/request_handler.py
Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@ def schedule(self):
f"the prompt(Request id = {seq.request_id}) length is longer than max_input_len, abort this sequence."
)
self.abort_sequence(seq.request_id)
remove_list.append(seq)
break

# stop feeding new sequence into running list to assure
17 changes: 13 additions & 4 deletions colossalai/inference/struct.py
Original file line number Diff line number Diff line change
@@ -29,6 +29,9 @@ class RequestStatus(enum.Enum):
COMPLETED = enum.auto()
LENGTH_CAPPED = enum.auto()

# recycle status
RECYCLED = enum.auto()

@staticmethod
def is_finished(status: "RequestStatus") -> bool:
return status in [
@@ -86,6 +89,8 @@ def input_len(self) -> int:
"""
Get length of input sentence.
"""
if self.status == RequestStatus.RECYCLED:
return len(self.input_token_id) + len(self.output_token_id)
return len(self.input_token_id)

@property
@@ -138,13 +143,14 @@ def recycle(self) -> None:
"""
Recycle a running sequnce to waiitting list
"""
if self.check_finish():
print(self.sentence_len)
print(self.status)
assert (
not self.check_finish() and not self.status == RequestStatus.ABORTED
), "The running sequence \
is already done but it still in running list"
self.status = RequestStatus.WAITING
self.input_token_id.extend(self.output_token_id)
self.output_token_id = []
self.status = RequestStatus.RECYCLED

def __repr__(self) -> str:
return (
@@ -305,7 +311,10 @@ def get_batch_inputs(self) -> torch.LongTensor:

for seq in self.sequences_set:
if self.is_prompts:
input_list.append(seq.input_token_id)
if seq.status == RequestStatus.RECYCLED:
input_list.append(seq.input_token_id.extend(seq.output_token_id))
else:
input_list.append(seq.input_token_id)
else:
input_list.append([seq.output_token_id[-1]])