@@ -504,24 +504,22 @@ def _kernel(ctx: dict) -> None:
504504def _cudagraph (ctx : dict ) -> bool :
505505 """Whether vLLM would replay this batch as a full CUDA graph: a uniform decode batch
506506 within the capture sizes, on backends that support one."""
507+ with ctx ["engine" ]._configured (): # backends read vLLM's current config to answer
508+ return _full_graph (ctx ["engine" ])
509+
510+
511+ def _full_graph (eng : _Engine ) -> bool :
507512 from vllm .v1 .attention .backend import AttentionCGSupport
508- groups = ctx ["engine" ].reqs
509- qs = {r .num_tokens - r .num_computed_tokens for r in groups }
513+ qs = {r .num_tokens - r .num_computed_tokens for r in eng .reqs }
510514 if len (qs ) != 1 :
511515 return False
512516 q = qs .pop ()
513- tokens = q * len (groups )
514- from vllm .config import set_current_vllm_config
515- with set_current_vllm_config (ctx ["engine" ].runner .vllm_config ):
516- top = vllm_linear ._capture_sizes ()[- 1 ]
517- if tokens > top :
517+ if q * len (eng .reqs ) > vllm_linear ._capture_sizes ()[- 1 ]:
518518 return False
519519 need = AttentionCGSupport .UNIFORM_SINGLE_TOKEN_DECODE if q == 1 else AttentionCGSupport .UNIFORM_BATCH
520- runner = ctx ["engine" ].runner
521- for gs in runner .attn_groups :
520+ for gs in eng .runner .attn_groups :
522521 for g in gs :
523- builder = g .backend .get_builder_cls ()
524- support = builder .get_cudagraph_support (runner .vllm_config , g .kv_cache_spec )
522+ support = g .backend .get_builder_cls ().get_cudagraph_support (eng .runner .vllm_config , g .kv_cache_spec )
525523 if support .value < need .value :
526524 return False
527525 return True
0 commit comments