Provide Omni lifecycle state for auxiliary v2 stages
Signed-off-by: tzhouam <tzhouam@connect.ust.hk>
This commit is contained in:
1 parent
cb8d9f2209
commit
aa499fe79d
2 files changed
+39
-4
No files matched your search
@@ -4,7 +4,8 @@
|
||||
"""Omni-aware ``init_model_state`` factory.
|
||||
|
||||
Extends the upstream v2 factory with Omni architecture dispatch.
|
||||
Non-Omni architectures fall through to the upstream ``init_model_state``.
|
||||
Non-Omni architectures use upstream dispatch; its default state acquires
|
||||
Omni lifecycle support when owned by an Omni stage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -16,8 +17,11 @@ from vllm.v1.worker.gpu.mm.encoder_cache import EncoderCache
|
||||
from vllm.v1.worker.gpu.model_states import (
|
||||
init_model_state as _upstream_init_model_state,
|
||||
)
|
||||
from vllm.v1.worker.gpu.model_states.default import DefaultModelState
|
||||
from vllm.v1.worker.gpu.model_states.interface import ModelState
|
||||
|
||||
from vllm_omni.config.model import OmniModelConfig
|
||||
|
||||
|
||||
def init_omni_model_state(
|
||||
vllm_config: VllmConfig,
|
||||
@@ -28,8 +32,8 @@ def init_omni_model_state(
|
||||
"""Create the appropriate ``ModelState`` for *model*.
|
||||
|
||||
Returns an ``OmniModelState`` when the model declares Omni lifecycle
|
||||
capabilities; otherwise
|
||||
delegates to the upstream v2 factory.
|
||||
capabilities. Otherwise delegates to the upstream v2 factory, wrapping
|
||||
its default state for auxiliary Omni stages.
|
||||
"""
|
||||
factory = getattr(model, "create_omni_model_state", None)
|
||||
if factory is not None:
|
||||
@@ -49,4 +53,12 @@ def init_omni_model_state(
|
||||
)
|
||||
|
||||
return OmniModelState(vllm_config, model, encoder_cache, device)
|
||||
return _upstream_init_model_state(vllm_config, model, encoder_cache, device)
|
||||
state = _upstream_init_model_state(vllm_config, model, encoder_cache, device)
|
||||
if type(state) is DefaultModelState and isinstance(getattr(vllm_config, "model_config", None), OmniModelConfig):
|
||||
# Auxiliary stages such as the forced aligner have no model-owned
|
||||
# hooks, but Omni's runner still needs its request/output lifecycle.
|
||||
# Keep specialized upstream states and plain vLLM configs intact.
|
||||
from vllm_omni.worker_v2.model_states.omni_model_state import OmniModelState
|
||||
|
||||
return OmniModelState(vllm_config, model, encoder_cache, device)
|
||||
return state
|
||||
Reference in new issue
Block a user