bugfix: fix MTP DP concurrent inference failures.#1817
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces raw_dp_global_token_nums to track original DP token counts before padding across various engines and padding structures. It also updates EmbeddingCache to clone detached embeddings, preventing dependencies on producer output storage, and adds serialization mutexes and stream synchronization in MTPWorkerImpl to support safe schedule overlap. Feedback suggests optimizing request ID lookups in WorkerImpl by changing last_step_request_ids_ from a std::vector to an std::unordered_set to avoid linear search overhead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (std::find(last_step_request_ids_.begin(), | ||
| last_step_request_ids_.end(), | ||
| request_id) != last_step_request_ids_.end()) { |
There was a problem hiding this comment.
The use of std::find on a std::vector<std::string> results in a linear search, which can be inefficient for large numbers of requests. The time complexity is O(N*M), where N is the number of current requests and M is the number of requests in the last step.
For better performance, consider changing last_step_request_ids_ from std::vector<std::string> to std::unordered_set<std::string>. This would reduce the lookup time to O(1) on average, making the check significantly faster for large batches.
This would require changing worker_impl.h and update_last_step_output. The check in this function would then become:
if (last_step_request_ids_.count(request_id) > 0) {
return true;
}b7cc198 to
858862c
Compare
Description
Related Issues
Change Type
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
<type>: <subject>.Pre-commit Checks
pre-commitby runningpip install pre-commitor an equivalent command.pre-commit install.pre-commit run --all-filesand fixed any reported issues.Self Review
.agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.mainbranch.Build and Test Coverage
python setup.py build testhas passed on a CUDA machine.python setup.py build testhas passed on an NPU machine.python setup.py build testhas passed on an MLU machine.Reviewer Notes