diff --git a/bench/results/2026-10-04-windows-mapped-release/README.md b/bench/results/2026-10-04-windows-mapped-release/README.md new file mode 100644 index 00000000..18193752 --- /dev/null +++ b/bench/results/2026-10-04-windows-mapped-release/README.md @@ -0,0 +1,144 @@ +# Windows mapped expert-page release + +Measured October 4, 2026, against upstream `6f32ec070f23ced9f50e704d854d775da52591ab` (0.1.39). +The same patched executable was run with `STRATA_ARENA_RELEASE=0` and `STRATA_ARENA_RELEASE=1`. +Releasing file-backed expert pages after GPU copies substantially increased available physical RAM on this +machine. Prefill was slightly slower. This is a memory-pressure improvement, not a general speed claim. + +## What changes + +Windows `FileExpertSource::release()` uses `VirtualUnlock` on complete interior pages of its read-only file views. +Windows documents that unlocked pages are removed from the process working set even when the call returns +`FALSE` with `ERROR_NOT_LOCKED`. Other errors are reported. The mapping stays valid and later reads fault in the +original bytes. Shared boundary pages are retained. The code resolves file spans directly, so it does not trim +resident complements, CUDA-pinned buffers or the temporary buffers used to assemble GGUF experts. + +Existing cache-upload release calls use this implementation. Two additional calls release pages after prefill's +lent cache slots have finished refilling, in serving and one-shot generation. Other platforms are unchanged. +`STRATA_ARENA_RELEASE=1` enables it; unset, `0`, or any other value leaves it disabled. The switch is read once +per engine process, so restart the engine when changing it. + +This builds on the existing working-set handling in [#467](https://github.com/Niko1221/Strata/issues/467) and the +mapped-arena work in [#640](https://github.com/Niko1221/Strata/pull/640). Multi-GPU placement already exists upstream; +this patch does not implement it. See Microsoft's [VirtualUnlock documentation](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualunlock). + +## Configuration + +| Component | Measured configuration | +| --- | --- | +| System | Windows 11 Pro build 26200, Core i9-14900HX, 31.77 GiB usable RAM, 2 x 16 GB DDR5-5600 | +| GPU 0 | RTX 4080 Laptop, 12,282 MiB VRAM; also drives the desktop | +| GPU 1 | RTX 3090, 24,576 MiB VRAM, Thunderbolt eGPU | +| Links | Engine H2D probes approximately 12.3-12.9 GB/s and 2.4 GB/s respectively; no CUDA peer read/write | +| Driver | NVIDIA 616.56 | +| Storage | Model and pack on an internal WD PC SN560 NVMe | +| Build | MSVC 19.29.30157, CUDA 13.1.80, Release, AVX2 portable, SM 86/89, native experts enabled | +| Model | `ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF`, IQ2_XS, with MTP | +| Placement | GPUs `0,1`, layer split 12, stage-weight trim, mapped experts | +| Runtime | Context 32768, int8 KV, 15 pool workers, auto expert cache and prefill, spec 4, minimum draft probability 0.5 | + +GPU 0 held 6,144 expert pairs (about 8.00 GiB), GPU 1 held 13,381 (about 18.15 GiB); 19,525 of 24,576 pairs in total. +Prefill selected 8192 and borrowed approximately 3.77 GiB of expert cache on each GPU. The native pack used +`experts.bin` (35,454,976,000 bytes), `dense.bin` (1,538,035,200 bytes), and the GGUF PLE table on disk. +Power was AC; the existing power plan, drivers and system-managed pagefile were not changed. + +Model revision: `ed59f92082b1e93c0e96d60a8b11aab089b52f09`. +MTP checkpoint revision: `de4b8e4d43b917e7706784d8bb445c9af86a3540`. +llama.cpp revision: `3cf03257f219afbe7334045ff7c6a06ac68c627d`. +The two downloaded GGUF shards were fully SHA-256 verified: + +| Shard | Bytes | SHA-256 | +| --- | ---: | --- | +| 1 | 39,225,954,592 | `92cee27ae5bbadcd732416a0f7a7f0acc092399dbbe8f5a5efa707c2ec0a49d7` | +| 2 | 28,800,138,432 | `316b46f3a2dbd68c900f43136ab9449f9dcc3725dfd8c794847c204bc161e113` | + +The measured prototype executable had SHA-256 +`9118b02dcc0ad4bd8398ba033c641feb93800e0eeecea59ee42be141e4a186fc`. +It predates the submitted patch's decision to default the switch to OFF. Explicit `0` and `1` have the same +behavior in both versions; the numbers below are from the prototype, not a benchmark of the final rebuild. + +## Measurements + +Each arm had one excluded short warmup followed by three fresh prompts at each length, with 256 output tokens, +temperature zero and thinking disabled. Prompts ask for explanations of synthetic integer-processing code. +The harness checks that all prompt tokens were processed, no prefix tokens were reused, the response completed, +and exactly one request was recorded by the idle dedicated server. Actual prompt lengths were 1023, 4096 and 16384. + +Medians of three requests per cell: + +| Prompt | Prefill OFF / ON, tok/s | Decode OFF / ON, tok/s | Client TTFT OFF / ON, s | +| --- | ---: | ---: | ---: | +| 1K | 263.68 / 253.83 | 77.35 / 77.65 | 3.93 / 4.07 | +| 4K | 583.51 / 558.24 | 81.99 / 94.17 | 7.06 / 7.38 | +| 16K | 1045.85 / 1000.16 | 80.88 / 84.93 | 15.73 / 16.45 | + +An independent Windows monitor sampled host RAM, process working sets, commit, pagefile use and physical-disk +counters approximately once per second. The following window includes warmup and gaps between requests, from +the first request's start to the last request's finish. GiB means bytes divided by 2^30. + +| Metric | Release OFF | Release ON | +| --- | ---: | ---: | +| Available RAM, median | 0.512 GiB | 12.187 GiB | +| Available RAM, minimum | 0.277 GiB | 6.110 GiB | +| Engine working set, median | 23.379 GiB | 11.946 GiB | +| Engine nonprivate working set, median | 20.460 GiB | 8.689 GiB | +| System commit, median | 51.880 GiB | 51.973 GiB | +| Engine private commit, median | 36.807 GiB | 36.804 GiB | +| Pagefile use, median | 1.233 GiB | 1.218 GiB | +| Internal physical-disk reads, total | 16.750 GiB | 16.809 GiB | + +The benefit was available physical RAM. Commit was effectively unchanged; this does not solve a commit-limit +failure or eliminate the need for pagefile capacity. Physical reads were also effectively unchanged. +Nonprivate working-set bytes include file mappings and shared images, not only model pages. Physical-disk +counters are system-wide and omit about 1.1-1.3 seconds at the sampled interval edges. The external disk was idle. + +These were sequential OFF-then-ON runs on one machine, with warm engines and retained OS file-cache history. +The adaptive expert cache remained enabled. The OS cache was not flushed; this is not a cold-SSD experiment. +Three repetitions provide observed ranges, not confidence intervals. Code-explanation outputs differed between +the two arms despite identical measured requests; speculative decode rates are workload-dependent. Prefill +throughput dropped 3.7-4.4%, and median whole-request time changed by +3.5%, -1.1% and +2.9% at 1K, 4K and 16K. +These observations do not establish a decode-speed improvement, output equivalence, or results on other hardware. + +## Reproduction and checks + +`measurements.json` contains the individual successful trials, their request/output hashes, timing summaries and +the host-window statistics. It is a scoped export of the recorded runs, not raw SSE streams or a full system trace. +`benchmark.py`, `test_benchmark.py` and `monitor_windows.py` are the unchanged scripts used for these measurements. +The benchmark needs the repository's normal server/tokenizer dependencies; the Windows monitor also needs psutil. + +Start a dedicated server on `127.0.0.1:18080` using a configuration with the runtime settings above, the patched +engine, and `"env": {"STRATA_ARENA_RELEASE": "0"}`. Wait until the engine is loaded and idle. In another terminal, +run the monitor against the server process ID, and then the benchmark (replace the uppercase placeholders): + +```powershell +python bench/results/2026-10-04-windows-mapped-release/monitor_windows.py --server-pid SERVER_PID --out off-host.jsonl --stop-file off-monitor.stop +``` + +```powershell +python bench/results/2026-10-04-windows-mapped-release/benchmark.py --pack PACK_DIR --config CONFIG_JSON --label release-off --out results-off --targets 1024,4096,16384 --runs 3 --max-tokens 256 +``` + +Stop the monitor by creating its stop file. Unload and stop the server, change only the release value to `1`, +restart, and repeat with new ON output paths. Keep available VRAM, background workloads and model files stable. +For host summaries, select samples with `min(started_epoch_s) <= epoch_s <= max(finished_epoch_s)` from the +benchmark's results, including warmup. Compute sample medians/minima and physical-disk last-minus-first counters. +Sum `windows_memory` counters for `strata.exe` processes only; nonprivate working set is total minus private. + +The C++ tests cover canonical and variable native layouts, full-page alignment, preserved boundary pages, +three release/read cycles with byte-for-byte checks, invalid indices, a closed source, and three GGUF roles +across two shards. Build with `STRATA_BUILD_TESTS=ON` and `STRATA_NATIVE_EXPERTS=ON`, then run +`ctest --test-dir BUILD_DIR -R "^(file_expert_source_test|expert_layout_test)$" --output-on-failure` in fresh +processes with the switch unset, `0`, and `1`. The HTTP harness checks run with +`python -m unittest discover -s bench/results/2026-10-04-windows-mapped-release -p test_benchmark.py`. + +The final submitted source was rebuilt with the toolchain above. Both C++ tests passed with the switch unset, +`0`, and `1`, and all eight HTTP harness tests passed. That rebuilt engine also completed a warmup and one fresh +request each at 1023 and 4096 prompt tokens, generating 256 tokens per measured request on both GPUs with release +enabled. This was an inference smoke test, not a replacement for the prototype's OFF/ON performance comparison. +Its executable SHA-256 is `9f1e96c36b2ddb530422ee37734606491c0f4c3c9b720095c68d63953e89913b`. + +Additional prototype checks with release ON completed 30 requests without runtime errors: 21 of 24 objective +checks passed, with three JSON-only checks failing because of Markdown fences. All 24 objective responses and +statuses matched the official engine with the same GPU placement, including those three failures. Six prose +requests were unscored. Needle retrieval passed near 1K/4K/16K tokens at 50% depth. The functional battery was not +run on the release-OFF prototype, and these limited checks do not prove general model quality or token parity. diff --git a/bench/results/2026-10-04-windows-mapped-release/benchmark.py b/bench/results/2026-10-04-windows-mapped-release/benchmark.py new file mode 100644 index 00000000..5ffbde3b --- /dev/null +++ b/bench/results/2026-10-04-windows-mapped-release/benchmark.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +"""Serial fresh-prompt benchmark, adapted from the community MI50/RTX 5090 harness. + +Start a dedicated Strata server separately. This script never starts or stops it. +Expert adaptation and the OS file cache stay warm between requests; prefix reuse +is rejected. Engine file-tier counters describe decode, not physical disk reads. +""" +from __future__ import annotations + +import argparse +import hashlib +import json +import platform +import statistics +import subprocess +import sys +import threading +import time +import urllib.error +import urllib.request +import uuid +from pathlib import Path + + +def write_json(path, value): + path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + + +def get(url, timeout=30): + with urllib.request.urlopen(url, timeout=timeout) as response: + return json.load(response) + + +def digest(value): + return hashlib.sha256(json.dumps(value, sort_keys=True).encode("utf-8")).hexdigest() + + +def executable_record(config): + """Resolve the configured binary exactly as serve/server.py does, without executing it.""" + executable = Path(config["exe"]) + if not executable.is_absolute(): + executable = Path(config.get("cwd") or ".") / executable + executable = executable.resolve() + checksum = hashlib.sha256() + with executable.open("rb") as source: + for block in iter(lambda: source.read(1024 * 1024), b""): + checksum.update(block) + return {"path": str(executable), "sha256": checksum.hexdigest(), "size_bytes": executable.stat().st_size} + + +def engine_provenance_record(path, executable): + """Keep compact build provenance and verify its executable artifact, when recorded.""" + path = path.resolve() + raw = path.read_bytes() + source = json.loads(raw.decode("utf-8-sig")) + artifacts = source.get("artifacts", {}) + if isinstance(artifacts, list): + entries = [(entry["file"], entry) for entry in artifacts] + elif isinstance(artifacts, dict): + entries = list(artifacts.items()) + else: + raise ValueError("Provenance artifacts must be a list or dictionary") + matches = [entry for name, entry in entries + if Path(name).name.casefold() == Path(executable["path"]).name.casefold()] + if len(matches) > 1: + raise ValueError("Provenance has multiple artifacts matching the configured executable") + expected = matches[0]["sha256"].lower() if matches else None + if expected is not None and expected != executable["sha256"]: + raise ValueError("Provenance executable SHA-256 does not match the configured executable") + toolchain_keys = ("cmake", "ninja", "msvc", "windows_sdk", "nvcc", "cuda", "cuda_architectures", + "cxx_standard", "cuda_standard", "build_type", "portable_avx2", "msvc_runtime", + "parallel_jobs", "tests_built") + toolchain = {key: value for key, value in source.get("toolchain", {}).items() if key in toolchain_keys} + # Release BUILD.json records CUDA and target architectures at the top level. + toolchain.update({key: source[key] for key in ("cuda", "archs", "ptx", "portable") if key in source}) + return {"path": str(path), "sha256": hashlib.sha256(raw).hexdigest(), + "version": source.get("strata_version", source.get("version")), "commit": source.get("commit"), + "fingerprint": source.get("engine_source_fingerprint", source.get("source_fingerprint")), + "toolchain": toolchain, "repository": source.get("fork_repository"), + "llama_cpp_commit": source.get("llama_cpp_pinned_commit"), + "executable_hash_verified": expected is not None, "recorded_executable_sha256": expected} + + +def validate_completion(before, after, chunks, expected, finish, done, text): + if not done: + raise RuntimeError("The stream ended without [DONE]") + if not text: + raise RuntimeError("The response contained no text") + if finish not in ("length", "stop"): + raise RuntimeError(f"Unsuccessful finish reason: {finish!r}") + if after["totals"]["requests"] != before["totals"]["requests"] + 1: + raise RuntimeError("Request counter mismatch; another client or engine restart invalidated this trial") + if after["live"]["state"] != "idle" or after["live"].get("queued", 0): + raise RuntimeError("The dedicated server was not idle after the request") + engine = after["requests"][0] + usage_chunk = next((chunk for chunk in reversed(chunks) if "usage" in chunk), None) + if not usage_chunk or not usage_chunk.get("timings"): + raise RuntimeError("The final stream chunk lacks usage or engine timings") + usage, timings = usage_chunk["usage"], usage_chunk["timings"] + if engine.get("reused") != 0 or usage["prompt_tokens_details"]["cached_tokens"] != 0: + raise RuntimeError("Fresh prompt reused cached tokens; restart this arm before resuming") + if engine["prompt_tokens"] != expected or usage["prompt_tokens"] != expected: + raise RuntimeError(f"Prompt token count mismatch; expected {expected}") + if engine.get("prompt_total") != expected or engine.get("prompt_read") != expected: + raise RuntimeError("The engine did not report reading the complete prompt") + if engine["finish"] != finish or engine["output_tokens"] != usage["completion_tokens"]: + raise RuntimeError("Stream usage or finish reason does not match /metrics") + if timings["prompt_n"] != expected or timings["predicted_n"] != usage["completion_tokens"]: + raise RuntimeError("Final stream timings do not match the completed request") + for name, timing_name in (("prompt_ms", "prompt_ms"), ("decode_ms", "predicted_ms")): + if engine[name] <= 0 or abs(engine[name] - timings[timing_name]) > 0.11: + raise RuntimeError(f"Invalid or mismatched engine timing: {name}") + if engine["engine_generated"] <= 0: + raise RuntimeError("The engine reported no generated tokens") + return engine, usage, timings + + +def perform(url, out, session, label, attempt, req, expected, interval=1.0, timeout=1800): + stem = f"{label}-attempt-{attempt}" + body = json.dumps(req, ensure_ascii=False).encode("utf-8") + (out / f"{stem}-request.json").write_bytes(body + b"\n") + row = {"label": label, "attempt": attempt, "session": session, "status": "failed", + "expected_prompt_tokens": expected, "request_sha256": hashlib.sha256(body).hexdigest(), + "started_epoch_s": time.time(), "raw_stream": f"{stem}-sse.jsonl", + "telemetry": f"{stem}-telemetry.jsonl", "text": "", "reasoning": ""} + chunks, texts, reasoning, telemetry_errors = [], [], [], [] + stop = threading.Event() + monitor = None + started = None + + def sample(output): + metrics = get(url + "/metrics") + hardware = dict(metrics["hardware"]) + if hardware.get("ram_total") is not None and hardware.get("ram_used") is not None: + hardware["ram_available"] = hardware["ram_total"] - hardware["ram_used"] + sample_row = {"epoch_s": time.time(), "metrics_time": metrics.get("time"), + "live": metrics["live"], "hardware": hardware, + "completed_requests": metrics["totals"]["requests"]} + output.write(json.dumps(sample_row) + "\n") + output.flush() + + def monitor_loop(output): + while not stop.wait(interval): + try: + sample(output) + except Exception as error: + telemetry_errors.append(f"{type(error).__name__}: {error}") + output.write(json.dumps({"epoch_s": time.time(), "error": telemetry_errors[-1]}) + "\n") + output.flush() + break + + try: + before = get(url + "/metrics") + row["metrics_before"] = before + if before["live"]["state"] != "idle" or before["live"].get("queued", 0): + raise RuntimeError("The dedicated server must already be loaded and idle") + if expected + req["max_tokens"] > before["engine"]["max_context"]: + raise RuntimeError("Prompt plus output cap exceeds the configured context") + with (out / row["telemetry"]).open("w", encoding="utf-8") as telemetry: + sample(telemetry) + monitor = threading.Thread(target=monitor_loop, args=(telemetry,), daemon=True) + monitor.start() + try: + with (out / row["raw_stream"]).open("w", encoding="utf-8") as raw: + started = time.perf_counter() + first, finish, done = None, None, False + wire = urllib.request.Request(url + "/v1/chat/completions", data=body, + headers={"Content-Type": "application/json"}) + with urllib.request.urlopen(wire, timeout=timeout) as response: + for line in response: + raw.write(json.dumps({"elapsed_s": time.perf_counter() - started, + "line": line.decode("utf-8")}, ensure_ascii=False) + "\n") + raw.flush() + if not line.startswith(b"data:"): + continue + payload = line[5:].strip() + if payload == b"[DONE]": + done = True + break + chunk = json.loads(payload) + chunks.append(chunk) + if chunk.get("error"): + raise RuntimeError(f"Stream error: {chunk['error']}") + for choice in chunk.get("choices", []): + delta = choice.get("delta", {}) + content = delta.get("content") or "" + thought = delta.get("reasoning_content") or "" + if (content or thought) and first is None: + first = time.perf_counter() - started + texts.append(content) + reasoning.append(thought) + finish = choice.get("finish_reason") or finish + row.update(client_ttft_s=first, client_elapsed_s=time.perf_counter() - started, + finish_reason=finish, stream_done=done) + after = get(url + "/metrics") + row["metrics_after"] = after + engine, usage, timings = validate_completion(before, after, chunks, expected, + finish, done, "".join(texts + reasoning)) + row.update(engine=engine, usage=usage, timings=timings, + prefill_tok_s=expected / (engine["prompt_ms"] / 1000), + decode_tok_s=engine["engine_generated"] / (engine["decode_ms"] / 1000)) + finally: + stop.set() + monitor.join() + try: + sample(telemetry) + except Exception as error: + telemetry_errors.append(f"{type(error).__name__}: {error}") + if telemetry_errors: + raise RuntimeError("Telemetry failed: " + "; ".join(telemetry_errors)) + row["status"] = "ok" + except urllib.error.HTTPError as error: + row["error"] = {"type": type(error).__name__, "message": str(error), "http_status": error.code, + "body": error.read().decode("utf-8", errors="replace")} + except Exception as error: + row["error"] = {"type": type(error).__name__, "message": str(error)} + finally: + stop.set() + if monitor is not None and monitor.is_alive(): + monitor.join() + row.update(text="".join(texts), reasoning="".join(reasoning), finished_epoch_s=time.time()) + if started is not None and "client_elapsed_s" not in row: + row["client_elapsed_s"] = time.perf_counter() - started + write_json(out / f"{stem}-record.json", row) + write_json(out / f"{stem}-chunks.json", chunks) + return row + + +def summary(rows, targets): + groups = {} + for target in targets: + selected = [r for r in rows if r["label"].startswith(f"tokens-{target}-")] + good = [r for r in selected if r["status"] == "ok"] + fields = ("client_ttft_s", "client_elapsed_s", "prefill_tok_s", "decode_tok_s") + groups[str(target)] = {"successful_runs": len(good), "failed_attempts": len(selected) - len(good), + **{field: {"median": statistics.median(v), "min": min(v), "max": max(v)} + for field in fields if (v := [r[field] for r in good])}} + return groups + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[3]) + parser.add_argument("--pack", type=Path, required=True) + parser.add_argument("--config", type=Path, help="Server configuration, saved with relevant fields only") + parser.add_argument("--engine-provenance", type=Path, + help="Build provenance JSON or release BUILD.json; requires --config") + parser.add_argument("--url", default="http://127.0.0.1:18080") + parser.add_argument("--model", default="strata") + parser.add_argument("--label", required=True, help="Configuration label, such as iq2-xs-3090-resident") + parser.add_argument("--out", type=Path, required=True, help="A separate directory for each configuration") + parser.add_argument("--targets", default="1024,4096,16384") + parser.add_argument("--runs", type=int, default=3) + parser.add_argument("--max-tokens", type=int, default=256) + parser.add_argument("--timeout", type=float, default=1800) + parser.add_argument("--telemetry-interval", type=float, default=1.0) + parser.add_argument("--resume", action="store_true", help="Keep completed trials and preserve failed attempts") + args = parser.parse_args() + targets = [int(value) for value in args.targets.split(",")] + if not targets or min(targets) <= 0 or len(set(targets)) != len(targets): + parser.error("Targets must be unique positive token counts") + if args.runs < 1 or args.max_tokens < 1 or args.timeout <= 0 or args.telemetry_interval <= 0: + parser.error("Runs, output cap, timeout, and telemetry interval must be positive") + if args.engine_provenance and not args.config: + parser.error("--engine-provenance requires --config to identify the executable") + args.root, args.pack, args.out = args.root.resolve(), args.pack.resolve(), args.out.resolve() + url = args.url.rstrip("/") + sys.path[:0] = [str(args.root), str(args.root / "tools")] + from strata_tokenizer import Tokenizer + from serve.frontend import ChatTemplate, openai_to_messages + + directory = args.pack / "tokenizer" + vocab = json.loads((directory / "vocab.json").read_text(encoding="utf-8")) + tokens = [None] * len(vocab) + for token, number in vocab.items(): + tokens[number] = token + tokenizer = Tokenizer(tokens, (directory / "merges.txt").read_text(encoding="utf-8").splitlines(), + json.loads((directory / "token_type.json").read_text(encoding="utf-8"))) + template = ChatTemplate(directory / "chat_template.jinja") + + def request(content, maximum=args.max_tokens): + return {"model": args.model, "messages": [{"role": "user", "content": content}], + "temperature": 0, "reasoning_effort": "none", "max_tokens": maximum, + "stream": True, "stream_options": {"include_usage": True}} + + def count(req): + messages, tools, kwargs = openai_to_messages(req) + return len(tokenizer.encode(template.render(messages, tools, **kwargs), parse_special=True)) + + initial = get(url + "/metrics") + if initial["live"]["state"] != "idle" or initial["live"].get("queued", 0): + raise RuntimeError("Start a dedicated, loaded and idle server before this benchmark") + config = {} + executable = None + if args.config: + source = json.loads(args.config.read_text(encoding="utf-8-sig")) + executable = executable_record(source) + keys = ("exe", "cwd", "args", "gpu", "layer_split", "split_skip_if_fits", "backend", "tokenizer", "log", + "model_name", "parallel", "expert_profile_save", "expert_profile_save_every") + config = {key: source[key] for key in keys if key in source} + compute_variables = {"CUDA_VISIBLE_DEVICES", "CUDA_DEVICE_ORDER", "STRATA_STAGE_TRIM", "STRATA_SPLIT_OWN", + "STRATA_ARENA_PIN_GIB", "STRATA_RESIDENT_PIN", "STRATA_RESIDENT_HEADROOM_GIB", + "STRATA_ARENA_MMAP", "STRATA_PREFILL_HELP", "STRATA_FETCH_THREADS", "STRATA_LOOKAHEAD", + "STRATA_DECODE_TIMING", "STRATA_SPLIT_TIMING", "STRATA_VERIFY_PROFILE", + "STRATA_SPLIT_MISS_MS", "STRATA_PF_FUSED", "STRATA_ARENA_RELEASE"} + config["env"] = {key: value for key, value in source.get("env", {}).items() + if key in compute_variables} + revision = subprocess.run(["git", "-c", f"safe.directory={args.root.as_posix()}", "rev-parse", "HEAD"], + cwd=args.root, capture_output=True, text=True, check=True).stdout.strip() + provenance = engine_provenance_record(args.engine_provenance, executable) if args.engine_provenance else None + manifest = {"label": args.label, "frontend_source_commit": revision, "pack": str(args.pack), + "config": config, "engine_executable": executable, + "engine_provenance": provenance, "engine_reported_version": initial["engine"].get("version"), + "targets": targets, "runs": args.runs, "max_tokens": args.max_tokens, + "model": args.model, "server_model": initial["engine"]["model"], + "max_context": initial["engine"]["max_context"], + "hardware_static": initial.get("hardware_static"), + "tokenizer_sha256": {name: hashlib.sha256((directory / name).read_bytes()).hexdigest() + for name in ("vocab.json", "merges.txt", "token_type.json", "chat_template.jinja")}, + "script_sha256": hashlib.sha256(Path(__file__).read_bytes()).hexdigest(), + "method": "Serial warm-engine trials; default adaptive expert state retained; zero prompt reuse required", + "disk_counter_note": "file_mb is the decode file tier, possibly OS-cached; disk_read_mb is system-wide physical I/O"} + manifest_path = args.out / "manifest.json" + if manifest_path.exists(): + if not args.resume: + raise RuntimeError("Output already has a manifest; use a new output directory or --resume") + if digest(json.loads(manifest_path.read_text(encoding="utf-8"))) != digest(manifest): + raise RuntimeError("Resume manifest differs; use a new output directory") + elif args.resume: + raise RuntimeError("Cannot resume: output has no manifest") + args.out.mkdir(parents=True, exist_ok=True) + write_json(manifest_path, manifest) + rows_path = args.out / "results.json" + rows = json.loads(rows_path.read_text(encoding="utf-8")) if args.resume and rows_path.exists() else [] + session = uuid.uuid4().hex[:12] + write_json(args.out / f"session-{session}.json", {"session": session, "epoch_s": time.time(), + "python": sys.version, "platform": platform.platform(), "initial_metrics": initial, + "initial_status": get(url + "/v1/status"), "resumed": args.resume}) + + def run(label, req): + if any(row["label"] == label and row["status"] == "ok" for row in rows): + print("skip completed", label, flush=True) + return + attempt = sum(row["label"] == label for row in rows) + 1 + print("start", args.label, label, "tokens", count(req), flush=True) + row = perform(url, args.out, session, label, attempt, req, count(req), + args.telemetry_interval, args.timeout) + rows.append(row) + write_json(rows_path, rows) + write_json(args.out / "summary.json", summary(rows, targets)) + print(row["status"], label, json.dumps({key: row.get(key) for key in + ("client_ttft_s", "prefill_tok_s", "decode_tok_s", "error")}), flush=True) + if row["status"] != "ok": + raise RuntimeError(f"Benchmark stopped after failed trial {label}; evidence was retained") + + run(f"warmup-{session}", request(f"Warmup {session}. Reply with exactly the word READY.", 16)) + filler = "\n".join(f"def task_{i:05d}(value: int) -> int: return (value * {(i % 97) + 1} + {i}) % 100003" + for i in range(12000)) + ending = ("\n\nWrite a detailed explanation of the code above. Discuss deterministic integer transforms, " + "modulo arithmetic, testing, naming, complexity, and maintainability. Write at least 600 words.") + for target in targets: + for trial in range(1, args.runs + 1): + # Checkpoints cover a complete turn or >=16K prompt tokens by default; + # this early differing nonce prevents a whole checkpoint from matching. + prefix = f"Benchmark nonce: series-{target}-trial-{trial}.\nReview this synthetic Python module:\n" + low, high = 0, len(filler) + while low < high: + middle = (low + high + 1) // 2 + if count(request(prefix + filler[:middle] + ending)) <= target: + low = middle + else: + high = middle - 1 + req = request(prefix + filler[:low] + ending) + if not target - 20 <= count(req) <= target: + raise RuntimeError(f"Could not construct target {target}: {count(req)}") + run(f"tokens-{target}-run-{trial}", req) + print("Complete:", args.out / "summary.json", flush=True) + + +if __name__ == "__main__": + main() diff --git a/bench/results/2026-10-04-windows-mapped-release/measurements.json b/bench/results/2026-10-04-windows-mapped-release/measurements.json new file mode 100644 index 00000000..5ec11394 --- /dev/null +++ b/bench/results/2026-10-04-windows-mapped-release/measurements.json @@ -0,0 +1,1463 @@ +{ + "schema_version": 1, + "measured_date": "2026-10-04", + "base_commit": "6f32ec070f23ced9f50e704d854d775da52591ab", + "prototype_executable_sha256": "9118b02dcc0ad4bd8398ba033c641feb93800e0eeecea59ee42be141e4a186fc", + "prototype_source_patch_sha256": "327fa305a12fee3395e788d6a2ea9dc731a9cc023290bbcf0609adf72d5832c9", + "source_difference_from_submission": "The submitted switch defaults to OFF; the measured prototype defaulted to ON. Both benchmark arms set it explicitly to 0 or 1.", + "toolchain": { + "cmake": "4.4.3", + "ninja": "1.13.2.git.kitware.jobserver-pipe-1", + "msvc": "19.29.30157.0", + "windows_sdk": "10.0.19041.0", + "nvcc": "13.1.80", + "cuda_architectures": [ + 86, + 89 + ], + "cxx_standard": 20, + "cuda_standard": 17, + "build_type": "Release", + "portable_avx2": true, + "msvc_runtime": "MultiThreaded", + "parallel_jobs": 2, + "tests_built": true + }, + "script_sha256": { + "benchmark.py": "e8e67bad6a669d894eec0a5257e7175ddb71984f31cabaad0343ad59087aa9f6", + "test_benchmark.py": "35a32af56e2f46c2b487e61ee577aa8ac8e219b16de3025ac4d0cb551b5d4486", + "monitor_windows.py": "889216af622afa3af85f27316018e658573e477d3a1fbe0768b395f0d7ab2983" + }, + "units": "Bytes, epoch seconds, seconds, and tokens per second. Host medians are sample medians, not time-weighted.", + "host_window": "Earliest request start through latest request finish, including the excluded warmup and gaps; approximately one sample per second.", + "arms": [ + { + "label": "off", + "STRATA_ARENA_RELEASE": "0", + "source_results_sha256": "4f0db7536c1cc97a104d3c7ccf0565b6cd2265a15bb0a3574748eb699b82092c", + "source_host_samples_sha256": "e8c1a9be8395b25dd1470eb9d04d1d13976dc530284b1ea0ce219a828f0b3ae8", + "speed_summary": { + "1024": { + "successful_runs": 3, + "failed_attempts": 0, + "client_ttft_s": { + "median": 3.934812100000272, + "min": 3.722584300001472, + "max": 6.9117251000006945 + }, + "client_elapsed_s": { + "median": 7.015831400000025, + "min": 6.942086900000504, + "max": 11.843229200001588 + }, + "prefill_tok_s": { + "median": 263.6801814573292, + "min": 149.1036292085702, + "max": 277.4764023000976 + }, + "decode_tok_s": { + "median": 77.34606320623602, + "min": 51.612903225806456, + "max": 84.16346122234278 + } + }, + "4096": { + "successful_runs": 3, + "failed_attempts": 0, + "client_ttft_s": { + "median": 7.062032199999521, + "min": 6.976809499999945, + "max": 7.534027300000162 + }, + "client_elapsed_s": { + "median": 10.167359600000054, + "min": 9.68955300000016, + "max": 10.720107400000416 + }, + "prefill_tok_s": { + "median": 583.5090318536668, + "min": 547.3594184306179, + "max": 590.329321899546 + }, + "decode_tok_s": { + "median": 81.98821419420958, + "min": 79.75077881619937, + "max": 93.90015772292116 + } + }, + "16384": { + "successful_runs": 3, + "failed_attempts": 0, + "client_ttft_s": { + "median": 15.729271700000027, + "min": 15.47054879999996, + "max": 16.01550429999952 + }, + "client_elapsed_s": { + "median": 18.869459200001074, + "min": 18.32465349999984, + "max": 19.213972899999135 + }, + "prefill_tok_s": { + "median": 1045.85176532169, + "min": 1027.448373603908, + "max": 1062.3439779542875 + }, + "decode_tok_s": { + "median": 80.87701007803368, + "min": 79.44142746314972, + "max": 89.16753744339951 + } + } + }, + "host_benchmark_window": { + "coverage": { + "requested_start_epoch_s": 1791137373.373225, + "requested_end_epoch_s": 1791137498.7173786, + "requested_duration_s": 125.34415364265442, + "sample_count": 125, + "first_sample_epoch_s": 1791137374.2838576, + "last_sample_epoch_s": 1791137498.400041, + "observed_span_s": 124.1161835193634, + "omitted_start_s": 0.9106326103210449, + "omitted_end_s": 0.3173375129699707, + "sample_spacing_s": { + "count": 124, + "min": 0.9795429706573486, + "median": 0.9988986253738403, + "max": 1.0212182998657227 + } + }, + "available_bytes": { + "count": 125, + "min": 297324544, + "median": 549507072, + "max": 831209472 + }, + "commit_bytes": { + "count": 125, + "min": 55056080896, + "median": 55705743360, + "max": 55899545600 + }, + "commit_limit_bytes": { + "count": 125, + "min": 55889264640, + "median": 56974360576, + "max": 56974360576 + }, + "commit_headroom_bytes": { + "count": 125, + "min": 330276864, + "median": 1260085248, + "max": 1379921920 + }, + "pagefile_total_bytes": { + "count": 125, + "min": 21781618688, + "median": 22866714624, + "max": 22866714624 + }, + "pagefile_used_bytes": { + "count": 125, + "min": 1323528192, + "median": 1323659264, + "max": 1327710208 + }, + "strata": { + "samples_with_engine": 125, + "process_count_per_host_sample": { + "count": 125, + "min": 1, + "median": 1, + "max": 1 + }, + "working_set_bytes": { + "count": 125, + "min": 24851771392, + "median": 25103110144, + "max": 25565278208 + }, + "private_working_set_bytes": { + "count": 125, + "min": 3088654336, + "median": 3141586944, + "max": 3324026880 + }, + "nonprivate_working_set_bytes": { + "count": 125, + "min": 21681967104, + "median": 21969186816, + "max": 22408978432 + }, + "private_commit_bytes": { + "count": 125, + "min": 38979821568, + "median": 39521062912, + "max": 39638933504 + } + }, + "system_physical_disk_io": { + "PhysicalDrive0": { + "samples_present": 125, + "status": "ok", + "read_bytes_delta": 17984702464, + "write_bytes_delta": 57162752 + }, + "PhysicalDrive2": { + "samples_present": 125, + "status": "ok", + "read_bytes_delta": 0, + "write_bytes_delta": 0 + } + } + }, + "trials": [ + { + "label": "warmup-c6eedd79209d", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 32, + "request_sha256": "109d29ce4ac42ab8a450ec87e42d2ac29f4d957fb391fc12db6211acddd5b651", + "started_epoch_s": 1791137373.373225, + "finished_epoch_s": 1791137374.9766107, + "client_ttft_s": 1.336918400000286, + "client_elapsed_s": 1.5827291000005062, + "finish_reason": "stop", + "stream_done": true, + "prefill_tok_s": 24.90466184138843, + "decode_tok_s": 6.805035726437564, + "usage": { + "prompt_tokens": 32, + "completion_tokens": 2, + "total_tokens": 34, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 32, + "prompt_ms": 1284.9, + "prompt_per_token_ms": 40.153, + "prompt_per_second": 24.9, + "predicted_n": 2, + "predicted_ms": 293.9, + "predicted_per_token_ms": 146.95, + "predicted_per_second": 6.8, + "draft_n": 3, + "draft_n_accepted": 3 + }, + "included_in_speed_summary": false, + "response_text_sha256": "c2e3ac47f4a325469c1a2d5f117e463ec943c721986d5d9f09ac4540b7d80526", + "engine": { + "prompt_tokens": 32, + "reused": 0, + "output_tokens": 2, + "prompt_total": 32, + "prompt_read": 32, + "engine_generated": 2, + "prompt_ms": 1284.9, + "decode_ms": 293.9, + "hit_rate": 0.866, + "pcie_share": 0.0, + "file_mb": 285.4, + "drafts_offered": 3, + "drafts_accepted": 3 + } + }, + { + "label": "tokens-1024-run-1", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 1023, + "request_sha256": "1b7264f120d81c7905cc2779e19aa3b14f7d2ad8efef6cc9c159e3e73bbe1ca5", + "started_epoch_s": 1791137375.9920728, + "finished_epoch_s": 1791137387.921758, + "client_ttft_s": 6.9117251000006945, + "client_elapsed_s": 11.843229200001588, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 149.1036292085702, + "decode_tok_s": 51.612903225806456, + "usage": { + "prompt_tokens": 1023, + "completion_tokens": 256, + "total_tokens": 1279, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 1023, + "prompt_ms": 6861.0, + "prompt_per_token_ms": 6.707, + "prompt_per_second": 149.1, + "predicted_n": 256, + "predicted_ms": 4960.0, + "predicted_per_token_ms": 19.375, + "predicted_per_second": 51.6, + "draft_n": 229, + "draft_n_accepted": 159 + }, + "included_in_speed_summary": true, + "response_text_sha256": "754e536475dcaa7e28eaf3c79499eb5588b1be3fc059d4a10573d2a2218c0532", + "engine": { + "prompt_tokens": 1023, + "reused": 0, + "output_tokens": 256, + "prompt_total": 1023, + "prompt_read": 1023, + "engine_generated": 256, + "prompt_ms": 6861.0, + "decode_ms": 4960.0, + "hit_rate": 0.971, + "pcie_share": 0.0, + "file_mb": 4797.1, + "drafts_offered": 229, + "drafts_accepted": 159 + } + }, + { + "label": "tokens-1024-run-2", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 1023, + "request_sha256": "670a09acda4a7e346e80e757d24552b70950ecec3bd9865cb3cc44bad41e3051", + "started_epoch_s": 1791137389.19458, + "finished_epoch_s": 1791137396.2214587, + "client_ttft_s": 3.934812100000272, + "client_elapsed_s": 6.942086900000504, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 263.6801814573292, + "decode_tok_s": 84.16346122234278, + "usage": { + "prompt_tokens": 1023, + "completion_tokens": 256, + "total_tokens": 1279, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 1023, + "prompt_ms": 3879.7, + "prompt_per_token_ms": 3.792, + "prompt_per_second": 263.7, + "predicted_n": 256, + "predicted_ms": 3041.7, + "predicted_per_token_ms": 11.882, + "predicted_per_second": 84.2, + "draft_n": 217, + "draft_n_accepted": 160 + }, + "included_in_speed_summary": true, + "response_text_sha256": "f16202df7a76d382e05db90e4feeeb85229cf2a62c17714e27425a261a81a855", + "engine": { + "prompt_tokens": 1023, + "reused": 0, + "output_tokens": 256, + "prompt_total": 1023, + "prompt_read": 1023, + "engine_generated": 256, + "prompt_ms": 3879.7, + "decode_ms": 3041.7, + "hit_rate": 0.992, + "pcie_share": 0.0, + "file_mb": 1525.5, + "drafts_offered": 217, + "drafts_accepted": 160 + } + }, + { + "label": "tokens-1024-run-3", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 1023, + "request_sha256": "aaeb15c4a0db6bd6c46ad6217c8babe776b720fb4ad9c375c8b0877527793168", + "started_epoch_s": 1791137397.3351476, + "finished_epoch_s": 1791137404.4230087, + "client_ttft_s": 3.722584300001472, + "client_elapsed_s": 7.015831400000025, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 277.4764023000976, + "decode_tok_s": 77.34606320623602, + "usage": { + "prompt_tokens": 1023, + "completion_tokens": 256, + "total_tokens": 1279, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 1023, + "prompt_ms": 3686.8, + "prompt_per_token_ms": 3.604, + "prompt_per_second": 277.5, + "predicted_n": 256, + "predicted_ms": 3309.8, + "predicted_per_token_ms": 12.929, + "predicted_per_second": 77.3, + "draft_n": 225, + "draft_n_accepted": 145 + }, + "included_in_speed_summary": true, + "response_text_sha256": "0b451b8c3fb95b34b030bd7c165bb636d571b89bcf137cc3165368185bc029e2", + "engine": { + "prompt_tokens": 1023, + "reused": 0, + "output_tokens": 256, + "prompt_total": 1023, + "prompt_read": 1023, + "engine_generated": 256, + "prompt_ms": 3686.8, + "decode_ms": 3309.8, + "hit_rate": 0.994, + "pcie_share": 0.0, + "file_mb": 1071.3, + "drafts_offered": 225, + "drafts_accepted": 145 + } + }, + { + "label": "tokens-4096-run-1", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 4096, + "request_sha256": "5d94c652067354bbe72930d2bdad3886564f08cf2546b32411af02d33ad3ce05", + "started_epoch_s": 1791137405.5423403, + "finished_epoch_s": 1791137416.3110352, + "client_ttft_s": 7.534027300000162, + "client_elapsed_s": 10.720107400000416, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 547.3594184306179, + "decode_tok_s": 79.75077881619937, + "usage": { + "prompt_tokens": 4096, + "completion_tokens": 256, + "total_tokens": 4352, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 4096, + "prompt_ms": 7483.2, + "prompt_per_token_ms": 1.827, + "prompt_per_second": 547.4, + "predicted_n": 256, + "predicted_ms": 3210.0, + "predicted_per_token_ms": 12.539, + "predicted_per_second": 79.8, + "draft_n": 223, + "draft_n_accepted": 156 + }, + "included_in_speed_summary": true, + "response_text_sha256": "d2d585d2a402a8626ef53f71831b4105a533c746301845be4f1cdff42fdd4c2d", + "engine": { + "prompt_tokens": 4096, + "reused": 0, + "output_tokens": 256, + "prompt_total": 4096, + "prompt_read": 4096, + "engine_generated": 256, + "prompt_ms": 7483.2, + "decode_ms": 3210.0, + "hit_rate": 0.991, + "pcie_share": 0.0, + "file_mb": 1609.7, + "drafts_offered": 223, + "drafts_accepted": 156 + } + }, + { + "label": "tokens-4096-run-2", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 4096, + "request_sha256": "8da8a04e70e4d916f6630729082bdfb9d6ebbb47117aad60bc0541bce198a213", + "started_epoch_s": 1791137417.3695579, + "finished_epoch_s": 1791137427.6159132, + "client_ttft_s": 7.062032199999521, + "client_elapsed_s": 10.167359600000054, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 583.5090318536668, + "decode_tok_s": 81.98821419420958, + "usage": { + "prompt_tokens": 4096, + "completion_tokens": 256, + "total_tokens": 4352, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 4096, + "prompt_ms": 7019.6, + "prompt_per_token_ms": 1.714, + "prompt_per_second": 583.5, + "predicted_n": 256, + "predicted_ms": 3122.4, + "predicted_per_token_ms": 12.197, + "predicted_per_second": 82.0, + "draft_n": 219, + "draft_n_accepted": 150 + }, + "included_in_speed_summary": true, + "response_text_sha256": "5abc1f348c1e9ac7fc96fdc7ec125a04f270f1f8522341ef2bb5915d5d6df3bb", + "engine": { + "prompt_tokens": 4096, + "reused": 0, + "output_tokens": 256, + "prompt_total": 4096, + "prompt_read": 4096, + "engine_generated": 256, + "prompt_ms": 7019.6, + "decode_ms": 3122.4, + "hit_rate": 0.996, + "pcie_share": 0.0, + "file_mb": 739.4, + "drafts_offered": 219, + "drafts_accepted": 150 + } + }, + { + "label": "tokens-4096-run-3", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 4096, + "request_sha256": "946079edb58e764050805886156dc8f877cc29e1ca8d01c84e9a1e7917d49492", + "started_epoch_s": 1791137428.6746917, + "finished_epoch_s": 1791137438.4311018, + "client_ttft_s": 6.976809499999945, + "client_elapsed_s": 9.68955300000016, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 590.329321899546, + "decode_tok_s": 93.90015772292116, + "usage": { + "prompt_tokens": 4096, + "completion_tokens": 256, + "total_tokens": 4352, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 4096, + "prompt_ms": 6938.5, + "prompt_per_token_ms": 1.694, + "prompt_per_second": 590.3, + "predicted_n": 256, + "predicted_ms": 2726.3, + "predicted_per_token_ms": 10.65, + "predicted_per_second": 93.9, + "draft_n": 219, + "draft_n_accepted": 146 + }, + "included_in_speed_summary": true, + "response_text_sha256": "ecbc06b7fbeb088cc190ce8ce631686749f1b1e36021f08c8541663d05d046d1", + "engine": { + "prompt_tokens": 4096, + "reused": 0, + "output_tokens": 256, + "prompt_total": 4096, + "prompt_read": 4096, + "engine_generated": 256, + "prompt_ms": 6938.5, + "decode_ms": 2726.3, + "hit_rate": 0.997, + "pcie_share": 0.0, + "file_mb": 617.8, + "drafts_offered": 219, + "drafts_accepted": 146 + } + }, + { + "label": "tokens-16384-run-1", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 16384, + "request_sha256": "6189656df3e39c2820cb59a0561adb1207c2f570424ca0aee304356f5e386de4", + "started_epoch_s": 1791137439.704907, + "finished_epoch_s": 1791137458.992146, + "client_ttft_s": 16.01550429999952, + "client_elapsed_s": 19.213972899999135, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 1027.448373603908, + "decode_tok_s": 79.44142746314972, + "usage": { + "prompt_tokens": 16384, + "completion_tokens": 256, + "total_tokens": 16640, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 16384, + "prompt_ms": 15946.3, + "prompt_per_token_ms": 0.973, + "prompt_per_second": 1027.4, + "predicted_n": 256, + "predicted_ms": 3222.5, + "predicted_per_token_ms": 12.588, + "predicted_per_second": 79.4, + "draft_n": 190, + "draft_n_accepted": 143 + }, + "included_in_speed_summary": true, + "response_text_sha256": "41f7e8d67aa50a49cf3eef6073fb813941d964d609e18974af91984540803ca4", + "engine": { + "prompt_tokens": 16384, + "reused": 0, + "output_tokens": 256, + "prompt_total": 16384, + "prompt_read": 16384, + "engine_generated": 256, + "prompt_ms": 15946.3, + "decode_ms": 3222.5, + "hit_rate": 0.993, + "pcie_share": 0.0, + "file_mb": 1146.8, + "drafts_offered": 190, + "drafts_accepted": 143 + } + }, + { + "label": "tokens-16384-run-2", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 16384, + "request_sha256": "d77a390c17eb10efc0a7a0117c5c9ed46fa24b12d8c1fe005e2253f0472dfd15", + "started_epoch_s": 1791137460.2221165, + "finished_epoch_s": 1791137479.142808, + "client_ttft_s": 15.729271700000027, + "client_elapsed_s": 18.869459200001074, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 1045.85176532169, + "decode_tok_s": 80.87701007803368, + "usage": { + "prompt_tokens": 16384, + "completion_tokens": 256, + "total_tokens": 16640, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 16384, + "prompt_ms": 15665.7, + "prompt_per_token_ms": 0.956, + "prompt_per_second": 1045.9, + "predicted_n": 256, + "predicted_ms": 3165.3, + "predicted_per_token_ms": 12.364, + "predicted_per_second": 80.9, + "draft_n": 210, + "draft_n_accepted": 156 + }, + "included_in_speed_summary": true, + "response_text_sha256": "6feccac79a8375700788234a9e4a69905c635f422051af412468ca7167b40d86", + "engine": { + "prompt_tokens": 16384, + "reused": 0, + "output_tokens": 256, + "prompt_total": 16384, + "prompt_read": 16384, + "engine_generated": 256, + "prompt_ms": 15665.7, + "decode_ms": 3165.3, + "hit_rate": 0.996, + "pcie_share": 0.0, + "file_mb": 715.1, + "drafts_offered": 210, + "drafts_accepted": 156 + } + }, + { + "label": "tokens-16384-run-3", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 16384, + "request_sha256": "7664e759d262ff5e9dbbef7e55d09267244629ba14eff0c871954813fd5e36b2", + "started_epoch_s": 1791137480.3262331, + "finished_epoch_s": 1791137498.7173786, + "client_ttft_s": 15.47054879999996, + "client_elapsed_s": 18.32465349999984, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 1062.3439779542875, + "decode_tok_s": 89.16753744339951, + "usage": { + "prompt_tokens": 16384, + "completion_tokens": 256, + "total_tokens": 16640, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 16384, + "prompt_ms": 15422.5, + "prompt_per_token_ms": 0.941, + "prompt_per_second": 1062.3, + "predicted_n": 256, + "predicted_ms": 2871.0, + "predicted_per_token_ms": 11.215, + "predicted_per_second": 89.2, + "draft_n": 211, + "draft_n_accepted": 157 + }, + "included_in_speed_summary": true, + "response_text_sha256": "f9a10eec256b346a886ce44e6cb1bcb62d974884108b660dbe650b365539354d", + "engine": { + "prompt_tokens": 16384, + "reused": 0, + "output_tokens": 256, + "prompt_total": 16384, + "prompt_read": 16384, + "engine_generated": 256, + "prompt_ms": 15422.5, + "decode_ms": 2871.0, + "hit_rate": 0.997, + "pcie_share": 0.0, + "file_mb": 445.6, + "drafts_offered": 211, + "drafts_accepted": 157 + } + } + ] + }, + { + "label": "on", + "STRATA_ARENA_RELEASE": "1", + "source_results_sha256": "5aee68f7a00f048edceb3b2b75baf7657b2b9fcb57e829cad3392a105fe9b1b4", + "source_host_samples_sha256": "31a5f48d96dd0b57bb43d77d2d634da4ae772c61d5327ff0e4a3e6b81a96fb75", + "speed_summary": { + "1024": { + "successful_runs": 3, + "failed_attempts": 0, + "client_ttft_s": { + "median": 4.0692154999997, + "min": 3.986472699998558, + "max": 6.56791929999963 + }, + "client_elapsed_s": { + "median": 7.263019899999563, + "min": 6.9997069999990345, + "max": 11.219825399999536 + }, + "prefill_tok_s": { + "median": 253.8272585167357, + "min": 156.63997305118744, + "max": 259.05292479108635 + }, + "decode_tok_s": { + "median": 77.64634516226873, + "min": 54.67281735861952, + "max": 86.72380500694467 + } + }, + "4096": { + "successful_runs": 3, + "failed_attempts": 0, + "client_ttft_s": { + "median": 7.375531800000317, + "min": 7.352118200000405, + "max": 8.131530399999974 + }, + "client_elapsed_s": { + "median": 10.056364900001427, + "min": 10.007067900000038, + "max": 11.0680511999999 + }, + "prefill_tok_s": { + "median": 558.2358873715485, + "min": 506.3917117919047, + "max": 560.0295328073942 + }, + "decode_tok_s": { + "median": 94.17304296645085, + "min": 86.66508683435458, + "max": 96.77907152578256 + } + }, + "16384": { + "successful_runs": 3, + "failed_attempts": 0, + "client_ttft_s": { + "median": 16.450469699999303, + "min": 16.266660800001773, + "max": 16.826802199999292 + }, + "client_elapsed_s": { + "median": 19.415217300000222, + "min": 19.26390910000009, + "max": 19.8214212999992 + }, + "prefill_tok_s": { + "median": 1000.1648220837175, + "min": 976.6915052160955, + "max": 1011.4391895645946 + }, + "decode_tok_s": { + "median": 84.928507447832, + "min": 84.86656721365821, + "max": 85.25944181709187 + } + } + }, + "host_benchmark_window": { + "coverage": { + "requested_start_epoch_s": 1791137626.402531, + "requested_end_epoch_s": 1791137752.6598368, + "requested_duration_s": 126.25730586051941, + "sample_count": 126, + "first_sample_epoch_s": 1791137626.977466, + "last_sample_epoch_s": 1791137752.1095142, + "observed_span_s": 125.1320481300354, + "omitted_start_s": 0.5749351978302002, + "omitted_end_s": 0.5503225326538086, + "sample_spacing_s": { + "count": 125, + "min": 0.9786038398742676, + "median": 0.9989616870880127, + "max": 1.0214459896087646 + } + }, + "available_bytes": { + "count": 126, + "min": 6560342016, + "median": 13085794304.0, + "max": 22309302272 + }, + "commit_bytes": { + "count": 126, + "min": 55180480512, + "median": 55805659136.0, + "max": 55971119104 + }, + "commit_limit_bytes": { + "count": 126, + "min": 56076263424, + "median": 57163968512.0, + "max": 57163968512 + }, + "commit_headroom_bytes": { + "count": 126, + "min": 391651328, + "median": 1339875328.0, + "max": 1484484608 + }, + "pagefile_total_bytes": { + "count": 126, + "min": 21968617472, + "median": 23056322560.0, + "max": 23056322560 + }, + "pagefile_used_bytes": { + "count": 126, + "min": 1306562560, + "median": 1307480064.0, + "max": 1325748224 + }, + "strata": { + "samples_with_engine": 126, + "process_count_per_host_sample": { + "count": 126, + "min": 1, + "median": 1.0, + "max": 1 + }, + "working_set_bytes": { + "count": 126, + "min": 3676139520, + "median": 12827172864.0, + "max": 19314704384 + }, + "private_working_set_bytes": { + "count": 126, + "min": 3141050368, + "median": 3504500736.0, + "max": 3622793216 + }, + "nonprivate_working_set_bytes": { + "count": 126, + "min": 535089152, + "median": 9330184192.0, + "max": 15692541952 + }, + "private_commit_bytes": { + "count": 126, + "min": 38980931584, + "median": 39518244864.0, + "max": 39636115456 + } + }, + "system_physical_disk_io": { + "PhysicalDrive0": { + "samples_present": 126, + "status": "ok", + "read_bytes_delta": 18048543744, + "write_bytes_delta": 33413632 + }, + "PhysicalDrive2": { + "samples_present": 126, + "status": "ok", + "read_bytes_delta": 0, + "write_bytes_delta": 0 + } + } + }, + "trials": [ + { + "label": "warmup-a1e1be73349b", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 33, + "request_sha256": "7cc9c1b4847a639e6588184ca10109efde1ab7e5af957bc4322ceebebe4bc689", + "started_epoch_s": 1791137626.402531, + "finished_epoch_s": 1791137627.908431, + "client_ttft_s": 1.2135624999991705, + "client_elapsed_s": 1.4330016000003525, + "finish_reason": "stop", + "stream_done": true, + "prefill_tok_s": 29.016090741229227, + "decode_tok_s": 7.178750897343861, + "usage": { + "prompt_tokens": 33, + "completion_tokens": 2, + "total_tokens": 35, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 33, + "prompt_ms": 1137.3, + "prompt_per_token_ms": 34.464, + "prompt_per_second": 29.0, + "predicted_n": 2, + "predicted_ms": 278.6, + "predicted_per_token_ms": 139.3, + "predicted_per_second": 7.2, + "draft_n": 3, + "draft_n_accepted": 3 + }, + "included_in_speed_summary": false, + "response_text_sha256": "c2e3ac47f4a325469c1a2d5f117e463ec943c721986d5d9f09ac4540b7d80526", + "engine": { + "prompt_tokens": 33, + "reused": 0, + "output_tokens": 2, + "prompt_total": 33, + "prompt_read": 33, + "engine_generated": 2, + "prompt_ms": 1137.3, + "decode_ms": 278.6, + "hit_rate": 0.857, + "pcie_share": 0.0, + "file_mb": 298.0, + "drafts_offered": 3, + "drafts_accepted": 3 + } + }, + { + "label": "tokens-1024-run-1", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 1023, + "request_sha256": "1b7264f120d81c7905cc2779e19aa3b14f7d2ad8efef6cc9c159e3e73bbe1ca5", + "started_epoch_s": 1791137628.7661443, + "finished_epoch_s": 1791137640.0090027, + "client_ttft_s": 6.56791929999963, + "client_elapsed_s": 11.219825399999536, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 156.63997305118744, + "decode_tok_s": 54.67281735861952, + "usage": { + "prompt_tokens": 1023, + "completion_tokens": 256, + "total_tokens": 1279, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 1023, + "prompt_ms": 6530.9, + "prompt_per_token_ms": 6.384, + "prompt_per_second": 156.6, + "predicted_n": 256, + "predicted_ms": 4682.4, + "predicted_per_token_ms": 18.291, + "predicted_per_second": 54.7, + "draft_n": 235, + "draft_n_accepted": 150 + }, + "included_in_speed_summary": true, + "response_text_sha256": "69e6248b81f83a2de98dbc75e0e40b4350bee7ca6cea5296b96a02f8975a0414", + "engine": { + "prompt_tokens": 1023, + "reused": 0, + "output_tokens": 256, + "prompt_total": 1023, + "prompt_read": 1023, + "engine_generated": 256, + "prompt_ms": 6530.9, + "decode_ms": 4682.4, + "hit_rate": 0.975, + "pcie_share": 0.0, + "file_mb": 4336.5, + "drafts_offered": 235, + "drafts_accepted": 150 + } + }, + { + "label": "tokens-1024-run-2", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 1023, + "request_sha256": "670a09acda4a7e346e80e757d24552b70950ecec3bd9865cb3cc44bad41e3051", + "started_epoch_s": 1791137640.9247723, + "finished_epoch_s": 1791137648.2246199, + "client_ttft_s": 3.986472699998558, + "client_elapsed_s": 7.263019899999563, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 259.05292479108635, + "decode_tok_s": 77.64634516226873, + "usage": { + "prompt_tokens": 1023, + "completion_tokens": 256, + "total_tokens": 1279, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 1023, + "prompt_ms": 3949.0, + "prompt_per_token_ms": 3.86, + "prompt_per_second": 259.1, + "predicted_n": 256, + "predicted_ms": 3297.0, + "predicted_per_token_ms": 12.879, + "predicted_per_second": 77.6, + "draft_n": 215, + "draft_n_accepted": 157 + }, + "included_in_speed_summary": true, + "response_text_sha256": "c066e3a14713ca128b2aa64ef1172ff3edaabaa394e11ae465e4d02514c9edce", + "engine": { + "prompt_tokens": 1023, + "reused": 0, + "output_tokens": 256, + "prompt_total": 1023, + "prompt_read": 1023, + "engine_generated": 256, + "prompt_ms": 3949.0, + "decode_ms": 3297.0, + "hit_rate": 0.99, + "pcie_share": 0.0, + "file_mb": 1774.4, + "drafts_offered": 215, + "drafts_accepted": 157 + } + }, + { + "label": "tokens-1024-run-3", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 1023, + "request_sha256": "aaeb15c4a0db6bd6c46ad6217c8babe776b720fb4ad9c375c8b0877527793168", + "started_epoch_s": 1791137649.1335173, + "finished_epoch_s": 1791137656.1717339, + "client_ttft_s": 4.0692154999997, + "client_elapsed_s": 6.9997069999990345, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 253.8272585167357, + "decode_tok_s": 86.72380500694467, + "usage": { + "prompt_tokens": 1023, + "completion_tokens": 256, + "total_tokens": 1279, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 1023, + "prompt_ms": 4030.3, + "prompt_per_token_ms": 3.94, + "prompt_per_second": 253.8, + "predicted_n": 256, + "predicted_ms": 2951.9, + "predicted_per_token_ms": 11.531, + "predicted_per_second": 86.7, + "draft_n": 214, + "draft_n_accepted": 159 + }, + "included_in_speed_summary": true, + "response_text_sha256": "5913309c145e19f3708b4783227ce89a428b93e2dfd48a49fbc05251a8f86880", + "engine": { + "prompt_tokens": 1023, + "reused": 0, + "output_tokens": 256, + "prompt_total": 1023, + "prompt_read": 1023, + "engine_generated": 256, + "prompt_ms": 4030.3, + "decode_ms": 2951.9, + "hit_rate": 0.993, + "pcie_share": 0.0, + "file_mb": 1169.8, + "drafts_offered": 214, + "drafts_accepted": 159 + } + }, + { + "label": "tokens-4096-run-1", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 4096, + "request_sha256": "5d94c652067354bbe72930d2bdad3886564f08cf2546b32411af02d33ad3ce05", + "started_epoch_s": 1791137657.1340292, + "finished_epoch_s": 1791137668.281504, + "client_ttft_s": 8.131530399999974, + "client_elapsed_s": 11.0680511999999, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 506.3917117919047, + "decode_tok_s": 86.66508683435458, + "usage": { + "prompt_tokens": 4096, + "completion_tokens": 256, + "total_tokens": 4352, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 4096, + "prompt_ms": 8088.6, + "prompt_per_token_ms": 1.975, + "prompt_per_second": 506.4, + "predicted_n": 256, + "predicted_ms": 2953.9, + "predicted_per_token_ms": 11.539, + "predicted_per_second": 86.7, + "draft_n": 215, + "draft_n_accepted": 157 + }, + "included_in_speed_summary": true, + "response_text_sha256": "5f83d6b250bc425094524568671a33dd5732382e1a63fdc4da122ce0d554c07f", + "engine": { + "prompt_tokens": 4096, + "reused": 0, + "output_tokens": 256, + "prompt_total": 4096, + "prompt_read": 4096, + "engine_generated": 256, + "prompt_ms": 8088.6, + "decode_ms": 2953.9, + "hit_rate": 0.995, + "pcie_share": 0.0, + "file_mb": 930.8, + "drafts_offered": 215, + "drafts_accepted": 157 + } + }, + { + "label": "tokens-4096-run-2", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 4096, + "request_sha256": "8da8a04e70e4d916f6630729082bdfb9d6ebbb47117aad60bc0541bce198a213", + "started_epoch_s": 1791137669.2562735, + "finished_epoch_s": 1791137679.3572376, + "client_ttft_s": 7.352118200000405, + "client_elapsed_s": 10.056364900001427, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 560.0295328073942, + "decode_tok_s": 94.17304296645085, + "usage": { + "prompt_tokens": 4096, + "completion_tokens": 256, + "total_tokens": 4352, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 4096, + "prompt_ms": 7313.9, + "prompt_per_token_ms": 1.786, + "prompt_per_second": 560.0, + "predicted_n": 256, + "predicted_ms": 2718.4, + "predicted_per_token_ms": 10.619, + "predicted_per_second": 94.2, + "draft_n": 233, + "draft_n_accepted": 157 + }, + "included_in_speed_summary": true, + "response_text_sha256": "d731c643f5498cf7670969f27dd7ef190be4afac0dff5fa847945c99a6fa7c24", + "engine": { + "prompt_tokens": 4096, + "reused": 0, + "output_tokens": 256, + "prompt_total": 4096, + "prompt_read": 4096, + "engine_generated": 256, + "prompt_ms": 7313.9, + "decode_ms": 2718.4, + "hit_rate": 0.995, + "pcie_share": 0.0, + "file_mb": 870.3, + "drafts_offered": 233, + "drafts_accepted": 157 + } + }, + { + "label": "tokens-4096-run-3", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 4096, + "request_sha256": "946079edb58e764050805886156dc8f877cc29e1ca8d01c84e9a1e7917d49492", + "started_epoch_s": 1791137680.263168, + "finished_epoch_s": 1791137690.3335505, + "client_ttft_s": 7.375531800000317, + "client_elapsed_s": 10.007067900000038, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 558.2358873715485, + "decode_tok_s": 96.77907152578256, + "usage": { + "prompt_tokens": 4096, + "completion_tokens": 256, + "total_tokens": 4352, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 4096, + "prompt_ms": 7337.4, + "prompt_per_token_ms": 1.791, + "prompt_per_second": 558.2, + "predicted_n": 256, + "predicted_ms": 2645.2, + "predicted_per_token_ms": 10.333, + "predicted_per_second": 96.8, + "draft_n": 222, + "draft_n_accepted": 155 + }, + "included_in_speed_summary": true, + "response_text_sha256": "57e181c3707584e86bde080bd2f4730d4f735bd0a34c83ab9fbacae2cb603fe2", + "engine": { + "prompt_tokens": 4096, + "reused": 0, + "output_tokens": 256, + "prompt_total": 4096, + "prompt_read": 4096, + "engine_generated": 256, + "prompt_ms": 7337.4, + "decode_ms": 2645.2, + "hit_rate": 0.995, + "pcie_share": 0.0, + "file_mb": 812.9, + "drafts_offered": 222, + "drafts_accepted": 155 + } + }, + { + "label": "tokens-16384-run-1", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 16384, + "request_sha256": "6189656df3e39c2820cb59a0561adb1207c2f570424ca0aee304356f5e386de4", + "started_epoch_s": 1791137691.5508344, + "finished_epoch_s": 1791137711.428968, + "client_ttft_s": 16.826802199999292, + "client_elapsed_s": 19.8214212999992, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 976.6915052160955, + "decode_tok_s": 84.928507447832, + "usage": { + "prompt_tokens": 16384, + "completion_tokens": 256, + "total_tokens": 16640, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 16384, + "prompt_ms": 16775.0, + "prompt_per_token_ms": 1.024, + "prompt_per_second": 976.7, + "predicted_n": 256, + "predicted_ms": 3014.3, + "predicted_per_token_ms": 11.775, + "predicted_per_second": 84.9, + "draft_n": 215, + "draft_n_accepted": 158 + }, + "included_in_speed_summary": true, + "response_text_sha256": "d33caffe0edc7aa192daf1b736ee3949313458f50d684e3b4fd6f8531c2e9d25", + "engine": { + "prompt_tokens": 16384, + "reused": 0, + "output_tokens": 256, + "prompt_total": 16384, + "prompt_read": 16384, + "engine_generated": 256, + "prompt_ms": 16775.0, + "decode_ms": 3014.3, + "hit_rate": 0.996, + "pcie_share": 0.0, + "file_mb": 668.2, + "drafts_offered": 215, + "drafts_accepted": 158 + } + }, + { + "label": "tokens-16384-run-2", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 16384, + "request_sha256": "d77a390c17eb10efc0a7a0117c5c9ed46fa24b12d8c1fe005e2253f0472dfd15", + "started_epoch_s": 1791137712.7162516, + "finished_epoch_s": 1791137732.0337036, + "client_ttft_s": 16.266660800001773, + "client_elapsed_s": 19.26390910000009, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 1011.4391895645946, + "decode_tok_s": 84.86656721365821, + "usage": { + "prompt_tokens": 16384, + "completion_tokens": 256, + "total_tokens": 16640, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 16384, + "prompt_ms": 16198.7, + "prompt_per_token_ms": 0.989, + "prompt_per_second": 1011.4, + "predicted_n": 256, + "predicted_ms": 3016.5, + "predicted_per_token_ms": 11.783, + "predicted_per_second": 84.9, + "draft_n": 218, + "draft_n_accepted": 159 + }, + "included_in_speed_summary": true, + "response_text_sha256": "bc9f9c578e0c3d37c6d874c03b58f4db0dd332dc4cfb1310976e0f4ecb63c7e3", + "engine": { + "prompt_tokens": 16384, + "reused": 0, + "output_tokens": 256, + "prompt_total": 16384, + "prompt_read": 16384, + "engine_generated": 256, + "prompt_ms": 16198.7, + "decode_ms": 3016.5, + "hit_rate": 0.996, + "pcie_share": 0.0, + "file_mb": 710.8, + "drafts_offered": 218, + "drafts_accepted": 159 + } + }, + { + "label": "tokens-16384-run-3", + "attempt": 1, + "status": "ok", + "expected_prompt_tokens": 16384, + "request_sha256": "7664e759d262ff5e9dbbef7e55d09267244629ba14eff0c871954813fd5e36b2", + "started_epoch_s": 1791137733.223531, + "finished_epoch_s": 1791137752.6598368, + "client_ttft_s": 16.450469699999303, + "client_elapsed_s": 19.415217300000222, + "finish_reason": "length", + "stream_done": true, + "prefill_tok_s": 1000.1648220837175, + "decode_tok_s": 85.25944181709187, + "usage": { + "prompt_tokens": 16384, + "completion_tokens": 256, + "total_tokens": 16640, + "prompt_tokens_details": { + "cached_tokens": 0 + } + }, + "timings": { + "cache_n": 0, + "prompt_n": 16384, + "prompt_ms": 16381.3, + "prompt_per_token_ms": 1.0, + "prompt_per_second": 1000.2, + "predicted_n": 256, + "predicted_ms": 3002.6, + "predicted_per_token_ms": 11.729, + "predicted_per_second": 85.3, + "draft_n": 210, + "draft_n_accepted": 157 + }, + "included_in_speed_summary": true, + "response_text_sha256": "fc3fd4e03cf8656f98f106a2edc8c9f64e593addedc7dadc0ccc4f9022390bf8", + "engine": { + "prompt_tokens": 16384, + "reused": 0, + "output_tokens": 256, + "prompt_total": 16384, + "prompt_read": 16384, + "engine_generated": 256, + "prompt_ms": 16381.3, + "decode_ms": 3002.6, + "hit_rate": 0.997, + "pcie_share": 0.0, + "file_mb": 514.7, + "drafts_offered": 210, + "drafts_accepted": 157 + } + } + ] + } + ] +} diff --git a/bench/results/2026-10-04-windows-mapped-release/monitor_windows.py b/bench/results/2026-10-04-windows-mapped-release/monitor_windows.py new file mode 100644 index 00000000..e2b0c8bd --- /dev/null +++ b/bench/results/2026-10-04-windows-mapped-release/monitor_windows.py @@ -0,0 +1,139 @@ +"""Record Windows host memory and physical-disk counters during a local experiment.""" +from __future__ import annotations + +import argparse +import ctypes +from ctypes import wintypes +import json +from pathlib import Path +import time + +import psutil + + +class PerformanceInformation(ctypes.Structure): + _fields_ = [("cb", wintypes.DWORD)] + [ + (name, ctypes.c_size_t) for name in ( + "CommitTotal", "CommitLimit", "CommitPeak", "PhysicalTotal", + "PhysicalAvailable", "SystemCache", "KernelTotal", "KernelPaged", + "KernelNonpaged", "PageSize", + ) + ] + [(name, wintypes.DWORD) for name in ( + "HandleCount", "ProcessCount", "ThreadCount", + )] + + +performance = ctypes.WinDLL("psapi", use_last_error=True).GetPerformanceInfo +performance.argtypes = [ctypes.POINTER(PerformanceInformation), wintypes.DWORD] +performance.restype = wintypes.BOOL + + +class ProcessMemoryCounters(ctypes.Structure): + _fields_ = [("cb", wintypes.DWORD), ("page_fault_count", wintypes.DWORD)] + [ + (name, ctypes.c_size_t) for name in ( + "peak_working_set_bytes", "working_set_bytes", "peak_paged_pool_bytes", + "paged_pool_bytes", "peak_nonpaged_pool_bytes", "nonpaged_pool_bytes", + "commit_bytes", "peak_commit_bytes", "private_commit_bytes", + "private_working_set_bytes", + ) + ] + [("shared_commit_bytes", ctypes.c_ulonglong)] + + +kernel = ctypes.WinDLL("kernel32", use_last_error=True) +kernel.OpenProcess.argtypes = [wintypes.DWORD, wintypes.BOOL, wintypes.DWORD] +kernel.OpenProcess.restype = wintypes.HANDLE +kernel.CloseHandle.argtypes = [wintypes.HANDLE] +kernel.CloseHandle.restype = wintypes.BOOL +process_memory = ctypes.WinDLL("psapi", use_last_error=True).GetProcessMemoryInfo +process_memory.argtypes = [wintypes.HANDLE, ctypes.POINTER(ProcessMemoryCounters), wintypes.DWORD] +process_memory.restype = wintypes.BOOL + + +def extended_memory(process): + handle = kernel.OpenProcess(0x1000, False, process.pid) # PROCESS_QUERY_LIMITED_INFORMATION + if not handle: + if not process.is_running(): + raise psutil.NoSuchProcess(process.pid) + raise ctypes.WinError(ctypes.get_last_error()) + try: + info = ProcessMemoryCounters() + info.cb = ctypes.sizeof(info) + if not process_memory(handle, ctypes.byref(info), info.cb): + raise ctypes.WinError(ctypes.get_last_error()) + return {name: getattr(info, name) for name, _ in info._fields_ if name != "cb"} + finally: + kernel.CloseHandle(handle) + + +def sample(server): + info = PerformanceInformation() + info.cb = ctypes.sizeof(info) + if not performance(ctypes.byref(info), info.cb): + raise ctypes.WinError(ctypes.get_last_error()) + processes = [] + if server is not None: + try: + descendants = [server, *server.children(recursive=True)] + except psutil.NoSuchProcess: + descendants = [] + for process in descendants: + try: + with process.oneshot(): + processes.append({ + "pid": process.pid, + "name": process.name(), + "memory": process.memory_info()._asdict(), + "windows_memory": extended_memory(process), + "cpu_seconds": process.cpu_times()._asdict(), + "io_counters": process.io_counters()._asdict(), + }) + except psutil.NoSuchProcess: + continue + battery = psutil.sensors_battery() + return { + "epoch_s": time.time(), + "memory": psutil.virtual_memory()._asdict(), + "pagefile": psutil.swap_memory()._asdict(), + "commit_bytes": info.CommitTotal * info.PageSize, + "commit_limit_bytes": info.CommitLimit * info.PageSize, + "commit_peak_bytes": info.CommitPeak * info.PageSize, + "system_cache_bytes": info.SystemCache * info.PageSize, + "physical_disks": { + name: counters._asdict() + for name, counters in psutil.disk_io_counters(perdisk=True).items() + }, + "ac_power": battery.power_plugged if battery is not None else None, + "processes": processes, + } + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--server-pid", type=int) + parser.add_argument("--out", type=Path, required=True) + parser.add_argument("--stop-file", type=Path, required=True) + parser.add_argument("--interval", type=float, default=1.0) + parser.add_argument("--samples", type=int, help="Optional bounded diagnostic run") + args = parser.parse_args() + if args.interval <= 0 or (args.samples is not None and args.samples < 1): + parser.error("Interval and sample limit must be positive") + if args.stop_file.exists(): + parser.error("The stop file already exists; choose a new experiment path") + server = psutil.Process(args.server_pid) if args.server_pid is not None else None + args.out.parent.mkdir(parents=True, exist_ok=True) + with args.out.open("x", encoding="utf-8") as output: + count = 0 + while not args.stop_file.exists(): + started = time.monotonic() + output.write(json.dumps(sample(server)) + "\n") + output.flush() + count += 1 + if args.samples is not None and count >= args.samples: + break + if server is not None and not server.is_running(): + break + time.sleep(max(0, args.interval - (time.monotonic() - started))) + + +if __name__ == "__main__": + main() diff --git a/bench/results/2026-10-04-windows-mapped-release/test_benchmark.py b/bench/results/2026-10-04-windows-mapped-release/test_benchmark.py new file mode 100644 index 00000000..4595de1b --- /dev/null +++ b/bench/results/2026-10-04-windows-mapped-release/test_benchmark.py @@ -0,0 +1,179 @@ +"""Protocol and evidence checks against a local fake server; no model or GPU work.""" +import importlib.util +import hashlib +import json +import tempfile +import threading +import unittest +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from pathlib import Path + +HERE = Path(__file__).resolve().parent +SPEC = importlib.util.spec_from_file_location("local_benchmark", HERE / "benchmark.py") +BENCH = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(BENCH) + + +class FakeServer(ThreadingHTTPServer): + def __init__(self): + super().__init__(("127.0.0.1", 0), FakeHandler) + self.mode = "ok" + self.metrics = {"engine": {"max_context": 32768}, "live": {"state": "idle", "queued": 0}, + "totals": {"requests": 0}, "requests": [], "time": 1, + "hardware": {"ram_total": 32 * 2**30, "ram_used": 10 * 2**30, + "gpus": [{"index": 0, "mem_used": 100}, {"index": 1, "mem_used": 200}], + "disk_read_mb": 3.5}} + + +class FakeHandler(BaseHTTPRequestHandler): + def log_message(self, *_): + pass + + def do_GET(self): + self.send_response(200) + self.end_headers() + self.wfile.write(json.dumps(self.server.metrics).encode("utf-8")) + + def do_POST(self): + self.rfile.read(int(self.headers["Content-Length"])) + if self.server.mode == "http_error": + self.send_response(400) + self.end_headers() + self.wfile.write(b'{"error": "Synthetic request rejection"}') + return + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.end_headers() + + def send(value): + self.wfile.write(b"data: " + json.dumps(value).encode("utf-8") + b"\n\n") + self.wfile.flush() + + send({"choices": [{"delta": {"content": "Verified output."}, "finish_reason": None}]}) + if self.server.mode == "stream_error": + send({"error": {"message": "Synthetic engine failure"}}) + return + reused = 1 if self.server.mode == "reused" else 0 + engine = {"prompt_tokens": 100, "prompt_total": 100, "prompt_read": 100 - reused, + "reused": reused, "prompt_ms": 100, "decode_ms": 200, + "output_tokens": 8, "engine_generated": 8, "finish": "length", + "file_mb": 12.5, "ram_blobs": 3, "file_blobs": 9} + self.server.metrics["totals"]["requests"] += 2 if self.server.mode == "other_client" else 1 + self.server.metrics["requests"].insert(0, engine) + send({"choices": [{"delta": {}, "finish_reason": "length"}], + "usage": {"prompt_tokens": 100, "completion_tokens": 8, + "prompt_tokens_details": {"cached_tokens": reused}}, + "timings": {"prompt_n": 100 - reused, "predicted_n": 8, + "prompt_ms": 100, "predicted_ms": 200}}) + if self.server.mode != "missing_done": + self.wfile.write(b"data: [DONE]\n\n") + + +class BenchmarkProtocolTest(unittest.TestCase): + def setUp(self): + self.server = FakeServer() + self.thread = threading.Thread(target=self.server.serve_forever, daemon=True) + self.thread.start() + self.temporary = tempfile.TemporaryDirectory(prefix="test-benchmark-", dir=HERE) + self.out = Path(self.temporary.name).resolve() + self.assertEqual(self.out.parent, HERE) + + def tearDown(self): + self.server.shutdown() + self.server.server_close() + self.thread.join() + self.temporary.cleanup() + + def run_trial(self, mode): + self.server.mode = mode + url = f"http://127.0.0.1:{self.server.server_port}" + return BENCH.perform(url, self.out, "fake-session", mode, 1, + {"max_tokens": 8}, 100, interval=0.01, timeout=3) + + def test_success_has_real_rates_and_both_gpus(self): + row = self.run_trial("ok") + self.assertEqual(row["status"], "ok", row.get("error")) + self.assertEqual(row["prefill_tok_s"], 1000) + self.assertEqual(row["decode_tok_s"], 40) + self.assertEqual(row["engine"]["file_mb"], 12.5) + samples = [json.loads(line) for line in (self.out / row["telemetry"]).read_text(encoding="utf-8").splitlines()] + self.assertEqual(samples[0]["hardware"]["ram_available"], 22 * 2**30) + self.assertEqual(len(samples[0]["hardware"]["gpus"]), 2) + + def test_rejects_cached_prompt_missing_done_and_other_client(self): + for mode, message in (("reused", "cached tokens"), ("missing_done", "without [DONE]"), + ("other_client", "counter mismatch")): + with self.subTest(mode=mode): + row = self.run_trial(mode) + self.assertEqual(row["status"], "failed") + self.assertIn(message, row["error"]["message"]) + self.assertTrue((self.out / f"{mode}-attempt-1-record.json").is_file()) + + def test_stream_error_retains_partial_text_and_error_payload(self): + row = self.run_trial("stream_error") + self.assertEqual(row["status"], "failed") + self.assertEqual(row["text"], "Verified output.") + self.assertIn("Synthetic engine failure", row["error"]["message"]) + self.assertIn("Synthetic engine failure", (self.out / row["raw_stream"]).read_text(encoding="utf-8")) + + def test_http_error_body_is_preserved(self): + row = self.run_trial("http_error") + self.assertEqual(row["status"], "failed") + self.assertEqual(row["error"]["http_status"], 400) + self.assertIn("Synthetic request rejection", row["error"]["body"]) + + def test_summary_reports_failed_attempts_separately(self): + good = {"label": "tokens-1024-run-1", "status": "ok", "client_ttft_s": 1, + "client_elapsed_s": 2, "prefill_tok_s": 1024, "decode_tok_s": 256} + failed = {"label": "tokens-1024-run-1", "status": "failed"} + group = BENCH.summary([failed, good], [1024])["1024"] + self.assertEqual(group["successful_runs"], 1) + self.assertEqual(group["failed_attempts"], 1) + self.assertEqual(group["decode_tok_s"]["median"], 256) + + def test_executable_hash_uses_config_working_directory(self): + payload = b"Synthetic binary contents; never executed." + executable = self.out / "strata.exe" + executable.write_bytes(payload) + for name in ("strata.exe", str(executable)): + with self.subTest(name=name): + record = BENCH.executable_record({"exe": name, "cwd": str(self.out)}) + self.assertEqual(record["path"], str(executable)) + self.assertEqual(record["sha256"], hashlib.sha256(payload).hexdigest()) + self.assertEqual(record["size_bytes"], len(payload)) + with self.assertRaises(FileNotFoundError): + BENCH.executable_record({"exe": "missing.exe", "cwd": str(self.out)}) + + def test_provenance_supports_artifact_schemas_and_rejects_wrong_binary(self): + executable = {"path": str(self.out / "strata.exe"), "sha256": "a" * 64} + artifact = {"sha256": executable["sha256"], "bytes": 123} + path = self.out / "provenance.json" + for artifacts in ({"strata.exe": artifact}, [{"file": "strata.exe", **artifact}]): + source = {"strata_version": "0.1.38", "commit": "fork-commit", + "engine_source_fingerprint": "engine-fingerprint", "artifacts": artifacts, + "source_file_hashes": [{"path": "large-file-list", "sha256": "omitted"}], + "toolchain": {"nvcc": "13.1.80", "cuda_architectures": [86, 89]}} + BENCH.write_json(path, source) + record = BENCH.engine_provenance_record(path, executable) + self.assertEqual(record["sha256"], hashlib.sha256(path.read_bytes()).hexdigest()) + self.assertEqual(record["version"], "0.1.38") + self.assertEqual(record["commit"], "fork-commit") + self.assertEqual(record["fingerprint"], "engine-fingerprint") + self.assertTrue(record["executable_hash_verified"]) + self.assertNotIn("source_file_hashes", record) + with self.assertRaisesRegex(ValueError, "does not match"): + BENCH.engine_provenance_record(path, {**executable, "sha256": "b" * 64}) + + def test_release_build_metadata_does_not_invent_commit_or_hash_verification(self): + path = self.out / "BUILD.json" + BENCH.write_json(path, {"version": "0.1.39", "source": "release", "cuda": "13.0", "archs": [86, 89]}) + record = BENCH.engine_provenance_record(path, {"path": str(self.out / "strata.exe"), "sha256": "a" * 64}) + self.assertEqual(record["version"], "0.1.39") + self.assertEqual(record["toolchain"]["cuda"], "13.0") + self.assertIsNone(record["commit"]) + self.assertIsNone(record["fingerprint"]) + self.assertFalse(record["executable_hash_verified"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/docs/DETAILS.md b/docs/DETAILS.md index 0da4777d..14d1cc8e 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -171,6 +171,15 @@ start writes `experts.bin` (when the drive has room for it), later starts map it are handed back to the OS. Run it with `--pcie-frac 0` (the GPUs get no mapped alias). Without the variable nothing changes. +**Releasing mapped expert pages on Windows (opt-in):** `STRATA_ARENA_RELEASE=1` lets `FileExpertSource` trim the +full file-backed pages of experts after their GPU uploads complete, including the slots lent to prefill and then +refilled. It works with `experts.bin` and the direct GGUF views; shared boundary pages and private/pinned buffers +are left alone. Unset or `0` keeps the previous behavior. On one 32 GB Windows 11 laptop with an RTX 4080 Laptop +and a Thunderbolt RTX 3090, IQ2_XS with `--mmap-experts --layer-split 12 --trim-stage-weights` raised median available +RAM from 0.51 to 12.19 GiB across 1K/4K/16K prompt trials, with 3.7-4.4% lower prefill throughput. It did not reduce +committed memory or physical SSD reads. This is a working-set hint, not an unmap or a guarantee that the OS drops +its file cache. See the [configuration, measurements and limits](../bench/results/2026-10-04-windows-mapped-release/README.md). + **Low-RAM mode without `experts.bin` (engine 0.1.31):** for the native packs (IQ2_XS, IQ3_XXS, IQ3_S, the Coder, Swift, Q2_0 packed by `tools/iq_pack.py`; not the canonical Q2_0 pack setup makes for AVX-512 CPUs) the mapped mode no longer needs the pack's `experts.bin`: when the pack has none, the engine diff --git a/include/strata/core/expert_source.hpp b/include/strata/core/expert_source.hpp index e798670a..ed50b6c2 100644 --- a/include/strata/core/expert_source.hpp +++ b/include/strata/core/expert_source.hpp @@ -549,6 +549,9 @@ public: bool advise_pairs(const std::pair* pairs, int64_t n) const override; const uint8_t* blob(int64_t layer, int64_t expert) override; + /// Windows, opt-in with STRATA_ARENA_RELEASE=1: trim the file mapping's full pages after their expert reaches + /// VRAM. Never touches the resident complement or staging buffers. Disabled by default. + uint64_t release(int64_t layer, int64_t expert) override; bool pinned(int64_t layer, int64_t expert) const override; const uint8_t* device_alias(int64_t layer, int64_t expert) const override; bool pcie_layer(int64_t layer) const override; diff --git a/src/core/expert_source.cpp b/src/core/expert_source.cpp index 05c20f8b..4f251e16 100644 --- a/src/core/expert_source.cpp +++ b/src/core/expert_source.cpp @@ -1582,6 +1582,58 @@ const uint8_t* FileExpertSource::mapped_blob(int64_t layer, int64_t expert) cons return base_ + (size_t) offset; } +uint64_t FileExpertSource::release(int64_t layer, int64_t expert) { +#if defined(_WIN32) + static const bool enabled = [] { + const char* v = std::getenv("STRATA_ARENA_RELEASE"); + return v != nullptr && std::strcmp(v, "1") == 0; + }(); + if (!enabled || base_ == nullptr || layer < 0 || expert < 0 || layer >= n_layers_ || expert >= n_expert_) + return 0; + static const uint64_t page = [] { + SYSTEM_INFO info{}; + GetSystemInfo(&info); + return (uint64_t) info.dwPageSize; + }(); + // These read-only file views are not CUDA-registered. blob() may instead return pinned RAM or an exchange + // buffer, so resolve the file spans directly. A shared boundary page stays for the neighboring expert. + auto trim = [&](const uint8_t* p, uint64_t bytes) -> uint64_t { + const uint64_t misalignment = (uintptr_t) p % page; + const uint64_t skip = misalignment == 0 ? 0 : page - misalignment; + if (bytes <= skip) return 0; + const uint64_t whole = (bytes - skip) / page * page; + if (whole == 0) return 0; + SetLastError(ERROR_SUCCESS); + if (!VirtualUnlock((LPVOID) (p + (size_t) skip), (SIZE_T) whole)) { + const DWORD error = GetLastError(); + // VirtualUnlock trims an unlocked range and reports FALSE / ERROR_NOT_LOCKED for that success. + if (error != ERROR_NOT_LOCKED) { + std::fprintf(stderr, "FileExpertSource: cannot trim mapped pages for layer %lld expert %lld " + "(%llu bytes, Windows error %lu)\n", + (long long) layer, (long long) expert, (unsigned long long) whole, + (unsigned long) error); + std::fflush(stderr); + return 0; + } + } + return whole; // bytes advised, not a measurement of physical RAM reclaimed + }; + if (role_ptr_.empty()) { + const uint8_t* p = mapped_blob(layer, expert); + return p == nullptr ? 0 : trim(p, layer_blob_bytes_[(size_t) layer]); + } + uint64_t bytes = 0; + for (int r = 0; r < 3; ++r) { + const size_t i = (size_t) (3 * layer + r); + bytes += trim(role_ptr_[i] + (size_t) ((uint64_t) expert * role_bytes_[i]), role_bytes_[i]); + } + return bytes; +#else + (void) layer; (void) expert; + return 0; +#endif +} + bool FileExpertSource::pin_cache_complement( const ExpertCache& cache, std::string& err, bool pin, const std::vector>& additional_gpu_pairs, int64_t lend_from_slot, diff --git a/src/program/generate.cpp b/src/program/generate.cpp index d2faa6e0..dd05c5d4 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -7744,6 +7744,11 @@ int main(int argc, char** argv) { auto refill_wait = [&](PfPart& p, std::string& e) -> bool { const strata::core::OnDevice on(p.dev); if (!p.cache->sync_queued(e)) return false; +#if defined(_WIN32) + // The copies have landed: the file pages touched by the loan need not stay in the working set. + for (const auto& [i, slot] : p.lent) + srcp->release(i / g.n_expert, i % g.n_expert); +#endif p.lent.clear(); p.lent_chunk = 0; return true; @@ -9172,6 +9177,10 @@ int main(int argc, char** argv) { std::fprintf(stderr, "strata generate: refilling the lent slots failed: %s\n", err.c_str()); return 1; } +#if defined(_WIN32) + for (const auto& [i, slot] : lent) + srcp->release(i / g.n_expert, i % g.n_expert); +#endif res_put(d_res); std::fprintf(stderr, "strata generate: %zu lent slots refilled in %.1f ms\n", lent.size(), std::chrono::duration(Clock::now() - tr).count()); diff --git a/tests/core/expert_layout_test.cpp b/tests/core/expert_layout_test.cpp index 35d1accf..88d01785 100644 --- a/tests/core/expert_layout_test.cpp +++ b/tests/core/expert_layout_test.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -223,6 +224,16 @@ void arena() { const uint8_t* b = fs.blob(l, e); const size_t n = (size_t) L.blob_bytes(l); same = same && b != nullptr && std::memcmp(b, dst.data() + L.blob_offset(l, e), n) == 0; + copies = copies && fs.copy_blob(l, e, buf.data()) && + std::memcmp(buf.data(), dst.data() + L.blob_offset(l, e), n) == 0; + const uint64_t released = fs.release(l, e); +#if defined(_WIN32) + const char* setting = std::getenv("STRATA_ARENA_RELEASE"); + const bool enabled = setting != nullptr && std::strcmp(setting, "1") == 0; + check(enabled ? released > 0 : released == 0, "GGUF mapped release honors its opt-in switch"); +#else + check(released == 0, "GGUF mapped release remains unchanged outside Windows"); +#endif copies = copies && fs.copy_blob(l, e, buf.data()) && std::memcmp(buf.data(), dst.data() + L.blob_offset(l, e), n) == 0; transient = transient && fs.transient(l, e); diff --git a/tests/core/file_expert_source_test.cpp b/tests/core/file_expert_source_test.cpp index 9a6a1d0d..9e272187 100644 --- a/tests/core/file_expert_source_test.cpp +++ b/tests/core/file_expert_source_test.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -26,6 +28,16 @@ #include #include +#if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX +#endif +#define PSAPI_VERSION 2 +#include +#include +#endif + namespace fs = std::filesystem; namespace { @@ -84,6 +96,45 @@ void check_file_size_rejection(strata::core::FileExpertSource& source, const fs: require(!source.mapped() && !err.empty(), "oversized-file rejection left the source mapped or unreported"); } +#if defined(_WIN32) +void check_mapped_release(strata::core::FileExpertSource& source, int64_t layer, int64_t expert, uint64_t bytes) { + const uint8_t* p = source.blob(layer, expert); + require(p != nullptr, "release fixture has no mapped blob"); + const std::vector saved(p, p + (size_t) bytes); + SYSTEM_INFO info{}; + GetSystemInfo(&info); + const uintptr_t page = info.dwPageSize; + const uintptr_t first = ((uintptr_t) p + page - 1) / page * page; + const uintptr_t end = ((uintptr_t) p + bytes) / page * page; + require(end > first, "release fixture has no full interior page"); + auto resident = [&](uintptr_t address) { + PSAPI_WORKING_SET_EX_INFORMATION state{}; + state.VirtualAddress = (void*) address; + require(QueryWorkingSetEx(GetCurrentProcess(), &state, sizeof state) != 0, + "QueryWorkingSetEx failed for the release fixture"); + return state.VirtualAttributes.Valid != 0; + }; + const char* setting = std::getenv("STRATA_ARENA_RELEASE"); + const bool enabled = setting != nullptr && std::strcmp(setting, "1") == 0; + for (int round = 0; round < 3; ++round) { + require(std::memcmp(p, saved.data(), saved.size()) == 0, "release changed the mapped expert bytes"); + require(resident(first), "reading the expert did not bring its interior page into the working set"); + const uint64_t released = source.release(layer, expert); + require(released == (enabled ? end - first : 0), "release did not honor full pages or its opt-in switch"); + require(resident(first) != enabled, "release did not honor the working-set contract"); + if ((uintptr_t) p < first) + require(resident((uintptr_t) p), "release trimmed the expert's shared first page"); + if (end < (uintptr_t) p + bytes) + require(resident(end), "release trimmed the expert's shared last page"); + } + require(std::memcmp(p, saved.data(), saved.size()) == 0, "the expert changed after repeated release/read cycles"); + require(source.release(-1, expert) == 0 && source.release(layer, -1) == 0 && + source.release(std::numeric_limits::max(), expert) == 0 && + source.release(layer, std::numeric_limits::max()) == 0, + "release accepted an invalid layer or expert"); +} +#endif + void test_canonical_layout() { using namespace strata::core; using namespace strata::kernels::cpu; @@ -115,6 +166,10 @@ void test_canonical_layout() { source.blob(layers, 0) == nullptr && source.blob(0, experts) == nullptr, "canonical bounds check accepted an invalid layer or expert"); require(source.reads() == 3, "invalid canonical lookups changed the read count"); +#if defined(_WIN32) + check_mapped_release(source, 0, 0, BLOB); + check_mapped_release(source, 0, 1, BLOB); +#endif check_file_size_rejection(source, dir.path, layers, experts, total); create_pack(dir.path, total, {{layer_bytes, 'c'}}); @@ -124,6 +179,7 @@ void test_canonical_layout() { const uint8_t* reopened = source.blob(1, 0); require(reopened && source.reads() == 1 && reopened[0] == 'c', "reopened canonical source kept stale state"); source.close(); + require(source.release(0, 0) == 0, "a closed file source released pages"); } #if defined(STRATA_NATIVE_EXPERTS) @@ -178,6 +234,10 @@ void test_native_variable_layout() { source.blob(layers, 0) == nullptr && source.blob(0, experts) == nullptr, "native bounds check accepted an invalid layer or expert"); require(source.reads() == 4, "invalid native lookups changed the read count"); +#if defined(_WIN32) + check_mapped_release(source, 0, 1, first_fmt.bytes); + check_mapped_release(source, 1, 1, second_fmt.bytes); +#endif check_file_size_rejection(source, dir.path, layers, experts, total); create_pack(dir.path, total, {{layer0_bytes, 'c'}});