Repository navigation
[Perf][TTS] step_audio2: keep streaming tokens on-device and batch audio-feature length syncs - #5067
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@QiuMike can you take a look? |
| if isinstance(audio_tokens, torch.Tensor): | ||
| # Already on device; avoids the D2H->H2D round-trip of rebuilding from a list. | ||
| token_tensor = audio_tokens.reshape(1, -1).to(device=self.device, dtype=torch.int32) | ||
| else: |
There was a problem hiding this comment.
I like keeping this on-device 👍 — the one thing I'm not sure about: when audio_tokens already arrives as int32 on self.device, .to(...) is a no-op and token_tensor ends up aliasing the caller's input_ids storage. Today the ids come in as int64 so the dtype cast copies, but if inference_chunk ever writes into token in place that'd quietly corrupt input_ids. A trailing .contiguous() (or .clone()) would make it robust regardless of the incoming dtype.
There was a problem hiding this comment.
Added .clone() so token_tensor never aliases the caller's input_ids, regardless of incoming dtype.
|
|
||
| audio_feature_list = [audio_features[i, : audio_feature_lens[i]] for i in range(audio_features.size(0))] | ||
| # Single host sync; slicing with per-item 0-d cuda tensors syncs once per item. | ||
| audio_feature_lens_cpu = audio_feature_lens.tolist() |
There was a problem hiding this comment.
Nice N-syncs-to-1 win here. The one thing I want to confirm is that _process_audio_input never runs inside a CUDA-graph capture region — .tolist() is a hard host sync. The old per-item slice synced too so this is no regression, I just want to be sure that assumption still holds on this path.
There was a problem hiding this comment.
Correct: _process_audio_input runs in the eager prefill path, not inside a CUDA-graph capture region, so the .tolist() host sync is safe; I added a comment noting this.
a9893ad to
149ba79
Compare
|
Fixed and added some comments @lishunyang12 |
…length syncs Signed-off-by: JuanPZuluaga <juanz9312@gmail.com>
2d0cd5e to
59dad85
Compare
a1a358c to
7a917ac
Compare
|
@lishunyang12 please let me know if there's anything else to be done here. |
vllm-omni-review-bot
left a comment
There was a problem hiding this comment.
Omni ReviewBot review
The on-device streaming tensor path preserves the prior [1, T] int32 input shape and non-aliasing behavior, while the batched .tolist() conversion preserves equivalent feature slicing. No concrete correctness defects found.
No actionable findings.
|
Ran an A/B on an idle L20X box (vLLM 0.26.0,
No regression, and no measurable speedup on this workload — but that's a statement about my probe, not about the patch. Text→speech never enters Code reads fine to me: Unrelated to this PR, in case it's useful: serving step_audio2 from a clean env needed |
linyueqian
left a comment
There was a problem hiding this comment.
Verified by A/B against pr5067^2: no regression (2.88s vs 2.87s median, 3/3 ok both legs, identical output size). Flat on my workload rather than faster, but the probe was text-to-speech so it never entered _process_audio_input, and max_num_seqs: 1 means no batching pressure on the syncs this removes — so that's a limit of my measurement, not evidence against the change. Code reads clean: the device-tensor audio_tokens has no list-assuming consumer left, and the .clone() against aliasing input_ids is a good catch.
…dio-feature length syncs (vllm-project#5067) Signed-off-by: JuanPZuluaga <juanz9312@gmail.com> Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
Purpose
Two small changes that cut host syncs on the hot path, with no change to outputs:
input_ids.flatten().cpu().tolist(), then rebuilt a device tensor). Now it passes the tensor straight through and stays on device..tolist().Numbers
Measured with a device-to-host (D2H) sync counter, greedy decoding, output checked byte-for-byte.
Test Plan
vLLM Version:
vLLM-Omni Commit:
Test Result
BEFORE SUBMITTING: read CONTRIBUTING.md and run the precheck-pr skill with the code agent for a self-check against project conventions.
(anything written below this line will be removed by GitHub Actions)