[Qwen4Exp] Restore torch.compile on the NVIDIA path; exact breakable pin; runtime graph-mode assertion
- torch.compile restored on the NVIDIA Qwen4Exp target and MTP so the production profile (VLLM_COMPILE + FULL_AND_PIECEWISE, breakable off) runs. - The production pin requires VLLM_USE_BREAKABLE_CUDAGRAPH to be exactly "0". - assert_resolved_cudagraph_modes() runs at the top of capture_model. - CPU tests for the combined profile, the exact pin and the resolved modes. Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import torch
|
||||
from torch import nn
|
||||
from transformers import Qwen4ExpConfig, Qwen4ExpTextConfig
|
||||
|
||||
from vllm.compilation.decorators import support_torch_compile
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.distributed import get_pp_group
|
||||
from vllm.logger import init_logger
|
||||
@@ -78,7 +79,11 @@ from vllm.multimodal.inputs import MultiModalFeatureSpec
|
||||
from vllm.sequence import IntermediateTensors
|
||||
from vllm.tokenizers.registry import cached_tokenizer_from_config
|
||||
from vllm.v1.attention.backends.registry import MambaAttentionBackendEnum
|
||||
from vllm.v1.e2_guards import assert_graph_profile_is_executable, assert_ple_mode
|
||||
from vllm.v1.e2_guards import (
|
||||
assert_compiled_submodule,
|
||||
assert_graph_profile_is_executable,
|
||||
assert_ple_mode,
|
||||
)
|
||||
from vllm.v1.kv_cache_interface import MambaSpec
|
||||
|
||||
from ..common.mtp import make_mtp_hidden_buffer
|
||||
@@ -472,6 +477,25 @@ class Qwen4ExpMixtureOfExperts(MixtureOfExperts):
|
||||
moe.experts.update_expert_map()
|
||||
|
||||
|
||||
# Compile-profile guard: torch.compile restored on the NVIDIA
|
||||
# path, reverting #55272's removal. Every request-dependent region is a custom
|
||||
# op listed in CompilationConfig._attention_ops (qsa_with_output,
|
||||
# ple_short_conv, compute_ple_ngram_ids, ple_{start,finalize}_prefetch), so
|
||||
# VLLM_COMPILE + FULL_AND_PIECEWISE is executable again with breakable capture
|
||||
# off. query_start_loc / ngram_context are fixed-capacity since #55272
|
||||
# (model_state.py); they stay marked dynamic as on v2.0.1 and only ever reach
|
||||
# the opaque PLE ops.
|
||||
@support_torch_compile(
|
||||
dynamic_arg_dims={
|
||||
"input_ids": 0,
|
||||
"positions": -1,
|
||||
"intermediate_tensors": 0,
|
||||
"inputs_embeds": 0,
|
||||
"query_start_loc": 0,
|
||||
"ngram_context": 0,
|
||||
"deepstack_input_embeds": 0,
|
||||
}
|
||||
)
|
||||
class Qwen4ExpModel(nn.Module):
|
||||
hf_to_vllm_mapper = Qwen3_5Model.hf_to_vllm_mapper | _EXTRA_WEIGHTS_MAPPER
|
||||
|
||||
@@ -760,12 +784,11 @@ class Qwen4ExpForCausalLM(
|
||||
|
||||
def __init__(self, *, vllm_config: VllmConfig, prefix: str = "") -> None:
|
||||
super().__init__()
|
||||
# V0.30.0 auto-enables breakable cudagraphs
|
||||
# for this architecture when VLLM_USE_BREAKABLE_CUDAGRAPH is unset, and
|
||||
# VLLM_COMPILE + a PIECEWISE mode dies at capture because #55272 left no
|
||||
# compiled submodule. Fail here rather than let a reference-host run qualify an
|
||||
# identity nobody chose. Qwen4ExpForConditionalGeneration constructs
|
||||
# this class; Qwen4ExpMTP does not, and guards itself.
|
||||
# Compile-profile guard: the only qualified profile on this tree is VLLM_COMPILE +
|
||||
# FULL_AND_PIECEWISE with breakable capture off (the v2.0.1 identity).
|
||||
# Fail at construction, before profiling or capture, on anything else.
|
||||
# Qwen4ExpForConditionalGeneration constructs this class; Qwen4ExpMTP
|
||||
# does not, and guards itself.
|
||||
assert_graph_profile_is_executable(vllm_config, role="target")
|
||||
assert_ple_mode(vllm_config, role="target")
|
||||
config: Qwen4ExpTextConfig = vllm_config.model_config.hf_text_config
|
||||
@@ -783,6 +806,9 @@ class Qwen4ExpForCausalLM(
|
||||
self.model = Qwen4ExpModel(
|
||||
vllm_config=vllm_config, prefix=maybe_prefix(prefix, "model")
|
||||
)
|
||||
# has_compiled_submodule() at gpu/cudagraph_utils.py:605 is what capture
|
||||
# actually tests; check the same property here.
|
||||
assert_compiled_submodule(self.model, vllm_config, role="target")
|
||||
# PP ownership: logits are computed on the
|
||||
# last stage only; earlier stages carried an unused 0.59 GiB head.
|
||||
if get_pp_group().is_last_rank:
|
||||
|
||||
Reference in New Issue
Block a user