Skip to content

Commit d025ebd

Browse files
authored
Avoid panic decoding tokens on error (#1527)
1 parent ea3f517 commit d025ebd

File tree

1 file changed

+5
-5
lines changed
  • mistralrs-core/src/utils

1 file changed

+5
-5
lines changed

mistralrs-core/src/utils/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ macro_rules! handle_pipeline_forward_error {
9898
error!("{} - Model failed with error: {:?}", $stage, &e);
9999
for seq in $seq_slice.iter_mut() {
100100
// Step 1: Add all choices to groups
101-
let res = match &tokenizer
102-
{
103-
Some(tok) => match tok.decode(&seq.get_toks()[seq.prompt_tokens()..], false) {
101+
let start = seq.prompt_tokens().min(seq.get_toks().len());
102+
let res = match &tokenizer {
103+
Some(tok) => match tok.decode(&seq.get_toks()[start..], false) {
104104
Ok(t) => t,
105-
Err(_) => "".to_string()
105+
Err(_) => "".to_string(),
106106
},
107-
None => "".to_string()
107+
None => "".to_string(),
108108
};
109109

110110
if seq.get_mut_group().is_chat {

0 commit comments

Comments
 (0)