[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:
2026-10-09 19:55:22 +07:00
co-authored by Hinata
parent 23349e43b2
commit 2e68aba2a7
8 changed files with 586 additions and 145 deletions
+262 -125
View File
@@ -3,33 +3,30 @@
"""Fork startup guards that fail closed on a graph profile we never qualified.
These run at model construction, on every rank, for the target model and for
the MTP drafter, before profiling or capture. They exist because a *documented*
launch flag is not a mechanism: the first reference-host run of a rebase will otherwise
qualify a compile/capture identity nobody chose
(see below).
the MTP drafter, before profiling or capture.
What this module does NOT do: choose a graph profile. That is the maintainer's
call and it is open (the graph-profile choice). What it does is refuse the
two states that are silently wrong on vLLM v0.30.0 --
Compile-profile guard: this tree restores torch.compile on the
NVIDIA Qwen4Exp path (reverting vLLM #55272) and removes Qwen4Exp from
``DEFAULT_BREAKABLE_CUDAGRAPH_ARCHITECTURES``. The ONE qualified profile is the
v2.0.1 production identity:
* ``VLLM_USE_BREAKABLE_CUDAGRAPH`` left unset, which lets
``VllmConfig._maybe_enable_breakable_cudagraph`` turn it on for this fork's
architectures and force ``CompilationMode.NONE``; and
* a PIECEWISE-bearing cudagraph mode combined with ``VLLM_COMPILE`` and
breakable-off, which upstream accepts at config time and then rejects at
capture, because #55272 removed every ``@support_torch_compile`` wrapper
from the NVIDIA Qwen4Exp model and MTP.
* ``VLLM_USE_BREAKABLE_CUDAGRAPH`` explicitly pinned to exactly ``0``, and
resolved OFF;
* ``CompilationMode.VLLM_COMPILE``;
* ``CUDAGraphMode.FULL_AND_PIECEWISE``;
* every Qwen4Exp request-dependent custom op in ``splitting_ops``
(:data:`REQUIRED_SPLITTING_OPS`);
* a live ``@support_torch_compile`` submodule
(:func:`assert_compiled_submodule`), which is the property
``vllm/v1/worker/gpu/cudagraph_utils.py:605`` actually tests at capture.
-- and to make the resolved profile visible and assertable.
Anything else -- eager, NONE + FULL, FULL_DECODE_ONLY, breakable PIECEWISE --
fails loud. ``VLLM_E2_ALLOW_BREAKABLE=1`` is the single, logged opt-out for
deliberate non-production boots (debug, probes); a production launch must not set it.
Timing limit, stated honestly: this runs at model construction, i.e. AFTER
``VllmConfig.__post_init__`` has already called
``_maybe_enable_breakable_cudagraph`` (``config/vllm.py:1561``) and
``_normalize_piecewise_cudagraph_mode`` (``:1673``, ``:1844``). It is early
enough to stop profiling and capture; it cannot un-mutate ``os.environ`` or
recover the originally requested cudagraph mode. Requiring the pin to be
*explicitly present* is the part of "validate before auto-enable" that is
checkable from here: absence is exactly the state the auto-enable feeds on.
Timing limit: this runs AFTER ``VllmConfig.__post_init__`` resolved the
profile. It stops the boot before profiling and capture; it cannot recover
the originally requested profile if the config layer rewrote it.
"""
import os
@@ -42,14 +39,32 @@ BREAKABLE_ENV = "VLLM_USE_BREAKABLE_CUDAGRAPH"
#: Opt-out for every guard in this module. Recorded in the launch identity and
#: PROHIBITED in production profiles; a production launch must not set it.
ALLOW_BREAKABLE_ENV = "VLLM_E2_ALLOW_BREAKABLE"
#: Optional expected resolved cudagraph mode, by name (e.g. "FULL",
#: "FULL_DECODE_ONLY"). When set, a mismatch is an error. This is how a launch
#: profile pins the graph identity once the maintainer has chosen one.
#: Optional expected resolved cudagraph mode, by name. When set, a mismatch is
#: an error (in addition to the fixed requirement below).
EXPECTED_MODE_ENV = "VLLM_E2_EXPECTED_CUDAGRAPH_MODE"
#: The architectures vLLM v0.30.0 auto-enables breakable cudagraphs for, out of
#: ``vllm/config/vllm.py:DEFAULT_BREAKABLE_CUDAGRAPH_ARCHITECTURES``, that are
#: ours. Recorded so the guard's message can name the upstream mechanism.
#: The qualified profile (the compile-profile guard).
REQUIRED_COMPILATION_MODE_NAME = "VLLM_COMPILE"
REQUIRED_CUDAGRAPH_MODE_NAME = "FULL_AND_PIECEWISE"
#: The only raw VLLM_USE_BREAKABLE_CUDAGRAPH value accepted as the production
#: pin. Resolution semantics stay upstream's (_upstream_truth).
PRODUCTION_BREAKABLE_PIN = "0"
#: Custom ops that must stay graph breaks on the NVIDIA Qwen4Exp path. Each
#: reads per-step request metadata (or forks/joins a side stream) and would be
#: baked into a piecewise graph otherwise.
REQUIRED_SPLITTING_OPS = (
"vllm::qwen4_exp_qsa_with_output",
"vllm::qwen4_exp_ple_short_conv",
"vllm::qwen4_exp_compute_ple_ngram_ids",
"vllm::qwen4_exp_ple_start_prefetch",
"vllm::qwen4_exp_ple_finalize_prefetch",
"vllm::qwen_gdn_attention_core",
"vllm::qwen_gdn_attention_core_fused_norm_packed",
)
#: Upstream v0.30.0 auto-enabled breakable cudagraphs for these; this tree
#: does not (vllm/config/vllm.py). Kept to name the mechanism in messages.
OUR_AUTO_BREAKABLE_ARCHITECTURES = frozenset(
{
"Qwen4ExpForCausalLM",
@@ -62,10 +77,7 @@ OUR_AUTO_BREAKABLE_ARCHITECTURES = frozenset(
def _upstream_truth(raw: str | None) -> bool:
"""Upstream's exact semantics for the breakable switch.
``envs.py:937`` is ``os.environ.get(..., "0") == "1"``. Nothing else is on:
``"2"``, ``"true"``, ``"FALSE"`` and ``""`` are all off. Using one parser
that matches it is the point -- a stricter local parser would reject boots
upstream treats as off, which is a false rejection, not extra safety.
``envs.py:937`` is ``os.environ.get(..., "0") == "1"``. Nothing else is on.
"""
return raw == "1"
@@ -73,17 +85,8 @@ def _upstream_truth(raw: str | None) -> bool:
def breakable_resolved() -> bool:
"""Whether breakable cudagraphs are on, as the engine will see it.
Two readings of ONE source, not three independent sources:
``vllm.compilation.breakable_cudagraph.is_breakable_cudagraph_enabled()``
is literally ``bool(envs.VLLM_USE_BREAKABLE_CUDAGRAPH)``
(``breakable_cudagraph.py:53``), so it adds nothing over the envs read.
The envs read is kept beside the raw one because
``_maybe_enable_breakable_cudagraph`` mutates ``os.environ`` at config time
while the envs accessor is cached, so the two can legitimately disagree;
either saying "on" means on.
No exception is swallowed. A guard that cannot read its own input must fail
the boot, not report False.
The raw environment and the (cached) envs accessor are two readings of one
source; either saying "on" means on. No exception is swallowed.
"""
if _upstream_truth(os.environ.get(BREAKABLE_ENV)):
return True
@@ -92,8 +95,12 @@ def breakable_resolved() -> bool:
return bool(envs.VLLM_USE_BREAKABLE_CUDAGRAPH)
def _profile(vllm_config) -> tuple[list[str], object, object]:
"""Resolved (architectures, compilation mode, cudagraph mode). Fails closed."""
def _name(value) -> str:
return getattr(value, "name", str(value))
def _profile(vllm_config) -> tuple[list[str], object, object, list[str] | None]:
"""Resolved (architectures, mode, cudagraph mode, splitting ops)."""
model_config = getattr(vllm_config, "model_config", None)
if model_config is None:
raise RuntimeError("e2-guard: vllm_config has no model_config to check")
@@ -105,112 +112,242 @@ def _profile(vllm_config) -> tuple[list[str], object, object]:
architectures,
compilation_config.mode,
compilation_config.cudagraph_mode,
getattr(compilation_config, "splitting_ops", None),
)
def _opted_out(role: str, detail: str) -> bool:
if os.environ.get(ALLOW_BREAKABLE_ENV, "") != "1":
return False
logger.warning(
"e2-guard[%s]: %s=1 -- guards disabled by request (%s). This boot is "
"NOT a promotion-grade boot; a production launch must not set this flag.",
role,
ALLOW_BREAKABLE_ENV,
detail,
)
return True
def assert_graph_profile_is_executable(vllm_config, *, role: str = "target") -> None:
"""Refuse the two silently-wrong startup states on v0.30.0.
"""Require the qualified profile: VLLM_COMPILE + FULL_AND_PIECEWISE.
``role`` is ``"target"`` or ``"draft"``; both are checked, because
``Qwen4ExpMTP`` builds ``Qwen4ExpMultiTokenPredictor`` rather than
``Qwen4ExpForCausalLM`` (``mtp.py:397``, ``:411``) from a config rebuilt at
``mtp.py:159``, so the drafter's profile can differ from the target's.
Intentional eager and intentional ``CompilationMode.NONE`` are PERMITTED.
On v0.30.0's NVIDIA Qwen4Exp path ``NONE`` is a normal resolved state, not
evidence of the auto-enable: #55272 removed the compile wrappers, so
``_normalize_piecewise_cudagraph_mode`` legitimately lands there.
``Qwen4ExpForCausalLM``, from a config rebuilt in ``mtp.py``.
"""
from vllm.config import CompilationMode
architectures, mode, cudagraph_mode = _profile(vllm_config)
if os.environ.get(ALLOW_BREAKABLE_ENV, "") == "1":
logger.warning(
"e2-guard[%s]: %s=1 -- guards disabled by request. architectures=%s "
"breakable=%s compilation_mode=%s cudagraph_mode=%s. This boot is "
"NOT a promotion-grade boot; a production launch must not set this flag.",
role,
ALLOW_BREAKABLE_ENV,
architectures,
os.environ.get(BREAKABLE_ENV),
mode,
cudagraph_mode,
)
architectures, mode, cudagraph_mode, splitting_ops = _profile(vllm_config)
detail = (
f"architectures={architectures} breakable={os.environ.get(BREAKABLE_ENV)} "
f"compilation_mode={_name(mode)} cudagraph_mode={_name(cudagraph_mode)}"
)
if _opted_out(role, detail):
return
# 1. The pin must be explicit. Absence is the state _maybe_enable_breakable_
# cudagraph feeds on (config/vllm.py:758: "not in os.environ").
if BREAKABLE_ENV not in os.environ:
# 1. The pin must be explicit, so a future upstream merge that re-adds us
# to DEFAULT_BREAKABLE_CUDAGRAPH_ARCHITECTURES cannot flip it silently.
raw_breakable = os.environ.get(BREAKABLE_ENV)
if raw_breakable is None:
raise RuntimeError(
f"e2-guard[{role}]: {BREAKABLE_ENV} is not set. vLLM v0.30.0 lists "
f"{sorted(OUR_AUTO_BREAKABLE_ARCHITECTURES)} in "
"DEFAULT_BREAKABLE_CUDAGRAPH_ARCHITECTURES and turns the switch on "
"by itself when it is unset (vllm/config/vllm.py:756-774), forcing "
"CompilationMode.NONE with it. Pin it in the launcher: "
f"export {BREAKABLE_ENV}=0 (or =1 deliberately), or set "
f"{ALLOW_BREAKABLE_ENV}=1 to take an unpinned boot on purpose."
f"e2-guard[{role}]: {BREAKABLE_ENV} is not set. Pin it in the "
f"launcher: export {BREAKABLE_ENV}=0, or set {ALLOW_BREAKABLE_ENV}=1 "
"to take an unpinned boot on purpose."
)
breakable = breakable_resolved()
# 2. Breakable on is an identity this fork has never qualified.
if breakable:
# 2. Breakable capture is not the qualified identity.
if raw_breakable == "1" or breakable_resolved():
raise RuntimeError(
f"e2-guard[{role}]: {BREAKABLE_ENV} resolved ON for "
f"{architectures or '<unknown architecture>'} "
f"(compilation_mode={mode}, cudagraph_mode={cudagraph_mode}). That "
"is not the identity the v2.0.1 results were measured on. Export "
f"{BREAKABLE_ENV}=0, or set {ALLOW_BREAKABLE_ENV}=1 to take it "
"deliberately."
f"e2-guard[{role}]: {BREAKABLE_ENV} resolved ON ({detail}). The "
"qualified profile is breakable-off VLLM_COMPILE + "
f"FULL_AND_PIECEWISE. Export {BREAKABLE_ENV}=0, or set "
f"{ALLOW_BREAKABLE_ENV}=1 to take it deliberately."
)
# 3. PIECEWISE with breakable off needs a torch-compiled submodule, and
# #55272 removed every @support_torch_compile wrapper from
# vllm/models/qwen4_exp/nvidia/*. Upstream only rewrites the mode when
# compilation mode is NOT VLLM_COMPILE
# (config/vllm.py:1010-1030), so VLLM_COMPILE + PIECEWISE + breakable-off
# survives config time and then dies at
# gpu/cudagraph_utils.py:605 in the middle of capture. Fail here instead,
# with the candidates named.
# 2b. The production pin is the exact string "0".
# Upstream's accessor reads anything but "1" as off, so "2", "true",
# "" or "00" would resolve off -- but a mistyped launcher value must
# not be recorded as a qualified breakable-off profile. The logged
# debug opt-out (VLLM_E2_ALLOW_BREAKABLE=1, handled above) is separate.
if raw_breakable != PRODUCTION_BREAKABLE_PIN:
raise RuntimeError(
f"e2-guard[{role}]: {BREAKABLE_ENV}={raw_breakable!r} is not the "
f"production pin; it must be exactly {PRODUCTION_BREAKABLE_PIN!r}. "
"Upstream would read it as off, but the launch profile does not "
f"say what was meant. Export {BREAKABLE_ENV}=0, or set "
f"{ALLOW_BREAKABLE_ENV}=1 for a deliberate non-production boot."
)
# 3. The profile itself: mode AND cudagraph mode, by name.
if (
cudagraph_mode.requires_piecewise_compilation()
and mode is CompilationMode.VLLM_COMPILE
_name(mode) != REQUIRED_COMPILATION_MODE_NAME
or _name(cudagraph_mode) != REQUIRED_CUDAGRAPH_MODE_NAME
):
raise RuntimeError(
f"e2-guard[{role}]: cudagraph_mode={cudagraph_mode} needs piecewise "
"capture, compilation mode is VLLM_COMPILE and breakable cudagraphs "
"are off -- but vLLM PR #55272 removed every @support_torch_compile "
"wrapper from vllm/models/qwen4_exp/nvidia/, so "
"has_compiled_submodule() is False and capture will raise at "
"vllm/v1/worker/gpu/cudagraph_utils.py:605. Executable candidates: "
"(a) breakable off + -O0/CompilationMode.NONE, which normalises "
"FULL_AND_PIECEWISE to FULL_DECODE_ONLY (changed prefill "
"behaviour -- must be qualified); (b) breakable off + an explicit "
"cudagraph_mode=FULL or NONE; (c) breakable PIECEWISE, i.e. "
f"{BREAKABLE_ENV}=1, which is a different identity. See "
"the graph-profile choice."
f"e2-guard[{role}]: resolved compilation_mode={_name(mode)} "
f"cudagraph_mode={_name(cudagraph_mode)}; the qualified profile is "
f"compilation_mode={REQUIRED_COMPILATION_MODE_NAME} "
f"cudagraph_mode={REQUIRED_CUDAGRAPH_MODE_NAME} (compile-profile guard). Check "
"-O / --compilation-config / --enforce-eager / TORCH_COMPILE_DISABLE, "
f"or set {ALLOW_BREAKABLE_ENV}=1 for a deliberate non-production boot."
)
# 4. Optional exact pin of the resolved mode, for a launch profile.
# 4. The graph breaks that make PIECEWISE correct on this model.
if splitting_ops is None:
raise RuntimeError(
f"e2-guard[{role}]: compilation_config.splitting_ops is unresolved; "
"cannot confirm the Qwen4Exp graph breaks."
)
missing = [op for op in REQUIRED_SPLITTING_OPS if op not in splitting_ops]
if missing:
raise RuntimeError(
f"e2-guard[{role}]: splitting_ops is missing {missing}. Each of "
"these reads per-step request metadata (or forks/joins a side "
"stream) and would be frozen into a piecewise CUDA graph."
)
# 5. Optional exact pin of the resolved mode, for a launch profile.
expected = os.environ.get(EXPECTED_MODE_ENV, "").strip()
if expected:
actual = getattr(cudagraph_mode, "name", str(cudagraph_mode))
if actual != expected:
raise RuntimeError(
f"e2-guard[{role}]: resolved cudagraph_mode={actual} but "
f"{EXPECTED_MODE_ENV}={expected}. The launch profile and the "
"engine disagree about the graph identity."
)
if expected and _name(cudagraph_mode) != expected:
raise RuntimeError(
f"e2-guard[{role}]: resolved cudagraph_mode={_name(cudagraph_mode)} "
f"but {EXPECTED_MODE_ENV}={expected}. The launch profile and the "
"engine disagree about the graph identity."
)
logger.info(
"e2-guard[%s]: architectures=%s breakable=OFF compilation_mode=%s "
"cudagraph_mode=%s expected=%s. Recorded, not certified -- this guard "
"checks startup states, not that the profile was qualified.",
"cudagraph_mode=%s splitting_ops=+%d required. Recorded, not "
"certified -- this checks startup state, not qualification.",
role,
architectures,
mode,
cudagraph_mode,
expected or "<unset>",
_name(mode),
_name(cudagraph_mode),
len(REQUIRED_SPLITTING_OPS),
)
def assert_compiled_submodule(module, vllm_config, *, role: str = "target") -> None:
"""Require a live ``@support_torch_compile`` wrapper on ``module``.
This is the property ``has_compiled_submodule()`` checks before PIECEWISE
capture (``gpu/cudagraph_utils.py:132``, ``:605``). Checking it at
construction turns a mid-capture failure into a startup one.
"""
from vllm.compilation.wrapper import TorchCompileWithNoGuardsWrapper
compiled = isinstance(module, TorchCompileWithNoGuardsWrapper) and not getattr(
module, "do_not_compile", True
)
if compiled:
return
detail = (
f"{type(module).__name__} is_wrapper="
f"{isinstance(module, TorchCompileWithNoGuardsWrapper)} "
f"do_not_compile={getattr(module, 'do_not_compile', '<absent>')}"
)
if _opted_out(role, detail):
return
raise RuntimeError(
f"e2-guard[{role}]: {detail}: no live torch.compile wrapper, so "
"PIECEWISE capture would raise at gpu/cudagraph_utils.py:605. The "
"@support_torch_compile decorator (compile-profile guard) is missing or disabled."
)
# --------------------------------------------------------------------------
# Resolved runtime graph modes.
# --------------------------------------------------------------------------
#: Target architectures whose V2 capture is checked. The construction guard
#: above lives in the NVIDIA Qwen4Exp model; this tree targets sm_86 only.
QWEN4EXP_TARGET_ARCHITECTURES = frozenset(
{"Qwen4ExpForCausalLM", "Qwen4ExpForConditionalGeneration"}
)
#: What each V2 cudagraph manager may hold immediately before capture.
#: The construction guard checks ``compilation_config.cudagraph_mode``; the
#: V2 runner later calls ``resolve_cudagraph_mode_and_sizes`` (and, with
#: adaptive verification, ``resolve_adaptive_cudagraph_mode``), which may
#: downgrade to FULL_DECODE_ONLY / PIECEWISE / NONE or drop the piecewise half
#: (attention CG support, spec-decode uniform batches, no compiled submodule).
#: No such downgrade is allowed for the target. The drafter's managers are
#: derived from the target's resolved mode by the speculator itself:
#: * autoregressive / MTP (``AutoRegressiveSpeculator.init_cudagraph_manager``):
#: prefill = the target's mode unchanged; decode = FULL_DECODE_ONLY
#: ("PIECEWISE cudagraphs are not supported for draft decodes");
#: * multi-module MTP (``MultiModuleMTPSpeculator``): one manager,
#: FULL_AND_PIECEWISE -> FULL_DECODE_ONLY by design.
#: Those decode-specific modes are the only drafter deviations accepted.
EXPECTED_RESOLVED_MODES = {
"target": REQUIRED_CUDAGRAPH_MODE_NAME,
"draft.prefill_cudagraph_manager": REQUIRED_CUDAGRAPH_MODE_NAME,
"draft.decode_cudagraph_manager": "FULL_DECODE_ONLY",
"draft.cudagraph_manager": "FULL_DECODE_ONLY",
}
_DRAFT_MANAGER_ATTRS = (
"prefill_cudagraph_manager",
"decode_cudagraph_manager",
"cudagraph_manager",
)
def assert_resolved_cudagraph_modes(
vllm_config, target_manager, speculator=None
) -> None:
"""Fail loud if the V2 runner is about to capture a downgraded mode.
Called from ``GPUModelRunner.capture_model`` (``vllm/v1/worker/gpu``)
before any capture, including the ``profile_only`` capture and the
"nothing to capture" early return, so a resolver downgrade to NONE cannot
skip it. Applies only to a Qwen4Exp target; any other model is untouched.
``VLLM_E2_ALLOW_BREAKABLE=1`` skips it, logged, like the other graph
guards.
"""
model_config = getattr(vllm_config, "model_config", None)
architectures = list(getattr(model_config, "architectures", None) or [])
if not QWEN4EXP_TARGET_ARCHITECTURES & set(architectures):
return
observed: dict[str, str] = {}
if target_manager is None:
observed["target"] = "<no manager>"
else:
observed["target"] = _name(getattr(target_manager, "cudagraph_mode", None))
if speculator is not None:
found = False
for attr in _DRAFT_MANAGER_ATTRS:
if not hasattr(speculator, attr):
continue
found = True
manager = getattr(speculator, attr)
observed[f"draft.{attr}"] = (
"<no manager>"
if manager is None
else _name(getattr(manager, "cudagraph_mode", None))
)
if not found:
observed["draft"] = f"<unrecognised speculator {type(speculator).__name__}>"
detail = " ".join(f"{key}={value}" for key, value in observed.items())
if _opted_out("runtime", detail):
return
wrong = {
key: value
for key, value in observed.items()
if EXPECTED_RESOLVED_MODES.get(key) != value
}
if wrong:
expected = {key: EXPECTED_RESOLVED_MODES.get(key, "<none>") for key in wrong}
raise RuntimeError(
f"e2-guard[runtime]: resolved cudagraph modes {wrong} differ from "
f"the qualified profile {expected} ({detail}). The V2 runner's "
"resolver downgraded the graph identity after the construction "
"guard passed (attention CG support, spec-decode uniform batch, "
"or no compiled submodule); see the resolver's warning above. Set "
f"{ALLOW_BREAKABLE_ENV}=1 only for a deliberate non-production boot."
)
logger.info(
"e2-guard[runtime]: resolved cudagraph modes before capture: %s.", detail
)
+7
View File
@@ -64,6 +64,7 @@ from vllm.utils.gc_utils import freeze_gc_for_cudagraph_capture
from vllm.utils.mem_utils import DeviceMemoryProfiler, format_gib
from vllm.utils.torch_utils import STR_DTYPE_TO_TORCH_DTYPE, async_tensor_h2d
from vllm.v1.core.sched.output import GrammarOutput, SchedulerOutput
from vllm.v1.e2_guards import assert_resolved_cudagraph_modes
from vllm.v1.kv_cache_interface import (
KVCacheConfig,
MambaSpec,
@@ -1106,6 +1107,12 @@ class GPUModelRunner(LoRAModelRunnerMixin):
@torch.inference_mode()
def capture_model(self, *, profile_only: bool = False) -> int:
assert self.cudagraph_manager is not None
# Fork (0.30 rebase): the construction guard saw the configured
# mode; this asserts what the resolver actually handed the target and
# drafter managers, before any capture and before the early return.
assert_resolved_cudagraph_modes(
self.vllm_config, self.cudagraph_manager, self.speculator
)
capture_encoder = (
self.model_state.supports_mm_inputs
and self.model_state.encoder_runner.has_cudagraph()