Signed-off-by: Thomas Parnell <tpa@zurich.ibm.com>
This commit is contained in:
@@ -223,7 +223,7 @@ class Scheduler(SchedulerInterface):
|
||||
# Make sure the input position does not exceed the max model len.
|
||||
# This is necessary when using spec decoding.
|
||||
num_new_tokens = min(
|
||||
num_new_tokens, self.max_model_len - request.num_computed_tokens
|
||||
num_new_tokens, self.max_model_len - 1 - request.num_computed_tokens
|
||||
)
|
||||
|
||||
# Schedule encoder inputs.
|
||||
|
||||
@@ -44,7 +44,7 @@ def check_stop(
|
||||
request: Request, max_model_len: int, pooler_output: Optional[torch.Tensor] = None
|
||||
) -> bool:
|
||||
if (
|
||||
request.num_tokens > max_model_len
|
||||
request.num_tokens >= max_model_len
|
||||
or request.num_output_tokens >= request.max_tokens
|
||||
):
|
||||
request.status = RequestStatus.FINISHED_LENGTH_CAPPED
|
||||
|
||||
@@ -2317,30 +2317,14 @@ class GPUModelRunner(LoRAModelRunnerMixin, KVConnectorModelRunnerMixin):
|
||||
|
||||
start_idx = self.input_batch.num_tokens_no_spec[req_idx]
|
||||
end_idx = start_idx + len(sampled_ids)
|
||||
assert end_idx <= self.max_model_len + 1, (
|
||||
"Sampled token IDs exceed the max model length + 1. "
|
||||
f"Total number of tokens: {end_idx} > max_model_len + 1: "
|
||||
f"{self.max_model_len + 1}"
|
||||
assert end_idx <= self.max_model_len, (
|
||||
"Sampled token IDs exceed the max model length. "
|
||||
f"Total number of tokens: {end_idx} > max_model_len: "
|
||||
f"{self.max_model_len}"
|
||||
)
|
||||
|
||||
n_tokens_cache = len(sampled_ids)
|
||||
|
||||
# Sampled token IDs exceed the max model length by 1. This is
|
||||
# legitimate as we can still sample 1 last token when the context
|
||||
# length equals the max model length. Note that we do not need to
|
||||
# cache this token ID as the sequence finishes after this step.
|
||||
# Additionally, the buffers token_ids_cpu and is_token_ids are of
|
||||
# size max model length only.
|
||||
if end_idx == self.max_model_len + 1:
|
||||
n_tokens_cache -= 1
|
||||
|
||||
self.input_batch.token_ids_cpu[
|
||||
req_idx, start_idx : (start_idx + n_tokens_cache)
|
||||
] = sampled_ids[:n_tokens_cache]
|
||||
self.input_batch.is_token_ids[
|
||||
req_idx, start_idx : (start_idx + n_tokens_cache)
|
||||
] = True
|
||||
|
||||
self.input_batch.token_ids_cpu[req_idx, start_idx:end_idx] = sampled_ids
|
||||
self.input_batch.is_token_ids[req_idx, start_idx:end_idx] = True
|
||||
self.input_batch.num_tokens_no_spec[req_idx] = end_idx
|
||||
self.input_batch.num_tokens[req_idx] = end_idx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user