fix inference
This commit is contained in:
@@ -246,6 +246,11 @@ class _TorchHandler(http.server.BaseHTTPRequestHandler):
|
||||
# but correct. Each step: head encodes current sequence → forwards through route
|
||||
# → tail returns the next token string → append → repeat.
|
||||
remaining_route = self._get_remaining_route(model_name)
|
||||
print(
|
||||
f" [node] chat route model={model_name!r} max_tokens={max_tokens} "
|
||||
f"downstream={remaining_route}",
|
||||
flush=True,
|
||||
)
|
||||
if not remaining_route:
|
||||
self._send_openai_response(
|
||||
"error: no downstream route — check tracker connectivity",
|
||||
@@ -300,7 +305,9 @@ class _TorchHandler(http.server.BaseHTTPRequestHandler):
|
||||
try:
|
||||
route = json.loads(injected)
|
||||
if isinstance(route, list):
|
||||
return [str(ep) for ep in route]
|
||||
resolved = [str(ep) for ep in route]
|
||||
print(f" [node] using injected downstream route: {resolved}", flush=True)
|
||||
return resolved
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
pass
|
||||
|
||||
@@ -315,7 +322,9 @@ class _TorchHandler(http.server.BaseHTTPRequestHandler):
|
||||
route_resp = json.loads(r.read())
|
||||
route = route_resp.get("route", [])
|
||||
own_port = server.server_address[1]
|
||||
return [ep for ep in route if not ep.rstrip("/").endswith(f":{own_port}")]
|
||||
resolved = [ep for ep in route if not ep.rstrip("/").endswith(f":{own_port}")]
|
||||
print(f" [node] tracker downstream route: {resolved}", flush=True)
|
||||
return resolved
|
||||
except Exception as exc:
|
||||
print(f" [node] WARNING: route lookup failed for {route_model!r}: {exc}", flush=True)
|
||||
return []
|
||||
@@ -346,6 +355,7 @@ class _TorchHandler(http.server.BaseHTTPRequestHandler):
|
||||
current_pos = pos_ids
|
||||
|
||||
for hop_index, node_url in enumerate(route):
|
||||
print(f" [node] pipeline hop {hop_index}: {node_url}", flush=True)
|
||||
headers: dict[str, str] = {
|
||||
"Content-Type": "application/octet-stream",
|
||||
"X-Meshnet-Wire": _WIRE_VERSION,
|
||||
@@ -371,12 +381,15 @@ class _TorchHandler(http.server.BaseHTTPRequestHandler):
|
||||
resp_body = r.read()
|
||||
resp_headers = {k.lower(): v for k, v in r.headers.items()}
|
||||
except Exception as exc:
|
||||
print(f" [node] pipeline hop {hop_index} failed at {node_url}: {exc}", flush=True)
|
||||
return f"pipeline error at {node_url}: {exc}"
|
||||
content_type = resp_headers.get("content-type", "")
|
||||
if "application/json" in content_type:
|
||||
try:
|
||||
data = json.loads(resp_body)
|
||||
return str(data.get("text", ""))
|
||||
text = str(data.get("text", ""))
|
||||
print(f" [node] pipeline hop {hop_index} returned text={text!r}", flush=True)
|
||||
return text
|
||||
except json.JSONDecodeError:
|
||||
return resp_body.decode("utf-8", errors="replace")
|
||||
# Binary activation — update and forward to next node
|
||||
|
||||
Reference in New Issue
Block a user