simulst 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. simulst-0.1.0/LICENSE +201 -0
  2. simulst-0.1.0/MANIFEST.in +1 -0
  3. simulst-0.1.0/PKG-INFO +394 -0
  4. simulst-0.1.0/README.md +363 -0
  5. simulst-0.1.0/examples/openai_client.py +240 -0
  6. simulst-0.1.0/pyproject.toml +62 -0
  7. simulst-0.1.0/setup.cfg +4 -0
  8. simulst-0.1.0/simulst.egg-info/PKG-INFO +394 -0
  9. simulst-0.1.0/simulst.egg-info/SOURCES.txt +31 -0
  10. simulst-0.1.0/simulst.egg-info/dependency_links.txt +1 -0
  11. simulst-0.1.0/simulst.egg-info/entry_points.txt +5 -0
  12. simulst-0.1.0/simulst.egg-info/requires.txt +17 -0
  13. simulst-0.1.0/simulst.egg-info/top_level.txt +1 -0
  14. simulst-0.1.0/simulst_mm/__init__.py +31 -0
  15. simulst-0.1.0/simulst_mm/chat_template.py +218 -0
  16. simulst-0.1.0/simulst_mm/export/__init__.py +1 -0
  17. simulst-0.1.0/simulst_mm/export/merge_export.py +382 -0
  18. simulst-0.1.0/simulst_mm/model/audio_encoder.py +383 -0
  19. simulst-0.1.0/simulst_mm/model/audio_tower.py +194 -0
  20. simulst-0.1.0/simulst_mm/model/boundary.py +169 -0
  21. simulst-0.1.0/simulst_mm/model/hy_v3_speech.py +209 -0
  22. simulst-0.1.0/simulst_mm/model/processing.py +310 -0
  23. simulst-0.1.0/simulst_mm/plugin.py +71 -0
  24. simulst-0.1.0/simulst_mm/serving/__init__.py +5 -0
  25. simulst-0.1.0/simulst_mm/serving/async_backend.py +278 -0
  26. simulst-0.1.0/tests/test_async_backend.py +241 -0
  27. simulst-0.1.0/tests/test_boundary.py +209 -0
  28. simulst-0.1.0/tests/test_chat_template.py +262 -0
  29. simulst-0.1.0/tests/test_merge_export.py +28 -0
  30. simulst-0.1.0/tests/test_openai_client.py +203 -0
  31. simulst-0.1.0/tests/test_package_smoke.py +98 -0
  32. simulst-0.1.0/tests/test_plugin.py +86 -0
  33. simulst-0.1.0/tests/test_processing.py +18 -0
simulst-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ include examples/openai_client.py
simulst-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,394 @@
1
+ Metadata-Version: 2.4
2
+ Name: simulst
3
+ Version: 0.1.0
4
+ Summary: Unified speech+LLM model for vLLM: serve the simultaneous-interpretation stack as one model
5
+ Author-email: pokoto <40024614+lvbotenbest@users.noreply.github.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/lvbotenbest/simulst
8
+ Project-URL: Source, https://github.com/lvbotenbest/simulst
9
+ Keywords: vllm,speech,simultaneous-interpretation,multimodal,asr
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
+ Requires-Python: <3.15,>=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Provides-Extra: server
18
+ Requires-Dist: vllm[audio]>=0.31; extra == "server"
19
+ Provides-Extra: audio
20
+ Requires-Dist: av; extra == "audio"
21
+ Requires-Dist: scipy; extra == "audio"
22
+ Requires-Dist: soundfile; extra == "audio"
23
+ Requires-Dist: soxr; extra == "audio"
24
+ Requires-Dist: mistral-common[audio]>=1.11.6; extra == "audio"
25
+ Provides-Extra: export
26
+ Requires-Dist: safetensors>=0.6.2; extra == "export"
27
+ Provides-Extra: client
28
+ Requires-Dist: numpy>=1.26; extra == "client"
29
+ Requires-Dist: openai<3,>=2.25; extra == "client"
30
+ Dynamic: license-file
31
+
32
+ # simulst
33
+
34
+ Serve a speech simultaneous-interpretation stack — audio encoder, adapter, and
35
+ LLM — as a **single vLLM model**.
36
+
37
+ ```bash
38
+ # Existing compatible vLLM GPU environment: keep its torch/CUDA stack unchanged.
39
+ python -m pip install --no-deps simulst
40
+
41
+ # Or, in a fresh Python 3.12 environment whose GPU stack pip may manage:
42
+ python -m pip install "simulst[server]"
43
+
44
+ vllm serve /path/to/unified_checkpoint --served-model-name simulst
45
+ ```
46
+
47
+ No wrapper script, no manual `import`, no second model directory. Installing the
48
+ package is enough: it registers the architecture through vLLM's
49
+ `vllm.general_plugins` entry point, which vLLM calls in the engine process and
50
+ in every tensor-parallel worker before the model is built. One server can accept
51
+ multiple concurrent HTTP requests; vLLM queues and schedules them.
52
+
53
+ ## Install
54
+
55
+ The plugin supports CPython **3.10, 3.11, 3.12, 3.13, and 3.14**
56
+ (`>=3.10,<3.15`) and requires upstream **vLLM >=0.31**. Python 3.12 is the
57
+ recommended default for a new environment. Choose the installation mode that
58
+ matches the environment:
59
+
60
+ ```bash
61
+ # Existing vLLM >=0.31 GPU environment: do not let pip touch the GPU stack.
62
+ python -m pip install --no-deps simulst
63
+ # Add only HTTP audio decoders if that vLLM was installed without its audio extra.
64
+ python -m pip install "simulst[audio]"
65
+
66
+ # New environment whose torch/CUDA packages may be managed by pip.
67
+ python -m pip install "simulst[server]"
68
+
69
+ # Optional checkpoint-export and reference-client tools.
70
+ python -m pip install "simulst[export,client]"
71
+ ```
72
+
73
+ The base package intentionally does not depend on vLLM. The `audio` extra
74
+ installs only the decoder libraries used by vLLM's HTTP `input_audio` path;
75
+ it does not depend on vLLM. The `server` extra installs
76
+ `vllm[audio]>=0.31`, including the same decoders. The missing upper bound avoids
77
+ downgrading a newer vLLM already selected by the operator. It is not a promise
78
+ that every future internal vLLM API will remain compatible. vLLM 0.31
79
+ currently resolves a substantially newer stack (including torch 2.13 and
80
+ Transformers 5) and defaults to CUDA 13 packages, with separate CUDA 12.9
81
+ artifacts available. Do not install the `server` extra into an established GPU
82
+ environment unless replacing that stack is intended.
83
+
84
+ Verify the install:
85
+
86
+ ```bash
87
+ python -c "
88
+ from importlib.metadata import entry_points
89
+ for g in ('vllm.general_plugins', 'vllm.logits_processors'):
90
+ print(g, {e.name: e.value for e in entry_points(group=g)})
91
+ "
92
+ ```
93
+
94
+ You should see `simulst_mm` and `simulst_boundary`.
95
+
96
+ ## Environment compatibility and troubleshooting
97
+
98
+ `simulst` is pure Python, but it integrates with internal vLLM model,
99
+ multimodal-processing, and logits-processing APIs. The supported server stack is
100
+ therefore deliberately narrow:
101
+
102
+ | component | supported / expected |
103
+ |---|---|
104
+ | Python | `>=3.10,<3.15` |
105
+ | vLLM | `>=0.31` (0.31 adapted; 0.32 key interfaces source-checked) |
106
+ | PyTorch | 2.13.0 for the vLLM 0.31.0 PyPI wheel |
107
+ | Transformers | `>=5.10.4,<5.18` through vLLM |
108
+ | FlashInfer core | `flashinfer-python==0.7.0.post1` through vLLM 0.31.0 |
109
+ | `flashinfer-cubin` | optional; if installed, its version must exactly match FlashInfer |
110
+ | `flashinfer-jit-cache` | optional; its version and CUDA suffix must match FlashInfer |
111
+ | external `flash-attn` | not required by `simulst`; an old build may conflict with PyTorch 2.13 |
112
+ | `deep-ep` | optional; only needed when that expert-parallel backend is selected |
113
+
114
+ The vLLM 0.31 implementation and the key vLLM 0.32 AsyncLLM, multimodal, and
115
+ Model Runner V2 interfaces have been checked. This is an API compatibility
116
+ check, not a claim that every future `>=0.31` release has passed GPU/checkpoint
117
+ end-to-end validation. Missing required model architecture or API capabilities
118
+ fail at startup and require a `simulst` compatibility update.
119
+
120
+ The exact torch, Transformers, FlashInfer, and CUDA packages are owned by vLLM.
121
+ They are intentionally not pinned a second time by `simulst`. For an existing
122
+ GPU environment, install this package with `--no-deps`. For a new environment,
123
+ prefer a fresh Python 3.12 virtual environment and install `simulst[server]`.
124
+
125
+ Inspect the active environment before troubleshooting:
126
+
127
+ ```bash
128
+ python - <<'PY'
129
+ from importlib.metadata import PackageNotFoundError, version
130
+ import torch
131
+
132
+ for name in (
133
+ "simulst",
134
+ "vllm",
135
+ "torch",
136
+ "transformers",
137
+ "flashinfer-python",
138
+ "flashinfer-cubin",
139
+ "flashinfer-jit-cache",
140
+ "flash-attn",
141
+ "deep-ep",
142
+ ):
143
+ try:
144
+ print(f"{name}: {version(name)}")
145
+ except PackageNotFoundError:
146
+ print(f"{name}: not installed")
147
+ print("torch CUDA:", torch.version.cuda)
148
+ PY
149
+ ```
150
+
151
+ ### `undefined symbol` from `flash_attn_2_cuda` or `deep_ep_cpp`
152
+
153
+ This means a compiled extension was built against a different PyTorch ABI,
154
+ usually because vLLM upgraded torch while an old extension remained installed.
155
+ Neither external `flash-attn` nor `deep-ep` is required for a single-GPU default
156
+ deployment. If those backends are not intentionally used, remove the stale
157
+ extensions and restart vLLM:
158
+
159
+ ```bash
160
+ python -m pip uninstall -y flash-attn deep-ep
161
+ ```
162
+
163
+ If either backend is required, rebuild it against the exact torch and CUDA
164
+ versions in the active environment instead of bypassing the import error.
165
+
166
+ ### FlashInfer package version mismatch
167
+
168
+ An error such as:
169
+
170
+ ```text
171
+ flashinfer-cubin version (X) does not match flashinfer version (Y)
172
+ ```
173
+
174
+ means an optional precompiled artifact does not match `flashinfer-python`.
175
+ `flashinfer-cubin` and `flashinfer-jit-cache` are not required: FlashInfer can
176
+ compile or download kernels on first use. The simplest repair is:
177
+
178
+ ```bash
179
+ python -m pip uninstall -y flashinfer-cubin flashinfer-jit-cache
180
+ ```
181
+
182
+ If precompiled/offline kernels are required, install matching artifacts from the
183
+ FlashInfer wheel index. All FlashInfer package versions must match exactly, and
184
+ the JIT-cache index must match the torch CUDA build (`cu129` or `cu130`). Use
185
+ `FLASHINFER_DISABLE_VERSION_CHECK=1` only while running FlashInfer's artifact
186
+ installation command to replace a mismatched package; do not keep it in the
187
+ vLLM service environment.
188
+
189
+ ### GPU memory utilization check fails
190
+
191
+ If vLLM reports that free memory is below its requested utilization, first stop
192
+ other GPU processes or lower the target, for example:
193
+
194
+ ```bash
195
+ vllm serve /path/to/unified_checkpoint \
196
+ --served-model-name simulst \
197
+ --gpu-memory-utilization 0.88
198
+ ```
199
+
200
+ ### Network interface errors from Gloo or NCCL
201
+
202
+ Single-node vLLM still initializes distributed communication. If an inherited
203
+ `GLOO_SOCKET_IFNAME` or `NCCL_SOCKET_IFNAME` names a missing interface, select a
204
+ real interface shown by `ip -br addr`. `lo` is suitable only for single-node
205
+ runs; multi-node deployments need a routable interface shared by all nodes.
206
+
207
+ ## Preparing a checkpoint
208
+
209
+ The package expects one directory containing the LLM weights, the audio tower
210
+ weights under an `audio_tower.` prefix, and a `config.json` whose
211
+ `architectures` is `["HYV3SpeechForCausalLM"]`. If you have the two halves
212
+ exported separately, use an existing PyTorch/Transformers export environment,
213
+ install the safetensors helper, and merge them:
214
+
215
+ ```bash
216
+ python -m pip install "simulst[export]"
217
+ python -m simulst_mm.export.merge_export \
218
+ --llm /path/to/hf_export \
219
+ --audio /path/to/hf_export_audio \
220
+ --target /path/to/unified_checkpoint \
221
+ --encoder-path /path/to/pretrained_audio_encoder # optional
222
+ ```
223
+
224
+ The LLM shards are **hard-linked**, not copied — tensor names are rewritten at
225
+ load time by a `WeightsMapper`, so there is no reason to rewrite tens of GB on
226
+ disk. A copy is used automatically when the paths are on different filesystems.
227
+
228
+ `--encoder-path` is only read for `preprocessor_config.json` and the encoder
229
+ shape, and falls back to built-in defaults when absent. Nothing outside the
230
+ merged directory is read at serving time.
231
+
232
+ The merge also installs an audio-aware `chat_template.jinja` and a
233
+ `generation_config.json` for `/v1/chat/completions`. Pass
234
+ `--no-openai-assets` only if the checkpoint must retain its original template.
235
+ An existing merged checkpoint can be updated in place with:
236
+
237
+ ```bash
238
+ python -m simulst_mm.chat_template --model /path/to/unified_checkpoint
239
+ ```
240
+
241
+ ## OpenAI-compatible HTTP deployment and concurrency
242
+
243
+ Activate the same Python environment that contains vLLM and `simulst`, then
244
+ start one vLLM server with the unified checkpoint:
245
+
246
+ ```bash
247
+ vllm serve /path/to/unified_checkpoint \
248
+ --served-model-name simulst \
249
+ --host 0.0.0.0 \
250
+ --port 8000
251
+ ```
252
+
253
+ That command already supports concurrent HTTP requests. Multiple clients send
254
+ independent requests to `/v1/chat/completions`; the one vLLM engine queues them
255
+ and applies continuous batching. Do not start one model process per request, and
256
+ do not add `AsyncTurnRunner` around the HTTP server.
257
+
258
+ For example, a two-GPU deployment with capacity for up to eight scheduled
259
+ sequences can be started as follows when those settings match the checkpoint and
260
+ hardware:
261
+
262
+ ```bash
263
+ CUDA_VISIBLE_DEVICES=0,1 vllm serve /path/to/unified_checkpoint \
264
+ --served-model-name simulst \
265
+ --tensor-parallel-size 2 \
266
+ --enable-expert-parallel \
267
+ --max-num-seqs 8 \
268
+ --host 0.0.0.0 \
269
+ --port 8000
270
+ ```
271
+
272
+ `--tensor-parallel-size` and `--enable-expert-parallel` configure model
273
+ parallelism, not HTTP concurrency. `--max-num-seqs` is scheduler capacity, not a
274
+ hard HTTP connection limit; excess requests may wait. Available admission and
275
+ scheduler flags vary by vLLM release, so inspect the installed CLI before adding
276
+ version-specific tuning:
277
+
278
+ ```bash
279
+ vllm serve --help | grep -E "max-num-seqs|max-num-active-seqs"
280
+ ```
281
+
282
+ To run the repository's reference streaming client, use a source checkout
283
+ (`examples/` is not installed by the wheel):
284
+
285
+ ```bash
286
+ python -m pip install "simulst[client]"
287
+ # Refresh an older unified checkpoint once to install the current chat template.
288
+ python -m simulst_mm.chat_template --model /path/to/unified_checkpoint
289
+ # Default: source text plus translation; appends control token 120808.
290
+ python examples/openai_client.py --audio talk.wav --direction en-zh
291
+ # Translation-only model: do not append the control token.
292
+ python examples/openai_client.py --audio talk.wav --direction en-zh \
293
+ --output-mode translation
294
+ ```
295
+
296
+ The example writes each raw server JSON response to stdout. It is only a
297
+ protocol reference; production conversation and result handling belong in the
298
+ downstream inference service. `/v1/completions` cannot carry audio and is not
299
+ supported for this path.
300
+
301
+ ## In-process usage
302
+
303
+ Pre-tokenised callers may still provide one expanded run of audio placeholder
304
+ tokens per chunk. The simultaneous-interpretation protocol (turn structure,
305
+ WAIT/EMIT policy, rolling window) remains in the client.
306
+
307
+ ```python
308
+ from vllm import LLM, SamplingParams
309
+ from vllm.inputs import TokensPrompt
310
+
311
+ llm = LLM(
312
+ model="/path/to/unified_checkpoint",
313
+ tensor_parallel_size=2,
314
+ enable_expert_parallel=True,
315
+ dtype="bfloat16",
316
+ enforce_eager=True,
317
+ )
318
+
319
+ prompt = TokensPrompt(
320
+ prompt_token_ids=token_ids, # placeholders already present
321
+ multi_modal_data={"audio": [chunk_waveform, ...]}, # one entry per chunk
322
+ )
323
+ llm.generate([prompt], SamplingParams(temperature=0.7, max_tokens=128))
324
+ ```
325
+
326
+ ## In-process AsyncLLM concurrency without HTTP
327
+
328
+ This helper is for applications that create vLLM `AsyncLLM` directly instead
329
+ of running `vllm serve`. HTTP clients do not need it: send concurrent requests
330
+ to the server as described above.
331
+
332
+ `AsyncTurnRunner` provides a synchronous one-input/one-output facade over one
333
+ shared `AsyncLLM`. Each caller blocks for its own final output, while calls from
334
+ different threads run concurrently and may finish out of submission order:
335
+
336
+ ```python
337
+ from concurrent.futures import ThreadPoolExecutor
338
+
339
+ from simulst_mm.serving import AsyncTurnRunner
340
+
341
+ # The factory runs on the runner's private asyncio thread and must return a
342
+ # configured vLLM AsyncLLM instance.
343
+ runner = AsyncTurnRunner(make_async_llm, timeout_seconds=900)
344
+ try:
345
+ with ThreadPoolExecutor(max_workers=8) as pool:
346
+ futures = [
347
+ pool.submit(runner.submit, prompt, sampling_params, owner=session_id)
348
+ for session_id, prompt in independent_turns
349
+ ]
350
+ outputs = [future.result() for future in futures]
351
+ finally:
352
+ runner.close()
353
+ ```
354
+
355
+ Prompts and audio arrays are treated as immutable for the duration of a request.
356
+ Owner cancellation affects only that owner's active requests. This helper does
357
+ not implement conversation history, HTTP/SSE/WebSocket transport, or
358
+ multi-instance routing; those belong in a higher-level serving application.
359
+
360
+ ## Design notes
361
+
362
+ **One chunk per encoder call.** Whisper-style feature extraction pads to the
363
+ longest waveform in the batch, so batching changes the padded mel width, which
364
+ in bf16 selects different kernels and shifts embeddings by ~0.03. Encoding one
365
+ chunk at a time is bit-exact across repeated calls (12/12 identical); batching
366
+ is not (0/12). The processor therefore extracts one waveform per call.
367
+
368
+ **Two placeholder shapes are supported.** The OpenAI chat template emits one
369
+ audio token per chunk and the processor expands it to the required run. Existing
370
+ `TokensPrompt` callers may supply those runs pre-expanded; the processor detects
371
+ that shape and uses vLLM's left-to-right scanner so runs of the same token remain
372
+ associated with the correct chunks.
373
+
374
+ **Boundary protection travels with the model.** A vLLM 0.31 Model Runner V2
375
+ logits processor masks end-of-turn and EOS for sampling requests unless the
376
+ boundary is already the argmax, so greedy boundary decisions are preserved.
377
+ State is keyed by persistent request slot and expanded through vLLM's row mapping,
378
+ including speculative-decoding rows. The entry point is global, so the processor
379
+ inspects the architecture and disables itself for every other model.
380
+
381
+ ## Verification
382
+
383
+ Parity against a reference deployment that keeps the tower outside vLLM:
384
+
385
+ | check | result |
386
+ |---|---|
387
+ | audio embeddings, bit-level | 12/12 identical, max abs diff 0 |
388
+ | generated token ids, 8 turns | identical on every turn |
389
+ | prefix cache, 40 turns | 0.9432 steady (0.977 by turn 40) |
390
+ | boundary processor | 5/5 checks pass |
391
+
392
+ ## License
393
+
394
+ See `LICENSE`.