Record Three.js agent A/B and add isolated profile controller

This commit is contained in:
Pavlo Ratushnyi
2026-10-03 14:16:57 +02:00
parent 7a6d1d6d93
commit 3fa57b9e11
2 changed files with 267 additions and 0 deletions
@@ -0,0 +1,78 @@
# Three.js agent task: native Strata versus KAR PLE, 2026-10-03
## Scope and fixed setup
One Codex agent per arm received the identical prompt (SHA-256
`e10a433962e47b191b8269348cf26f9756d070ca800f2fe77213aa13f78023b1`):
build a single-file Three.js/WebGL tic-tac-toe game, verify it, and complete
the dedicated LeaseVibe test-project workflow. The agents ran sequentially in
separate empty workspaces. No operator changed either game's files or helped
either agent while it worked. The original Strata launcher profile was left
untouched. Test project tasks were `TEST-2` (baseline) and `TEST-3` (KAR PLE),
both reported Done by their agents.
Both arms used the Linux RTX 5090 host, driver 595.91.07, CUDA 13.2, the same
Qwen3.8-Flash-Next IQ3_S shards, source commit and engine configuration listed
in [the paired inference report](2026-10-03-kar-ple-ab.md). Each had one 256K
slot, INT8 **K+V** cache with 32,768 resident cells, MTP speculation depth 4,
and Strata's ordinary expert cache. The candidate used level-2 KAR only for
the PLE table, read and decoded on CPU. The model shards and KAR artifact were
on NTFS. This was neither the proposed compressed expert cache in VRAM nor
the experimental V-only KV path. The two agents followed different tool and
generation trajectories; this is one agent run per arm, not a paired
statistical benchmark.
## End-to-end observations
| Metric | Native baseline | KAR PLE candidate |
| --- | ---: | ---: |
| Full agent wall time | 2,162.44 s (36m02s) | 1,810.22 s (30m10s) |
| Codex CLI input tokens | 3,297,339 | 3,226,901 |
| Codex CLI cached input tokens | 1,100,546 | 741,408 |
| Codex CLI output tokens | 52,878 | 37,439 |
| Output tokens / full wall second | 24.45 | 20.68 |
| Completed bridge requests | 97 | 95 |
| Median request decode rate | 62.0 tok/s | 118.9 tok/s |
| Decode tokens / sum of decode time | 52.35 tok/s | 44.06 tok/s |
| Prompt tokens / sum of prompt time | 3,804 tok/s | 5,312 tok/s |
| Median first-token latency | 7.49 s | 8.50 s |
| Final HTML size | 13,930 bytes | 15,771 bytes |
| Shared browser checks | 6/6 | 6/6 |
The candidate's full task was 16.3% shorter, but its output-token count was
29.2% lower. Its output tokens per full wall second were 15.4% lower. The
per-request median decode rate is strongly affected by request length:
candidate had 30 requests below 100 generated tokens versus five in the
baseline. Weighting by all measured decode time reverses the median's apparent
gain. Neither ratio isolates an engine effect in these divergent agent traces.
MCP schema rejections and later corrected calls are ordinary parts of the
workflow; they are included in wall time and were not scored as quality defects.
The operator's same browser test ran after both agents finished, without
editing their files: each loaded without a page error, rendered a visible
WebGL canvas, completed a row win through real clicks, blocked moves after
the win, restarted to an empty board, and reached a draw through real clicks.
Both scored 6/6. Their own agent tests reported 37 Chrome assertions and
29 Chromium assertions respectively; these are different suites and their
counts are not comparable quality scores. This task did not measure model
perplexity, long-context retrieval, tool-call fidelity over a dataset, or
V-only KV quality.
Private prompt, final HTML files, raw event streams, bridge logs, and the
common browser test remain outside Git under
`/Users/para/.cache/strata-next/agent-ab-threejs-20261003/` and
`/Users/para/.codex-qwen-interactive/bridge-logs/`. The final HTML digests
are `c4bc939d7fabd51f2a95d95c430c04fdaf64c9e27d2fd0300baebc3b59e0bfe4`
(baseline) and `9a944c1e1d23042f362eb6078fb49aa07b45eb677ad631edd77308fff005dbc5`
(KAR PLE).
## Decision
This agent task provides a successful functional comparison, not evidence of
a KAR performance improvement. The earlier paired inference suite found
matched short outputs but no CPU PLE speedup. The current runtime should not
be replaced on the basis of these runs. The next performance experiment must
integrate a bounded GPU-resident compressed weight cache and CUDA decoding
into the actual inference path, then compare identical requests and agent
tasks with a quality gate. V-only KV is a separate lossy mode and needs its
own long-context and tool-call quality gate before any default use.
+189
View File
@@ -0,0 +1,189 @@
#!/usr/bin/env python3
"""Start one private Strata A/B agent profile on the Linux GPU host.
This is an offline experiment controller. It keeps its config in tmpfs, never
prints credentials, and does not modify the ordinary Strata service on port 8080.
"""
import json
import os
from pathlib import Path
import signal
import subprocess
import sys
import time
import urllib.request
ROOT = Path('/home/para/.cache/strata-next/agent-profiles')
STATE = ROOT / 'state.json'
CONFIG = Path('/dev/shm/strata-next-agent-profile.json')
SOURCE = Path('/home/para/inference/strata/strata-iq3_s.json')
SERVER = Path('/home/para/inference/strata/serve/server.py')
PYTHON = Path('/home/para/inference/strata/.venv/bin/python')
ARCHIVE = Path('/mnt/microcrm-flash-preflight/microcrm-flash-next-experiment/strata-next/qwen-iq3-s-l2-v4.kar')
EXES = {
'strata-next-baseline': Path('/home/para/.cache/strata-next/engine-fork-f80a3e0/build/strata'),
'strata-next-kar-ple': Path('/home/para/.cache/strata-next/engine-kar-ple-build/strata'),
}
HOST = '192.168.1.196'
PORT = 18081
URL = f'http://{HOST}:{PORT}'
def pid_alive(pid):
try:
os.kill(pid, 0)
return True
except (ProcessLookupError, PermissionError):
return False
def state():
if not STATE.exists():
return None
value = json.loads(STATE.read_text())
if not pid_alive(value['pid']):
return None
return value
def health():
try:
with urllib.request.urlopen(URL + '/health', timeout=3) as response:
value = json.load(response)
return {'ready': bool(value.get('loaded') and value.get('max_context') == 262144),
'context': value.get('max_context')}
except (OSError, ValueError):
return {'ready': False}
def status():
current = state()
observed = health() if current else {'ready': False}
return {'profile': current['profile'] if current else None,
'pid': current['pid'] if current else None, **observed}
def unload(current):
if health()['ready']:
key = json.loads(CONFIG.read_text())['api_key']
request = urllib.request.Request(URL + '/unload', data=b'{}', method='POST',
headers={'Authorization': 'Bearer ' + key,
'Content-Type': 'application/json'})
with urllib.request.urlopen(request, timeout=180) as response:
if response.status != 200:
raise RuntimeError('model unload failed')
try:
os.killpg(current['pid'], signal.SIGTERM)
except ProcessLookupError:
pass
for _ in range(30):
if not pid_alive(current['pid']):
break
time.sleep(1)
if pid_alive(current['pid']):
os.killpg(current['pid'], signal.SIGKILL)
STATE.unlink(missing_ok=True)
CONFIG.unlink(missing_ok=True)
def ensure_idle():
current = state()
if not current:
return
config = json.loads(CONFIG.read_text())
key = config['api_key']
request = urllib.request.Request(URL + '/slots',
headers={'Authorization': 'Bearer ' + key})
try:
with urllib.request.urlopen(request, timeout=5) as response:
slots = json.load(response)
except (OSError, ValueError):
raise RuntimeError('experimental server is loading or its state is unknown')
if not slots or any(slot.get('is_processing', True) for slot in slots):
raise RuntimeError('experimental server is processing a request')
def start(profile):
if profile not in EXES:
raise ValueError('unknown experiment profile')
current = state()
if current and current['profile'] == profile:
return {'started': False, **status()}
if current:
ensure_idle()
unload(current)
elif STATE.exists():
STATE.unlink()
CONFIG.unlink(missing_ok=True)
if health()['ready']:
raise RuntimeError('port is already occupied by an untracked server')
used = subprocess.check_output(
['nvidia-smi', '--query-gpu=memory.used', '--format=csv,noheader,nounits'],
text=True).strip()
if int(used.splitlines()[0]) > 1024:
raise RuntimeError('GPU is already occupied by another workload')
for path in (SOURCE, SERVER, PYTHON, EXES[profile]):
if not path.is_file():
raise FileNotFoundError(path)
if profile == 'strata-next-kar-ple' and not ARCHIVE.is_file():
raise FileNotFoundError(ARCHIVE)
raw = json.loads(SOURCE.read_text())
args = raw['args']
if (args[args.index('--max-context') + 1] != '262144' or
args[args.index('--kv') + 1] != 'int8' or
args[args.index('--kv-resident') + 1] != '32768'):
raise RuntimeError('expected 1x256K with INT8 K+V and 32768 resident cells')
if '--ple-kar' in args or '--control-vector-scaled' in args:
raise RuntimeError('source config contains another experiment')
cfg = dict(raw)
cfg['exe'] = str(EXES[profile])
cfg['args'] = list(args)
if profile == 'strata-next-kar-ple':
cfg['args'] += ['--ple-kar', str(ARCHIVE), '--ple-kar-level', '2']
ROOT.mkdir(mode=0o700, parents=True, exist_ok=True)
os.chmod(ROOT, 0o700)
cfg['log'] = str(ROOT / f'{profile}-engine.log')
fd = os.open(CONFIG, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
try:
with os.fdopen(fd, 'w') as file:
json.dump(cfg, file)
log = ROOT / f'{profile}-server.log'
with log.open('ab') as output:
proc = subprocess.Popen([str(PYTHON), '-u', str(SERVER), '--engine', 'strata',
'--config', str(CONFIG), '--host', HOST, '--port', str(PORT)],
cwd=raw['cwd'], stdout=output, stderr=subprocess.STDOUT,
start_new_session=True, close_fds=True)
STATE.write_text(json.dumps({'pid': proc.pid, 'profile': profile}) + '\n')
os.chmod(STATE, 0o600)
except BaseException:
CONFIG.unlink(missing_ok=True)
raise
return {'started': True, **status()}
def main():
action = sys.argv[1]
payload = json.load(sys.stdin)
if action == 'status':
result = status()
elif action == 'start':
result = start(payload['profile'])
elif action == 'stop':
current = state()
if current:
ensure_idle()
unload(current)
result = {'stopped': bool(current)}
else:
raise ValueError('unknown action')
print(json.dumps(result))
if __name__ == '__main__':
try:
main()
except Exception as exc:
print(type(exc).__name__ + ': ' + str(exc), file=sys.stderr)
sys.exit(1)