Skip to content

Commit eaefb07

Browse files
hbarclayclaude
andcommitted
operatorx attention: ask backends for CUDA-graph support under vLLM's current config
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent a0ee5b8 commit eaefb07

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

‎operatorx/runners/common/vllm/attention.py‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,24 +504,22 @@ def _kernel(ctx: dict) -> None:
504504
def _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

Comments
 (0)