Skip to content

Commit 61e30f0

Browse files
committed
lint
1 parent af095fb commit 61e30f0

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎src/mobius/_execution_providers.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ def __post_init__(self) -> None:
108108
f"supports_fused_rope=False — UnpackQKV lowering always fires for "
109109
f"this EP, so packing would be immediately undone."
110110
)
111+
if self.cap_kv_buffer_max_length and not self.supports_past_present_share_buffer:
112+
raise ValueError(
113+
f"EP '{self.name}': cap_kv_buffer_max_length=True requires "
114+
f"supports_past_present_share_buffer=True — the cap only matters "
115+
f"when the runtime pre-allocates the full KV-cache buffer at load "
116+
f"time, which is what buffer sharing enables."
117+
)
111118

112119

113120
class EpRegistry:
@@ -260,14 +267,15 @@ def _register_builtins() -> None:
260267
# InlinePass to their standard-ONNX function bodies. No GQA or QKV
261268
# packing fusion is applied. Use this EP to produce models that run
262269
# on any conformant ONNX runtime without ORT extensions.
270+
# KV buffer sharing is unsupported here: GQA isn't emitted, so
271+
# standard Attention's concat-grow semantics handle the cache.
263272
EpCapabilities(
264273
name="onnx-standard",
265274
gqa_dtypes=frozenset(), # no GroupQueryAttention
266275
qkv_pack_dtypes=frozenset(), # no PackQKV
267276
supports_fused_rope=False, # no fused RoPE inside GQA (GQA not supported)
268277
supports_skip_layer_norm=False, # inline SkipLayerNorm
269278
supports_packed_multi_head_attention=False, # inline PackedMHA
270-
supports_past_present_share_buffer=True,
271279
),
272280
]
273281
for caps in _builtins:

‎src/mobius/integrations/ort_genai/genai_config.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ def _default_search_params(*, ep: str, context_length: int) -> dict[str, Any]:
6262
caps = ep_registry.get(ep)
6363
share_buffer = caps.supports_past_present_share_buffer if caps is not None else False
6464
cap_length = caps.cap_kv_buffer_max_length if caps is not None else False
65-
if cap_length:
65+
if share_buffer and cap_length:
6666
# Memory-constrained EPs (e.g. WebGPU on consumer GPUs) pre-allocate
6767
# KV-cache for the full max_length at load time. Cap the default to
6868
# avoid pre-allocating huge buffers (~8 GB for 128K-token models).
6969
# Users can raise the limit in genai_config.json for their device.
70+
# The cap only applies when buffer sharing is also active — without
71+
# sharing, the runtime grows the cache on demand and no cap is needed.
7072
max_length = min(context_length, _SHARE_BUFFER_MAX_LENGTH_CAP)
7173
else:
7274
max_length = context_length

0 commit comments

Comments
 (0)