Truncating left for radix purposes.

This commit is contained in:
Nicolas Patry 2024-08-28 10:53:22 +02:00
parent 0a60973166
commit e6ee67f301
No known key found for this signature in database
GPG Key ID: 64AF4752B2967863
2 changed files with 5 additions and 1 deletions

View File

@ -167,7 +167,8 @@ impl Validation {
)); ));
} }
let input_ids = encoding.get_ids()[..input_length].to_owned(); let ids = encoding.get_ids();
let input_ids = ids[ids.len().saturating_sub(input_length)..].to_owned();
metrics::histogram!("tgi_request_input_length").record(input_length as f64); metrics::histogram!("tgi_request_input_length").record(input_length as f64);
Ok((inputs, Some(input_ids), input_length, max_new_tokens)) Ok((inputs, Some(input_ids), input_length, max_new_tokens))

View File

@ -272,6 +272,9 @@ class FlashCausalLMBatch(Batch):
prefix_len = r.prefix_len prefix_len = r.prefix_len
assert prefix_len <= orig_input_length assert prefix_len <= orig_input_length
if prefix_len == orig_input_length:
assert prefix_len > 0
prefix_len -= 1
prefix_ids.append(tokenized_input[:prefix_len]) prefix_ids.append(tokenized_input[:prefix_len])
tokenized_input = tokenized_input[prefix_len:] tokenized_input = tokenized_input[prefix_len:]