[Bugfix] Fix failing transformers dynamic module resolving with spawn multiproc method#13403
Conversation
Signed-off-by: Isotr0py <2037008807@qq.com>
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
Signed-off-by: Isotr0py <2037008807@qq.com>
hmellor
left a comment
There was a problem hiding this comment.
This is an elegant fix, I've just suggested a few modifications to reduce the level of nesting
hmellor
left a comment
There was a problem hiding this comment.
LGTM, just add a comment explaining why we need to create all the classes in auto_map (your original one got lost in my suggested refactor)
Signed-off-by: Isotr0py <2037008807@qq.com>
| # executor. | ||
| auto_modules = { | ||
| name: get_class_from_dynamic_module(module, model_config.model) | ||
| for name, module in auto_map.items() |
There was a problem hiding this comment.
This implementation depends on the order of entries in auto_map (eg. how they are iterated). It assumes that the Config class comes before the Modeling class that imports it. That will probably be true in most cases, but we could explicitly load AutoConfig first to be more robust to the ordering.
Another edge case would be if the custom code has relative imports for files that are not in the auto_map, but that seems uncommon...
There was a problem hiding this comment.
This implementation depends on the order of entries in
auto_map
Only in the multiprocessing case though, right? Before this PR we never loaded the config class at all (and it is imported by the model class).
There was a problem hiding this comment.
The config class is typically loaded early as part of the engine initialization when the ModelConfig is initialized (using transformers.AutoConfig). It is only in a spawned Worker that we lose the cached import and hit the case that this PR is trying to fix. In that error case, loading the modeling class before its dependencies is what raises the error. If the modeling class is first in auto_map.items(), then it will still fail after this PR.
There was a problem hiding this comment.
I think we can sort auto_map from keys to make sure that it has correct like:
{
"AutoConfig": "<your-repo-name>--<config-name>",
"AutoModel": "<your-repo-name>--<config-name>",
"AutoModelFor<Task>": "<your-repo-name>--<config-name>",
}
Signed-off-by: Isotr0py <2037008807@qq.com>
… multiproc method (vllm-project#13403) Signed-off-by: Isotr0py <2037008807@qq.com>
… multiproc method (vllm-project#13403) Signed-off-by: Isotr0py <2037008807@qq.com>
… multiproc method (vllm-project#13403) Signed-off-by: Isotr0py <2037008807@qq.com> Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
… multiproc method (vllm-project#13403) Signed-off-by: Isotr0py <2037008807@qq.com>
Issue discussion on Slack: https://vllm-dev.slack.com/archives/C07R5Q1Q2BB/p1739776343893149?thread_ts=1739553140.299949&cid=C07R5Q1Q2BB
transformersbackend failed to load custom module on multiproc executor withVLLM_WORKER_MULTIPROC_METHOD=spawnbecause false-positive loaded custom module.