Add authenticated content-free speed telemetry for Athena Pulse
This commit is contained in:
1 parent
9572d9f680
commit
7fa040094f
6 files changed
+92
No files matched your search
@@ -231,6 +231,31 @@ class Dashboard:
|
||||
result['available'] = bool(result['slots'] or result['metrics'])
|
||||
return result
|
||||
|
||||
def speed_snapshot(self):
|
||||
"""Content-free backend-wide rates; never a claim about one client's chat."""
|
||||
worker = self.server.worker.status()
|
||||
backend = worker.get('runtime', 'llama')
|
||||
result = dict(schema_version=1, sampled_at=time.time(), scope='backend',
|
||||
backend=backend, phase='unloaded', generation_tok_s=None,
|
||||
prefill_tok_s=None, active_slots=None, attribution='unavailable')
|
||||
if worker.get('state') != 'ready':
|
||||
return result
|
||||
if backend != 'strata':
|
||||
result['phase'] = 'unsupported'
|
||||
return result
|
||||
live = strata_live(self._read_worker('/metrics?format=prometheus').decode('utf-8', 'replace'))
|
||||
result['phase'] = live.get('phase', 'unknown')
|
||||
if result['phase'] == 'generating':
|
||||
result['generation_tok_s'] = live.get('generation_rate')
|
||||
if result['phase'] == 'reading':
|
||||
result['prefill_tok_s'] = live.get('prompt_rate')
|
||||
try:
|
||||
slots = slot_data(json.loads(self._read_worker('/slots')))
|
||||
result['active_slots'] = sum(bool(row['processing']) for row in slots)
|
||||
except (OSError, ValueError, TypeError, http.client.HTTPException):
|
||||
pass
|
||||
return result
|
||||
|
||||
def snapshot(self):
|
||||
now = time.monotonic()
|
||||
with self.lock:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Athena Pulse — 20 October 2026
|
||||
|
||||
Private standalone repository: https://git.casaderoll.de/michael/athena-pulse
|
||||
|
||||
User requested a Hermes speed plugin and a new Gitea repo. This change adds
|
||||
GET /v1/telemetry/speed to the existing authenticated inference API. It reads
|
||||
Strata's numeric live Prometheus gauge and content-filtered slot status, never
|
||||
loads a model and returns no prompts/completions/keys/session identifiers. Rates
|
||||
are backend-wide, NOT attributed to the focused Hermes session or either slot.
|
||||
No average over whole request latency is substituted. Unsupported/unloaded/idle
|
||||
states do not show a stale generation rate.
|
||||
|
||||
The plugin comprises a NAS Hermes user-plugin API and a standalone Mac Desktop
|
||||
statusbar file. It uses supported ctx.rest plus React Query; no Hermes core patch,
|
||||
new container, model/tool invocation, custom Hermes image or Conduit UI. Credentials
|
||||
are private runtime configuration excluded from Git. No credentials copied yet.
|
||||
|
||||
Validation: 5 proxy tests, 2 Desktop display tests and 9 Deck tests pass (the last
|
||||
includes the existing dashboard-data tests plus speed contract and authenticated
|
||||
HTTP endpoint test). Mac native rendering, live remote transport and production
|
||||
activation are still pending. Automatic approval review blocked staging a Deck
|
||||
image/recreate update; explicit user permission requested before proceeding.
|
||||
Production services were not restarted or changed for this feature.
|
||||
|
||||
Native Debian: the normal Deck update ships dashboard_data.py, endpoint.py and
|
||||
server.py together. No Docker is needed for the feature itself. Existing encrypted
|
||||
state backup holds credentials; Hermes appdata backup must include plugin files
|
||||
and private connection.json, and Mac UI file restore is separate. Fresh native
|
||||
restore E2E remains unqualified. See standalone README for lifecycle and removal.
|
||||
@@ -375,6 +375,10 @@ class APIHandler(BaseHTTPRequestHandler):
|
||||
if not ep.allowed():raise APIError('Endpunkt wird gestoppt.',503,'endpoint_stopping')
|
||||
ep.inflight+=1;admitted=True
|
||||
parsed=urlsplit(self.path)
|
||||
if self.command=='GET' and parsed.path=='/v1/telemetry/speed':
|
||||
provider=getattr(ep,'speed_telemetry',None)
|
||||
if not callable(provider):raise APIError('Geschwindigkeitstelemetrie nicht verfügbar.',503,'telemetry_unavailable')
|
||||
return self.send(provider())
|
||||
if self.command=='GET' and (parsed.path=='/models' or (parsed.path=='/v1/models' and ep.scheduler.gpu_mode!='video')):
|
||||
return self.send(ep.model_list())
|
||||
if self.command=='GET' and parsed.path=='/props':
|
||||
|
||||
@@ -251,6 +251,7 @@ class Server(ThreadingHTTPServer):
|
||||
self.profiles.video_runtime_ready=lambda:self.image_runtime.status().get("installed",False)
|
||||
from dashboard_data import Dashboard
|
||||
self.dashboard=Dashboard(self,self.catalog.root.parent)
|
||||
self.endpoint.speed_telemetry=self.dashboard.speed_snapshot
|
||||
if self.endpoint.config['autostart']:
|
||||
try:self.endpoint.start()
|
||||
except ValueError as exc:self.endpoint.error=str(exc)
|
||||
|
||||
@@ -66,6 +66,14 @@ class EndpointTests(unittest.TestCase):
|
||||
status,result=self.request('/v1/chat/completions',dict(model='alpha',messages=[{'role':'user','content':'x'*(1100*1024)}]))
|
||||
self.assertEqual(status,200,result)
|
||||
self.assertEqual(len(self.worker.requests[-1]['messages'][0]['content']),1100*1024)
|
||||
def test_speed_telemetry_requires_auth_and_does_not_load_a_model(self):
|
||||
sample=dict(schema_version=1,scope='backend',phase='idle',generation_tok_s=None)
|
||||
self.ep.speed_telemetry=Mock(return_value=sample)
|
||||
code,result=self.request('/v1/telemetry/speed',token='wrong')
|
||||
self.assertEqual(code,401);self.ep.speed_telemetry.assert_not_called()
|
||||
code,result=self.request('/v1/telemetry/speed')
|
||||
self.assertEqual(code,200);self.assertEqual(result,sample)
|
||||
self.assertEqual(self.worker.started,[])
|
||||
def test_oversized_request_rejected_before_body_read(self):
|
||||
conn=http.client.HTTPConnection('127.0.0.1',self.port,timeout=5)
|
||||
conn.request('POST','/v1/chat/completions',body=None,headers={'Authorization':'Bearer '+'A'*32,'Content-Type':'application/json','Content-Length':str(64*1024*1024+1)})
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import json
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock
|
||||
from dashboard_data import Dashboard
|
||||
|
||||
class SpeedTests(unittest.TestCase):
|
||||
def dashboard(self,state='ready',runtime='strata'):
|
||||
d=object.__new__(Dashboard)
|
||||
d.server=SimpleNamespace(worker=SimpleNamespace(status=lambda:dict(state=state,runtime=runtime)))
|
||||
return d
|
||||
def test_live_rate_is_phase_scoped_and_content_free(self):
|
||||
d=self.dashboard()
|
||||
responses={'/metrics?format=prometheus':b'strata:live_state{state="generating"} 1\nstrata:live_tok_s 51.7\nstrata:live_prefill_tok_s_mean 500', '/slots':json.dumps([dict(id=0,is_processing=True,prompt='private'),dict(id=1,is_processing=False)]).encode()}
|
||||
d._read_worker=Mock(side_effect=lambda path:responses[path]);r=d.speed_snapshot()
|
||||
self.assertEqual(r['generation_tok_s'],51.7);self.assertIsNone(r['prefill_tok_s'])
|
||||
self.assertEqual(r['active_slots'],1);self.assertEqual(r['scope'],'backend')
|
||||
self.assertNotIn('private',json.dumps(r))
|
||||
self.assertEqual({x.args[0] for x in d._read_worker.call_args_list},set(responses))
|
||||
def test_unloaded_does_not_touch_worker(self):
|
||||
d=self.dashboard(state='stopped');d._read_worker=Mock()
|
||||
self.assertIsNone(d.speed_snapshot()['generation_tok_s']);d._read_worker.assert_not_called()
|
||||
def test_unsupported_is_not_estimated(self):
|
||||
self.assertEqual(self.dashboard(runtime='llama').speed_snapshot()['phase'],'unsupported')
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user