Skip to content

perf: avoid redundant copies when batching a single multimodal tensor. - #2745

Open
liutongxuan wants to merge 1 commit into
xLLM-AI:mainfrom
liutongxuan:features/perf_mm
Open

liutongxuan wants to merge 1 commit into
xLLM-AI:mainfrom
liutongxuan:features/perf_mm

Conversation

@liutongxuan

Copy link
Copy Markdown
Collaborator

Description

Reuse the storage of a single contiguous tensor during multimodal batching instead of concatenating it into a new allocation. Preserve existing behavior for multiple tensors and noncontiguous inputs, along with serialization interfaces and wire formats for shared-memory and multi-node transport.

For a 56 MB visual input, an isolated batching benchmark reduced median CPU aggregation time from approximately 11.14 ms to 0.012 ms. End-to-end measurements have not yet established a consistent latency improvement due to run-to-run variation.

The full NPU build and six targeted tests passed, covering batching correctness, tensor lifetime, and packed/shared-memory transport. Full regression validation is still in progress.

Related Issues

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Test
  • Build or CI

Pull Request Checklist

Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.

PR Title and Commit Messages

  • The PR title and each commit message follow the xLLM commit format: <type>: <subject>.

Allowed types: feat, bugfix, docs, test, refactor, chore, style, revert, perf, model, build, release.
The subject should use clear English, start with a verb, include at least 4 words, and end with ..

Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or an equivalent command.
  • I have installed the hooks with pre-commit install.
  • I have run pre-commit run --all-files and fixed any reported issues.

If you are unsure how to set up pre-commit, see the pre-commit documentation.

Self Review

  • I have self-reviewed the code according to .agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.
  • I have rebased this PR onto the latest main branch.

Build and Test Coverage

  • Tests have been added or updated as needed.
  • CUDA: python setup.py build test has passed on a CUDA machine.
  • NPU: python setup.py build test has passed on an NPU machine.
  • MLU: python setup.py build test has passed on an MLU machine.

Reviewer Notes

Multimodal batching concatenates even a single tensor, copying the full visual payload before transport and when rebuilding the received batch. Retain a contiguous singleton through tensor ownership while preserving concatenation for multiple inputs and tensor lists for unsupported layouts.

Keep serialization interfaces and wire schemas intact. Cover source lifetime, protobuf round trips, noncontiguous inputs, multiple images, and packed and shared-memory visual transport.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T09:55:06.406598Z 7da7068 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant