relay working with qwen2.5;

relay anounced on node ready
This commit is contained in:
Dobromir Popov
2026-07-09 10:48:32 +02:00
parent 4c6e1ed8b6
commit 1d3fb060ae
6 changed files with 100 additions and 7 deletions

View File

@@ -308,7 +308,11 @@ class TorchModelShard:
self._norm = _final_norm(self.model) if self.is_tail else None
self._lm_head = getattr(self.model, "lm_head", None) if self.is_tail else None
# Per-session KV/recurrent-state cache for this shard's layer range.
self.supports_kv_cache = True
# Hybrid/linear-attention models such as Qwen3.6 can dispatch Triton
# recurrent-cache kernels when use_cache=True. Those kernels cannot
# consume CPU tensors ("Pointer argument cannot be accessed from Triton"),
# so CPU shards intentionally stay on the stateless prefill path.
self.supports_kv_cache = self.device.type != "cpu"
self.kv_sessions = SessionCacheStore(
max_sessions=int(os.environ.get("MESHNET_KV_MAX_SESSIONS", "8")),
ttl_seconds=float(os.environ.get("MESHNET_KV_TTL_SECONDS", "600")),
@@ -612,9 +616,13 @@ class TorchModelShard:
hidden_states, attention_mask, position_ids,
start_layer=start_layer, cache=cache, past_len=0,
)
except TypeError as exc:
except Exception as exc:
if not _cache_unsupported_for_shard(exc):
raise
# Layers reject cache kwargs (exotic architecture) — disable caching
# for this backend and stay on the stateless path.
# for this backend and stay on the stateless path. Some hybrid
# CPU paths also accept cache kwargs but fail at runtime inside
# Triton-only kernels; treat those as cache-unsupported too.
self.supports_kv_cache = False
print(f" [node] kv cache unsupported by {self.model_id}: {exc}", flush=True)
return self._run_layers(
@@ -1146,3 +1154,13 @@ def _looks_like_oom(exc: BaseException) -> bool:
return True
current = current.__cause__ or current.__context__
return False
def _cache_unsupported_for_shard(exc: BaseException) -> bool:
"""True when a layer failure means session cache is unsupported, not fatal."""
text = str(exc).lower()
return (
isinstance(exc, TypeError)
or "pointer argument cannot be accessed from triton" in text
or ("triton" in text and "cpu tensor" in text)
)