Measure dual 256K agent runs and add experimental shared endpoint

This commit is contained in:
Pavlo Ratushnyi
2026-10-03 22:28:55 +02:00
parent 7360e33826
commit d51b7510e9
3 changed files with 189 additions and 4 deletions
+58 -3
View File
@@ -33,6 +33,61 @@ inside one engine still need separate implementation.
Two independent `codex-qwen` sessions started on the same Three.js tic-tac-toe
prompt used in the [single-worker comparison](2026-10-03-agent-gpu-kar-threejs.md).
They work in separate empty directories and use the shared dedicated MCP test
project. No operator changes their files or guides their calls. Their task
results, output-token totals, average rates, wall times, and common browser
checks will be added after both sessions finish.
project. No operator changed their files or guided their calls. The second
agent started 25.7 seconds after the first. Both produced one working WebGL
game. An independent browser replay for each passed the same six checks used
for the single-worker games: no page error, visible canvas, row win through
clicks, locked board after a win, restart, and draw through clicks.
| Run | Completed model requests | Tool calls | CLI input / cached tokens | CLI output tokens | Weighted decode tok/s | Wall time | Browser checks |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| Native single worker, earlier fresh run | 49 | 59 | 3,380,308 / 3,325,362 | 49,854 | 115.7 | 634.27 s | 6/6 |
| CPU KAR PLE single worker, earlier fresh run | 70 | 70 | 5,498,472 / 5,440,802 | 64,006 | 150.3 | 707.59 s | 6/6 |
| GPU KAR PLE single worker, earlier fresh run | 68 | 73 | 4,955,852 / 4,908,060 | 69,101 | 150.1 | 712.29 s | 6/6 |
| Dual worker A, native | 69 | 71 | 6,472,001 / 6,395,938 | 78,286 | 35.32 | 3,721.36 s | 6/6 |
| Dual worker B, native | 71 | 74 | 6,178,149 / 6,105,218 | 60,337 | 29.21 | 2,615.25 s | 6/6 |
The pair finished when A finished, **3,721.36 seconds** (62m 01s) after A
started. Together they produced 138,623 output tokens, an end-to-end aggregate
of **37.25 output tok/s** over that wall time; the weighted decode-only rate
across both was 32.37 tok/s. Four bridge requests failed and were retried;
one A request waited 968.43 seconds before timing out. Its server log had
stopped progressing while the GPU was idle. This is a stability failure even
though A eventually completed the task. Per-request decode rates had long
tails: A median 64.9, p10–p90 20.8–78.6 tok/s; B median 55.4, p10–p90
19.9–71.6 tok/s. A's first 20 completed requests weighted 22.6 tok/s while
both agents competed; its last eight after B finished weighted 66.3 tok/s.
This dual-process profile **does not improve end-to-end throughput** on this
workload. Its expert cache is much smaller than the single-worker profile, the
agents followed different paths, and the 968-second stall dominates A's wall
time. The one-run comparison is directional, not an isolated estimate of the
cost of request concurrency. It does prove two full 256K contexts and two
simultaneous requests fit on this GPU. A production one-engine two-slot
scheduler remains unbuilt and unmeasured.
## One endpoint, two requests
The requested interface is one endpoint that accepts two simultaneous requests
from a client. The first run above instead used two independent agent clients
on separate ports; it measures GPU feasibility and end-to-end contention but
does not by itself prove that interface. The experimental
`scripts/strata-dual-request-proxy.py` now admits one request to each worker
through a single HTTP address. A local barrier test confirmed that two
concurrent calls to that address reached distinct workers. The proxy preserves
the first worker for serial requests so a single agent can reuse its prefix
cache. A second local barrier test confirmed that both streamed responses
delivered their terminal SSE event. After both agents completed, one client
sent two simultaneous Chat Completions to that same address. Both workers
reported `is_processing=true` at the same time. Both returned 30 completion
tokens, `finish_reason=stop`, and nonempty content; their individual latencies
were 3.82 and 3.80 seconds, and the pair took 3.88 seconds. This is
HTTP-level concurrency across two processes, not continuous batching in one
model process. It is a short correctness smoke, not a speed claim for a
long-running agent.
The experimental proxy and workers were stopped after testing. GPU memory
fell to 34 MiB; temporary credential configs under `/dev/shm` were removed.
Private model shards and the validated KAR archive were retained. The two
games and event logs remain in the ignored local experiment directory to
reproduce these measurements.
+1 -1
View File
@@ -3,7 +3,7 @@ set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
python3 -m py_compile "${repo_root}/scripts/bench-chat-paired.py" "${repo_root}/scripts/compare-chat-reports.py" "${repo_root}/scripts/bench-chat-sequential-server.py" "${repo_root}/scripts/check-kar-cuda-records.py" "${repo_root}/scripts/strata-agent-profile.py" "${repo_root}/scripts/strata-dual-256-experiment.py" "${repo_root}/scripts/kv-keyless-feasibility.py" "${repo_root}/scripts/kv-keyless-attention.py" "${repo_root}/scripts/bench-expert-reserve.py" "${repo_root}/scripts/ple-cache-reuse.py" "${repo_root}/scripts/split-ple-row-trace.py" "${repo_root}/scripts/bench-kar-ple-device.py" "${repo_root}/scripts/bench-kar-ple-serve.py"
python3 -m py_compile "${repo_root}/scripts/bench-chat-paired.py" "${repo_root}/scripts/compare-chat-reports.py" "${repo_root}/scripts/bench-chat-sequential-server.py" "${repo_root}/scripts/check-kar-cuda-records.py" "${repo_root}/scripts/strata-agent-profile.py" "${repo_root}/scripts/strata-dual-256-experiment.py" "${repo_root}/scripts/strata-dual-request-proxy.py" "${repo_root}/scripts/kv-keyless-feasibility.py" "${repo_root}/scripts/kv-keyless-attention.py" "${repo_root}/scripts/bench-expert-reserve.py" "${repo_root}/scripts/ple-cache-reuse.py" "${repo_root}/scripts/split-ple-row-trace.py" "${repo_root}/scripts/bench-kar-ple-device.py" "${repo_root}/scripts/bench-kar-ple-serve.py"
python3 "${repo_root}/scripts/test-benchmark-harness.py"
cargo fmt --manifest-path "${repo_root}/control-plane/Cargo.toml" --check
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env python3
"""Experimental one-endpoint admission for two independent Strata workers.
Each upstream still owns one sequence. This proxy accepts two concurrent HTTP
requests and gives each a different worker; it does not batch model kernels.
Production serving must use the Rust control plane instead.
"""
import argparse
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import hmac
import json
from pathlib import Path
import threading
import urllib.error
import urllib.request
class Pool:
def __init__(self, upstreams):
self.upstreams = upstreams
self.free = [True] * len(upstreams)
self.condition = threading.Condition()
def acquire(self):
with self.condition:
self.condition.wait_for(lambda: any(self.free))
# Serial turns stay on worker zero for prefix reuse. A concurrent
# second request goes to worker one.
index = self.free.index(True)
self.free[index] = False
return index
def release(self, index):
with self.condition:
self.free[index] = True
self.condition.notify()
class Handler(BaseHTTPRequestHandler):
protocol_version = 'HTTP/1.1'
server_version = 'StrataDualExperiment/0.1'
def log_message(self, format, *args):
# Requests may contain private prompts and credentials.
pass
def do_GET(self):
self.forward()
def do_POST(self):
self.forward()
def forward(self):
if not hmac.compare_digest(self.headers.get('Authorization', ''),
'Bearer ' + self.server.api_key):
self.send_error(401)
return
if self.path not in ('/health', '/slots', '/v1/models', '/models',
'/v1/chat/completions', '/v1/completions'):
self.send_error(404)
return
try:
length = int(self.headers.get('Content-Length', '0'))
except ValueError:
self.send_error(400)
return
if length < 0 or length > 64 * 1024 * 1024:
self.send_error(413)
return
body = self.rfile.read(length) if length else None
index = self.server.pool.acquire()
response_started = False
try:
request = urllib.request.Request(
self.server.pool.upstreams[index] + self.path,
data=body if self.command == 'POST' else None,
method=self.command,
headers={
'Authorization': self.headers['Authorization'],
'Content-Type': self.headers.get('Content-Type', 'application/json'),
'Accept': self.headers.get('Accept', '*/*'),
},
)
try:
response = urllib.request.urlopen(request, timeout=900)
except urllib.error.HTTPError as error:
response = error
with response:
self.send_response(response.status)
self.send_header('Content-Type', response.headers.get('Content-Type',
'application/json'))
self.send_header('Connection', 'close')
self.end_headers()
response_started = True
self.close_connection = True
reader = getattr(response, 'read1', response.read)
while chunk := reader(65536):
self.wfile.write(chunk)
self.wfile.flush()
except (BrokenPipeError, ConnectionResetError):
pass
except (OSError, ValueError):
if not response_started:
self.send_error(502)
finally:
self.server.pool.release(index)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--host', default='127.0.0.1')
parser.add_argument('--port', type=int, default=18080)
parser.add_argument('--upstream', action='append', required=True)
parser.add_argument('--config', type=Path, required=True,
help='private Strata JSON config containing api_key')
options = parser.parse_args()
if len(options.upstream) != 2 or not 1 <= options.port <= 65535:
parser.error('exactly two --upstream values and a valid port are required')
config = json.loads(options.config.read_text())
with ThreadingHTTPServer((options.host, options.port), Handler) as server:
server.api_key = config['api_key']
server.pool = Pool([url.rstrip('/') for url in options.upstream])
print(json.dumps({'host': options.host, 'port': options.port,
'upstream_count': len(options.upstream)}), flush=True)
server.serve_forever(poll_interval=0.2)
if __name__ == '__main__':
main()