[Guards] Draft identity and draft PLE guard report the drafter's own state
Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
+34
-3
@@ -484,6 +484,38 @@ def resolve_ple_mode(vllm_config) -> str:
|
||||
return PLE_MODE_UVA if cpu_offload else PLE_MODE_DEVICE
|
||||
|
||||
|
||||
def _role_ple_layer_ids(vllm_config, role: str) -> list[int]:
|
||||
"""The 1-based PLE layer ids the role's own decoder layers carry.
|
||||
|
||||
``role="target"``: ``model_config.hf_text_config.ple_layer_ids``.
|
||||
``role="draft"``: the drafter is constructed with the target's VllmConfig
|
||||
(the trap an earlier commit fixed for the architectures), so the target's
|
||||
model_config names the TARGET's PLE layers. The drafter's decoder layers
|
||||
are ``num_hidden_layers + i`` for ``i < mtp_num_hidden_layers``
|
||||
(``Qwen4ExpMultiTokenPredictor``), and a layer builds a PLE block only if
|
||||
``layer_idx + 1`` is in ``ple_layer_ids`` (``Qwen4ExpDecoderLayer``). The
|
||||
draft line reports exactly that intersection, read from
|
||||
``speculative_config.draft_model_config`` -- empty for this checkpoint,
|
||||
whose ids must name backbone layers (``Qwen4ExpTextConfig``).
|
||||
"""
|
||||
model_config = getattr(vllm_config, "model_config", None)
|
||||
if role == "draft":
|
||||
spec = getattr(vllm_config, "speculative_config", None)
|
||||
draft_config = getattr(spec, "draft_model_config", None)
|
||||
if draft_config is not None:
|
||||
model_config = draft_config
|
||||
text_config = getattr(model_config, "hf_text_config", None)
|
||||
ids = list(getattr(text_config, "ple_layer_ids", None) or [])
|
||||
if role != "draft":
|
||||
return ids
|
||||
num_hidden_layers = getattr(text_config, "num_hidden_layers", None)
|
||||
if num_hidden_layers is None:
|
||||
return ids
|
||||
num_mtp = int(getattr(text_config, "mtp_num_hidden_layers", 1))
|
||||
own = range(int(num_hidden_layers) + 1, int(num_hidden_layers) + num_mtp + 1)
|
||||
return [layer_id for layer_id in ids if layer_id in own]
|
||||
|
||||
|
||||
def assert_ple_mode(vllm_config, *, role: str = "target") -> str:
|
||||
"""Startup guard: resolve, assert and log the effective PLE mode.
|
||||
|
||||
@@ -492,11 +524,10 @@ def assert_ple_mode(vllm_config, *, role: str = "target") -> str:
|
||||
target's EngramConfig and the same process environment, so a mixed
|
||||
configuration fails there too). NOT disabled by VLLM_E2_ALLOW_BREAKABLE:
|
||||
that opt-out is about graph identity, not about owning the PLE table twice.
|
||||
The logged ``ple_layer_ids`` are the role's own (:func:`_role_ple_layer_ids`).
|
||||
"""
|
||||
mode = resolve_ple_mode(vllm_config)
|
||||
model_config = getattr(vllm_config, "model_config", None)
|
||||
text_config = getattr(model_config, "hf_text_config", None)
|
||||
ple_layer_ids = list(getattr(text_config, "ple_layer_ids", None) or [])
|
||||
ple_layer_ids = _role_ple_layer_ids(vllm_config, role)
|
||||
engram_config = getattr(vllm_config, "engram_config", None)
|
||||
logger.info(
|
||||
"e2-guard[%s]: ple_mode=%s pull_transport=%d engram_cpu_offload=%s "
|
||||
|
||||
Reference in New Issue
Block a user