Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tgaddair committed Mar 22, 2024
1 parent 0326980 commit e3fb65c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 2 additions & 6 deletions router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,7 @@ impl From<CompletionRequest> for CompatGenerateRequest {
top_p: req.top_p,
typical_p: None,
do_sample: !req.n.is_none(),
max_new_tokens: req
.max_tokens
.map(|x| x as u32),
max_new_tokens: req.max_tokens.map(|x| x as u32),
ignore_eos_token: req.ignore_eos_token.unwrap_or(false),
return_full_text: req.echo,
stop: req.stop,
Expand Down Expand Up @@ -653,9 +651,7 @@ impl From<ChatCompletionRequest> for CompatGenerateRequest {
top_p: req.top_p,
typical_p: None,
do_sample: !req.n.is_none(),
max_new_tokens: req
.max_tokens
.map(|x| x as u32),
max_new_tokens: req.max_tokens.map(|x| x as u32),
ignore_eos_token: req.ignore_eos_token.unwrap_or(false),
return_full_text: None,
stop: req.stop,
Expand Down
8 changes: 6 additions & 2 deletions router/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,18 @@ impl Validation {
return_k_alternatives,
};

let effective_max_new_tokens = max_new_tokens.unwrap_or((self.max_total_tokens - input_length) as u32);
let effective_max_new_tokens =
max_new_tokens.unwrap_or((self.max_total_tokens - input_length) as u32);
let stopping_parameters = StoppingCriteriaParameters {
max_new_tokens: effective_max_new_tokens,
stop_sequences,
ignore_eos_token,
};

metrics::histogram!("lorax_request_max_new_tokens", effective_max_new_tokens as f64);
metrics::histogram!(
"lorax_request_max_new_tokens",
effective_max_new_tokens as f64
);

Ok(ValidGenerateRequest {
inputs,
Expand Down

0 comments on commit e3fb65c

Please sign in to comment.