Commit 4c51461
authored
Fix Voxtral Realtime runner flush (#18339)
### Summary
`VoxtralRealtimeRunner` was outputting excessive duplicate
tokens/gibberish on stream flush. In an audio file where I say "The
weather is clear today" run like
```
voxtral_realtime_runner \
--model_path model.pte \
--tokenizer_path tekken.json \
--preprocessor_path preprocessor.pte \
--streaming \
--audio_path audio.wav
```
I would get output: `The weather is clear todayoday.</s>`
I also experienced this with periods and many other circumstances with
repeating tokens at the end of the stream.
Upon investigation into vLLM's (Mistrals recommended inferencing runner
for [Voxtral
Realtime](https://huggingface.co/mistralai/Voxtral-Mini-4B-Realtime-2602#vllm-recommended)),
I observed that vLLM finishes the stream by closing the streaming input
and draining model-defined right-padding audio, whereas ExecuTorch
`flush()` finished by switching into post-audio text-only decoding after
audio ended. See vLLM ref:
https://github.com/vllm-project/vllm/blob/2f9f946/vllm/model_executor/models/voxtral_realtime.py#L239-L270.
Therefore, apply similar logic here by converting the model-defined
transcription delay into a finite number of trailing silent streaming
steps to properly conclude the stream.
After this, the same command outputs:
```
The weather is clear today.
```
As I would expect. No `</s>` b/c like vLLM, the stream ends by naturally
draining the padded audio tail and letting the model emit whatever final
delayed text it wants.
### Test plan
Tested with above example and a few other audio files to observe the
behavior improvement and lack of giberrish/incorrect end of stream.1 parent 2165b5a commit 4c51461
6 files changed
Lines changed: 95 additions & 72 deletions
File tree
- examples/models/voxtral_realtime
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
| 603 | + | |
| 604 | + | |
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
| |||
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
92 | 112 | | |
93 | 113 | | |
94 | 114 | | |
| |||
109 | 129 | | |
110 | 130 | | |
111 | 131 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | 132 | | |
117 | 133 | | |
118 | 134 | | |
| |||
156 | 172 | | |
157 | 173 | | |
158 | 174 | | |
159 | | - | |
| 175 | + | |
| 176 | + | |
160 | 177 | | |
161 | 178 | | |
162 | 179 | | |
| |||
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
210 | | - | |
| 227 | + | |
| 228 | + | |
211 | 229 | | |
212 | 230 | | |
213 | 231 | | |
| |||
221 | 239 | | |
222 | 240 | | |
223 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
224 | 245 | | |
225 | 246 | | |
226 | 247 | | |
227 | | - | |
| 248 | + | |
228 | 249 | | |
229 | 250 | | |
230 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| |||
Lines changed: 43 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| |||
158 | 162 | | |
159 | 163 | | |
160 | 164 | | |
161 | | - | |
162 | | - | |
| 165 | + | |
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
| |||
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
294 | | - | |
| 297 | + | |
295 | 298 | | |
296 | 299 | | |
297 | 300 | | |
| |||
423 | 426 | | |
424 | 427 | | |
425 | 428 | | |
426 | | - | |
| 429 | + | |
427 | 430 | | |
428 | 431 | | |
429 | 432 | | |
| |||
434 | 437 | | |
435 | 438 | | |
436 | 439 | | |
437 | | - | |
| 440 | + | |
438 | 441 | | |
439 | 442 | | |
440 | | - | |
441 | 443 | | |
442 | 444 | | |
443 | 445 | | |
| |||
452 | 454 | | |
453 | 455 | | |
454 | 456 | | |
455 | | - | |
| 457 | + | |
456 | 458 | | |
457 | | - | |
| 459 | + | |
458 | 460 | | |
459 | 461 | | |
460 | 462 | | |
| |||
467 | 469 | | |
468 | 470 | | |
469 | 471 | | |
470 | | - | |
| 472 | + | |
471 | 473 | | |
472 | 474 | | |
473 | 475 | | |
| |||
586 | 588 | | |
587 | 589 | | |
588 | 590 | | |
589 | | - | |
| 591 | + | |
590 | 592 | | |
591 | 593 | | |
592 | | - | |
| 594 | + | |
593 | 595 | | |
594 | 596 | | |
595 | 597 | | |
| |||
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
606 | | - | |
| 608 | + | |
607 | 609 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
627 | 619 | | |
628 | 620 | | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
633 | 627 | | |
634 | 628 | | |
635 | 629 | | |
| |||
669 | 663 | | |
670 | 664 | | |
671 | 665 | | |
672 | | - | |
673 | | - | |
674 | 666 | | |
675 | 667 | | |
676 | 668 | | |
677 | 669 | | |
678 | 670 | | |
679 | | - | |
680 | | - | |
681 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
682 | 683 | | |
683 | 684 | | |
| 685 | + | |
| 686 | + | |
684 | 687 | | |
685 | 688 | | |
686 | 689 | | |
687 | 690 | | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | 691 | | |
698 | 692 | | |
699 | 693 | | |
| |||
Lines changed: 17 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | | - | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
57 | | - | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
| |||
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| |||
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
124 | | - | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
| |||
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
142 | | - | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| |||
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
166 | | - | |
167 | | - | |
168 | | - | |
| 172 | + | |
| 173 | + | |
169 | 174 | | |
170 | | - | |
| 175 | + | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
0 commit comments