Repository navigation
mtmd: reserve embedding storage before populating batches - #33171
Smartens-gaowz wants to merge 1 commit into
Conversation
|
Hello @ngxson , this PR reserves storage capacity in advance for the embedding batch of mtmd, reducing the need for expansion and data migration during the padding process. I have added performance comparisons, as well as regression verification results for Qwen3-ASR, Qwen3-TTS, and SmolVLM2. Currently, the CPU CI shows it is awaiting approval from the maintainer. Could you please approve it at your convenience and review this modification? If additional testing or code adjustments are needed, I will continue to assist. Thank you! |
|
I'd suggest closing this for now, it's better to fix the root cause: do not pass the embd via host any more, so no need to alloc the batch to start with. There will be multiple PRs to make it work, but we're getting there, see: #33377 |
Overview
decod_embedd_batch:: render() append embeddings line by line. When the capacity of the std:: vector on the CPU side is insufficient,
It reallocates and moves the already written data. Before adding embeddings line by line, reserve capacity based on the number of rows and the width of each row,
Then use the original loop to fill in the embedding, positioning, and output marker fields.
Additional information
On the same NVIDIA GeForce RTX 4090 device, benchmark the baseline commit 07ba74b (A) and PR build (B) using the same input for 11 Qwen3-VL-8B workloads.
The test execution sequence is A->B->B->A. Each step starts with a warm-up request, followed by three formal requests. The result is calculated by taking the average of the three formal request times.
The average time to first token issuance (TTFT) decreased by 1.78% to 10.84%.
Output consistency
Requirements
Codex helped implement capacity reservation for MTMD embedding batches and revised the patch based on my feedback. I have reviewed the patch.
Codex checked and analyzed the test results,I personally verified the test results.