diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 9737282abe1..db356c5f6fb 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -3,9 +3,9 @@ name: TensorFold Web on: push: branches: [main] - paths: ["web/**", ".github/workflows/web.yml"] + paths: ["web/**", ".github/workflows/web.yml", "build.zig.zon"] pull_request: - paths: ["web/**", ".github/workflows/web.yml"] + paths: ["web/**", ".github/workflows/web.yml", "build.zig.zon"] permissions: contents: read @@ -60,9 +60,12 @@ jobs: - run: npm ci - run: npm test - run: npm run build - # the built page ships in the package, so it must match the sources - - name: Built page is committed + # The page and stand-in version ship in the package, so both must match the sources. + - name: Generated Web files are committed run: | - git diff --exit-code -- ../tensorfold_web/ui_dist || { echo "tensorfold_web/ui_dist is stale; run npm run build in ui/ and commit"; exit 1; } + git diff --exit-code -- ../tensorfold_web/ui_dist ../tensorfold_web/data/native-version.json || { + echo "Generated Web files are stale; run npm run build in web/ui and commit" + exit 1 + } - name: No untracked built files run: test -z "$(git status --porcelain -- ../tensorfold_web/ui_dist)" diff --git a/CHANGELOG.md b/CHANGELOG.md index c060c25601d..b3a7866e6a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,136 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel ## Unreleased +- Nemotron on HIP: a checkpoint whose token table (`backbone.embeddings`) is stored bf16 beside quantized matrices, marked `false` in config.json's quantization block or stored without scales, is admitted and loads; its rows are gathered as stored, the memory plan counts them at their stored bytes, and the startup label adds `+bf16-embed`; a bf16 `lm_head`, projection or other unquantized tensor is still refused by name (#3575, refs #3061). Thanks to @gilby. + +- GLM-5.3-Flash on Metal: prompt index scores read each row's queries once per tile and routed-expert gathers load the next step's codes ahead, so follow-up turns reach the first token sooner with unchanged outputs (#3458). + + + +- Web: an explicit relative `--token-file` path for the service installer is anchored to the directory it is run from, so the file the installer prepares and the file the generated launcher opens are the same; the default path and symlink handling are unchanged (#3838, fixes #3835). Thanks to @AIFlowML. + +- Tests: `test-pull-host` no longer hangs on macOS, where the test allocator's stack capture on frees from the client's I/O threads deadlocked in Zig's Mach-O unwinder (#3740). + +- Tests: a new host step, `test-hip-followers-host`, runs the HIP followers' step-parser tests (the `hip_serve` protocol tests and the Flash Next, Qwen and Nemotron HIP worker security tests) in CI, where no build step ran them (#3091). + +- Kernel contract: the nvcc 13.2/13.3 usage table moves to its own registry_cuda_sets.zig, so registry.zig has room under the 600-line limit; the registered set is unchanged (#3865). + +- Tools: `tools/draft_divergence.py` checks drafted decoding returns exactly the plain token IDs on prompts around recorded BF16 near-ties, at draft caps 1, 4 and 8 (#3841). + +- Tests: a two-session KV isolation test pins that kept states across spill, offload and page reuse match by tokens only, never position (#3840). + +- CI: the last four host checks excluded under #2031 return to the aggregate; recording fixtures initialize runner state and affine kernel handles. + +- Server: `GET /v1/models/{id}` (and `/models/{id}`) returns the entry `/v1/models` lists for the served name or an alias, the id sent as written or percent-escaped (`org%2Fname`); any other id is a 404 `model_not_found`, and API keys and key scopes treat the route as they treat `/v1/models` (#3535). + +- CUDA and HIP: Qwen 3.5 settings go through the environment rules, so malformed text is refused at startup with the setting's name and accepted forms; names, defaults and clamps are unchanged (#3520). + +- Qwen3.8-27B on Metal: tensor-unit qk projections, flat glue kernels and Metal 4 verify passes each have their own off switch (`TF_Q27_QK=0`, `TF_Q27_FLAT_GLUE=0`, `TF_Q27_METAL4=0`) and are bit-identical to the kernels they replace; qk and Metal 4 stay off on chips without tensor units (#2342). + +- Tools: the served gates (`tools/conformance.py`, the Qwen and LFM3 serve checks and the Qwen3.8-27B HTTP gate) prove they ran what they claim: drafts landed, the sampler and the prompt cache were used, and concurrent requests overlapped (#3708, follows #2460). Thanks to @jschmied. + +- GLM on CUDA: a decode window's EXL3 routed experts launch on the 16-pair item plan instead of the group kernel's grid of mostly idle blocks, with the same output bytes (#2044). Thanks to @BadAd84. + +- Docs: the optimization ledger adds rows 30 to 32 (small-kernel fusion, stream-tile prefetch and the filled-item prompt grid), each `failed` for Flash Next on HIP with the measurements from #1603 (#3160, refs #1603). Thanks to @gilby. + +- Docs: the Qwen3.8-27B recipe says to serve with `--thinking-budget 4096` when thinking is on, and gives its GPQA Diamond result on TensorFold 1.2.7 and one GB10: replies cut at the limit from 78 of 198 to 0, and correct from 58.1% to 82.8% (#3373, fixes #3323). + + + +- Idol on CUDA: `tf-idol` runs Idol's denoiser on GB10 (sm_121) and on RTX 50-series and RTX PRO Blackwell (sm_120) cards against a reference case, gated step by step against idol-sdk's float32 run as on Metal, and refuses other GPUs by name (#1767, for #1757). Thanks to @jayleaton, with device runs from @GustavBlack and @Nipale-ai. + +- Docs: the drafter training recipe gains a section on adapting an already released drafter, budgeted from a few passes over the scarcest class at a low learning rate with early checkpoints, with the Qwen3.8-27B pilot behind it (#3369, refs #2667). Thanks to @Maxrio9. + +- Desktop: searching the current conversation no longer carries a project picked under All saved conversations; the request, its results, filters and navigation use the scope's own project filter, and switching back restores the project (#3900, fixes #3849). Thanks to @AIFlowML. + +- Docs: GLM-5.3-Flash Jammed XSFP4 NZ5 is listed as in 1.2.10 in the supported models table and the GLM CUDA recipe, where both said "on main after 1.2.7" (#3869, refs #2894). Thanks to @Bizuayeu. + +- CUDA: NVFP4 expert decode streams its weights through a per-warp `cp.async` ring with the same output bits; on an RTX PRO 6000 (sm_120) with drafts off the author measured GLM-5.3 decode at 104.1 tok/s against 83.8, and on GB10 (sm_121) it is level (#2266). Thanks to @eleqtrizit. + +- Docs: the GLM-5.3-Flash CUDA recipe covers switchless RoCE links on separate IPv4 subnets: NCCL 2.30.7 or later with `NCCL_IB_SUBNET_AWARE_ROUTING=1` and `NCCL_IB_SUBNET_PREFIX_LEN`, and how to check the NCCL version and NIC each rank picked at startup (#2993). Thanks to @vdalesandro. + +- Families: Nemotron, GLM, Qwen 3.8 27B, MiniMax M3, Dory, tensor-parallel fabric, pictures and video settings read through platform/environment.zig (#3558). + +- Qwen3.5 on Metal: the text-only server no longer keeps the vision tower stored between the language-model tensors in GPU memory, so the 2B holds 1.7 GiB instead of 2.3 GiB measured with `footprint` after load, with replies unchanged (#3407). Thanks to @jschmied. + +- Server: `TENSORFOLD_REQUEST_JOURNAL=PATH` records each chat or completion request in three JSON lines (start, prepared, finish), so a request unfinished at a crash is flagged on the next start, one in flight at two crashes is refused with 400 `request_quarantined`, and `tools/replay_request.py` replays a journaled request and compares the reply's `tensorfold.token_sha256`; off unless set (#3221). + +- CLI: `tensorfold config validate FILE` (source builds only, not `tensorfold-native`) reads a cluster.json with the same parser and 16 MiB limit the server uses, prints the node and model counts on success or every problem the parser collected, and exits 0, 1 or 2 without planning models or probing hosts; `cluster check` is unchanged (#3189). Thanks to @mvanhorn. + +- Drama voices: `--manage-voices` (off by default) lets admin keys add a voice with `POST /v1/voices` (a WAV with its transcript, or an attested voice file, checked and encoded by the loaded model's own codec) and delete one with `DELETE /v1/voices/NAME`, and `--request-voices` lets a request carry an inline voice object; a running request keeps the voice it copied when it arrived (#3140). + +- Idol on Metal: Idol's released denoiser runs as a native Metal family, `idol`, with fp16 block projections and attention inputs summed in fp32 and fp32 norms, softmax and RePo as the SDK splits them; `tf-idol` checks it step by step against idol-sdk's float32 run, and its 27 kernels are in the kernel contract with 19 planted controls. The image encoders and decoders are separate changes (#1766, for #1757). Thanks to @jayleaton. + +- Code: a GPTQ reader in `core/quant` reads AutoGPTQ v1 4-bit symmetric group-128 weights as stored (`qweight`, fp16 `scales`, a `qzeros` zero point of 8) into an fp64 reference, and refuses every other GPTQ field, rule or tensor by name; host only, with no caller yet (#3611, refs #3368). + +- Desktop: an attachment in a saved draft keeps only its original diagnostic, and the reselection guidance is added once when the draft is rendered, so reopening and editing unrelated text no longer stores the composed message as the error; older drafts with repeated guidance show one copy and keep any surviving diagnostic (#3842, fixes #3837). Thanks to @AIFlowML. + +- Desktop: turning off `autoCheckUpdates` now cancels the first scheduled update check as well as the recurring interval, and scheduled callbacks recheck the saved setting before calling the feed; a manual check from Settings still works with automatic checks off (#3836, fixes #3833). Thanks to @AIFlowML. + +- Desktop: changing the run, mode or redaction in the export panel clears the old preview at once and leaves `Copy JSON` and `Save…` disabled until the new selection builds successfully; a late result cannot replace another selection's preview or its feedback (#3834, fixes #3829). Thanks to @AIFlowML. + +- Web: the engine address may be an OpenAI base URL ending in `/v1` as well as a server root; health, the relay and Connect derive the server root with `engine_root` and append the API suffix once, and settings keeps the supplied address so a reverse-proxy prefix ending in `/v1` survives a reload (#3831, fixes #3830). Thanks to @AIFlowML. + +- Desktop: the library scan uses four convolution taps for Qwen3.5-2B, so the supported checkpoint is offered instead of being refused at scan time; a checkpoint with the old value still gets a geometry refusal (#3768). Thanks to @AIFlowML. + +- Desktop: a ticket can finalize only after a current independent review of its actual builder work; reviewer blockers stay with their batch and ordinary later notes no longer revoke approval (#3484). Thanks to @AIFlowML. + +- Metal: Ling-3.0-tiny's MLA layers run on Kimi's `k3_mla` kernels with three added kernels for cache and query RoPE and gate widening, registered with planted controls in the kernel contract (#3609). Thanks to @ThinkOffApp. + +- Nemotron: the Living Weights copies left behind by the October revert are deleted and `cuda_pages` imports `living.lesson_route`, leaving one copy of the learner, pocket and lesson files (#3707). Thanks to @jschmied. + +- Flash Next on CUDA: after load, a mixed shard keeps only the n-gram table's pages in the page cache, and the final sweep reaches shards nested under `tensors/`, freeing about 3 GiB of page cache on the NVFP4 export with replies unchanged (#3467). Thanks to @jschmied. + +- CUDA: GLM's `TF_GLM_L2PF` site f now also prefetches a MoE layer's shared expert gate-up after its router within the same `TF_GLM_L2PF_MB` budget, giving about 1.0-1.2% faster decode at TP=2 on GB10 (mean of three alternating launches) with identical tokens (#3156). Thanks to @Bizuayeu. + +- Desktop: the Terminal picker launches a registered Orchestrator CLI by its ID without forwarding the catalog command as a custom override, lists CLIs for the current project and host, and stops a click left stale by retargeting, project removal or a disabled host before dispatch; local custom commands and the remote refusal still apply (#3828, fixes #3824). Thanks to @AIFlowML. + +- Web: the OpenAI connection probe now uses the shared stream reader, so partial text followed by an error or early EOF fails the check instead of passing; the reader handles LF, CRLF and bare CR, including a CRLF split across chunks, and complete streams still pass the text-or-reasoning check (#3826, fixes #3823). Thanks to @AIFlowML. + +- Web: `POST /api/conversations` now keeps a validated `pinned` and `folder` supplied at creation, so the response, later reads and folder counts agree; requests that omit those fields keep the old response shape (#3825, fixes #3822). Thanks to @AIFlowML. + +- Web: cleaning up Bench runs now drops a finished comparison only once none of its runs remain, so two passes can remove one a single pass kept; age-filtered cleanup considers only comparisons touched by that pass, and a full cleanup also clears a comparison left with no runs (#3820, fixes #3818). Thanks to @AIFlowML. + +- Web: stopping Chat Replay during its final reply now marks the replay cancelled and keeps only the turns already completed, leaving the interrupted reply out of the done count and saved results; other engine errors still use the per-turn error path (#3815). Thanks to @AIFlowML. + +- Web: on reattachment to a running engine, the last unfinished log line stays buffered until the engine completes it, so a split context-window line is recorded once and supplies startup telemetry; truncating the log clears that fragment (#3813). Thanks to @AIFlowML. + +- Web: settings files whose JSON root is an array or a scalar now fall back to defaults at startup instead of raising, and the original file is left untouched; a valid settings object still loads its known fields (#3808). Thanks to @AIFlowML. + +- Tests: the Desktop helper timing test drives the exact echo, typing and keypress deadlines with a fake clock instead of real process startup, while still checking that the timed-out helper exits and a fresh one starts (#3802). Thanks to @AIFlowML. + +- Docs: the native release guide's CUDA command builds all four required targets with the build's catalog, and both archive commands supply the pinned XGrammar checkout with `-Dxgrammar=DIR` so `libtfgrammar` is packaged (#3764, fixes #3763). Thanks to @AIFlowML. + +- `tensorfold web`: when `uv` is missing, the fallback points to uv's installation guide and asks for `uv` on PATH instead of suggesting `pip install --user`; the printed install command, consent and exit status are unchanged (#3746, fixes #3743). Thanks to @AIFlowML. + +- Desktop: a manual Refresh results click in Benchmarks now takes priority over an in-flight status poll, so duplicate reads stay coalesced and a late response from the old poll cannot replace the refreshed result (#3817). Thanks to @AIFlowML. + +- Desktop: new local project Chats and Tasks keep an explicit Provider key or Default login selection through thread creation and renderer configuration instead of falling back to a named account; projects that omit the account field keep their old fallback (#3810). Thanks to @AIFlowML. + +- Tests: the Desktop power test runs the real power module with a fake process handle and a mock clock, checking owned shutdown, the restart backoff boundary and saved errors without looking up or stopping unrelated host processes (#3804). Thanks to @AIFlowML. + +- Desktop: deleting an unloaded checkpoint refreshes the engine snapshot so the open Models view drops its old Downloads row; the browser demo removes that row from its backing snapshot too (#3798, fixes #3796). Thanks to @AIFlowML. + +- Desktop: Cancel is honored at the final download byte update, before verification; a cancelled download is not registered as a model and its bytes stay cached for a later retry (#3795, fixes #3794). Thanks to @AIFlowML. + +- Desktop: downloader diagnostics are assembled per stream with split UTF-8 intact and an unterminated final line flushed before the exit is handled; a bounded tail keeps long diagnostics usable (#3793, fixes #3792). Thanks to @AIFlowML. + +- Desktop: the Hub check and local model library recognize Spark's declared BF16 dtype when a config has no quantization or compression field, while still comparing the detected format with the active engine's capabilities (#3791, fixes #3789). Thanks to @AIFlowML. + +- Tests: the loopback conformance fixture sets its listen backlog explicitly so a concurrent burst does not lose connections while handler threads start; the same token-equality checks still run (#3784, fixes #3782). Thanks to @AIFlowML. + +- GLM-5.3-Flash on CUDA: the recipe gives `nvidia/GLM-5.3-Flash-FP4-Local` its pinned pull and launch, with a new TP=2 receipt on two GB10s in which drafted replies equal plain ones, concurrent equal alone and resumed equal cold (#3425). Thanks to @laudney. + +- Tests: the macOS nightly builds again: the row dispatch tests handle both pipeline representations, and the OS readings test accepts a small runner's RAM with its footprint check unchanged (#3854). + +- Desktop: a Room's health counter shows completed tickets out of the Room's total, and the bot VM guest's cleanup after a bounded command treats macOS's EPERM as already stopped instead of failing the command (#3698). Thanks to @devopsfortunato. + +- Tests: the benchmark TTFT test pins its send clock and requires a nonempty result set before its exact assertion, so rounding no longer decides the result; it still separates first content from headers and role or usage frames (#3783, fixes #3779). Thanks to @AIFlowML. + +- Web: the packaged stand-in reports the current native version after a native release bump, and Web CI now runs when `build.zig.zon` changes with a build check that the committed packaged version is fresh (#3745, fixes #3739). Thanks to @AIFlowML. + +## 1.2.10 + - Server: `background: true` on `POST /v1/responses` answers at once with a queued response and generates the reply after the POST returns; `GET /v1/responses/{id}` polls it and `POST /v1/responses/{id}/cancel` or `DELETE` stops it, at most 64 are queued or running per server (16 per key, 256 MiB of copied requests) before a create answers 429, and `stream: true` with `background` is refused (#3220). - Qwen 3.5 on CUDA: a dropped kept prompt state's pinned host buffer goes to a spare list of at most two, and the next save or recall blank of the same size reuses it instead of pinning new memory; spares count inside the prompt-cache budget and are freed before any state is evicted (#2841). diff --git a/README.md b/README.md index 349754660f7..870a9a3dc98 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Needs glibc 2.28 or newer and NVIDIA driver R580 or newer (CUDA 13.0). The [run lists the archive's requirements; Windows has [its own guide](docs/WINDOWS.md). ```sh -V=1.2.9 +V=1.2.10 case "$(uname -m)" in aarch64|arm64) PLATFORM=linux-aarch64 ;; x86_64) PLATFORM=linux-x86_64 ;; diff --git a/RUNBOOK.md b/RUNBOOK.md index 4e2f6662cf5..945a87b4082 100644 --- a/RUNBOOK.md +++ b/RUNBOOK.md @@ -19,7 +19,7 @@ For an archive installation, download the arm64 asset and its companion checksum [latest release](https://github.com/ashhart/TensorFold/releases/latest), with `V` set to its version: ```sh -V=1.2.9 +V=1.2.10 curl -fLO https://github.com/ashhart/TensorFold/releases/download/v$V/tensorfold-$V-macos-arm64.tar.gz curl -fLO https://github.com/ashhart/TensorFold/releases/download/v$V/tensorfold-$V-macos-arm64.tar.gz.sha256 shasum -a 256 -c tensorfold-$V-macos-arm64.tar.gz.sha256 @@ -210,7 +210,7 @@ Qwen4 has synthetic gates only. On a GB10 arm64 host (an x86_64 host uses `linux-x86_64` in the same commands): ```sh -V=1.2.9 +V=1.2.10 curl -fLO https://github.com/ashhart/TensorFold/releases/download/v$V/tensorfold-$V-linux-aarch64.tar.gz curl -fLO https://github.com/ashhart/TensorFold/releases/download/v$V/tensorfold-$V-linux-aarch64.tar.gz.sha256 sha256sum -c tensorfold-$V-linux-aarch64.tar.gz.sha256 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index ea8232eed7d..1710de6711f 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -335,6 +335,7 @@ These follow a model's release code or a library's model code for their math, ro - `zig/src/vision/qwen_cuda.zig`: `Qwen3_5VisionModel` in transformers. - `zig/src/core/picture/patches_test.zig`: recorded image-processor output data from `Lfm3VlImageProcessor` and `Qwen2VLImageProcessor` in transformers; the processing implementation is described below. - `zig/src/families/flashnext/rotary_config.zig`: `_compute_yarn_parameters` in transformers, for the 64 rotary dims. +- `zig/kernels/metal/idol.metal`, `zig/kernels/cuda/idol.cu` and `zig/kernels/cuda/idol_attention.cuh`: the rounding points of Idol's denoiser in [speridlabs/idol-sdk](https://github.com/speridlabs/idol-sdk) at `4702a7f0`. Copyright speridlabs, Apache License 2.0; see [the license text](LICENSES/Apache-2.0.txt). transformers is Copyright The HuggingFace Team, Apache License 2.0; see [the license text](LICENSES/Apache-2.0.txt). diff --git a/app/electron/agent/bot-vm/guest.trace-diagnostic.test.ts b/app/electron/agent/bot-vm/guest.trace-diagnostic.test.ts new file mode 100644 index 00000000000..c28117f105e --- /dev/null +++ b/app/electron/agent/bot-vm/guest.trace-diagnostic.test.ts @@ -0,0 +1,220 @@ +import assert from 'node:assert/strict' +import { spawnSync } from 'node:child_process' +import { mkdirSync, mkdtempSync, rmSync } from 'node:fs' +import os from 'node:os' +import path from 'node:path' +import { BOT_VM_GUEST } from './guest' + +// Trace-only mirror of the guest program: same logic and limits as BOT_VM_GUEST, with P*/F*/X* markers on stderr localizing which syscall raises inside command(); assertions match guest.test.ts. +const DIAG = String.raw`import os, sys, json, stat, subprocess, signal, selectors, time, uuid, fnmatch, itertools +MAX=65536 +def E(*a): print(*a, file=sys.stderr, flush=True) +def pathparts(value): + if not isinstance(value,str) or len(value)>2048 or '\x00' in value: raise ValueError('Invalid workspace path.') + if value=='/workspace': value='' + elif value.startswith('/workspace/'): value=value[11:] + elif value.startswith('/'): raise ValueError('Files must stay inside /workspace.') + parts=value.split('/') + if any(p=='..' for p in parts): raise ValueError('Parent paths are not allowed.') + return [p for p in parts if p not in ('','.')] +def directory(parts,create=False): + fd=os.open('/workspace',os.O_RDONLY|os.O_DIRECTORY|os.O_NOFOLLOW) + try: + for p in parts: + if create: + try: os.mkdir(p,0o700,dir_fd=fd) + except FileExistsError: pass + nextfd=os.open(p,os.O_RDONLY|os.O_DIRECTORY|os.O_NOFOLLOW,dir_fd=fd) + os.close(fd); fd=nextfd + return fd + except: os.close(fd); raise +def readfile(parts,limit=1048576): + if not parts: raise ValueError('Choose a file.') + parent=directory(parts[:-1]); fd=None + try: + fd=os.open(parts[-1],os.O_RDONLY|os.O_NOFOLLOW|os.O_NONBLOCK,dir_fd=parent) + s=os.fstat(fd) + if not stat.S_ISREG(s.st_mode) or s.st_nlink!=1: raise ValueError('Only regular files without links can be read.') + if s.st_size>limit: raise ValueError('File exceeds the one MiB text limit.') + with os.fdopen(fd,'rb') as f: fd=None; raw=f.read(limit+1) + if len(raw)>limit: raise ValueError('File exceeds the text limit.') + return raw.decode('utf-8') + finally: + if fd is not None: os.close(fd) + os.close(parent) +def writefile(parts,content): + if not parts or not isinstance(content,str) or len(content.encode('utf-8'))>1048576: raise ValueError('Write requires a file and at most one MiB of UTF-8 text.') + parent=directory(parts[:-1],True); temp='.tensorfold-'+uuid.uuid4().hex + try: + try: + s=os.stat(parts[-1],dir_fd=parent,follow_symlinks=False) + if not stat.S_ISREG(s.st_mode) or s.st_nlink!=1: raise ValueError('Refusing to replace a link or non-regular file.') + except FileNotFoundError: pass + fd=os.open(temp,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,0o600,dir_fd=parent) + with os.fdopen(fd,'w',encoding='utf-8') as f: f.write(content); f.flush(); os.fsync(f.fileno()) + os.replace(temp,parts[-1],src_dir_fd=parent,dst_dir_fd=parent) + finally: + try: os.unlink(temp,dir_fd=parent) + except FileNotFoundError: pass + os.close(parent) +def walk(parts): + pending=[parts]; seen=0 + while pending and seen<2000: + parentparts=pending.pop(); fd=directory(parentparts) + try: + with os.scandir(fd) as entries: names=sorted(entry.name for entry in itertools.islice(entries,1001)) + for name in names[:1000]: + seen+=1 + if seen>2000: return + info=os.stat(name,dir_fd=fd,follow_symlinks=False); rel=parentparts+[name] + if stat.S_ISDIR(info.st_mode) and name not in ('node_modules','.git','__pycache__','.venv'): pending.append(rel) + elif stat.S_ISREG(info.st_mode) and info.st_nlink==1: yield rel + finally: os.close(fd) +def command(args): + cmd=args.get('command'); timeout=args.get('timeoutMs',30000) + if not isinstance(cmd,str) or not cmd.strip() or len(cmd)>16384 or '\x00' in cmd: raise ValueError('Command must contain at most 16,384 characters.') + if not isinstance(timeout,(int,float)): raise ValueError('Invalid command timeout.') + timeout=max(1000,min(120000,int(timeout)))/1000 + E('P1 pre-Popen: cmd=%r timeout=%r' % (cmd,timeout)) + p=subprocess.Popen(['/bin/sh','-c',cmd],cwd='/workspace',stdin=subprocess.DEVNULL,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,start_new_session=True,env={'PATH':'/usr/local/bin:/usr/bin:/bin','HOME':'/workspace','LANG':'C.UTF-8','TMPDIR':'/tmp'}) + E('P2 Popen ok: pid=%r pgid=%r' % (p.pid, os.getpgid(p.pid))) + sel=selectors.DefaultSelector(); E('P3 selector created: %s' % type(sel).__name__) + sel.register(p.stdout,selectors.EVENT_READ); E('P4 registered fd=%r' % p.stdout.fileno()) + data=bytearray(); end=time.monotonic()+timeout; timedout=False + try: + while sel.get_map(): + remaining=end-time.monotonic() + if remaining<=0: timedout=True; E('P5b time limit hit bytes=%d' % (len(data),)); break + for key,_ in sel.select(min(.1,remaining)): + chunk=os.read(key.fileobj.fileno(),8192) + if not chunk: sel.unregister(key.fileobj); E('P5c EOF -> unregistered fd=%r' % key.fileobj.fileno()) + elif len(data)=MAX: E('P5a MAX reached bytes=%d -> break' % (len(data),)); break + E('P6 loop done: bytes=%d timedout=%r bounded=%r' % (len(data),timedout,len(data)>=MAX)) + bounded=len(data)>=MAX + if timedout or bounded: + E('P7 primary killpg(%r,SIGKILL)' % p.pid) + try: os.killpg(p.pid,signal.SIGKILL); E('P7a primary killpg returned') + except (ProcessLookupError, PermissionError) as e: E('P7a primary killpg %s: %r' % (type(e).__name__, e)) + E('P8 primary p.wait(timeout=2)') + try: code=p.wait(timeout=2); E('P8a reaped code=%r' % (code,)) + except subprocess.TimeoutExpired: + E('P8b wait expired -> secondary killpg + wait') + os.killpg(p.pid,signal.SIGKILL); code=p.wait(timeout=2); E('P8c reaped after secondary code=%r' % (code,)) + output=data.decode('utf-8',errors='replace') + if timedout: output+='\n[Command stopped at its time limit.]' + if bounded: output+='\n[Command stopped at its output limit.]' + result={'ok':code==0 and not timedout and not bounded,'code':code,'output':output,'truncated':bounded,'interrupted':timedout or bounded} + E('P9 returning normal/bounded result: ok=%r code=%r truncated=%r outlen=%d' % (result['ok'],result['code'],result['truncated'],len(output))) + return result + finally: + E('F1 finally start (poll=%r)' % (p.poll(),)) + sel.close(); E('F2 sel.close() ok') + p.stdout.close(); E('F3 p.stdout.close() ok') + E('F4 FINAL killpg(%r,SIGKILL) -- after reap' % p.pid) + try: + os.killpg(p.pid,signal.SIGKILL); E('F4a final killpg returned (no exception)') + except ProcessLookupError as e: E('F4a final killpg ProcessLookupError: %r' % (e,)) + except PermissionError as e: E('F4a final killpg PermissionError errno=%r' % (getattr(e,'errno',None),)) + E('F5 pre-poll: poll=%r' % (p.poll(),)) + if p.poll() is None: E('F5a still unreaped -> p.wait()'); p.wait(); E('F5b waited') + E('F6 finally end') +def main(req): + tool=req.get('tool'); args=req.get('args') + if not isinstance(args,dict): raise ValueError('Invalid tool input.') + if tool=='run_command': return command(args) + parts=pathparts(args.get('path','')) + if tool=='read_file': + text=readfile(parts); lines=text.split('\n'); offset=max(1,min(1000000,int(args.get('offset',1)))); limit=max(1,min(2000,int(args.get('limit',2000)))) + out='\n'.join(str(i+offset).rjust(5)+'\t'+line for i,line in enumerate(lines[offset-1:offset-1+limit])); truncated=len(out)>MAX + return {'ok':True,'output':out[:MAX]+ ('\n[Output limited; use a later offset.]' if truncated else ''),'truncated':truncated} + if tool in ('write_file','edit_file'): + if tool=='write_file': content=args.get('content') + else: + content=readfile(parts); old=args.get('old_string'); new=args.get('new_string') + if not isinstance(old,str) or not old or not isinstance(new,str) or content.count(old)!=1: raise ValueError('The old string must occur exactly once.') + content=content.replace(old,new,1) + writefile(parts,content); return {'ok':True,'output':'Saved '+ '/'.join(parts),'changedPaths':['/'.join(parts)]} + if tool=='list_dir': + fd=directory(parts) + try: + with os.scandir(fd) as entries: names=sorted(entry.name for entry in itertools.islice(entries,501)) + out=[] + for name in names[:500]: + s=os.stat(name,dir_fd=fd,follow_symlinks=False) + if not stat.S_ISLNK(s.st_mode): out.append(name+('/' if stat.S_ISDIR(s.st_mode) else '')) + return {'ok':True,'output':'\n'.join(out)[:MAX] or '(empty)','truncated':len(names)>500} + finally: os.close(fd) + if tool in ('search','glob'): + value=args.get('query' if tool=='search' else 'pattern') + if not isinstance(value,str) or not value or len(value)>500 or '\x00' in value: raise ValueError('Provide a bounded search string or glob pattern.') + if tool=='glob' and (value.startswith('/') or '..' in value.split('/')): raise ValueError('Glob must stay inside the workspace.') + out=[]; count=0 + for rel in walk(parts): + count+=1; name='/'.join(rel) + if tool=='glob': + relative='/'.join(rel[len(parts):]) + if fnmatch.fnmatchcase(relative,value) or (value.startswith('**/') and fnmatch.fnmatchcase(relative,value[3:])): out.append(name) + else: + try: text=readfile(rel,65536) + except (ValueError,UnicodeError,OSError): continue + for i,line in enumerate(text.split('\n')): + if value in line: out.append(name+':'+str(i+1)+':'+line[:1000]) + if len(out)>=100: break + if len(out)>=100 or sum(len(x)+1 for x in out)>MAX: break + return {'ok':True,'output':'\n'.join(out)[:MAX] or '(no matches)','truncated':count>=2000 or len(out)>=100} + raise ValueError('This tool is not available inside the bot VM.') +try: + E('P0 stdin read') + raw=sys.stdin.buffer.read(1100000) + if len(raw)>1090000: raise ValueError('Request exceeds the VM limit.') + result=main(json.loads(raw)); print(json.dumps(result,ensure_ascii=True)) +except Exception as e: + E('X1 outer except: %s: %r' % (type(e).__name__, str(e))) + E('X2 __context__ chain: %r' % (repr(e.__context__),)) + print(json.dumps({'ok':False,'output':'VM tool refused: '+str(e)[:500]}))` + +const root = mkdtempSync(path.join(os.tmpdir(), 'tensorfold-vm-guest-test-')) +try { + const workspace = path.join(root, 'workspace') + mkdirSync(workspace) + // Same two rewrites guest.test.ts applies to BOT_VM_GUEST, so both programs see one remapped root. + const apply = (src: string) => src.replaceAll('/workspace', workspace).replace('value=value[11:]', `value=value[${workspace.length + 1}:]`) + const realProgram = apply(BOT_VM_GUEST) + const diagProgram = apply(DIAG) + const probe = spawnSync('/usr/bin/python3', ['-I', '-c', "import sys,selectors,platform,json;print(json.dumps({'python':sys.version,'selector':type(selectors.DefaultSelector()).__name__,'platform':platform.platform()}))"], { encoding: 'utf8' }) + const envProbe = probe.status === 0 ? JSON.stringify(JSON.parse(probe.stdout)) : JSON.stringify({ probeStatus: probe.status, probeError: probe.error?.message, probeStderr: probe.stderr }) + const run = (program: string, tool: string, args: Record) => spawnSync('/usr/bin/python3', ['-I', '-c', program], { input: JSON.stringify({ tool, args }), encoding: 'utf8', timeout: 10000 }) + type RunResult = ReturnType + // Every message carries the case id, iteration, env probe and both stream tails so the CI log alone explains a failure. + const detail = (caseId: string, iteration: number, result: RunResult) => `${caseId} iter=${iteration} env=${envProbe} signal=${result.signal ?? ''} error=${result.error?.message ?? ''} stdout_tail=${result.stdout.slice(-1500)} stderr_tail=${result.stderr.slice(-4000)}` + const parsedOf = (caseId: string, iteration: number, result: RunResult) => { + assert.equal(result.status, 0, `${caseId} iter=${iteration} guest exited abnormally: ${detail(caseId, iteration, result)}`) + return JSON.parse(result.stdout) as { ok?: unknown; truncated?: unknown; interrupted?: unknown; code?: unknown } + } + for (let i = 1; i <= 8; i++) { + const result = run(realProgram, 'run_command', { command: 'yes bounded-output' }) + const parsed = parsedOf('A-real-yes', i, result) + assert.equal(parsed.ok, false, detail('A-real-yes', i, result)) + assert.equal(parsed.truncated, true, detail('A-real-yes', i, result)) + assert.equal(typeof parsed.code, 'number', detail('A-real-yes', i, result)) + } + const hello = run(diagProgram, 'run_command', { command: 'printf hello' }) + const helloParsed = parsedOf('B-diag-printf', 1, hello) + assert.equal(helloParsed.ok, true, detail('B-diag-printf', 1, hello)) + assert.equal(helloParsed.truncated, false, detail('B-diag-printf', 1, hello)) + const nap = run(diagProgram, 'run_command', { command: 'sleep 8', timeoutMs: 1000 }) + const napParsed = parsedOf('B-diag-timeout', 1, nap) + assert.equal(napParsed.ok, false, detail('B-diag-timeout', 1, nap)) + assert.equal(napParsed.interrupted, true, detail('B-diag-timeout', 1, nap)) + let lastYesStderr = '' + for (let i = 1; i <= 8; i++) { + const result = run(diagProgram, 'run_command', { command: 'yes bounded-output' }) + const parsed = parsedOf('B-diag-yes', i, result) + assert.equal(parsed.ok, false, detail('B-diag-yes', i, result)) + assert.equal(parsed.truncated, true, detail('B-diag-yes', i, result)) + lastYesStderr = result.stderr + } + console.log(`trace-diagnostic: 8 real runs, 10 instrumented runs, env ${envProbe}`) + console.log(`trace-diagnostic last-instrumented-yes stderr:\n${lastYesStderr}`) +} finally { rmSync(root, { recursive: true, force: true }) } diff --git a/app/electron/agent/bot-vm/guest.ts b/app/electron/agent/bot-vm/guest.ts index 7724b1b7e14..875ae5a5a02 100644 --- a/app/electron/agent/bot-vm/guest.ts +++ b/app/electron/agent/bot-vm/guest.ts @@ -83,7 +83,7 @@ def command(args): bounded=len(data)>=MAX if timedout or bounded: try: os.killpg(p.pid,signal.SIGKILL) - except ProcessLookupError: pass + except (ProcessLookupError, PermissionError): pass try: code=p.wait(timeout=2) except subprocess.TimeoutExpired: os.killpg(p.pid,signal.SIGKILL); code=p.wait(timeout=2) @@ -94,7 +94,7 @@ def command(args): finally: sel.close(); p.stdout.close() try: os.killpg(p.pid,signal.SIGKILL) - except ProcessLookupError: pass + except (ProcessLookupError, PermissionError): pass if p.poll() is None: p.wait() def main(req): tool=req.get('tool'); args=req.get('args') diff --git a/app/electron/agent/computer-use/helper.test.ts b/app/electron/agent/computer-use/helper.test.ts index b439c428ff4..9be1dfd9ed0 100644 --- a/app/electron/agent/computer-use/helper.test.ts +++ b/app/electron/agent/computer-use/helper.test.ts @@ -2,6 +2,7 @@ import assert from 'node:assert/strict' import { promises as fs } from 'node:fs' import os from 'node:os' import path from 'node:path' +import { mock } from 'node:test' import { COMPUTER_HELPER_TIMEOUT_MS, ComputerHelper, @@ -114,11 +115,17 @@ async function main() { // A timeout rejects that call, ends the stuck helper, and the next call starts a new one. const slowRecord = path.join(root, 'slow.jsonl') - const slowHelper = make(await wrapper(root, 'slow', { FAKE_HELPER_RECORD: slowRecord }), { timeoutMs: 500 }) + const slowHelper = make(await wrapper(root, 'slow', { FAKE_HELPER_RECORD: slowRecord })) const firstPid = (await slowHelper.request<{ pid: number }>('pid')).pid - const started = Date.now() - await assert.rejects(slowHelper.request('echo', { delayMs: 5_000 }), isCode('timeout')) - assert.ok(Date.now() - started < 2_000, 'the timeout fires on time') + mock.timers.enable({ apis: ['setTimeout'] }) + try { + const outcome = slowHelper.request('echo', { delayMs: 5_000 }, 500).then(() => undefined, (error: unknown) => error) + mock.timers.tick(499) + assert.equal(slowHelper.pid, firstPid, 'the helper stays live before the echo deadline') + mock.timers.tick(1) + assert.equal(slowHelper.running, false, 'the echo deadline retires the helper') + assert.ok(isCode('timeout')(await outcome), 'the echo rejects with a timeout') + } finally { mock.timers.reset() } await waitFor(() => !alive(firstPid)) const secondPid = (await slowHelper.request<{ pid: number }>('pid')).pid assert.notEqual(secondPid, firstPid) @@ -127,9 +134,22 @@ async function main() { // type gets a timeout that grows with the text; other calls keep the base timeout. assert.equal(typeTimeoutMs('abcd', 100), 120) assert.equal(typeTimeoutMs(''), COMPUTER_HELPER_TIMEOUT_MS) - const delayed = make(await wrapper(root, 'delayed', { FAKE_HELPER_DELAY_MS: '400' }), { timeoutMs: 250 }) - assert.equal((await delayed.type({ text: 'x'.repeat(200) })).typed, 200) - await assert.rejects(delayed.key({ keys: 'a' }), isCode('timeout')) + const delayed = make(await wrapper(root, 'delayed', { FAKE_HELPER_DELAY_MS: '5000' }), { timeoutMs: 250 }) + const deadlines = [ + { name: 'type', ms: 1250, request: () => delayed.type({ text: 'x'.repeat(200) }) }, + { name: 'key', ms: 250, request: () => delayed.key({ keys: 'a' }) }, + ] + mock.timers.enable({ apis: ['setTimeout'] }) + try { + for (const { name, ms, request } of deadlines) { + const outcome = request().then(() => undefined, (error: unknown) => error) + mock.timers.tick(ms - 1) + assert.equal(delayed.running, true, `${name} should stay live before its deadline`) + mock.timers.tick(1) + assert.equal(delayed.running, false, `${name} should time out at its deadline`) + assert.ok(isCode('timeout')(await outcome), `${name} should reject with a timeout`) + } + } finally { mock.timers.reset() } // A crash rejects everything in flight; the next call restarts the helper. const crashRecord = path.join(root, 'crash.jsonl') diff --git a/app/electron/agent/engine/cli.test.ts b/app/electron/agent/engine/cli.test.ts index bd92709797f..087fbbd1a30 100644 --- a/app/electron/agent/engine/cli.test.ts +++ b/app/electron/agent/engine/cli.test.ts @@ -37,6 +37,16 @@ async function main() { assert.equal(formatName({ quantization: { bits: 4, group_size: 64 } }), 'mlx-q4g64') assert.equal(formatName({ quantization: { bits: 6 } }), 'mlx-q6g32', 'a missing group size is 32, as hub.zig reads it') assert.equal(formatName({}), null) + const spark = { model_type: 'spark2_5' } + assert.equal(formatName({ ...spark, dtype: 'bfloat16' }), 'bf16') + assert.equal(formatName({ ...spark, torch_dtype: 'bfloat16' }), 'bf16') + assert.equal(formatName({ ...spark, dtype: 'float32', text_config: { dtype: 'bfloat16' } }), 'bf16') + assert.equal(formatName({ ...spark, dtype: 'float32' }), null) + assert.equal(formatName({ ...spark, dtype: 'bfloat16', quantization: { bits: 4, group_size: 64 } }), 'mlx-q4g64') + assert.equal(formatName({ ...spark, dtype: 'bfloat16', quantization_config: { quant_method: 'fp8' } }), null) + assert.equal(formatName({ ...spark, dtype: 'bfloat16', text_config: { quantization: { bits: 4 } } }), null) + assert.equal(formatName({ ...spark, dtype: 'bfloat16', compression_config: {} }), null) + assert.equal(formatName({ model_type: 'qwen3', dtype: 'bfloat16' }), null) assert.equal(describeFormat('mlx-q4g64'), '4-bit, group 64') assert.equal(describeFormat(null), 'full precision') diff --git a/app/electron/agent/engine/cli.ts b/app/electron/agent/engine/cli.ts index 061a6c1c135..68a64993d91 100644 --- a/app/electron/agent/engine/cli.ts +++ b/app/electron/agent/engine/cli.ts @@ -92,10 +92,28 @@ export function parseCapabilities(text: string): EngineCapabilities { } } -// MLX affine quantization as the engine's format names spell it: mlx-q4g64, mlx-q6g32. -export function formatName(config: { quantization?: { bits?: unknown; group_size?: unknown } | null } | null | undefined): string | null { +interface CheckpointFormat { + model_type?: unknown + quantization?: { bits?: unknown; group_size?: unknown } | null + quantization_config?: unknown + compression_config?: unknown + dtype?: unknown + torch_dtype?: unknown + text_config?: CheckpointFormat | null +} + +// Format names as advertised by the engine, such as mlx-q4g64 and bf16. +export function formatName(config: CheckpointFormat | null | undefined): string | null { const q = config?.quantization - if (!q || typeof q !== 'object') return null + if (q == null) { + // The capabilities list also includes BF16 engines for embeddings and OCR. + if (config?.model_type !== 'spark2_5') return null + const tower = config?.text_config + if ([config, tower].some((part) => part?.quantization != null || part?.quantization_config != null || part?.compression_config != null)) return null + const dtype = tower?.dtype ?? tower?.torch_dtype ?? config?.dtype ?? config?.torch_dtype + return dtype === 'bfloat16' ? 'bf16' : null + } + if (typeof q !== 'object') return null const bits = Number(q.bits) const group = q.group_size == null ? 32 : Number(q.group_size) if (!Number.isInteger(bits) || !Number.isInteger(group)) return null diff --git a/app/electron/agent/engine/geometry.ts b/app/electron/agent/engine/geometry.ts index 7c8a95d2de1..a03b49bfc8b 100644 --- a/app/electron/agent/engine/geometry.ts +++ b/app/electron/agent/engine/geometry.ts @@ -32,7 +32,7 @@ const QWEN35: PinnedGeometry = { linear_num_value_heads: 16, linear_key_head_dim: 128, linear_value_head_dim: 128, - linear_conv_kernel_dim: 6144, + linear_conv_kernel_dim: 4, num_attention_heads: 8, num_key_value_heads: 2, head_dim: 256, diff --git a/app/electron/agent/engine/hub.test.ts b/app/electron/agent/engine/hub.test.ts index 91892a2cbe0..020934590d4 100644 --- a/app/electron/agent/engine/hub.test.ts +++ b/app/electron/agent/engine/hub.test.ts @@ -83,6 +83,17 @@ async function main() { assert.equal(good.family, 'Qwen3.5-2B or Qwen3.8-27B') assert.equal(good.fileCount, 2) + const sparkRepo = 'Example/Spark-BF16' + const sparkRoutes = repoRoutes(sparkRepo, { modelType: 'spark2_5', quant: null }) + sparkRoutes[`/${sparkRepo}/resolve/${SHA}/config.json`] = { body: { model_type: 'spark2_5', dtype: 'bfloat16' } } + const spark = mockHub(sparkRoutes) + const metal = await preflightRepo(sparkRepo, null, context(spark.fetchImpl, { families: { spark2_5: ['bf16', 'mlx-q4g64'] } })) + assert.equal(metal.format, 'bf16') + assert.equal(metal.verdict, 'ok') + const cuda = await preflightRepo(sparkRepo, null, context(spark.fetchImpl, { families: { spark2_5: ['mlx-q4g64'] } })) + assert.equal(cuda.format, 'bf16') + assert.equal(cuda.verdict, 'format') + const declared = parseCapabilities(JSON.stringify({ schema: 1, engine: 'zig', version: '1.1.0', backends: ['metal'], families: { lfm2_moe: ['mlx-q6g64'], gemma4: ['mlx-q3g64'], gemma4_unified: ['mlx-q8g64'], step5_vl: ['mlx-q2g128'], fish_omni: ['fp8-block128'], glm_moe_dsa: ['exlr8'] }, serve: { flags: {} }, env: [] })) for (const [modelType, bits, group] of [['lfm2_moe', 6, 64], ['gemma4', 3, 64], ['gemma4_unified', 8, 64], ['step5_vl', 2, 128]] as const) { const repo = `Example/Declared-${modelType}`, hub = mockHub(repoRoutes(repo, { modelType, quant: { bits, group_size: group } })) diff --git a/app/electron/agent/engine/library.test.ts b/app/electron/agent/engine/library.test.ts index 11027af03c5..940c2b70a4b 100644 --- a/app/electron/agent/engine/library.test.ts +++ b/app/electron/agent/engine/library.test.ts @@ -85,7 +85,23 @@ try { await fs.writeFile(path.join(wrongGeometry, 'config.json'), JSON.stringify({ model_type: 'qwen3_5', quantization: { bits: 4, group_size: 64 }, max_position_embeddings: 32768, text_config: { hidden_size: 1024, num_hidden_layers: 24, vocab_size: 151936 } })) const servedGeometry = path.join(modelsDir, 'served-geometry') await checkpoint(servedGeometry) - await fs.writeFile(path.join(servedGeometry, 'config.json'), JSON.stringify({ model_type: 'qwen3_5', quantization: { bits: 4, group_size: 64 }, max_position_embeddings: 32768, text_config: { hidden_size: 2048, num_hidden_layers: 24, vocab_size: 248320, intermediate_size: 6144, linear_num_key_heads: 16, linear_num_value_heads: 16, linear_key_head_dim: 128, linear_value_head_dim: 128, linear_conv_kernel_dim: 6144, num_attention_heads: 8, num_key_value_heads: 2, head_dim: 256, full_attention_interval: 4 } })) + const servedConfig = { + model_type: 'qwen3_5', + quantization: { bits: 4, group_size: 64 }, + max_position_embeddings: 32768, + text_config: { + hidden_size: 2048, num_hidden_layers: 24, vocab_size: 248320, intermediate_size: 6144, + linear_num_key_heads: 16, linear_num_value_heads: 16, linear_key_head_dim: 128, linear_value_head_dim: 128, + linear_conv_kernel_dim: 4, num_attention_heads: 8, num_key_value_heads: 2, head_dim: 256, full_attention_interval: 4, + }, + } + await fs.writeFile(path.join(servedGeometry, 'config.json'), JSON.stringify(servedConfig)) + const wrongConvolution = path.join(modelsDir, 'wrong-convolution') + await checkpoint(wrongConvolution) + await fs.writeFile(path.join(wrongConvolution, 'config.json'), JSON.stringify({ + ...servedConfig, + text_config: { ...servedConfig.text_config, linear_conv_kernel_dim: 6144 }, + })) const incomplete = path.join(modelsDir, 'incomplete') await checkpoint(incomplete) await fs.writeFile(path.join(incomplete, 'model.safetensors.index.json'), JSON.stringify({ weight_map: { a: 'model-00001-of-00002.safetensors', b: 'model-00002-of-00002.safetensors' } })) @@ -111,6 +127,10 @@ try { assert.match(refused.reason!, /hidden size is 1024/) assert.match(refused.reason!, /UnsupportedQwenGeometry/) assert.equal(selected.models.find((model) => model.path === servedGeometry)?.loadable, true, 'the geometry the engine serves stays offered') + const refusedConvolution = selected.models.find((model) => model.path === wrongConvolution)! + assert.equal(refusedConvolution.complete, true) + assert.equal(refusedConvolution.loadable, false) + assert.match(refusedConvolution.reason!, /linear conv kernel dim is 6144/) assert.equal(selected.models.find((model) => model.path === foreign)?.complete, true) assert.match(selected.models.find((model) => model.path === incomplete)!.reason!, /missing.*shards/) assert.match(selected.models.find((model) => model.path === invalid)!.reason!, /safetensors/) diff --git a/app/electron/agent/engine/pull-queue.test.ts b/app/electron/agent/engine/pull-queue.test.ts index 12c89f252c1..b716b45957f 100644 --- a/app/electron/agent/engine/pull-queue.test.ts +++ b/app/electron/agent/engine/pull-queue.test.ts @@ -1,4 +1,5 @@ import assert from 'node:assert/strict' +import { hasCachedSnapshot } from './paths' import { PullQueue } from './pull' import { makeHarness, waitFor } from './test-fixtures/harness' @@ -22,6 +23,8 @@ async function main() { assert.equal((await cancelled.done).state, 'cancelled') assert.equal(second.progress().queuePosition, 1, 'positions update after cancelling a queued item') await waitFor(() => first.progress().state === 'verifying', 10_000, 'durable completion boundary') + first.cancel() + assert.equal(first.progress().state, 'verifying') assert.deepEqual((await h.records()).filter((r) => r.kind === 'pull').map((r) => r.repo), ['Org/First', 'Org/Drafter'], 'next job never overlaps model, companion or finalization') finish() assert.equal((await first.done).state, 'done') @@ -43,6 +46,25 @@ async function main() { assert.equal((await running.done).state, 'cancelled') assert.equal((await successor.done).state, 'done', 'cancelling the current item respects the separate next-item consent') + const repo = 'Org/FinalSample' + const total = 65536 + let cancelledFromSample = false + let finalized = false + const late = queue.enqueue({ + ...options(repo), totalBytes: total, pollMs: 60_000, + onUpdate: ({ state, receivedBytes }) => { + if (cancelledFromSample || state !== 'running' || receivedBytes !== total) return + cancelledFromSample = true + late.cancel() + }, + }, async (progress) => { finalized = true; return progress }) + const afterLateCancel = queue.enqueue(options('Org/AfterLateCancel')) + assert.equal((await late.done).state, 'cancelled') + assert.equal(cancelledFromSample, true) + assert.equal(finalized, false) + assert.equal(await hasCachedSnapshot(h.hub, repo), true, 'the cancelled job keeps its downloaded bytes') + assert.equal((await afterLateCancel.done).state, 'done') + const stopFirst = queue.enqueue(options('Org/ShutdownFirst')) const stopNext = queue.enqueue(options('Org/ShutdownNeverStarted')) queue.cancelAll() diff --git a/app/electron/agent/engine/pull.test.ts b/app/electron/agent/engine/pull.test.ts index fc73f236319..c6ae858503e 100644 --- a/app/electron/agent/engine/pull.test.ts +++ b/app/electron/agent/engine/pull.test.ts @@ -40,6 +40,26 @@ async function main() { assert.equal(failed.state, 'failed') assert.match(failed.message ?? '', /file tree is unreachable/) + const diagnostic = 'error: checkpoint café is incomplete' + const script = ` + const fs = require('node:fs') + const bytes = Buffer.from(${JSON.stringify(diagnostic)}) + const split = bytes.indexOf(Buffer.from('é')) + 1 + fs.writeSync(2, bytes.subarray(0, split)) + setTimeout(() => fs.writeSync(1, 'checking checkpoint\\r\\n'), 100) + setTimeout(() => { fs.writeSync(2, bytes.subarray(split)); process.exitCode = 1 }, 200) + ` + const visible = new Set() + const fragmented = startPull({ + binary: { command: process.execPath, args: ['-e', script, '--'] }, env: h.env, hub: h.hub, + steps: [{ repo: 'Org/Fragmented', revision: null }], totalBytes: null, + onUpdate: ({ lastLine }) => { if (lastLine) visible.add(lastLine) }, + }) + const fragmentFailure = await fragmented.done + assert.equal(fragmentFailure.state, 'failed') + assert.equal(fragmentFailure.message, diagnostic) + assert.deepEqual(visible, new Set(['checking checkpoint', diagnostic])) + // Cancel kills the whole process group, not just the direct child. const slow = startPull({ binary: h.binary, env: { ...h.env, FAKE_PULL_DELAY_MS: '200' }, hub: h.hub, steps: [{ repo: 'Org/Slow', revision: null }], totalBytes: total, pollMs: 40, onUpdate: () => {} }) await waitFor(async () => (await fs.readdir(path.join(h.hub, 'models--Org--Slow', 'blobs')).catch(() => [])).length > 0, 10_000, 'slow pull to start') diff --git a/app/electron/agent/engine/pull.ts b/app/electron/agent/engine/pull.ts index 8eaf90e35c4..880f731dc4b 100644 --- a/app/electron/agent/engine/pull.ts +++ b/app/electron/agent/engine/pull.ts @@ -1,4 +1,5 @@ import { spawn, type ChildProcess } from 'node:child_process' +import type { Readable } from 'node:stream' import type { PullProgress } from '../types' import { repoCachedBytes, type EngineBinary } from './paths' @@ -30,6 +31,7 @@ export interface PullHandle { } const KEEP_LINES = 40 +const MAX_LINE_CHARS = 64 * 1024 // Cache bytes are measured, not guessed from the advertised model size. A resumed download's // existing bytes establish the baseline and never count as this session's transfer speed. @@ -118,18 +120,31 @@ export function startPull(opts: PullOptions): PullHandle { const spec = step.revision ? `${step.repo}@${step.revision}` : step.repo const proc = spawn(opts.binary.command, [...opts.binary.args, 'pull', spec], { env: opts.env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] }) child = proc - const onText = (chunk: Buffer) => { - for (const raw of chunk.toString('utf8').split(/\r?\n/)) { - const line = raw.trimEnd() - if (!line.trim()) continue - lines.push(line.trim()) + const onLines = (records: string[]) => { + let changed = false + for (const raw of records) { + const line = raw.trim().slice(-MAX_LINE_CHARS) + if (!line) continue + lines.push(line) if (lines.length > KEEP_LINES) lines.shift() - state.lastLine = line.trim() + state.lastLine = line + changed = true } - emit() + if (changed) emit() + } + const capture = (stream: Readable | null) => { + if (!stream) return + let pending = '' + stream.setEncoding('utf8') + stream.on('data', (chunk: string) => { + const records = (pending + chunk).split('\n') + pending = records.pop()!.slice(-MAX_LINE_CHARS) + onLines(records) + }) + stream.once('end', () => onLines([pending])) } - proc.stdout?.on('data', onText) - proc.stderr?.on('data', onText) + capture(proc.stdout) + capture(proc.stderr) proc.once('error', (error) => reject(new Error(`Could not start tensorfold-native pull: ${error.message}`))) proc.once('close', (code, signal) => { child = null @@ -147,6 +162,7 @@ export function startPull(opts: PullOptions): PullHandle { await runStep(step, index) } await measure() + if (cancelled) throw new Error('cancelled') state.state = 'done' state.phase = 'Downloaded' if (state.totalBytes != null) state.receivedBytes = state.totalBytes diff --git a/app/electron/agent/ticket-review-build.test.ts b/app/electron/agent/ticket-review-build.test.ts new file mode 100644 index 00000000000..b983eeb0934 --- /dev/null +++ b/app/electron/agent/ticket-review-build.test.ts @@ -0,0 +1,106 @@ +import assert from 'node:assert/strict' +import { summarizeTicketWorkerOutcome } from '../main/host/ticket-helpers' +import { roomFinalGateBlockers, ticketNeedsReviewAfterBuilder, ticketReviewGateState } from './tickets' +import type { Thread, Ticket, TicketEvidence } from './types' + +const build: TicketEvidence = { id: 'build', kind: 'file', summary: 'Inspected src/parser.ts.', createdBy: 'Builder', createdAt: 10 } +const approval: TicketEvidence = { id: 'approval', kind: 'review', summary: 'Reviewer approved.', createdBy: 'Reviewer', createdAt: 20 } +const rebuild: TicketEvidence = { ...build, id: 'rebuild', summary: 'Inspected the follow-up implementation.', createdAt: 30 } +const waiver: TicketEvidence = { ...approval, id: 'waiver', kind: 'note', summary: 'Review skipped: read-only source lookup, no code changes.' } + +function ticket(evidence: TicketEvidence[]): Ticket { + return { + id: 'ticket-fixture', projectId: 'project-fixture', roomId: 'room-fixture', title: 'Follow-up implementation', body: '', + type: 'task', status: 'completed', priority: 'medium', effort: 'medium', tags: [], assignee: 'Builder', + parentId: null, threadId: null, runState: null, startedAt: null, order: 0, createdAt: 1, updatedAt: 90, + risk: 'high', allowedCapabilities: ['read'], requiredEvidence: ['Findings'], acceptanceCriteria: [], evidence, + } +} + +let passed = 0 +function check(name: string, evidence: TicketEvidence[], allowed: boolean, builder = 'Builder') { + const current = ticket(evidence) + assert.equal(ticketReviewGateState(current).hasReviewOrSkipAfterBuilder, allowed, name) + assert.equal(ticketReviewGateState(current).builderEvidenceBy, builder, name) + assert.equal(ticketNeedsReviewAfterBuilder(current), !allowed, name) + assert.deepEqual(roomFinalGateBlockers({ tickets: [current], greenEvidenceAt: 100 }), allowed ? [] + : ['review evidence after builder or justified skip missing on: Follow-up implementation.'], name) + passed++ +} + +function worker(phase: 'build' | 'review', at: number, createdBy: string | null, changes = false): TicketEvidence[] { + const now = Date.now + Date.now = () => at + try { + const thread = { + id: `${phase}-thread-${at}`, + timeline: [ + { id: 'read', kind: 'tool', path: 'src/parser.ts', state: 'ok' }, + ...(changes ? [{ id: 'edit', kind: 'tool', path: 'src/parser.ts', diff: [{ type: 'add', text: 'const value = 1' }], state: 'ok' }] : []), + { id: 'status', kind: 'tool', command: 'git status --short', output: '', state: 'ok' }, + { id: 'test', kind: 'tool', command: 'npm test', output: '2 passed', state: 'ok' }, + ], + } as unknown as Thread + return summarizeTicketWorkerOutcome(ticket([]), thread, phase, false, createdBy).evidence + } finally { Date.now = now } +} + +check('an approval does not cover later builder findings', [build, approval, rebuild], false) +check('timestamp order wins over insertion order', [rebuild, build, approval], false) +check('a fresh independent approval covers the rebuild', [build, approval, rebuild, { ...approval, id: 'fresh', createdAt: 40 }], true) +check('a waiver does not cover later builder findings', [build, waiver, rebuild], false) +check('a fresh justified waiver covers read-only work', [build, waiver, rebuild, { ...waiver, id: 'fresh-waiver', createdAt: 40 }], true) +check('a new builder is reported as the current builder', [build, approval, { ...rebuild, createdBy: 'Second builder' }], false, 'Second builder') +check('a review cannot cover a build at the same timestamp', [build, approval, { ...rebuild, createdAt: 20 }], false) + +const reviewBlocker: TicketEvidence = { + id: 'review-blocker', kind: 'note', summary: 'Blocker: parser validation failed.', + createdBy: 'Reviewer', createdAt: 20, ref: 'thread:review-fixture', +} +const blockedBatch = [{ ...approval, ref: reviewBlocker.ref }, reviewBlocker] +check('a reviewer blocker preserves the original builder identity', [build, ...blockedBatch], false) +check('reviewer blocker batches are independent of insertion order', [build, ...[...blockedBatch].reverse()], false) +check('a fresh approval resolves the reviewer blocker without a new build', [build, ...blockedBatch, { + ...approval, id: 'resolved', createdAt: 30, +}], true) +check('an unrelated note cannot inherit a review blocker batch', [build, ...blockedBatch.slice(0, 1), { + ...reviewBlocker, ref: 'thread:other-review', +}], true) +check('another actor cannot attach a review blocker batch', [build, blockedBatch[0], { + ...reviewBlocker, createdBy: 'Another actor', +}], true) +check('another timestamp cannot attach a review blocker batch', [build, blockedBatch[0], { + ...reviewBlocker, createdAt: 21, +}], true) +check('a blocker describing changed code is still a review finding', [build, blockedBatch[0], { + ...reviewBlocker, summary: 'Blocker: changed parser behavior fails validation.', +}], false) +check('an explicit empty blocker does not reject a review', [build, blockedBatch[0], { + ...reviewBlocker, summary: 'Blocker: none', +}], true) +check('a later builder run still invalidates approval without file events', [build, approval, { + ...build, id: 'builder-run', kind: 'note', summary: 'Builder worker finished the follow-up.', createdAt: 30, +}], false) + +const reviewRun = worker('review', 20, 'Reviewer') +const reviewOnly = ticket(reviewRun) +assert.deepEqual(ticketReviewGateState(reviewOnly), { hasBuilderEvidence: false, builderEvidenceBy: null, hasReviewOrSkipAfterBuilder: false }) +assert.equal(ticketNeedsReviewAfterBuilder(reviewOnly), false, 'a review cannot create builder evidence for another review') +assert.deepEqual(roomFinalGateBlockers({ tickets: [reviewOnly] }), ['review evidence after builder or justified skip missing on: Follow-up implementation.']) +passed++ +check('real reviewer verification is not a new build', [build, ...reviewRun], true) +check('review batch order does not alter builder ownership', [build, ...[...reviewRun].reverse()], true) +check('anonymous review batches keep the same verification behavior', [build, ...worker('review', 20, null)], true) +check('an actual later build worker invalidates the review', [build, ...reviewRun, ...worker('build', 30, 'Builder')], false) +check('a new review worker covers the actual rebuilt output', [build, ...reviewRun, ...worker('build', 30, 'Builder'), ...worker('review', 40, 'Reviewer')], true) + +const testResult = reviewRun.find((item) => item.kind === 'test')! +assert.ok(testResult, 'the host fixture must produce a verification record') +check('another thread cannot inherit a review batch exemption', [build, ...reviewRun, { ...testResult, id: 'other-thread', ref: 'thread:other-run' }], false, 'Reviewer') +check('another actor cannot inherit a review batch exemption', [build, ...reviewRun, { ...testResult, id: 'other-actor', createdBy: 'Second builder' }], false, 'Second builder') +check('a missing thread reference cannot inherit a review batch exemption', [build, ...reviewRun, { ...testResult, id: 'missing-ref', ref: null }], false, 'Reviewer') +check('a later run cannot reuse an earlier batch timestamp', [build, ...reviewRun, { ...testResult, id: 'later-run', createdAt: 30 }], false, 'Reviewer') +check('code changes made during a review still need independent review', [build, ...worker('review', 20, 'Reviewer', true)], false, 'Reviewer') +check('a different reviewer can approve the reviewer-made changes', [build, ...worker('review', 20, 'Reviewer', true), { ...approval, id: 'independent', createdBy: 'Second reviewer', createdAt: 30 }], true, 'Reviewer') + +console.log(`ticket review build freshness: ${passed} cases passed`) diff --git a/app/electron/agent/ticket-review-verdict.test.ts b/app/electron/agent/ticket-review-verdict.test.ts new file mode 100644 index 00000000000..cf6825a6a4a --- /dev/null +++ b/app/electron/agent/ticket-review-verdict.test.ts @@ -0,0 +1,53 @@ +import assert from 'node:assert/strict' +import { roomFinalGateBlockers, ticketNeedsReviewAfterBuilder, ticketReviewGateState } from './tickets' +import type { Ticket, TicketEvidence } from './types' + +const finding: TicketEvidence = { id: 'finding', kind: 'file', summary: 'Inspected src/parser.ts.', createdBy: 'Builder', createdAt: 10 } +const approved: TicketEvidence = { id: 'approved', kind: 'review', summary: 'Reviewer approved; no blockers.', createdBy: 'Reviewer', createdAt: 20 } +const blocked: TicketEvidence = { id: 'blocked', kind: 'review', summary: 'Changes requested: regression in empty input handling.', createdBy: 'Reviewer', createdAt: 30 } +const waived: TicketEvidence = { id: 'waived', kind: 'note', summary: 'Review skipped: read-only source lookup, no code changes.', createdBy: 'Reviewer', createdAt: 20 } + +function ticket(evidence: TicketEvidence[], patch: Partial = {}): Ticket { + return { + id: 'ticket-fixture', projectId: 'project-fixture', roomId: 'room-fixture', title: 'Review the parser', body: '', + type: 'task', status: 'completed', priority: 'medium', effort: 'medium', tags: [], assignee: 'Builder', + parentId: null, threadId: null, runState: null, startedAt: null, order: 0, createdAt: 1, updatedAt: 40, + risk: 'high', allowedCapabilities: ['read'], requiredEvidence: ['Findings'], acceptanceCriteria: [], evidence, ...patch, + } +} + +let passed = 0 +function check(name: string, evidence: TicketEvidence[], allowed: boolean) { + const current = ticket(evidence) + assert.equal(ticketReviewGateState(current).hasReviewOrSkipAfterBuilder, allowed, name) + assert.equal(ticketNeedsReviewAfterBuilder(current), !allowed, name) + assert.deepEqual(roomFinalGateBlockers({ tickets: [current] }), allowed ? [] + : ['review evidence after builder or justified skip missing on: Review the parser.'], name) + passed++ +} + +check('an independent approval completes the gate', [finding, approved], true) +check('an ordinary later note does not revoke approval', [finding, approved, { + ...finding, id: 'reminder', kind: 'note', summary: 'Follow up with the documentation team tomorrow.', createdAt: 30, +}], true) +check('a later note describing code changes still requires review', [finding, approved, { + ...finding, id: 'changed-note', kind: 'note', summary: 'Changed the parser implementation.', createdAt: 30, +}, { ...finding, id: 'later-green', kind: 'test', summary: 'Parser tests passed.', createdAt: 31 }], false) +check('a later blocking verdict supersedes approval', [finding, approved, blocked], false) +check('another reviewer can reopen a ticket', [finding, approved, { ...blocked, createdBy: 'Second reviewer' }], false) +check('a fresh approval resolves the blocking verdict', [finding, approved, blocked, { ...approved, id: 'fresh', createdAt: 40 }], true) +check('an older blocking verdict does not override a newer approval', [finding, blocked, { ...approved, createdAt: 40 }], true) +check('timestamps take precedence over array order', [finding, blocked, approved], false) +check('the last verdict wins at equal timestamps', [finding, approved, { ...blocked, createdAt: 20 }], false) +check('a same-timestamp follow-up approval can resolve the verdict', [finding, blocked, { ...approved, createdAt: 30 }], true) +check('informational review notes do not revoke approval', [finding, approved, { ...blocked, summary: 'Reviewer inspected the examples.' }], true) +check('user approval records are not reviewer verdicts', [finding, approved, { ...blocked, kind: 'note', summary: 'User approval rejected for a separate action.' }], true) +check('a later blocking verdict supersedes a waiver', [finding, waived, blocked], false) +check('a justified later waiver can resolve read-only review', [finding, blocked, { ...waived, createdAt: 40 }], true) +check('a later self-review cannot reuse an older independent approval', [finding, approved, { ...approved, id: 'self', createdBy: 'Builder', createdAt: 40 }], false) + +const changed: TicketEvidence = { ...finding, kind: 'diff', summary: 'Changed src/parser.ts.' } +const green: TicketEvidence = { id: 'green', kind: 'test', summary: 'Parser tests passed.', createdBy: 'Builder', createdAt: 11 } +check('an invalid code-change waiver cannot bypass a blocking verdict', [changed, green, approved, blocked, { ...waived, createdAt: 40 }], false) + +console.log(`ticket review verdict: ${passed} cases passed`) diff --git a/app/electron/agent/tickets.ts b/app/electron/agent/tickets.ts index e7a68828e3f..e8cfaaba3e7 100644 --- a/app/electron/agent/tickets.ts +++ b/app/electron/agent/tickets.ts @@ -236,13 +236,12 @@ export interface TicketReviewGateState { export function ticketReviewGateState(ticket: Ticket): TicketReviewGateState { const evidence = meaningfulTicketEvidence(ticket) - const builder = newestEvidence(evidence.filter(isBuilderEvidence)) - const review = newestReviewPassAfterBuilder(evidence) - const skip = newestReviewSkipAfterBuilder(evidence, ticket) + const builder = newestBuilderEvidence(evidence, ticket) + const review = newestReviewDecisionAfterBuilder(evidence, builder) return { hasBuilderEvidence: !!builder, builderEvidenceBy: builder?.createdBy ?? null, - hasReviewOrSkipAfterBuilder: !!review || !!skip, + hasReviewOrSkipAfterBuilder: !!review, } } @@ -264,27 +263,33 @@ function newestEvidence(items: TicketEvidence[]): TicketEvidence | null { }, null) } -function newestReviewPassAfterBuilder(evidence: TicketEvidence[]): TicketEvidence | null { - return newestEvidence(evidence.filter((item) => { - if (!isReviewPassEvidence(item)) return false - const builder = newestBuilderEvidenceBefore(evidence, item) - if (!builder) return false - return !sameEvidenceCreator(builder, item) - })) +function newestReviewDecisionAfterBuilder(evidence: TicketEvidence[], builder: TicketEvidence | null): TicketEvidence | null { + const canSkip = !evidence.some(isCodeChangeEvidence) + const decision = newestEvidence(evidence.filter((item) => + isReviewPassEvidence(item) || canSkip && isReviewSkipEvidence(item) + || hasReviewerSignal(item) && isBlockingReviewEvidence(item), + )) + if (!decision || !(isReviewPassEvidence(decision) || canSkip && isReviewSkipEvidence(decision))) return null + const batch = reviewBatchKey(decision) + if (batch && evidence.some((item) => item.kind === 'note' && reviewBatchKey(item) === batch + && /^Blocker:/i.test(item.summary) && isBlockingReviewEvidence(item))) return null + return builder && builder.createdAt < decision.createdAt && !sameEvidenceCreator(builder, decision) ? decision : null } -function newestReviewSkipAfterBuilder(evidence: TicketEvidence[], ticket: Ticket): TicketEvidence | null { - if (hasCodeChangeEvidence(ticket)) return null +function newestBuilderEvidence(evidence: TicketEvidence[], ticket: Ticket): TicketEvidence | null { + const reviewBatches = new Set(evidence.filter((item) => item.kind === 'review') + .map(reviewBatchKey).filter((key): key is string => key !== null)) return newestEvidence(evidence.filter((item) => { - if (!isReviewSkipEvidence(item)) return false - const builder = newestBuilderEvidenceBefore(evidence, item) - if (!builder) return false - return !sameEvidenceCreator(builder, item) + if (!isBuilderEvidence(item, ticket)) return false + const verification = item.kind === 'test' || item.kind === 'command' + const batch = reviewBatchKey(item) + return !verification || isCodeChangeEvidence(item) || batch === null || !reviewBatches.has(batch) })) } -function newestBuilderEvidenceBefore(evidence: TicketEvidence[], item: TicketEvidence): TicketEvidence | null { - return newestEvidence(evidence.filter((candidate) => isBuilderEvidence(candidate) && candidate.createdAt < item.createdAt)) +function reviewBatchKey(item: TicketEvidence): string | null { + if (!item.ref?.startsWith('thread:') || item.ref.length === 'thread:'.length) return null + return JSON.stringify([item.createdAt, item.createdBy ?? null, item.ref]) } function sameEvidenceCreator(a: TicketEvidence, b: TicketEvidence): boolean { @@ -307,12 +312,11 @@ function hasUnresolvedExternalDestructiveApproval(ticket: Ticket): boolean { return !approvalAt || approvalAt < actionAt } -function hasCodeChangeEvidence(ticket: Ticket): boolean { - return meaningfulTicketEvidence(ticket).some(isCodeChangeEvidence) -} - -function isBuilderEvidence(item: TicketEvidence): boolean { - return !isReviewEvidence(item) && !isReviewSkipEvidence(item) +function isBuilderEvidence(item: TicketEvidence, ticket: Ticket): boolean { + if (isReviewEvidence(item) || isReviewSkipEvidence(item)) return false + if (item.kind === 'note' && /^Blocker:/i.test(item.summary)) return false + return item.kind !== 'note' || isCodeChangeEvidence(item) || /^Builder worker\b/i.test(item.summary) + || isExternalDestructiveActionEvidence(item, ticket) } function isReservationEvidence(item: TicketEvidence): boolean { @@ -325,12 +329,15 @@ function isReviewEvidence(item: TicketEvidence): boolean { return item.kind === 'review' || /\b(reviewed|reviewer|verdict|approved|approval|blocking issues?|ready for final)\b/i.test(text) } +function hasReviewerSignal(item: TicketEvidence): boolean { + return item.kind === 'review' || /\b(reviewed|reviewer|review verdict|verdict)\b/i.test(evidenceText(item)) +} + function isReviewPassEvidence(item: TicketEvidence): boolean { if (isReviewSkipEvidence(item)) return false if (isBlockingReviewEvidence(item)) return false const text = evidenceText(item) - const reviewerSignal = item.kind === 'review' || /\b(reviewed|reviewer|review verdict|verdict)\b/i.test(text) - if (!reviewerSignal) return false + if (!hasReviewerSignal(item)) return false return /\b(approved|approval|pass(?:ed)?|verified|accepted|ready for final|ready to final|ready|finished|looks good|lgtm|no blockers?|no blocking issues?)\b/i.test(text) } diff --git a/app/electron/main/host/ipc/workspace-ipc.ts b/app/electron/main/host/ipc/workspace-ipc.ts index b9a76a015e3..ff167ef71b2 100644 --- a/app/electron/main/host/ipc/workspace-ipc.ts +++ b/app/electron/main/host/ipc/workspace-ipc.ts @@ -171,9 +171,11 @@ handle('threads:create', async (_e, { cwd, kind = 'task', projectId = null, comm : projectWorkspace?.kind === 'ssh' && candidateCwd === projectWorkspace.path ? candidateCwd : candidateCwd && (await dirExists(candidateCwd)) ? candidateCwd : '' - const resolved = project ? resolveProjectProvider(project) : null + const usesProjectBaseAccount = project?.defaultProviderAccountId === null + && store.settings.providers.some((p) => p.id === project.defaultProviderId && (!project.localOnly || p.kind === 'local')) + const resolved = project ? resolveProjectProvider(project, usesProjectBaseAccount ? null : undefined) : null const baseProvider = resolved?.baseProvider ?? store.settings.providers.find((p) => p.id === store.settings.activeProviderId) - const providerAccountId = resolved?.providerAccountId ?? (baseProvider ? selectedProviderAccountId(baseProvider, store.settings.activeProviderAccountId ?? undefined) : null) + const providerAccountId = resolved ? resolved.providerAccountId : (baseProvider ? selectedProviderAccountId(baseProvider, store.settings.activeProviderAccountId ?? undefined) : null) const model = resolved?.model ?? (baseProvider ? resolveProviderModel(baseProvider, providerAccountId, store.settings.activeModel) : store.settings.activeModel) // Folder checks above yield; a simultaneous retry may have completed meanwhile. const concurrent = priorCreatedThread() diff --git a/app/electron/main/host/power.test.ts b/app/electron/main/host/power.test.ts index 26534409a56..88c8b12861e 100644 --- a/app/electron/main/host/power.test.ts +++ b/app/electron/main/host/power.test.ts @@ -1,123 +1,96 @@ import assert from 'node:assert/strict' +import { EventEmitter } from 'node:events' +import { readFileSync } from 'node:fs' import path from 'node:path' -import os from 'node:os' -import { promises as fs } from 'node:fs' -import { createJiti } from 'jiti' +import { mock } from 'node:test' +import ts from 'typescript' -// Isolated test for power.ts. power.ts imports the real `../../store` (which pulls -// in electron + crypto + fs) and `../state`. We alias both to lightweight fakes so -// the module under test loads in a plain node/jiti context, and we point its -// hardcoded `/usr/bin/caffeinate` spawn at a tiny long-lived stand-in via a PATH- -// independent absolute path by aliasing nothing there — instead we drive the REAL -// caffeinate binary on this macOS host and observe the respawn behaviour. +const source = readFileSync(path.join(__dirname, 'power.ts'), 'utf8') +const output = ts.transpileModule(source, { + compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }, +}).outputText +const loadPower = new Function('require', 'exports', 'process', output) -const hostDir = __dirname // electron/main/host -const powerPath = path.join(hostDir, 'power.ts') +class FakeCaffeinate extends EventEmitter { + signals: NodeJS.Signals[] = [] -async function main() { - // ---- shared fake state module ---------------------------------------- - const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'power-test-')) - const savedCalls: any[] = [] + get killed() { return this.signals.length > 0 } - const fakeStorePath = path.join(tmp, 'fake-store.mjs') - await fs.writeFile( - fakeStorePath, - `export const store = { settings: { power: { keepComputerAlive: true, lastError: null } } } -`, - ) - const fakeSaveSettingsPath = path.join(tmp, 'fake-save.mjs') - await fs.writeFile( - fakeSaveSettingsPath, - `globalThis.__savedCalls = globalThis.__savedCalls || [] -export async function saveSettings(s){ globalThis.__savedCalls.push(s); return s } -`, - ) - - void savedCalls // capture happens via globalThis.__savedCalls in the fake module - const jiti = createJiti(__filename, { - // jiti matches alias keys against the import *specifier*, so we alias the exact - // relative strings power.ts imports rather than resolved absolute paths. - alias: { - '../../store': fakeSaveSettingsPath, // import { saveSettings } from '../../store' - '../state': fakeStorePath, // import { store } from '../state' - }, - moduleCache: false, - fsCache: false, - }) - - const mod: any = await jiti.import(powerPath) - const { applyPowerSettings, stopCaffeinate } = mod - assert.equal(typeof applyPowerSettings, 'function', 'applyPowerSettings exported') - - if (process.platform !== 'darwin') { - console.log('non-darwin host: applyPowerSettings should record a platform error and not spawn') - applyPowerSettings() - console.log('PASS (skipped respawn assertions; macOS-only path)') - return + kill(signal: NodeJS.Signals) { + this.signals.push(signal) + return true } +} - // ---- start caffeinate ------------------------------------------------- - applyPowerSettings() - - // find the spawned caffeinate pid (the module keeps the handle private, so we - // detect via the system process list) - const { execSync } = await import('node:child_process') - const pidOf = (): number | null => { - try { - const out = execSync('pgrep -f "/usr/bin/caffeinate -dimsu"', { encoding: 'utf8' }).trim() - const pids = out.split(/\s+/).filter(Boolean).map(Number) - return pids.length ? pids[pids.length - 1] : null - } catch { - return null - } - } - - const wait = (ms: number) => new Promise((r) => setTimeout(r, ms)) - - await wait(300) - const firstPid = pidOf() - assert.ok(firstPid, 'caffeinate spawned on applyPowerSettings') - console.log('PASS: caffeinate spawned, pid', firstPid) - - // ---- simulate an unexpected death (NOT our SIGTERM) ------------------- - // SIGKILL the child as if the OS reaped it. The exit handler should respawn - // after RESPAWN_BACKOFF_MS (2s) because keepComputerAlive is still wanted. - process.kill(firstPid!, 'SIGKILL') - await wait(500) - // briefly: process gone, no immediate respawn yet (backoff pending) - // (we don't hard-assert the gap window to avoid timing flakiness) - - // wait past the 2s backoff + spawn time - await wait(2500) - const secondPid = pidOf() - assert.ok(secondPid, 'caffeinate was respawned after unexpected death') - assert.notEqual(secondPid, firstPid, 'respawn produced a new process') - console.log('PASS: caffeinate respawned after unexpected exit, new pid', secondPid) - - // ---- deliberate stop must NOT respawn --------------------------------- - stopCaffeinate() - await wait(2700) // longer than backoff - const afterStop = pidOf() - assert.equal(afterStop, null, 'no caffeinate process after deliberate stopCaffeinate (no respawn)') - console.log('PASS: stopCaffeinate killed it and suppressed respawn') - - // ---- error path was recorded for the unexpected exit ------------------ - const calls: any[] = (globalThis as any).__savedCalls || [] - const sawExitError = calls.some( - (c) => c?.power?.lastError && /caffeinate exited/.test(String(c.power.lastError)), - ) - assert.ok(sawExitError, 'lastError recorded the unexpected caffeinate exit') - console.log('PASS: unexpected exit recorded lastError') +function makeFixture(platform: NodeJS.Platform) { + const store = { settings: { power: { keepComputerAlive: true, lastError: null as string | null } } } + const children: FakeCaffeinate[] = [] + const writes: Array<{ key: string; lastError: string | null }> = [] + const imports = new Map([ + ['node:child_process', { + spawn(command: string, args: string[], options: object) { + assert.equal(command, '/usr/bin/caffeinate') + assert.deepEqual(args, ['-dimsu']) + assert.deepEqual(options, { stdio: 'ignore' }) + const child = new FakeCaffeinate() + children.push(child) + return child + }, + }], + ['../state', { store }], + ['./persistence', { + persistSettings(key: string) { + writes.push({ key, lastError: store.settings.power.lastError }) + }, + }], + ]) + const power = {} as typeof import('./power') + loadPower((id: string) => { + assert.ok(imports.has(id), `unexpected power dependency ${id}`) + return imports.get(id) + }, power, { platform }) + return { power, children, writes } +} - await fs.rm(tmp, { recursive: true, force: true }).catch(() => {}) - console.log('ALL TESTS PASSED') +const unsupported = makeFixture('linux') +unsupported.power.applyPowerSettings() +assert.equal(unsupported.children.length, 0) +assert.equal(unsupported.writes.at(-1)?.key, 'power.lastError') +assert.match(unsupported.writes.at(-1)?.lastError ?? '', /only available on macOS/) + +const { power, children, writes } = makeFixture('darwin') +mock.timers.enable({ apis: ['setTimeout'] }) +try { + power.applyPowerSettings() + power.applyPowerSettings() + assert.equal(children.length, 1, 'reapplying settings keeps the same live helper') + assert.deepEqual(writes, [{ key: 'power.lastStartedAt', lastError: null }]) + + children[0].emit('exit', null, 'SIGKILL') + assert.deepEqual(writes.at(-1), { key: 'power.lastError', lastError: 'caffeinate exited: SIGKILL' }) + mock.timers.tick(1999) + assert.equal(children.length, 1, 'respawn waits for the backoff') + mock.timers.tick(1) + assert.equal(children.length, 2, 'the helper respawns once at the deadline') + assert.deepEqual(writes.at(-1), { key: 'power.lastStartedAt', lastError: null }) + + children[1].emit('exit', 1, null) + power.stopCaffeinate() + mock.timers.tick(2000) + assert.equal(children.length, 2, 'stopping cancels a pending respawn') + + power.applyPowerSettings() + assert.equal(children.length, 3) + const savedBeforeStop = writes.length + power.stopCaffeinate() + assert.deepEqual(children.map((child) => child.signals), [[], [], ['SIGTERM']], 'stop signals only the current child') + children[2].emit('exit', null, 'SIGTERM') + mock.timers.tick(2000) + assert.equal(children.length, 3, 'a deliberate stop does not respawn') + assert.equal(writes.length, savedBeforeStop, 'a deliberate stop does not record an error') +} finally { + power.stopCaffeinate() + mock.timers.reset() } -main().catch((e) => { - // best-effort cleanup of any stray caffeinate we started - try { - require('node:child_process').execSync('pkill -f "/usr/bin/caffeinate -dimsu"') - } catch {} - console.error('TEST FAILED:', e) - process.exit(1) -}) +console.log('Desktop power: platform guard, owned shutdown, error persistence and restart backoff passed') diff --git a/app/electron/main/host/project-thread-route.test.ts b/app/electron/main/host/project-thread-route.test.ts new file mode 100644 index 00000000000..bae38c282f3 --- /dev/null +++ b/app/electron/main/host/project-thread-route.test.ts @@ -0,0 +1,84 @@ +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import path from 'node:path' +import ts from 'typescript' +import { providerWithAccount, resolveProviderModel, selectProviderAccount } from '../../agent/provider-accounts' + +function readSource(file: string): ts.SourceFile { + return ts.createSourceFile(file, readFileSync(path.join(__dirname, file), 'utf8'), ts.ScriptTarget.ES2022, true) +} + +function find(root: ts.Node, match: (node: ts.Node) => node is T): T { + let found: T | undefined + const visit = (node: ts.Node) => { + if (match(node)) found = node + if (!found) ts.forEachChild(node, visit) + } + visit(root) + assert.ok(found, 'production route source exists') + return found +} + +function compile(source: string, exports: string[], dependencies: Record) { + const output = ts.transpileModule(source, { + compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.None }, + }).outputText + return new Function(...Object.keys(dependencies), `${output}\nreturn { ${exports.join(', ')} }`)(...Object.values(dependencies)) +} + +const printer = ts.createPrinter() +const providerSource = readSource('provider-runtime.ts') +const ipcSource = readSource('ipc/workspace-ipc.ts') +const routeNames = ['selectedProviderAccountId', 'runtimeProvider', 'resolveProjectProvider'] +const functions = routeNames.map((name) => { + const declaration = find(providerSource, (node): node is ts.FunctionDeclaration => ts.isFunctionDeclaration(node) && node.name?.text === name) + return printer.printNode(ts.EmitHint.Unspecified, declaration, providerSource).replace(/^export /, '') +}).join('\n') +const call = find(ipcSource, (node): node is ts.CallExpression => + ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'handle' + && ts.isStringLiteral(node.arguments[0]) && node.arguments[0].text === 'threads:create') +const handler = printer.printNode(ts.EmitHint.Expression, call.arguments[1], ipcSource) + +const provider = { + id: 'fixture', name: 'Fixture', kind: 'local', models: ['base-model'], defaultAccountId: 'named', + accounts: [{ id: 'named', name: 'Named fixture', models: ['named-model'] }], +} +const project = { id: 'project', defaultProviderId: provider.id, defaultProviderAccountId: null, defaultModel: 'base-model' } +const store = { + settings: { providers: [provider], activeProviderId: provider.id, activeProviderAccountId: 'named', activeModel: 'named-model' }, + projects: [project], threads: [] as Array<{ providerAccountId: string | null; model: string }>, +} +const route = compile(functions, routeNames, { store, providerWithAccount, resolveProviderModel, selectProviderAccount }) +let sequence = 0 +const persisted: Array<{ providerAccountId: string | null; model: string }> = [] +const { create } = compile(`const create = ${handler}`, ['create'], { + store, ...route, resolveProviderModel, + requireSecurityRole() {}, + workspaceMutationGuard: { reserveStart: () => ({ release() {} }) }, + spine: () => null, + privateCreateCommands: new Map(), + randomUUID: () => String(++sequence), + dirExists: async () => true, + persistThreads: () => { persisted.push(structuredClone(store.threads[0])) }, + remoteServer: { publish() {} }, + assertThreadMemoryTransport() {}, +}) + +for (const kind of ['chat', 'task']) { + const thread = await create(null, { cwd: '/fixture', kind, projectId: project.id }) + assert.deepEqual([thread.providerAccountId, thread.model], [null, 'base-model']) + const record = persisted.at(-1) + assert.deepEqual([record?.providerAccountId, record?.model], [null, 'base-model']) +} + +const noAccount = route.resolveProjectProvider({ ...project, defaultProviderAccountId: undefined }) +assert.deepEqual([noAccount.providerAccountId, noAccount.model], ['named', 'named-model']) +const noProjectProvider = route.resolveProjectProvider({ ...project, defaultProviderId: null }) +assert.equal(noProjectProvider.providerAccountId, 'named') +store.projects.push({ ...project, id: 'missing-provider', defaultProviderId: 'missing' }) +const inherited = await create(null, { cwd: '/fixture', kind: 'chat', projectId: 'missing-provider' }) +assert.deepEqual([inherited.providerAccountId, inherited.model], ['named', 'named-model']) +const explicitOverride = route.resolveProjectProvider(project, 'named') +assert.deepEqual([explicitOverride.providerAccountId, explicitOverride.model], ['named', 'named-model']) + +console.log('Project Chat and Task persist the selected provider key and retain inherited or explicitly named accounts') diff --git a/app/electron/main/host/ticket-worker-evidence.test.ts b/app/electron/main/host/ticket-worker-evidence.test.ts new file mode 100644 index 00000000000..d413c9885da --- /dev/null +++ b/app/electron/main/host/ticket-worker-evidence.test.ts @@ -0,0 +1,139 @@ +import assert from 'node:assert/strict' +import { ticketReviewGateState } from '../../agent/tickets' +import type { AgentEvent, Job, Thread, Ticket, TimelineItem } from '../../agent/types' +import { store } from '../state' +import { createTicketWorkerRuntime } from './ticket-worker-runtime' + +const oldDiff = { id: 'old-diff', kind: 'tool', path: 'src/parser.ts', state: 'ok', diff: [{ type: 'add', text: 'const value = 1' }] } as TimelineItem +const oldTest = { id: 'old-test', kind: 'tool', command: 'npm test', output: '2 passed', state: 'ok' } as TimelineItem +const currentRead = { id: 'current-read', kind: 'tool', path: 'src/parser.ts', state: 'ok' } as TimelineItem +const currentTest = { id: 'current-test', kind: 'tool', command: 'npm test', output: '3 passed', state: 'ok' } as TimelineItem + +interface Scenario { + phase?: 'build' | 'review' + rewrite?: 'trim' | 'replace' | 'reverse' | 'remove-current' + interrupted?: boolean +} + +function applyEvent(thread: Thread, event: AgentEvent): void { + if (event.type === 'item_add') thread.timeline.push(structuredClone(event.item)) + else if (event.type === 'item_update') Object.assign(thread.timeline.find((item) => item.id === event.id) ?? {}, event.patch) + else if (event.type === 'item_delta') { + const item = thread.timeline.find((candidate) => candidate.id === event.id) + if (item) item[event.field] = (item[event.field] ?? '') + event.chunk + } +} + +let passed = 0 +async function scenario(previous: TimelineItem[], current: TimelineItem[], options: Scenario = {}) { + const saved = { tickets: store.tickets, projects: store.projects, rooms: store.rooms, threads: store.threads, settings: store.settings } + const phase = options.phase ?? 'review' + const thread = { + id: 'reused-thread', projectId: 'project', title: 'Inspect parser', kind: 'task', cwd: '/workspace/project', + providerId: 'fixture', model: 'fixture', + status: 'idle', timeline: structuredClone(previous), apiMessages: [], createdAt: 1, updatedAt: 1, + } as Thread + const ticket = { + id: 'ticket', projectId: 'project', threadId: thread.id, title: 'Inspect parser', body: '', type: 'task', + status: 'review', priority: 'medium', effort: 'small', tags: [], order: 0, createdAt: 1, updatedAt: 1, + parentId: null, assignee: 'Builder', runState: null, + risk: 'high', allowedCapabilities: ['read'], + evidence: [{ id: 'builder', kind: 'file', summary: 'Inspected src/parser.ts.', createdBy: 'Builder', createdAt: 10 }], + } as Ticket + const provider = { id: 'fixture', name: 'Fixture', kind: 'local', models: ['fixture'], baseUrl: 'http://127.0.0.1:9897/v1', apiKey: '' } as const + const aborters = new Map() + let released = false, outcome: string | null = null, savedTimeline: TimelineItem[] = [], published = 0 + let settled!: () => void + const completion = new Promise((resolve) => { settled = resolve }) + let timer: ReturnType | undefined + try { + store.tickets = [ticket] + store.projects = [{ id: 'project', name: 'Fixture project', cwd: thread.cwd, memory: '', team: '', createdAt: 1, updatedAt: 1 }] + store.rooms = [] + store.threads = [thread] + store.settings = { ...saved.settings, providers: [{ ...provider, models: [...provider.models] }], activeProviderId: provider.id, activeModel: 'fixture' } + const runtime = createTicketWorkerRuntime({ + runAgent: async ({ emit, thread: active }) => { + const base = { runId: 'fixture-run', threadId: active.id } + for (const item of current) emit({ ...base, type: 'item_add', item: structuredClone(item) }) + if (options.rewrite === 'trim') active.timeline.splice(0, previous.length) + if (options.rewrite === 'replace') active.timeline = [] + if (options.rewrite === 'reverse') active.timeline.reverse() + if (options.rewrite === 'remove-current') { + active.timeline = active.timeline.filter((item) => item.id !== currentTest.id) + emit({ ...base, type: 'item_update', id: currentTest.id, patch: { state: 'ok', output: '3 ' } }) + emit({ ...base, type: 'item_delta', id: currentTest.id, field: 'output', chunk: 'passed' }) + } + emit({ ...base, type: 'item_update', id: oldDiff.id, patch: { state: 'ok' } }) + if (options.interrupted) aborters.get(active.id)!.abort() + savedTimeline = structuredClone(active.timeline) + }, + resolveWorkspaceCwd: async () => '/workspace/project', + inspectGitRepository: async () => ({ branch: 'fixture' }) as any, + persistThreads() {}, persistTickets() {}, emitTicket() { published++ }, appendRoomSupervisorEvent() {}, + claimJob: () => ({ id: 'job' }) as Job, patchJob: (job) => job, fullToolContext: () => ({}), + drainThreadCues: () => [], waitForThreadCue: async () => {}, approvalResolver: () => async () => 'deny', + timelineErrorSince: (active, start) => active.timeline.slice(start).find((item) => item.kind === 'error') ?? null, + timelineError: () => new Error('Synthetic agent error'), isHighRiskTool: () => false, emitToRenderer() {}, + addThreadNotice() {}, auditModelRoute: async () => {}, markRouteErrorRecovered() {}, injectThreadRouteHandoff: () => '', + aborters, workspaceMutationGuard: { + assertThreadStartAllowed() {}, + reserveStart: () => ({ addWorkspaceKeys() {}, addThreadId() {}, release() { released = true } }), + }, + applyEventToThread: applyEvent, activeJob: () => null, + finishJob: (_job, result) => { outcome = result; settled() }, markUndrainedCues() {}, effectiveContextLimit: () => 4096, + }) + assert.equal(await runtime.startTicketWork({ ticketId: ticket.id, opts: { phase } }), thread) + await Promise.race([completion, new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('Worker settlement timed out')), 2000) })]) + assert.ok(released, 'the production finalizer releases its run reservation') + assert.equal(aborters.size, 0, 'the production finalizer clears the active worker') + assert.equal(published, 2, 'startup and settlement both publish the ticket') + assert.equal(runtime.isTicketStarting(ticket.id), false) + assert.deepEqual(thread.timeline, savedTimeline, 'settlement leaves live conversation history intact') + passed++ + return { ticket, outcome } + } finally { + clearTimeout(timer) + Object.assign(store, saved) + } +} + +const clean = await scenario([oldDiff, oldTest], [currentRead, currentTest]) +assert.equal(clean.ticket.evidence!.filter((item) => item.kind === 'diff').length, 0, 'old diffs are not reviewer-made changes') +assert.equal(clean.ticket.status, 'completed') +assert.equal(clean.outcome, 'completed') +assert.equal(ticketReviewGateState(clean.ticket).hasReviewOrSkipAfterBuilder, true) +assert.equal(ticketReviewGateState(clean.ticket).builderEvidenceBy, 'Builder') + +for (const rewrite of ['trim', 'replace', 'reverse', 'remove-current'] as const) { + const result = await scenario([oldDiff, oldTest], [currentRead, currentTest], { rewrite }) + assert.deepEqual(result.ticket.execution!.checks, [{ command: 'npm test', passed: true }], `${rewrite} retains this run's verification`) + assert.ok(!result.ticket.evidence!.some((item) => item.kind === 'diff'), `${rewrite} excludes historical diffs`) +} + +const recovered = await scenario([{ id: 'old-error', kind: 'error', text: 'Previous run failed.' } as TimelineItem], [currentRead, currentTest]) +assert.equal(recovered.ticket.status, 'completed', 'old errors do not fail this review') + +const noCurrentTest = await scenario([oldTest], [currentRead]) +assert.ok(!noCurrentTest.ticket.evidence!.some((item) => item.kind === 'test')) +assert.deepEqual(noCurrentTest.ticket.execution!.checks, []) + +const changed = await scenario([], [{ ...oldDiff, id: 'current-diff' }, currentTest]) +assert.ok(changed.ticket.evidence!.some((item) => item.kind === 'diff')) +assert.equal(ticketReviewGateState(changed.ticket).hasReviewOrSkipAfterBuilder, false, 'reviewer-made changes need independent review') + +const failed = await scenario([], [{ id: 'current-error', kind: 'error', text: 'This review failed.' } as TimelineItem], { rewrite: 'replace' }) +assert.equal(failed.ticket.status, 'needs_clarification') +assert.equal(failed.outcome, 'failed') +assert.ok(failed.ticket.evidence!.some((item) => item.kind === 'review' && item.summary.includes('blocked'))) + +const rebuilt = await scenario([oldDiff, oldTest], [currentRead], { phase: 'build' }) +assert.equal(rebuilt.ticket.status, 'review') +assert.equal(rebuilt.outcome, 'completed') +assert.ok(!rebuilt.ticket.evidence!.some((item) => item.kind === 'test' || item.kind === 'diff')) + +const interrupted = await scenario([oldTest], [currentRead], { interrupted: true }) +assert.equal(interrupted.ticket.status, 'in_progress') +assert.equal(interrupted.ticket.runState, null) +assert.equal(interrupted.outcome, 'paused') +console.log(`ticket worker evidence: ${passed} exported-runtime scenarios passed`) diff --git a/app/electron/main/host/ticket-worker-runtime.ts b/app/electron/main/host/ticket-worker-runtime.ts index 80afcc2fb34..b0c6c5fbb2b 100644 --- a/app/electron/main/host/ticket-worker-runtime.ts +++ b/app/electron/main/host/ticket-worker-runtime.ts @@ -63,6 +63,9 @@ export async function awaitTicketStartupStep(pending: Promise, revalidate: } interface TicketWorkerRuntimeDeps { + runAgent?: typeof runAgent + resolveWorkspaceCwd?: typeof resolveWorkspaceCwd + inspectGitRepository?: typeof inspectGitRepository persistThreads(): void persistTickets(): void emitTicket(ticket: Ticket): void @@ -92,6 +95,9 @@ interface TicketWorkerRuntimeDeps { export function createTicketWorkerRuntime(deps: TicketWorkerRuntimeDeps): TicketWorkerRuntime { const { + runAgent: executeAgent = runAgent, + resolveWorkspaceCwd: resolveWorkerCwd = resolveWorkspaceCwd, + inspectGitRepository: inspectWorkerGit = inspectGitRepository, persistThreads, persistTickets, emitTicket, @@ -178,12 +184,12 @@ async function startTicketWork(input: TicketWorkerInput): Promise { : await runtimeProviderWithFreshModels(routeBaseProvider, providerAccountId) let model = resolvedRoute.model assertProviderEndpoint(provider) - const cwd = await resolveWorkspaceCwd(roomWorkspace || project?.cwd || store.settings.defaultCwd, 'ticket workspace') + const cwd = await resolveWorkerCwd(roomWorkspace || project?.cwd || store.settings.defaultCwd, 'ticket workspace') assertActiveTicketWorkOwnership(ticket, project, room, existingThread) const executionBranch = await awaitTicketStartupStep( - inspectGitRepository(cwd, 'ticket workspace').then((repo) => repo.branch).catch(() => null), + inspectWorkerGit(cwd, 'ticket workspace').then((repo) => repo.branch).catch(() => null), () => assertActiveTicketWorkOwnership(ticket, project, room, existingThread), ) @@ -211,6 +217,8 @@ async function startTicketWork(input: TicketWorkerInput): Promise { store.threads.unshift(thread); persistThreads() sendToRenderer('thread:update', thread) } + const previousItemIds = new Set(thread.timeline.map((item) => item.id)) + const runItems = new Map() ticket.threadId = thread.id ticket.status = 'in_progress' ticket.runState = 'running' @@ -264,7 +272,21 @@ async function startTicketWork(input: TicketWorkerInput): Promise { emitToRenderer({ runId: '', threadId: thread.id, type: 'item_add', item: userItem }) const t = thread - const emit = (e: AgentEvent) => { applyEventToThread(t, e); emitToRenderer(e) } + const emit = (e: AgentEvent) => { + applyEventToThread(t, e) + if (e.threadId === t.id && e.type === 'item_add' && !previousItemIds.has(e.item.id)) { + runItems.set(e.item.id, t.timeline.find((item) => item.id === e.item.id) ?? structuredClone(e.item)) + } else if (e.threadId === t.id && (e.type === 'item_update' || e.type === 'item_delta')) { + const owned = runItems.get(e.id) + if (owned) { + const live = t.timeline.find((item) => item.id === e.id) + if (live) runItems.set(e.id, live) + else if (e.type === 'item_update') Object.assign(owned, structuredClone(e.patch)) + else owned[e.field] = (owned[e.field] ?? '') + e.chunk + } + } + emitToRenderer(e) + } t.cwd = cwd t.providerId = baseProvider.id t.providerAccountId = providerAccountId @@ -301,7 +323,7 @@ async function startTicketWork(input: TicketWorkerInput): Promise { fullToolContext({ thread: t, provider: route.provider, model: route.model, signal: controller.signal }), allowedCapabilities, ) - await runAgent({ + await executeAgent({ responseLocale: selectedResponseLocale(store.settings.uiPreferences), thread: t, provider: route.provider, @@ -396,7 +418,8 @@ async function startTicketWork(input: TicketWorkerInput): Promise { markUndrainedCues(t, controller.signal.aborted ? 'canceled' : 'run ended') aborters.delete(t.id) runLease.release() - const failed = t.timeline.some((i) => i.kind === 'error') + const runTimeline = [...runItems.values()] + const failed = runTimeline.some((i) => i.kind === 'error') const interrupted = controller.signal.aborted t.status = failed ? 'error' : 'idle'; t.updatedAt = Date.now() // When the run was aborted/paused (no completion), park the ticket without @@ -406,7 +429,7 @@ async function startTicketWork(input: TicketWorkerInput): Promise { ticket.runState = settled.runState ticket.status = settled.status ticket.updatedAt = Date.now() - const summary = summarizeTicketWorkerOutcome(ticket, t, phase, failed, input.source?.seat ?? model) + const summary = summarizeTicketWorkerOutcome(ticket, { ...t, timeline: runTimeline }, phase, failed, input.source?.seat ?? model) if (ticket.execution) { ticket.execution = settleTicketExecution(ticket.execution, { outcome: { phase, failed, interrupted }, diff --git a/app/electron/main/host/update-schedule.test.ts b/app/electron/main/host/update-schedule.test.ts new file mode 100644 index 00000000000..beb555417f5 --- /dev/null +++ b/app/electron/main/host/update-schedule.test.ts @@ -0,0 +1,101 @@ +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { createRequire } from 'node:module' +import { mock } from 'node:test' +import ts from 'typescript' + +const requireBuiltin = createRequire(__filename) +const source = readFileSync(new URL('./updates.ts', import.meta.url), 'utf8') +const compiled = ts.transpileModule(source, { + compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS }, +}).outputText + +function updater() { + const settings = { autoCheckUpdates: true } + const store = { settings, updateStatus: { state: 'idle' } } + const requests: string[] = [] + const feed = 'https://synthetic.invalid/feed' + const imports: Record = { + electron: { app: { getVersion: () => '1.0.0', isPackaged: false } }, + '../../../build/release-trust.json': {}, + '../../agent/update-checker': { + emptyUpdateStatus: () => ({ state: 'idle' }), + checkingUpdateStatus: () => ({ state: 'checking' }), + checkUpdateFeed: async (url: string) => { + requests.push(url) + return { state: 'current' } + }, + }, + '../../agent/update-feed': { resolveUpdateFeedUrl: () => feed }, + '../../agent/security': { assertUpdateFeedUrl: (url: string) => assert.equal(url, feed) }, + '../../store': {}, + '../state': { store }, + './audit': {}, + '../../agent/update-download': {}, + '../../agent/update-trust': {}, + '../../agent/update-install': {}, + './ipc': {}, + './update-profile': {}, + } + const loaded = { exports: {} as typeof import('./updates') } + new Function('require', 'module', 'exports', compiled)((id: string) => { + if (id.startsWith('node:')) return requireBuiltin(id) + assert.ok(Object.hasOwn(imports, id), `Reviewed updater import ${id}`) + return imports[id] + }, loaded, loaded.exports) + return { ...loaded.exports, settings, requests, feed } +} + +async function advance(ms: number) { + mock.timers.tick(ms) + // Let the synthetic feed response finish before advancing to another due callback. + for (let i = 0; i < 12; i++) await Promise.resolve() +} + +async function withClock(run: () => Promise) { + mock.timers.enable({ apis: ['setTimeout', 'setInterval'] }) + try { await run() } + finally { mock.timers.reset() } +} + +await withClock(async () => { + const update = updater() + update.startUpdateChecks() + await advance(100) + update.settings.autoCheckUpdates = false + update.startUpdateChecks() + await advance(6 * 60 * 60_000) + assert.deepEqual(update.requests, [], 'turning automatic checks off cancels the pending first check and interval') + await update.checkForAppUpdate() + assert.deepEqual(update.requests, [update.feed], 'a manual check still works when automatic checks are off') +}) + +await withClock(async () => { + const update = updater() + update.startUpdateChecks() + await advance(100) + // Settings are persisted before the asynchronous post-save work reschedules checks. + update.settings.autoCheckUpdates = false + await advance(1500) + assert.deepEqual(update.requests, [], 'the first callback honors saved Off before rescheduling') + await advance(6 * 60 * 60_000) + assert.deepEqual(update.requests, [], 'the periodic callback also honors saved Off before rescheduling') +}) + +await withClock(async () => { + const update = updater() + update.startUpdateChecks() + await advance(100) + update.startUpdateChecks() + await advance(100) + update.startUpdateChecks() + await advance(1300) + await advance(100) + assert.deepEqual(update.requests, [], 'staggered settings saves cancel the older first checks') + await advance(100) + assert.deepEqual(update.requests, [update.feed], 'only the latest first check reaches the feed') + await advance(6 * 60 * 60_000 - 1500) + assert.deepEqual(update.requests, [update.feed, update.feed], 'automatic checks keep their six-hour interval') +}) + +console.log('Automatic update checks honor saved preferences and coalesce settings reschedules') diff --git a/app/electron/main/host/updates.ts b/app/electron/main/host/updates.ts index e4b7c9eba28..5638e831b04 100644 --- a/app/electron/main/host/updates.ts +++ b/app/electron/main/host/updates.ts @@ -40,6 +40,7 @@ export function signedUpdatesRequired(): boolean { } let updateTimer: ReturnType | null = null +let initialUpdateTimer: ReturnType | null = null let updateCheckInFlight: Promise | null = null let updateDownloadInFlight: Promise<{ ok: boolean }> | null = null let downloadController: AbortController | null = null @@ -118,11 +119,18 @@ export async function checkForAppUpdate(): Promise { export function startUpdateChecks() { if (updateTimer) { clearInterval(updateTimer); updateTimer = null } + if (initialUpdateTimer) { clearTimeout(initialUpdateTimer); initialUpdateTimer = null } const feedUrl = updateFeedUrl() if (!busy()) setUpdateStatus(emptyUpdateStatus(app.getVersion(), feedUrl || null)) if (!store.settings?.autoCheckUpdates || !feedUrl) return - setTimeout(() => { void checkForAppUpdate() }, 1500) - updateTimer = setInterval(() => { void checkForAppUpdate() }, 6 * 60 * 60_000) + const checkIfEnabled = () => { + if (store.settings?.autoCheckUpdates) void checkForAppUpdate() + } + initialUpdateTimer = setTimeout(() => { + initialUpdateTimer = null + checkIfEnabled() + }, 1500) + updateTimer = setInterval(checkIfEnabled, 6 * 60 * 60_000) } export async function openUpdateDownload(): Promise<{ ok: boolean }> { diff --git a/app/src/components/ExportPanel.test.tsx b/app/src/components/ExportPanel.test.tsx new file mode 100644 index 00000000000..c94f52d734b --- /dev/null +++ b/app/src/components/ExportPanel.test.tsx @@ -0,0 +1,129 @@ +import assert from 'node:assert/strict' +import { find, harness, jsx, load, settle, text } from './reading/reading-test-harness' + +type Request = { threadId: string; options: { mode: string; redact: boolean } } +const hook = harness() +hook.hooks.useCallback = (callback: unknown) => hook.hooks.useRef(callback).current +const builds: (Request & { finish: (label: string) => void; fail: () => void })[] = [] +const saves: (Request & { finish: () => void })[] = [] +const copies: { json: string; finish: () => void }[] = [] +const windowFixture = new EventTarget() +Object.defineProperty(globalThis, 'window', { configurable: true, value: windowFixture }) +Object.defineProperty(globalThis, 'navigator', { configurable: true, value: { + clipboard: { writeText: (json: string) => new Promise((finish) => copies.push({ json, finish })) }, +} }) + +const api = { + buildExport: (threadId: string, options: Request['options']) => new Promise((resolve, reject) => { + builds.push({ + threadId, + options, + finish: (label) => resolve({ json: label, bundle: { + thread: { title: label }, + stats: { messages: 0, toolCalls: 0, diffs: 0, denied: 0, errors: 0 }, + redactionReport: [], + } }), + fail: () => reject(new Error('synthetic build failure')), + }) + }), + saveExport: (threadId: string, options: Request['options']) => new Promise((resolve) => { + saves.push({ threadId, options, finish: () => resolve({ saved: true }) }) + }), +} +const { ExportPanel } = load('src/components/ExportPanel.tsx', { + react: hook.hooks, 'react/jsx-runtime': jsx, + clsx: (...classes: string[]) => classes.filter(Boolean).join(' '), + '../lib/ipc': { api }, '../lib/icons': { Icon: () => null }, +}) +const render = () => hook.render(() => ExportPanel()) +const open = () => windowFixture.dispatchEvent(new CustomEvent('vontra:export', { detail: { threadId: 'test-run' } })) +const button = (tree: ReturnType, label: string) => find(tree, (node) => node.type === 'button' && text(node) === label) +const setRedact = (checked: boolean) => find(render(), (node) => node.type === 'input').props.onChange({ target: { checked } }) +const preview = (tree: ReturnType) => text(find(tree, (node) => node.type === 'pre')) +const assertUnavailable = (tree: ReturnType) => { + assert.equal(button(tree, 'Copy JSON').props.disabled, true) + assert.equal(button(tree, 'Save…').props.disabled, true) +} + +render() +hook.flush() +open() +render() +hook.flush() +builds[0].finish('first preview') +await settle() +const ready = render() +assert.equal(preview(ready), 'first preview') +assert.equal(button(ready, 'Copy JSON').props.disabled, false) +assert.equal(button(ready, 'Save…').props.disabled, false) +const copy = button(ready, 'Copy JSON').props.onClick +const save = button(ready, 'Save…').props.onClick +const copying = copy() +const saving = save() +assert.equal(copies[0].json, 'first preview') +assert.deepEqual(saves[0].options, { mode: 'full', redact: true }) + +setRedact(false) +const staleCopy = copy() +const staleSave = save() +const pending = render() +assert.equal(preview(pending), 'Building…') +assert.equal(text(pending).includes('first preview'), false) +assertUnavailable(pending) +await Promise.all([staleCopy, staleSave]) +assert.equal(copies.length, 1) +assert.equal(saves.length, 1) +hook.flush() +assert.deepEqual(builds[1].options, { mode: 'full', redact: false }) +setRedact(true) +render() +hook.flush() +assert.deepEqual(builds[2].options, { mode: 'full', redact: true }) +copies[0].finish() +saves[0].finish() +await Promise.all([copying, saving]) +assert.equal(text(render()).includes('Saved'), false) +assertUnavailable(render()) +builds[2].finish('replacement preview') +await settle() +builds[1].fail() +await settle() +assert.equal(preview(render()), 'replacement preview') + +button(render(), 'Share packet').props.onClick() +render() +hook.flush() +assert.deepEqual(builds[3].options, { mode: 'share', redact: true }) +builds[3].fail() +await settle() +assert.equal(preview(render()), 'Nothing to export.') +assertUnavailable(render()) +button(render(), 'Full run').props.onClick() +render() +hook.flush() +button(render(), 'esc').props.onClick() +assert.equal(render(), null) +hook.flush() +open() +assertUnavailable(render()) +hook.flush() +assert.equal(builds[5].threadId, 'test-run') +builds[4].finish('closed preview') +await settle() +assert.equal(preview(render()), 'Building…') +assertUnavailable(render()) +builds[5].finish('reopened preview') +await settle() +const reopened = render() +assert.equal(preview(reopened), 'reopened preview') +const reopenedCopy = button(reopened, 'Copy JSON').props.onClick() +const reopenedSave = button(reopened, 'Save…').props.onClick() +assert.equal(copies[1].json, 'reopened preview') +assert.equal(saves[1].threadId, 'test-run') +assert.deepEqual(saves[1].options, { mode: 'full', redact: true }) +copies[1].finish() +saves[1].finish() +await Promise.all([reopenedCopy, reopenedSave]) +assert.ok(button(render(), 'Copied')) +assert.equal(text(render()).includes('Saved'), true) +hook.cleanup() diff --git a/app/src/components/ExportPanel.tsx b/app/src/components/ExportPanel.tsx index 51111c4e049..5c5e8d154d9 100644 --- a/app/src/components/ExportPanel.tsx +++ b/app/src/components/ExportPanel.tsx @@ -1,7 +1,7 @@ import { useAuthoredText } from '../lib/preferences/useAuthoredText' import { authoredText } from '../lib/preferences/language-packs' import { useStore as useLocaleStore } from '../lib/store' -import { useEffect, useRef, useState } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import clsx from 'clsx' import { api } from '../lib/ipc' import { Icon, type IconName } from '../lib/icons' @@ -17,40 +17,52 @@ const MODES: { id: ExportMode; label: string; icon: IconName; blurb: string }[] { id: 'eval', get label() { return authoredText(useLocaleStore.getState().settings?.uiPreferences?.locale, "Eval replay") }, icon: 'spark', blurb: 'Replay skeleton — prompts, tool calls and outcomes only; reasoning dropped, anonymized.' }, ] +type ExportSelection = { threadId: string; mode: ExportMode; redact: boolean } +type ExportPreview = { selection: ExportSelection; result: ExportResult | null } + export function ExportPanel() { const tx = useAuthoredText() - const [threadId, setThreadId] = useState(null) - const [mode, setMode] = useState('full') - const [redact, setRedact] = useState(true) - const [result, setResult] = useState(null) - const [building, setBuilding] = useState(false) + const [selection, setSelection] = useState(null) + const [preview, setPreview] = useState(null) const [saved, setSaved] = useState(null) const [copied, setCopied] = useState(false) - const reqRef = useRef(0) + const selectionRef = useRef(selection) + const choose = useCallback((next: ExportSelection | null) => { + selectionRef.current = next + setSelection(next) + setPreview(null) + setSaved(null) + setCopied(false) + }, []) useEffect(() => { const onOpen = (e: Event) => { const id = (e as CustomEvent).detail?.threadId - if (typeof id !== 'string') return - setThreadId(id); setMode('full'); setRedact(true); setSaved(null); setCopied(false) + if (typeof id !== 'string' || !id) return + choose({ threadId: id, mode: 'full', redact: true }) } window.addEventListener('vontra:export', onOpen as EventListener) return () => window.removeEventListener('vontra:export', onOpen as EventListener) - }, []) + }, [choose]) - // Rebuild the bundle whenever the target or options change (request-id guards races). useEffect(() => { - if (!threadId) { setResult(null); return } - const req = ++reqRef.current - setBuilding(true); setSaved(null); setCopied(false) + if (!selection) return + const { threadId, mode, redact } = selection + let active = true + const finish = (result: ExportResult | null) => { + if (active && selectionRef.current === selection) setPreview({ selection, result }) + } api.buildExport(threadId, { mode, redact }) - .then((r) => { if (req === reqRef.current) setResult(r) }) - .catch(() => { if (req === reqRef.current) setResult(null) }) - .finally(() => { if (req === reqRef.current) setBuilding(false) }) - }, [threadId, mode, redact]) - - if (!threadId) return null - const close = () => setThreadId(null) + .then(finish, () => finish(null)) + return () => { active = false } + }, [selection]) + + if (!selection) return null + const { threadId, mode, redact } = selection + const currentPreview = preview?.selection === selection ? preview : null + const building = currentPreview === null + const result = currentPreview?.result + const close = () => { if (selectionRef.current === selection) choose(null) } const bundle = result?.bundle const totalRedactions = bundle?.redactionReport.reduce((n, r) => n + r.count, 0) ?? 0 const evidence = bundle?.evidence @@ -59,13 +71,18 @@ export function ExportPanel() { : 0 const onCopy = async () => { - if (!result) return - try { await navigator.clipboard.writeText(result.json); setCopied(true); setTimeout(() => setCopied(false), 1600) } catch { /* clipboard blocked */ } + if (!result || selectionRef.current !== selection) return + try { + await navigator.clipboard.writeText(result.json) + if (selectionRef.current !== selection) return + setCopied(true) + setTimeout(() => { if (selectionRef.current === selection) setCopied(false) }, 1600) + } catch { /* clipboard blocked */ } } const onSave = async () => { - if (!threadId) return + if (!result || selectionRef.current !== selection) return const res = await api.saveExport(threadId, { mode, redact }) - if (res.saved) setSaved(res.path ?? 'saved') + if (res.saved && selectionRef.current === selection) setSaved(res.path ?? 'saved') } return ( @@ -86,7 +103,9 @@ export function ExportPanel() { {/* mode picker */}
{MODES.map((m) => ( - ))} @@ -95,7 +114,9 @@ export function ExportPanel() { {/* redaction control */}
- 0} /> + 0} /> 0} />
diff --git a/app/src/components/search/ConversationSearchHost.tsx b/app/src/components/search/ConversationSearchHost.tsx index f7cbdf939e6..d900b24d9ee 100644 --- a/app/src/components/search/ConversationSearchHost.tsx +++ b/app/src/components/search/ConversationSearchHost.tsx @@ -31,6 +31,7 @@ export function ConversationSearchHost({ navigationBlocked = false }: { navigati const [open, setOpen] = useState(false), [query, setQuery] = useState('') const [scope, setScope] = useState<'all' | 'thread'>('all'), [projectId, setProjectId] = useState('') const [archived, setArchived] = useState(false), [selected, setSelected] = useState(0), [retry, setRetry] = useState(0) + const scopedProjectId = scope === 'all' ? projectId : '' const panel = useRef(null), input = useRef(null) const close = () => { client.clear(); setOpen(false); setQuery('') } useAccessibleDialog({ open, onClose: close, dialogRef: panel, initialFocusRef: input }) @@ -54,19 +55,19 @@ export function ConversationSearchHost({ navigationBlocked = false }: { navigati useEffect(() => { client.clear(); setSelected(0) if (!open || filterState.error || scope === 'thread' && !activeThreadId) return - const timer = setTimeout(() => void client.search({ scope, query, ...(scope === 'thread' ? { threadId: activeThreadId } : {}), ...(projectId ? { projectId } : {}), includeArchived: archived, filters: filterState.filters, limit: 50 }), 180) + const timer = setTimeout(() => void client.search({ scope, query, ...(scope === 'thread' ? { threadId: activeThreadId } : {}), ...(scopedProjectId ? { projectId: scopedProjectId } : {}), includeArchived: archived, filters: filterState.filters, limit: 50 }), 180) return () => { clearTimeout(timer); client.clear() } - }, [open, query, scope, activeThreadId, projectId, archived, filterKey, filterState.error, retry, client]) + }, [open, query, scope, activeThreadId, scopedProjectId, archived, filterKey, filterState.error, retry, client]) const ownsState = open && state.request?.query === query.trim().replace(/\s+/g, ' ') && state.request.scope === scope && (scope !== 'thread' || state.request.threadId === activeThreadId) - && (state.request.projectId ?? '') === projectId && !!state.request.includeArchived === archived && !filterState.error && conversationSearchFilterKey(state.request.filters) === filterKey + && (state.request.projectId ?? '') === scopedProjectId && !!state.request.includeArchived === archived && !filterState.error && conversationSearchFilterKey(state.request.filters) === filterKey const filterThreads = (threads ?? []).filter(thread => !thread.orchestratorHostId && (scope === 'thread' ? thread.id === activeThreadId : !thread.incognito && !thread.phoneLocalOnly && !thread.googleLocalOnly && !thread.bot && (archived || !thread.archivedAt)) - && (!projectId || thread.projectId === projectId)) + && (!scopedProjectId || thread.projectId === scopedProjectId)) const current = ownsState ? state : { result: null, error: '', busy: false } const matches = current.result?.matches ?? [] const navigationOwner = useRef('') - const ownership = JSON.stringify([open, scope, query.trim().replace(/\s+/g, ' '), activeThreadId, projectId, archived, filterKey, filterState.error, navigationBlocked]) + const ownership = JSON.stringify([open, scope, query.trim().replace(/\s+/g, ' '), activeThreadId, scopedProjectId, archived, filterKey, filterState.error, navigationBlocked]) navigationOwner.current = ownership useEffect(() => { document.getElementById(`conversation-search-result-${selected}`)?.scrollIntoView({ block: 'nearest' }) diff --git a/app/src/components/search/usability-search.integration.test.tsx b/app/src/components/search/usability-search.integration.test.tsx index 22aa0e96e6a..46e31f62a6e 100644 --- a/app/src/components/search/usability-search.integration.test.tsx +++ b/app/src/components/search/usability-search.integration.test.tsx @@ -69,6 +69,49 @@ assert.equal(nodes(tree).some((node) => node.type === 'result-fixture'), false); input().props.onChange({ target: { value: 'late' } }); await commit(); tickTimers(); await commit() find(render(), (node) => node.type === 'button' && text(node) === 'Close search').props.onClick(); await commit() resolve(4, 'late', [match('late', 'current')]); await settle(); assert.equal(render(), null, 'Closing search discards delayed private snippets') + +store.projects = [{ id: 'project-a', name: 'Project A' }, { id: 'project-b', name: 'Project B' }] +store.threads = [{ id: 'thread-a', projectId: 'project-a' }, { id: 'current', projectId: 'project-b' }] +const picker = (label: string) => find(render(), (node) => node.type === 'select' && node.props['aria-label'] === label) +const nextSearch = async () => { + const index = pending.length + await commit() + tickTimers() + await commit() + assert.equal(pending.length, index + 1) + return index +} +events.requestConversationSearch({ scope: 'all', query: 'needle' }) +await commit() +picker('Conversation search project').props.onChange({ target: { value: 'project-a' } }) +find(render(), (node) => node.type === 'input' && node.props.type === 'checkbox').props.onChange({ target: { checked: true } }) +const projectSearch = await nextSearch() +assert.equal(pending[projectSearch].request.projectId, 'project-a') +assert.equal(pending[projectSearch].request.includeArchived, true) +resolve(projectSearch, 'needle', [{ ...match('needle', 'thread-a'), projectId: 'project-a' }]) +await settle() +const oldProjectRow = find(render(), (node) => node.type === 'result-fixture') +assert.ok(oldProjectRow) + +picker('Conversation search scope').props.onChange({ target: { value: 'thread' } }) +assert.equal(picker('Conversation search project'), undefined, 'the project filter is hidden in current-conversation scope') +oldProjectRow.props.onOpen() +assert.deepEqual(opened, [], 'a cached global project result cannot navigate once the scope changes') +const currentSearch = await nextSearch() +const currentRequest = pending[currentSearch].request +assert.equal(currentRequest.scope, 'thread') +assert.equal(currentRequest.threadId, 'current') +assert.equal(currentRequest.projectId, undefined, 'a global project filter must not restrict the current conversation') +assert.deepEqual(find(render(), (node) => node.type === 'filter-controls').props.threads, [store.threads[1]]) +resolve(currentSearch, 'needle', [{ ...match('needle', 'current'), projectId: 'project-b' }]) +await settle() +assert.equal(find(render(), (node) => node.type === 'result-fixture').props.match.threadId, 'current') + +picker('Conversation search scope').props.onChange({ target: { value: 'all' } }) +const restoredSearch = await nextSearch() +assert.equal(picker('Conversation search project').props.value, 'project-a') +assert.equal(pending[restoredSearch].request.projectId, 'project-a', 'returning to global scope restores the project filter') +assert.equal(pending[restoredSearch].request.includeArchived, true) hooks.cleanup() const anchorHooks = harness(), windowHooks = harness(), revealed: string[] = [], focused: string[] = [] diff --git a/app/src/components/terminals/TerminalLaunch.test.tsx b/app/src/components/terminals/TerminalLaunch.test.tsx new file mode 100644 index 00000000000..0936a6409e7 --- /dev/null +++ b/app/src/components/terminals/TerminalLaunch.test.tsx @@ -0,0 +1,79 @@ +import assert from 'node:assert/strict' +import * as executionTarget from '../../lib/execution-target' +import * as terminalLayout from '../../lib/terminal-layout' +import * as terminalSessions from '../../lib/terminal-sessions' +import { find, harness, jsx, load, settle, text } from '../reading/reading-test-harness' + +const hooks = harness() +const Menu = () => null +const projectId = 'fixture-project' +const codex = { id: 'codex', name: 'Codex', command: '/fixture/bin/codex', icon: 'terminal' } +const shell = { id: 'shell', name: 'Shell', command: null, icon: 'terminal' } +const hosts = [{ id: 'alpha', name: 'Alpha', enabled: true }, { id: 'bravo', name: 'Bravo', enabled: true }] +const project = { id: projectId, executionTarget: 'orchestrator', orchestratorId: 'alpha' } +const catalogs: (string | null)[] = [] +const launches: unknown[][] = [] +const state = { + settings: { remoteOrchestrators: hosts, defaultExecutionTarget: 'local', defaultOrchestratorId: 'bravo' }, + projects: [project], + terminals: {} as Record, + activeTerminalId: {}, + loadTerminals: async () => {}, + killTerminal: async () => {}, + listTerminalClis: async () => { + const target = executionTarget.resolveExecutionTarget(state.settings as any, state.projects[0] as any) + catalogs.push(target.hostId) + return target.hostId === 'bravo' ? [shell] : [codex, shell] + }, + startTerminal: async (...args: unknown[]) => { launches.push(args) }, +} +const useStore = Object.assign((select: (current: typeof state) => unknown) => select(state), { getState: () => state }) +const { TerminalsTab } = load('src/components/terminals/TerminalsTab.tsx', { + react: hooks.hooks, 'react/jsx-runtime': jsx, + '../../lib/preferences/useAuthoredText': { useAuthoredText: () => (value: string) => value }, + '../../lib/store': { useStore }, '../../lib/execution-target': executionTarget, + '../../lib/icons': { Icon: 'icon' }, '../../lib/terminal-sessions': terminalSessions, + '../../lib/terminal-layout': terminalLayout, '../ui': { Menu }, './TerminalPane': { TerminalPane: 'terminal' }, +}) +const render = () => hooks.render(() => TerminalsTab({ projectId })) +function picker(tree: any) { + const split = find(tree, (node) => node.type === Menu) + if (split) return split.props.children(() => {}) + const empty = find(tree, (node) => node.type?.name === 'EmptyState') + assert.ok(empty) + return empty.type(empty.props) +} +const button = (tree: any, name: string) => find(tree, (node) => node.type === 'button' && text(node) === name) +render(); hooks.flush(); await settle() +button(picker(render()), 'Codex').props.onClick() +assert.deepEqual(launches, [[projectId, 'codex', undefined]], 'remote empty picker sends only the registered CLI ID') +state.terminals[projectId] = [{ id: 'shell-fixture', projectId, cliId: 'shell', title: 'Shell' }] +const alphaClick = button(picker(render()), 'Codex').props.onClick +alphaClick() +assert.deepEqual(launches[1], [projectId, 'codex', undefined], 'remote Split sends only the registered CLI ID') + +state.projects = [{ ...project, orchestratorId: 'bravo' }] +alphaClick() +assert.equal(launches.length, 2, 'a stale Alpha click cannot start a CLI on Bravo') +assert.equal(button(picker(render()), 'Codex'), undefined, 'Alpha catalog disappears before Bravo responds') +hooks.flush(); await settle() +const bravoPicker = picker(render()) +assert.deepEqual(catalogs, ['alpha', 'bravo']) +assert.equal(button(bravoPicker, 'Codex'), undefined) +const bravoClick = button(bravoPicker, 'Shell').props.onClick +state.projects = [] +state.settings.defaultExecutionTarget = 'orchestrator' +bravoClick() +assert.equal(launches.length, 2, 'a deleted project cannot inherit the global host for a stale click') + +state.projects = [{ ...project, orchestratorId: 'bravo' }] +state.settings.remoteOrchestrators = [hosts[0], { ...hosts[1], enabled: false }] +bravoClick() +assert.equal(launches.length, 2, 'an unavailable remote host cannot route a stale launch locally') +state.projects = [{ ...project, executionTarget: 'local' }] +state.settings.defaultExecutionTarget = 'local' +render(); hooks.flush(); await settle() +button(picker(render()), 'Codex').props.onClick() +assert.deepEqual(launches[2], [projectId, 'codex', { command: codex.command, label: codex.name }]) +hooks.cleanup() +console.log('Terminal launch picker preserves named remote IDs, local options and host ownership') diff --git a/app/src/components/terminals/TerminalsTab.tsx b/app/src/components/terminals/TerminalsTab.tsx index 260daa2d6f2..cbc3eff2767 100644 --- a/app/src/components/terminals/TerminalsTab.tsx +++ b/app/src/components/terminals/TerminalsTab.tsx @@ -23,6 +23,15 @@ function toLauncher(c: CliDefinition): Launcher { } const EMPTY_SESSIONS: CliSession[] = [] +const EMPTY_LAUNCHERS: Launcher[] = [] + +function matchesLaunchTarget(projectId: string, hostId: string | null): boolean { + const { settings, projects } = useStore.getState() + const project = projects.find((candidate) => candidate.id === projectId) + if (!project) return false + const target = resolveExecutionTarget(settings, project) + return !target.unavailableReason && target.hostId === hostId +} // The Terminal tab. Sessions are listed in the left sidebar (renameable, click to open); this view // shows the active one, with a compact top row to start a new terminal or split the screen. @@ -46,7 +55,11 @@ export function TerminalsTab({ projectId }: { projectId: string }) { const killTerminal = useStore((s) => s.killTerminal) const loadTerminals = useStore((s) => s.loadTerminals) const listTerminalClis = useStore((s) => s.listTerminalClis) - const [installed, setInstalled] = useState([]) + const [catalog, setCatalog] = useState<{ projectId: string; hostId: string | null; launchers: Launcher[] } | null>(null) + const hostId = decision.hostId + const canLaunch = project !== null && !decision.unavailableReason + const installed = canLaunch && catalog?.projectId === projectId && catalog.hostId === hostId + ? catalog.launchers : EMPTY_LAUNCHERS const [customOpen, setCustomOpen] = useState(false) const [customCmd, setCustomCmd] = useState('') const remoteTerminal = !!decision.hostId @@ -59,16 +72,21 @@ export function TerminalsTab({ projectId }: { projectId: string }) { useEffect(() => { void loadTerminals(projectId) }, [projectId, loadTerminals]) // Only offer CLIs really installed where this project's terminal will run. useEffect(() => { + if (!canLaunch || !matchesLaunchTarget(projectId, hostId)) return let live = true - setInstalled([]) - listTerminalClis(projectId).then((clis) => { if (live) setInstalled(clis.map(toLauncher)) }).catch(() => { if (live) setInstalled([]) }) + void listTerminalClis(projectId).then((clis) => { + if (live) setCatalog({ projectId, hostId, launchers: clis.map(toLauncher) }) + }).catch(() => { if (live) setCatalog({ projectId, hostId, launchers: EMPTY_LAUNCHERS }) }) return () => { live = false } - }, [projectId, listTerminalClis]) + }, [projectId, hostId, canLaunch, listTerminalClis]) - const launch = (l: Launcher) => { void startTerminal(projectId, l.cliId, l.command ? { command: l.command, label: l.label } : undefined) } + const launch = (l: Launcher) => { + if (!canLaunch || !matchesLaunchTarget(projectId, hostId)) return + void startTerminal(projectId, l.cliId, !remoteTerminal && l.command ? { command: l.command, label: l.label } : undefined) + } // Electron has no window.prompt, so a custom command opens an inline input instead. const launchCustom = () => { - if (remoteTerminal) return + if (!canLaunch || remoteTerminal) return setCustomCmd('') setCustomOpen(true) } @@ -99,7 +117,7 @@ export function TerminalsTab({ projectId }: { projectId: string }) { {l.label} ))} - {!remoteTerminal && ( + {canLaunch && !remoteTerminal && ( <>
)} - {customOpen && !remoteTerminal && ( + {customOpen && canLaunch && !remoteTerminal && (
{sessions.length === 0 - ? + ? : }
diff --git a/app/src/lib/conversation-drafts.test.ts b/app/src/lib/conversation-drafts.test.ts index 879a3b8734e..736a6bf0a30 100644 --- a/app/src/lib/conversation-drafts.test.ts +++ b/app/src/lib/conversation-drafts.test.ts @@ -1,5 +1,5 @@ import assert from 'node:assert/strict' -import { ConversationDrafts, draftAttachmentReferences } from './conversation-drafts' +import { ConversationDrafts, draftAttachmentReferences, restoreDraftAttachments } from './conversation-drafts' import { composerDraftKey, emptyComposerDraft } from '../../shared/composer-drafts' import type { ComposerDraftPort, ComposerDraftScope, ComposerDraftSnapshot, ComposerDraftWrite, ComposerDraftWriteResult } from '../../shared/composer-drafts' import type { Attachment } from './types' @@ -148,6 +148,44 @@ function memoryPort() { drafts.dispose(); restarted.dispose() } +{ + const { port, saved } = memoryPort() + const reason = 'The synthetic PDF is password-protected.' + const attachment: Attachment = { + id: 'fixture', name: 'fixture.pdf', kind: 'document', mime: 'application/pdf', + status: 'error', error: reason, + } + const seed = new ConversationDrafts(port, 60_000) + seed.update(a, { attachments: [attachment] }) + await seed.flush(a) + seed.dispose() + const key = composerDraftKey(a) + const display = 'Select this file again after restarting TensorFold; its contents were not stored with the draft.' + const prefix = `${display} Previous file error: ` + for (let i = 0; i < 3; i++) { + const reopened = new ConversationDrafts(port, 60_000) + reopened.get(a) + await tick() + assert.equal(reopened.get(a).attachments[0].error, prefix + reason) + reopened.update(a, { text: `Unrelated edit ${i}` }) + await reopened.flush(a) + assert.equal(saved.get(key)!.attachments[0].error, reason) + reopened.dispose() + } + + const ref = saved.get(key)!.attachments[0] + const recoverable = restoreDraftAttachments([{ ...ref, error: prefix.repeat(2) + reason }]) + assert.equal(recoverable[0].error, prefix + reason) + assert.equal(draftAttachmentReferences(recoverable)[0].error, reason) + + const clipped = restoreDraftAttachments([{ ...ref, error: prefix.repeat(12).slice(0, 1000) }]) + assert.equal(clipped[0].error, display) + const longError = 'x'.repeat(999) + 'YZ' + const long = draftAttachmentReferences([{ ...attachment, error: longError }]) + assert.equal(long[0].error, longError.slice(0, 1000)) + assert.deepEqual(draftAttachmentReferences(restoreDraftAttachments(long)), long) +} + { const { port, saved, writes } = memoryPort() let readCalls = 0; port.getComposerDraft = async () => { readCalls++; throw new Error('Incognito must not call disk') } diff --git a/app/src/lib/conversation-drafts.ts b/app/src/lib/conversation-drafts.ts index d896749965c..73ba1f829f3 100644 --- a/app/src/lib/conversation-drafts.ts +++ b/app/src/lib/conversation-drafts.ts @@ -40,6 +40,17 @@ interface Entry { } const RESELECT = 'Select this file again after restarting TensorFold; its contents were not stored with the draft.' +const PREVIOUS_ERROR = `${RESELECT} Previous file error: ` +const ATTACHMENT_ERROR_LIMIT = 1_000 + +function attachmentDiagnostic(error = ''): string { + let diagnostic = error + while (diagnostic.startsWith(PREVIOUS_ERROR)) diagnostic = diagnostic.slice(PREVIOUS_ERROR.length) + if (diagnostic === RESELECT) return '' + // Older drafts could fill the storage limit with repeated guidance and no diagnostic. + if (error.length === ATTACHMENT_ERROR_LIMIT && diagnostic !== error && PREVIOUS_ERROR.startsWith(diagnostic)) return '' + return diagnostic +} /** Strictly omit payloads, paths and source objects from durable references. */ export function draftAttachmentReferences(attachments: Attachment[]): DraftAttachmentReference[] { @@ -47,26 +58,29 @@ export function draftAttachmentReferences(attachments: Attachment[]): DraftAttac return attachments.map((attachment) => { const extraction = (attachment as Attachment & { extraction?: { state: string; text: string } }).extraction if (extraction?.state === 'accepted' && extraction.text.length > MAX_DRAFT_ACCEPTED_TEXT_CHARS) throw new Error('Accepted extracted text exceeds the draft storage limit; copy it to a document before restarting.') - const rawError = (attachment as Attachment & { error?: string }).error + const error = attachment.status === 'needs-reselection' ? attachmentDiagnostic(attachment.error) : attachment.error return { id: attachment.id, name: attachment.name, kind: attachment.kind, mime: attachment.mime, ...(attachment.bytes === undefined ? {} : { bytes: attachment.bytes }), - status: 'needs-reselection', error: rawError ? rawError.slice(0, 1_000) : RESELECT, + status: 'needs-reselection', error: error ? error.slice(0, ATTACHMENT_ERROR_LIMIT) : RESELECT, ...(extraction?.state === 'accepted' && typeof extraction.text === 'string' && extraction.text.length <= MAX_DRAFT_ACCEPTED_TEXT_CHARS ? { acceptedText: extraction.text } : {}), } }) } export function restoreDraftAttachments(references: DraftAttachmentReference[]): Attachment[] { - return references.map((reference) => ({ - id: reference.id, name: reference.name, kind: reference.kind, mime: reference.mime, - ...(reference.bytes === undefined ? {} : { bytes: reference.bytes }), - status: 'needs-reselection', error: reference.error && reference.error !== RESELECT ? `${RESELECT} Previous file error: ${reference.error}` : RESELECT, - ...(reference.acceptedText === undefined ? {} : { - text: reference.acceptedText, - extraction: { method: 'apple-vision', state: 'accepted', text: reference.acceptedText, confidence: null, warnings: ['Original file must be selected again before sending. Previously accepted extracted text was retained.'], pageCount: 0, processedPages: 0, truncated: false }, - }), - })) + return references.map((reference) => { + const diagnostic = attachmentDiagnostic(reference.error) + return { + id: reference.id, name: reference.name, kind: reference.kind, mime: reference.mime, + ...(reference.bytes === undefined ? {} : { bytes: reference.bytes }), + status: 'needs-reselection', error: diagnostic ? PREVIOUS_ERROR + diagnostic : RESELECT, + ...(reference.acceptedText === undefined ? {} : { + text: reference.acceptedText, + extraction: { method: 'apple-vision', state: 'accepted', text: reference.acceptedText, confidence: null, warnings: ['Original file must be selected again before sending. Previously accepted extracted text was retained.'], pageCount: 0, processedPages: 0, truncated: false }, + }), + } + }) } function detached(attachments: Attachment[]): Attachment[] { diff --git a/app/src/lib/mock/engine.ts b/app/src/lib/mock/engine.ts index 061e4ba4a82..796b94a8c7b 100644 --- a/app/src/lib/mock/engine.ts +++ b/app/src/lib/mock/engine.ts @@ -201,6 +201,7 @@ export function createMockEngineApi(): Pick { if (status.model === repo && status.state !== 'stopped') throw new Error(`Unload ${repo} before deleting it.`) installed = installed.filter((m) => m.repo !== repo) + if (pulls.get(repo)?.state === 'done') pulls.delete(repo) emit({ kind: 'installed', installed }) return installed }, diff --git a/app/src/lib/policy.ts b/app/src/lib/policy.ts index 88e1f8a86d6..82a465a6283 100644 --- a/app/src/lib/policy.ts +++ b/app/src/lib/policy.ts @@ -16,7 +16,8 @@ export function projectDefaultModel(project: Project | null | undefined, provide const allowed = allowedProviders(providers, project) const p = allowed.find((x) => x.id === project?.defaultProviderId) || allowed[0] || null const accounts = p ? providerAccountChoices(p) : [] - const requestedAccountId = project?.defaultProviderAccountId ?? p?.defaultAccountId ?? null + const usesProjectBaseAccount = project?.defaultProviderAccountId === null && project.defaultProviderId === p?.id + const requestedAccountId = usesProjectBaseAccount ? null : project?.defaultProviderAccountId ?? p?.defaultAccountId ?? null const account = accounts.find((choice) => choice.id === requestedAccountId) ?? accounts[0] ?? null const models = account?.models?.length ? account.models : (p?.models ?? []) const model = project?.defaultModel && models.includes(project.defaultModel) ? project.defaultModel : (models[0] ?? null) diff --git a/app/src/lib/store/shared/model-policy.ts b/app/src/lib/store/shared/model-policy.ts index 602e9a0972a..d4f1defb09c 100644 --- a/app/src/lib/store/shared/model-policy.ts +++ b/app/src/lib/store/shared/model-policy.ts @@ -81,8 +81,12 @@ export function applyProjectModel(get: () => AppState, s: Settings | null, proje let model = surface.model if (project && (project.localOnly || project.defaultProviderId)) { const d = projectDefaultModel(project, s.providers) - if (d.providerId) { providerId = d.providerId; model = d.model } - providerAccountId = d.providerAccountId ?? providerAccountId + if (d.providerId) { + providerId = d.providerId + const usesProjectBaseAccount = project.defaultProviderAccountId === null && project.defaultProviderId === d.providerId + providerAccountId = usesProjectBaseAccount ? null : d.providerAccountId ?? providerAccountId + model = d.model + } } const provider = s.providers.find((p) => p.id === providerId) providerAccountId = selectedAccountId(provider, providerAccountId) diff --git a/app/src/lib/store/shared/project-model-route.test.ts b/app/src/lib/store/shared/project-model-route.test.ts new file mode 100644 index 00000000000..2f3092e809b --- /dev/null +++ b/app/src/lib/store/shared/project-model-route.test.ts @@ -0,0 +1,49 @@ +import assert from 'node:assert/strict' +import { mkdtemp, rm, writeFile } from 'node:fs/promises' +import os from 'node:os' +import path from 'node:path' +import { createJiti } from 'jiti' +import type { Project, Provider, Settings, Thread } from '../../types' +import type { AppState } from '../types' + +const root = await mkdtemp(path.join(os.tmpdir(), 'tf-project-model-route-')) +try { + const stub = path.join(root, 'ipc.cjs') + await writeFile(stub, 'exports.api = { configureThread: async (...args) => globalThis.projectModelCalls.push(args) }') + const calls: unknown[][] = [] + const globals = globalThis as unknown as { projectModelCalls: unknown[][] } + globals.projectModelCalls = calls + const load = createJiti(__filename, { alias: { '../../ipc': stub } }) + const { applyProjectModel } = await load.import('./model-policy') + const provider = { + id: 'fixture', name: 'Fixture', kind: 'local', models: ['base-model'], defaultAccountId: 'named', + accounts: [{ id: 'named', name: 'Named fixture', models: ['named-model'] }], + } as Provider + const settings = { providers: [provider], activeProviderId: provider.id, activeProviderAccountId: 'named', activeModel: 'named-model' } as Settings + const project = { id: 'project', defaultProviderId: provider.id, defaultProviderAccountId: null, defaultModel: 'base-model' } as Project + + for (const kind of ['chat', 'task'] as const) { + const thread = { id: kind, kind } as Thread + applyProjectModel(() => ({ projects: [project] }) as AppState, settings, project.id, thread) + assert.deepEqual([thread.providerId, thread.providerAccountId, thread.model], [provider.id, null, 'base-model']) + assert.deepEqual(calls.at(-1), [kind, provider.id, 'base-model', null]) + } + + const legacy = { ...project, defaultProviderAccountId: undefined } + const oldThread = { id: 'older-project', kind: 'chat' } as Thread + applyProjectModel(() => ({ projects: [legacy] }) as AppState, settings, legacy.id, oldThread) + assert.deepEqual([oldThread.providerAccountId, oldThread.model], ['named', 'named-model']) + + const withoutProviderDefault = { ...provider, defaultAccountId: null } + const task = { id: 'global-account', kind: 'task' } as Thread + applyProjectModel(() => ({ projects: [project] }) as AppState, { ...settings, providers: [withoutProviderDefault] }, project.id, task) + assert.deepEqual([task.providerAccountId, task.model], [null, 'base-model']) + + const legacyTask = { id: 'legacy-global-account', kind: 'task' } as Thread + applyProjectModel(() => ({ projects: [legacy] }) as AppState, { ...settings, providers: [withoutProviderDefault] }, legacy.id, legacyTask) + assert.deepEqual([legacyTask.providerAccountId, legacyTask.model], ['named', 'named-model']) +} finally { + await rm(root, { recursive: true, force: true }) +} + +console.log('Project Chat and Task inherit the selected provider key and keep legacy named defaults') diff --git a/build.zig.zon b/build.zig.zon index bbfa758645e..526c7a4685f 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .tensorfold, - .version = "1.2.9", + .version = "1.2.10", .fingerprint = 0xb6dc5a482d53980a, // Changing this has security and trust implications. .minimum_zig_version = "0.17.0", .dependencies = .{}, diff --git a/docs/api.md b/docs/api.md index db5ffae36bc..69c1304b18e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -49,7 +49,8 @@ different scopes, or scopes a key the flags or environment already give, is refu | `read` | GET `/metrics`, `/v1/metrics`, `/v1/load`, `/memory`, `/v1/memory`, `/stats`, `/dashboard`, `/v1/benchmark/manifest`, `/v1/models`, `/models`, `/v1/voices` | A scoped key reaches nothing else: not the stored Responses (GET or DELETE `/v1/responses/ID`), Recall, Sliding Weights, -`/v1/imprint`, another method, or a suffix alias such as `/alt/completions` that the server answers for a full key. The route +`/v1/imprint`, adding or deleting voices (`--manage-voices`), another method, or a suffix alias such as `/alt/completions` +that the server answers for a full key. The route is matched exactly after the query and trailing slashes are cut. A refused route answers 403 with the code `insufficient_scope` (Messages routes: an Anthropic `permission_error`) and closes the connection before the body is read or a parked model reloads. The public routes stay public. @@ -1740,3 +1741,61 @@ streamed. ```bash curl http://127.0.0.1:8080/api/embed -d '{"model":"local-model","input":"hello"}' ``` + +## Request journal and replay + +`TENSORFOLD_REQUEST_JOURNAL=PATH` turns on a request journal; it is off unless set, and only `PATH` and its siblings are +written. **It holds every chat and completion prompt and reply in full**: treat it like the conversations themselves. +Image URLs and PDF data are replaced with ``, as in `TENSORFOLD_REQUEST_LOG`, which is unchanged. No HTTP header +is journaled, so API keys and `Authorization` values never reach it. The server creates `PATH` and `PATH.lock` +owner-only (0600), refuses a symbolic link or a file others can read, and holds `PATH.lock` while it runs, so a second +server on the same journal does not start. Benchmark child servers never inherit the variable. + +Each request writes three JSON lines: `start` before any work (its reply id, route, fingerprint, the client's seed and +the redacted body), `prepared` before the engine sees it (the seed and sampling the server resolved, the token limit, +thinking, drafts and the prompt's token count and SHA-256), and `finish` once the reply has gone (status, outcome, the +reply's size and SHA-256, its `token_sha256`, and the reply bytes in base64 when they fit 4 MiB). Responses and Messages +requests are journaled in the chat form they are translated to. A raw completion whose `prompt` is a list is not +replay-exact: its per-prompt prepared records are not written, and its individual drawn seeds are not journaled. + +Size is bounded: a file rotates at 64 MiB to `PATH.1`, older files move up, and `PATH.3` is the last kept, so the +journal holds at most 256 MiB. A body or reply too large for one 8 MiB record keeps its size and hash only. Each record +is one `write` with no sync, so the journal adds three small appends to a request and nothing to its tokens; a full +disk or a write error loses that record (the server logs it once), never the request. A record survives the server +process crashing, not a power loss. + +On the next start the server reads the kept files. A request that started and never finished, with no clean stop after +it, was in flight at a crash: a `quarantine` line flags it, and the server never retries it. Its fingerprint is SHA-256 +over the API key's label (as in the access log), the route and the whole body, so it matches only the same key sending +the same request. One crash only flags what was in flight, since a crash can come from elsewhere (another route, the +machine) and the requests beside it are not to blame. A request whose fingerprint was in flight at two crashes is +refused with a 400 `request_quarantined` before the engine sees it, which ends a client's retry loop after the second +crash. Other requests, and other keys sending the same body, are served as before; the check is one hash lookup. Without +API keys every client shares one label. A quarantine lapses 24 hours after its last crash, and a clean stop (SIGTERM, +Ctrl-C) quarantines nothing. + +`tools/replay_request.py` lists, clears and replays journaled requests: + +```sh +python3 tools/replay_request.py requests.jsonl --list +python3 tools/replay_request.py requests.jsonl --id chatcmpl-example --base http://127.0.0.1:8080 +python3 tools/replay_request.py requests.jsonl --clear chatcmpl-example # or a fingerprint, or all; server stopped +``` + +`--list` sends nothing. A replay sends the journaled body once to its route; when the client sent no seed, it adds the +seed the server drew. It compares the reply's output: every choice's text, reasoning, tool calls (without their ids), +logprobs and finish reason, the token counts, the stop sequence and `tensorfold.token_sha256`, the SHA-256 of the reply's +token ids, so equal means the same tokens. Streams compare their joined deltas, whatever their frame boundaries. Reply +ids, `created`, timings, `cached_tokens` and keepalives are left out; `--whole-body` compares every byte instead and +will differ on those. A reply too large to keep is compared by its token hash. Exit 0 is equal, 1 is different, and 2 +means there was no finished reply to compare. `--body FILE` supplies the original request when images or a PDF were +redacted or the body was too large; `--allow-quarantined` sends a quarantined request on purpose; `--key-env NAME` +names the variable holding the API key (`TENSORFOLD_API_KEY` by default), which is sent and never written. + +A replay is exact on the same build, checkpoint, tokenizer, drafter and server flags, since TensorFold's decode gives the +same tokens for the same prompt and seed with or without drafts, alone or batched. It is not exact across builds or +checkpoints, after the server's defaults change, when a Messages request relied on the server's thinking default, when +the body was restored with different media, or for a request whose server ran several generations for it (Cortheon) +without a client seed or `--prompt-seed`, since only the last drawn seed is journaled. +Unseeded prompt lists are not replay-exact either: each prompt draws its own seed, and those per-prompt prepared +records are omitted. Send a client seed or keep the same `--prompt-seed` setting for an exact list replay. diff --git a/docs/drama-http-voices.md b/docs/drama-http-voices.md index 1599ebdab32..3f5a2ca4279 100644 --- a/docs/drama-http-voices.md +++ b/docs/drama-http-voices.md @@ -1,8 +1,8 @@ # Attested HTTP voices -`tensorfold-native serve MODEL --voices DIR --default-voice NAME` loads the catalog at startup. Without these flags the built-in voice and speech request lowering are unchanged. `--default-voice` defaults to `default`; a configured name must exist. A missing, malformed or unattested catalog file refuses startup rather than silently substituting a voice. Restart to reload files. +`tensorfold-native serve MODEL --voices DIR --default-voice NAME` loads the catalog at startup. Without these flags the built-in voice and speech request lowering are unchanged. `--default-voice` defaults to `default`; a configured name must exist. A missing, malformed or unattested catalog file refuses startup rather than silently substituting a voice. Without `--manage-voices`, restart to reload files. -`POST /v1/audio/speech` selects a catalog entry with `voice` (or the existing `speaker` alias). An absent, empty or case-insensitive `default` selects the configured default. Other names match exactly. Request-supplied reference arrays and paths remain unsupported. `GET /v1/voices` returns `{"voices": ["default", ...], "details": [{"id": NAME, "description": TEXT}, ...]}` with catalog names sorted, without transcripts, codes or attestation notes; `description` is the file's optional one-line description (at most 200 bytes), else empty. Non-speech models return the existing unknown-route response. +`POST /v1/audio/speech` selects a catalog entry with `voice` (or the existing `speaker` alias). An absent, empty or case-insensitive `default` selects the configured default. Other names match exactly. Reference arrays, `ref_audio`, `ref_text` and paths in a request remain unsupported; an inline voice object needs `--request-voices` (below). `GET /v1/voices` returns `{"voices": ["default", ...], "details": [{"id": NAME, "description": TEXT}, ...]}` with catalog names sorted, without transcripts, codes or attestation notes; `description` is the file's optional one-line description (at most 200 bytes), else empty. Non-speech models return the existing unknown-route response. Each regular `NAME.json` file contains: @@ -25,6 +25,19 @@ Reference `text` is the exact transcript. Codes are frame-major signed integers, The loader enforces the family's reference count, transcript length, frame count and codebook ranges before serving. It also rejects empty references, structural prompt tokens, malformed speaker tags, oversized files and oversized catalogs. The assembled prompt must still fit the engine's advertised prompt budget. Reference rows go through the same family `prompt.build` used by the generation CLI; only the tokenizer interface is adapted. +## Voices added while serving + +`--manage-voices` (off by default) adds two routes for keys with the `admin` scope, or any key in a key file without scopes; `inference` and `read` keys get 403. Without an API key every client is an admin, so serve with `--api-key-file` before turning it on. Without the flag both routes answer as before, with the unknown-route 404. + +- `POST /v1/voices` adds or replaces `name`. The body is `{"name": NAME, ...}` plus either a voice file's own fields (`format`, `source`, `references`, optional `description`), or `{"audio": BASE64, "text": TRANSCRIPT, "source": {...}}` with optional `description`. `audio` is a WAV file (PCM 8, 16, 24 or 32-bit, or float32, any channel count, at most 30 seconds, and a rate from 1 to 192,000 Hz whose reduced ratio `rate / gcd(rate, 44100)` is at most 640; this includes 8/16/24/32/44.1/48/64/88.2/96/176.4/192 kHz) in standard base64, resampled and encoded by the loaded model's own codec, on the speech engine's thread when a lane is free. The attestation and transcript are checked before any audio is encoded. The reply is `{"id": NAME, "description": TEXT, "added": true}` with 201, or `"added": false` with 200 for a replaced voice. +- `DELETE /v1/voices/NAME` deletes a voice; the configured `--default-voice` cannot be deleted (409), and an unknown name is a 404. + +With `--voices DIR`, an added voice is written to `DIR/NAME.json` (through a temporary file renamed into place, before the catalog changes) and a deleted one's file is removed, so a restart loads the same catalog. Without a directory, changes last until the server stops. A request reads its voice once, when it arrives: a voice deleted or replaced while it runs does not change its audio. The reference prompt cache keys on the reference rows themselves, so a replaced voice never reuses the old voice's saved rows. + +## Inline voices + +`--request-voices` (off by default) lets `voice` in `POST /v1/audio/speech` be a voice file's object instead of a name: `"voice": {"format": "drama3-http-voice/1", "source": {...}, "references": [...]}`, checked as the catalog checks a file, attestation included. It builds the same prompt as a catalog voice with the same references, and takes no `speaker` field. Without the flag, an object `voice` gets the same refusal as before. + ## Speech limits and discovery `GET /v1/models` includes a `speech` object only for a loaded speech engine. `max_assembled_prompt_rows` counts all backbone prompt rows, including wrappers, reference transcripts and acoustic reference codes. `max_generated_acoustic_frames` is the output budget, not a text-token limit. `sample_rate_hz` and `samples_per_acoustic_frame` describe the output geometry. `max_input_code_points` is the separate HTTP input-text policy; it is not a tokenizer or assembled-row budget. diff --git a/docs/environment.md b/docs/environment.md index 9d53fab2db2..fc606a7996b 100644 --- a/docs/environment.md +++ b/docs/environment.md @@ -51,6 +51,14 @@ Diagnostics quote and escape the supplied text so it cannot create another termi | `TF_GLM_DRAFT_CONFIDENCE` | Finite number 0 through 1 where a DFlash2 chain's chance product stops it; default 0.7 | | `TF_GLM_CONTEXT_CEILING` | GLM-5.3-Flash on CUDA: whole token count 1 through 2147483616, the window `--context` may ask for and `--context 0` serves, in place of config.json's 1048576; read at GLM's open. Past that length the model's quality is the operator's to check. Unset keeps config.json's window | | `TF_GLM_EXPERT_FORM` | `classic` or `factored`: the expert form GLM's CUDA decode windows use (the same bits either way), also at a load that times nothing; unset or blank races the two when a build first loads with drafts and scratch context and keeps the winner, else classic; read on rank 0, which chooses every rank's form | +| `TF_GLM_INDEX_CUDA` | GLM on CUDA: exactly `1` (both DSA indexer kernels), `0` (neither) or `scores` (scores only); unset or blank is `both` | +| `TF_GLM_KV_HOST_GIB` | GLM on CUDA: a finite GiB amount of at least 0 for the DSA layers' pinned host pages; unset or blank uses one full window and 16 rows a page | +| `TF_GLM_RANK` | GLM-5.3-Flash on CUDA: a whole rank index from 0 through 4294967295, set with `TF_GLM_WORLD`; unset with it gives one rank | +| `TF_GLM_WORLD` | GLM-5.3-Flash on CUDA: a whole rank count from 1 through 4294967295, set with `TF_GLM_RANK`; unset with it gives one rank | +| `TF_NEMOTRON_RANK` | Nemotron 3.5 Super on CUDA: a whole rank index from 0 through 4294967295, set with `TF_NEMOTRON_WORLD`; unset with it gives one rank | +| `TF_NEMOTRON_WORLD` | Nemotron 3.5 Super on CUDA: a whole rank count from 1 through 4294967295, set with `TF_NEMOTRON_RANK`; unset with it gives one rank | +| `TF_MINIMAX_RANK` | MiniMax-M3.1-Flash on CUDA: a whole rank index, 0 or 1 at two ranks, set with `TF_MINIMAX_WORLD`; unset with it gives one rank | +| `TF_MINIMAX_WORLD` | MiniMax-M3.1-Flash on CUDA: a whole rank count, 2 at CUDA, set with `TF_MINIMAX_RANK`; unset with it gives one rank | | `TF_PROMPT_ROWS` | Native serving: a multiple of 16 from 128 through 2048; unset keeps the chip/family default | | `TF_ANE_COLUMNS` | Whole u32 count; zero disables the experimental share; default zero | | `TF_FLASHNEXT_SCALE_INDEX` | Flash Next on Metal before tensor units: exactly `0` or `1`; default 1, where the 4-bit expert kernels (decode, grouped and prompt gathers) read each group's scale and bias through a 16-bit index into its tensor's table of pairs, the same values from fewer weight bytes, and the routed experts' stored scales and biases are not kept in memory; `0` keeps and reads the stored arrays; ignored with `--ssd-experts` | @@ -161,6 +169,7 @@ These settings retain their existing boolean policies rather than gaining new al - Flash Next keeps its lenient readers where they are: `TF_FLASHNEXT_TP` and `TF_FLASHNEXT_LOGITS` take a path, `TF_FLASHNEXT_OWNED` a list, `TF_FLASHNEXT_DEPTH_LOG` and `TF_TP_TRACE`/`TF_TP_LOCAL`/`TF_TP_STATS` select by presence, and the tool-only sampling settings of the MTP check and the `FZ_` developer switches keep their semantics. +The fabric/tp config helper keeps its runtime-name lookup instead of gaining a startup row: it carries the lenient switches above and transport names read only by tools, which no server would set. The profile registry reports selected arithmetic/experimental overrides; it does not change their parsing or defaults. See [profiles](profiles.md) for classes, scopes and grouped slide-learning names. diff --git a/docs/evaluating.md b/docs/evaluating.md index d90b8627169..0d249d85a74 100644 --- a/docs/evaluating.md +++ b/docs/evaluating.md @@ -43,6 +43,9 @@ These need no GPU, driver or checkpoint: - `tensorfold capabilities --json` lists the backends, model families, formats, serve flags and `optional_libraries`, each with a `found` flag. - `tensorfold info REPO` prints a pulled checkpoint's family, format, context, weights size and memory floor. +- From a source build (`tensorfold` built from source, or `tf-cluster`), `tensorfold config validate FILE` + reads a cluster.json, prints every problem, and does not plan models or probe hosts. The release + binary, `tensorfold-native`, does not have this command. ## Container diff --git a/docs/kernel-contract.md b/docs/kernel-contract.md index cbe12c376a4..862e8594d23 100644 --- a/docs/kernel-contract.md +++ b/docs/kernel-contract.md @@ -177,6 +177,9 @@ The HIP relu^2 replacement retains every non-finite plant and checks both unfuse independent float64 output class. No inherited infinity discrepancy is accepted. The paired launch retains every table plant and checks both members' separate-launch bytes and every float64 output class, without an inherited exception. +Its 1x8 tile at 5, 6 and 8 bits takes 256 VGPRs and spills to scratch on gfx1100, a gate-5 finding: limits do not count +scratch, so `spills_on_gfx1100` in `hip_records_relu2_widths.zig` names those three records, and its test fails when a +record spills that the list does not name or a named one stops spilling. ## Isolated masked-value panels @@ -351,6 +354,10 @@ HIP also checks the router over the rows a checkpoint already holds in bf16 (`tf form), bit-equal to the fp32-rows router it replaces at 1 to 16 rows, with both kinds' non-finite plants through gate 1 and the exact sums of gate 4. +Metal also checks Idol's denoiser (`metal_idol*.zig`): its fp16 projections and GELU form, the split-K fp32 rows, +`id_gemm32` (true fp32 sums: the NAX fp32 path in its place is a control gate 4 must catch), the LayerNorms, RePo's +angles, the heads, the elementwise steps and the attention's four forms, each at idol-sdk's fp16 points (19 controls). + HIP also checks the DeltaNet prompt recurrence at half a value head a block (`tf_gdn_prompt_128`, its y and state), bit-equal to the plain window scan `gated_delta_tile` on the same tokens. Its prompt prework in one launch (`tf_gdn_prompt_prep`: conv, q and k head norms, v, gate, beta and the new conv state) @@ -402,6 +409,36 @@ GLM's Metal window projections register narrow and wide rows at 2, 3, 4, 5, 6 an Independent FP64 linear cases accompany byte replacements against frozen pre-window-optimization kernels. The gathered SwiGLU keeps its predecessor's clipped BF16 output and nonfinite rules; gate/up taps qualify its dots separately. Controls dispatch real source mutations that couple rows or select the wrong expert; host tests validate their witnesses. +GLM-5.3-Flash's other served Metal launches (`metal_glm_launch.zig`, names `metal glm launch ...`) each run the loader's +own library text beside the kernel they replace, on the same inputs, and must give its bytes in every written buffer, +untouched guards and poisoned padding included. The decode select's merge (rows within 3,072 blocks) and its mark and +merge (past 8,192 blocks, to rows past 65,536 blocks where the merge falls back to the whole row) keep +`glm_index_select`'s key lists over ties, signed zeros, NaNs, infinities and a floor that overshoots. The windowed KDA +step (`glm_kda_window`, 64 heads, and `glm_kda_window_tp`, 32) keeps `kda_rows`' outputs, next state and next conv +window at 2 to 16 rows. A window's dense attention as `attendRows` launches it (`glm_latent_scores_rows`, +`glm_softmax_rows`, `glm_latent_values_rows`) keeps main's one-row launches' scores, probabilities and outputs row by +row, 1 to 2,048 keys across the 256-key join and the 1,024-key split, against a frozen copy of main's `glm_attn.metal`. +The hyper-connection boundary as `core/hc.zig` launches it (the expand's parts on six groups a slice to 4 rows) keeps +main's expand and split (a frozen `hc_boundary.metal`) in the streams, partial sums, normed row, post and comb, as raw +words, for separate streams, in place and at a first read. The decode experts at `moe.zig`'s outputs a simdgroup keep +the four-output gate/up and down kernels' activations and outputs. On an Ultra's GPU the KDA step's two groups a head +with the norm after (`glm_kda_parts`, `glm_kda_norm`) keep `kda_rows`' bytes at 2 to 16 rows. The boundary's two-group +split runs in the same boundary entries, and the attention entry runs the prefetched score and value bodies with a +control that multiplies the prefetched block. The one-row router and indexer-gate logits (`glm_route_logits_one`, fp32 +and bf16 out) also meet float64 at every gate, each row its own one-row launch, and give `tf_route_logits`' bits. The +core route select (`tf_route_select`, its picks by simd max and min and its groups' offsets by prefix sums) keeps main's +picks, weights, held groups, pick lists and counts at GLM's shape (every expert held, or either half) and Step-5's, over +ties, NaNs, signed zeros and -inf biases. `glm_mla_norms` (three roles, and four with the query norm) keeps main's +`glm_rms`, `glm_layer_norm` and `glm_scale` launches; the attention entry's scores kernel scales the queries by 1/16 as +it loads them, against main's `glm_scale` first. The boundary that combines a MoE block's picks (`tf_hc_expand_mix_moe`, +and its parts to 2 rows) keeps main's combine then expand, and a one-row MoE layer whose gate/up groups replay the +select keeps main's select then the one-row gathers (its picks held to the 16 experts given weights by -inf biases +elsewhere). A prompt chunk's routed experts and deep dense products in column groups (`glm_gather_glu_32`/`_64`, +`glm_gather_scatter_32`/`_64`, `glm_mm_grouped`) keep `core/affine_mm.metal`'s one-launch gathers and `tf_affine_mm` at +both gather heights, with a partial last column group in the dense entry. Gate 1 plants NaN and both infinities and +requires the predecessor's bytes, NaN payloads included; these +entries compare and keep sums rather than requalify them, so gate 4 does not apply. Each has a control, a planted source +fault red at `shapes`, and its launches are in `glm_launch_records.zig`. CUDA also checks LFM2.5-24B-A2B's kernels: the router's fp32 logits (`tf_lfm2m_route`) and its top-4 rule, Liquid's 3-tap short conv with its per-row state snapshots and the state commit (`liquid_conv.cuh`), each against the host's replay of its fp32 and bf16 steps (three controls: ties to the higher expert, bx unrounded, every stream committing into diff --git a/docs/optimization-ledger.md b/docs/optimization-ledger.md index e67ea9e1304..658aa868898 100644 --- a/docs/optimization-ledger.md +++ b/docs/optimization-ledger.md @@ -78,6 +78,9 @@ last two hold the families with only a Metal, HIP or scoring backend. | 27. Profiles | done [#1944] | done [#1944] | done [#1959] | done [#1944] | done [#2061] | | 28. Scale index | ? | done M[#2760], open M[#2805] | ? | ? | ? | | 29. DSpine | done C[#2633] | no (no drafter) | no (no drafter) | no (no drafter) | no (no drafter) | +| 30. Small-kernel fusion | ? | failed H[#1603] | ? | ? | ? | +| 31. Stream-tile prefetch | ? | failed H[#1603] | ? | ? | ? | +| 32. Filled-item prompt grid | ? | failed H[#1603] | ? | ? | ? | | Optimization | kol1 | spk25 | dory | mm3 | dsv41 | | --- | --- | --- | --- | --- | --- | @@ -110,6 +113,9 @@ last two hold the families with only a Metal, HIP or scoring backend. | 27. Profiles | done [#1944] | done [#1944] | open [#2306] | yes | yes | | 28. Scale index | ? | ? | ? | ? | ? | | 29. DSpine | no (no drafter) | no (no drafter) | no (no drafter) | no (no drafter) | no (no drafter) | +| 30. Small-kernel fusion | ? | ? | ? | ? | ? | +| 31. Stream-tile prefetch | ? | ? | ? | ? | ? | +| 32. Filled-item prompt grid | ? | ? | ? | ? | ? | | Optimization | lfm2m | lfm3 | qwen4 | ling | | --- | --- | --- | --- | --- | @@ -142,6 +148,9 @@ last two hold the families with only a Metal, HIP or scoring backend. | 27. Profiles | yes | yes | yes | yes | | 28. Scale index | ? | ? | ? | ? | | 29. DSpine | no (no drafter) | no (no drafter) | no (no drafter) | no (no drafter) | +| 30. Small-kernel fusion | ? | ? | ? | ? | +| 31. Stream-tile prefetch | ? | ? | ? | ? | +| 32. Filled-item prompt grid | ? | ? | ? | ? | q3.5 `qwen3_5` (C, M, H, X), fnext `flashnext` (C, M, H), glm `glm` (C, M), gem4 `gemma4` (C, M, X), nemo `nemotron` (C, M, H, X), kol1 `kolibri1` (C), spk25 `spark25` (C, M), @@ -180,6 +189,9 @@ ling `ling` (host package only, no engine yet; CUDA plan in [#850]). | 27. Profiles | yes | yes | yes | yes | | 28. Scale index | ? | ? | ? | ? | | 29. DSpine | open M[#2634] | no (scores) | no (no drafter) | no (no drafter) | +| 30. Small-kernel fusion | ? | ? | ? | ? | +| 31. Stream-tile prefetch | ? | ? | ? | ? | +| 32. Filled-item prompt grid | ? | ? | ? | ? | | Optimization | gdsa | kimi | qwen3 | | --- | --- | --- | --- | @@ -212,6 +224,9 @@ ling `ling` (host package only, no engine yet; CUDA plan in [#850]). | 27. Profiles | yes | yes | yes | | 28. Scale index | ? | ? | ? | | 29. DSpine | no (no drafter) | no (no drafter) | no (prompt) | +| 30. Small-kernel fusion | ? | ? | ? | +| 31. Stream-tile prefetch | ? | ? | ? | +| 32. Filled-item prompt grid | ? | ? | ? | q27 `qwen27` (M: Qwen3.8-27B and Qwen3.5-MoE), lfm2 `lfm2` (C: LFM2-VL, scores decisions and writes no text), llama `llama` (M), step5 `step5` (M), gdsa `glm_dsa` (M), kimi `kimi_k3` (M, native serving on [#2221]), @@ -258,6 +273,9 @@ below; these are estimates for planning a port, not results. | 27. Profiles | none | none | none | names the opt-in switches | | 28. Scale index | none | low | 5 % of the weights once prompts read it too | one stream's decode before tensor units | | 29. DSpine | none | medium | low | Qwen3.8-27B; agent 2–20 % faster, chat and code 10–19 % slower | +| 30. Small-kernel fusion | none | low | none | HIP Flash Next: 1.2–2.0 % of a round for the hyper-connection block, 2.4–4.0 % for all four groups | +| 31. Stream-tile prefetch | none | none | none | HIP Flash Next: the hyper-connection projections, no gain | +| 32. Filled-item prompt grid | low | none | none | HIP Flash Next: prompt tok/s at most 1.2 % better | ## The optimizations @@ -480,6 +498,30 @@ below; these are estimates for planning a port, not results. ([#2633]); the Metal binding ([#2634]) is still open. On a GB10, against DFlash2: agent prompts decode 2–20 % faster, chat and code 10–19 % slower. It needs the checkpoint's own DSpine drafter, so other families have none. +30. **Small-kernel fusion.** Launches under 20 µs, fused into one launch where they sit next to each other, to save the + gap between dispatches (2.0 µs median) and the per-launch floor (the cheapest kernels run 1.3 µs). Bounded under the + bar on Flash Next HIP, so the row is `failed` ([#1603]). + + | Family | Gain (measured) | Where | + | --- | --- | --- | + | flashnext (H) | hyper-connection block 1.2–2.0 % of a round, all four groups together 2.4–4.0 %; estimates from measured gaps and launch counts, not built | [#1603], main `6c5cef894`, gfx1151 | + +31. **Prefetched and double-buffered stream tiles.** A separate stream-tile family for the hyper-connection + projections that prefetches or double-buffers the weight loads, bit-equal to the plain kernel at 1–8 rows. On + Flash Next HIP it gained nothing, so the row is `failed` ([#1603]). + + | Family | Gain (measured) | Where | + | --- | --- | --- | + | flashnext (H) | code 46.01–46.30 tok/s and chat 39.87–40.10 tok/s against main, every token hash equal | [#1603], one Strix Halo iGPU (gfx1151) | + +32. **Routed-expert prompt grid sized by filled items.** The prompt launch's grid follows the items actually filled + and not the decode tile's capacity, where about 91 % of the blocks exit empty at 4,096 rows. On Flash Next HIP the + empty blocks cost almost nothing, so the row is `failed` ([#1603]). + + | Family | Gain (measured) | Where | + | --- | --- | --- | + | flashnext (H) | first-token ratios 0.99–1.01, prompt tok/s at most 1.2 % better, decode and concurrency level | [#1603], one Strix Halo iGPU (gfx1151) | + [#458]: https://github.com/ashhart/TensorFold/pull/458 [#468]: https://github.com/ashhart/TensorFold/pull/468 [#519]: https://github.com/ashhart/TensorFold/pull/519 @@ -630,5 +672,6 @@ below; these are estimates for planning a port, not results. [#2634]: https://github.com/ashhart/TensorFold/pull/2634 [#2784]: https://github.com/ashhart/TensorFold/pull/2784 [#2764]: https://github.com/ashhart/TensorFold/issues/2764 +[#1603]: https://github.com/ashhart/TensorFold/issues/1603 [#2977]: https://github.com/ashhart/TensorFold/pull/2977 [#2805]: https://github.com/ashhart/TensorFold/pull/2805 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/README.md b/docs/receipts/glm-fp4local-3a56d4eb/README.md new file mode 100644 index 00000000000..d55b817d9ed --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/README.md @@ -0,0 +1,108 @@ +# GLM-5.3-Flash FP4-Local on CUDA at TP=2: a receipt on main + +Tested commit: `3a56d4eb92` (`commit.txt`), built from a `git archive` of it with an empty `.zig-cache`. Later `main` up +to `964174ea05` changes only DeepSeek V4.1 Metal files and the changelog, which GLM's CUDA path does not read; it was +not rebuilt. Test date: 2026-11-15. Platform: two DGX Spark (GB10, sm_121, 128 GB shared memory), TP=2 over a direct +RoCE link (NCCL NET/IB), Ubuntu 24.04.5, kernel 7.0.0-1025-nvidia, driver 580.178.04 (CUDA 13.0). Toolchain: Zig 0.17.0, +nvcc 13.5 (V13.5.37) for sm_121; runtime NCCL 2.30.7. One `tensorfold-native` (sha256 in `commit.txt`) on both ranks. +Checkpoint: `nvidia/GLM-5.3-Flash-FP4-Local` at `76348ddb2be2e35e39ecfc00e75dc07703f4f3d5`, its own MTP layer as the +drafter, with the default copies beside it (`drafts: MTP + copies`). + +## Scope + +This rechecks FP4-Local as #1050 loads it, on current `main` with default settings: drafted = `"draft": false`, +concurrent = alone, resumed = cold, per-rank load and peak memory, decode with and without drafts, and cold prompts from +2,048 to 65,536 tokens. It does not rerun the [1.1.5-era receipt](../glm-fp4local-80517fc3/README.md)'s loader gate, +kernel contract, structured output and tools, media and video, prompt logprobs against BF16 (its BF16 reference is not +published), or TP=3. No baseline binary ran beside it: the earlier receipt's columns below are context, not a +before/after. + +## Results + +Exactness (`ex/`: `--context 40960 --parallel 4`, every other setting default, so the prompt cache is on): + +| Check | Ids | Result | +| --- | --- | --- | +| Golden count (`golden_http.py`, 512 tokens, greedy) | `ba28cfb7c5b9` | PASS drafted = plain, 4.20 tokens a round, 11.6 s | +| Golden prose | `dae7e2a5c84e` | PASS drafted = plain, 1.92 tokens a round, 17.1 s | +| Golden code | `db45a54eb863` | PASS drafted = plain, 3.01 tokens a round, 13.6 s | +| Concurrent (`bench_concurrent.py --levels 1,2,4 --temperatures 0,1 --reps 3 --alone --serial`) | 12 cells | PASS: 84 replies equal to their alone runs and 30 alone runs equal to `"draft": false`, 0 unequal or failed | +| Resume (`resume_http.py`, a 6,595-token chat) | `1e3f89236de5` | PASS: repeated, `"draft": false` and two at once resume from 6,144 cached tokens, each equal to the cold reply | + +The three golden ids are the 1.1.5-era receipt's (`tp2/serve/ex-fl`): FP4-Local's greedy replies have not moved since. + +Startup and memory (process-owned CUDA buffers from `TF_CUDA_MEMORY_RECEIPTS`, `memory-rank*.json`): + +| Launch | Model on each rank | Peak on each rank | After cleanup | Plan | +| --- | --- | --- | --- | --- | +| `ex/`, 40,960 tokens, 4 streams | 90.20 GiB | 103.31 GiB | 0.00 | 324 pages of 512 rows (2.02 GiB), a 10.4 GiB prompt cache | +| `sp/`, 131,072 tokens, 4 streams, `--prompt-cache-gib 0` | 90.26 GiB | 97.33 GiB | 0.00 | 1,028 pages of 512 rows (6.40 GiB), no prompt cache | + +Both ranks exited 0 after SIGINT in both launches. The loads read the checkpoint from the page cache (71.5 to 91.5 s to +ready); `ex/`'s first launch of the day timed its windows (`41.07 ms at 1 row, 63.31 at 4, 180.35 at 32, a draft 1.98 +ms; experts classic`) and `sp/` kept them. + +Decode (`sp/`, 256 tokens, 5 reps after a warm-up, one stream): + +| Decode | Prompt | t | Median tok/s | All | +| --- | --- | ---: | ---: | --- | +| `"draft": false` (`openai_aligned.py nodraft`) | fibonacci-raw | 0 | 23.9 | 23.92, 23.53, 23.87, 23.91, 23.43 | +| `"draft": false` | gpu-chat-no-think | 0 | 23.9 | 23.86, 23.62, 23.77, 23.9, 23.89 | +| drafted (`bench_openai.py`) | fibonacci-raw | 0 | 42.3 | 41.94, 42.26, 42.33, 42.87, 40.49 | +| drafted | gpu-chat-no-think | 0 | 34.4 | 35.56, 35.2, 33.11, 34.35, 33.51 | +| drafted | fibonacci-raw | 1 | 42.7 | 44.4, 40.92, 42.68, 46.41, 42.07 | +| drafted | gpu-chat-no-think | 1 | 35.8 | 33.02, 37.72, 35.78, 34.47, 35.8 | + +Every greedy reply has one token hash across its reps. + +Cold prompts (`sp/`, `bench_cache.py --require-cold --tokens 16`, `--prompt-cache-gib 0`; every row 0 cached tokens and +one token hash): + +| Prompt tokens | First token, s (first, two repeats) | Prompt tok/s (median) | Two at once, s | +| ---: | --- | ---: | --- | +| 2,048 | 1.39, 1.83, 1.37 | 1,478 | 1.38, 2.82 | +| 8,192 | 5.69, 5.69, 5.70 | 1,439 | 5.68, 12.40 | +| 9,600 | 6.78, 6.79, 6.76 | 1,417 | 6.96, 14.66 | +| 32,768 | 22.43, 22.88, 22.88 | 1,432 | 23.05, 46.71 | +| 38,400 | 26.91, 26.87, 26.87 | 1,429 | 29.70, 54.59 | +| 65,536 | 45.84, 45.42, 45.91 | 1,430 | 48.26, 91.63 | + +Throughput by stream count (`ex/`, `bench_concurrent.py`, drafted, 256 tokens, aggregate tok/s): + +| Prompt | t | 1 stream | 2 streams | 4 streams | +| --- | ---: | ---: | ---: | ---: | +| code | 0 | 42.4 | 73.8 | 113.8 | +| chat | 0 | 34.0 | 56.5 | 85.4 | +| code | 1 | 44.9 | 58.0 | 71.9 | +| chat | 1 | 33.9 | 44.7 | 56.3 | + +## Beside the 1.1.5-era receipt + +The [earlier receipt](../glm-fp4local-80517fc3/README.md) ran `80517fc3` on 2026-10-20 on another GB10 pair (a two-rail +link, containers pinned to the efficiency cores, the page cache dropped before each load). The rows share its inputs: +`p9600.json` and `p38400.json` have its fixture hashes, the golden prompts are its `dc.json`, and the `PROMPTS` lists of +`bench_openai.py` and `bench_concurrent.py` are unchanged since v1.1.1. The machines differ, and so does the clients' +timing code (for example `c874a7e350` and `4a2596c630`), so the columns are side by side, not a before/after. + +| Row | 2026-10-20, `80517fc3` | 2026-11-15, `3a56d4eb92` | +| --- | --- | --- | +| Golden ids, count / prose / code | `ba28cfb7` / `dae7e2a5` / `db45a54e` | the same | +| Tokens a round with drafts, count / prose / code | 3.26 / 1.82 / 2.72 | 4.20 / 1.92 / 3.01 | +| `"draft": false` decode (tok/s) | 24.5 to 24.6 | 23.9 | +| Drafted aggregate, 4 streams, code / chat, t=0 (tok/s) | 86.4 / 58.7 | 113.8 / 85.4 | +| Cold prompt of 9,600 and 38,400 tokens (s) | 7.22 and 28.52 | 6.78 and 26.91 | +| Model on each rank at load end | 90.27 GiB | 90.20 GiB (40,960-token launch) | + +## Files + +- `ex/` and `sp/`: each launch's raw results (`golden.json`, `conc.json`, `resume.json`, `nodraft.json`, `drafted.json`, + `prefill*.json`), the clients' logs (`check-*.log`, `suite.log`), both ranks' server logs and memory receipts, and the + host's free memory before the launch and at ready. +- `runs.log`: each launch's start, ready, suite result and end. `commit.txt`: the commit, build, toolchain and binary. +- `inputs.txt`: the sha256 of each client and fixture the suites read, and where it comes from (the tested commit's + `tools/`, the earlier receipt's `tools/`, or the `openai_aligned.py tokens` command that makes it). +- `tools/`: `build.sh` (the build), `fl-env.sh` (the ranks' environment, with documentation addresses), `run.sh` (one + launch: rank 1 on the peer, rank 0 here, the suite, then both stopped by SIGINT), `rank.sh` (a rank under + `tools/memory_receipts.py`), `stop.sh`, `chain.sh` with `queue.txt` (the two launches), `suite-ex.sh`, `suite-sp.sh`, + and `summarize.py`, which prints this receipt's tables from `ex/` and `sp/` (`python3 tools/summarize.py . ex sp`). +- `SHA256SUMS` covers every file here except itself. diff --git a/docs/receipts/glm-fp4local-3a56d4eb/SHA256SUMS b/docs/receipts/glm-fp4local-3a56d4eb/SHA256SUMS new file mode 100644 index 00000000000..21c409f7fed --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/SHA256SUMS @@ -0,0 +1,52 @@ +505d0c01bb0ebf61b1ceb6464c30b76dde0187c80ef21dcde09bdbc9a342343d ./commit.txt +2094a9fedacfd6d7d23395be29799dba145577b146c9c18d8f44bd6d337a526a ./ex/check-conc.log +96013fa77adc109de90ff8ce894551656d53851e70acdf6dd13aa3cd44b7f38e ./ex/check-golden.log +37fd9b369897638f7b09bed5632b05c948597e70bf79fadaeba2da3c79da10b8 ./ex/check-resume.log +8d6b7c54d7acf67ff1f535ca2e19401a4251eac3ce237b30a64b1a220cb84882 ./ex/conc.json +ed71960adb10e4e01c3f43220c3ddd8c77632b93dfc988df4e880084889a168b ./ex/free-before.txt +56b829c56ce4729b4ffa281e3f48bfb849056785bd690a9c0c62a3a89f4b2f51 ./ex/free-ready.txt +916d4207c9c6709abf55e1de9e10a061c52812386ef182a7e1bb5bb3bfb3ee24 ./ex/golden.json +22eb40b913a2c208b9acb10aca5964c51ece817c81827d685d152865c8db0d6f ./ex/memory-rank0.json +3be7ad98548a6b55ab1aafaa73c10b0875fe809fdff371ad20b108a4dca2a5ca ./ex/memory-rank1.json +b8022bda86d5d6a8f2c71d90dcf17c643364a344435f6df532179cae5736dc84 ./ex/resume.json +fcd44b6321a95e2925bfc00983a3d3d995674dae2734cfa325a6597f7c6ef83e ./ex/server-rank0.log +de9c5b0405171ebdc374783f592453b5c6b3e0b0d6670b1f700eea788fd16068 ./ex/server-rank1.log +68c9138413280b0c8a252238a35c0b546a87ceb0249c4eea30b472a31e13aa37 ./ex/stop.txt +93ec057bb79c22ae2e3f01b5851528eccca6c536adc3a9aaaf2780f495510988 ./ex/suite.log +b6e92751ab275def8d16fa8b60f254f402557f66aa7dc788a60c4b2dd8fb276a ./inputs.txt +911f0e9e03628b8143c4ca9bbcbe9652d7e5f6280ab83a51d5e662fdf4ecfa32 ./README.md +0c572f7006205eee2f843d15311146a9c0aa2bb52a0be5ba73680dbccd769d9d ./runs.log +d6c6879941e119814b7608be237a1b0b2f63403a82861af40433ebf7534d35a0 ./sp/check-drafted.log +a9b48d619accc9ef1eea50c16bdb1c600a231e22551219bb1b4becfc12b9c2f9 ./sp/check-nodraft.log +17481c1d411e5046301436ee7d0ea7b245041521cfcf5f3360aad137cc3967b0 ./sp/check-prefill2048.log +7ca16345ef83745e35e796162de8e3f203e3127553b52c8d1269e5d051b9a97c ./sp/check-prefill32768.log +fd78f3a0b7392c5dc0f909b13984587fbc69872e8dc1a96b83526bc0c87f4800 ./sp/check-prefill38400.log +ac84e10d454b7bf1f295788a0354fa4c80c75c2a7ef5d158ce07f0710ebb020a ./sp/check-prefill65536.log +dfdf8fd6cecca49656096b8a60624234d0d3ead34617fd3c6150fc928f617e28 ./sp/check-prefill8192.log +cee67d547c08de8412318c60d9822767605fa639b54c49119017090e418c41ae ./sp/check-prefill9600.log +3b6b3116eb5b4ee088e9130efbb21792cf63bba8ced8ae318f956f5f86956525 ./sp/drafted.json +0c0008e46ed1deda4bf6bc3d6d7b926f4373b2dd593d96e8744a9a57a89adea3 ./sp/free-before.txt +4c7f40cfcaf07b64ab99e48b6355500affe196997c593581997f8470e8dae56d ./sp/free-ready.txt +836fe736d2f8eeaccd1f0b6c8e11d18c53e86558f8d13ff1937f1bbc50331d43 ./sp/memory-rank0.json +b44829a268f3a6391f4c540e10d514f15091aa12becbbc0144fc9d876e2edbe9 ./sp/memory-rank1.json +8b63ce1c2e59fbbab8c3d019b0d566f9283aa5fdad7cb6ca94aa90d34a16ee36 ./sp/nodraft.json +17481c1d411e5046301436ee7d0ea7b245041521cfcf5f3360aad137cc3967b0 ./sp/prefill2048.json +7ca16345ef83745e35e796162de8e3f203e3127553b52c8d1269e5d051b9a97c ./sp/prefill32768.json +fd78f3a0b7392c5dc0f909b13984587fbc69872e8dc1a96b83526bc0c87f4800 ./sp/prefill38400.json +ac84e10d454b7bf1f295788a0354fa4c80c75c2a7ef5d158ce07f0710ebb020a ./sp/prefill65536.json +dfdf8fd6cecca49656096b8a60624234d0d3ead34617fd3c6150fc928f617e28 ./sp/prefill8192.json +cee67d547c08de8412318c60d9822767605fa639b54c49119017090e418c41ae ./sp/prefill9600.json +015298cfa034b80fa95038efc9b513df5c6cbc141f0e7176693a539f0d45c918 ./sp/server-rank0.log +ece32702d32d383f71c82f9b78ce820bb6bb01c7797b975b6366e143cb265f46 ./sp/server-rank1.log +68c9138413280b0c8a252238a35c0b546a87ceb0249c4eea30b472a31e13aa37 ./sp/stop.txt +eba9e5188843223d401846ec38d9c015dcd2303886494a4bb8f48b73845293b0 ./sp/suite.log +2d8fd1a50729259e46c76dbbecf6be774fdc5b82737df522bc963c163cfc945e ./tools/build.sh +799690e81c76677d82783af8ff5db12d7ab34eb024ab9b4257bb15a6ce389171 ./tools/chain.sh +2230d1ec5435df8f94bfc96daab587a12cbc6dda1a080f8d7de321ea3a88472c ./tools/fl-env.sh +089f3da7b12454422a458b9c9810a8926fef556b4fdab57e2dac720fb4944c0a ./tools/queue.txt +a75e9b8e96221c70262cad31cc1b2619b54f4b0ee3265002ee4e5faf7dc042e9 ./tools/rank.sh +665fd73f05c4c3077ebd0f49fdac5e52d517de206eb63c256738942b73724ebc ./tools/run.sh +5aad5241a39f3e8d20b4de1cc7d94efb0646177410deeec68a67714ae047ddd9 ./tools/stop.sh +f16d168beb345e69f698b4abf6498b5fe2d831968234ef18a9d94f693ffe233b ./tools/suite-ex.sh +80f0daa213501856e2e10c87e1ea35c8303c41a12a63be12d133806c64f912c5 ./tools/suite-sp.sh +65f37f44f1bae0cd9e981c3fcb75447fc59e727c68d676157bb116fa5af35ad7 ./tools/summarize.py diff --git a/docs/receipts/glm-fp4local-3a56d4eb/commit.txt b/docs/receipts/glm-fp4local-3a56d4eb/commit.txt new file mode 100644 index 00000000000..60bb8c757f6 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/commit.txt @@ -0,0 +1,7 @@ +tested commit: 3a56d4eb922467685ca73f7487bb5cacd35b63a3 +tree: 9cdfd2c7c31deeef58a8a4475fd06a35ae12159f +later main, not rebuilt: 964174ea05879e6dde1de1198a3aae3ef8b46a3b (3a56d4eb92..: CHANGELOG.md zig/kernels/metal/deepseek_v41/fp8_mma.metal zig/src/core/contract/dsv41_fp8_mma_records.zig ) +build (git archive of the commit, empty .zig-cache): zig build -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=121 && zig build native -Dnvcc=/usr/local/cuda/bin/nvcc -Dtp-nvcc=/usr/local/cuda/bin/nvcc +Zig 0.17.0; nvcc release 13.5, V13.5.37; driver 580.178.04 (CUDA 13.0); NCCL 2.30.7 +tensorfold-native sha256 (the same file on both ranks): 6f3b114dc675e868d365277c8946a6f32defac11a8f0a987e63f11e3e8408325 +checkpoint: nvidia/GLM-5.3-Flash-FP4-Local at 76348ddb2be2e35e39ecfc00e75dc07703f4f3d5 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/check-conc.log b/docs/receipts/glm-fp4local-3a56d4eb/ex/check-conc.log new file mode 100644 index 00000000000..3d2bdea857d --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/check-conc.log @@ -0,0 +1,12 @@ +{"label": "ex", "prompt": "code", "temperature": 0.0, "thinking": "not applicable", "thinking_off_requested": false, "thinking_switch": true, "thinking_applicable": true, "streams": 1, "failed": 0, "unmeasured": 0, "aggregate_tps": 42.4, "per_stream_tps": 42.4, "ttft_s_max": 0.13, "request": {"ttft_s": 0.129, "decode_tps": 42.351, "prompt_ttft_tps": 108.266, "prefill_tps": 108.266, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 23.612, "round_gap_p50_ms": 71.664, "round_gap_p95_ms": 80.28, "tokens_per_chunk": 3.012, "headers_s": 0.001, "first_payload_s": 0.129, "first_content_s": 0.129, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.129, "last_output_s": 6.15}, "pooled": {"aggregate_prompt_ttft_tps": 108.266, "aggregate_prefill_tps": 108.266, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 23.612, "round_gap_p50_ms": 71.664, "round_gap_p95_ms": 80.28, "tokens_per_chunk": 3.012}, "completions": {"truncated": 3}, "timing_valid": true, "end_to_end_tps": 41.622582058637754, "makespan_s": 6.150507425016258, "alone": {"equal": 3, "unequal": 0, "failed": 0}, "serial": {"equal": 1, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "code", "temperature": 0.0, "thinking": "not applicable", "thinking_off_requested": false, "thinking_switch": true, "thinking_applicable": true, "streams": 2, "failed": 0, "unmeasured": 0, "aggregate_tps": 73.8, "per_stream_tps": 37.0, "ttft_s_max": 0.26, "request": {"ttft_s": 0.194, "decode_tps": 37.04, "prompt_ttft_tps": 80.801, "prefill_tps": 80.801, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 26.998, "round_gap_p50_ms": 80.585, "round_gap_p95_ms": 86.083, "tokens_per_chunk": 3.012, "headers_s": 0.001, "first_payload_s": 0.194, "first_content_s": 0.194, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.194, "last_output_s": 7.044}, "pooled": {"aggregate_prompt_ttft_tps": 108.993, "aggregate_prefill_tps": 108.993, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 26.865, "round_gap_p50_ms": 80.509, "round_gap_p95_ms": 86.116, "tokens_per_chunk": 3.012}, "completions": {"truncated": 6}, "timing_valid": true, "end_to_end_tps": 72.67885718024927, "makespan_s": 7.044689746981021, "steady_tps": 74.4, "alone": {"equal": 6, "unequal": 0, "failed": 0}, "serial": {"equal": 1, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "code", "temperature": 0.0, "thinking": "not applicable", "thinking_off_requested": false, "thinking_switch": true, "thinking_applicable": true, "streams": 4, "failed": 0, "unmeasured": 0, "aggregate_tps": 113.8, "per_stream_tps": 29.0, "ttft_s_max": 0.51, "request": {"ttft_s": 0.323, "decode_tps": 28.998, "prompt_ttft_tps": 44.979, "prefill_tps": 44.979, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 34.486, "round_gap_p50_ms": 102.912, "round_gap_p95_ms": 107.643, "tokens_per_chunk": 3.012, "headers_s": 0.002, "first_payload_s": 0.323, "first_content_s": 0.323, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.323, "last_output_s": 9.092}, "pooled": {"aggregate_prompt_ttft_tps": 109.02, "aggregate_prefill_tps": 109.02, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 34.391, "round_gap_p50_ms": 102.921, "round_gap_p95_ms": 107.657, "tokens_per_chunk": 3.012}, "completions": {"truncated": 12}, "timing_valid": true, "end_to_end_tps": 112.57504502171228, "makespan_s": 9.096154479018878, "steady_tps": 116.8, "alone": {"equal": 12, "unequal": 0, "failed": 0}, "serial": {"equal": 1, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "chat", "temperature": 0.0, "thinking": "off", "thinking_off_requested": true, "thinking_switch": true, "thinking_applicable": true, "streams": 1, "failed": 0, "unmeasured": 0, "aggregate_tps": 34.0, "per_stream_tps": 34.0, "ttft_s_max": 0.21, "request": {"ttft_s": 0.198, "decode_tps": 33.969, "prompt_ttft_tps": 161.354, "prefill_tps": 161.354, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 29.439, "round_gap_p50_ms": 63.076, "round_gap_p95_ms": 74.38, "tokens_per_chunk": 2.207, "headers_s": 0.001, "first_payload_s": 0.001, "first_content_s": 0.198, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.198, "last_output_s": 7.701}, "pooled": {"aggregate_prompt_ttft_tps": 161.354, "aggregate_prefill_tps": 161.354, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 29.439, "round_gap_p50_ms": 63.076, "round_gap_p95_ms": 74.38, "tokens_per_chunk": 2.207}, "completions": {"truncated": 3}, "timing_valid": true, "end_to_end_tps": 33.24022059367094, "makespan_s": 7.701513270003488, "alone": {"equal": 3, "unequal": 0, "failed": 0}, "serial": {"equal": 1, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "chat", "temperature": 0.0, "thinking": "off", "thinking_off_requested": true, "thinking_switch": true, "thinking_applicable": true, "streams": 2, "failed": 0, "unmeasured": 0, "aggregate_tps": 56.5, "per_stream_tps": 28.2, "ttft_s_max": 0.43, "request": {"ttft_s": 0.295, "decode_tps": 28.235, "prompt_ttft_tps": 120.807, "prefill_tps": 120.807, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 35.417, "round_gap_p50_ms": 80.253, "round_gap_p95_ms": 84.939, "tokens_per_chunk": 2.306, "headers_s": 0.002, "first_payload_s": 0.002, "first_content_s": 0.295, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.295, "last_output_s": 9.229}, "pooled": {"aggregate_prompt_ttft_tps": 164.51, "aggregate_prefill_tps": 164.51, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 35.047, "round_gap_p50_ms": 80.28, "round_gap_p95_ms": 84.93, "tokens_per_chunk": 2.306}, "completions": {"truncated": 6}, "timing_valid": true, "end_to_end_tps": 55.469507963751596, "makespan_s": 9.230296405992704, "steady_tps": 57.6, "alone": {"equal": 6, "unequal": 0, "failed": 0}, "serial": {"equal": 1, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "chat", "temperature": 0.0, "thinking": "off", "thinking_off_requested": true, "thinking_switch": true, "thinking_applicable": true, "streams": 4, "failed": 0, "unmeasured": 0, "aggregate_tps": 85.4, "per_stream_tps": 21.8, "ttft_s_max": 0.79, "request": {"ttft_s": 0.486, "decode_tps": 21.733, "prompt_ttft_tps": 68.542, "prefill_tps": 68.542, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 46.013, "round_gap_p50_ms": 102.689, "round_gap_p95_ms": 108.556, "tokens_per_chunk": 2.306, "headers_s": 0.002, "first_payload_s": 0.002, "first_content_s": 0.486, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.486, "last_output_s": 12.147}, "pooled": {"aggregate_prompt_ttft_tps": 165.111, "aggregate_prefill_tps": 165.111, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 45.73, "round_gap_p50_ms": 102.699, "round_gap_p95_ms": 108.367, "tokens_per_chunk": 2.306}, "completions": {"truncated": 12}, "timing_valid": true, "end_to_end_tps": 84.29277243740043, "makespan_s": 12.148135248018662, "steady_tps": 89.2, "alone": {"equal": 12, "unequal": 0, "failed": 0}, "serial": {"equal": 1, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "code", "temperature": 1.0, "thinking": "not applicable", "thinking_off_requested": false, "thinking_switch": true, "thinking_applicable": true, "streams": 1, "failed": 0, "unmeasured": 0, "aggregate_tps": 44.9, "per_stream_tps": 44.9, "ttft_s_max": 0.13, "request": {"ttft_s": 0.131, "decode_tps": 44.915, "prompt_ttft_tps": 107.002, "prefill_tps": 107.002, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 22.264, "round_gap_p50_ms": 72.205, "round_gap_p95_ms": 94.161, "tokens_per_chunk": 3.325, "headers_s": 0.001, "first_payload_s": 0.131, "first_content_s": 0.131, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.131, "last_output_s": 5.809}, "pooled": {"aggregate_prompt_ttft_tps": 107.002, "aggregate_prefill_tps": 107.002, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 22.264, "round_gap_p50_ms": 72.205, "round_gap_p95_ms": 94.161, "tokens_per_chunk": 3.325}, "completions": {"truncated": 3}, "timing_valid": true, "end_to_end_tps": 44.06755670382355, "makespan_s": 5.809262395021506, "alone": {"equal": 3, "unequal": 0, "failed": 0}, "serial": {"equal": 4, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "code", "temperature": 1.0, "thinking": "not applicable", "thinking_off_requested": false, "thinking_switch": true, "thinking_applicable": true, "streams": 2, "failed": 0, "unmeasured": 0, "aggregate_tps": 58.0, "per_stream_tps": 29.4, "ttft_s_max": 0.26, "request": {"ttft_s": 0.192, "decode_tps": 29.458, "prompt_ttft_tps": 81.168, "prefill_tps": 81.168, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 33.947, "round_gap_p50_ms": 107.824, "round_gap_p95_ms": 114.987, "tokens_per_chunk": 3.165, "headers_s": 0.001, "first_payload_s": 0.192, "first_content_s": 0.192, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.192, "last_output_s": 8.911}, "pooled": {"aggregate_prompt_ttft_tps": 109.805, "aggregate_prefill_tps": 109.805, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 33.526, "round_gap_p50_ms": 107.964, "round_gap_p95_ms": 114.979, "tokens_per_chunk": 3.16}, "completions": {"truncated": 6}, "timing_valid": true, "end_to_end_tps": 57.38007218886278, "makespan_s": 8.922958450013539, "steady_tps": 60.2, "alone": {"equal": 6, "unequal": 0, "failed": 0}, "serial": {"equal": 4, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "code", "temperature": 1.0, "thinking": "not applicable", "thinking_off_requested": false, "thinking_switch": true, "thinking_applicable": true, "streams": 4, "failed": 0, "unmeasured": 0, "aggregate_tps": 71.9, "per_stream_tps": 18.6, "ttft_s_max": 0.52, "request": {"ttft_s": 0.321, "decode_tps": 18.576, "prompt_ttft_tps": 45.115, "prefill_tps": 45.115, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 53.833, "round_gap_p50_ms": 171.254, "round_gap_p95_ms": 215.475, "tokens_per_chunk": 3.221, "headers_s": 0.002, "first_payload_s": 0.321, "first_content_s": 0.321, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.321, "last_output_s": 14.033}, "pooled": {"aggregate_prompt_ttft_tps": 108.384, "aggregate_prefill_tps": 108.384, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 53.925, "round_gap_p50_ms": 171.263, "round_gap_p95_ms": 216.513, "tokens_per_chunk": 3.2}, "completions": {"truncated": 12}, "timing_valid": true, "end_to_end_tps": 71.51349299805634, "makespan_s": 14.318976141017629, "steady_tps": 73.5, "alone": {"equal": 12, "unequal": 0, "failed": 0}, "serial": {"equal": 4, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "chat", "temperature": 1.0, "thinking": "off", "thinking_off_requested": true, "thinking_switch": true, "thinking_applicable": true, "streams": 1, "failed": 0, "unmeasured": 0, "aggregate_tps": 33.9, "per_stream_tps": 33.9, "ttft_s_max": 0.2, "request": {"ttft_s": 0.196, "decode_tps": 33.931, "prompt_ttft_tps": 163.524, "prefill_tps": 163.524, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 29.472, "round_gap_p50_ms": 63.874, "round_gap_p95_ms": 85.454, "tokens_per_chunk": 2.286, "headers_s": 0.001, "first_payload_s": 0.001, "first_content_s": 0.196, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.196, "last_output_s": 7.711}, "pooled": {"aggregate_prompt_ttft_tps": 163.524, "aggregate_prefill_tps": 163.524, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 29.472, "round_gap_p50_ms": 63.874, "round_gap_p95_ms": 85.454, "tokens_per_chunk": 2.286}, "completions": {"truncated": 3}, "timing_valid": true, "end_to_end_tps": 33.199096629143575, "makespan_s": 7.7110531909856945, "alone": {"equal": 3, "unequal": 0, "failed": 0}, "serial": {"equal": 4, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "chat", "temperature": 1.0, "thinking": "off", "thinking_off_requested": true, "thinking_switch": true, "thinking_applicable": true, "streams": 2, "failed": 0, "unmeasured": 0, "aggregate_tps": 44.7, "per_stream_tps": 22.6, "ttft_s_max": 0.4, "request": {"ttft_s": 0.289, "decode_tps": 22.622, "prompt_ttft_tps": 123.626, "prefill_tps": 123.626, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 44.207, "round_gap_p50_ms": 106.359, "round_gap_p95_ms": 135.958, "tokens_per_chunk": 2.462, "headers_s": 0.002, "first_payload_s": 0.002, "first_content_s": 0.289, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.289, "last_output_s": 11.604}, "pooled": {"aggregate_prompt_ttft_tps": 166.007, "aggregate_prefill_tps": 166.007, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 44.33, "round_gap_p50_ms": 106.335, "round_gap_p95_ms": 137.45, "tokens_per_chunk": 2.462}, "completions": {"truncated": 6}, "timing_valid": true, "end_to_end_tps": 44.12097789870904, "makespan_s": 11.604457207984524, "steady_tps": 45.7, "alone": {"equal": 6, "unequal": 0, "failed": 0}, "serial": {"equal": 4, "unequal": 0, "failed": 0}} +{"label": "ex", "prompt": "chat", "temperature": 1.0, "thinking": "off", "thinking_off_requested": true, "thinking_switch": true, "thinking_applicable": true, "streams": 4, "failed": 0, "unmeasured": 0, "aggregate_tps": 56.3, "per_stream_tps": 14.4, "ttft_s_max": 0.78, "request": {"ttft_s": 0.486, "decode_tps": 14.469, "prompt_ttft_tps": 68.267, "prefill_tps": 68.267, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 69.112, "round_gap_p50_ms": 167.721, "round_gap_p95_ms": 210.443, "tokens_per_chunk": 2.462, "headers_s": 0.003, "first_payload_s": 0.003, "first_content_s": 0.486, "first_reasoning_s": null, "first_tool_s": null, "first_output_s": 0.486, "last_output_s": 18.138}, "pooled": {"aggregate_prompt_ttft_tps": 165.72, "aggregate_prefill_tps": 165.72, "itl_mean_ms": null, "itl_p50_ms": null, "itl_p95_ms": null, "tpot_ms": null, "chunk_tpot_estimate_ms": 69.176, "round_gap_p50_ms": 167.703, "round_gap_p95_ms": 212.379, "tokens_per_chunk": 2.456}, "completions": {"truncated": 12}, "timing_valid": true, "end_to_end_tps": 55.909513358104235, "makespan_s": 18.31530876402394, "steady_tps": 58.0, "alone": {"equal": 12, "unequal": 0, "failed": 0}, "serial": {"equal": 4, "unequal": 0, "failed": 0}} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/check-golden.log b/docs/receipts/glm-fp4local-3a56d4eb/ex/check-golden.log new file mode 100644 index 00000000000..00560969fe8 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/check-golden.log @@ -0,0 +1,10 @@ +count drafts: 512 tokens, ba28cfb7c5b94418cb274891300c856ef827ac5d647505c33d6793a240e7ce48, 11.6 s, 4.19672131147541 a round +count plain: 512 tokens, ba28cfb7c5b94418cb274891300c856ef827ac5d647505c33d6793a240e7ce48, 23.7 s, 1.0019569471624266 a round +PASS count: drafts and plain equal +prose drafts: 512 tokens, dae7e2a5c84e5b6fb9d32a16a36fdb3abfa616b94c936b672c01ed51b18a08a6, 17.1 s, 1.9248120300751879 a round +prose plain: 512 tokens, dae7e2a5c84e5b6fb9d32a16a36fdb3abfa616b94c936b672c01ed51b18a08a6, 23.8 s, 1.0019569471624266 a round +PASS prose: drafts and plain equal +code drafts: 512 tokens, db45a54eb863ca46490cb8b9f235656c7b78494b7a175833d8b62403517c25f3, 13.6 s, 3.011764705882353 a round +code plain: 512 tokens, db45a54eb863ca46490cb8b9f235656c7b78494b7a175833d8b62403517c25f3, 23.7 s, 1.0019569471624266 a round +PASS code: drafts and plain equal +exit 0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/check-resume.log b/docs/receipts/glm-fp4local-3a56d4eb/ex/check-resume.log new file mode 100644 index 00000000000..2d4231d003f --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/check-resume.log @@ -0,0 +1,6 @@ +first: prompt 6595 cached 0 tokens 64 6.533 s sha256 1e3f89236de5 +repeated: prompt 6595 cached 6144 tokens 64 2.154 s sha256 1e3f89236de5 same_as_first True +draft_false: prompt 6595 cached 6144 tokens 64 3.527 s sha256 1e3f89236de5 same_as_first True +concurrent: prompt 6595 cached 6144 tokens 64 3.143 s sha256 1e3f89236de5 same_as_first True +concurrent: prompt 6595 cached 6144 tokens 64 3.192 s sha256 1e3f89236de5 same_as_first True +exit 0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/conc.json b/docs/receipts/glm-fp4local-3a56d4eb/ex/conc.json new file mode 100644 index 00000000000..e729f0347d3 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/conc.json @@ -0,0 +1,17624 @@ +{ + "label": "ex", + "tokens": 256, + "mixed": false, + "cells": [ + { + "prompt": "code", + "temperature": 0.0, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 1, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 42.4, + "per_stream_tps": 42.4, + "ttft_s_max": 0.13, + "request": { + "ttft_s": 0.129, + "decode_tps": 42.351, + "prompt_ttft_tps": 108.266, + "prefill_tps": 108.266, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 23.612, + "round_gap_p50_ms": 71.664, + "round_gap_p95_ms": 80.28, + "tokens_per_chunk": 3.012, + "headers_s": 0.001, + "first_payload_s": 0.129, + "first_content_s": 0.129, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.129, + "last_output_s": 6.15 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 108.266, + "aggregate_prefill_tps": 108.266, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 23.612, + "round_gap_p50_ms": 71.664, + "round_gap_p95_ms": 80.28, + "tokens_per_chunk": 3.012 + }, + "completions": { + "truncated": 3 + }, + "timing_valid": true, + "end_to_end_tps": 41.622582058637754, + "makespan_s": 6.150507425016258, + "alone": { + "equal": 3, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 1, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 39.42662648728088, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 6.598462984984508, + "end_to_end_tps": 38.796913854416516, + "timing_valid": true, + "per_stream_tps": [ + 39.4 + ], + "ttft_s": [ + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.1305970069952309, + "decode_tps": 39.42662648728088, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 107.20000650942364, + "prefill_tps": 107.20000650942364, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 25.363569980368528, + "round_gap_p50_ms": 72.22596599604003, + "round_gap_p95_ms": 98.59111899277195, + "tokens_per_chunk": 2.942528735632184, + "headers_s": 0.0010172220063395798, + "first_payload_s": 0.1305970069952309, + "first_content_s": 0.1305970069952309, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1305970069952309, + "last_output_s": 6.598307351989206 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 25.363569980368528, + "round_gap_p50_ms": 72.22596599604003, + "round_gap_p95_ms": 98.59111899277195, + "round_gap_mean_ms": 75.205934244116, + "tokens_per_chunk": 2.942528735632184, + "aggregate_prompt_ttft_tps": 107.20000650942364, + "aggregate_prefill_tps": 107.20000650942364 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258297.640148584, + "first": 258297.770745591, + "last": 258304.238455936, + "end": 258304.238611569, + "elapsed_s": 6.598462984984508, + "chunk_offsets_s": [ + 0.1305970069952309, + 0.19557773298583925, + 0.266965213988442, + 0.338470471004257, + 0.4110253030085005, + 0.4867510639887769, + 0.5634410220081918, + 0.6442231310065836, + 0.7244580689875875, + 0.7976405679946765, + 0.8733306810026988, + 0.9450788369867951, + 1.0236103250063024, + 1.100764942006208, + 1.176658768003108, + 1.252693858987186, + 1.3373884540051222, + 1.4267347379936837, + 1.4992483379901387, + 1.5723014760005753, + 1.6445274419966154, + 1.7065785999875516, + 1.776120678987354, + 1.8657330450078007, + 1.9584790439985227, + 2.0408804749895353, + 2.1310739800101146, + 2.2296650990028866, + 2.3306662479881197, + 2.41110729900538, + 2.501677735010162, + 2.623732679989189, + 2.7461031620041467, + 2.8536456910078414, + 2.946789901005104, + 3.0143380500085186, + 3.082696361991111, + 3.149359689996345, + 3.2180345169908833, + 3.2902885469957255, + 3.371268577990122, + 3.4390081349993125, + 3.5085148710059, + 3.5771333139855415, + 3.647157044004416, + 3.7149449219868984, + 3.786504852992948, + 3.8594667429861147, + 3.9331447659933474, + 4.000934371986659, + 4.072355901997071, + 4.147627676982665, + 4.222096760000568, + 4.291781912004808, + 4.360424787009833, + 4.435559906007256, + 4.517777575994842, + 4.589452034997521, + 4.660324969998328, + 4.73569532300462, + 4.802623723982833, + 4.8696624939912, + 4.93594946799567, + 5.001709158997983, + 5.075641870993422, + 5.143798662989866, + 5.214461533003487, + 5.284303054999327, + 5.348691121995216, + 5.418098082009237, + 5.489500700001372, + 5.56443530600518, + 5.637103354994906, + 5.705464180995477, + 5.772943001007661, + 5.839844058995368, + 5.908072788006393, + 5.980725909001194, + 6.049724193988368, + 6.121045787993353, + 6.196592892985791, + 6.267862470995169, + 6.338379547989462, + 6.411130382010015, + 6.48561546599376, + 6.549567370995646, + 6.598307351989206 + ], + "chunk_gaps_ms": { + "count": 86, + "p50": 72.23999800044112, + "p95": 98.59111899277195, + "max": 122.37048201495782 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 42.42431490912143, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 6.139536504022544, + "end_to_end_tps": 41.696958692610124, + "timing_valid": true, + "per_stream_tps": [ + 42.4 + ], + "ttft_s": [ + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.12869128701277077, + "decode_tps": 42.42431490912143, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 108.78747368973549, + "prefill_tps": 108.78747368973549, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 23.571388298011037, + "round_gap_p50_ms": 70.8823130116798, + "round_gap_p95_ms": 80.27958098682575, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0010140690137632191, + "first_payload_s": 0.12869128701277077, + "first_content_s": 0.12869128701277077, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.12869128701277077, + "last_output_s": 6.1393953030055854 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 23.571388298011037, + "round_gap_p50_ms": 70.8823130116798, + "round_gap_p95_ms": 80.27958098682575, + "round_gap_mean_ms": 71.55600019039065, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 108.78747368973549, + "aggregate_prefill_tps": 108.78747368973549 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258304.239581799, + "first": 258304.368273086, + "last": 258310.378977102, + "end": 258310.379118303, + "elapsed_s": 6.139536504022544, + "chunk_offsets_s": [ + 0.12869128701277077, + 0.1929225860221777, + 0.26282532399636693, + 0.3323069880134426, + 0.4056374090141617, + 0.47970125800929964, + 0.5517994649999309, + 0.6300948570133187, + 0.7091151500062551, + 0.7826496050111018, + 0.8583252230018843, + 0.9313253540021833, + 1.008685894019436, + 1.084880491020158, + 1.1631687640037853, + 1.2454053790133912, + 1.3282044770021457, + 1.3985201290051918, + 1.4656172520190012, + 1.533512428024551, + 1.602453385014087, + 1.673613714025123, + 1.739007340016542, + 1.8118664310022723, + 1.887707826012047, + 1.9612621210108045, + 2.0292102730018087, + 2.101382464024937, + 2.171148098015692, + 2.2448864900215995, + 2.3189972520049196, + 2.39473775101942, + 2.4671182000020053, + 2.5357367070100736, + 2.60912791301962, + 2.676214044011431, + 2.744267813017359, + 2.8143108720250893, + 2.888549587019952, + 2.9590676090156194, + 3.034239641012391, + 3.102795397018781, + 3.173411580006359, + 3.2403660940181, + 3.311183734011138, + 3.3813854190229904, + 3.451018540014047, + 3.5203256439999677, + 3.5999795730167534, + 3.675733256008243, + 3.7497496330179274, + 3.819231330009643, + 3.8878227340173908, + 3.960984803008614, + 4.035692433011718, + 4.1182767460122705, + 4.203203328012023, + 4.278049599000951, + 4.345981895021396, + 4.412925226002699, + 4.479662571015069, + 4.542188246006845, + 4.608803798008012, + 4.6796861110196915, + 4.755707060015993, + 4.825314037007047, + 4.8896407459978946, + 4.959578285022872, + 5.030930745007936, + 5.102992616011761, + 5.171414643002208, + 5.241355990001466, + 5.315532897016965, + 5.382586213003378, + 5.451143313024659, + 5.524134805018548, + 5.592246671003522, + 5.661565918009728, + 5.728555730020162, + 5.800927043019328, + 5.881206624006154, + 5.952961180999409, + 6.027150217007147, + 6.090179206017638, + 6.1393953030055854 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 71.02132101135794, + "p95": 80.27958098682575, + "max": 84.92658199975267 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 42.35108238538767, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 6.150507425016258, + "end_to_end_tps": 41.622582058637754, + "timing_valid": true, + "per_stream_tps": [ + 42.4 + ], + "ttft_s": [ + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.12931148501229472, + "decode_tps": 42.35108238538767, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 108.2657120415012, + "prefill_tps": 108.2657120415012, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 23.612147403935737, + "round_gap_p50_ms": 71.66439801221713, + "round_gap_p95_ms": 79.02736600954086, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.00892342600855045, + "first_payload_s": 0.12931148501229472, + "first_content_s": 0.12931148501229472, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.12931148501229472, + "last_output_s": 6.150409073015908 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 23.612147403935737, + "round_gap_p50_ms": 71.66439801221713, + "round_gap_p95_ms": 79.02736600954086, + "round_gap_mean_ms": 71.6797331905192, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 108.2657120415012, + "aggregate_prefill_tps": 108.2657120415012 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258310.379726914, + "first": 258310.509038399, + "last": 258316.530135987, + "end": 258316.530234339, + "elapsed_s": 6.150507425016258, + "chunk_offsets_s": [ + 0.12931148501229472, + 0.19490194402169436, + 0.26457421900704503, + 0.3338460750237573, + 0.4078713650233112, + 0.4890194790204987, + 0.5663216030225158, + 0.644226531003369, + 0.7232538970129099, + 0.7968765620025806, + 0.872752103023231, + 0.9443789000215475, + 1.0217828809982166, + 1.0980142960033845, + 1.1761725050164387, + 1.2572219630237669, + 1.3354443650168832, + 1.4036523910181131, + 1.470902875997126, + 1.5396407289954368, + 1.611305127007654, + 1.6788942060084082, + 1.7448160750209354, + 1.8180375859956257, + 1.8941748719953466, + 1.9666006980114616, + 2.03556277701864, + 2.1070180690148845, + 2.1760156200034544, + 2.2501466870016884, + 2.326011876022676, + 2.402230651001446, + 2.4744836919999216, + 2.5445794090046547, + 2.6181449849973433, + 2.6864237480040174, + 2.762261416995898, + 2.8353899189969525, + 2.9071236140152905, + 2.9770064660115167, + 3.052987112023402, + 3.121677973016631, + 3.1914959130226634, + 3.2593134570051916, + 3.329532375006238, + 3.400636130012572, + 3.4696668010146823, + 3.5400561840215232, + 3.62023840501206, + 3.694834082998568, + 3.7698502280109096, + 3.8391782130056527, + 3.908153044001665, + 3.9812411300081294, + 4.054205199005082, + 4.127682487014681, + 4.2061674510187, + 4.280936427006964, + 4.349976922007045, + 4.421907865995308, + 4.488732493016869, + 4.551665002014488, + 4.618806479003979, + 4.691518003004603, + 4.7668780219974, + 4.836216312018223, + 4.9008261270064395, + 4.970246896002209, + 5.04236310502165, + 5.114382258005207, + 5.182272459001979, + 5.252007182018133, + 5.326845725998282, + 5.393931123020593, + 5.461985421017744, + 5.535267701023258, + 5.6030934220179915, + 5.6718419160170015, + 5.738778832019307, + 5.812037655006861, + 5.894685987004777, + 5.963814290997107, + 6.03898768502404, + 6.102318724995712, + 6.150409073015908 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 71.69904651527759, + "p95": 79.02736600954086, + "max": 82.6483319979161 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + } + ] + }, + { + "prompt": "code", + "temperature": 0.0, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 2, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 73.8, + "per_stream_tps": 37.0, + "ttft_s_max": 0.26, + "request": { + "ttft_s": 0.194, + "decode_tps": 37.04, + "prompt_ttft_tps": 80.801, + "prefill_tps": 80.801, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.998, + "round_gap_p50_ms": 80.585, + "round_gap_p95_ms": 86.083, + "tokens_per_chunk": 3.012, + "headers_s": 0.001, + "first_payload_s": 0.194, + "first_content_s": 0.194, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.194, + "last_output_s": 7.044 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 108.993, + "aggregate_prefill_tps": 108.993, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.865, + "round_gap_p50_ms": 80.509, + "round_gap_p95_ms": 86.116, + "tokens_per_chunk": 3.012 + }, + "completions": { + "truncated": 6 + }, + "timing_valid": true, + "end_to_end_tps": 72.67885718024927, + "makespan_s": 7.044689746981021, + "steady_tps": 74.4, + "alone": { + "equal": 6, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 1, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 74.37202356659205, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 6.995155861019157, + "end_to_end_tps": 73.19350850395553, + "timing_valid": true, + "steady_tps": 75.0081133385265, + "per_stream_tps": [ + 37.9, + 37.2 + ], + "ttft_s": [ + 0.26, + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.25829697199515067, + "decode_tps": 37.89210707830235, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.20117739615949, + "prefill_tps": 54.20117739615949, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.390720313693414, + "round_gap_p50_ms": 80.14825498685241, + "round_gap_p95_ms": 85.711966996314, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0013998639769852161, + "first_payload_s": 0.25829697199515067, + "first_content_s": 0.25829697199515067, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.25829697199515067, + "last_output_s": 6.9879306519869715 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.13087876001372933, + "decode_tps": 37.19588046437607, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 106.96922860922112, + "prefill_tps": 106.96922860922112, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.88469764703483, + "round_gap_p50_ms": 80.3082229977008, + "round_gap_p95_ms": 85.69502201862633, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0012149510148447007, + "first_payload_s": 0.13087876001372933, + "first_content_s": 0.13087876001372933, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13087876001372933, + "last_output_s": 6.986476660007611 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.637708980364124, + "round_gap_p50_ms": 80.24375801323913, + "round_gap_p95_ms": 85.711966996314, + "round_gap_mean_ms": 80.86447369039108, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 108.24922245602005, + "aggregate_prefill_tps": 108.24922245602005 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258316.531835516, + "first": 258316.790132488, + "last": 258323.519766168, + "end": 258323.519881417, + "elapsed_s": 6.988045901001897, + "chunk_offsets_s": [ + 0.25829697199515067, + 0.334908901975723, + 0.4161763619922567, + 0.4966983939812053, + 0.5795107429730706, + 0.664539375982713, + 0.7447831339959521, + 0.8236007730010897, + 0.9050220579956658, + 0.9831586039799731, + 1.0612290859862696, + 1.1400002769951243, + 1.2205291249847505, + 1.2996333729824983, + 1.3789324539829977, + 1.4608146690006834, + 1.5452262589824386, + 1.628242192993639, + 1.7064338609925471, + 1.78544297197368, + 1.866552719991887, + 1.9450439249922056, + 2.021191307983827, + 2.1025968979811296, + 2.1825430390017573, + 2.2665391379850917, + 2.3465895039844327, + 2.428219461988192, + 2.508002577989828, + 2.59227938298136, + 2.6785737359896302, + 2.7668617320014164, + 2.8437776479986496, + 2.9208466049749404, + 3.002694196999073, + 3.0798750429821666, + 3.1592176129925065, + 3.2403693449741695, + 3.3224153209885117, + 3.401962467993144, + 3.482026945974212, + 3.5620112639735453, + 3.6432559569948353, + 3.7116582739981823, + 3.7943820469954517, + 3.8767015769844875, + 3.9575659799738787, + 4.035899119975511, + 4.118914446997223, + 4.204717948974576, + 4.289306227990892, + 4.370820153999375, + 4.450714742997661, + 4.534501802001614, + 4.6195750609913375, + 4.7022764179855585, + 4.784507723990828, + 4.870297593995929, + 4.948150555981556, + 5.025717644981341, + 5.102993866981706, + 5.177185720996931, + 5.255605917976936, + 5.3344378779875115, + 5.413071435992606, + 5.493531243992038, + 5.569034400978126, + 5.6500123890000395, + 5.731790572986938, + 5.816737238987116, + 5.897302951983875, + 5.976414033997571, + 6.0544637969869655, + 6.133701150974957, + 6.213148601993453, + 6.296790155989584, + 6.376938410976436, + 6.456769432988949, + 6.535121629975038, + 6.617818906990578, + 6.6991847369936295, + 6.778433962987037, + 6.864145929983351, + 6.93431486497866, + 6.9879306519869715 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 80.19600650004577, + "p95": 85.711966996314, + "max": 88.28799601178616 + } + }, + { + "start": 258316.531470122, + "first": 258316.662348882, + "last": 258323.517946782, + "end": 258323.526625983, + "elapsed_s": 6.995155861019157, + "chunk_offsets_s": [ + 0.13087876001372933, + 0.33512101499945857, + 0.41624215501360595, + 0.4967760099971201, + 0.579712840000866, + 0.6646274400118273, + 0.7449634550139308, + 0.82346302800579, + 0.9055853890022263, + 0.9832847170182504, + 1.061375727003906, + 1.1400942449981812, + 1.2201863230147865, + 1.2999184300133493, + 1.3790658790094312, + 1.4607315490138717, + 1.5457951580174267, + 1.6283859219984151, + 1.7063664839952253, + 1.7856793260143604, + 1.8665280959976371, + 1.945218645996647, + 2.0214004139997996, + 2.1023726560233627, + 2.1826808790210634, + 2.2665826580196153, + 2.346384525997564, + 2.4283944710041396, + 2.508136723015923, + 2.5924625680199824, + 2.6788069210015237, + 2.7670980850234628, + 2.8440314730105456, + 2.921447792003164, + 3.003167144022882, + 3.0799175550055224, + 3.1593471170053817, + 3.2403333760157693, + 3.32246559401392, + 3.402217078022659, + 3.482054034015164, + 3.5621444650168996, + 3.6434572380094323, + 3.7119059870019555, + 3.794458943011705, + 3.876732777018333, + 3.957371835014783, + 4.036112257017521, + 4.118859901995165, + 4.204953134001698, + 4.289431765006157, + 4.370876138011226, + 4.450906008016318, + 4.534524570015492, + 4.620167464017868, + 4.702471283002524, + 4.78470959700644, + 4.870372043020325, + 4.948381437017815, + 5.025739133008756, + 5.103242429002421, + 5.177394426020328, + 5.255683758005034, + 5.3345756540074944, + 5.413104892009869, + 5.493641677021515, + 5.569193314004224, + 5.649676322995219, + 5.731803469010629, + 5.816921863995958, + 5.897411657002522, + 5.976377345010405, + 6.05455590900965, + 6.1336303660064, + 6.2132013060036115, + 6.296682636020705, + 6.376884922996396, + 6.4568389850028325, + 6.535254414018709, + 6.617865307023749, + 6.699387666012626, + 6.778583612001967, + 6.864278634020593, + 6.934510802006116, + 6.986476660007611 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 80.32211899990216, + "p95": 85.69502201862633, + "max": 204.24225498572923 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 73.76695591174615, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 7.044689746981021, + "end_to_end_tps": 72.67885718024927, + "timing_valid": true, + "steady_tps": 74.35052078203746, + "per_stream_tps": [ + 37.6, + 36.9 + ], + "ttft_s": [ + 0.26, + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.2562536059995182, + "decode_tps": 37.56895755627344, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.63337753001736, + "prefill_tps": 54.63337753001736, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.617720188326476, + "round_gap_p50_ms": 80.48355398932472, + "round_gap_p95_ms": 86.11566599574871, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0010508859995752573, + "first_payload_s": 0.2562536059995182, + "first_content_s": 0.2562536059995182, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.2562536059995182, + "last_output_s": 7.04377225402277 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.13044347998220474, + "decode_tps": 36.88454633130639, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 107.3261768385043, + "prefill_tps": 107.3261768385043, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 27.111625313694937, + "round_gap_p50_ms": 80.68707399070263, + "round_gap_p95_ms": 86.05001698015258, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0010053659789264202, + "first_payload_s": 0.13044347998220474, + "first_content_s": 0.13044347998220474, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13044347998220474, + "last_output_s": 7.043907934974413 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 26.864672751010705, + "round_gap_p50_ms": 80.50891399034299, + "round_gap_p95_ms": 86.11566599574871, + "round_gap_mean_ms": 81.5534708512825, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 109.12369836299636, + "aggregate_prefill_tps": 109.12369836299636 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258323.527797189, + "first": 258323.784050795, + "last": 258330.571569443, + "end": 258330.572150998, + "elapsed_s": 7.044353809003951, + "chunk_offsets_s": [ + 0.2562536059995182, + 0.33151154601364397, + 0.41256249402067624, + 0.49307140801101923, + 0.5764575530192815, + 0.6614336920029018, + 0.7438949200150091, + 0.8228667050134391, + 0.9056280790246092, + 0.9835455540160183, + 1.061570213001687, + 1.1406093270052224, + 1.2207774220150895, + 1.3007937250076793, + 1.3800623429997358, + 1.4620113130076788, + 1.547379630006617, + 1.6277079980063718, + 1.7077251650043763, + 1.7870312560116872, + 1.869927143008681, + 1.952061985997716, + 2.0439263870066497, + 2.111190059018554, + 2.191673613007879, + 2.2749331500090193, + 2.354852076008683, + 2.437783979024971, + 2.5179218990087975, + 2.6022794900054578, + 2.6883951560012065, + 2.772687211021548, + 2.8496225050184876, + 2.928026031004265, + 3.0075579950062092, + 3.085087341023609, + 3.1650794990127906, + 3.246145985001931, + 3.3284830050251912, + 3.4079246490146033, + 3.4883925059984904, + 3.5680942480103113, + 3.649243310006568, + 3.7179473740106914, + 3.8025062310043722, + 3.8843871360004414, + 3.9642617590143345, + 4.0427116860228125, + 4.1254065000102855, + 4.211370693024946, + 4.2963424480112735, + 4.37800738401711, + 4.457562853000127, + 4.541316954011563, + 4.625042238010792, + 4.7080737900105305, + 4.79026209001313, + 4.87588860100368, + 4.956885518011404, + 5.035810264002066, + 5.124010597006418, + 5.2122462750121485, + 5.310071926011005, + 5.392370530025801, + 5.471598702017218, + 5.551896991004469, + 5.6279129199974705, + 5.707970632007346, + 5.789622705022339, + 5.873390342021594, + 5.952876979019493, + 6.031792957015568, + 6.110758711001836, + 6.189778241008753, + 6.269524431001628, + 6.353269348008325, + 6.432180702016922, + 6.512429103022441, + 6.590471172006801, + 6.6721991170197725, + 6.753267411026172, + 6.8356240800058, + 6.9215307050035335, + 6.992296606011223, + 7.04377225402277 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 80.49623398983385, + "p95": 86.11566599574871, + "max": 97.82565099885687 + } + }, + { + "start": 258323.527461251, + "first": 258323.657904731, + "last": 258330.571369186, + "end": 258330.571601491, + "elapsed_s": 7.044140240002889, + "chunk_offsets_s": [ + 0.13044347998220474, + 0.3320366370026022, + 0.41272371099330485, + 0.4930083829967771, + 0.576445104990853, + 0.6619667829945683, + 0.7443970829772297, + 0.8230196819931734, + 0.905792751989793, + 0.983664867002517, + 1.0617012539878488, + 1.1406733429757878, + 1.2207778379961383, + 1.3007699489826337, + 1.3801081359852105, + 1.4619766410032753, + 1.5473738219880033, + 1.6277976949932054, + 1.7077681579976343, + 1.7870257519825827, + 1.869851542985998, + 1.9520363379851915, + 2.0290524959855247, + 2.111064265976893, + 2.1918679979862645, + 2.2751560949836858, + 2.3548483479826245, + 2.437821963976603, + 2.5178058659948874, + 2.6024397629953455, + 2.688489779975498, + 2.7728225399914663, + 2.849501895980211, + 2.928248383977916, + 3.007535098993685, + 3.085023227991769, + 3.1649941069772467, + 3.246061503974488, + 3.328516204986954, + 3.408428347989684, + 3.488240170001518, + 3.5682616089761723, + 3.6493407980015036, + 3.718486625002697, + 3.802693031990202, + 3.8845920659950934, + 3.9644590399984736, + 4.042600228975061, + 4.125556276994757, + 4.211527813982684, + 4.296206142986193, + 4.3781159129866865, + 4.457677749975119, + 4.541498234990286, + 4.625205038988497, + 4.708141182985855, + 4.79010658498737, + 4.875966233987128, + 4.9571503039915115, + 5.036011032992974, + 5.124228917993605, + 5.212791845988249, + 5.3102615749812685, + 5.392243985988898, + 5.471704094001325, + 5.552049535996048, + 5.627845223993063, + 5.708057352981996, + 5.789778753998689, + 5.873522934998618, + 5.952916546986671, + 6.031933485995978, + 6.110630982002476, + 6.189642896002624, + 6.269653055991512, + 6.353402628999902, + 6.43205954899895, + 6.512274141976377, + 6.590361746988492, + 6.672326909989351, + 6.753830182977254, + 6.8357915859960485, + 6.9217087229772005, + 6.992340125987539, + 7.043907934974413 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 80.74540300003719, + "p95": 86.05001698015258, + "max": 201.59315702039748 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 70.41344924157264, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 7.373663428006694, + "end_to_end_tps": 69.43631276351975, + "timing_valid": true, + "steady_tps": 70.91493472794969, + "per_stream_tps": [ + 35.8, + 35.2 + ], + "ttft_s": [ + 0.26, + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.25679710201802664, + "decode_tps": 35.83113936023974, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.517749187906446, + "prefill_tps": 54.517749187906446, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 27.908685513630545, + "round_gap_p50_ms": 81.06869499897584, + "round_gap_p95_ms": 108.66753800655715, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0009429019992239773, + "first_payload_s": 0.25679710201802664, + "first_content_s": 0.25679710201802664, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.25679710201802664, + "last_output_s": 7.373511907993816 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.13067714701173827, + "decode_tps": 35.20951521513952, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 107.13426425465525, + "prefill_tps": 107.13426425465525, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 28.40141347842291, + "round_gap_p50_ms": 81.11927000572905, + "round_gap_p95_ms": 108.85704300017096, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0008842770184855908, + "first_payload_s": 0.13067714701173827, + "first_content_s": 0.13067714701173827, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13067714701173827, + "last_output_s": 7.37303758400958 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 28.155049496026727, + "round_gap_p50_ms": 81.08635901589878, + "round_gap_p95_ms": 108.85704300017096, + "round_gap_mean_ms": 85.47068597008113, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 108.99317051906417, + "aggregate_prefill_tps": 108.99317051906417 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258330.573229212, + "first": 258330.830026314, + "last": 258337.94674112, + "end": 258337.946792912, + "elapsed_s": 7.373563700006343, + "chunk_offsets_s": [ + 0.25679710201802664, + 0.3338310540129896, + 0.414611601998331, + 0.49497232399880886, + 0.5795297099975869, + 0.6644092090136837, + 0.7446877229958773, + 0.824676346994238, + 0.9064924209960736, + 0.9875787800119724, + 1.0660716830170713, + 1.1447670200141147, + 1.2269574649981223, + 1.307544172013877, + 1.3858800510060973, + 1.46815372799756, + 1.5526316899922676, + 1.6332728780107573, + 1.7118502779921982, + 1.7912483230174985, + 1.8720126319967676, + 1.9516148540133145, + 2.0282232350145932, + 2.1100688140140846, + 2.1894955309981015, + 2.290445921011269, + 2.3886645199963823, + 2.4938073490047827, + 2.5967602620075922, + 2.7054278000141494, + 2.817372940015048, + 2.9295269130088855, + 3.0294256010092795, + 3.136083015007898, + 3.24313150299713, + 3.347704618005082, + 3.455819991999306, + 3.5647394029947463, + 3.67811053499463, + 3.7749770779919345, + 3.8563139990146738, + 3.9364786090154666, + 4.020110390003538, + 4.089385769999353, + 4.173474882001756, + 4.255086763994768, + 4.336155458993744, + 4.4146839790046215, + 4.496854488999816, + 4.583706367993727, + 4.668924894998781, + 4.749570643005427, + 4.830002903006971, + 4.9141641430032905, + 4.9974991230119485, + 5.080989879992558, + 5.163468534999993, + 5.248860293999314, + 5.327931634004926, + 5.405979959992692, + 5.483494779007742, + 5.556878183007939, + 5.635889922996284, + 5.714798750006594, + 5.793204310000874, + 5.876943228999153, + 5.952408964018105, + 6.0324280060012825, + 6.115229351009475, + 6.198862891993485, + 6.2788588300172705, + 6.358890639006859, + 6.4373907599947415, + 6.516244515019935, + 6.596269061003113, + 6.679954794992227, + 6.759069174993783, + 6.83985382100218, + 6.917810498998733, + 6.999296813010005, + 7.08432802700554, + 7.164415661012754, + 7.249907132994849, + 7.321076301013818, + 7.373511907993816 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 81.07752700743731, + "p95": 108.66753800655715, + "max": 113.3711319998838 + } + }, + { + "start": 258330.573129484, + "first": 258330.703806631, + "last": 258337.946167068, + "end": 258337.946351502, + "elapsed_s": 7.373222018009983, + "chunk_offsets_s": [ + 0.13067714701173827, + 0.3337840129970573, + 0.4144163040036801, + 0.4949087389977649, + 0.579453084996203, + 0.664319992007222, + 0.7446083620015997, + 0.8245652579935268, + 0.9062797960068565, + 0.9873990660125855, + 1.0658920340065379, + 1.1446851789951324, + 1.2267677350027952, + 1.3074293870013207, + 1.3857867059996352, + 1.4681121110043023, + 1.552615209016949, + 1.6332603330083657, + 1.7117900050070602, + 1.7910632340062875, + 1.8719325670099352, + 1.9514761330210604, + 2.0281742910156026, + 2.1099386530113406, + 2.1896541400055867, + 2.2904171840054914, + 2.3888262959953863, + 2.4938519730058033, + 2.5967033180058934, + 2.7054597829992417, + 2.817577964015072, + 2.929687808995368, + 3.0292804469936527, + 3.1360368379973806, + 3.243119327002205, + 3.347726185020292, + 3.4557764230121393, + 3.5646334660123102, + 3.6781053180166055, + 3.7748400210111868, + 3.8561960460210685, + 3.9364106400171295, + 4.020026309008244, + 4.08992903699982, + 4.1733562250155956, + 4.255104940006277, + 4.335996833018726, + 4.414689994999208, + 4.496868712012656, + 4.5837346719927154, + 4.668750540993642, + 4.749436418002006, + 4.829901142016752, + 4.913975100993412, + 4.997257265000371, + 5.080938503000652, + 5.1632869169989135, + 5.248711732012453, + 5.327791616000468, + 5.405824086017674, + 5.483467657992151, + 5.556870358996093, + 5.635896977997618, + 5.714760317001492, + 5.79319183001644, + 5.877278942003613, + 5.95231795500149, + 6.0329625040176325, + 6.115214518009452, + 6.198813740018522, + 6.278769613010809, + 6.358715837995987, + 6.437419320020126, + 6.51607675399282, + 6.596265524014598, + 6.679901305993553, + 6.759013942995807, + 6.839724332006881, + 6.917801939009223, + 6.999281324999174, + 7.084181626007194, + 7.164274252019823, + 7.249818395997863, + 7.320991564018186, + 7.37303758400958 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 81.23764750780538, + "p95": 108.85704300017096, + "max": 203.10686598531902 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + } + ] + }, + { + "prompt": "code", + "temperature": 0.0, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 4, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 113.8, + "per_stream_tps": 29.0, + "ttft_s_max": 0.51, + "request": { + "ttft_s": 0.323, + "decode_tps": 28.998, + "prompt_ttft_tps": 44.979, + "prefill_tps": 44.979, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.486, + "round_gap_p50_ms": 102.912, + "round_gap_p95_ms": 107.643, + "tokens_per_chunk": 3.012, + "headers_s": 0.002, + "first_payload_s": 0.323, + "first_content_s": 0.323, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.323, + "last_output_s": 9.092 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 109.02, + "aggregate_prefill_tps": 109.02, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.391, + "round_gap_p50_ms": 102.921, + "round_gap_p95_ms": 107.657, + "tokens_per_chunk": 3.012 + }, + "completions": { + "truncated": 12 + }, + "timing_valid": true, + "end_to_end_tps": 112.57504502171228, + "makespan_s": 9.096154479018878, + "steady_tps": 116.8, + "alone": { + "equal": 12, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 1, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 113.80039399786904, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 9.096154479018878, + "end_to_end_tps": 112.57504502171228, + "timing_valid": true, + "steady_tps": 116.82988798906064, + "per_stream_tps": [ + 28.9, + 29.3, + 29.7, + 28.5 + ], + "ttft_s": [ + 0.26, + 0.39, + 0.51, + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.25826761199277826, + "decode_tps": 28.87597247206645, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.20733901543749, + "prefill_tps": 54.20733901543749, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.63086830988508, + "round_gap_p50_ms": 103.08592399815097, + "round_gap_p95_ms": 107.48922900529578, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0016801379970274866, + "first_payload_s": 0.25826761199277826, + "first_content_s": 0.25826761199277826, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.25826761199277826, + "last_output_s": 9.089139031013474 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.3854540540196467, + "decode_tps": 29.278410061449353, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 36.32080102415116, + "prefill_tps": 36.32080102415116, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.154860113688066, + "round_gap_p50_ms": 102.94801901909523, + "round_gap_p95_ms": 107.55964598502032, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0023759970208629966, + "first_payload_s": 0.3854540540196467, + "first_content_s": 0.3854540540196467, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3854540540196467, + "last_output_s": 9.094943383010104 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.5128712500154506, + "decode_tps": 29.716196423997754, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 27.29729927263078, + "prefill_tps": 27.29729927263078, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.651682258784476, + "round_gap_p50_ms": 102.65763298957609, + "round_gap_p95_ms": 107.51892498228699, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0016006480145733804, + "first_payload_s": 0.5128712500154506, + "first_content_s": 0.5128712500154506, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5128712500154506, + "last_output_s": 9.094050226005493 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.13197779800975695, + "decode_tps": 28.467470475833903, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 106.07844812629013, + "prefill_tps": 106.07844812629013, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.12781372159154, + "round_gap_p50_ms": 102.92089998256415, + "round_gap_p95_ms": 107.45343699818477, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0013235110091045499, + "first_payload_s": 0.13197779800975695, + "first_content_s": 0.13197779800975695, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13197779800975695, + "last_output_s": 9.089570297015598 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.39130610098729, + "round_gap_p50_ms": 102.92089998256415, + "round_gap_p95_ms": 107.55710100056604, + "round_gap_mean_ms": 104.40217923513998, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 109.02031793610277, + "aggregate_prefill_tps": 109.02031793610277 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258337.948986748, + "first": 258338.20725436, + "last": 258347.038125779, + "end": 258347.038583526, + "elapsed_s": 9.089596778008854, + "chunk_offsets_s": [ + 0.25826761199277826, + 0.6131224870041478, + 0.7163615470053628, + 0.817487380001694, + 0.9234983760106843, + 1.0299419820075855, + 1.1330279060057364, + 1.2334658619947731, + 1.3370460770092905, + 1.4366103170032147, + 1.538745291007217, + 1.6386826210073195, + 1.74185569799738, + 1.8432796119886916, + 1.9429944129951764, + 2.0475885689957067, + 2.1550777980010025, + 2.2582371780008543, + 2.358701248012949, + 2.461447073990712, + 2.563951779011404, + 2.665528526005801, + 2.7674918840057217, + 2.870691824995447, + 2.973827509005787, + 3.0790112529939506, + 3.181790614995407, + 3.2865585809922777, + 3.3887091719952878, + 3.4958611670008395, + 3.6038148629886564, + 3.7118763990001753, + 3.8104095140006393, + 3.9116775559959933, + 4.014798457006691, + 4.114366872992832, + 4.215751556010218, + 4.319918271008646, + 4.424319963000016, + 4.5254036679980345, + 4.630582885001786, + 4.73354727300466, + 4.8362888589908835, + 4.91268140199827, + 5.020081830996787, + 5.1229365059989505, + 5.22627065598499, + 5.326847366988659, + 5.43127059499966, + 5.538579983985983, + 5.644763654010603, + 5.749714406003477, + 5.853934401005972, + 5.9603371449920814, + 6.065390809002565, + 6.17127551799058, + 6.27684067300288, + 6.38324011999066, + 6.48439878699719, + 6.5842465499881655, + 6.684280106012011, + 6.78080313000828, + 6.881007487012539, + 6.982930333004333, + 7.08640669300803, + 7.1891243279969785, + 7.286224812007276, + 7.388464412011672, + 7.492767544987146, + 7.598811039002612, + 7.7037846710009035, + 7.804764695989434, + 7.90658987898496, + 8.00769052898977, + 8.110813846986275, + 8.21668732399121, + 8.318612506991485, + 8.420817500009434, + 8.522253703995375, + 8.62602888199035, + 8.72952736998559, + 8.834028743993258, + 8.942956110986415, + 9.029260854003951, + 9.089139031013474 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 103.10341250442434, + "p95": 107.48922900529578, + "max": 354.8548750113696 + } + }, + { + "start": 258337.948487834, + "first": 258338.333941888, + "last": 258347.043431217, + "end": 258347.044545784, + "elapsed_s": 9.09605795002426, + "chunk_offsets_s": [ + 0.3854540540196467, + 0.614081931009423, + 0.7167050520074554, + 0.8183282000245526, + 0.9238732250232715, + 1.0306841609999537, + 1.1337481650116388, + 1.234216474025743, + 1.3375922230188735, + 1.4374077610264067, + 1.5393001580087002, + 1.6392365600040648, + 1.7424360840232112, + 1.8439124630240258, + 1.943571759009501, + 2.0482453560107388, + 2.1563192440080456, + 2.2585599790036213, + 2.359381939022569, + 2.4621335250267293, + 2.56413592302124, + 2.666107135999482, + 2.7680922700092196, + 2.8714562600071076, + 2.974404279026203, + 3.0796050150238443, + 3.1822329370188527, + 3.2871167910052463, + 3.3893682790221646, + 3.496878516016295, + 3.6044381620013155, + 3.712547041999642, + 3.811612416000571, + 3.912093590013683, + 4.015685597027186, + 4.114818139001727, + 4.216346935019828, + 4.320988244027831, + 4.42496022200794, + 4.525974503019825, + 4.631244488002267, + 4.734192556003109, + 4.837043199018808, + 4.913283276022412, + 5.020807658002013, + 5.123530893004499, + 5.226924659014912, + 5.32724082400091, + 5.432653210009448, + 5.539534757001093, + 5.645590906002326, + 5.7502703920181375, + 5.8544820670213085, + 5.96100278000813, + 6.0660339150053915, + 6.171927632007282, + 6.27757517201826, + 6.384204685018631, + 6.485210087004816, + 6.584923609014368, + 6.6850005890009925, + 6.78144764501485, + 6.881643377011642, + 6.983598528022412, + 7.086559989023954, + 7.1897224110143725, + 7.286772734019905, + 7.389123327011475, + 7.493221722019371, + 7.599761491001118, + 7.704633539018687, + 7.80584737402387, + 7.907009864022257, + 8.008102578023681, + 8.111264105013106, + 8.217136958002811, + 8.319459279009607, + 8.421829633007292, + 8.522697546024574, + 8.626668373006396, + 8.730319902009796, + 8.834689595008967, + 8.943509472999722, + 9.029829848004738, + 9.094943383010104 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.94804350996856, + "p95": 107.55964598502032, + "max": 228.62787698977627 + } + }, + { + "start": 258337.949185774, + "first": 258338.462057024, + "last": 258347.043236, + "end": 258347.043285521, + "elapsed_s": 9.094099747017026, + "chunk_offsets_s": [ + 0.5128712500154506, + 0.6132922150136437, + 0.7159498480032198, + 0.8174207060073968, + 0.92297998801223, + 1.030428928002948, + 1.1335492999933194, + 1.233645639003953, + 1.3367643789970316, + 1.4365551480150316, + 1.5382542640145402, + 1.6390525110182352, + 1.7412936780019663, + 1.8427538640098646, + 1.9432388929999433, + 2.0477002330007963, + 2.1552573340013623, + 2.2581644570163917, + 2.3588642880204134, + 2.46165358601138, + 2.5633456780051347, + 2.665527325007133, + 2.7671887610049453, + 2.870703071996104, + 2.973264433006989, + 3.079153636994306, + 3.1818108709994704, + 3.2870286150136963, + 3.388406081998255, + 3.4958401579933707, + 3.604103792022215, + 3.7119735990127083, + 3.810316249000607, + 3.9116358589963056, + 4.014764919993468, + 4.1143722489941865, + 4.2161258140113205, + 4.320171055995161, + 4.424486842995975, + 4.525443699996686, + 4.630670451995684, + 4.73368364101043, + 4.836226890009129, + 4.912692681013141, + 5.020211605995428, + 5.123051482019946, + 5.226432640018174, + 5.326945815002546, + 5.431284707010491, + 5.5387308960198425, + 5.6447369329980575, + 5.749837973999092, + 5.853958496009, + 5.960371463996125, + 6.065402520005591, + 6.171503757999744, + 6.276987504999852, + 6.383177895011613, + 6.484653107007034, + 6.584363733010832, + 6.684504874021513, + 6.780819673003862, + 6.88107627001591, + 6.983041277009761, + 7.08519551702193, + 7.188731685018865, + 7.286348299996462, + 7.388146073993994, + 7.492876792006427, + 7.598890782013768, + 7.703986047010403, + 7.804708103009034, + 7.906532054010313, + 8.007858241006033, + 8.110846550000133, + 8.216733628010843, + 8.318605866021244, + 8.42072178699891, + 8.522203207015991, + 8.626117186009651, + 8.72954159299843, + 8.834245944017312, + 8.942991101997904, + 9.029250004998175, + 9.094050226005493 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.72346549027134, + "p95": 107.51892498228699, + "max": 108.74515798059292 + } + }, + { + "start": 258337.948391305, + "first": 258338.080369103, + "last": 258347.037961602, + "end": 258347.038154836, + "elapsed_s": 9.089763530995697, + "chunk_offsets_s": [ + 0.13197779800975695, + 0.613886906998232, + 0.7171389430004638, + 0.8185908890154678, + 0.9235935439937748, + 1.0307337460108101, + 1.1339013660035562, + 1.2341431620006915, + 1.3373340940161142, + 1.4372899040172342, + 1.5391358050110284, + 1.6396411700116005, + 1.7422596520045772, + 1.8437053580128122, + 1.9443784680042882, + 2.0486074070213363, + 2.1558181540167425, + 2.2591498070105445, + 2.359565891994862, + 2.46237807100988, + 2.564468708995264, + 2.666531715018209, + 2.768382576003205, + 2.871449155994924, + 2.974220358999446, + 3.079865513020195, + 3.182677019998664, + 3.287511402013479, + 3.389652440993814, + 3.4968254280101974, + 3.604710404004436, + 3.712959589000093, + 3.8123783890041523, + 3.912488072004635, + 4.015622364997398, + 4.115752512996551, + 4.216696057002991, + 4.320786883996334, + 4.4257695710111875, + 4.526375209010439, + 4.631418649019906, + 4.734967744007008, + 4.837080415018136, + 4.9136746390140615, + 5.021128076012246, + 5.1240489759948105, + 5.227807865012437, + 5.327805052016629, + 5.432559642009437, + 5.539437461004127, + 5.6456192590121645, + 5.750575594021939, + 5.8548238780058455, + 5.96122143699904, + 6.066374350019032, + 6.172798166022403, + 6.278251128009288, + 6.384142093011178, + 6.485670346010011, + 6.585085162019823, + 6.6852535030047875, + 6.78175644701696, + 6.881947507994482, + 6.983892946009291, + 7.0864262279937975, + 7.189902380021522, + 7.287251457019011, + 7.388863054016838, + 7.4937294220144395, + 7.600050228997134, + 7.704635907022748, + 7.8057366860157344, + 7.907419963012217, + 8.00852786100586, + 8.111764475994278, + 8.218033219018253, + 8.319639409019146, + 8.421736304997467, + 8.523069757007761, + 8.626975510997, + 8.730277134018252, + 8.835666897008196, + 8.943688466009917, + 9.030105002020719, + 9.089570297015598 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.99373998714145, + "p95": 107.45343699818477, + "max": 481.90910898847505 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 113.92471433571866, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 9.095736457995372, + "end_to_end_tps": 112.58021873532618, + "timing_valid": true, + "steady_tps": 116.8768693472677, + "per_stream_tps": [ + 28.5, + 28.9, + 29.7, + 29.3 + ], + "ttft_s": [ + 0.13, + 0.26, + 0.51, + 0.39 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.1312083730008453, + "decode_tps": 28.481363854854063, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 106.70050759572946, + "prefill_tps": 106.70050759572946, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.11067816471754, + "round_gap_p50_ms": 102.6986759970896, + "round_gap_p95_ms": 107.64652799116448, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0011174299870617688, + "first_payload_s": 0.1312083730008453, + "first_content_s": 0.1312083730008453, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1312083730008453, + "last_output_s": 9.084431305003818 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.2584206110041123, + "decode_tps": 28.89046059317514, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.17524533202661, + "prefill_tps": 54.17524533202661, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.613501462701926, + "round_gap_p50_ms": 103.20384800434113, + "round_gap_p95_ms": 107.65696101589128, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0013057989999651909, + "first_payload_s": 0.2584206110041123, + "first_content_s": 0.2584206110041123, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.2584206110041123, + "last_output_s": 9.084863483993104 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.5117474330181722, + "decode_tps": 29.74613803464331, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 27.357245189157325, + "prefill_tps": 27.357245189157325, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.61780943917385, + "round_gap_p50_ms": 102.68691700184718, + "round_gap_p95_ms": 107.63171201688237, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0015057680138852447, + "first_payload_s": 0.5117474330181722, + "first_content_s": 0.5117474330181722, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5117474330181722, + "last_output_s": 9.084288840007503 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.3856555219972506, + "decode_tps": 29.31397067262488, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 36.30182689332737, + "prefill_tps": 36.30182689332737, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.11342704705164, + "round_gap_p50_ms": 102.80830899137072, + "round_gap_p95_ms": 107.63948899693787, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0018008429906331003, + "first_payload_s": 0.3856555219972506, + "first_content_s": 0.3856555219972506, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3856555219972506, + "last_output_s": 9.084579418995418 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.36385402841124, + "round_gap_p50_ms": 102.79485399951227, + "round_gap_p95_ms": 107.65696101589128, + "round_gap_mean_ms": 104.3188425862484, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 109.34891772090756, + "aggregate_prefill_tps": 109.34891772090756 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258347.046728468, + "first": 258347.177936841, + "last": 258356.131159773, + "end": 258356.142018251, + "elapsed_s": 9.095289782999316, + "chunk_offsets_s": [ + 0.1312083730008453, + 0.6120132789947093, + 0.7145795219985303, + 0.8171320209803525, + 0.9237698389915749, + 1.0306196110032033, + 1.1335858879901934, + 1.233927527006017, + 1.3390178970003035, + 1.4381463440076914, + 1.5381489729916211, + 1.6421437530079857, + 1.7448672610044014, + 1.8476476809883025, + 1.948285449994728, + 2.0538519179972354, + 2.16103343598661, + 2.26336129399715, + 2.3647898189956322, + 2.4648090729897376, + 2.567507748986827, + 2.6698247109889053, + 2.7704159040004015, + 2.875963475991739, + 2.978324119001627, + 3.084806128987111, + 3.187598213989986, + 3.292582983005559, + 3.3952619479969144, + 3.5013520029897336, + 3.6112134889990557, + 3.71886001699022, + 3.817880240996601, + 3.9178798779903445, + 4.020142520981608, + 4.122142937994795, + 4.223386645986466, + 4.326889824005775, + 4.431563152000308, + 4.5318721029907465, + 4.63626291800756, + 4.7391810519911814, + 4.841778959991643, + 4.9184227059886325, + 5.025438430981012, + 5.1293376429821365, + 5.231401597004151, + 5.332338071981212, + 5.436750182998367, + 5.544135206000647, + 5.651386437006295, + 5.755490673996974, + 5.860455140005797, + 5.96560203898116, + 6.070132150984136, + 6.176385633007158, + 6.2809320649830624, + 6.388663985999301, + 6.4886193999846, + 6.5880327629856765, + 6.689041959005408, + 6.784539235988632, + 6.884377032984048, + 6.985537158005172, + 7.086758050980279, + 7.189967707992764, + 7.2869102569820825, + 7.390489515004447, + 7.494576105003944, + 7.600313375995029, + 7.704454493999947, + 7.805138536001323, + 7.907026136992499, + 8.007807171990862, + 8.109835029987153, + 8.216015056008473, + 8.317732127994532, + 8.420221317006508, + 8.52046218898613, + 8.624605963006616, + 8.728325254982337, + 8.830337961000623, + 8.941358126001433, + 9.026434784987941, + 9.084431305003818 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.71109199675266, + "p95": 107.64652799116448, + "max": 480.80490599386394 + } + }, + { + "start": 258347.04635453, + "first": 258347.304775141, + "last": 258356.131218014, + "end": 258356.141459176, + "elapsed_s": 9.095104645995889, + "chunk_offsets_s": [ + 0.2584206110041123, + 0.6118771340115927, + 0.7151231250027195, + 0.8177382170106284, + 0.923944272013614, + 1.0307853069971316, + 1.1340128990123048, + 1.2343656409939285, + 1.3386314779927488, + 1.4388049400004093, + 1.5381818049936555, + 1.6424467299948446, + 1.7456964339944534, + 1.8489732570014894, + 1.9487361880019307, + 2.05343431601068, + 2.1609340909926686, + 2.2641379389970098, + 2.3654016949876677, + 2.465562677010894, + 2.567964566987939, + 2.6704625069978647, + 2.770587584003806, + 2.8761041490070056, + 2.9787581530108582, + 3.0850151219929103, + 3.1881401209975593, + 3.293013833987061, + 3.3956985420081764, + 3.501778565987479, + 3.6118440679856576, + 3.719501029001549, + 3.818081089993939, + 3.918436184991151, + 4.020581051008776, + 4.122633179998957, + 4.223644535988569, + 4.32742969901301, + 4.43296751199523, + 4.532541163003771, + 4.63653381500626, + 4.73979012700147, + 4.842344754986698, + 4.918592978006927, + 5.0259836339973845, + 5.12988524598768, + 5.231967024010373, + 5.332768394000595, + 5.436990935995709, + 5.544335815007798, + 5.651871256006416, + 5.755732691992307, + 5.860918791004224, + 5.966191707004327, + 6.070560569001827, + 6.1762291039922275, + 6.2814181149879005, + 6.38908318898757, + 6.488931433996186, + 6.588673919002758, + 6.689259208011208, + 6.7855765860003885, + 6.8849768599902745, + 6.986030872008996, + 7.086857362999581, + 7.19044734199997, + 7.287453972006915, + 7.3907760129950475, + 7.495172636001371, + 7.600745266012382, + 7.704928352002753, + 7.806131949997507, + 7.907264073990518, + 8.00781425999594, + 8.11039829699439, + 8.216494466993026, + 8.31820070699905, + 8.420995560998563, + 8.521523714996874, + 8.624930396996206, + 8.72852264798712, + 8.830763772013597, + 8.941551214986248, + 9.027079363993835, + 9.084863483993104 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 103.2157200097572, + "p95": 107.65696101589128, + "max": 353.4565230074804 + } + }, + { + "start": 258347.046656484, + "first": 258347.558403917, + "last": 258356.130945324, + "end": 258356.140967621, + "elapsed_s": 9.094311137014301, + "chunk_offsets_s": [ + 0.5117474330181722, + 0.6113556750060525, + 0.7154610950092319, + 0.8175104390247725, + 0.9239240960159805, + 1.0303107930230908, + 1.1340151220210828, + 1.2338590779982042, + 1.33842253300827, + 1.43855549802538, + 1.538128445012262, + 1.642413370020222, + 1.7450132610101718, + 1.8480423870205414, + 1.948597050999524, + 2.0530318490054924, + 2.161263181013055, + 2.2636112150212284, + 2.3644430650165305, + 2.4650173929985613, + 2.567832310014637, + 2.6700839120021556, + 2.770114557002671, + 2.8759182910143863, + 2.9782348860171624, + 3.084634463011753, + 3.187727734009968, + 3.2923734940122813, + 3.3952436430263333, + 3.5012758430093527, + 3.611476785998093, + 3.7191084980149753, + 3.8175781910249498, + 3.9180531590245664, + 4.020080872025574, + 4.122669244010467, + 4.223126099997899, + 4.3273118900251575, + 4.431722368026385, + 4.532116776012117, + 4.636440950009273, + 4.739032603014493, + 4.842097217013361, + 4.9184088809997775, + 5.025813153013587, + 5.129503211006522, + 5.231357468001079, + 5.332195223018061, + 5.43627510801889, + 5.5438919410225935, + 5.651394084998174, + 5.755365553020965, + 5.860666229011258, + 5.965729640010977, + 6.07031031200313, + 6.176070479006739, + 6.2807910710107535, + 6.388634369999636, + 6.48846893501468, + 6.588425149006071, + 6.68858898000326, + 6.784766725002555, + 6.884503481007414, + 6.985506645025453, + 7.086322688002838, + 7.190236253023613, + 7.287683653004933, + 7.39037057000678, + 7.494742202019552, + 7.600285327003803, + 7.704913488007151, + 7.805896972015034, + 7.906629286997486, + 8.008055621001404, + 8.1100199430075, + 8.215852863009786, + 8.317977009020979, + 8.420586087013362, + 8.521139313001186, + 8.624489434005227, + 8.728299399022944, + 8.830525450001005, + 8.941019788006088, + 9.026599985023495, + 9.084288840007503 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.75091700896155, + "p95": 107.63171201688237, + "max": 110.49433800508268 + } + }, + { + "start": 258347.046281793, + "first": 258347.431937315, + "last": 258356.130861212, + "end": 258356.141617049, + "elapsed_s": 9.095335255988175, + "chunk_offsets_s": [ + 0.3856555219972506, + 0.6116545739932917, + 0.7156290169805288, + 0.8177179449994583, + 0.923798848001752, + 1.0306334029883146, + 1.1342197640042286, + 1.2341813529783394, + 1.3386057349853218, + 1.4392880789819174, + 1.538443486992037, + 1.6429571819899138, + 1.7452398879977409, + 1.8482631889928598, + 1.948891501990147, + 2.053694014000939, + 2.1612375499971677, + 2.2640458589885384, + 2.364629755000351, + 2.465473652991932, + 2.567806982988259, + 2.6703825229778886, + 2.7704455359780695, + 2.876021412987029, + 2.978895273990929, + 3.0849027219810523, + 3.1878749360039365, + 3.2929568419931456, + 3.3954887809813954, + 3.501569316984387, + 3.6117980839917436, + 3.7194375729886815, + 3.8179980339773465, + 3.918694138992578, + 4.020406122988788, + 4.122915454005124, + 4.223446550982771, + 4.327627955994103, + 4.4325546619948, + 4.532421146985143, + 4.6368906179850455, + 4.739344748988515, + 4.842090657999506, + 4.9185122909839265, + 5.026125426986255, + 5.129639692982892, + 5.231684254977154, + 5.332518073002575, + 5.436810646991944, + 5.5441615429881494, + 5.651696102984715, + 5.75567085199873, + 5.861187945003621, + 5.965954154002247, + 6.070454760978464, + 6.176700962998439, + 6.281124881992582, + 6.388967812992632, + 6.488784697983647, + 6.588668398995651, + 6.689195655984804, + 6.786105612991378, + 6.884929788997397, + 6.985783927986631, + 7.086624834977556, + 7.191101938980864, + 7.288005287002306, + 7.390700684976764, + 7.4951652769814245, + 7.600572258001193, + 7.705186385981506, + 7.806048094003927, + 7.906897832988761, + 8.007642019976629, + 8.110984204977285, + 8.216277906001778, + 8.31840254898998, + 8.420821017003618, + 8.521429714979604, + 8.624824428989086, + 8.728475719981361, + 8.830664604000049, + 8.94135484698927, + 9.02756980000413, + 9.084579418995418 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.84108499763533, + "p95": 107.63948899693787, + "max": 225.9990519960411 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 113.13000864040806, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 9.149157394014765, + "end_to_end_tps": 111.92287506933532, + "timing_valid": true, + "steady_tps": 116.05528177602719, + "per_stream_tps": [ + 29.1, + 29.5, + 28.3, + 28.7 + ], + "ttft_s": [ + 0.39, + 0.51, + 0.13, + 0.26 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.38709451400791295, + "decode_tps": 29.105601616888276, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 36.166877838299236, + "prefill_tps": 36.166877838299236, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.357647478406996, + "round_gap_p50_ms": 102.9540250019636, + "round_gap_p95_ms": 110.65555800450966, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0017210009973496199, + "first_payload_s": 0.38709451400791295, + "first_content_s": 0.38709451400791295, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.38709451400791295, + "last_output_s": 9.148294621001696 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.5139954580226913, + "decode_tps": 29.535750896186805, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 27.237594771473532, + "prefill_tps": 27.237594771473532, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.85727363136396, + "round_gap_p50_ms": 102.66773498733528, + "round_gap_p95_ms": 110.70406998624094, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0017466820136178285, + "first_payload_s": 0.5139954580226913, + "first_content_s": 0.5139954580226913, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5139954580226913, + "last_output_s": 9.147600234020501 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.13228423800319433, + "decode_tps": 28.28648349617424, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 105.83271454957419, + "prefill_tps": 105.83271454957419, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.352573964708284, + "round_gap_p50_ms": 102.95016801683232, + "round_gap_p95_ms": 110.45277302036993, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0009588050015736371, + "first_payload_s": 0.13228423800319433, + "first_content_s": 0.13228423800319433, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13228423800319433, + "last_output_s": 9.147190599003807 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.26101488701533526, + "decode_tps": 28.69611941901141, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 53.636787388213094, + "prefill_tps": 53.636787388213094, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.8479174273819, + "round_gap_p50_ms": 102.90388000430539, + "round_gap_p95_ms": 110.24746001930907, + "tokens_per_chunk": 3.011764705882353, + "headers_s": 0.0016214810020755976, + "first_payload_s": 0.26101488701533526, + "first_content_s": 0.26101488701533526, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.26101488701533526, + "last_output_s": 9.14723383099772 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.603853125465285, + "round_gap_p50_ms": 102.94931998942047, + "round_gap_p95_ms": 110.70406998624094, + "round_gap_mean_ms": 105.0474112737339, + "tokens_per_chunk": 3.011764705882353, + "aggregate_prompt_ttft_tps": 108.93040014306064, + "aggregate_prefill_tps": 108.93040014306064 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258356.143693669, + "first": 258356.530788183, + "last": 258365.29198829, + "end": 258365.292390661, + "elapsed_s": 9.148696991993347, + "chunk_offsets_s": [ + 0.38709451400791295, + 0.613264771993272, + 0.7152498950017616, + 0.8189008659974206, + 0.9232322740135714, + 1.0302799050114118, + 1.1319381300127134, + 1.2343193019914906, + 1.3374193749914411, + 1.4372363250004128, + 1.5374147660040762, + 1.6407022310013417, + 1.7450338790076785, + 1.8464601660089102, + 1.9467114069848321, + 2.051804724003887, + 2.158843795012217, + 2.261771018995205, + 2.362589478987502, + 2.4638306940032635, + 2.5680512209946755, + 2.6693676199938636, + 2.7684768059989437, + 2.873915804986609, + 2.9760829290025868, + 3.082203642989043, + 3.1848657460068353, + 3.290728666994255, + 3.392107035004301, + 3.4997854699904565, + 3.6096051489876118, + 3.716402811987791, + 3.815392205986427, + 3.915354485012358, + 4.01754696998978, + 4.116860189998988, + 4.226582861010684, + 4.331489776988747, + 4.436280452006031, + 4.537805684987688, + 4.639338389999466, + 4.745939587010071, + 4.847982119012158, + 4.924316471995553, + 5.031600009999238, + 5.1345540350012016, + 5.2463285099947825, + 5.363975787011441, + 5.490953756001545, + 5.599151011003414, + 5.7057288810028695, + 5.810720389010385, + 5.914862148987595, + 6.021530180005357, + 6.126718457991956, + 6.233013910008594, + 6.3371667900064494, + 6.444595640990883, + 6.545018403994618, + 6.644941820006352, + 6.74600765798823, + 6.842484766995767, + 6.942622647999087, + 7.044114313990576, + 7.144257939013187, + 7.248262306995457, + 7.3454939640068915, + 7.448582326003816, + 7.552472404990112, + 7.659575973986648, + 7.763883223000448, + 7.8654807769926265, + 7.966703960992163, + 8.06838092399994, + 8.170627665997017, + 8.276704460993642, + 8.37921774800634, + 8.481546442984836, + 8.581718645000365, + 8.6860425019986, + 8.79091357899597, + 8.891977177991066, + 9.002632735995576, + 9.089638367004227, + 9.148294621001696 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 103.02119349944405, + "p95": 110.65555800450966, + "max": 226.17025798535906 + } + }, + { + "start": 258356.143450179, + "first": 258356.657445637, + "last": 258365.291050413, + "end": 258365.292059523, + "elapsed_s": 9.14860934400349, + "chunk_offsets_s": [ + 0.5139954580226913, + 0.6133417329983786, + 0.7156822980032302, + 0.8190823559998535, + 0.9240622630168218, + 1.031226343009621, + 1.1325214300013613, + 1.2347376410034485, + 1.3382008199987467, + 1.4376869359984994, + 1.5383344030124135, + 1.640882057021372, + 1.7450507920002565, + 1.8470041539985687, + 1.947730934014544, + 2.0518784210144076, + 2.1592640220187604, + 2.262213342008181, + 2.3630566820211243, + 2.4643906020210125, + 2.568412983993767, + 2.669743815000402, + 2.769077753997408, + 2.8742889919958543, + 2.976521908014547, + 3.082696351018967, + 3.1853640860063024, + 3.2911506539967377, + 3.3920585230225697, + 3.5002555370156188, + 3.6097594870079774, + 3.7170329760119785, + 3.816012002003845, + 3.9157325999985915, + 4.018038876994979, + 4.11723496101331, + 4.226963968016207, + 4.331897220021347, + 4.436358933016891, + 4.538362153019989, + 4.640165323013207, + 4.74628189401119, + 4.848315465002088, + 4.924040662997868, + 5.03165714701754, + 5.134900406002998, + 5.246631904999958, + 5.363946266996209, + 5.491134765994502, + 5.599448501016013, + 5.705642449000152, + 5.810548356996151, + 5.914752901007887, + 6.02205767101259, + 6.126760106999427, + 6.2331716869957745, + 6.33761149700149, + 6.4449929560068995, + 6.545433799008606, + 6.644893036020221, + 6.746427773003234, + 6.842446399008622, + 6.9426065210136585, + 7.044145257998025, + 7.144381748017622, + 7.260169799003052, + 7.345806958008325, + 7.448599559022114, + 7.552844104007818, + 7.6597103270178195, + 7.764221434015781, + 7.865495914011262, + 7.967208381014643, + 8.068886574998032, + 8.170927524013678, + 8.277137552009663, + 8.37952360700001, + 8.481625051994342, + 8.58203664701432, + 8.685919509996893, + 8.791269742010627, + 8.892027307010721, + 9.002731376996962, + 9.089598688005935, + 9.147600234020501 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.73016800056212, + "p95": 110.70406998624094, + "max": 127.18849899829365 + } + }, + { + "start": 258356.14352866, + "first": 258356.275812898, + "last": 258365.290719259, + "end": 258365.292513301, + "elapsed_s": 9.148984641011339, + "chunk_offsets_s": [ + 0.13228423800319433, + 0.6130659870104864, + 0.7153279749909416, + 0.8184877760068048, + 0.9234967390075326, + 1.0306644029915333, + 1.1321960189961828, + 1.234560855984455, + 1.337676625000313, + 1.4376621840056032, + 1.5377764159929939, + 1.6409222809888888, + 1.7450628229998983, + 1.846766247996129, + 1.94701246501063, + 2.0516153470089193, + 2.159111076995032, + 2.2620612450118642, + 2.3628941210045014, + 2.464237415988464, + 2.5684049669944216, + 2.669604230002733, + 2.7688740890007466, + 2.8738210200099275, + 2.976380275009433, + 3.0824921570019796, + 3.1850972039974295, + 3.291117196989944, + 3.392110986984335, + 3.499882334988797, + 3.609619021997787, + 3.7168970229977276, + 3.8158749449939933, + 3.9155960549833253, + 4.017897163983434, + 4.117097423004452, + 4.226824398996541, + 4.331761731009465, + 4.436217059992487, + 4.537713124009315, + 4.639867736987071, + 4.746145459997933, + 4.848183688009158, + 4.924134550994495, + 5.031509577005636, + 5.135005046002334, + 5.24631383799715, + 5.364522797986865, + 5.490818316000514, + 5.59955557298963, + 5.705742577003548, + 5.810659412993118, + 5.914828804990975, + 6.022043878998375, + 6.126502889004769, + 6.232919684989611, + 6.337584280001465, + 6.444968811003491, + 6.545408581994707, + 6.644944203988416, + 6.746297548001166, + 6.842452126991702, + 6.9425897680048365, + 7.044175497983815, + 7.144368515990209, + 7.248506931995507, + 7.345787405007286, + 7.448572581983171, + 7.552696709986776, + 7.659840535983676, + 7.76420268099173, + 7.865701209986582, + 7.96703253898886, + 8.068748541991226, + 8.170685121993301, + 8.276933054003166, + 8.379512518004049, + 8.481441226002062, + 8.582015046005836, + 8.686052885983372, + 8.791136299987556, + 8.892010921990732, + 9.002463695011102, + 9.089588750997791, + 9.147190599003807 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 103.03296851634514, + "p95": 110.45277302036993, + "max": 480.7817490072921 + } + }, + { + "start": 258356.143355907, + "first": 258356.404370794, + "last": 258365.290589738, + "end": 258365.291103213, + "elapsed_s": 9.147747306007659, + "chunk_offsets_s": [ + 0.26101488701533526, + 0.6131505800003652, + 0.7154062000045087, + 0.8184747039922513, + 0.923326513991924, + 1.030393618013477, + 1.132689174002735, + 1.2344844389881473, + 1.3376982570043765, + 1.437333606008906, + 1.5375503659888636, + 1.6412307620048523, + 1.7449575590144377, + 1.846490583004197, + 1.9468608000024687, + 2.0515558260085527, + 2.159485095005948, + 2.2623889750102535, + 2.363335867994465, + 2.4643083290138748, + 2.5681429659889545, + 2.6699169350031298, + 2.769101818004856, + 2.874112302000867, + 2.9760998249985278, + 3.0823626040073577, + 3.1851126280089375, + 3.29087734001223, + 3.392625742009841, + 3.4999163190077525, + 3.609663534007268, + 3.7169353589997627, + 3.8159306889865547, + 3.915439606003929, + 4.017976731993258, + 4.1169596149993595, + 4.226741758000571, + 4.33166788998642, + 4.436236339999596, + 4.537800980993779, + 4.639961673005018, + 4.7460692200111225, + 4.848122327995952, + 4.924562138010515, + 5.031518025993137, + 5.1352388550003525, + 5.246413246990414, + 5.36346610399778, + 5.490711594989989, + 5.599367907998385, + 5.7056102080096025, + 5.810366994992364, + 5.914595731999725, + 6.021626324014505, + 6.12649354399764, + 6.232876997004496, + 6.337825961993076, + 6.444573880988173, + 6.545148069009883, + 6.645463807013584, + 6.746096187009243, + 6.842150589014636, + 6.942336918989895, + 7.043955528992228, + 7.144169075007085, + 7.24831739498768, + 7.345460971991997, + 7.448281491990201, + 7.552658789994894, + 7.659357108990662, + 7.764439914986724, + 7.86568485799944, + 7.967100779002067, + 8.068789470009506, + 8.170675345987547, + 8.276895838003838, + 8.379178259987384, + 8.481158456997946, + 8.58162190800067, + 8.685838197008707, + 8.790850618999684, + 8.891948537988355, + 9.002195998007664, + 9.089207645010902, + 9.14723383099772 + ], + "chunk_gaps_ms": { + "count": 84, + "p50": 102.98619199602399, + "p95": 110.24746001930907, + "max": 352.1356929850299 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "3fcd20ce2fb0da2d0d18ea1f198e6512e3be5c199ee53241cd198c95a1e40611", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + } + ] + }, + { + "prompt": "chat", + "temperature": 0.0, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 1, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 34.0, + "per_stream_tps": 34.0, + "ttft_s_max": 0.21, + "request": { + "ttft_s": 0.198, + "decode_tps": 33.969, + "prompt_ttft_tps": 161.354, + "prefill_tps": 161.354, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.439, + "round_gap_p50_ms": 63.076, + "round_gap_p95_ms": 74.38, + "tokens_per_chunk": 2.207, + "headers_s": 0.001, + "first_payload_s": 0.001, + "first_content_s": 0.198, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.198, + "last_output_s": 7.701 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 161.354, + "aggregate_prefill_tps": 161.354, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.439, + "round_gap_p50_ms": 63.076, + "round_gap_p95_ms": 74.38, + "tokens_per_chunk": 2.207 + }, + "completions": { + "truncated": 3 + }, + "timing_valid": true, + "end_to_end_tps": 33.24022059367094, + "makespan_s": 7.701513270003488, + "alone": { + "equal": 3, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 1, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 35.00080306939731, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 7.483990658976836, + "end_to_end_tps": 34.206349481868365, + "timing_valid": true, + "per_stream_tps": [ + 35.0 + ], + "ttft_s": [ + 0.2 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.19832113798474893, + "decode_tps": 35.00080306939731, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 161.3544593640887, + "prefill_tps": 161.3544593640887, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 28.57077301961516, + "round_gap_p50_ms": 66.32225299836136, + "round_gap_p95_ms": 74.38015600200742, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0007458119944203645, + "first_payload_s": 0.0007480519998352975, + "first_content_s": 0.19832113798474893, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19832113798474893, + "last_output_s": 7.4838682579866145 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 28.57077301961516, + "round_gap_p50_ms": 66.32225299836136, + "round_gap_p95_ms": 74.38015600200742, + "round_gap_mean_ms": 66.23224654547151, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 161.3544593640887, + "aggregate_prefill_tps": 161.3544593640887 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258385.039922221, + "first": 258385.238243359, + "last": 258392.523790479, + "end": 258392.52391288, + "elapsed_s": 7.483990658976836, + "chunk_offsets_s": [ + 0.19832113798474893, + 0.27123803697759286, + 0.33837567098089494, + 0.39909989197622053, + 0.46087338199140504, + 0.5310454010032117, + 0.5967339229828212, + 0.6591641529812478, + 0.7288725699763745, + 0.7952475269848946, + 0.8617649169755168, + 0.9214948919834569, + 0.9783214099879842, + 1.037932056991849, + 1.0978829929954372, + 1.1598969659826253, + 1.2262192189809866, + 1.285040692979237, + 1.3449925409804564, + 1.4109939759946428, + 1.479389136977261, + 1.5444104069902096, + 1.616315235994989, + 1.6902209410036448, + 1.7664459389925469, + 1.8330357449885923, + 1.8982841999968514, + 1.9664631679770537, + 2.0354979329858907, + 2.102972544991644, + 2.161574161989847, + 2.2241186809842475, + 2.298498836986255, + 2.367276991979452, + 2.441405721998308, + 2.5155307079839986, + 2.5870898079883773, + 2.6579421509813983, + 2.7257211319811177, + 2.797998939990066, + 2.8734744459798094, + 2.9433269589790143, + 3.0150589239783585, + 3.080798133974895, + 3.152957380982116, + 3.2204775129794143, + 3.2842311119893566, + 3.3443649129767437, + 3.4209897219843697, + 3.481701094977325, + 3.5437222679902334, + 3.6044871769845486, + 3.6659611469949596, + 3.726062756002648, + 3.7883481709868647, + 3.8501947019831277, + 3.9208546610025223, + 3.9913469059974886, + 4.058103001996642, + 4.118685814988567, + 4.178105036990019, + 4.236162635002984, + 4.293960694980342, + 4.355890218983404, + 4.425597436988028, + 4.486991197976749, + 4.545093723980244, + 4.604337024997221, + 4.667075434001163, + 4.728331113990862, + 4.7898866679752246, + 4.851939664979, + 4.912907599995378, + 4.975357670977246, + 5.044694085983792, + 5.110288543975912, + 5.1708982049894985, + 5.234509642992634, + 5.296163597988198, + 5.363254255993525, + 5.440039721986977, + 5.506090949987993, + 5.5791348589991685, + 5.649651007988723, + 5.719392961997073, + 5.789787606976461, + 5.859971083002165, + 5.9283394609810784, + 5.992368068982614, + 6.054717227991205, + 6.119280223996611, + 6.188320636982098, + 6.258965539978817, + 6.332400043000234, + 6.401053526002215, + 6.471010680979816, + 6.5340914279804565, + 6.593591434997506, + 6.656375571998069, + 6.728269218001515, + 6.7953651569841895, + 6.863497116981307, + 6.927990176976891, + 6.990602504985873, + 7.071211336995475, + 7.139992741984315, + 7.207722219987772, + 7.277156828000443, + 7.345868535980117, + 7.419199933996424, + 7.4838682579866145 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 66.34860500344075, + "p95": 74.38015600200742, + "max": 80.60883200960234 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 33.96886819357246, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 7.701513270003488, + "end_to_end_tps": 33.24022059367094, + "timing_valid": true, + "per_stream_tps": [ + 34.0 + ], + "ttft_s": [ + 0.19 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.19451732898596674, + "decode_tps": 33.96886819357246, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 164.50976458919303, + "prefill_tps": 164.50976458919303, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.438720015676545, + "round_gap_p50_ms": 59.26811901736073, + "round_gap_p95_ms": 72.26774498121813, + "tokens_per_chunk": 2.015748031496063, + "headers_s": 0.0007183409761637449, + "first_payload_s": 0.0007209169853013009, + "first_content_s": 0.19451732898596674, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19451732898596674, + "last_output_s": 7.701390932983486 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.438720015676545, + "round_gap_p50_ms": 59.26811901736073, + "round_gap_p95_ms": 72.26774498121813, + "round_gap_mean_ms": 59.57836193648825, + "tokens_per_chunk": 2.015748031496063, + "aggregate_prompt_ttft_tps": 164.50976458919303, + "aggregate_prefill_tps": 164.50976458919303 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258392.524650564, + "first": 258392.719167893, + "last": 258400.226041497, + "end": 258400.226163834, + "elapsed_s": 7.701513270003488, + "chunk_offsets_s": [ + 0.19451732898596674, + 0.2653326010040473, + 0.3351082829758525, + 0.40539135999279097, + 0.47372552898013964, + 0.543193577992497, + 0.61201856599655, + 0.6834642419999, + 0.7583759379922412, + 0.8250418099923991, + 0.8934723639977165, + 0.9657401089789346, + 1.0333209139935207, + 1.1007602469762787, + 1.1614535249827895, + 1.223150423989864, + 1.289641079987632, + 1.350493509991793, + 1.4239689739770256, + 1.495767179003451, + 1.5536361529957503, + 1.6172697999863885, + 1.684381498984294, + 1.7636192519858014, + 1.8607047389959916, + 1.9336107439885382, + 2.0030367439903785, + 2.0720323419955093, + 2.146274465980241, + 2.2140649049833883, + 2.27963243497652, + 2.335312963987235, + 2.404042847978417, + 2.4536368300032336, + 2.5024581989855506, + 2.5532755489984993, + 2.6041466419992503, + 2.6572468199883588, + 2.708600429003127, + 2.763174950989196, + 2.823380546993576, + 2.8757708329940215, + 2.9272560739773326, + 2.9772634340042714, + 3.026594822993502, + 3.081302817998221, + 3.1322142639837693, + 3.186018541979138, + 3.2496069409826305, + 3.3114557139924727, + 3.3662468940019608, + 3.4359720639768057, + 3.4860183209821116, + 3.537490873975912, + 3.5856479829817545, + 3.6375612109841313, + 3.695827114977874, + 3.7468665140040684, + 3.7984662349917926, + 3.849052670993842, + 3.9002646949957125, + 3.951001595996786, + 4.002797702996759, + 4.0557579759915825, + 4.114009159995476, + 4.168782995984657, + 4.22975050000241, + 4.288259797991486, + 4.34079574898351, + 4.398144895996666, + 4.449155701993732, + 4.508644781977637, + 4.578381920000538, + 4.6357528269873, + 4.696694938989822, + 4.757090375991538, + 4.814373345987406, + 4.874133306992007, + 4.937807786976919, + 5.002586321003037, + 5.070593098003883, + 5.127498769987142, + 5.178907098976197, + 5.238772483979119, + 5.2992847219866235, + 5.35896274598781, + 5.417834269988816, + 5.477529766998487, + 5.539261626981897, + 5.588711688993499, + 5.642234445986105, + 5.692818673996953, + 5.74387999298051, + 5.794303995993687, + 5.845915205980418, + 5.9035356669919565, + 5.970632069977, + 6.029900188994361, + 6.091998898977181, + 6.154927566996776, + 6.212133305001771, + 6.262810461979825, + 6.312886350991903, + 6.367767371993978, + 6.427642422000645, + 6.490241134975804, + 6.550666123977862, + 6.601145823980914, + 6.6532453569816425, + 6.703243821975775, + 6.752144600002794, + 6.805063897976652, + 6.865333909983747, + 6.927469900983851, + 6.9864175059774425, + 7.044379408995155, + 7.102363104000688, + 7.162891644984484, + 7.2256939279905055, + 7.2857521469995845, + 7.3529077989805955, + 7.413764278986491, + 7.472218184993835, + 7.530432440980803, + 7.592691312980605, + 7.652293800987536, + 7.701390932983486 + ], + "chunk_gaps_ms": { + "count": 126, + "p50": 59.378599500632845, + "p95": 72.26774498121813, + "max": 97.08548701019026 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 32.69821626835206, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 8.007217136007966, + "end_to_end_tps": 31.97115747602043, + "timing_valid": true, + "per_stream_tps": [ + 32.7 + ], + "ttft_s": [ + 0.21 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.20832798798801377, + "decode_tps": 32.69821626835206, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 153.60394111731705, + "prefill_tps": 153.60394111731705, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 30.582707992175084, + "round_gap_p50_ms": 63.076413003727794, + "round_gap_p95_ms": 88.73601700179279, + "tokens_per_chunk": 2.206896551724138, + "headers_s": 0.0007144999981392175, + "first_payload_s": 0.0007172680052462965, + "first_content_s": 0.20832798798801377, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.20832798798801377, + "last_output_s": 8.00691852599266 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 30.582707992175084, + "round_gap_p50_ms": 63.076413003727794, + "round_gap_p95_ms": 88.73601700179279, + "round_gap_mean_ms": 67.81383076525779, + "tokens_per_chunk": 2.206896551724138, + "aggregate_prompt_ttft_tps": 153.60394111731705, + "aggregate_prefill_tps": 153.60394111731705 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258400.226844302, + "first": 258400.43517229, + "last": 258408.233762828, + "end": 258408.234061438, + "elapsed_s": 8.007217136007966, + "chunk_offsets_s": [ + 0.20832798798801377, + 0.29548085998976603, + 0.3802267099963501, + 0.4645273410133086, + 0.539944480988197, + 0.6159927280095872, + 0.6892963360005524, + 0.7540693980117794, + 0.8342514940013643, + 0.9253319890121929, + 1.0076946089975536, + 1.0726736730139237, + 1.1398437409952749, + 1.211834732996067, + 1.318715606990736, + 1.4198454240104184, + 1.5120591250015423, + 1.5893891399900895, + 1.6563611600140575, + 1.7226947910094168, + 1.775489544001175, + 1.8447362009901553, + 1.9354660380049609, + 2.02357794001, + 2.112313957011793, + 2.1954510619980283, + 2.282945615996141, + 2.366738787997747, + 2.4523369949893095, + 2.5358680229983293, + 2.6131919260078575, + 2.6762683390115853, + 2.7407442000112496, + 2.7993268109858036, + 2.8592317969887517, + 2.9181007459992543, + 2.9825999829918146, + 3.045126248995075, + 3.1071461600076873, + 3.172099719988182, + 3.2463351580081508, + 3.3230124649999198, + 3.3921255049936008, + 3.477426847006427, + 3.5639355719904415, + 3.652211921988055, + 3.734541966987308, + 3.818556404992705, + 3.8862227810022887, + 3.947387071006233, + 4.002942624996649, + 4.064769287011586, + 4.125589750998188, + 4.188030688004801, + 4.24923067499185, + 4.312042957986705, + 4.378416494990233, + 4.4419534699991345, + 4.504678633995354, + 4.566640879987972, + 4.6262971780088264, + 4.686429733992554, + 4.746811491000699, + 4.807749091996811, + 4.872290522005642, + 4.9295479739957955, + 4.9897003379883245, + 5.050948101008544, + 5.111211634008214, + 5.169878085987875, + 5.22866481001256, + 5.292481148004299, + 5.363765401009005, + 5.425266236998141, + 5.485227911995025, + 5.542523251991952, + 5.6009890789864585, + 5.661401972989552, + 5.719723654008703, + 5.781733982003061, + 5.852248437993694, + 5.913734425994335, + 5.976850984006887, + 6.03848514900892, + 6.098701178008923, + 6.159272585005965, + 6.222053989011329, + 6.283774011011701, + 6.352571513009025, + 6.416697948996443, + 6.476469687011559, + 6.535580605996074, + 6.59601535598631, + 6.653262567997444, + 6.712191069003893, + 6.772577530995477, + 6.842060110007878, + 6.902434140007244, + 6.963679887005128, + 7.023244023992447, + 7.081923163990723, + 7.141293027991196, + 7.201727265986847, + 7.265474484011065, + 7.3312701449904125, + 7.389486178988591, + 7.4482615439919755, + 7.50758142300765, + 7.573521757993149, + 7.631490238010883, + 7.690719108999474, + 7.753042717988137, + 7.8201855559891555, + 7.891277632006677, + 7.957759937009541, + 8.00691852599266 + ], + "chunk_gaps_ms": { + "count": 115, + "p50": 63.076413003727794, + "p95": 88.73601700179279, + "max": 106.88087399466895 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + } + ] + }, + { + "prompt": "chat", + "temperature": 0.0, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 2, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.5, + "per_stream_tps": 28.2, + "ttft_s_max": 0.43, + "request": { + "ttft_s": 0.295, + "decode_tps": 28.235, + "prompt_ttft_tps": 120.807, + "prefill_tps": 120.807, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.417, + "round_gap_p50_ms": 80.253, + "round_gap_p95_ms": 84.939, + "tokens_per_chunk": 2.306, + "headers_s": 0.002, + "first_payload_s": 0.002, + "first_content_s": 0.295, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.295, + "last_output_s": 9.229 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 164.51, + "aggregate_prefill_tps": 164.51, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.047, + "round_gap_p50_ms": 80.28, + "round_gap_p95_ms": 84.93, + "tokens_per_chunk": 2.306 + }, + "completions": { + "truncated": 6 + }, + "timing_valid": true, + "end_to_end_tps": 55.469507963751596, + "makespan_s": 9.230296405992704, + "steady_tps": 57.6, + "alone": { + "equal": 6, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 1, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.455917073270484, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 9.230296405992704, + "end_to_end_tps": 55.469507963751596, + "timing_valid": true, + "steady_tps": 57.57538383003938, + "per_stream_tps": [ + 28.8, + 28.2 + ], + "ttft_s": [ + 0.39, + 0.2 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.3886705260083545, + "decode_tps": 28.844300498778853, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 82.33194404690249, + "prefill_tps": 82.33194404690249, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.668894121469016, + "round_gap_p50_ms": 80.27964999200776, + "round_gap_p95_ms": 84.6668430021964, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0014357199834194034, + "first_payload_s": 0.0014375920000020415, + "first_content_s": 0.3886705260083545, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3886705260083545, + "last_output_s": 9.229238526982954 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.1960041449929122, + "decode_tps": 28.22827372059104, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 163.2618534733394, + "prefill_tps": 163.2618534733394, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.425474823511884, + "round_gap_p50_ms": 80.22667397744954, + "round_gap_p95_ms": 84.90191702730954, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0016763780149631202, + "first_payload_s": 0.0016796739946585149, + "first_content_s": 0.1960041449929122, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1960041449929122, + "last_output_s": 9.229500224988442 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.04718447249045, + "round_gap_p50_ms": 80.27964999200776, + "round_gap_p95_ms": 84.6668430021964, + "round_gap_mean_ms": 81.2457458225915, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 164.51042805197724, + "aggregate_prefill_tps": 164.51042805197724 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258408.236027434, + "first": 258408.62469796, + "last": 258417.465265961, + "end": 258417.465489562, + "elapsed_s": 9.229462127987063, + "chunk_offsets_s": [ + 0.3886705260083545, + 0.4707843939831946, + 0.5501314619905315, + 0.6305592560092919, + 0.710567911999533, + 0.790790280996589, + 0.870505383994896, + 0.9508463139936794, + 1.032279937993735, + 1.1099961810105015, + 1.1893472500087228, + 1.2725448200071696, + 1.35111817199504, + 1.4321771700051613, + 1.5151954919856507, + 1.5949263549991883, + 1.6746466890035663, + 1.7533715940080583, + 1.837449441984063, + 1.9221162849862594, + 2.0027575849962886, + 2.0783966959861573, + 2.1616330670076422, + 2.2441706339886878, + 2.324735550006153, + 2.404574173007859, + 2.489811067993287, + 2.5694996579841245, + 2.6529694229830056, + 2.7331435199885163, + 2.8106044660089538, + 2.89000977500109, + 2.9691086820093915, + 3.0478936200088356, + 3.1329437289969064, + 3.21813620798639, + 3.300345516996458, + 3.3815470449917484, + 3.464590326999314, + 3.5460885599895846, + 3.6254604769928847, + 3.706701732997317, + 3.7894104050064925, + 3.8658409290073905, + 3.9494127900106832, + 4.030213580001146, + 4.110493229993153, + 4.189326199993957, + 4.271006113995099, + 4.352527164010098, + 4.433254689007299, + 4.517162823991384, + 4.596785511006601, + 4.676206739997724, + 4.761076977010816, + 4.84158586099511, + 4.922383658005856, + 5.003820787009317, + 5.083411489991704, + 5.1641033189953305, + 5.242781120003201, + 5.320111440989422, + 5.3990954519831575, + 5.4782796560029965, + 5.5587564279849175, + 5.640766648983117, + 5.718904687004397, + 5.798743855004432, + 5.881365262990585, + 5.965625816985266, + 6.046944864996476, + 6.124784326006193, + 6.198781059996691, + 6.278496291983174, + 6.357905696990201, + 6.436987469001906, + 6.517273903999012, + 6.600220225984231, + 6.681447242008289, + 6.764736990007805, + 6.845122002006974, + 6.921466973988572, + 7.00529309301055, + 7.085176774009597, + 7.167189586994937, + 7.248624075989937, + 7.329242033010814, + 7.408025835000444, + 7.485405612998875, + 7.565892993006855, + 7.645235951000359, + 7.723882632009918, + 7.805611763003981, + 7.887298110988922, + 7.966079625010025, + 8.046148058987455, + 8.122513526992407, + 8.200152587000048, + 8.279613193008117, + 8.3615999899921, + 8.43968903599307, + 8.517685489990981, + 8.594580945995403, + 8.676695406989893, + 8.764573199005099, + 8.84249174798606, + 8.92065689098672, + 9.000656108983094, + 9.079551511997124, + 9.163615712983301, + 9.229238526982954 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 80.28304249455687, + "p95": 84.6668430021964, + "max": 87.87779201520607 + } + }, + { + "start": 258408.235664871, + "first": 258408.431669016, + "last": 258417.465165096, + "end": 258417.465961277, + "elapsed_s": 9.230296405992704, + "chunk_offsets_s": [ + 0.1960041449929122, + 0.47097421999205835, + 0.5505758330109529, + 0.630962155002635, + 0.7109612910135183, + 0.7911879649909679, + 0.8709054350038059, + 0.9512485250015743, + 1.0325974129955284, + 1.1103933679987676, + 1.1896700200159103, + 1.2729595440032426, + 1.3515228950127494, + 1.4324795569991693, + 1.5154575420019682, + 1.5953143739898223, + 1.6749335560016334, + 1.7536986210034229, + 1.837845157017, + 1.9225075200083666, + 2.0031507720123045, + 2.0786908910085913, + 2.1620215180155355, + 2.244579101999989, + 2.325062785006594, + 2.4048969600116834, + 2.490134799008956, + 2.569828061008593, + 2.6533717779966537, + 2.7335352190129925, + 2.810920421004994, + 2.8903317940130364, + 2.969522589002736, + 3.048286759003531, + 3.1333433010149747, + 3.218462210992584, + 3.300756993005052, + 3.3819302479969338, + 3.464991785993334, + 3.5464785950025544, + 3.6258572319929954, + 3.7069987269933335, + 3.7897234320116695, + 3.866236308007501, + 3.9497400890104473, + 4.030535853991751, + 4.11082097698818, + 4.189653162989998, + 4.271397492993856, + 4.35285558301257, + 4.433557923010085, + 4.517419803014491, + 4.5969951289880555, + 4.676360357989324, + 4.761262275016634, + 4.841769638995174, + 4.922842269996181, + 5.0040966939996, + 5.083625924016815, + 5.164371385006234, + 5.242975489993114, + 5.320407716004411, + 5.399534096010029, + 5.478504730999703, + 5.558952733990736, + 5.640966426988598, + 5.7191189610166475, + 5.798938224994345, + 5.881610448996071, + 5.96589388299617, + 6.047185828007059, + 6.1247224870021455, + 6.1990050460153725, + 6.278739797999151, + 6.358192563988268, + 6.437237503007054, + 6.517522209993331, + 6.60047144399141, + 6.681648044002941, + 6.765000257000793, + 6.845020145992748, + 6.921656991995405, + 7.005552855989663, + 7.085460039990721, + 7.1674432370055, + 7.248545340989949, + 7.32950779501698, + 7.408325438009342, + 7.485674335999647, + 7.566025954991346, + 7.645486705005169, + 7.72410783401574, + 7.805830486002378, + 7.887562193005579, + 7.9663292430050205, + 8.04641287701088, + 8.122734761011088, + 8.200369452999439, + 8.279884684015997, + 8.36152669499279, + 8.439921087003313, + 8.517932084010681, + 8.59478673999547, + 8.676956818002509, + 8.76482470499468, + 8.842719206004404, + 8.920859261008445, + 9.000586556998314, + 9.079801674000919, + 9.163822850998258, + 9.229500224988442 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 80.25569048186298, + "p95": 84.90191702730954, + "max": 274.97007499914616 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.473308071086365, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 9.22816964800586, + "end_to_end_tps": 55.48229167098586, + "timing_valid": true, + "steady_tps": 57.59156250349207, + "per_stream_tps": [ + 28.2, + 28.8 + ], + "ttft_s": [ + 0.2, + 0.39 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.1969488910108339, + "decode_tps": 28.241488770371774, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 162.47870112779523, + "prefill_tps": 162.47870112779523, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.408898168608694, + "round_gap_p50_ms": 80.00061102211475, + "round_gap_p95_ms": 84.93041500332765, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0010499580239411443, + "first_payload_s": 0.0010631589975673705, + "first_content_s": 0.1969488910108339, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1969488910108339, + "last_output_s": 9.22621792400605 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.388542853994295, + "decode_tps": 28.84768867040834, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 82.35899765246965, + "prefill_tps": 82.35899765246965, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.6648222471213, + "round_gap_p50_ms": 80.123124003876, + "round_gap_p95_ms": 84.94718300062232, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.001896636007586494, + "first_payload_s": 0.0018996919970959425, + "first_content_s": 0.388542853994295, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.388542853994295, + "last_output_s": 9.228072527010227 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.036860207865, + "round_gap_p50_ms": 80.08955599507317, + "round_gap_p95_ms": 84.93041500332765, + "round_gap_mean_ms": 81.22181230005067, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 164.7179953049393, + "aggregate_prefill_tps": 164.7179953049393 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258417.468074121, + "first": 258417.665023012, + "last": 258426.694292045, + "end": 258426.694568399, + "elapsed_s": 9.226494278002065, + "chunk_offsets_s": [ + 0.1969488910108339, + 0.4709021809976548, + 0.5514860740222502, + 0.6312350980006158, + 0.7114698220102582, + 0.7915690079971682, + 0.8714702569996007, + 0.9514664830057882, + 1.0315084050234873, + 1.1089461680094246, + 1.1876899060152937, + 1.2717387000157032, + 1.3504578139982186, + 1.4344294230104424, + 1.5144156010064762, + 1.5938645920250565, + 1.6737571530102286, + 1.7531573270098306, + 1.8374701220018324, + 1.9222043920017313, + 2.0025396600249223, + 2.0781887890188955, + 2.160751686024014, + 2.2436007920186967, + 2.324135405011475, + 2.404101838998031, + 2.489370544004487, + 2.571725055022398, + 2.6516779370140284, + 2.7329475470178295, + 2.810472175013274, + 2.8896028120070696, + 2.9684927110210992, + 3.047474771999987, + 3.1324051870033145, + 3.218050134018995, + 3.3004286140203476, + 3.3816298550227657, + 3.4608442520257086, + 3.5424375279981177, + 3.622383562003961, + 3.7032539370120503, + 3.786461142008193, + 3.862675971002318, + 3.9462361540063284, + 4.026632399007212, + 4.106491359998472, + 4.184968538000248, + 4.267568363022292, + 4.348818997008493, + 4.431082164024701, + 4.513724294025451, + 4.593218294001417, + 4.672297011013143, + 4.758133766998071, + 4.838985567010241, + 4.919827414007159, + 5.001355729997158, + 5.0804103030241095, + 5.160608354024589, + 5.239902736997465, + 5.3175383580091875, + 5.396460146002937, + 5.475186173018301, + 5.55664480800624, + 5.638699367002118, + 5.716696237999713, + 5.796155901014572, + 5.879081777005922, + 5.9633004770148546, + 6.0442164210253395, + 6.12172832901706, + 6.195478615001775, + 6.27547922602389, + 6.355317708017537, + 6.434121655009221, + 6.514243099023588, + 6.597755121998489, + 6.678589786024531, + 6.762698661012109, + 6.842152981000254, + 6.918894468020881, + 7.002642749022925, + 7.082281854003668, + 7.163333671021974, + 7.245427494024625, + 7.325643674004823, + 7.404241620999528, + 7.482310893014073, + 7.562707250006497, + 7.640847130009206, + 7.719947767996928, + 7.801870102004614, + 7.883416483004112, + 7.962460336013464, + 8.042549892008537, + 8.11881092900876, + 8.1954377439979, + 8.275396515004104, + 8.357240192999598, + 8.4351820560114, + 8.51430170200183, + 8.591441352997208, + 8.67562406801153, + 8.761621547018876, + 8.839655634015799, + 8.918159325025044, + 8.997929039003793, + 9.07676820299821, + 9.160236338997493, + 9.22621792400605 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 80.02126651990693, + "p95": 84.93041500332765, + "max": 273.9532899868209 + } + }, + { + "start": 258417.467765527, + "first": 258417.856308381, + "last": 258426.695838054, + "end": 258426.695935175, + "elapsed_s": 9.22816964800586, + "chunk_offsets_s": [ + 0.388542853994295, + 0.47150504900491796, + 0.5518726690206677, + 0.6316279010206927, + 0.711862399999518, + 0.7919444340222981, + 0.8718457480135839, + 0.9518385650007986, + 1.0322816419939045, + 1.1095707640051842, + 1.1883279580215458, + 1.272323695011437, + 1.3508274970226921, + 1.4348367700004019, + 1.5147920190065634, + 1.5944809149950743, + 1.674367029016139, + 1.7537954590225127, + 1.837870509014465, + 1.9228176920150872, + 2.0031572000007145, + 2.0786481670220383, + 2.161161063995678, + 2.244033691007644, + 2.324782033014344, + 2.4045286260079592, + 2.489982676022919, + 2.5721432660066057, + 2.6523519740148913, + 2.7335572470037732, + 2.810893121000845, + 2.890204046998406, + 2.969153515994549, + 3.047896774020046, + 3.1330407590139657, + 3.2184453679947183, + 3.3011039300181437, + 3.3822805150120985, + 3.4612322710163426, + 3.5428749230050016, + 3.6227694530098233, + 3.7038828850199934, + 3.786864969006274, + 3.863278375007212, + 3.9468657100223936, + 4.027118338010041, + 4.107159108010819, + 4.185612622008193, + 4.2678173890162725, + 4.34949404100189, + 4.431524359009927, + 4.514139625011012, + 4.59382696900866, + 4.673014503001468, + 4.758803179021925, + 4.8394047540205065, + 4.9204893540008925, + 5.00194173300406, + 5.080796816997463, + 5.161090709007112, + 5.240308052016189, + 5.3179496560187545, + 5.396960709011182, + 5.475809729017783, + 5.557292123994557, + 5.639326522999909, + 5.717304514022544, + 5.796836546011036, + 5.879676069016568, + 5.963933777005877, + 6.044630103016971, + 6.122349484998267, + 6.19589249001001, + 6.2758668920141645, + 6.359558580996236, + 6.43475802699686, + 6.514881151000736, + 6.598383125994587, + 6.6792475180118345, + 6.763338760996703, + 6.842768775997683, + 6.919308167009149, + 7.003135856008157, + 7.0829426260024775, + 7.163979035016382, + 7.245919656998012, + 7.326038493018132, + 7.404835352994269, + 7.482720975007396, + 7.563113589014392, + 7.641493917995831, + 7.7206235640042, + 7.802484378014924, + 7.883914694015402, + 7.96285217901459, + 8.043216152000241, + 8.119461013004184, + 8.195843971014256, + 8.276074887020513, + 8.357885029021418, + 8.435831195994979, + 8.514879866008414, + 8.59186364299967, + 8.676083575002849, + 8.76228321500821, + 8.840315958019346, + 8.918811857001856, + 8.998337841010652, + 9.076992429007078, + 9.160489285015501, + 9.228072527010227 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 80.1659160060808, + "p95": 84.94718300062232, + "max": 86.19964000536129 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 53.933192855746825, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 9.657535255973926, + "end_to_end_tps": 53.01559729572706, + "timing_valid": true, + "steady_tps": 55.168128385520646, + "per_stream_tps": [ + 27.0, + 27.6 + ], + "ttft_s": [ + 0.2, + 0.43 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.2009343420213554, + "decode_tps": 26.966596427873412, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 159.2560021253063, + "prefill_tps": 159.2560021253063, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 37.082914882293885, + "round_gap_p50_ms": 80.93935399665497, + "round_gap_p95_ms": 104.97290300554596, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0009903580066747963, + "first_payload_s": 0.001011814019875601, + "first_content_s": 0.2009343420213554, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.2009343420213554, + "last_output_s": 9.657077637006296 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.43061928398674354, + "decode_tps": 27.638621281749167, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 74.31158145947107, + "prefill_tps": 74.31158145947107, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 36.181254839232444, + "round_gap_p50_ms": 80.93295397702605, + "round_gap_p95_ms": 104.67763800988905, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0017135139787569642, + "first_payload_s": 0.0017168099875561893, + "first_content_s": 0.43061928398674354, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.43061928398674354, + "last_output_s": 9.656839267991018 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 36.632084860763165, + "round_gap_p50_ms": 80.93935399665497, + "round_gap_p95_ms": 104.69760600244626, + "round_gap_mean_ms": 84.91983308631461, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 148.62316291894214, + "aggregate_prefill_tps": 148.62316291894214 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258426.697673297, + "first": 258426.898607639, + "last": 258436.354750934, + "end": 258436.354906679, + "elapsed_s": 9.657233381993137, + "chunk_offsets_s": [ + 0.2009343420213554, + 0.5261313620139845, + 0.6062264220090583, + 0.6861423130030744, + 0.7662853890215047, + 0.8463857290043961, + 0.9260211380023975, + 1.006077333993744, + 1.0860585379996337, + 1.1638801280059852, + 1.2433371689985506, + 1.329954587010434, + 1.4086414790072013, + 1.4893492300179787, + 1.5692457300028764, + 1.6487151379988063, + 1.7282797149964608, + 1.807052112009842, + 1.8911503790004645, + 1.9771313620149158, + 2.057639528007712, + 2.1332007060118485, + 2.216841067012865, + 2.299035164003726, + 2.3799606770044193, + 2.462491462996695, + 2.5481781880080234, + 2.6269921690109186, + 2.7079751070123166, + 2.7886877070122864, + 2.8658059340086766, + 2.9451716460171156, + 3.024345612997422, + 3.1030696090019774, + 3.188333035999676, + 3.2736397109983955, + 3.356123841018416, + 3.4370812110137194, + 3.5162580420146696, + 3.597435764997499, + 3.6767542129964568, + 3.7580561130016576, + 3.8408966129936744, + 3.917489909013966, + 4.001762882020557, + 4.082856509019621, + 4.162937953020446, + 4.241760302014882, + 4.323739550018217, + 4.408202732010977, + 4.489343527005985, + 4.570270385011099, + 4.649634497007355, + 4.7296024530078284, + 4.814366261009127, + 4.895137614017585, + 4.976633946993388, + 5.057874357997207, + 5.137215366994496, + 5.2182962730003055, + 5.297050813998794, + 5.375871532014571, + 5.454621976998169, + 5.536706281010993, + 5.617645635007648, + 5.699020271014888, + 5.7770306000020355, + 5.856372009002371, + 5.93928519799374, + 6.023657676007133, + 6.104901560000144, + 6.182403868995607, + 6.256604719994357, + 6.336203793995082, + 6.415911813004641, + 6.494732002000092, + 6.575096985005075, + 6.658065295021515, + 6.739379851002013, + 6.8231929980101995, + 6.902964297012659, + 6.980722481006524, + 7.065199119999306, + 7.145323892997112, + 7.226875602995278, + 7.30825252700015, + 7.3890044880099595, + 7.473235334007768, + 7.570994403009536, + 7.666506690002279, + 7.763614330993732, + 7.863423652015626, + 7.969585665996419, + 8.076067762012826, + 8.178982701007044, + 8.2830415990029, + 8.385651192016667, + 8.488780451996718, + 8.599152123002568, + 8.711116891994607, + 8.816089795000153, + 8.920787401002599, + 9.023968501016498, + 9.107084620016394, + 9.191949005995411, + 9.270390890014824, + 9.349379145016428, + 9.427982406021329, + 9.50744290399598, + 9.590933921019314, + 9.657077637006296 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 80.94836199597921, + "p95": 104.97290300554596, + "max": 325.19701999262907 + } + }, + { + "start": 258426.697371423, + "first": 258427.127990707, + "last": 258436.354210691, + "end": 258436.354318867, + "elapsed_s": 9.656947443989338, + "chunk_offsets_s": [ + 0.43061928398674354, + 0.526817381993169, + 0.6068553539807908, + 0.6867386359954253, + 0.7668974409752991, + 0.8470145649916958, + 0.9264013009960763, + 1.006846346979728, + 1.0866960939893033, + 1.1643504349922296, + 1.2439124999800697, + 1.330370748997666, + 1.4092227299988735, + 1.4897177609964274, + 1.5697551889752503, + 1.6491106129833497, + 1.7288780550006777, + 1.8076633629971184, + 1.8918370079773013, + 1.9775298759923317, + 2.0582954209821764, + 2.1338249499967787, + 2.2172455659892876, + 2.2994707339967135, + 2.380365542980144, + 2.463123066991102, + 2.548571790975984, + 2.627649645000929, + 2.7083693809981924, + 2.7891359659843147, + 2.8661987519881222, + 2.945814481994603, + 3.0248336479999125, + 3.1037127649760805, + 3.1887215669848956, + 3.2742823389999103, + 3.3567111729935277, + 3.4376676629763097, + 3.516644028975861, + 3.597916055994574, + 3.6771454959816765, + 3.7582036659878213, + 3.8412522159924265, + 3.9179368240002077, + 4.002148052997654, + 4.083354192000115, + 4.163428883999586, + 4.242227152979467, + 4.323889950988814, + 4.408602174982661, + 4.4897978020017035, + 4.57073075597873, + 4.650113699986832, + 4.730087848001858, + 4.814752823993331, + 4.895288478990551, + 4.976986956986366, + 5.058225321001373, + 5.137355496000964, + 5.218684116000077, + 5.297527841001283, + 5.376025452977046, + 5.455080714978976, + 5.537184475979302, + 5.618126838002354, + 5.6991740969824605, + 5.777407722984208, + 5.8567587309808005, + 5.939643711986719, + 6.024037086986937, + 6.105279162002262, + 6.182784031989286, + 6.25674657698255, + 6.336585315992124, + 6.416262886981713, + 6.495082372974139, + 6.575449386989931, + 6.658444689994212, + 6.739731198002119, + 6.823542903992347, + 6.9033418519829866, + 6.981101186975138, + 7.065580753987888, + 7.145681558991782, + 7.2272547890024725, + 7.308603232988389, + 7.389256809983635, + 7.473649079998722, + 7.571352389000822, + 7.666655954992166, + 7.763966092985356, + 7.863783717999468, + 7.970047908980632, + 8.076601444976404, + 8.17922025398002, + 8.283445009001298, + 8.385777528979816, + 8.489269350975519, + 8.599644349975279, + 8.711566205980489, + 8.816579045989783, + 8.921256683999673, + 9.024462487985147, + 9.106890091992682, + 9.192322543996852, + 9.270834684983129, + 9.349147079978138, + 9.428452024993021, + 9.507922202988993, + 9.59130753998761, + 9.656839267991018 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 80.93765800003894, + "p95": 104.67763800988905, + "max": 111.92185600521043 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + } + ] + }, + { + "prompt": "chat", + "temperature": 0.0, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 4, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 85.4, + "per_stream_tps": 21.8, + "ttft_s_max": 0.79, + "request": { + "ttft_s": 0.486, + "decode_tps": 21.733, + "prompt_ttft_tps": 68.542, + "prefill_tps": 68.542, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 46.013, + "round_gap_p50_ms": 102.689, + "round_gap_p95_ms": 108.556, + "tokens_per_chunk": 2.306, + "headers_s": 0.002, + "first_payload_s": 0.002, + "first_content_s": 0.486, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.486, + "last_output_s": 12.147 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 165.111, + "aggregate_prefill_tps": 165.111, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.73, + "round_gap_p50_ms": 102.699, + "round_gap_p95_ms": 108.367, + "tokens_per_chunk": 2.306 + }, + "completions": { + "truncated": 12 + }, + "timing_valid": true, + "end_to_end_tps": 84.29277243740043, + "makespan_s": 12.148135248018662, + "steady_tps": 89.2, + "alone": { + "equal": 12, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 1, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 85.35117289145266, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 12.148135248018662, + "end_to_end_tps": 84.29277243740043, + "timing_valid": true, + "steady_tps": 89.24896877682905, + "per_stream_tps": [ + 22.1, + 21.3, + 21.7, + 22.4 + ], + "ttft_s": [ + 0.58, + 0.2, + 0.39, + 0.77 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.5820965169987176, + "decode_tps": 22.050593971190597, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.9737012085068, + "prefill_tps": 54.9737012085068, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.35025230188872, + "round_gap_p50_ms": 103.22146900580265, + "round_gap_p95_ms": 108.0880609806627, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0022541569778695703, + "first_payload_s": 0.002255868981592357, + "first_content_s": 0.5820965169987176, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5820965169987176, + "last_output_s": 12.146410853980342 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.19679294599336572, + "decode_tps": 21.339467988622488, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 162.60745444137405, + "prefill_tps": 162.60745444137405, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 46.861524407879685, + "round_gap_p50_ms": 103.2904299790971, + "round_gap_p95_ms": 108.23943602736108, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0014820409996900707, + "first_payload_s": 0.0014850969891995192, + "first_content_s": 0.19679294599336572, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19679294599336572, + "last_output_s": 12.146481670002686 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.3897174209996592, + "decode_tps": 21.689206913510745, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 82.11077636179877, + "prefill_tps": 82.11077636179877, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 46.10588132556729, + "round_gap_p50_ms": 103.27283199876547, + "round_gap_p95_ms": 108.46639701048844, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0018291140149813145, + "first_payload_s": 0.0018310820159967989, + "first_content_s": 0.3897174209996592, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3897174209996592, + "last_output_s": 12.146717159019317 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.7741504599980544, + "decode_tps": 22.420750421316434, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 41.33563390258842, + "prefill_tps": 41.33563390258842, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.601540145117276, + "round_gap_p50_ms": 103.24441400007345, + "round_gap_p95_ms": 108.17613999824971, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0028238570084795356, + "first_payload_s": 0.002831777004757896, + "first_content_s": 0.7741504599980544, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.7741504599980544, + "last_output_s": 12.14754319700296 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.729799545113245, + "round_gap_p50_ms": 103.27163100009784, + "round_gap_p95_ms": 108.17613999824971, + "round_gap_mean_ms": 106.0099898545807, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 165.34253561035368, + "aggregate_prefill_tps": 165.34253561035368 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258436.356833602, + "first": 258436.938930119, + "last": 258448.503244456, + "end": 258448.503349481, + "elapsed_s": 12.14651587899425, + "chunk_offsets_s": [ + 0.5820965169987176, + 0.8877891419979278, + 0.990843090985436, + 1.0948370929982048, + 1.1976385279849637, + 1.3008599969907664, + 1.4032260699896142, + 1.5046222649980336, + 1.6079033019777853, + 1.7085731729748659, + 1.8093858929933049, + 1.9163056719989982, + 2.020213818002958, + 2.123201861977577, + 2.2265361809986643, + 2.32870599598391, + 2.431963001989061, + 2.535139382991474, + 2.642432556982385, + 2.7512138199817855, + 2.8542308879841585, + 2.9516665479750372, + 3.0569445259752683, + 3.1620315909967758, + 3.2655602309969254, + 3.3687351729895454, + 3.476979359984398, + 3.579158455977449, + 3.6816616659925785, + 3.7850653609784786, + 3.888019997975789, + 3.991318123997189, + 4.0925944469927344, + 4.193798769003479, + 4.301852475997293, + 4.409442259988282, + 4.51403316197684, + 4.617809114977717, + 4.719343392003793, + 4.824760042974958, + 4.927027571975486, + 5.032638815988321, + 5.13973574899137, + 5.242914915987058, + 5.349807015998522, + 5.453398263984127, + 5.558667554985732, + 5.660344471980352, + 5.764819373987848, + 5.871391808002954, + 5.9741553719795775, + 6.079061236989219, + 6.181819360994268, + 6.283332244987832, + 6.391401311993832, + 6.495388674986316, + 6.599795304995496, + 6.702862998994533, + 6.805097343982197, + 6.909015986981103, + 7.014084380993154, + 7.115440961002605, + 7.217469847993925, + 7.320043810992502, + 7.424045911000576, + 7.5278341049852315, + 7.627943173982203, + 7.731106147984974, + 7.838288938975893, + 7.946765640983358, + 8.054828195978189, + 8.15550083600101, + 8.251704713999061, + 8.354937928990694, + 8.457585940981517, + 8.559751517983386, + 8.663841906003654, + 8.76887007598998, + 8.872553581983084, + 8.978230731998337, + 9.082254271983402, + 9.181685992982239, + 9.28866738997749, + 9.391670891985996, + 9.49577318498632, + 9.60078937097569, + 9.70382823300315, + 9.805521328002214, + 9.905453675979516, + 10.008090807998087, + 10.110736356000416, + 10.21166832599556, + 10.317915544001153, + 10.423463749000803, + 10.524814776988933, + 10.629866003990173, + 10.728856713976711, + 10.828449844993884, + 10.93058793398086, + 11.036222011985956, + 11.139603900985094, + 11.2408428810013, + 11.340797853976255, + 11.445233315986115, + 11.555038538994268, + 11.655928812979255, + 11.757917718001409, + 11.860737954993965, + 11.963736498000799, + 12.071824558981461, + 12.146410853980342 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 103.22734199871775, + "p95": 108.0880609806627, + "max": 305.69262499921024 + } + }, + { + "start": 258436.356283759, + "first": 258436.553076705, + "last": 258448.502765429, + "end": 258448.502843526, + "elapsed_s": 12.146559766988503, + "chunk_offsets_s": [ + 0.19679294599336572, + 0.8887709399859887, + 0.9916155909886584, + 1.0955624569905922, + 1.1980137939972337, + 1.3012314549996518, + 1.4035552080022171, + 1.5050074990140274, + 1.6082979289931245, + 1.7090755279932637, + 1.8101443450141232, + 1.9166162020119373, + 2.0206851800030563, + 2.123673736990895, + 2.2268024859949946, + 2.3291484779911116, + 2.432581597007811, + 2.5354672090034, + 2.6428687990119215, + 2.7519881280022673, + 2.854667851002887, + 2.9519215259933844, + 3.057569105993025, + 3.1625187619938515, + 3.266050506004831, + 3.3692226469866, + 3.477462083013961, + 3.5794483610079624, + 3.6820228839933407, + 3.785872020991519, + 3.8884569279907737, + 3.992214944999432, + 4.093040161009412, + 4.194241268007318, + 4.302021389012225, + 4.409866309986683, + 4.514387356000952, + 4.618785249011125, + 4.7196505129977595, + 4.825120636989595, + 4.92748394201044, + 5.0333970279898494, + 5.140375929011498, + 5.2438392089970876, + 5.350204201997258, + 5.453845273994375, + 5.559071060997667, + 5.660987851006212, + 5.76552254598937, + 5.871459312009392, + 5.974795023998013, + 6.0791751090146136, + 6.18185763299698, + 6.283366421004757, + 6.391867155005457, + 6.496182008006144, + 6.600465997005813, + 6.703737628005911, + 6.8052512489957735, + 6.909799574990757, + 7.014161628991133, + 7.115504977002274, + 7.218142124009319, + 7.320513493992621, + 7.424147862999234, + 7.5279658020008355, + 7.628309048013762, + 7.732182954001473, + 7.8386221720138565, + 7.9474994690099265, + 8.054883300006622, + 8.156152103998465, + 8.25209937200998, + 8.355615020991536, + 8.458069335989421, + 8.560359313007211, + 8.664626262005186, + 8.76984534598887, + 8.873231937992387, + 8.978924127994105, + 9.082974596007261, + 9.182141466997564, + 9.289094784995541, + 9.392108911008108, + 9.496825415000785, + 9.60124422100489, + 9.704263771011028, + 9.805967410007725, + 9.905576252000174, + 10.008852828003, + 10.110864421003498, + 10.212298538011964, + 10.318187497003237, + 10.424311817012494, + 10.525179546995787, + 10.630664247990353, + 10.729763984010788, + 10.82936290599173, + 10.931214370008092, + 11.037018161005108, + 11.1402344800008, + 11.241583316994365, + 11.341726290993392, + 11.446069177007303, + 11.55567199800862, + 11.656301982991863, + 11.758382759988308, + 11.861371990991756, + 11.964631190989166, + 12.07225987300626, + 12.146481670002686 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 103.31307098385878, + "p95": 108.23943602736108, + "max": 691.9779939926229 + } + }, + { + "start": 258436.356927683, + "first": 258436.746645104, + "last": 258448.503644842, + "end": 258448.504068557, + "elapsed_s": 12.147140874003526, + "chunk_offsets_s": [ + 0.3897174209996592, + 0.8875528360076714, + 0.9908135860168841, + 1.0945369630062487, + 1.1974303660099395, + 1.3009868139924947, + 1.4025727219996043, + 1.504450790991541, + 1.6077175890095532, + 1.708120497991331, + 1.809616101993015, + 1.9157589960086625, + 2.0204610509972554, + 2.1234857510135043, + 2.2263679390016478, + 2.328651115007233, + 2.431810392998159, + 2.5348975739907473, + 2.6424507810152136, + 2.750958249991527, + 2.8541950799990445, + 2.9517746930068824, + 3.0566050359921064, + 3.1620361669920385, + 3.265518502012128, + 3.368389537994517, + 3.477115200017579, + 3.5790301029919647, + 3.681505376007408, + 3.784699518000707, + 3.888169342011679, + 3.9914755490026437, + 4.092784303997178, + 4.194081777997781, + 4.3016751460090745, + 4.409290178009542, + 4.513872392009944, + 4.61792434801464, + 4.7191974540182855, + 4.8248416270071175, + 4.927113779995125, + 5.032649967994075, + 5.139581572002498, + 5.24366856800043, + 5.349464564991649, + 5.453104646003339, + 5.558340624003904, + 5.660169686016161, + 5.7655158580164425, + 5.870578619011212, + 5.973492807999719, + 6.078443297010381, + 6.181123948015738, + 6.282622464990709, + 6.391088862001197, + 6.4954150750127155, + 6.600402971991571, + 6.702992631006055, + 6.804925998003455, + 6.9090803709987085, + 7.0134066799946595, + 7.114782796008512, + 7.217887481994694, + 7.32012561900774, + 7.423427043017, + 7.527224437013501, + 7.627583410998341, + 7.730923219001852, + 7.837903928011656, + 7.946587447018828, + 8.054146912007127, + 8.155087969003944, + 8.251278278999962, + 8.354551110998727, + 8.457323459006147, + 8.55946871600463, + 8.663583920017118, + 8.769079821009655, + 8.872319916001288, + 8.977926649997244, + 9.081945757992798, + 9.181413671001792, + 9.288358188001439, + 9.39138380199438, + 9.496110017993487, + 9.600511833006749, + 9.703885688999435, + 9.805476287001511, + 9.904724807012826, + 10.007914838002762, + 10.110013758996502, + 10.211341364018153, + 10.317404516012175, + 10.423597093002172, + 10.524453815014567, + 10.629956899996614, + 10.728960027016, + 10.829217177000828, + 10.93029260399635, + 11.035981177992653, + 11.139405530993827, + 11.240694144013105, + 11.340884558012476, + 11.445002131018555, + 11.554847129009431, + 11.65603863701108, + 11.757605299004354, + 11.860540241992567, + 11.964072228001896, + 12.071507243992528, + 12.146717159019317 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 103.28712800401263, + "p95": 108.46639701048844, + "max": 497.8354150080122 + } + }, + { + "start": 258436.356160142, + "first": 258437.130310602, + "last": 258448.503703339, + "end": 258448.50429539, + "elapsed_s": 12.148135248018662, + "chunk_offsets_s": [ + 0.7741504599980544, + 0.8886935480113607, + 0.9916689200035762, + 1.0955788730061613, + 1.1979653300077189, + 1.3019388999964576, + 1.403743864997523, + 1.5053634850191884, + 1.608733947010478, + 1.7093712259957101, + 1.810341033997247, + 1.916792363015702, + 2.0217181949992664, + 2.12404970699572, + 2.2269951270136517, + 2.329334544017911, + 2.432868542993674, + 2.535874972003512, + 2.643162961001508, + 2.75204518501414, + 2.855089245014824, + 2.9521691109985113, + 3.0577403390198015, + 3.162760459992569, + 3.266337644017767, + 3.369460425019497, + 3.4777033959981054, + 3.5796406190202106, + 3.682555655017495, + 3.7858000690175686, + 3.8888130100094713, + 3.992160865018377, + 4.093443972000387, + 4.194668726006057, + 4.3022872940055095, + 4.410298185015563, + 4.514860415016301, + 4.618808672996238, + 4.71991568300291, + 4.825379838992376, + 4.927917209017323, + 5.0336757820041385, + 5.140259049017914, + 5.243773497000802, + 5.350425195007119, + 5.454119339992758, + 5.559389414993348, + 5.66121326101711, + 5.76589065999724, + 5.871509745018557, + 5.974393886019243, + 6.079820937011391, + 6.182443700003205, + 6.2839546970208175, + 6.392130837019067, + 6.4964054650045, + 6.600873215007596, + 6.703921085019829, + 6.80550628999481, + 6.909791126992786, + 7.014925505995052, + 7.116229973005829, + 7.218444797996199, + 7.320468805992277, + 7.424797226994997, + 7.527886185009265, + 7.628665946016554, + 7.732100202003494, + 7.839041230996372, + 7.948079584020888, + 8.055597769009182, + 8.15600528701907, + 8.2521414369985, + 8.355409323994536, + 8.458314601011807, + 8.560325697006192, + 8.664587383012986, + 8.76959907199489, + 8.873280050000176, + 8.978803263016744, + 9.0828580520174, + 9.182410492998315, + 9.289391714992234, + 9.3923978570092, + 9.496542085020337, + 9.601518014998874, + 9.70457062200876, + 9.806296260008821, + 9.905609133013058, + 10.008849836012814, + 10.110894661018392, + 10.212212025013287, + 10.318395034002606, + 10.424069592001615, + 10.525431165006012, + 10.630465815018397, + 10.729469901998527, + 10.829253978008637, + 10.931161810003687, + 11.037024560995633, + 11.140424946002895, + 11.241624550020788, + 11.341754851018777, + 11.446016936999513, + 11.555899839993799, + 11.656533809000393, + 11.758679146005306, + 11.861588488012785, + 11.964525271003367, + 12.072554803016828, + 12.14754319700296 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 103.25615049805492, + "p95": 108.17613999824971, + "max": 114.54308801330626 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 85.70444007445295, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 12.099370642012218, + "end_to_end_tps": 84.63250116864764, + "timing_valid": true, + "steady_tps": 89.7978928385415, + "per_stream_tps": [ + 22.2, + 22.6, + 21.4, + 21.8 + ], + "ttft_s": [ + 0.6, + 0.79, + 0.2, + 0.39 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.6017538000014611, + "decode_tps": 22.181607181426358, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 53.177894348024566, + "prefill_tps": 53.177894348024566, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.08239605096534, + "round_gap_p50_ms": 102.2373890154995, + "round_gap_p95_ms": 108.72995399404317, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0017422339878976345, + "first_payload_s": 0.0017527460004203022, + "first_content_s": 0.6017538000014611, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.6017538000014611, + "last_output_s": 12.097764792997623 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.7944969199888874, + "decode_tps": 22.560118605517758, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 40.27705985373434, + "prefill_tps": 40.27705985373434, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.32600809799909, + "round_gap_p50_ms": 102.25302100297995, + "round_gap_p95_ms": 108.36678300984204, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0018186029919888824, + "first_payload_s": 0.0018307789869140834, + "first_content_s": 0.7944969199888874, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.7944969199888874, + "last_output_s": 12.097628984978655 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.1966598629951477, + "decode_tps": 21.427546106059015, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 162.71749360869612, + "prefill_tps": 162.71749360869612, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 46.6688996980962, + "round_gap_p50_ms": 102.29241300839931, + "round_gap_p95_ms": 108.30299099325202, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0011475910141598433, + "first_payload_s": 0.0011649829975795, + "first_content_s": 0.1966598629951477, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1966598629951477, + "last_output_s": 12.097229286009679 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.38879496199660935, + "decode_tps": 21.776572572368774, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 82.30559325066324, + "prefill_tps": 82.30559325066324, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.92090865891591, + "round_gap_p50_ms": 102.20711602596566, + "round_gap_p95_ms": 108.64462397876196, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0018849869957193732, + "first_payload_s": 0.0018883150187321007, + "first_content_s": 0.38879496199660935, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.38879496199660935, + "last_output_s": 12.098626670020167 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.499553126494135, + "round_gap_p50_ms": 102.2647809877526, + "round_gap_p95_ms": 108.36678300984204, + "round_gap_mean_ms": 105.47623679323641, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 161.02802343215797, + "aggregate_prefill_tps": 161.02802343215797 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258448.50690179, + "first": 258449.10865559, + "last": 258460.604666583, + "end": 258460.604755944, + "elapsed_s": 12.097854153980734, + "chunk_offsets_s": [ + 0.6017538000014611, + 0.9027235579851549, + 1.0047611669870093, + 1.1064736859989353, + 1.2082899659872055, + 1.310837338998681, + 1.4124405769980513, + 1.5137213979905937, + 1.6167795739893336, + 1.7175576879817527, + 1.8184393219999038, + 1.923604997980874, + 2.027171384979738, + 2.1287499189784285, + 2.2318501109839417, + 2.3326646409987006, + 2.434469896979863, + 2.535532076988602, + 2.642729924991727, + 2.75145987898577, + 2.8532463029841892, + 2.95144225799595, + 3.0550816049799323, + 3.159614588978002, + 3.2628270059940405, + 3.3645834460039623, + 3.4725694909866434, + 3.573355589003768, + 3.6766856869799085, + 3.779802902980009, + 3.879200992989354, + 3.9842073250038084, + 4.084572572988691, + 4.185536607983522, + 4.291805298998952, + 4.398746825987473, + 4.5025352939846925, + 4.605162171996199, + 4.705913646990666, + 4.810503496002639, + 4.912505938002141, + 5.014511579996906, + 5.123366797983181, + 5.221951363986591, + 5.327683587995125, + 5.430719523981679, + 5.532831613993039, + 5.633413359988481, + 5.737725159997353, + 5.840935176995117, + 5.943504022987327, + 6.046790311986115, + 6.148401023994666, + 6.250083480001194, + 6.356805565999821, + 6.46103755797958, + 6.564119861985091, + 6.667147895001108, + 6.768572109984234, + 6.871010906994343, + 6.97205806398415, + 7.076064549997682, + 7.177438715996686, + 7.278262559993891, + 7.381464240985224, + 7.482556133996695, + 7.581896160991164, + 7.685274035990005, + 7.790907075977884, + 7.898252301994944, + 8.001312894979492, + 8.10453584100469, + 8.199722163000843, + 8.301844109984813, + 8.403598374978174, + 8.503718950989423, + 8.606047171982937, + 8.710902783001075, + 8.813055979000637, + 8.919317662977846, + 9.021443945995998, + 9.120079568994697, + 9.226444965985138, + 9.328264063980896, + 9.432708920998266, + 9.535573176981416, + 9.63846469699638, + 9.74014520199853, + 9.838497032003943, + 9.938694263983052, + 10.039422219997505, + 10.141119732987136, + 10.245212651992915, + 10.350024839979596, + 10.450550185982138, + 10.552787574997637, + 10.651089099992532, + 10.750709576997906, + 10.851520780997816, + 10.95658845899743, + 11.055736676993547, + 11.161647479981184, + 11.274781572981738, + 11.405969355982961, + 11.515258114988683, + 11.614577150001423, + 11.71524817799218, + 11.815550786996027, + 11.918451699981233, + 12.023677410994424, + 12.097764792997623 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.28280500450637, + "p95": 108.72995399404317, + "max": 300.96975798369385 + } + }, + { + "start": 258448.506956366, + "first": 258449.301453286, + "last": 258460.604585351, + "end": 258460.605520412, + "elapsed_s": 12.0985640459985, + "chunk_offsets_s": [ + 0.7944969199888874, + 0.9028637029987294, + 1.004499885981204, + 1.106086788000539, + 1.2080421569989994, + 1.3103062000009231, + 1.4122119839885272, + 1.513482437003404, + 1.6163712989946362, + 1.7171162290032953, + 1.8180323120031971, + 1.9233023730048444, + 2.02686354299658, + 2.128464317996986, + 2.2314333569956943, + 2.3324020319851115, + 2.4343490169849247, + 2.5352378039970063, + 2.642294466990279, + 2.7511146609904245, + 2.853068957978394, + 2.9511007359833457, + 3.054955636005616, + 3.1593245399999432, + 3.2624684920010623, + 3.3643258289957885, + 3.4721706729906145, + 3.573098355991533, + 3.676393300993368, + 3.779407508991426, + 3.878941215982195, + 3.9840417240047827, + 4.084114825993311, + 4.185141053982079, + 4.291510321985697, + 4.3983562479843386, + 4.502142668003216, + 4.604736009991029, + 4.705500796000706, + 4.8101073339930736, + 4.9122915850020945, + 5.014657021005405, + 5.123233852995327, + 5.2217992350051645, + 5.328184679005062, + 5.430621795007028, + 5.532702077995054, + 5.633714658004465, + 5.737520614988171, + 5.840804937004577, + 5.943306389992358, + 6.046587655990152, + 6.148300559987547, + 6.25008839298971, + 6.35665854200488, + 6.460858996986644, + 6.563946341979317, + 6.666910150001058, + 6.768706222996116, + 6.870801833982114, + 6.97206400000141, + 7.075212784984615, + 7.178188608988421, + 7.278465568990214, + 7.380593115987722, + 7.4826600549858995, + 7.581787168979645, + 7.684704208979383, + 7.790152208006475, + 7.897511866001878, + 8.001112765981816, + 8.10379705298692, + 8.199478273978457, + 8.301649453002028, + 8.403463238995755, + 8.50335968498257, + 8.605261007003719, + 8.710686429985799, + 8.812939450988779, + 8.919092733995058, + 9.021330874005798, + 9.119963040982839, + 9.226202900987118, + 9.328141582984244, + 9.432592953002313, + 9.535331816005055, + 9.638216823979747, + 9.739990065980237, + 9.838378999003908, + 9.93845202299417, + 10.0393037229951, + 10.141123364999657, + 10.245089036005083, + 10.349689013994066, + 10.4502857849875, + 10.552671333978651, + 10.65092529100366, + 10.750471912004286, + 10.851655278995167, + 10.956429641984869, + 11.05544125198503, + 11.161671751993708, + 11.274795044999337, + 11.405632138979854, + 11.515113361994736, + 11.614158235985087, + 11.714891391980927, + 11.815602083981503, + 11.91822697900352, + 12.023703490995103, + 12.097628984978655 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.25853200245183, + "p95": 108.36678300984204, + "max": 130.83709398051724 + } + }, + { + "start": 258448.507160335, + "first": 258448.703820198, + "last": 258460.604389621, + "end": 258460.60593123, + "elapsed_s": 12.098770895012422, + "chunk_offsets_s": [ + 0.1966598629951477, + 0.9026179740030784, + 1.0043857250129804, + 1.1059745000093244, + 1.2077869240019936, + 1.3102789040131029, + 1.4121274560166057, + 1.5133770919928793, + 1.6163539080007467, + 1.717041637020884, + 1.8179895440116525, + 1.9232927090197336, + 2.0267750789935235, + 2.12844404601492, + 2.2313688450085465, + 2.332342336012516, + 2.434375912998803, + 2.535201932012569, + 2.64229408299434, + 2.7510717330151238, + 2.853133822995005, + 2.951244577008765, + 3.055152229993837, + 3.159277196013136, + 3.2624455320183188, + 3.364242996001849, + 3.47213800100144, + 3.5729879080026876, + 3.6763372370041907, + 3.779364453017479, + 3.878815152012976, + 3.9841169730061665, + 4.084222842997406, + 4.1850096940179355, + 4.291451266006334, + 4.398311480006669, + 4.502100779995089, + 4.604659674019786, + 4.705445388011867, + 4.810060518007958, + 4.911943343002349, + 5.0145480440114625, + 5.1228510350047145, + 5.222287846001564, + 5.327346386009594, + 5.43032958600088, + 5.532331836002413, + 5.633326928014867, + 5.737372758012498, + 5.840436727012275, + 5.943166373006534, + 6.046450663008727, + 6.148001822002698, + 6.249764615000458, + 6.357327425997937, + 6.460994630004279, + 6.563679636019515, + 6.666799781000009, + 6.7684509420068935, + 6.870703449007124, + 6.971944974997314, + 7.075067055993713, + 7.177311067993287, + 7.278057199000614, + 7.380506556015462, + 7.482502710015979, + 7.581506974995136, + 7.68455524800811, + 7.790035583020654, + 7.897399848996429, + 8.000856797007145, + 8.103829644998768, + 8.199367329012603, + 8.301632110000355, + 8.403411142993718, + 8.503376277018106, + 8.605167263012845, + 8.710420173010789, + 8.812879545992473, + 8.918984413001454, + 9.021276826009853, + 9.119897985015996, + 9.226089812000282, + 9.328107470995747, + 9.432311047014082, + 9.535242439014837, + 9.638106360012898, + 9.73997449799208, + 9.838316951005254, + 9.938337733998196, + 10.038929945003474, + 10.140792099002283, + 10.245146764005767, + 10.349674149998464, + 10.4505148580065, + 10.552688791009132, + 10.651005260006059, + 10.750357976008672, + 10.851346701005241, + 10.956377946014982, + 11.055327667010715, + 11.16165103201638, + 11.274829781003064, + 11.405633098998806, + 11.515074146009283, + 11.614194557012524, + 11.714927473018179, + 11.815339427004801, + 11.918118355009938, + 12.023308769013966, + 12.097229286009679 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.37088501162361, + "p95": 108.30299099325202, + "max": 705.9581110079307 + } + }, + { + "start": 258448.506560588, + "first": 258448.89535555, + "last": 258460.605187258, + "end": 258460.605318939, + "elapsed_s": 12.09875835099956, + "chunk_offsets_s": [ + 0.38879496199660935, + 0.9031379120133352, + 1.0050526570121292, + 1.106665191007778, + 1.2082744460203685, + 1.3110922040068544, + 1.4128689000208396, + 1.514204584993422, + 1.6175542499986477, + 1.7177075759973377, + 1.8186441550205927, + 1.923992919997545, + 2.027459834003821, + 2.1291472500015516, + 2.2320536480110604, + 2.3330621320055798, + 2.4349057399958838, + 2.535928096011048, + 2.6431154000165407, + 2.7517600239953026, + 2.85364302500966, + 2.9515754580206703, + 3.0556584400183056, + 3.1600100159994327, + 3.26312433599378, + 3.364974696014542, + 3.472968996997224, + 3.5741050179931335, + 3.677163465996273, + 3.780509371019434, + 3.8799742620030884, + 3.984782128012739, + 4.084631117002573, + 4.185660704999464, + 4.292466262995731, + 4.3990022520010825, + 4.502922193001723, + 4.605359036999289, + 4.706309297005646, + 4.810941530013224, + 4.912930276012048, + 5.015000557992607, + 5.1237811199971475, + 5.222611575998599, + 5.328280118992552, + 5.431214823009213, + 5.533256785012782, + 5.633704994019354, + 5.738205722998828, + 5.841318987018894, + 5.943890233000275, + 6.047177675005514, + 6.148886339011369, + 6.250641212012852, + 6.357500979007455, + 6.461427656002343, + 6.564414983993629, + 6.6674460410140455, + 6.769004447996849, + 6.871401405020151, + 6.972337793005863, + 7.076146790001076, + 7.178068320004968, + 7.278808435017709, + 7.381331679993309, + 7.482983593014069, + 7.582304771000054, + 7.68525632400997, + 7.790818147012033, + 7.898064492997946, + 8.001601424010005, + 8.104385712009389, + 8.200010469008703, + 8.302137312013656, + 8.404050473996904, + 8.503819734993158, + 8.605969507014379, + 8.711313345993403, + 8.813520462019369, + 8.919706865010085, + 9.0218359970022, + 9.120538468006998, + 9.226736568001797, + 9.328769331012154, + 9.433092171006138, + 9.535985979018733, + 9.638752107013715, + 9.740529477014206, + 9.838960634020623, + 9.938982490013586, + 10.039641292998567, + 10.141330982005456, + 10.245783808000851, + 10.350312426016899, + 10.450829259993043, + 10.553323930012994, + 10.651649470994016, + 10.751001835014904, + 10.851999488018919, + 10.957021356996847, + 11.055981287005125, + 11.163768564001657, + 11.275296488020103, + 11.406359918997623, + 11.515721766016213, + 11.61485832001199, + 11.715391235018615, + 11.815815348993056, + 11.918823750020238, + 12.02429770200979, + 12.098626670020167 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.30203652463388, + "p95": 108.64462397876196, + "max": 514.3429500167258 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 83.6290664624641, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 12.394172644009814, + "end_to_end_tps": 82.61947202219311, + "timing_valid": true, + "steady_tps": 87.36559883803507, + "per_stream_tps": [ + 21.9, + 21.2, + 20.9, + 21.6 + ], + "ttft_s": [ + 0.77, + 0.39, + 0.2, + 0.58 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.7743718939891551, + "decode_tps": 21.94902816781977, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 41.32381385273799, + "prefill_tps": 41.32381385273799, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.56010372550957, + "round_gap_p50_ms": 102.62172899092548, + "round_gap_p95_ms": 136.36300101643428, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.002163789002224803, + "first_payload_s": 0.002167500992072746, + "first_content_s": 0.7743718939891551, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.7743718939891551, + "last_output_s": 12.392198343994096 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.3895856009912677, + "decode_tps": 21.24377977170385, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 82.13855932708678, + "prefill_tps": 82.13855932708678, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 47.07260246276764, + "round_gap_p50_ms": 102.68025600817055, + "round_gap_p95_ms": 136.72279502497986, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0015350809844676405, + "first_payload_s": 0.0015555449936073273, + "first_content_s": 0.3895856009912677, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3895856009912677, + "last_output_s": 12.393099228997016 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.1960344559920486, + "decode_tps": 20.908182686878604, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 163.23660979934036, + "prefill_tps": 163.23660979934036, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 47.828164454846295, + "round_gap_p50_ms": 102.69864098518156, + "round_gap_p95_ms": 137.14484599768184, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.0013426799851004034, + "first_payload_s": 0.0013466799864545465, + "first_content_s": 0.1960344559920486, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1960344559920486, + "last_output_s": 12.392216391977854 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.5828578330110759, + "decode_tps": 21.591626946297207, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.90189577565807, + "prefill_tps": 54.90189577565807, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 46.31424961570541, + "round_gap_p50_ms": 102.70097802276723, + "round_gap_p95_ms": 136.67573902057484, + "tokens_per_chunk": 2.3063063063063063, + "headers_s": 0.002869857009500265, + "first_payload_s": 0.0028885290084872395, + "first_content_s": 0.5828578330110759, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5828578330110759, + "last_output_s": 12.392991485015955 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 46.69378006470723, + "round_gap_p50_ms": 102.69864098518156, + "round_gap_p95_ms": 136.72279502497986, + "round_gap_mean_ms": 108.24467196818495, + "tokens_per_chunk": 2.3063063063063063, + "aggregate_prompt_ttft_tps": 165.11110443110232, + "aggregate_prefill_tps": 165.11110443110232 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258460.609255202, + "first": 258461.383627096, + "last": 258473.001453546, + "end": 258473.001901245, + "elapsed_s": 12.392646043008426, + "chunk_offsets_s": [ + 0.7743718939891551, + 0.8795689010003116, + 0.9814102080126759, + 1.0875951719935983, + 1.1889603479939979, + 1.2919644780049566, + 1.3934600219945423, + 1.4949678709963337, + 1.5972447970125359, + 1.6971882359939627, + 1.7985110600129701, + 1.9031201600155327, + 2.003791827999521, + 2.1090920669957995, + 2.2114786570018623, + 2.3130308749969117, + 2.413306188012939, + 2.5146501479903236, + 2.6219411519996356, + 2.7295224289991893, + 2.832362606015522, + 2.929510173999006, + 3.03405749698868, + 3.139456633012742, + 3.241984391992446, + 3.3442489659937564, + 3.451668625988532, + 3.552669513010187, + 3.6558429719880223, + 3.7584366360097192, + 3.858655390009517, + 3.9607925710151903, + 4.062173843005439, + 4.1642344479914755, + 4.271368859015638, + 4.378842967009405, + 4.483173810003791, + 4.586603383009788, + 4.686687528010225, + 4.791343171993503, + 4.892949214001419, + 4.995686383015709, + 5.10188406900852, + 5.203991410002345, + 5.3103131120151374, + 5.41290548001416, + 5.514934084989363, + 5.615982907998841, + 5.719092320010532, + 5.82310336799128, + 5.924773619015468, + 6.027980454993667, + 6.130378278001444, + 6.2309816910128575, + 6.341793258994585, + 6.444818605988985, + 6.548056914994959, + 6.650975316995755, + 6.752246782009024, + 6.855610386992339, + 6.955801108997548, + 7.055923462990904, + 7.160685507988092, + 7.262027101009153, + 7.369692059990484, + 7.497480818012264, + 7.621211871999549, + 7.750792592996731, + 7.887678605009569, + 8.026917943003355, + 8.164044901001034, + 8.300156699988293, + 8.428740183007903, + 8.567129628994735, + 8.70414845799678, + 8.840511459013214, + 8.946759993996238, + 9.051505960000213, + 9.154127688991139, + 9.259401082003023, + 9.362870799988741, + 9.461227416002657, + 9.566794362006476, + 9.668225028988672, + 9.771442889003083, + 9.875270290009212, + 9.977696082001785, + 10.079831489012577, + 10.18025331699755, + 10.279345504997764, + 10.38058191401069, + 10.48043327499181, + 10.584196243988117, + 10.688434111012612, + 10.788434752990725, + 10.89101894601481, + 10.988903943012701, + 11.088077508000424, + 11.18960542298737, + 11.297592577000614, + 11.395906232995912, + 11.495772297988879, + 11.594685462012421, + 11.69779119399027, + 11.805947148997802, + 11.905331899004523, + 12.005354174005333, + 12.110444557998562, + 12.212363788014045, + 12.318523538997397, + 12.392198343994096 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.67944900260773, + "p95": 136.36300101643428, + "max": 139.23933799378574 + } + }, + { + "start": 258460.608676959, + "first": 258460.99826256, + "last": 258473.001776188, + "end": 258473.002222895, + "elapsed_s": 12.393545936007285, + "chunk_offsets_s": [ + 0.3895856009912677, + 0.8800687269831542, + 0.9820932029979303, + 1.0880204059940297, + 1.1896421920100693, + 1.2923668480070774, + 1.393965016992297, + 1.4954611060093157, + 1.5981422899931204, + 1.6975447979930323, + 1.7987933660042472, + 1.9036056339973584, + 2.00423554200097, + 2.109479573002318, + 2.2117085460049566, + 2.313670973991975, + 2.4139751519833226, + 2.5151454950100742, + 2.6224551709892694, + 2.730025039985776, + 2.832839648996014, + 2.9300236479903106, + 3.034571274998598, + 3.139816538983723, + 3.2424967949918937, + 3.344890904991189, + 3.4521593329845928, + 3.5531597869994584, + 3.6564839989878237, + 3.758952653995948, + 3.8591603839886375, + 3.9613055329828057, + 4.0626353659899905, + 4.165080292994389, + 4.2717960930021945, + 4.379356105986517, + 4.483816820982611, + 4.587050873000408, + 4.687140633992385, + 4.791775782010518, + 4.893460432998836, + 4.996104080986697, + 5.102391463005915, + 5.204481588007184, + 5.310795113997301, + 5.413399994984502, + 5.515687896986492, + 5.616475710994564, + 5.7196084820025135, + 5.823615931003587, + 5.9254123579885345, + 6.028496585990069, + 6.130867352010682, + 6.231458013004158, + 6.342529871006263, + 6.445455217995914, + 6.548576517001493, + 6.651740041008452, + 6.752767199999653, + 6.85640384699218, + 6.956298759992933, + 7.056570393993752, + 7.161553065001499, + 7.2625409759930335, + 7.370203183003468, + 7.49779814700014, + 7.621982868004125, + 7.751307651982643, + 7.888030447007623, + 8.027340920991264, + 8.164563239988638, + 8.300847456004703, + 8.428984375990694, + 8.567650302982656, + 8.704780461004702, + 8.841009909985587, + 8.947188299993286, + 9.052027338009793, + 9.154628891003085, + 9.259921563992975, + 9.363389186008135, + 9.461923402996035, + 9.567432237992762, + 9.669019208988175, + 9.772172989003593, + 9.875906052999198, + 9.97812661199714, + 10.08035153898527, + 10.180927399982465, + 10.279848867998226, + 10.381092620984418, + 10.480909342004452, + 10.584709893999388, + 10.689122529991437, + 10.789078275993234, + 10.89173317400855, + 10.989396329998272, + 11.08859661500901, + 11.190126050001709, + 11.298083490983117, + 11.396739149000496, + 11.49624226798187, + 11.595031254983041, + 11.69807325999136, + 11.806466271984391, + 11.905845358007355, + 12.006029473006492, + 12.111081649985863, + 12.213008015009109, + 12.319020708993776, + 12.393099228997016 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.6807199959876, + "p95": 136.72279502497986, + "max": 490.4831259918865 + } + }, + { + "start": 258460.609025409, + "first": 258460.805059865, + "last": 258473.001241801, + "end": 258473.001486858, + "elapsed_s": 12.392461448995164, + "chunk_offsets_s": [ + 0.1960344559920486, + 0.8796221649972722, + 0.9818278739985544, + 1.0877357489953283, + 1.1890699799987487, + 1.291932652995456, + 1.3933019889809657, + 1.494767933996627, + 1.5975949419953395, + 1.697645278996788, + 1.7982612350024283, + 1.9029398699931335, + 2.0039361160015687, + 2.1093725319951773, + 2.2112412639835384, + 2.3128902329772245, + 2.4137342699978035, + 2.514940277993446, + 2.62186364698573, + 2.729811469995184, + 2.832387693983037, + 2.9297944470017683, + 3.0340075439889915, + 3.139323367999168, + 3.241971591982292, + 3.3443991899839602, + 3.451982019993011, + 3.5529891139885876, + 3.6559433240036014, + 3.7583616909978446, + 3.858964622981148, + 3.960765497991815, + 4.062192690995289, + 4.164600625983439, + 4.271672475995729, + 4.37875203898875, + 4.483166560996324, + 4.586762598977657, + 4.686848616984207, + 4.791310771979624, + 4.892931006004801, + 4.995629646989983, + 5.1019867089926265, + 5.203942608990474, + 5.310297032003291, + 5.412988967989804, + 5.515272390999598, + 5.616272669984028, + 5.719040222989861, + 5.823071271996014, + 5.924937587988097, + 6.0279303419811185, + 6.130332917004125, + 6.231279771978734, + 6.342276126000797, + 6.444802013982553, + 6.548052433994599, + 6.651504727982683, + 6.752237052976852, + 6.856132054002956, + 6.956112886982737, + 7.056287816987606, + 7.161135526985163, + 7.262320446985541, + 7.369696284004021, + 7.497307073004777, + 7.621555825986434, + 7.7507705119787715, + 7.888023086998146, + 8.026850197988097, + 8.163995075999992, + 8.30072142300196, + 8.428909975977149, + 8.567068028001813, + 8.704212873999495, + 8.840599460003432, + 8.946706841001287, + 9.051467814977514, + 9.154226056998596, + 9.25933687298675, + 9.3628352789965, + 9.461351511999965, + 9.566776233987184, + 9.668324516998837, + 9.771756795002148, + 9.875303345994325, + 9.977716130000772, + 10.079796175996307, + 10.18038669298403, + 10.279643410991412, + 10.380536649987334, + 10.480502555001294, + 10.584185954998247, + 10.688727583998116, + 10.78850907299784, + 10.891498067998327, + 10.989217880996875, + 11.088021028001094, + 11.18957059099921, + 11.297886913991533, + 11.396242889983114, + 11.495656968996627, + 11.594767478003632, + 11.69785023399163, + 11.805886683985591, + 11.905440763977822, + 12.00573942399933, + 12.11046279798029, + 12.212448059988674, + 12.318814323982224, + 12.392216391977854 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.72844150313176, + "p95": 137.14484599768184, + "max": 683.5877090052236 + } + }, + { + "start": 258460.608391533, + "first": 258461.191249366, + "last": 258473.001383018, + "end": 258473.002564177, + "elapsed_s": 12.394172644009814, + "chunk_offsets_s": [ + 0.5828578330110759, + 0.8801961530116387, + 0.9826926630048547, + 1.0882325519924052, + 1.1900496979942545, + 1.2927383060159627, + 1.3940867939963937, + 1.4955610269971658, + 1.598325235012453, + 1.6982268030114938, + 1.7992491610057186, + 1.9037024349963758, + 2.0043412070081104, + 2.115580553014297, + 2.212165189004736, + 2.3137024780153297, + 2.4144990110071376, + 2.515347480017226, + 2.622640212008264, + 2.730180896993261, + 2.833334691997152, + 2.9301915529940743, + 3.0347500930074602, + 3.1402524140139576, + 3.2427132120064925, + 3.344931433995953, + 3.4523704860184807, + 3.5533746049914043, + 3.6569504819926806, + 3.7591380800004117, + 3.8593372970062774, + 3.961519086995395, + 4.0631555290019605, + 4.165299990010681, + 4.272009358013747, + 4.379539643006865, + 4.483965813997202, + 4.587209818011615, + 4.687324140017154, + 4.792138824996073, + 4.89368651501718, + 4.996487316006096, + 5.102509784017457, + 5.204702229995746, + 5.311246716999449, + 5.4135160600126255, + 5.516036203014664, + 5.616686783992918, + 5.7197985160164535, + 5.82382777199382, + 5.92548413501936, + 6.0287037230154965, + 6.13109290599823, + 6.231980448006652, + 6.342736241000239, + 6.4455764509912115, + 6.548794742993778, + 6.651741594017949, + 6.75298603400006, + 6.856576873018639, + 6.956483881018357, + 7.0566628749947995, + 7.161662650003564, + 7.262699712999165, + 7.370434592012316, + 7.4982823909958825, + 7.622357751009986, + 7.751531204994535, + 7.88820694401511, + 8.027691340015735, + 8.164747369010001, + 8.300913073006086, + 8.429450780007755, + 8.567836336995242, + 8.704943535005441, + 8.84111701499205, + 8.947551791003207, + 9.052215452014934, + 9.154751084017335, + 9.260110686009284, + 9.363596531999065, + 9.46216214101878, + 9.567550734995166, + 9.669260171009228, + 9.77220219001174, + 9.876058310997905, + 9.978486934996909, + 10.080523061013082, + 10.180896167992614, + 10.280042421014514, + 10.381302605994279, + 10.48101731101633, + 10.584943800000474, + 10.68919397101854, + 10.78986082499614, + 10.892561803018907, + 10.989577499014558, + 11.088782216014806, + 11.190324387018336, + 11.298253253014991, + 11.396935471013421, + 11.496183979994385, + 11.59521341699292, + 11.698251613008324, + 11.806665201002033, + 11.905964191013481, + 12.006127090018708, + 12.111231971008237, + 12.213474626012612, + 12.319215974013787, + 12.392991485015955 + ], + "chunk_gaps_ms": { + "count": 110, + "p50": 102.73259301902726, + "p95": 136.67573902057484, + "max": 297.3383200005628 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "98f95af2c394a9340781bb382dae9e5715b3a9c724c8d4ede48d5c84d7df3423", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + } + ] + }, + { + "prompt": "code", + "temperature": 1.0, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 1, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 44.9, + "per_stream_tps": 44.9, + "ttft_s_max": 0.13, + "request": { + "ttft_s": 0.131, + "decode_tps": 44.915, + "prompt_ttft_tps": 107.002, + "prefill_tps": 107.002, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 22.264, + "round_gap_p50_ms": 72.205, + "round_gap_p95_ms": 94.161, + "tokens_per_chunk": 3.325, + "headers_s": 0.001, + "first_payload_s": 0.131, + "first_content_s": 0.131, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.131, + "last_output_s": 5.809 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 107.002, + "aggregate_prefill_tps": 107.002, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 22.264, + "round_gap_p50_ms": 72.205, + "round_gap_p95_ms": 94.161, + "tokens_per_chunk": 3.325 + }, + "completions": { + "truncated": 3 + }, + "timing_valid": true, + "end_to_end_tps": 44.06755670382355, + "makespan_s": 5.809262395021506, + "alone": { + "equal": 3, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 4, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 46.36731347711258, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 5.628724405018147, + "end_to_end_tps": 45.48099739467963, + "timing_valid": true, + "per_stream_tps": [ + 46.4 + ], + "ttft_s": [ + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.12880575901363045, + "decode_tps": 46.36731347711258, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 108.69079230004378, + "prefill_tps": 108.69079230004378, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 21.566916972526588, + "round_gap_p50_ms": 72.20530300401151, + "round_gap_p95_ms": 88.80122800474055, + "tokens_per_chunk": 3.3684210526315788, + "headers_s": 0.0010330950026400387, + "first_payload_s": 0.12880575901363045, + "first_content_s": 0.12880575901363045, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.12880575901363045, + "last_output_s": 5.62836958700791 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 21.566916972526588, + "round_gap_p50_ms": 72.20530300401151, + "round_gap_p95_ms": 88.80122800474055, + "round_gap_mean_ms": 73.3275177065904, + "tokens_per_chunk": 3.3684210526315788, + "aggregate_prompt_ttft_tps": 108.69079230004378, + "aggregate_prefill_tps": 108.69079230004378 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258541.19984691, + "first": 258541.328652669, + "last": 258546.828216497, + "end": 258546.828571315, + "elapsed_s": 5.628724405018147, + "chunk_offsets_s": [ + 0.12880575901363045, + 0.18875425099395216, + 0.24747454401222058, + 0.30747914902167395, + 0.36756394599797204, + 0.4283502350153867, + 0.4866549580183346, + 0.5461301030009054, + 0.6161989289976191, + 0.6757714510022197, + 0.7386304250103422, + 0.7997580440132879, + 0.860269500000868, + 0.9197494450199883, + 0.9808042810182087, + 1.045524226006819, + 1.1113705940078944, + 1.1730936730164103, + 1.235343220003415, + 1.2977076950191986, + 1.361348481994355, + 1.4288895479985513, + 1.5012785959988832, + 1.5772680820082314, + 1.6547043129976373, + 1.7233274340105709, + 1.786339048994705, + 1.8558891040156595, + 1.9296025760122575, + 2.000248861993896, + 2.0741200630145613, + 2.14632511002128, + 2.2272595539980102, + 2.304734889010433, + 2.397651406005025, + 2.482152208016487, + 2.562797146005323, + 2.6515983740100637, + 2.736561850993894, + 2.822421941003995, + 2.9110771040141117, + 2.977363106998382, + 3.051417220995063, + 3.123168585996609, + 3.1953738890006207, + 3.270987469004467, + 3.341318071994465, + 3.4229041690123267, + 3.5047323940088972, + 3.575829706998775, + 3.656790759006981, + 3.737552130012773, + 3.822592712007463, + 3.9082957450009417, + 3.992267312016338, + 4.080350920005003, + 4.1643280390126165, + 4.2391225900209974, + 4.323212540999521, + 4.397493073018268, + 4.467356025998015, + 4.528746624011546, + 4.597837395995157, + 4.665104589017574, + 4.7421890900004655, + 4.812224363995483, + 4.9072034220153, + 4.982133798010182, + 5.069004774995847, + 5.147596597002121, + 5.233595729019726, + 5.318211475998396, + 5.414214428019477, + 5.496124541998142, + 5.56565454902011, + 5.62836958700791 + ], + "chunk_gaps_ms": { + "count": 75, + "p50": 72.20530300401151, + "p95": 88.80122800474055, + "max": 96.002952021081 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 44.91470856679708, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 5.809262395021506, + "end_to_end_tps": 44.06755670382355, + "timing_valid": true, + "per_stream_tps": [ + 44.9 + ], + "ttft_s": [ + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.13128207900444977, + "decode_tps": 44.91470856679708, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 106.64060248105511, + "prefill_tps": 106.64060248105511, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 22.264421431407076, + "round_gap_p50_ms": 70.66942300298251, + "round_gap_p95_ms": 94.16086197597906, + "tokens_per_chunk": 3.324675324675325, + "headers_s": 0.0008898939995560795, + "first_payload_s": 0.13128207900444977, + "first_content_s": 0.13128207900444977, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13128207900444977, + "last_output_s": 5.808709544013254 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 22.264421431407076, + "round_gap_p50_ms": 70.66942300298251, + "round_gap_p95_ms": 94.16086197597906, + "round_gap_mean_ms": 74.70299296064216, + "tokens_per_chunk": 3.324675324675325, + "aggregate_prompt_ttft_tps": 106.64060248105511, + "aggregate_prefill_tps": 106.64060248105511 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258546.829241287, + "first": 258546.960523366, + "last": 258552.637950831, + "end": 258552.638503682, + "elapsed_s": 5.809262395021506, + "chunk_offsets_s": [ + 0.13128207900444977, + 0.2001282419951167, + 0.2671819140086882, + 0.3378513370116707, + 0.4078160980134271, + 0.48001292199478485, + 0.5458998350077309, + 0.6205929139978252, + 0.6950356070010457, + 0.7564987009973265, + 0.8155333320028149, + 0.876799657009542, + 0.9365530610084534, + 0.997401880013058, + 1.0593221450108103, + 1.1225678570044693, + 1.1930229580029845, + 1.25763242400717, + 1.3221692969964352, + 1.393202369014034, + 1.4509020010009408, + 1.5132532120042015, + 1.574695490009617, + 1.6386849679984152, + 1.7069662639987655, + 1.7668281640217174, + 1.8276104550168384, + 1.8881586630013771, + 1.9528057290008292, + 2.0139869330159854, + 2.0761120959941763, + 2.141019019007217, + 2.210899380996125, + 2.2851654489932116, + 2.361869915999705, + 2.4372698310180567, + 2.5183611570100766, + 2.611085993994493, + 2.698361885995837, + 2.7863739099993836, + 2.8862606619950384, + 2.977607762994012, + 3.063454493007157, + 3.1512305320065934, + 3.2389421700208914, + 3.3259419160021935, + 3.4193947900203057, + 3.5061418139957823, + 3.6051987380196806, + 3.692494278016966, + 3.7812543390027713, + 3.8693633869988844, + 3.960344918014016, + 4.045273802999873, + 4.129591597011313, + 4.217565188999288, + 4.3080795489950106, + 4.396889210009249, + 4.486147962015821, + 4.571008415019605, + 4.6343460970092565, + 4.693353417009348, + 4.7546778230171185, + 4.8197831790021155, + 4.889667125011329, + 4.959219213022152, + 5.053380074998131, + 5.129059591999976, + 5.211479935009265, + 5.281152662995737, + 5.381733437010553, + 5.470057111000642, + 5.556525510008214, + 5.632487652997952, + 5.700790998002049, + 5.758547270001145, + 5.808709544013254 + ], + "chunk_gaps_ms": { + "count": 76, + "p50": 70.8512475102907, + "p95": 94.16086197597906, + "max": 100.58077401481569 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 44.633162268468375, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 5.844264076993568, + "end_to_end_tps": 43.80363320811688, + "timing_valid": true, + "per_stream_tps": [ + 44.6 + ], + "ttft_s": [ + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.13083827000809833, + "decode_tps": 44.633162268468375, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 107.00233195634166, + "prefill_tps": 107.00233195634166, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 22.404865556802857, + "round_gap_p50_ms": 74.06574799097143, + "round_gap_p95_ms": 98.0212549911812, + "tokens_per_chunk": 3.324675324675325, + "headers_s": 0.001923787989653647, + "first_payload_s": 0.13083827000809833, + "first_content_s": 0.13083827000809833, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13083827000809833, + "last_output_s": 5.844078986992827 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 22.404865556802857, + "round_gap_p50_ms": 74.06574799097143, + "round_gap_p95_ms": 98.0212549911812, + "round_gap_mean_ms": 75.17421996032537, + "tokens_per_chunk": 3.324675324675325, + "aggregate_prompt_ttft_tps": 107.00233195634166, + "aggregate_prefill_tps": 107.00233195634166 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258552.639320999, + "first": 258552.770159269, + "last": 258558.483399986, + "end": 258558.483585076, + "elapsed_s": 5.844264076993568, + "chunk_offsets_s": [ + 0.13083827000809833, + 0.19727027500630356, + 0.25613506499212235, + 0.31684180299635045, + 0.376455399004044, + 0.4366902299807407, + 0.49562964600045234, + 0.5548213349829894, + 0.6267536130035296, + 0.6866727150045335, + 0.7483550109900534, + 0.8080353589903098, + 0.8685347040009219, + 0.9275758639851119, + 0.988869822002016, + 1.0527705310087185, + 1.119158232002519, + 1.1827846359810792, + 1.256206955993548, + 1.3279742260056082, + 1.399296179995872, + 1.4577140889887232, + 1.5223655230074655, + 1.5894017239916138, + 1.6691752990009263, + 1.7372439059836324, + 1.799808719981229, + 1.871315363998292, + 1.9407687789935153, + 2.0153288019937463, + 2.085899312980473, + 2.161493502004305, + 2.2405000959988683, + 2.3145658439898398, + 2.3905485949944705, + 2.4680051479954273, + 2.553423956996994, + 2.638194441999076, + 2.7201646699977573, + 2.806307531980565, + 2.8983283169800416, + 2.987842656002613, + 3.072143169993069, + 3.153551299008541, + 3.2411710009910166, + 3.3288037599995732, + 3.4183665789896622, + 3.5051368520071264, + 3.6031581069983076, + 3.6917085989844054, + 3.78091250298894, + 3.8688671039999463, + 3.959989131981274, + 4.044306286989013, + 4.128320975985844, + 4.216563210007735, + 4.304746356996475, + 4.391461413993966, + 4.480565173987998, + 4.564379157993244, + 4.629419075004989, + 4.688191866007401, + 4.749289598985342, + 4.814968639984727, + 4.884691993007436, + 4.953953279997222, + 5.04787462198874, + 5.122780646983301, + 5.208302096987609, + 5.288111751986435, + 5.387993865995668, + 5.48787196399644, + 5.595907248003641, + 5.674736001004931, + 5.734529470006237, + 5.793128291988978, + 5.844078986992827 + ], + "chunk_gaps_ms": { + "count": 76, + "p50": 74.31288549560122, + "p95": 98.0212549911812, + "max": 108.03528400720097 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + } + ] + }, + { + "prompt": "code", + "temperature": 1.0, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 2, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 58.0, + "per_stream_tps": 29.4, + "ttft_s_max": 0.26, + "request": { + "ttft_s": 0.192, + "decode_tps": 29.458, + "prompt_ttft_tps": 81.168, + "prefill_tps": 81.168, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.947, + "round_gap_p50_ms": 107.824, + "round_gap_p95_ms": 114.987, + "tokens_per_chunk": 3.165, + "headers_s": 0.001, + "first_payload_s": 0.192, + "first_content_s": 0.192, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.192, + "last_output_s": 8.911 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 109.805, + "aggregate_prefill_tps": 109.805, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.526, + "round_gap_p50_ms": 107.964, + "round_gap_p95_ms": 114.979, + "tokens_per_chunk": 3.16 + }, + "completions": { + "truncated": 6 + }, + "timing_valid": true, + "end_to_end_tps": 57.38007218886278, + "makespan_s": 8.922958450013539, + "steady_tps": 60.2, + "alone": { + "equal": 6, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 4, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 57.9945415548918, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 8.922958450013539, + "end_to_end_tps": 57.38007218886278, + "timing_valid": true, + "steady_tps": 60.24197306723191, + "per_stream_tps": [ + 30.7, + 29.0 + ], + "ttft_s": [ + 0.25, + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.254889956995612, + "decode_tps": 30.706279764856472, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.92566347069145, + "prefill_tps": 54.92566347069145, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 32.566628313746634, + "round_gap_p50_ms": 108.17293298896402, + "round_gap_p95_ms": 114.9955989967566, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0010842469928320497, + "first_payload_s": 0.254889956995612, + "first_content_s": 0.254889956995612, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.254889956995612, + "last_output_s": 8.559380177001003 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.1289539230056107, + "decode_tps": 28.9972707774459, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 108.56591000640492, + "prefill_tps": 108.56591000640492, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.486004137251456, + "round_gap_p50_ms": 107.82805099734105, + "round_gap_p95_ms": 114.97868699370883, + "tokens_per_chunk": 3.0476190476190474, + "headers_s": 0.0009553980198688805, + "first_payload_s": 0.1289539230056107, + "first_content_s": 0.1289539230056107, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1289539230056107, + "last_output_s": 8.922884978004731 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.526316225499045, + "round_gap_p50_ms": 107.96368401497602, + "round_gap_p95_ms": 114.97868699370883, + "round_gap_mean_ms": 106.8651329687782, + "tokens_per_chunk": 3.1604938271604937, + "aggregate_prompt_ttft_tps": 109.8046152666782, + "aggregate_prefill_tps": 109.8046152666782 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258558.484690378, + "first": 258558.739580335, + "last": 258567.044070555, + "end": 258567.044225788, + "elapsed_s": 8.55953540999326, + "chunk_offsets_s": [ + 0.254889956995612, + 0.3424462039838545, + 0.44093538098968565, + 0.54089519198169, + 0.6438486209954135, + 0.7457222989760339, + 0.848653551976895, + 0.9600588719767984, + 1.0652585709758569, + 1.1742078279785346, + 1.2808137440006249, + 1.3875306839763653, + 1.4904162559832912, + 1.5994028899876866, + 1.7029152179893572, + 1.8120081409870181, + 1.922047437983565, + 2.033899352973094, + 2.144138490984915, + 2.2505091409839224, + 2.354478991997894, + 2.4633847609802615, + 2.5700493489857763, + 2.6800943259731866, + 2.7858660599740688, + 2.8858456639864016, + 2.9943431749998126, + 3.0972835479769856, + 3.2017191619961523, + 3.3069142529857345, + 3.415911527001299, + 3.5275233139982447, + 3.637582322990056, + 3.7525070089905057, + 3.8675026079872623, + 3.9783695899823215, + 4.08737824097625, + 4.197468497994123, + 4.308860938996077, + 4.420555221993709, + 4.526942895987304, + 4.639468927984126, + 4.754731376975542, + 4.870537525974214, + 4.987921523978002, + 5.102385215985123, + 5.210348900000099, + 5.318521832989063, + 5.4249698919884395, + 5.529133920994354, + 5.63669189097709, + 5.747934875980718, + 5.859370725986082, + 5.972966556990286, + 6.083031133981422, + 6.186445478990208, + 6.294820301991422, + 6.403861225000583, + 6.509755695995409, + 6.613722140988102, + 6.7229077849769965, + 6.829878182994435, + 6.934700024983613, + 7.046085633977782, + 7.157241018983768, + 7.264812060981058, + 7.366752428992186, + 7.480942647991469, + 7.588359640998533, + 7.7028746779833455, + 7.813978909980506, + 7.924931828980334, + 8.03156395399128, + 8.138033149996772, + 8.244950123975286, + 8.35253263899358, + 8.456149416975677, + 8.559380177001003 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 108.17293298896402, + "p95": 114.9955989967566, + "max": 117.38399800378829 + } + }, + { + "start": 258558.484581946, + "first": 258558.613535869, + "last": 258567.407466924, + "end": 258567.407540396, + "elapsed_s": 8.922958450013539, + "chunk_offsets_s": [ + 0.1289539230056107, + 0.3424729710095562, + 0.440896068001166, + 0.5411883770138957, + 0.6438267960038502, + 0.7457309380115476, + 0.8486209750117268, + 0.9604116740229074, + 1.0652395780198276, + 1.1741283550218213, + 1.280724894022569, + 1.3875141710159369, + 1.490374575019814, + 1.5993347449984867, + 1.703221060015494, + 1.8120019800262526, + 1.9220149730099365, + 2.033925736002857, + 2.1441312580136582, + 2.250494484003866, + 2.3544747830019332, + 2.4636754030070733, + 2.570044821011834, + 2.680097573000239, + 2.785886924015358, + 2.88575355001376, + 2.9943429499980994, + 3.0971786190057173, + 3.2017270180222113, + 3.3068129880120978, + 3.416197689017281, + 3.527482017001603, + 3.6375878899998497, + 3.752485360018909, + 3.867464047012618, + 3.9783466290100478, + 4.087387904000934, + 4.197395553026581, + 4.3088408740004525, + 4.420833271025913, + 4.527119457023218, + 4.639459408004768, + 4.7547500650107395, + 4.870500485005323, + 4.987837442022283, + 5.1022753580182325, + 5.210335843003122, + 5.318502328998875, + 5.4252680060162675, + 5.528776575025404, + 5.636604626022745, + 5.748321470018709, + 5.859346933022607, + 5.973318910022499, + 6.0832742390048224, + 6.186453494010493, + 6.2948200610117055, + 6.404204826016212, + 6.50968303901027, + 6.613719708024291, + 6.723232666001422, + 6.829796646023169, + 6.935016090021236, + 7.0459661450004205, + 7.157581436011242, + 7.264819692005403, + 7.367001822014572, + 7.480925591022242, + 7.588350903999526, + 7.703079110011458, + 7.8139005890116096, + 7.92515989401727, + 8.031248879007762, + 8.138373503024923, + 8.245161773025757, + 8.352545198024018, + 8.455831558007048, + 8.559383920015534, + 8.63129349600058, + 8.694054585008416, + 8.758547299017664, + 8.817134250013623, + 8.871234421007102, + 8.922884978004731 + ], + "chunk_gaps_ms": { + "count": 83, + "p50": 107.82805099734105, + "p95": 114.97868699370883, + "max": 213.5190480039455 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 55.71327266312467, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 9.283369537006365, + "end_to_end_tps": 55.15238814516761, + "timing_valid": true, + "steady_tps": 57.72245223213973, + "per_stream_tps": [ + 29.4, + 27.9 + ], + "ttft_s": [ + 0.25, + 0.13 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.25277820401242934, + "decode_tps": 29.422040426457258, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 55.38452199506729, + "prefill_tps": 55.38452199506729, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.98812541569236, + "round_gap_p50_ms": 109.09423601697199, + "round_gap_p95_ms": 140.77150300727226, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0008462929981760681, + "first_payload_s": 0.25277820401242934, + "first_content_s": 0.25277820401242934, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.25277820401242934, + "last_output_s": 8.919750185013982 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.12924835900776088, + "decode_tps": 27.856636331562335, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 108.31858994170558, + "prefill_tps": 108.31858994170558, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 35.898088631288644, + "round_gap_p50_ms": 107.82029398251325, + "round_gap_p95_ms": 141.03416100260802, + "tokens_per_chunk": 3.0476190476190474, + "headers_s": 0.0011175579857081175, + "first_payload_s": 0.12924835900776088, + "first_content_s": 0.12924835900776088, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.12924835900776088, + "last_output_s": 9.283260959986364 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 34.943107023490505, + "round_gap_p50_ms": 108.18703199038282, + "round_gap_p95_ms": 140.77150300727226, + "round_gap_mean_ms": 111.38115363737597, + "tokens_per_chunk": 3.1604938271604937, + "aggregate_prompt_ttft_tps": 110.5941842359749, + "aggregate_prefill_tps": 110.5941842359749 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258567.408984421, + "first": 258567.661762625, + "last": 258576.328734606, + "end": 258576.328865039, + "elapsed_s": 8.919880617992021, + "chunk_offsets_s": [ + 0.25277820401242934, + 0.34260957001242787, + 0.44033959199441597, + 0.5407528149953578, + 0.6433989469951484, + 0.744257981015835, + 0.8472558600187767, + 0.9547215100028552, + 1.0610349450143985, + 1.1712540360167623, + 1.2776649440056644, + 1.3846399509930052, + 1.4879773360153195, + 1.5992434740182944, + 1.7033664789923932, + 1.8109258580079768, + 1.9216791450162418, + 2.063636670995038, + 2.1991116290155333, + 2.33260060599423, + 2.4646949839952867, + 2.6043276629934553, + 2.743130401999224, + 2.8874248219945002, + 3.0278744189999998, + 3.162102105008671, + 3.3065275980043225, + 3.444724925007904, + 3.585496428015176, + 3.6957559040165506, + 3.806736072001513, + 3.91807665899978, + 4.027170895016752, + 4.140837223996641, + 4.256861039000796, + 4.364296498009935, + 4.473689887992805, + 4.583564258005936, + 4.694581849995302, + 4.806159399013268, + 4.911823374015512, + 5.022686262003845, + 5.141602510993835, + 5.2558778040111065, + 5.371710609993897, + 5.481406099017477, + 5.590687121002702, + 5.696900059992913, + 5.8028480380016845, + 5.907390806998592, + 6.014671993005322, + 6.125436992995674, + 6.238078371010488, + 6.351543307013344, + 6.462760852999054, + 6.567279670009157, + 6.672231417993316, + 6.778779400017811, + 6.884142110007815, + 6.986456690006889, + 7.094643721997272, + 7.200306401995476, + 7.305650727998, + 7.413809520017821, + 7.523095390002709, + 7.630222976004006, + 7.736598524003057, + 7.850071813008981, + 7.954975528002251, + 8.06826428801287, + 8.180886115005706, + 8.288904474000446, + 8.395054213004187, + 8.500389435008401, + 8.607564492995152, + 8.714901008002926, + 8.81810516101541, + 8.919750185013982 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 109.09423601697199, + "p95": 140.77150300727226, + "max": 144.42549299565144 + } + }, + { + "start": 258567.408584755, + "first": 258567.537833114, + "last": 258576.691845715, + "end": 258576.691954292, + "elapsed_s": 9.283369537006365, + "chunk_offsets_s": [ + 0.12924835900776088, + 0.3425203049846459, + 0.4405358970107045, + 0.5413773939944804, + 0.6438777020084672, + 0.7447282719949726, + 0.8477143739874009, + 0.954952678992413, + 1.0616261000104714, + 1.171836263005389, + 1.2778605450002942, + 1.3848630400025286, + 1.4885706189961638, + 1.599484611011576, + 1.7039132659847382, + 1.810958401998505, + 1.9215885679877829, + 2.064266145986039, + 2.199080860009417, + 2.3325528939894866, + 2.46462698301184, + 2.604860817984445, + 2.743748837005114, + 2.887388501985697, + 3.027952019008808, + 3.1623418660019524, + 3.307137873984175, + 3.444797453004867, + 3.585831614007475, + 3.695983409008477, + 3.806665782991331, + 3.918287426989991, + 4.0274980810063425, + 4.141401739005232, + 4.257455841987394, + 4.364530146995094, + 4.47391515300842, + 4.583884610998211, + 4.694913819985231, + 4.806347990990616, + 4.9124137299950235, + 5.023307641997235, + 5.14181319999625, + 5.256128445005743, + 5.372316981985932, + 5.48162614798639, + 5.59090109000681, + 5.697526495991042, + 5.8030553509888705, + 5.907587703986792, + 6.014900954003679, + 6.125994355999865, + 6.2382918919902295, + 6.3517207319964655, + 6.463233816000866, + 6.567497031006496, + 6.672747100994457, + 6.7793764589878265, + 6.884779505984625, + 6.987091716990108, + 7.094882842997322, + 7.200898724986473, + 7.306239675002871, + 7.414059968985384, + 7.523315806989558, + 7.630411599995568, + 7.736751772987191, + 7.850267428992083, + 7.955211800988764, + 8.068438479996985, + 8.181214948010165, + 8.289511020993814, + 8.395334950007964, + 8.500974686990958, + 8.607896191009786, + 8.71522830601316, + 8.818638939992525, + 8.92007637899951, + 8.992282277991762, + 9.055323097010842, + 9.118822558986722, + 9.17787044099532, + 9.232156423007837, + 9.283260959986364 + ], + "chunk_gaps_ms": { + "count": 83, + "p50": 107.82029398251325, + "p95": 141.03416100260802, + "max": 213.27194597688504 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 58.147110049578515, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 8.902338554995367, + "end_to_end_tps": 57.51297783577345, + "timing_valid": true, + "steady_tps": 60.504372364117, + "per_stream_tps": [ + 30.3, + 29.5 + ], + "ttft_s": [ + 0.13, + 0.26 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.13090160398860462, + "decode_tps": 30.325646701845777, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 106.9505611345965, + "prefill_tps": 106.9505611345965, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 32.9753891098103, + "round_gap_p50_ms": 107.706278009573, + "round_gap_p95_ms": 114.93787402287126, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0010790950036607683, + "first_payload_s": 0.13090160398860462, + "first_content_s": 0.13090160398860462, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13090160398860462, + "last_output_s": 8.539625826990232 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.25579174599261023, + "decode_tps": 29.493206975531713, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.73202407557145, + "prefill_tps": 54.73202407557145, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.906112713670794, + "round_gap_p50_ms": 107.54302798886783, + "round_gap_p95_ms": 114.64923198218457, + "tokens_per_chunk": 3.0476190476190474, + "headers_s": 0.0017402019875589758, + "first_payload_s": 0.25579174599261023, + "first_content_s": 0.25579174599261023, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.25579174599261023, + "last_output_s": 8.901850487978663 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 33.44075091174055, + "round_gap_p50_ms": 107.68317300244235, + "round_gap_p95_ms": 114.87305699847639, + "round_gap_mean_ms": 106.592393531173, + "tokens_per_chunk": 3.1604938271604937, + "aggregate_prompt_ttft_tps": 109.4640481511429, + "aggregate_prefill_tps": 109.4640481511429 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258576.693148379, + "first": 258576.824049983, + "last": 258585.232774206, + "end": 258585.232870255, + "elapsed_s": 8.539721875975374, + "chunk_offsets_s": [ + 0.13090160398860462, + 0.3427426479756832, + 0.43915325598209165, + 0.5406092549965251, + 0.6429787319793832, + 0.7455490409920458, + 0.8488408440025523, + 0.9557546679861844, + 1.0642561659915373, + 1.1717877709888853, + 1.2765360779885668, + 1.3833413099928293, + 1.4871893069939688, + 1.5974470079818275, + 1.7012579499860294, + 1.8084446559951175, + 1.9209635549923405, + 2.0347919990017544, + 2.1461516749986913, + 2.2538348480011337, + 2.357948366989149, + 2.4678867390030064, + 2.5749409639975056, + 2.68414299498545, + 2.7910197000019252, + 2.892302081978414, + 3.000008359987987, + 3.1036790130019654, + 3.2090952599828597, + 3.315118711994728, + 3.423872499988647, + 3.5365875129937194, + 3.645283236983232, + 3.7601562939817086, + 3.8753671619924717, + 3.9813689979782794, + 4.096306872001151, + 4.205575015977956, + 4.317135156976292, + 4.4273520589922555, + 4.535246769984951, + 4.645929930004058, + 4.760457177995704, + 4.873373567999806, + 4.991542566975113, + 5.100733861996559, + 5.209212896996178, + 5.316500515997177, + 5.422151981998468, + 5.527376293000998, + 5.633361104002688, + 5.743151570990449, + 5.85435020699515, + 5.9669581149937585, + 6.077370329992846, + 6.180741269985447, + 6.286864417983452, + 6.394556264975108, + 6.499269469000865, + 6.602322917984566, + 6.709980924002593, + 6.8159713839995675, + 6.918210076983087, + 7.025935747980839, + 7.137979620980332, + 7.246074652997777, + 7.348033504997147, + 7.458786105999025, + 7.564927895000437, + 7.676995191985043, + 7.788433957990492, + 7.897318675997667, + 8.006176080991281, + 8.115700514987111, + 8.222588804987026, + 8.332550216990057, + 8.4363146959804, + 8.539625826990232 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 107.706278009573, + "p95": 114.93787402287126, + "max": 211.8410439870786 + } + }, + { + "start": 258576.693056715, + "first": 258576.948848461, + "last": 258585.594907203, + "end": 258585.59539527, + "elapsed_s": 8.902338554995367, + "chunk_offsets_s": [ + 0.25579174599261023, + 0.3427201669837814, + 0.4391196229844354, + 0.5405192699981853, + 0.6429560269752983, + 0.7455416809825692, + 0.848808074981207, + 0.9557256429980043, + 1.0641094289894681, + 1.171652456978336, + 1.2764491169946268, + 1.3833470690005925, + 1.4871714990003966, + 1.5973976799868979, + 1.7012324929819442, + 1.8084512479836121, + 1.9209419069811702, + 2.0347794219851494, + 2.1461146179935895, + 2.2538240629946813, + 2.3578899819985963, + 2.467870257998584, + 2.5749291079991963, + 2.684059505991172, + 2.7909255389822647, + 2.8922660009993706, + 2.9999762469960842, + 3.1036486759840045, + 3.2090554509777576, + 3.3150971589784604, + 3.4238189309835434, + 3.53657255199505, + 3.645234563999111, + 3.7601114139833953, + 3.8753589219995774, + 3.9813568370009307, + 4.0962330949842, + 4.20547896597418, + 4.316812082979595, + 4.42718759298441, + 4.534984751982847, + 4.645765496999957, + 4.760414728982141, + 4.873335999000119, + 4.99151202198118, + 5.10068998899078, + 5.2091447839920875, + 5.316450146987336, + 5.422120732982876, + 5.527340531989466, + 5.633559712994611, + 5.743134594988078, + 5.85418919697986, + 5.966859729989665, + 6.077563818980707, + 6.18069030897459, + 6.286815264989855, + 6.394473158987239, + 6.499224987986963, + 6.602133492997382, + 6.70990397897549, + 6.815921126981266, + 6.918165819981368, + 7.025891026976751, + 7.137817187001929, + 7.2460645409883, + 7.347859310975764, + 7.459121930995025, + 7.564960135001456, + 7.67718492099084, + 7.788345765002305, + 7.897084609983722, + 8.006131600996014, + 8.115656305977609, + 8.222522083990043, + 8.332473927992396, + 8.43615538199083, + 8.539565618993947, + 8.61139041199931, + 8.673592778999591, + 8.737401875987416, + 8.79716509199352, + 8.851295025000582, + 8.901850487978663 + ], + "chunk_gaps_ms": { + "count": 83, + "p50": 107.54302798886783, + "p95": 114.64923198218457, + "max": 118.17602298106067 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + } + ] + }, + { + "prompt": "code", + "temperature": 1.0, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 4, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 71.9, + "per_stream_tps": 18.6, + "ttft_s_max": 0.52, + "request": { + "ttft_s": 0.321, + "decode_tps": 18.576, + "prompt_ttft_tps": 45.115, + "prefill_tps": 45.115, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.833, + "round_gap_p50_ms": 171.254, + "round_gap_p95_ms": 215.475, + "tokens_per_chunk": 3.221, + "headers_s": 0.002, + "first_payload_s": 0.321, + "first_content_s": 0.321, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.321, + "last_output_s": 14.033 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 108.384, + "aggregate_prefill_tps": 108.384, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.925, + "round_gap_p50_ms": 171.263, + "round_gap_p95_ms": 216.513, + "tokens_per_chunk": 3.2 + }, + "completions": { + "truncated": 12 + }, + "timing_valid": true, + "end_to_end_tps": 71.51349299805634, + "makespan_s": 14.318976141017629, + "steady_tps": 73.5, + "alone": { + "equal": 12, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 4, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 71.88504112756847, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 14.318976141017629, + "end_to_end_tps": 71.51349299805634, + "timing_valid": true, + "steady_tps": 73.48773840928055, + "per_stream_tps": [ + 18.5, + 18.3, + 18.6, + 18.7 + ], + "ttft_s": [ + 0.13, + 0.38, + 0.5, + 0.25 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.1292723799997475, + "decode_tps": 18.549294296593438, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 108.29846251788159, + "prefill_tps": 108.29846251788159, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.91040672548115, + "round_gap_p50_ms": 171.40316998120397, + "round_gap_p95_ms": 225.49249400617555, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0008980220009107143, + "first_payload_s": 0.1292723799997475, + "first_content_s": 0.1292723799997475, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1292723799997475, + "last_output_s": 13.876426094997441 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.3791276769770775, + "decode_tps": 18.293509179265133, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 36.926874111716344, + "prefill_tps": 36.926874111716344, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 54.66419756869037, + "round_gap_p50_ms": 171.03587201563641, + "round_gap_p95_ms": 216.841960005695, + "tokens_per_chunk": 3.0843373493975905, + "headers_s": 0.00129911198746413, + "first_payload_s": 0.3791276769770775, + "first_content_s": 0.3791276769770775, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3791276769770775, + "last_output_s": 14.318498056993121 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.5038536610081792, + "decode_tps": 18.6214163555968, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 27.78584554091934, + "prefill_tps": 27.78584554091934, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.70160791767287, + "round_gap_p50_ms": 171.00419200141914, + "round_gap_p95_ms": 205.01307098311372, + "tokens_per_chunk": 3.1604938271604937, + "headers_s": 0.0014725050132256001, + "first_payload_s": 0.5038536610081792, + "first_content_s": 0.5038536610081792, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5038536610081792, + "last_output_s": 14.19776368001476 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.25425746900145896, + "decode_tps": 18.718483877248367, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 55.062295927753716, + "prefill_tps": 55.062295927753716, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.42313012943658, + "round_gap_p50_ms": 171.26265598926693, + "round_gap_p95_ms": 225.36412498448044, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.001789467001799494, + "first_payload_s": 0.25425746900145896, + "first_content_s": 0.25425746900145896, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.25425746900145896, + "last_output_s": 13.877155652007787 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.92483558532024, + "round_gap_p50_ms": 171.26265598926693, + "round_gap_p95_ms": 217.21927501494065, + "round_gap_mean_ms": 174.06117815514762, + "tokens_per_chunk": 3.2, + "aggregate_prompt_ttft_tps": 110.96191445052627, + "aggregate_prefill_tps": 110.96191445052627 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "e83550d98e0d", + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "6b0505e27f4f", + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258585.598059574, + "first": 258585.727331954, + "last": 258599.474485669, + "end": 258599.47462599, + "elapsed_s": 13.876566416001879, + "chunk_offsets_s": [ + 0.1292723799997475, + 0.6376972690050025, + 0.7911821170127951, + 0.9394124379905406, + 1.0984025039942935, + 1.2472764929989353, + 1.4028641229961067, + 1.561683259991696, + 1.72166267700959, + 1.8817322390095796, + 2.0404333920159843, + 2.209227871004259, + 2.375566639006138, + 2.5402610450109933, + 2.7103031009901315, + 2.8777224679943174, + 3.0470811749983113, + 3.2190153539995663, + 3.3895405319926795, + 3.5585861490108073, + 3.726738272991497, + 3.895599729003152, + 4.070754296000814, + 4.241412258998025, + 4.411540875007631, + 4.579733352002222, + 4.750488707999466, + 4.919447380991187, + 5.0894686529936735, + 5.273974573996384, + 5.479478207998909, + 5.696644298994215, + 5.9230965900060255, + 6.148589084012201, + 6.37629680801183, + 6.5734847109997645, + 6.74646488201688, + 6.917678913014242, + 7.0921088850009255, + 7.269462185999146, + 7.44604335501208, + 7.620645359012997, + 7.799424894008553, + 7.981456945009995, + 8.16526574199088, + 8.339363039995078, + 8.518502480990719, + 8.694815216003917, + 8.876537745003588, + 9.050489201996243, + 9.228289563005092, + 9.406506517989328, + 9.585089027998038, + 9.764047620003112, + 9.936783165991073, + 10.102433755993843, + 10.266515905008418, + 10.432773217995418, + 10.601400643005036, + 10.765692504995968, + 10.935378511989256, + 11.106270318996394, + 11.275023505004356, + 11.453457710013026, + 11.62983054301003, + 11.803509423014475, + 11.977915891999146, + 12.157485672010807, + 12.328888841992011, + 12.510646300012013, + 12.691244840010768, + 12.868367501010653, + 13.038462536002044, + 13.209510984015651, + 13.38106018700637, + 13.555386304011336, + 13.718002940993756, + 13.876426094997441 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 171.40316998120397, + "p95": 225.49249400617555, + "max": 508.42488900525495 + } + }, + { + "start": 258585.598155959, + "first": 258585.977283636, + "last": 258599.916654016, + "end": 258599.916733009, + "elapsed_s": 14.318577049998567, + "chunk_offsets_s": [ + 0.3791276769770775, + 0.6375384509738069, + 0.7911717649840284, + 0.9392599079874344, + 1.0983939439756796, + 1.2473257569945417, + 1.4027000409842003, + 1.5614972269977443, + 1.7214599399885628, + 1.8818089749838691, + 2.0402238379756454, + 2.2093289269832894, + 2.3760561619710643, + 2.5404654939775355, + 2.710779630986508, + 2.877738930983469, + 3.047074869973585, + 3.219149849988753, + 3.3897581169730984, + 3.5584262599877547, + 3.7269520339905284, + 3.8958622419741005, + 4.070463717973325, + 4.241195585986134, + 4.411564042995451, + 4.579085282981396, + 4.750531491998117, + 4.919429316971218, + 5.089547948999098, + 5.274207646987634, + 5.479796353989514, + 5.696638313995209, + 5.923146685992833, + 6.148907629976748, + 6.3763391109823715, + 6.573781736980891, + 6.746853715972975, + 6.918365860998165, + 7.092232004972175, + 7.269531273981556, + 7.446025177981937, + 7.620947744988371, + 7.799489133991301, + 7.981569808995118, + 8.165398765995633, + 8.339472911990015, + 8.518277806986589, + 8.695159921975574, + 8.876582240976859, + 9.050839891977375, + 9.228307738987496, + 9.406141267972998, + 9.584798529976979, + 9.764199188997736, + 9.936887405987363, + 10.102657884999644, + 10.266653536993545, + 10.432896402984625, + 10.601574851985788, + 10.765825065987883, + 10.935419647983508, + 11.10635579098016, + 11.275074192992179, + 11.453507117985282, + 11.629939598991768, + 11.803715407993877, + 11.978028867975809, + 12.157499703986105, + 12.328937017999124, + 12.510671243973775, + 12.69146413699491, + 12.868405084998813, + 13.038557351974305, + 13.209593223989941, + 13.38119180398644, + 13.555471999978181, + 13.718196172994794, + 13.876803280989407, + 13.991339795989916, + 14.101517212984618, + 14.198106800991809, + 14.267419229989173, + 14.318498056993121 + ], + "chunk_gaps_ms": { + "count": 82, + "p50": 171.2365930143278, + "p95": 216.841960005695, + "max": 258.4107739967294 + } + }, + { + "start": 258585.598580873, + "first": 258586.102434534, + "last": 258599.796344553, + "end": 258599.796422665, + "elapsed_s": 14.197841792018153, + "chunk_offsets_s": [ + 0.5038536610081792, + 0.6369964010082185, + 0.7906080500106327, + 0.9386339370103087, + 1.0978331570222508, + 1.2470995640032925, + 1.4021716220013332, + 1.5609819600067567, + 1.720922865002649, + 1.881156955001643, + 2.039681082998868, + 2.2093547520053107, + 2.3755655990098603, + 2.5404020060086623, + 2.7102268600137904, + 2.877391490008449, + 3.047099175018957, + 3.2187893360096496, + 3.389222466008505, + 3.5581756670144387, + 3.7263901910046116, + 3.8952166070230305, + 4.070687688014004, + 4.2410025450226385, + 4.411383275000844, + 4.578948355017928, + 4.750350659014657, + 4.91922757201246, + 5.089338668010896, + 5.274246528017102, + 5.4792595990002155, + 5.696450729999924, + 5.923182047001319, + 6.148399051016895, + 6.376133383018896, + 6.573433575016679, + 6.746236368024256, + 6.917835666012252, + 7.092029620020185, + 7.269029112008866, + 7.445684441016056, + 7.620418910024455, + 7.799278957012575, + 7.981348368019098, + 8.164806171000237, + 8.338913740997668, + 8.517754476022674, + 8.69465478300117, + 8.876079166017007, + 9.05032806500094, + 9.22811676200945, + 9.405811889999313, + 9.58468649801216, + 9.7638702270051, + 9.936377180012641, + 10.102089834021172, + 10.266369504010072, + 10.43235547200311, + 10.601081121014431, + 10.765484760020627, + 10.935143487004098, + 11.10585382100544, + 11.274732159014093, + 11.45321028502076, + 11.629598508996423, + 11.803225021023536, + 11.977658578020055, + 12.157171206024941, + 12.328642617008882, + 12.513587487017503, + 12.690960438019829, + 12.86812127599842, + 13.038246823009104, + 13.209251015010523, + 13.380843065999215, + 13.554750252020312, + 13.717710411001462, + 13.876631520019146, + 13.990841218008427, + 14.101015913998708, + 14.19776368001476 + ], + "chunk_gaps_ms": { + "count": 80, + "p50": 171.20324799907394, + "p95": 205.01307098311372, + "max": 227.73433200200088 + } + }, + { + "start": 258585.597756868, + "first": 258585.852014337, + "last": 258599.47491252, + "end": 258599.475045688, + "elapsed_s": 13.877288820018293, + "chunk_offsets_s": [ + 0.25425746900145896, + 0.6380645669996738, + 0.7916123600152787, + 0.9395926950091962, + 1.0988603470032103, + 1.2475118540169206, + 1.403216300997883, + 1.5621040950063616, + 1.721914135006955, + 1.8821413610130548, + 2.040676850010641, + 2.2096559060155414, + 2.3759548180096317, + 2.5406845519901253, + 2.710437917994568, + 2.877945317013655, + 3.0472961679915898, + 3.2192403789958917, + 3.3899214139964897, + 3.559087432018714, + 3.7271178110095207, + 3.896308613999281, + 4.071141530992463, + 4.241642501001479, + 4.412296383990906, + 4.579974729014793, + 4.75123738500406, + 4.920115001004888, + 5.089886927016778, + 5.274404447991401, + 5.4798936189909, + 5.697112894005841, + 5.923634930019034, + 6.1489990550035145, + 6.37681826701737, + 6.57393437801511, + 6.746952613000758, + 6.918154212005902, + 7.0925518320000265, + 7.283072830003221, + 7.4462310840026475, + 7.621054242015816, + 7.799806368013378, + 7.981897971010767, + 8.165715873008594, + 8.33981275500264, + 8.51815166301094, + 8.695212866994552, + 8.877066548011499, + 9.050902709015645, + 9.22876865399303, + 9.406447941990336, + 9.58559117501136, + 9.764490903005935, + 9.937346049991902, + 10.10299635201227, + 10.266947586991591, + 10.433356421999633, + 10.601843445998384, + 10.766160700004548, + 10.935888548003277, + 11.10649803301203, + 11.275621444015997, + 11.45397161701112, + 11.630239713005722, + 11.80393915399327, + 11.978306534001604, + 12.158092380006565, + 12.329395166016184, + 12.51113297601114, + 12.691662938013906, + 12.868870128993876, + 13.038887706992682, + 13.209926203009672, + 13.381516126013594, + 13.55578277099994, + 13.718445006990805, + 13.877155652007787 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 171.26265598926693, + "p95": 225.36412498448044, + "max": 383.8070979982149 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 71.45296191711344, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 14.409605597000336, + "end_to_end_tps": 71.0637076849048, + "timing_valid": true, + "steady_tps": 73.16586531238556, + "per_stream_tps": [ + 18.8, + 18.4, + 18.0, + 18.6 + ], + "ttft_s": [ + 0.39, + 0.52, + 0.13, + 0.26 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.3895324699988123, + "decode_tps": 18.777168198644432, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 35.940521210061604, + "prefill_tps": 35.940521210061604, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.25616671379619, + "round_gap_p50_ms": 172.3713880055584, + "round_gap_p95_ms": 219.1051309928298, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0019575640035327524, + "first_payload_s": 0.3895324699988123, + "first_content_s": 0.3895324699988123, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3895324699988123, + "last_output_s": 13.969854982016841 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.5160605319833849, + "decode_tps": 18.35499947862479, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 27.128600488383686, + "prefill_tps": 27.128600488383686, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 54.481069376468476, + "round_gap_p50_ms": 170.88131498894654, + "round_gap_p95_ms": 214.4419660035055, + "tokens_per_chunk": 3.0843373493975905, + "headers_s": 0.0018651789869181812, + "first_payload_s": 0.5160605319833849, + "first_content_s": 0.5160605319833849, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5160605319833849, + "last_output_s": 14.408733222982846 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.1335347769781947, + "decode_tps": 18.012501153862047, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 104.84160244103377, + "prefill_tps": 104.84160244103377, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 55.516998525526304, + "round_gap_p50_ms": 171.73325500334613, + "round_gap_p95_ms": 216.5078510006424, + "tokens_per_chunk": 3.1604938271604937, + "headers_s": 0.0012404719891492277, + "first_payload_s": 0.1335347769781947, + "first_content_s": 0.1335347769781947, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1335347769781947, + "last_output_s": 14.290369400987402 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.26264880600501783, + "decode_tps": 18.60279696085231, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 53.30311686142801, + "prefill_tps": 53.30311686142801, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.755357439227986, + "round_gap_p50_ms": 172.66583800665103, + "round_gap_p95_ms": 219.4973099976778, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.002159836993087083, + "first_payload_s": 0.26264880600501783, + "first_content_s": 0.26264880600501783, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.26264880600501783, + "last_output_s": 13.970264953008154 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 54.252398013754735, + "round_gap_p50_ms": 171.76154401386157, + "round_gap_p95_ms": 216.51276299962774, + "round_gap_mean_ms": 175.11849991781594, + "tokens_per_chunk": 3.2, + "aggregate_prompt_ttft_tps": 108.38373757804906, + "aggregate_prefill_tps": 108.38373757804906 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "e83550d98e0d", + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "6b0505e27f4f", + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258599.918697725, + "first": 258600.308230195, + "last": 258613.888552707, + "end": 258613.889277623, + "elapsed_s": 13.970579898013966, + "chunk_offsets_s": [ + 0.3895324699988123, + 0.6659052820177749, + 0.8198719609936234, + 0.9658584310091101, + 1.1256116900185589, + 1.2737069250142667, + 1.426425437006401, + 1.584833119995892, + 1.7429480650171172, + 1.9031706230016425, + 2.06114128002082, + 2.228139432001626, + 2.394647981011076, + 2.5587203390023205, + 2.7277971760195214, + 2.8947292160009965, + 3.063258210022468, + 3.2443395699956454, + 3.451244608993875, + 3.6587874440010637, + 3.869981405994622, + 4.084481883997796, + 4.313080946012633, + 4.537577295006486, + 4.7566824259993155, + 4.973195188998943, + 5.143628451012773, + 5.313326205010526, + 5.495392147015082, + 5.658272835018579, + 5.824583464011084, + 5.99538664802094, + 6.172421584022231, + 6.348559666017536, + 6.533917245018529, + 6.707373038021615, + 6.879460919008125, + 7.049713284010068, + 7.223717193002813, + 7.401464485999895, + 7.574328228016384, + 7.748745451011928, + 7.9286739570088685, + 8.10974687000271, + 8.293265109998174, + 8.465722305001691, + 8.643749840004602, + 8.818943612015573, + 8.999166696012253, + 9.170902671001386, + 9.349705843022093, + 9.526526970003033, + 9.704313271009596, + 9.882010835019173, + 10.052977045997977, + 10.217871443019249, + 10.380404546012869, + 10.544815949018812, + 10.71182944701286, + 10.874759816011647, + 11.042748264997499, + 11.212041585997213, + 11.37992913799826, + 11.559150265005883, + 11.734183524997206, + 11.906554913002765, + 12.07996950802044, + 12.259585533000063, + 12.433206257002894, + 12.613885280996328, + 12.797271217015805, + 12.97329064400401, + 13.144778139016125, + 13.314178789005382, + 13.481932452996261, + 13.652329717006069, + 13.813043642003322, + 13.969854982016841 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 172.3713880055584, + "p95": 219.1051309928298, + "max": 276.3728120189626 + } + }, + { + "start": 258599.919015023, + "first": 258600.435075555, + "last": 258614.327748246, + "end": 258614.327998472, + "elapsed_s": 14.408983448985964, + "chunk_offsets_s": [ + 0.5160605319833849, + 0.6656987999740522, + 0.8196293829823844, + 0.9656053889775649, + 1.12538069699076, + 1.2735272439895198, + 1.4262465719948523, + 1.5847679039870854, + 1.7431562259735074, + 1.9033144799759611, + 2.0611236469994765, + 2.2275278119777795, + 2.394149961997755, + 2.55832212898531, + 2.7273451419896446, + 2.8943103659839835, + 3.062890671979403, + 3.243793197994819, + 3.4507309579930734, + 3.6583320329955313, + 3.869536218990106, + 4.083978184993612, + 4.31257367899525, + 4.537116299994523, + 4.756273526989389, + 4.972752305999165, + 5.143152143980842, + 5.312566775974119, + 5.494543277978664, + 5.657621470978484, + 5.823756994999712, + 5.994622979982523, + 6.172400879993802, + 6.3478815329726785, + 6.533207815984497, + 6.70670832999167, + 6.878697393985931, + 7.049148256977787, + 7.223146917996928, + 7.400780176976696, + 7.5737071839976124, + 7.748244488000637, + 7.927988591982285, + 8.109361218987033, + 8.292522528994596, + 8.465025868994417, + 8.642909801972564, + 8.818540201988071, + 8.998509523982648, + 9.170293067989405, + 9.349835203989642, + 9.526450360979652, + 9.704163829999743, + 9.882242100982694, + 10.053115894988878, + 10.217904371995246, + 10.380157601000974, + 10.544895340979565, + 10.711591125989798, + 10.874781080987304, + 11.04257069597952, + 11.212243154994212, + 11.379992242989829, + 11.559425385989016, + 11.733689553977456, + 11.906310239981394, + 12.080073443998117, + 12.259692044986878, + 12.433285424980568, + 12.613643454998964, + 12.797425041993847, + 12.973427652992541, + 13.144653833995108, + 13.3142579899868, + 13.482046869990882, + 13.652928184979828, + 13.813186938990839, + 13.970052614982706, + 14.083483637979953, + 14.194407861999935, + 14.29051530599827, + 14.358047212997917, + 14.408733222982846 + ], + "chunk_gaps_ms": { + "count": 82, + "p50": 171.05374799575657, + "p95": 214.4419660035055, + "max": 228.59549400163814 + } + }, + { + "start": 258599.919087951, + "first": 258600.052622728, + "last": 258614.209457352, + "end": 258614.209545369, + "elapsed_s": 14.290457417984726, + "chunk_offsets_s": [ + 0.1335347769781947, + 0.6650888609874528, + 0.8201588269730564, + 0.9653406199940946, + 1.1251206309825648, + 1.273209210979985, + 1.4259457219741307, + 1.5848428319732193, + 1.7430405459890608, + 1.9031993919925299, + 2.061012302991003, + 2.227803205983946, + 2.3939865849970374, + 2.558126224001171, + 2.72718048497336, + 2.894106940977508, + 3.062594861985417, + 3.2436586059920955, + 3.4504975649761036, + 3.658144736982649, + 3.8693877069745213, + 4.08382698497735, + 4.312565582979005, + 4.536946026986698, + 4.756058613973437, + 4.972566464974079, + 5.1429958079825155, + 5.312583528982941, + 5.494656654977007, + 5.657804031972773, + 5.824032068980159, + 5.994820020976476, + 6.172268718975829, + 6.34808823899948, + 6.533444633998442, + 6.707134844997199, + 6.878868100000545, + 7.049472706974484, + 7.223492247983813, + 7.401006818981841, + 7.574097666976741, + 7.748590762988897, + 7.928217953973217, + 8.109719029976986, + 8.292795202985872, + 8.465188174974173, + 8.643186460976722, + 8.81872471497627, + 8.998926774977008, + 9.17068831899087, + 9.349596146988915, + 9.526202439999906, + 9.703882788977353, + 9.881996851996519, + 10.05288334999932, + 10.21775181099656, + 10.380302337987814, + 10.544755164999515, + 10.711826071987161, + 10.874640375986928, + 11.042424950981513, + 11.212129810999613, + 11.379839121975238, + 11.559281801979523, + 11.73393550797482, + 11.90651657700073, + 12.079904147976777, + 12.259554380987538, + 12.433132016973104, + 12.6138088159787, + 12.797202368994476, + 12.973289235989796, + 13.145001228986075, + 13.31411270899116, + 13.481781556998612, + 13.652663847984513, + 13.812939048977569, + 13.970162055979017, + 14.083350741973845, + 14.194278309994843, + 14.290369400987402 + ], + "chunk_gaps_ms": { + "count": 80, + "p50": 171.74739950860385, + "p95": 216.5078510006424, + "max": 531.5540840092581 + } + }, + { + "start": 258599.918392875, + "first": 258600.181041681, + "last": 258613.888657828, + "end": 258613.888761476, + "elapsed_s": 13.970368601003429, + "chunk_offsets_s": [ + 0.26264880600501783, + 0.665934434015071, + 0.8203960279934108, + 0.9664010579872411, + 1.12635436700657, + 1.274091536004562, + 1.4268179039936513, + 1.5852169459976722, + 1.7433324999874458, + 1.9040158290008549, + 2.061539170012111, + 2.228250681015197, + 2.3948979509877972, + 2.5591353019990493, + 2.7280457699962426, + 2.895119363005506, + 3.0634586430096533, + 3.244576770986896, + 3.4514853789878543, + 3.659042037994368, + 3.870374593010638, + 4.084728638001252, + 4.3133345959940925, + 4.537828447995707, + 4.757325757993385, + 4.973588343011215, + 5.143877221009461, + 5.31342883000616, + 5.495584485004656, + 5.658148162008729, + 5.8248003289918415, + 5.995174278999912, + 6.172651905013481, + 6.34892273999867, + 6.534272655000677, + 6.707882880989928, + 6.879640695988201, + 7.050072407000698, + 7.224234813009389, + 7.401816424011486, + 7.57484104699688, + 7.749231694004266, + 7.928736661007861, + 8.1101942799869, + 8.293272293987684, + 8.465957587002777, + 8.643628366990015, + 8.819325566990301, + 8.999542667006608, + 9.17105456101126, + 9.350095892994432, + 9.527131070004543, + 9.704717257001903, + 9.88302511398797, + 10.053692235000199, + 10.218601127999136, + 10.380858660995727, + 10.545225918991491, + 10.712288442009594, + 10.875477500987472, + 11.043264251988148, + 11.212660885998048, + 11.380681815004209, + 11.559554554987699, + 11.734389861987438, + 11.907055699994089, + 12.08077906499966, + 12.260005423013354, + 12.43407392600784, + 12.614579668996157, + 12.797680852003396, + 12.973727703007171, + 13.14521804600372, + 13.314948346000165, + 13.482604152988642, + 13.65292053698795, + 13.813736862008227, + 13.970264953008154 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 172.66583800665103, + "p95": 219.4973099976778, + "max": 403.2856280100532 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 72.43897380328185, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 14.215515390009386, + "end_to_end_tps": 72.03396935714787, + "timing_valid": true, + "steady_tps": 74.38539210083232, + "per_stream_tps": [ + 18.9, + 18.4, + 18.3, + 19.2 + ], + "ttft_s": [ + 0.26, + 0.39, + 0.13, + 0.52 + ], + "errors": [], + "thinking_modes": [ + "not applicable" + ], + "requests": [ + { + "prompt_tokens": 14, + "ttft_s": 0.2608019050094299, + "decode_tps": 18.873250535887664, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 53.68058948608446, + "prefill_tps": 53.68058948608446, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 52.98504346659791, + "round_gap_p50_ms": 171.82446000515483, + "round_gap_p95_ms": 200.2037089841906, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0016171619936358184, + "first_payload_s": 0.2608019050094299, + "first_content_s": 0.2608019050094299, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.2608019050094299, + "last_output_s": 13.771987988991896 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.3882904070196673, + "decode_tps": 18.44274411896329, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 36.05548771461378, + "prefill_tps": 36.05548771461378, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 54.22186598423686, + "round_gap_p50_ms": 171.14178501651622, + "round_gap_p95_ms": 192.60314901475795, + "tokens_per_chunk": 3.0843373493975905, + "headers_s": 0.0018782030092552304, + "first_payload_s": 0.3882904070196673, + "first_content_s": 0.3882904070196673, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3882904070196673, + "last_output_s": 14.214866233000066 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.13454629099578597, + "decode_tps": 18.266220215928897, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 104.05340716852972, + "prefill_tps": 104.05340716852972, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 54.745863576524656, + "round_gap_p50_ms": 170.6833009957336, + "round_gap_p95_ms": 192.99811200471595, + "tokens_per_chunk": 3.1604938271604937, + "headers_s": 0.0010899269836954772, + "first_payload_s": 0.13454629099578597, + "first_content_s": 0.13454629099578597, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.13454629099578597, + "last_output_s": 14.094741503009573 + }, + { + "prompt_tokens": 14, + "ttft_s": 0.5167935890203808, + "decode_tps": 19.236903097251542, + "thinking": "not applicable", + "thinking_off_requested": false, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 27.090119338628025, + "prefill_tps": 27.090119338628025, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 51.983419313625085, + "round_gap_p50_ms": 171.24447200330906, + "round_gap_p95_ms": 192.96950299758464, + "tokens_per_chunk": 3.282051282051282, + "headers_s": 0.0022187659924384207, + "first_payload_s": 0.5167935890203808, + "first_content_s": 0.5167935890203808, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5167935890203808, + "last_output_s": 13.772565513994778 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 53.48404808524612, + "round_gap_p50_ms": 171.24447200330906, + "round_gap_p95_ms": 192.99811200471595, + "round_gap_mean_ms": 172.63838305997166, + "tokens_per_chunk": 3.2, + "aggregate_prompt_ttft_tps": 108.3604773545121, + "aggregate_prefill_tps": 108.3604773545121 + }, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "e83550d98e0d", + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "6b0505e27f4f", + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258614.33025807, + "first": 258614.591059975, + "last": 258628.102246059, + "end": 258628.102483261, + "elapsed_s": 13.77222519100178, + "chunk_offsets_s": [ + 0.2608019050094299, + 0.664652520994423, + 0.8172510350123048, + 0.9672691019950435, + 1.1269735319947358, + 1.2747038890083786, + 1.4269838409963995, + 1.587410644016927, + 1.7464272789948154, + 1.9081238340004347, + 2.0670043230056763, + 2.2343926900066435, + 2.399582306999946, + 2.563305401999969, + 2.7334593220148236, + 2.9019799520028755, + 3.069520288001513, + 3.2443659490090795, + 3.413728902989533, + 3.5827143200149294, + 3.7501036470057443, + 3.919399450009223, + 4.09744361101184, + 4.267646107007749, + 4.43383797100978, + 4.61901902401587, + 4.772928699996555, + 4.940672621014528, + 5.110171337990323, + 5.2733341270068195, + 5.439393654000014, + 5.609921208990272, + 5.7870019400143065, + 5.963923135015648, + 6.1414102849958, + 6.3158204079954885, + 6.488254422991304, + 6.659366381994914, + 6.83414738700958, + 7.0102207850140985, + 7.185086495010182, + 7.35923941701185, + 7.537362572009442, + 7.7287113280035555, + 7.90053578800871, + 8.06948218200705, + 8.246712610998657, + 8.423102650995133, + 8.603505756007507, + 8.774321249016793, + 8.95222521899268, + 9.129253054998117, + 9.308693433995359, + 9.485536885011243, + 9.657959700998617, + 9.823247463995358, + 9.986086317017907, + 10.153971583989915, + 10.346685966011137, + 10.546889674995327, + 10.763262348016724, + 10.981965612008935, + 11.166622807999374, + 11.344573339010822, + 11.522819598991191, + 11.696578119008336, + 11.869435417989735, + 12.050811266002711, + 12.222372766002081, + 12.407330059999367, + 12.586142435990041, + 12.764755851007067, + 12.937778207007796, + 13.108138242998393, + 13.281027399003506, + 13.452168976014946, + 13.613753004989121, + 13.771987988991896 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 171.82446000515483, + "p95": 200.2037089841906, + "max": 403.85061598499306 + } + }, + { + "start": 258614.330428039, + "first": 258614.718718446, + "last": 258628.545294272, + "end": 258628.545390001, + "elapsed_s": 14.214961962017696, + "chunk_offsets_s": [ + 0.3882904070196673, + 0.6645459760038648, + 0.817434556025546, + 0.9671730530099012, + 1.126866652019089, + 1.2747430090093985, + 1.426870528026484, + 1.5874148520233575, + 1.746433695021551, + 1.9081246820278466, + 2.0673463260172866, + 2.2343722580117173, + 2.399582707002992, + 2.5632596740033478, + 2.733667307009455, + 2.902011312020477, + 3.0695390080218203, + 3.244295468000928, + 3.4136342470010277, + 3.582884161005495, + 3.7500341750273947, + 3.91933108100784, + 4.0974251630250365, + 4.267569163028384, + 4.434022948000347, + 4.601894022023771, + 4.773187966027763, + 4.940868591016624, + 5.109668055025395, + 5.272837692027679, + 5.4394449180108495, + 5.609990089025814, + 5.78671798601863, + 5.963978591025807, + 6.141292332002195, + 6.316084522026358, + 6.488226407003822, + 6.659388446016237, + 6.833725513017271, + 7.0104578910104465, + 7.1852043680264615, + 7.359464427019702, + 7.537615373003064, + 7.718030254007317, + 7.900525580014801, + 8.06958099800977, + 8.246604338026373, + 8.423126875015441, + 8.603515388007509, + 8.774546947010094, + 8.951998513017315, + 9.128918957023416, + 9.308554825023748, + 9.485267828014912, + 9.657750244019553, + 9.823032423009863, + 9.985860667016823, + 10.153873408009531, + 10.346476557024289, + 10.546954667021055, + 10.762966762005817, + 10.9814043600054, + 11.16618554102024, + 11.344053847016767, + 11.521985514002154, + 11.696070884005167, + 11.869212105026236, + 12.050186671025585, + 12.222143564024009, + 12.406745064014103, + 12.585712129017338, + 12.764235176000511, + 12.937537694000639, + 13.10791222602711, + 13.280791285011219, + 13.451933070027735, + 13.613363178010331, + 13.771723428013502, + 13.88715681800386, + 13.997962564026238, + 14.094044457015116, + 14.16323674400337, + 14.214866233000066 + ], + "chunk_gaps_ms": { + "count": 82, + "p50": 171.15191201446578, + "p95": 192.60314901475795, + "max": 276.25556898419745 + } + }, + { + "start": 258614.329930067, + "first": 258614.464476358, + "last": 258628.42467157, + "end": 258628.424755218, + "elapsed_s": 14.094825150998076, + "chunk_offsets_s": [ + 0.13454629099578597, + 0.665282030007802, + 0.8178363199986052, + 0.9675187679822557, + 1.1274912160006352, + 1.2746751369850244, + 1.4277903749898542, + 1.5881393699964974, + 1.747501301986631, + 1.909223648981424, + 2.0673954949888866, + 2.234997318999376, + 2.400366488000145, + 2.5641086240066215, + 2.7343026239832398, + 2.901928161008982, + 3.069932546990458, + 3.2450139060092624, + 3.41374055299093, + 3.5832683729822747, + 3.7502962889848277, + 3.92013089498505, + 4.097853198007215, + 4.268157760001486, + 4.434385558997747, + 4.602468586992472, + 4.773147997999331, + 4.940877279994311, + 5.110044633998768, + 5.273234319000039, + 5.440236763999565, + 5.610107594984584, + 5.787635337008396, + 5.964405906997854, + 6.141622911003651, + 6.316238956002053, + 6.488462504989002, + 6.659977314004209, + 6.834086540009594, + 7.010652356984792, + 7.185485283000162, + 7.359825805993751, + 7.537854463997064, + 7.718662706989562, + 7.901146672986215, + 8.07002260198351, + 8.247171078983229, + 8.4238072320004, + 8.604121935990406, + 8.77480523698614, + 8.952842408005381, + 9.129872051998973, + 9.308841852005571, + 9.485939753009006, + 9.658525545004522, + 9.823793068993837, + 9.986570145003498, + 10.154152353992686, + 10.347150465997402, + 10.547330270987004, + 10.763515439000912, + 10.982358318986371, + 11.167049020004924, + 11.344652523985133, + 11.522588845982682, + 11.69696932300576, + 11.87030590500217, + 12.0508020670095, + 12.222953825985314, + 12.408416307996958, + 12.586538870993536, + 12.76482865298749, + 12.938190882996423, + 13.10858285499853, + 13.281929004995618, + 13.452577074989676, + 13.614339457009919, + 13.7730572129949, + 13.887818343006074, + 13.99860197599628, + 14.094741503009573 + ], + "chunk_gaps_ms": { + "count": 80, + "p50": 171.0990550054703, + "p95": 192.99811200471595, + "max": 530.735739012016 + } + }, + { + "start": 258614.329874611, + "first": 258614.8466682, + "last": 258628.102440125, + "end": 258628.103177473, + "elapsed_s": 13.773302862013225, + "chunk_offsets_s": [ + 0.5167935890203808, + 0.6648198190086987, + 0.8178260950080585, + 0.9673667190072592, + 1.1272771829972044, + 1.2744987200130709, + 1.4276101019931957, + 1.58863802801352, + 1.7472972529940307, + 1.9089119349955581, + 2.0672199410037138, + 2.235685994004598, + 2.400292280013673, + 2.563998174999142, + 2.7340307499980554, + 2.901823919994058, + 3.070161587995244, + 3.245146546018077, + 3.413869848998729, + 3.583555029996205, + 3.7506705629930366, + 3.9203028960037045, + 4.0980391670018435, + 4.2682949760055635, + 4.434345782996388, + 4.602341898018494, + 4.77356987199164, + 4.941243170003872, + 5.110389708017465, + 5.273895395017462, + 5.440113435004605, + 5.6106326220033225, + 5.787817258009454, + 5.964401106000878, + 6.141923824994592, + 6.316439629008528, + 6.4888593229989056, + 6.660103795002215, + 6.83435446099611, + 7.010901077999733, + 7.185603555000853, + 7.359720013017068, + 7.537981839996064, + 7.718790003011236, + 7.901259121019393, + 8.06998501700582, + 8.24700419700821, + 8.42392016001395, + 8.604355073999614, + 8.774920373019995, + 8.953381051018368, + 9.12982368300436, + 9.308829884015722, + 9.486192762007704, + 9.658773978997488, + 9.82403783799964, + 9.986560960009228, + 10.154297986999154, + 10.347267489996739, + 10.547445391013753, + 10.76344390201848, + 10.982044541015057, + 11.166942395007936, + 11.34480137299397, + 11.523121089005144, + 11.69675738501246, + 11.87010012700921, + 12.051041957020061, + 12.222842273011338, + 12.408252674009418, + 12.586375701997895, + 12.7650706860004, + 12.93830787501065, + 13.10859181502019, + 13.281704427994555, + 13.452745843998855, + 13.614268609002465, + 13.772565513994778 + ], + "chunk_gaps_ms": { + "count": 77, + "p50": 171.24447200330906, + "p95": 192.96950299758464, + "max": 218.6006389965769 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "4ea5890db75b1c9b8fc29ba1467a8ba880ee9a4a6e2e009e5ae3683bbc1932ba", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "9ad5da4b74fc2493dcaacc7130b1fe8fb745d3820c1ddf6c80caaa8d77a397ac", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "e83550d98e0d7410f68de4910cc91c748725489975bba9d48e4d6f680d391ac0", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "complete": true, + "error": null, + "thinking": "not applicable" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "alone": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + }, + "serial": { + "tokens": 256, + "token_sha256": "6b0505e27f4ffabd1c4a034fc772125365af3de8cafaba8bbad640ed52eeda03", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "complete": true, + "error": null, + "thinking": "not applicable" + } + } + ] + } + ] + }, + { + "prompt": "chat", + "temperature": 1.0, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 1, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 33.9, + "per_stream_tps": 33.9, + "ttft_s_max": 0.2, + "request": { + "ttft_s": 0.196, + "decode_tps": 33.931, + "prompt_ttft_tps": 163.524, + "prefill_tps": 163.524, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.472, + "round_gap_p50_ms": 63.874, + "round_gap_p95_ms": 85.454, + "tokens_per_chunk": 2.286, + "headers_s": 0.001, + "first_payload_s": 0.001, + "first_content_s": 0.196, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.196, + "last_output_s": 7.711 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 163.524, + "aggregate_prefill_tps": 163.524, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.472, + "round_gap_p50_ms": 63.874, + "round_gap_p95_ms": 85.454, + "tokens_per_chunk": 2.286 + }, + "completions": { + "truncated": 3 + }, + "timing_valid": true, + "end_to_end_tps": 33.199096629143575, + "makespan_s": 7.7110531909856945, + "alone": { + "equal": 3, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 4, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 33.9309778446927, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 7.7110531909856945, + "end_to_end_tps": 33.199096629143575, + "timing_valid": true, + "per_stream_tps": [ + 33.9 + ], + "ttft_s": [ + 0.2 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.1956903109967243, + "decode_tps": 33.9309778446927, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 163.52368104998135, + "prefill_tps": 163.52368104998135, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.471593909764515, + "round_gap_p50_ms": 62.82071801251732, + "round_gap_p95_ms": 93.42675202060491, + "tokens_per_chunk": 2.2857142857142856, + "headers_s": 0.0010319899884052575, + "first_payload_s": 0.0010357979917898774, + "first_content_s": 0.1956903109967243, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.1956903109967243, + "last_output_s": 7.710946757986676 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.471593909764515, + "round_gap_p50_ms": 62.82071801251732, + "round_gap_p95_ms": 93.42675202060491, + "round_gap_mean_ms": 67.70501303594551, + "tokens_per_chunk": 2.2857142857142856, + "aggregate_prompt_ttft_tps": 163.52368104998135, + "aggregate_prefill_tps": 163.52368104998135 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258703.874580244, + "first": 258704.070270555, + "last": 258711.585527002, + "end": 258711.585633435, + "elapsed_s": 7.7110531909856945, + "chunk_offsets_s": [ + 0.1956903109967243, + 0.2599684779997915, + 0.3224370809912216, + 0.38521664700238034, + 0.44757521798601374, + 0.5095286339928862, + 0.5698125839990098, + 0.6372221619822085, + 0.7306489140028134, + 0.8228671459946781, + 0.8994525430025533, + 0.9711763089871965, + 1.0413677449978422, + 1.1060213379969355, + 1.173119618993951, + 1.257221159990877, + 1.370531125983689, + 1.4761481779860333, + 1.5858014329860453, + 1.7101368599978741, + 1.8279280540009495, + 1.916887337982189, + 2.0025866639916785, + 2.0881018139771186, + 2.1795866809843574, + 2.237819178000791, + 2.29186187198502, + 2.3558615740039386, + 2.4268624389951583, + 2.484692358004395, + 2.537087042001076, + 2.599904031987535, + 2.6708777449966874, + 2.7349115909892134, + 2.794960675004404, + 2.857902945979731, + 2.9186448819818906, + 2.981465599994408, + 3.0420712159830146, + 3.104326698987279, + 3.1730321579962038, + 3.235027799004456, + 3.2964784119976684, + 3.357207388995448, + 3.416445348004345, + 3.479474722989835, + 3.540615510981297, + 3.6029502419987693, + 3.672468905977439, + 3.732549078995362, + 3.7914464119821787, + 3.853652053978294, + 3.9153626849874854, + 3.9770218109770212, + 4.036568316980265, + 4.102044011990074, + 4.171282097988296, + 4.233000072999857, + 4.294874257000629, + 4.3559459559910465, + 4.419190500979312, + 4.4822765970020555, + 4.544979361991864, + 4.604590715985978, + 4.670804383989889, + 4.731262478977442, + 4.791071241983445, + 4.853524820995517, + 4.91048846198828, + 4.971545073000016, + 5.0331085349898785, + 5.09403525700327, + 5.1643909190024715, + 5.234723684989149, + 5.304791776987258, + 5.3746710999985225, + 5.443374047987163, + 5.515154917986365, + 5.57648445898667, + 5.648878693988081, + 5.7184753109759185, + 5.788630572002148, + 5.860514370986493, + 5.927035896980669, + 5.993176460004179, + 6.063505737984087, + 6.129109129979042, + 6.205652094999095, + 6.285215287003666, + 6.353834921988891, + 6.4155765140021686, + 6.475066794984741, + 6.534893653995823, + 6.595311732991831, + 6.655206080991775, + 6.717359210975701, + 6.784287171001779, + 6.845682327984832, + 6.905921237979783, + 6.965316878980957, + 7.025281930982601, + 7.084224464982981, + 7.143320503004361, + 7.205797058995813, + 7.274251636990812, + 7.333875135984272, + 7.395111588004511, + 7.459640124987345, + 7.52261266799178, + 7.585928925982444, + 7.65538429399021, + 7.710946757986676 + ], + "chunk_gaps_ms": { + "count": 111, + "p50": 62.82071801251732, + "p95": 93.42675202060491, + "max": 124.33542701182887 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 35.18239021353922, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 7.444510743982391, + "end_to_end_tps": 34.387753447321174, + "timing_valid": true, + "per_stream_tps": [ + 35.2 + ], + "ttft_s": [ + 0.2 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.19644758198410273, + "decode_tps": 35.18239021353922, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 162.89332592848896, + "prefill_tps": 162.89332592848896, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 28.423310466699633, + "round_gap_p50_ms": 63.87448601890355, + "round_gap_p95_ms": 73.70974798686802, + "tokens_per_chunk": 2.2857142857142856, + "headers_s": 0.0013563130050897598, + "first_payload_s": 0.0013599130033981055, + "first_content_s": 0.19644758198410273, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19644758198410273, + "last_output_s": 7.444391750992509 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 28.423310466699633, + "round_gap_p50_ms": 63.87448601890355, + "round_gap_p95_ms": 73.70974798686802, + "round_gap_mean_ms": 65.29679431539104, + "tokens_per_chunk": 2.2857142857142856, + "aggregate_prompt_ttft_tps": 162.89332592848896, + "aggregate_prefill_tps": 162.89332592848896 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258711.58673797, + "first": 258711.783185552, + "last": 258719.031129721, + "end": 258719.031248714, + "elapsed_s": 7.444510743982391, + "chunk_offsets_s": [ + 0.19644758198410273, + 0.27053395498660393, + 0.34245535600348376, + 0.41073820399469696, + 0.47577645699493587, + 0.5518552110006567, + 0.6210750899917912, + 0.6864879209897481, + 0.7569883679971099, + 0.8292591949866619, + 0.898452305002138, + 0.9585161739960313, + 1.021877503982978, + 1.0851352169993334, + 1.1547011469956487, + 1.2228443310013972, + 1.2956530329829548, + 1.3613458329928108, + 1.4275891330034938, + 1.4973214799829293, + 1.5687960129871499, + 1.6354809959884733, + 1.7032758739951532, + 1.7774404409865383, + 1.8537733409903012, + 1.9161729849874973, + 1.9771338989958167, + 2.038178318005521, + 2.1010767970001325, + 2.1622694419929758, + 2.2211889349855483, + 2.285063421004452, + 2.3562882079859264, + 2.4205978800018784, + 2.4809287909884006, + 2.5436663569998927, + 2.604014323995216, + 2.6650520069815684, + 2.7260144900064915, + 2.7879693629802205, + 2.857081977999769, + 2.920037144998787, + 2.981776592991082, + 3.0424306739878375, + 3.1019649549853057, + 3.1659072490001563, + 3.2273931590025313, + 3.289325983991148, + 3.3579849319939967, + 3.4187120689894073, + 3.4779505250044167, + 3.5409300119790714, + 3.6038462840078864, + 3.6665025370020885, + 3.7262796529976185, + 3.7909015670011286, + 3.8607451299903914, + 3.9251015379850287, + 3.995083005982451, + 4.06748292199336, + 4.140571033989545, + 4.213654185994528, + 4.2839754479937255, + 4.3523112410039175, + 4.424455170985311, + 4.494530288007809, + 4.561627529998077, + 4.6303992939938325, + 4.702870249981061, + 4.773053783981595, + 4.834289980994072, + 4.903558227990288, + 4.978477872005897, + 5.0510563800053205, + 5.120793846988818, + 5.190568546007853, + 5.264278293994721, + 5.3306628270074725, + 5.394647840992548, + 5.455521203984972, + 5.525159501994494, + 5.587229480006499, + 5.650428008986637, + 5.709948290983448, + 5.771181607997278, + 5.830808914004592, + 5.890818062995095, + 5.957010722981067, + 6.027081328007625, + 6.087612225004705, + 6.1500879649829585, + 6.209918968990678, + 6.269631635979749, + 6.330501030985033, + 6.390583683998557, + 6.453227649995824, + 6.520481260988163, + 6.581826529989485, + 6.645301460986957, + 6.704915391979739, + 6.765124509984162, + 6.824372629984282, + 6.8830544269876555, + 6.946612478990573, + 7.014685039001051, + 7.0744201699853875, + 7.135116124001797, + 7.200449433992617, + 7.263614170980873, + 7.324828911980148, + 7.385066527000163, + 7.444391750992509 + ], + "chunk_gaps_ms": { + "count": 111, + "p50": 63.87448601890355, + "p95": 73.70974798686802, + "max": 76.33290000376292 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 33.90549855821617, + "requested_requests": 1, + "timed_requests": 1, + "makespan_s": 7.715454427001532, + "end_to_end_tps": 33.180158397940225, + "timing_valid": true, + "per_stream_tps": [ + 33.9 + ], + "ttft_s": [ + 0.19 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.19443424299242906, + "decode_tps": 33.90549855821617, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 164.5800632003182, + "prefill_tps": 164.5800632003182, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.493741207874802, + "round_gap_p50_ms": 66.52115899487399, + "round_gap_p95_ms": 85.45435100677423, + "tokens_per_chunk": 2.2857142857142856, + "headers_s": 0.0009291419992223382, + "first_payload_s": 0.0009311579924542457, + "first_content_s": 0.19443424299242906, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19443424299242906, + "last_output_s": 7.715338251000503 + } + ], + "pooled": { + "streams_timed": 1, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 29.493741207874802, + "round_gap_p50_ms": 66.52115899487399, + "round_gap_p95_ms": 85.45435100677423, + "round_gap_mean_ms": 67.7558919640367, + "tokens_per_chunk": 2.2857142857142856, + "aggregate_prompt_ttft_tps": 164.5800632003182, + "aggregate_prefill_tps": 164.5800632003182 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258719.032040655, + "first": 258719.226474898, + "last": 258726.747378906, + "end": 258726.747495082, + "elapsed_s": 7.715454427001532, + "chunk_offsets_s": [ + 0.19443424299242906, + 0.26861058600479737, + 0.34089598900754936, + 0.4092324390076101, + 0.4738642099837307, + 0.5474244689976331, + 0.616422266990412, + 0.6833881479979027, + 0.7609114249935374, + 0.8313664640008938, + 0.901827711990336, + 0.9684218629845418, + 1.0336051729973406, + 1.1065788039995823, + 1.1733379639917985, + 1.236442077002721, + 1.318430613988312, + 1.3885309470060747, + 1.4620129019895103, + 1.5295055389869958, + 1.594424095004797, + 1.660945253999671, + 1.7285979560110718, + 1.8026897860108875, + 1.8789091499929782, + 1.9406218939984683, + 2.002447470993502, + 2.063097297010245, + 2.126003823999781, + 2.1864598079991993, + 2.2492934399924707, + 2.3131024049944244, + 2.384616074996302, + 2.448656177992234, + 2.50877278400003, + 2.5708827629860025, + 2.631123994011432, + 2.691359255986754, + 2.7526679179864004, + 2.8147049999970477, + 2.8835772940074094, + 2.9464519169996493, + 3.0080168040003628, + 3.071574295987375, + 3.1309140810044482, + 3.1940720030106604, + 3.255948971986072, + 3.3178116850031074, + 3.386574650008697, + 3.4474500929936767, + 3.506189698004164, + 3.567631576996064, + 3.6294233450025786, + 3.6911159929877613, + 3.751724330999423, + 3.8164206619840115, + 3.88604899198981, + 3.9505921700038016, + 4.020488118985668, + 4.093436277995352, + 4.16616978100501, + 4.239849081001012, + 4.310073622997152, + 4.3785446670081, + 4.447805075003998, + 4.517596269986825, + 4.58494298599544, + 4.653735631989548, + 4.725925770995673, + 4.7956853339856025, + 4.856872058997396, + 4.925070299999788, + 5.000448251987109, + 5.07058701699134, + 5.139453518990194, + 5.2088831450091675, + 5.285394734994043, + 5.360192091000499, + 5.431005741003901, + 5.503673242987134, + 5.595022863999475, + 5.680477215006249, + 5.762738474004436, + 5.865657368005486, + 5.963826424005674, + 6.042460716009373, + 6.138647151994519, + 6.233670187997632, + 6.306720157008385, + 6.368678550992627, + 6.428164785000263, + 6.488879779004492, + 6.549418100010371, + 6.608603308006423, + 6.668693818006432, + 6.7324906399881, + 6.7990963910124265, + 6.860929888993269, + 6.920697116991505, + 6.9808163630077615, + 7.0406005030090455, + 7.099795296002412, + 7.158420277002733, + 7.2216047259862535, + 7.289612838998437, + 7.349000896996586, + 7.409778995002853, + 7.4751249630062375, + 7.53808245100663, + 7.599032694997732, + 7.659133893001126, + 7.715338251000503 + ], + "chunk_gaps_ms": { + "count": 111, + "p50": 66.52115899487399, + "p95": 85.45435100677423, + "max": 102.91889400104992 + } + } + ], + "equal_alone": [ + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + } + ] + }, + { + "prompt": "chat", + "temperature": 1.0, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 2, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 44.7, + "per_stream_tps": 22.6, + "ttft_s_max": 0.4, + "request": { + "ttft_s": 0.289, + "decode_tps": 22.622, + "prompt_ttft_tps": 123.626, + "prefill_tps": 123.626, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.207, + "round_gap_p50_ms": 106.359, + "round_gap_p95_ms": 135.958, + "tokens_per_chunk": 2.462, + "headers_s": 0.002, + "first_payload_s": 0.002, + "first_content_s": 0.289, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.289, + "last_output_s": 11.604 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 166.007, + "aggregate_prefill_tps": 166.007, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.33, + "round_gap_p50_ms": 106.335, + "round_gap_p95_ms": 137.45, + "tokens_per_chunk": 2.462 + }, + "completions": { + "truncated": 6 + }, + "timing_valid": true, + "end_to_end_tps": 44.12097789870904, + "makespan_s": 11.604457207984524, + "steady_tps": 45.7, + "alone": { + "equal": 6, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 4, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 46.246516119836194, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 11.22162055701483, + "end_to_end_tps": 45.62620856752636, + "timing_valid": true, + "steady_tps": 46.889351171948654, + "per_stream_tps": [ + 23.1, + 23.5 + ], + "ttft_s": [ + 0.19, + 0.38 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.19357806400512345, + "decode_tps": 23.124771726643537, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 165.30798654517514, + "prefill_tps": 165.30798654517514, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 43.243670113631254, + "round_gap_p50_ms": 105.97624201909639, + "round_gap_p95_ms": 111.59175098873675, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0008655099954921752, + "first_payload_s": 0.0008677019795868546, + "first_content_s": 0.19357806400512345, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19357806400512345, + "last_output_s": 11.220713942981092 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.38344107900047675, + "decode_tps": 23.528183351443527, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 83.45480375606864, + "prefill_tps": 83.45480375606864, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 42.50221893730044, + "round_gap_p50_ms": 105.86318699643016, + "round_gap_p95_ms": 111.3554929906968, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0014626969932578504, + "first_payload_s": 0.001466921006795019, + "first_content_s": 0.38344107900047675, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.38344107900047675, + "last_output_s": 11.221506908012088 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 42.87294452546585, + "round_gap_p50_ms": 105.87008198490366, + "round_gap_p95_ms": 111.45791001035832, + "round_gap_mean_ms": 106.14175586401738, + "tokens_per_chunk": 2.4615384615384617, + "aggregate_prompt_ttft_tps": 166.90960751213728, + "aggregate_prefill_tps": 166.90960751213728 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258726.748750786, + "first": 258726.94232885, + "last": 258737.969464729, + "end": 258737.96961385, + "elapsed_s": 11.22086306399433, + "chunk_offsets_s": [ + 0.19357806400512345, + 0.4780868490051944, + 0.58217682299437, + 0.6890996639849618, + 0.7950759060040582, + 0.901059299998451, + 1.004605847003404, + 1.1115991830010898, + 1.216212617000565, + 1.321342901996104, + 1.428784032992553, + 1.532500084984349, + 1.6349089449795429, + 1.7450149570067879, + 1.8451621379936114, + 1.947298340004636, + 2.055975783994654, + 2.1627556949970312, + 2.2693400209827814, + 2.3760429880057927, + 2.4820965429826174, + 2.5801307990041096, + 2.6831913749920204, + 2.785952381003881, + 2.894986514991615, + 3.004093544994248, + 3.1116806780046318, + 3.2141762579849456, + 3.3214063009945676, + 3.4261016229866073, + 3.534272007003892, + 3.6449485839984845, + 3.7581531289906707, + 3.8628380830050446, + 3.967731709999498, + 4.072391928988509, + 4.175836234993767, + 4.284562446991913, + 4.393925095006125, + 4.509729768993566, + 4.61522997598513, + 4.725978361006128, + 4.840952372993343, + 4.948001726996154, + 5.0551511450030375, + 5.168028647982283, + 5.275354946992593, + 5.383558979985537, + 5.485823678987799, + 5.593840510991868, + 5.700388452998595, + 5.809088762005558, + 5.920116380992113, + 6.022512488998473, + 6.128382570983376, + 6.238635688991053, + 6.347076186997583, + 6.452670651982771, + 6.557980266981758, + 6.659530161006842, + 6.766665707982611, + 6.870071982004447, + 6.9700039949966595, + 7.074884550995193, + 7.182944806991145, + 7.289885215985123, + 7.389113543991698, + 7.4928565729933325, + 7.598369916988304, + 7.700931834988296, + 7.8072379200020805, + 7.91455010700156, + 8.019992187008029, + 8.119738982000854, + 8.218989023007452, + 8.32398799600196, + 8.427612383995438, + 8.531956168997567, + 8.635276058979798, + 8.741428142995574, + 8.840360998001415, + 8.951952748990152, + 9.057947839988628, + 9.163072781986557, + 9.270367577002617, + 9.375480982998852, + 9.476668747985968, + 9.575328592996811, + 9.682692828995641, + 9.791070959996432, + 9.897627990983892, + 10.000140339980135, + 10.108386965992395, + 10.213948005985003, + 10.320932159986114, + 10.42546908298391, + 10.52716337898164, + 10.629136317002121, + 10.73770190498908, + 10.844547418004368, + 10.954635239992058, + 11.060308729007374, + 11.153634235990467, + 11.220713942981092 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 105.97624201909639, + "p95": 111.59175098873675, + "max": 284.50878500007093 + } + }, + { + "start": 258726.748679666, + "first": 258727.132120745, + "last": 258737.970186574, + "end": 258737.970300223, + "elapsed_s": 11.22162055701483, + "chunk_offsets_s": [ + 0.38344107900047675, + 0.4779725600092206, + 0.5820561980071943, + 0.6893189450202044, + 0.7949726250080857, + 0.9009573149960488, + 1.0047905670071486, + 1.1118283999967389, + 1.216429866006365, + 1.3212366920197383, + 1.4290320180007257, + 1.5326477980124764, + 1.6351048170181457, + 1.7449201559938956, + 1.8453967310197186, + 1.9474714930111077, + 2.056178073020419, + 2.1629485599987675, + 2.269522293994669, + 2.3763048780092504, + 2.4823012000124436, + 2.580076606012881, + 2.683388367993757, + 2.785937003995059, + 2.894867986004101, + 3.003971575992182, + 3.111654709005961, + 3.214383987011388, + 3.3216183170152362, + 3.426367800013395, + 3.5344776879937854, + 3.6449568239913788, + 3.758381065999856, + 3.8630473960074596, + 3.967904671008, + 4.072393031994579, + 4.176121101016179, + 4.284723504009889, + 4.393926663004095, + 4.5099075770122, + 4.615448249009205, + 4.726199418015312, + 4.841138806019444, + 4.947991982015083, + 5.0553572259959765, + 5.168310441018548, + 5.275240290007787, + 5.383724165003514, + 5.486087616009172, + 5.594091616017977, + 5.700579638010822, + 5.808966648008209, + 5.920424558018567, + 6.0227032090188, + 6.128574795991881, + 6.2388112420157995, + 6.346986746008042, + 6.452849933004472, + 6.558239628007868, + 6.659805875009624, + 6.766994269011775, + 6.869979948998662, + 6.9698686490010004, + 7.075031239015516, + 7.182951655006036, + 7.2901006570027675, + 7.389359544991748, + 7.493036366009619, + 7.598566589993425, + 7.701170620013727, + 7.807522577000782, + 7.9147305880032945, + 8.019984810991446, + 8.119980424002279, + 8.218955821997952, + 8.323961067013443, + 8.427792897011386, + 8.531963015993824, + 8.63525922599365, + 8.741663663997315, + 8.840602119016694, + 8.95195761200739, + 9.057949487993028, + 9.163270638993708, + 9.270610089995898, + 9.375666439998895, + 9.476544475008268, + 9.575560577999568, + 9.682949053996708, + 9.791358640999533, + 9.897821287013358, + 10.000385285005905, + 10.108578407001914, + 10.214148327009752, + 10.321189665992279, + 10.425653483020142, + 10.52704901000834, + 10.629333278018748, + 10.73793686600402, + 10.844733851001365, + 10.954813143995125, + 11.060548922017915, + 11.153500907006674, + 11.221506908012088 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 105.86318699643016, + "p95": 111.3554929906968, + "max": 115.98091400810517 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 44.702964441986175, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 11.604457207984524, + "end_to_end_tps": 44.12097789870904, + "timing_valid": true, + "steady_tps": 45.65680711610935, + "per_stream_tps": [ + 22.8, + 22.4 + ], + "ttft_s": [ + 0.4, + 0.2 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.40427036900655366, + "decode_tps": 22.768669002415916, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 79.15494790933155, + "prefill_tps": 79.15494790933155, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 43.92000252161832, + "round_gap_p50_ms": 106.40119097661227, + "round_gap_p95_ms": 136.78616800461896, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0017266670183744282, + "first_payload_s": 0.0017300590116064996, + "first_content_s": 0.40427036900655366, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.40427036900655366, + "last_output_s": 11.603871012019226 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.19536458898801357, + "decode_tps": 22.351748610812788, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 163.7963162401111, + "prefill_tps": 163.7963162401111, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.73922901567729, + "round_gap_p50_ms": 106.31654999451712, + "round_gap_p95_ms": 137.77764697442763, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.001593402004800737, + "first_payload_s": 0.0015965699858497828, + "first_content_s": 0.19536458898801357, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19536458898801357, + "last_output_s": 11.603867987985723 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.329615768647805, + "round_gap_p50_ms": 106.33531800704077, + "round_gap_p95_ms": 137.77764697442763, + "round_gap_mean_ms": 109.7480778738368, + "tokens_per_chunk": 2.4615384615384617, + "aggregate_prompt_ttft_tps": 158.2578524588575, + "aggregate_prefill_tps": 158.2578524588575 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258737.971556471, + "first": 258738.37582684, + "last": 258749.575427483, + "end": 258749.575880734, + "elapsed_s": 11.60432426299667, + "chunk_offsets_s": [ + 0.40427036900655366, + 0.518633754021721, + 0.6450899839983322, + 0.7760089310177136, + 0.9115949150000233, + 1.0469969310215674, + 1.181286203005584, + 1.323741639003856, + 1.463370161014609, + 1.6037288320076186, + 1.7430512249993626, + 1.8811277050117496, + 2.0179138730163686, + 2.1266530950088054, + 2.226369379000971, + 2.327060149022145, + 2.4368369930016343, + 2.544473296002252, + 2.650164065998979, + 2.7568172100000083, + 2.862749262014404, + 2.960726990015246, + 3.065648156014504, + 3.167265092022717, + 3.276925982994726, + 3.3849912650184706, + 3.4931998590182047, + 3.5957152650225908, + 3.702763372013578, + 3.8096559090190567, + 3.91719547501998, + 4.028436153021175, + 4.138833897013683, + 4.244044137012679, + 4.351053587015485, + 4.455194220005069, + 4.559046545997262, + 4.667928120994475, + 4.780080516997259, + 4.893155366007704, + 4.9999191670212895, + 5.1105077610118315, + 5.225526271009585, + 5.333330958994338, + 5.441040446021361, + 5.558129512995947, + 5.664062013005605, + 5.772692466009175, + 5.873680343007436, + 5.981453367014183, + 6.089065333013423, + 6.197197816014523, + 6.309338995022699, + 6.411531904013827, + 6.517470596008934, + 6.6269267500028946, + 6.734856207011035, + 6.842104012001073, + 6.948439330008114, + 7.052086936018895, + 7.158606592012802, + 7.262520535005024, + 7.365711946011288, + 7.469836627016775, + 7.577421713998774, + 7.683555511001032, + 7.78554131402052, + 7.890117518021725, + 7.991373044002103, + 8.094183061009971, + 8.199963096005376, + 8.308418956003152, + 8.413050905015552, + 8.51358772200183, + 8.617507362010656, + 8.721993676997954, + 8.82599144501728, + 8.929109543998493, + 9.033059695007978, + 9.138848307018634, + 9.23783410701435, + 9.34954395602108, + 9.453506956022466, + 9.558143016998656, + 9.665474070003256, + 9.768787050008541, + 9.871302361018024, + 9.969683277013246, + 10.076606840011664, + 10.181562022014987, + 10.285848208004609, + 10.388356959010707, + 10.496352432994172, + 10.60104870100622, + 10.706472703022882, + 10.81322218501009, + 10.912375218002126, + 11.013272919022711, + 11.119674109999323, + 11.225190463999752, + 11.334722219995456, + 11.439771723002195, + 11.53187080801581, + 11.603871012019226 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 106.40119097661227, + "p95": 136.78616800461896, + "max": 142.45543599827215 + } + }, + { + "start": 258737.971423526, + "first": 258738.166788115, + "last": 258749.575291514, + "end": 258749.575459083, + "elapsed_s": 11.604035556985764, + "chunk_offsets_s": [ + 0.19536458898801357, + 0.5185650019848254, + 0.6450201759871561, + 0.7762214280082844, + 0.9112778889830224, + 1.0469608980056364, + 1.181250714987982, + 1.3237096710072365, + 1.463327056990238, + 1.6036868160008453, + 1.7433964750089217, + 1.8811741219833493, + 2.017955218005227, + 2.126991817000089, + 2.226429554983042, + 2.3272629989951383, + 2.436867649987107, + 2.5445293439843226, + 2.6501795859949198, + 2.756846314005088, + 2.8629670229856856, + 2.960774446983123, + 3.065694299992174, + 3.167617478000466, + 3.276939614996081, + 3.3852810749958735, + 3.4935310290020425, + 3.596043074998306, + 3.702427609998267, + 3.80930384300882, + 3.9171698429854587, + 4.028105990990298, + 4.138901801983593, + 4.2442784259910695, + 4.3513682300108485, + 4.454852969996864, + 4.5592716519895475, + 4.668221658997936, + 4.780447142984485, + 4.892806883988669, + 4.999554732989054, + 5.110120413999539, + 5.22518070100341, + 5.333316447009565, + 5.440731563983718, + 5.557822311006021, + 5.664382079005009, + 5.772364144999301, + 5.8736202949949075, + 5.98177597700851, + 6.089090405992465, + 6.197158806986408, + 6.308983169001294, + 6.411490094993496, + 6.517093136993935, + 6.6269039979961235, + 6.735193408996565, + 6.841739146009786, + 6.948055696004303, + 7.052320538001368, + 7.158272397995461, + 7.262468742992496, + 7.366033211990725, + 7.470099989004666, + 7.5773550249869, + 7.683585366990883, + 7.7859280850098, + 7.889728667010786, + 7.991372404008871, + 8.094487975002266, + 8.200197049998678, + 8.30847966100555, + 8.413110057008453, + 8.513590330985608, + 8.617543586005922, + 8.722056894010166, + 8.826315110985888, + 8.929172631993424, + 9.032949102984276, + 9.138826531008817, + 9.237767515005544, + 9.349220322998008, + 9.453153401991585, + 9.55840781799634, + 9.66512861198862, + 9.768833337991964, + 9.871293225005502, + 9.969746796996333, + 10.076671576010995, + 10.18162434300757, + 10.286146722006379, + 10.38862360100029, + 10.496672114997637, + 10.601368431991432, + 10.706782736990135, + 10.81323215298471, + 10.912344834010582, + 11.013637385010952, + 11.119921472010901, + 11.225241776992334, + 11.334790252993116, + 11.440036588988733, + 11.532095097005367, + 11.603867987985723 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 106.31654999451712, + "p95": 137.77764697442763, + "max": 323.2004129968118 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 44.2083581084609, + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 11.732129148003878, + "end_to_end_tps": 43.6408424712161, + "timing_valid": true, + "steady_tps": 45.01050481257033, + "per_stream_tps": [ + 22.1, + 22.5 + ], + "ttft_s": [ + 0.19, + 0.39 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.19486169298761524, + "decode_tps": 22.10417905423045, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 164.21903920353301, + "prefill_tps": 164.21903920353301, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 45.24031394907712, + "round_gap_p50_ms": 107.43047899450175, + "round_gap_p95_ms": 138.1076359830331, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0015034329844638705, + "first_payload_s": 0.0015062489837873727, + "first_content_s": 0.19486169298761524, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19486169298761524, + "last_output_s": 11.73114175000228 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.38552646301104687, + "decode_tps": 22.475317146652614, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 83.0033812726445, + "prefill_tps": 83.0033812726445, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.49325424308578, + "round_gap_p50_ms": 107.17322898562998, + "round_gap_p95_ms": 135.1306409924291, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0019154040201101452, + "first_payload_s": 0.0019180280214641243, + "first_content_s": 0.38552646301104687, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.38552646301104687, + "last_output_s": 11.731306294997921 + } + ], + "pooled": { + "streams_timed": 2, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 44.866784096081446, + "round_gap_p50_ms": 107.38353498163633, + "round_gap_p95_ms": 137.45017600012943, + "round_gap_mean_ms": 111.07796062622106, + "tokens_per_chunk": 2.4615384615384617, + "aggregate_prompt_ttft_tps": 166.006762545289, + "aggregate_prefill_tps": 166.006762545289 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258749.577301415, + "first": 258749.772163108, + "last": 258761.308443165, + "end": 258761.308563662, + "elapsed_s": 11.73126224699081, + "chunk_offsets_s": [ + 0.19486169298761524, + 0.4806703829963226, + 0.5852981869829819, + 0.6893949160003103, + 0.7947330930037424, + 0.9011231169861276, + 1.0067736959899776, + 1.1150165319850203, + 1.2217283500067424, + 1.3263887630018871, + 1.4314600900106598, + 1.5343323629931547, + 1.6382569480047096, + 1.7492429690028075, + 1.84796847999678, + 1.9489505969977472, + 2.056381075992249, + 2.1641245640057605, + 2.2737748329818714, + 2.3803478019835893, + 2.487067604990443, + 2.5855075779836625, + 2.690988924005069, + 2.792774006986292, + 2.9016174220014364, + 3.010931097000139, + 3.1220512639847584, + 3.224671487987507, + 3.3312987129902467, + 3.4369776929961517, + 3.5444165079970844, + 3.656212581990985, + 3.7681793619995005, + 3.874105207010871, + 3.979593322001165, + 4.08285414200509, + 4.187466075003613, + 4.295193227997515, + 4.404991290008184, + 4.519071458984399, + 4.627351319999434, + 4.73879326399765, + 4.853297739988193, + 4.9611702539841644, + 5.068227467010729, + 5.181650112004718, + 5.287977080006385, + 5.396904656983679, + 5.498922108992701, + 5.60659911800758, + 5.714097741001751, + 5.821886430989252, + 5.93372768998961, + 6.035919783986174, + 6.144065355008934, + 6.255565556988586, + 6.363181316992268, + 6.470264817995485, + 6.576692747010384, + 6.6802902089839336, + 6.785821236000629, + 6.890161279996391, + 6.99105864498415, + 7.0950059659953695, + 7.204043543984881, + 7.311857530003181, + 7.411394886003109, + 7.515163757983828, + 7.6188125330081675, + 7.72371763701085, + 7.831101171992486, + 7.940041149005992, + 8.047634157002904, + 8.16237506698235, + 8.283969124982832, + 8.417557612003293, + 8.550354637991404, + 8.68466210499173, + 8.818597122008214, + 8.957321049994789, + 9.08636320399819, + 9.230136395985028, + 9.363899891992332, + 9.501338292000582, + 9.641364579991205, + 9.781566404999467, + 9.908296816982329, + 10.036260244000005, + 10.174367879983038, + 10.304138854000485, + 10.407775197993033, + 10.510770864988444, + 10.619403304008301, + 10.724223447003169, + 10.82873971699155, + 10.934096502984175, + 11.033314978005365, + 11.134055654983968, + 11.243312962993514, + 11.350309711997397, + 11.462898783996934, + 11.569038487999933, + 11.663055042008637, + 11.73114175000228 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 107.43047899450175, + "p95": 138.1076359830331, + "max": 285.80869000870734 + } + }, + { + "start": 258749.577007525, + "first": 258749.962533988, + "last": 258761.30831382, + "end": 258761.309136673, + "elapsed_s": 11.732129148003878, + "chunk_offsets_s": [ + 0.38552646301104687, + 0.4810425130126532, + 0.5856780620233621, + 0.6898581830027979, + 0.7951961680082604, + 0.9014924960210919, + 1.007148322998546, + 1.1153885340027045, + 1.2221916330163367, + 1.3268491660128348, + 1.4316648750100285, + 1.5347227020247374, + 1.6386418620240875, + 1.7496117550181225, + 1.848341650009388, + 1.9493362640205305, + 2.056822375016054, + 2.1645135750004556, + 2.2743432050046977, + 2.380575260001933, + 2.487464327015914, + 2.5858624120010063, + 2.6911275809979998, + 2.7932188100239728, + 2.9020011050160974, + 3.0114078360202257, + 3.1225667870021425, + 3.2251372350146994, + 3.331698492023861, + 3.4371722860087175, + 3.554518156015547, + 3.656686073023593, + 3.7685363730124664, + 3.874236200004816, + 3.979726715013385, + 4.083331553003518, + 4.187587756023277, + 4.29528239602223, + 4.405371180007933, + 4.519452325999737, + 4.627455384004861, + 4.739238739013672, + 4.853744574997108, + 4.961527361010667, + 5.068700589996297, + 5.182119971024804, + 5.288436714996351, + 5.397441748005804, + 5.499021230003564, + 5.606776271015406, + 5.714254782011267, + 5.822041520004859, + 5.933870075008599, + 6.036054857017007, + 6.144245389004936, + 6.2557460220123176, + 6.363373110012617, + 6.470441170997219, + 6.576881772023626, + 6.680369538022205, + 6.785932997008786, + 6.89035628901911, + 6.99125445500249, + 7.095171904016752, + 7.204203305009287, + 7.31201585099916, + 7.411499623005511, + 7.515334559022449, + 7.618978823011275, + 7.723860598023748, + 7.831285173015203, + 7.940201022021938, + 8.047782270004973, + 8.162850846012589, + 8.284072662005201, + 8.417712285008747, + 8.550464847008698, + 8.6847826980229, + 8.81868758701603, + 8.957476555020548, + 9.086459940997884, + 9.230231485009426, + 9.36402006901335, + 9.50147024501348, + 9.641488773020683, + 9.776619414013112, + 9.90844264201587, + 10.036400133016286, + 10.174475848005386, + 10.304243047023192, + 10.407896543008974, + 10.510920497996267, + 10.619583482010057, + 10.724385321023874, + 10.82887558999937, + 10.934218088019406, + 11.03344990700134, + 11.134221960004652, + 11.243457524018595, + 11.350438129011309, + 11.463072226004442, + 11.569165113003692, + 11.6632069949992, + 11.731306294997921 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 107.17322898562998, + "p95": 135.1306409924291, + "max": 143.77154401154257 + } + } + ], + "equal_alone": [ + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + } + ] + }, + { + "prompt": "chat", + "temperature": 1.0, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "streams": 4, + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.3, + "per_stream_tps": 14.4, + "ttft_s_max": 0.78, + "request": { + "ttft_s": 0.486, + "decode_tps": 14.469, + "prompt_ttft_tps": 68.267, + "prefill_tps": 68.267, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.112, + "round_gap_p50_ms": 167.721, + "round_gap_p95_ms": 210.443, + "tokens_per_chunk": 2.462, + "headers_s": 0.003, + "first_payload_s": 0.003, + "first_content_s": 0.486, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.486, + "last_output_s": 18.138 + }, + "pooled": { + "aggregate_prompt_ttft_tps": 165.72, + "aggregate_prefill_tps": 165.72, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.176, + "round_gap_p50_ms": 167.703, + "round_gap_p95_ms": 212.379, + "tokens_per_chunk": 2.456 + }, + "completions": { + "truncated": 12 + }, + "timing_valid": true, + "end_to_end_tps": 55.909513358104235, + "makespan_s": 18.31530876402394, + "steady_tps": 58.0, + "alone": { + "equal": 12, + "unequal": 0, + "failed": 0 + }, + "serial": { + "equal": 4, + "unequal": 0, + "failed": 0 + }, + "reps": [ + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.291250481829884, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 18.31530876402394, + "end_to_end_tps": 55.909513358104235, + "timing_valid": true, + "steady_tps": 58.18843339699829, + "per_stream_tps": [ + 14.7, + 14.2, + 14.7, + 14.2 + ], + "ttft_s": [ + 0.77, + 0.2, + 0.58, + 0.39 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.7714232919970527, + "decode_tps": 14.683048820766597, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 41.481765370551265, + "prefill_tps": 41.481765370551265, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 68.10574644318253, + "round_gap_p50_ms": 167.66931398888119, + "round_gap_p95_ms": 201.84615900507197, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0027016329986508936, + "first_payload_s": 0.0027197290037292987, + "first_content_s": 0.7714232919970527, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.7714232919970527, + "last_output_s": 18.138388635008596 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.19505824099178426, + "decode_tps": 14.211314997653297, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 164.05356593648264, + "prefill_tps": 164.05356593648264, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 70.36646504318068, + "round_gap_p50_ms": 167.67713901936077, + "round_gap_p95_ms": 212.26308998302557, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0021817100059706718, + "first_payload_s": 0.0021960620069876313, + "first_content_s": 0.19505824099178426, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19505824099178426, + "last_output_s": 18.138506827002857 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.579350029991474, + "decode_tps": 14.723236267268785, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 55.234311458430284, + "prefill_tps": 55.234311458430284, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 67.91985008235582, + "round_gap_p50_ms": 167.87755500990897, + "round_gap_p95_ms": 212.426306999987, + "tokens_per_chunk": 2.5098039215686274, + "headers_s": 0.0018850679916795343, + "first_payload_s": 0.0018883959855884314, + "first_content_s": 0.579350029991474, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.579350029991474, + "last_output_s": 17.89891180099221 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.3852264510060195, + "decode_tps": 14.221990951004026, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 83.06802379855264, + "prefill_tps": 83.06802379855264, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 70.31364338826297, + "round_gap_p50_ms": 167.61523502646014, + "round_gap_p95_ms": 212.3790750047192, + "tokens_per_chunk": 2.392523364485981, + "headers_s": 0.0026264970074407756, + "first_payload_s": 0.0026299210148863494, + "first_content_s": 0.3852264510060195, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3852264510060195, + "last_output_s": 18.315205515013076 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.1764262392455, + "round_gap_p50_ms": 167.70257899770513, + "round_gap_p95_ms": 212.3790750047192, + "round_gap_mean_ms": 170.84734809692594, + "tokens_per_chunk": 2.4556354916067145, + "aggregate_prompt_ttft_tps": 165.86553655576355, + "aggregate_prefill_tps": 165.86553655576355 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3672ac37f298", + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "fb6e67c7120b", + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258761.31110507, + "first": 258762.082528362, + "last": 258779.449493705, + "end": 258779.449841547, + "elapsed_s": 18.138736477005295, + "chunk_offsets_s": [ + 0.7714232919970527, + 0.8948765300156083, + 1.0287317399925087, + 1.1806068560108542, + 1.3333613380091265, + 1.4900460859935265, + 1.6404623769922182, + 1.8043892990099266, + 1.9618520039948635, + 2.1191672190034296, + 2.288485760014737, + 2.4555728300183546, + 2.6235247220029123, + 2.8056194730161224, + 2.971380103001138, + 3.1389633679937106, + 3.306415785016725, + 3.4704935240151826, + 3.644994914007839, + 3.8134672899905127, + 3.981650414993055, + 4.140659305994632, + 4.30901828900096, + 4.472535561013501, + 4.64518410700839, + 4.815491262997966, + 4.985612624994246, + 5.150777923990972, + 5.31824485299876, + 5.4841232119943015, + 5.655518949992256, + 5.831711728009395, + 6.0011353740119375, + 6.171925605012802, + 6.339594919001684, + 6.5073674989980645, + 6.677657549997093, + 6.847560719994362, + 7.015320578997489, + 7.186281066999072, + 7.352109667001059, + 7.526692290004576, + 7.699281987996073, + 7.864246614015428, + 8.031353989994386, + 8.203114659001585, + 8.373667400999693, + 8.543889980006497, + 8.705308200005675, + 8.870819917006884, + 9.042260201007593, + 9.21011260501109, + 9.38456236399361, + 9.553960971010383, + 9.732553108013235, + 9.904289010009961, + 10.070169434009586, + 10.236616950016469, + 10.405668449995574, + 10.56729023900698, + 10.736140426015481, + 10.934500211005798, + 11.13634637001087, + 11.337765694013797, + 11.554386620002333, + 11.766594701999566, + 11.981652593996841, + 12.2001551160065, + 12.42243892600527, + 12.610399508004775, + 12.778441706992453, + 12.946906580007635, + 13.110292380995816, + 13.271114900999237, + 13.426959709002404, + 13.592667332995916, + 13.762442711013136, + 13.926582436019089, + 14.092515933007235, + 14.259581534017343, + 14.423689963005017, + 14.592920986004174, + 14.754784393007867, + 14.91845776399714, + 15.087615458003711, + 15.254744434991153, + 15.417435800016392, + 15.576027522009099, + 15.746031445014523, + 15.91109128901735, + 16.07819209099398, + 16.245623021997744, + 16.423821397998836, + 16.590372979990207, + 16.76075501801097, + 16.922628202009946, + 17.081857287994353, + 17.243066627997905, + 17.412008273007814, + 17.584612853010185, + 17.75183727199328, + 17.899472332006553, + 18.030465318006463, + 18.138388635008596 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 167.66931398888119, + "p95": 201.84615900507197, + "max": 222.28380999877118 + } + }, + { + "start": 258761.310921053, + "first": 258761.505979294, + "last": 258779.44942788, + "end": 258779.450132989, + "elapsed_s": 18.139211936009815, + "chunk_offsets_s": [ + 0.19505824099178426, + 0.894781970011536, + 1.0292006540112197, + 1.1805732560169417, + 1.3332795620081015, + 1.4901090140047017, + 1.6405340259952936, + 1.804465571010951, + 1.9619349639979191, + 2.1190539550152607, + 2.2885238559974823, + 2.455619246000424, + 2.623553970013745, + 2.8057334090117365, + 2.971469670999795, + 3.1388051109970547, + 3.3064442810136825, + 3.4702276820025872, + 3.6450498740014154, + 3.8133697530138306, + 3.9816080309974495, + 4.140352232003352, + 4.308882976009045, + 4.47259383299388, + 4.64509733801242, + 4.815550863015233, + 4.985532399994554, + 5.150611170014599, + 5.318244885012973, + 5.48469041500357, + 5.655558582016965, + 5.831974992994219, + 6.001253886002814, + 6.172037348995218, + 6.339714488014579, + 6.507295849994989, + 6.678402563004056, + 6.847642959997756, + 7.015882598992903, + 7.186365564004518, + 7.352229106996674, + 7.526807826012373, + 7.699407684995094, + 7.864267174009001, + 8.031427270005224, + 8.20324451601482, + 8.373735769011546, + 8.543817819998367, + 8.705308183009038, + 8.871475872991141, + 9.04231559301843, + 9.210236301994883, + 9.384677869005827, + 9.553746905003209, + 9.73291194200283, + 9.90427508900757, + 10.070188714016695, + 10.236615764995804, + 10.405674801993882, + 10.56727703899378, + 10.735624983004527, + 10.935096342000179, + 11.136107216007076, + 11.338190784998005, + 11.554452300013509, + 11.766715389996534, + 11.981933650997235, + 12.2002764439967, + 12.42255361500429, + 12.610512453014962, + 12.778559466998558, + 12.947017316997517, + 13.110418429016136, + 13.27123680600198, + 13.427053166000405, + 13.592694532999303, + 13.762482215010095, + 13.926698116993066, + 14.092578270006925, + 14.259646846010583, + 14.423630747012794, + 14.592856121016666, + 14.75475692100008, + 14.918589893000899, + 15.088238502008608, + 15.254756962996908, + 15.417293222009903, + 15.576162290992215, + 15.746123462013202, + 15.911134138004854, + 16.078167241998017, + 16.24570551799843, + 16.42391021401272, + 16.59046448400477, + 16.760846905992366, + 16.92272092201165, + 17.082239355018828, + 17.243315380997956, + 17.412121585017303, + 17.58470840600785, + 17.75197124000988, + 17.89984335799818, + 18.030896600015694, + 18.138506827002857 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 167.67713901936077, + "p95": 212.26308998302557, + "max": 699.7237290197518 + } + }, + { + "start": 258761.31178533, + "first": 258761.89113536, + "last": 258779.210697131, + "end": 258779.211046045, + "elapsed_s": 17.8992607149994, + "chunk_offsets_s": [ + 0.579350029991474, + 0.89411953400122, + 1.0278820539824665, + 1.1798533159890212, + 1.3327570149849635, + 1.4895719549967907, + 1.6399745979870204, + 1.8039043519820552, + 1.9613876329967752, + 2.118303069990361, + 2.2879959009878803, + 2.455087051988812, + 2.6230231509834994, + 2.8047629399807192, + 2.970896195998648, + 3.138082642981317, + 3.305960197991226, + 3.469504701992264, + 3.644481455005007, + 3.8126176210062113, + 3.9811539009970147, + 4.139783492981223, + 4.308141035988228, + 4.472036374005256, + 4.644683831982547, + 4.815005276002921, + 4.9847749559849035, + 5.149905517988373, + 5.317620240995893, + 5.483629416994518, + 5.654920562985353, + 5.830961530999048, + 6.0006913550023455, + 6.171590259007644, + 6.3390286279900465, + 6.506633637996856, + 6.677450461982517, + 6.847073980985442, + 7.014776559983147, + 7.185661447991151, + 7.351609567995183, + 7.526093805994606, + 7.6986967049888335, + 7.8635059380030725, + 8.030801794986473, + 8.202525503991637, + 8.373082534002606, + 8.543376841989812, + 8.7048598289839, + 8.870498731004773, + 9.041662837000331, + 9.209599257999798, + 9.383975768985692, + 9.553131157997996, + 9.732333827007096, + 9.903849839000031, + 10.069653174985433, + 10.23601065800176, + 10.405159582995111, + 10.566670522995992, + 10.734993235004367, + 10.934049375995528, + 11.135783214005642, + 11.337398731993744, + 11.553657240001485, + 11.766083547001472, + 11.981126270984532, + 12.199538391985698, + 12.422041963989614, + 12.609777025005314, + 12.77797112800181, + 12.946281471988186, + 13.109659032983473, + 13.270605522004189, + 13.426326536980923, + 13.591907024005195, + 13.761713938001776, + 13.926145329984138, + 14.09178178498405, + 14.25884689000668, + 14.42284267800278, + 14.592068676982308, + 14.754220197995892, + 14.917834143998334, + 15.087497553991852, + 15.254260479996447, + 15.416593859001296, + 15.57556302298326, + 15.745424161985284, + 15.910138820006978, + 16.077469862008, + 16.24512585098273, + 16.42332350698416, + 16.590234706993215, + 16.76026168698445, + 16.921992438001325, + 17.08141928599798, + 17.242714385996806, + 17.411368461005623, + 17.583999409980606, + 17.75123952399008, + 17.89891180099221 + ], + "chunk_gaps_ms": { + "count": 101, + "p50": 167.87755500990897, + "p95": 212.426306999987, + "max": 314.769504009746 + } + }, + { + "start": 258761.310818924, + "first": 258761.696045375, + "last": 258779.626024439, + "end": 258779.626127688, + "elapsed_s": 18.31530876402394, + "chunk_offsets_s": [ + 0.3852264510060195, + 0.8949982590274885, + 1.0292169430176727, + 1.1807372570037842, + 1.3334348110074643, + 1.4906210500048473, + 1.6410202690167353, + 1.805028791015502, + 1.96251432801364, + 2.1195111900160555, + 2.288851475022966, + 2.456138578010723, + 2.6238951410050504, + 2.8060421800182667, + 2.9717807290144265, + 3.138965240010293, + 3.3069929410121404, + 3.4706900540040806, + 3.645627478021197, + 3.813935645011952, + 3.9817926560062915, + 4.140573706012219, + 4.309490292012924, + 4.4731792450184, + 4.645304860023316, + 4.815893729013624, + 4.985954130999744, + 5.151120422000531, + 5.318438006012002, + 5.484843025013106, + 5.655725160002476, + 5.832332164020045, + 6.001725026027998, + 6.172481752000749, + 6.340096987027209, + 6.507536572025856, + 6.67819662601687, + 6.848171188001288, + 7.015825815004064, + 7.186824383010389, + 7.352721975010354, + 7.52717018101248, + 7.699748376006028, + 7.864598409010796, + 8.031707112008007, + 8.203933833021438, + 8.3741037560103, + 8.544104254018748, + 8.705281048023608, + 8.871261456020875, + 9.042761180025991, + 9.210620705009205, + 9.385042303008959, + 9.554453054006444, + 9.73321620002389, + 9.904910709999967, + 10.070790206023958, + 10.237077785015572, + 10.406514456000878, + 10.567503376019886, + 10.736553117021685, + 10.935119095025584, + 11.136414881999372, + 11.338216273026774, + 11.554840399010573, + 11.767219474015292, + 11.982278518000385, + 12.200945201009745, + 12.423320596019039, + 12.610826551011996, + 12.779032399004791, + 12.947437256021658, + 13.111072898027487, + 13.271501688024728, + 13.427347824006574, + 13.59302755902172, + 13.76314338701195, + 13.927510554000037, + 14.092980257002637, + 14.260033745027613, + 14.424354544025846, + 14.593568766023964, + 14.755261436017463, + 14.918988871009788, + 15.088612088002264, + 15.255347911006538, + 15.417629801027942, + 15.576594150013989, + 15.746475928026484, + 15.911312267009635, + 16.07837799601839, + 16.24650746001862, + 16.424415642017266, + 16.59109813600662, + 16.76162344001932, + 16.923016732005635, + 17.08255146900774, + 17.243622519017663, + 17.412408852018416, + 17.585119609022513, + 17.75225978702656, + 17.900117728015175, + 18.031109226023545, + 18.13900308700977, + 18.208669934014324, + 18.2660920790222, + 18.315205515013076 + ], + "chunk_gaps_ms": { + "count": 106, + "p50": 167.6349310146179, + "p95": 212.3790750047192, + "max": 509.77180802146904 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.39159950338021, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 18.28396483499091, + "end_to_end_tps": 56.00535820547639, + "timing_valid": true, + "steady_tps": 57.99678477620345, + "per_stream_tps": [ + 14.5, + 14.4, + 14.4, + 14.6 + ], + "ttft_s": [ + 0.58, + 0.39, + 0.2, + 0.77 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.5802379679807927, + "decode_tps": 14.54764424545626, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 55.14978640808158, + "prefill_tps": 55.14978640808158, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 68.7396518039225, + "round_gap_p50_ms": 167.78242500731722, + "round_gap_p95_ms": 207.13056498789228, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.002041596977505833, + "first_payload_s": 0.002045228990027681, + "first_content_s": 0.5802379679807927, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5802379679807927, + "last_output_s": 18.10884917798103 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.3862436009803787, + "decode_tps": 14.388050838459987, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 82.84926900737344, + "prefill_tps": 82.84926900737344, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.502117502042, + "round_gap_p50_ms": 167.9746959998738, + "round_gap_p95_ms": 207.01965302578174, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.0023686710046604276, + "first_payload_s": 0.0023721589823253453, + "first_content_s": 0.3862436009803787, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3862436009803787, + "last_output_s": 18.10928356400109 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.19589897102559917, + "decode_tps": 14.427921340056788, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 163.3495052703385, + "prefill_tps": 163.3495052703385, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.31005350186253, + "round_gap_p50_ms": 168.05612100870349, + "round_gap_p95_ms": 207.44023198494688, + "tokens_per_chunk": 2.5098039215686274, + "headers_s": 0.002017532999161631, + "first_payload_s": 0.0020344290242064744, + "first_content_s": 0.19589897102559917, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.19589897102559917, + "last_output_s": 17.869962614000542 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.7723859069810715, + "decode_tps": 14.561909656620381, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 41.43006716043592, + "prefill_tps": 41.43006716043592, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 68.67231177645462, + "round_gap_p50_ms": 167.7864560042508, + "round_gap_p95_ms": 205.42668300913647, + "tokens_per_chunk": 2.392523364485981, + "headers_s": 0.002874194993637502, + "first_payload_s": 0.0028777149855159223, + "first_content_s": 0.7723859069810715, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.7723859069810715, + "last_output_s": 18.283825409977 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.0560336460704, + "round_gap_p50_ms": 167.86861699074507, + "round_gap_p95_ms": 207.20155799062923, + "round_gap_mean_ms": 170.5500104576073, + "tokens_per_chunk": 2.4556354916067145, + "aggregate_prompt_ttft_tps": 165.72026864174367, + "aggregate_prefill_tps": 165.72026864174367 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3672ac37f298", + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "fb6e67c7120b", + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258779.628868121, + "first": 258780.209106089, + "last": 258797.737717299, + "end": 258797.738164598, + "elapsed_s": 18.109296476992313, + "chunk_offsets_s": [ + 0.5802379679807927, + 0.896798065979965, + 1.0321117829880677, + 1.1848780129803345, + 1.338355990999844, + 1.4944621299800929, + 1.648171982000349, + 1.8093874179758132, + 1.9687930019863416, + 2.125941835984122, + 2.295630478998646, + 2.462188764999155, + 2.631814703985583, + 2.8116576189931948, + 2.978678132989444, + 3.1477583079831675, + 3.3165186409896705, + 3.481688181986101, + 3.6571671499987133, + 3.8247923079761676, + 3.992592970986152, + 4.153508660994703, + 4.320741895993706, + 4.486088782985462, + 4.655841986997984, + 4.825784007989569, + 4.996081341989338, + 5.164251479989616, + 5.331553019990679, + 5.501893474982353, + 5.673147791996598, + 5.852061278972542, + 6.023858015978476, + 6.1971998819790315, + 6.365957879985217, + 6.534335090982495, + 6.7063510609732475, + 6.875944007973885, + 7.043701135000447, + 7.213629747973755, + 7.380235203978373, + 7.553362908976851, + 7.726353173988173, + 7.893413432990201, + 8.059668214991689, + 8.23161108099157, + 8.402428451983724, + 8.571094096987508, + 8.731666873994982, + 8.899396608991083, + 9.070694494992495, + 9.239752174995374, + 9.415610474999994, + 9.585560496983817, + 9.76517573199817, + 9.938745248975465, + 10.105592898995383, + 10.273161897988757, + 10.444009380997159, + 10.60476889598067, + 10.774536596989492, + 10.941551079973578, + 11.105627447977895, + 11.267727258993546, + 11.436491240980104, + 11.599724835978122, + 11.763137839996489, + 11.928230342979077, + 12.098018331977073, + 12.26514265598962, + 12.450676810985897, + 12.657807375973789, + 12.868545068980893, + 13.077292620990193, + 13.282290500996169, + 13.49814366697683, + 13.71876131198951, + 13.904751293972367, + 14.070802090980578, + 14.23791732697282, + 14.4023908659874, + 14.569542262994219, + 14.7306813649775, + 14.894321938976645, + 15.062048618972767, + 15.22982272398076, + 15.393117951985914, + 15.551533899997594, + 15.718314942991128, + 15.887127997993957, + 16.05240903099184, + 16.220659970975248, + 16.395549721986754, + 16.56094185897382, + 16.73082044199691, + 16.89163067797199, + 17.050279139977647, + 17.21274418698158, + 17.382976067980053, + 17.555651228991337, + 17.723433653998654, + 17.869598163990304, + 18.00069060898386, + 18.10884917798103 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 167.78242500731722, + "p95": 207.13056498789228, + "max": 316.5600979991723 + } + }, + { + "start": 258779.628357542, + "first": 258780.014601143, + "last": 258797.737641106, + "end": 258797.73793002, + "elapsed_s": 18.109572477987967, + "chunk_offsets_s": [ + 0.3862436009803787, + 0.8976164229970891, + 1.032508873991901, + 1.1852743189956527, + 1.3388109059887938, + 1.4949257169791963, + 1.645031800988363, + 1.8091195919841994, + 1.9693694379820954, + 2.126664944982622, + 2.2960388009960297, + 2.462882049003383, + 2.6326972369861323, + 2.8122286789875943, + 2.979275464982493, + 3.1479942289879546, + 3.3170731239952147, + 3.4823320739960764, + 3.657863026979612, + 3.8254135759780183, + 3.993388271977892, + 4.154149912996218, + 4.32130085999961, + 4.486025742982747, + 4.65641898199101, + 4.826497451984324, + 4.99636478399043, + 5.164612489985302, + 5.3322650239861105, + 5.502025458990829, + 5.673812499997439, + 5.852424672979396, + 6.02454322000267, + 6.197961711004609, + 6.366408889996819, + 6.534964981983649, + 6.707049304997781, + 6.876596747984877, + 7.044396866986062, + 7.214294247998623, + 7.380692021979485, + 7.553915008989861, + 7.727079866977874, + 7.893835978989955, + 8.060004647995811, + 8.232192315976135, + 8.403018807002809, + 8.571334545995342, + 8.732356989989057, + 8.900276439002482, + 9.071292370994342, + 9.240512243995909, + 9.416284702980192, + 9.586191412003245, + 9.765849175979383, + 9.939376164984424, + 10.106247878982686, + 10.273604843998328, + 10.444825209997362, + 10.60544790799031, + 10.775187991996063, + 10.941946249979082, + 11.106474076979794, + 11.268691600998864, + 11.437246909976238, + 11.60028355999384, + 11.763802259985823, + 11.928569544979837, + 12.098370349995093, + 12.266132485994603, + 12.451374062977266, + 12.658393716003047, + 12.86940830599633, + 13.077675390988588, + 13.282909064990235, + 13.498800150991883, + 13.719557012984296, + 13.905467793985736, + 14.071379934990546, + 14.238493266981095, + 14.403016358002787, + 14.570101050980156, + 14.731245656003011, + 14.894882566004526, + 15.062721598980715, + 15.23074159398675, + 15.393769155984046, + 15.552096047991654, + 15.719057298992993, + 15.887516544986283, + 16.053068010980496, + 16.22122677398147, + 16.39631494198693, + 16.561513734981418, + 16.73142028498114, + 16.892380682984367, + 17.050869895989308, + 17.21320542198373, + 17.383680807979545, + 17.556393584993202, + 17.724103401997127, + 17.870403976994567, + 18.001403524976922, + 18.10928356400109 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 167.9746959998738, + "p95": 207.01965302578174, + "max": 511.3728220167104 + } + }, + { + "start": 258779.628407158, + "first": 258779.824306129, + "last": 258797.498369772, + "end": 258797.499200098, + "elapsed_s": 17.87079294002615, + "chunk_offsets_s": [ + 0.19589897102559917, + 0.8972085650020745, + 1.0321732880256604, + 1.1851439990277868, + 1.3383813190157525, + 1.4947558920248412, + 1.6449292090255767, + 1.8090112400241196, + 1.9694391190132592, + 2.1264936160005163, + 2.2957143830135465, + 2.4627134570037015, + 2.632352771004662, + 2.812048230000073, + 2.9789664710115176, + 3.1478833650180604, + 3.316809906013077, + 3.4819568400271237, + 3.6574638560123276, + 3.825519977021031, + 3.9928760770126246, + 4.153869800007669, + 4.32134599602432, + 4.486418305023108, + 4.656243205012288, + 4.826677757024299, + 4.9962576800026, + 5.164343736018054, + 5.332092543016188, + 5.501916419016197, + 5.673520515003474, + 5.852440753020346, + 6.024251122027636, + 6.197825086012017, + 6.366526891011745, + 6.535100680019241, + 6.706886153027881, + 6.876235002011526, + 7.0439996650093235, + 7.214029767026659, + 7.380843992024893, + 7.553639071004, + 7.727507118019275, + 7.893485946027795, + 8.05973547900794, + 8.231752266001422, + 8.402678421000019, + 8.571212562004803, + 8.732058973022504, + 8.900086453999393, + 9.071301667019725, + 9.240159553999547, + 9.416337599017425, + 9.585842177999439, + 9.765900441008853, + 9.939108756021596, + 10.105992726021213, + 10.273390651011141, + 10.444378359010443, + 10.605344740004512, + 10.77490109502105, + 10.941713273001369, + 11.106247900024755, + 11.268372495018411, + 11.437147870019544, + 11.600091095024254, + 11.763474930019584, + 11.928588345006574, + 12.098250366019784, + 12.265835349011468, + 12.45107414101949, + 12.658514373004436, + 12.868945632013492, + 13.077557071024785, + 13.283044138021069, + 13.498537190025672, + 13.719159635016695, + 13.905139280017465, + 14.071202621998964, + 14.238319442025386, + 14.40276645301492, + 14.569933994003804, + 14.730961255001603, + 14.894719830015674, + 15.06258844700642, + 15.230503673024941, + 15.393516066018492, + 15.55192257501767, + 15.718963587016333, + 15.887388144008582, + 16.052806010004133, + 16.221064214012586, + 16.395899020018987, + 16.56124416500097, + 16.73121726102545, + 16.892187818011735, + 17.050643847003812, + 17.213062733004335, + 17.383251686027506, + 17.55601662301342, + 17.723794215999078, + 17.869962614000542 + ], + "chunk_gaps_ms": { + "count": 101, + "p50": 168.05612100870349, + "p95": 207.44023198494688, + "max": 701.3095939764753 + } + }, + { + "start": 258779.628281189, + "first": 258780.400667096, + "last": 258797.912106599, + "end": 258797.912246024, + "elapsed_s": 18.28396483499091, + "chunk_offsets_s": [ + 0.7723859069810715, + 0.8975061509991065, + 1.032383272977313, + 1.1856280019856058, + 1.3385816889931448, + 1.4949526299897116, + 1.6452908599749207, + 1.809789100982016, + 1.9695011349976994, + 2.1266760649741627, + 2.2959195689763874, + 2.4628991700010374, + 2.632691765000345, + 2.8124809689761605, + 2.9797123959870078, + 3.148178518982604, + 3.3172672539949417, + 3.4823569389991462, + 3.657999827992171, + 3.8255537689838093, + 3.9933535839954857, + 4.154169609973906, + 4.3215390859986655, + 4.486003230995266, + 4.6566061999765225, + 4.826501195988385, + 4.996497008978622, + 5.164284151978791, + 5.332284655974945, + 5.502315125981113, + 5.67395426199073, + 5.852791619981872, + 6.024543955980334, + 6.197882558975834, + 6.366366394999204, + 6.535102375986753, + 6.7070734500011895, + 6.876616235997062, + 7.044402692001313, + 7.214312088995939, + 7.380649813974742, + 7.5540429939865135, + 7.727095482987352, + 7.89369343497674, + 8.059932247997494, + 8.231954842980485, + 8.4031517689873, + 8.571621715993388, + 8.732334303000243, + 8.900104485976044, + 9.071494372998131, + 9.240528244001325, + 9.416060877993004, + 9.586216964991763, + 9.765642151993234, + 9.939393109991215, + 10.106263367983047, + 10.273594764992595, + 10.444774073985172, + 10.605600852984935, + 10.775323513982585, + 10.942198299977463, + 11.106467309000436, + 11.268834545975551, + 11.437411839986453, + 11.600419368973235, + 11.763937397976406, + 11.928898811980616, + 12.098544719978236, + 12.26610048598377, + 12.451510335988132, + 12.658711893978762, + 12.869389346975368, + 13.077819760976126, + 13.283246443985263, + 13.498803527996643, + 13.71941787598189, + 13.90540400199825, + 14.071512319991598, + 14.238656051980797, + 14.403035366995027, + 14.570239611988654, + 14.731201272981707, + 14.895026439975481, + 15.062901312980102, + 15.230734489974566, + 15.393779779988108, + 15.552241984987631, + 15.719206980982563, + 15.887658193998504, + 16.053078907978488, + 16.221376264002174, + 16.39621257397812, + 16.561651959986193, + 16.73155497497646, + 16.892397498973878, + 17.051006584981224, + 17.21341100797872, + 17.383689080976183, + 17.55632132900064, + 17.724102794978535, + 17.870350376993883, + 18.001395461993525, + 18.109582462988328, + 18.178474650980206, + 18.23489435800002, + 18.283825409977 + ], + "chunk_gaps_ms": { + "count": 106, + "p50": 167.78679950220976, + "p95": 205.42668300913647, + "max": 220.61434798524715 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + }, + { + "failed": 0, + "unmeasured": 0, + "aggregate_tps": 56.24588871402655, + "requested_requests": 4, + "timed_requests": 4, + "makespan_s": 18.33637687098235, + "end_to_end_tps": 55.8452745166085, + "timing_valid": true, + "steady_tps": 57.840258999648896, + "per_stream_tps": [ + 14.4, + 14.5, + 14.4, + 14.5 + ], + "ttft_s": [ + 0.39, + 0.59, + 0.2, + 0.78 + ], + "errors": [], + "thinking_modes": [ + "off" + ], + "requests": [ + { + "prompt_tokens": 32, + "ttft_s": 0.3936099130078219, + "decode_tps": 14.352648014929745, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 81.29876545910085, + "prefill_tps": 81.29876545910085, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.67355424307706, + "round_gap_p50_ms": 167.71221900125965, + "round_gap_p95_ms": 213.17665599053726, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.006090167007641867, + "first_payload_s": 0.006092471012379974, + "first_content_s": 0.3936099130078219, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.3936099130078219, + "last_output_s": 18.160366244992474 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.5866507249884307, + "decode_tps": 14.510664068640098, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 54.54693676655913, + "prefill_tps": 54.54693676655913, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 68.91483361958343, + "round_gap_p50_ms": 167.59706599987112, + "round_gap_p95_ms": 213.1697919976432, + "tokens_per_chunk": 2.4615384615384617, + "headers_s": 0.027604529983364046, + "first_payload_s": 0.027611089986748993, + "first_content_s": 0.5866507249884307, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.5866507249884307, + "last_output_s": 18.159933297982207 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.2013289610040374, + "decode_tps": 14.39048852635758, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 158.94384911348288, + "prefill_tps": 158.94384911348288, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.49034413726837, + "round_gap_p50_ms": 167.72909899009392, + "round_gap_p95_ms": 213.1292480044067, + "tokens_per_chunk": 2.5098039215686274, + "headers_s": 0.006116951000876725, + "first_payload_s": 0.006121623009676114, + "first_content_s": 0.2013289610040374, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.2013289610040374, + "last_output_s": 17.92136671600747 + }, + { + "prompt_tokens": 32, + "ttft_s": 0.7774994429782964, + "decode_tps": 14.522803686929993, + "thinking": "off", + "thinking_off_requested": true, + "completion": "truncated", + "token_timing": "chunk", + "prompt_ttft_tps": 41.15758575648686, + "prefill_tps": 41.15758575648686, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 68.85722767842441, + "round_gap_p50_ms": 167.60613900260068, + "round_gap_p95_ms": 208.62257800763473, + "tokens_per_chunk": 2.392523364485981, + "headers_s": 0.028629640000872314, + "first_payload_s": 0.02863458398496732, + "first_content_s": 0.7774994429782964, + "first_reasoning_s": null, + "first_tool_s": null, + "first_output_s": 0.7774994429782964, + "last_output_s": 18.33609250097652 + } + ], + "pooled": { + "streams_timed": 4, + "streams_token_timed": 0, + "itl_mean_ms": null, + "itl_p50_ms": null, + "itl_p95_ms": null, + "tpot_ms": null, + "chunk_tpot_estimate_ms": 69.23398991958831, + "round_gap_p50_ms": 167.6877560093999, + "round_gap_p95_ms": 213.1697919976432, + "round_gap_mean_ms": 170.98951505564185, + "tokens_per_chunk": 2.4556354916067145, + "aggregate_prompt_ttft_tps": 164.63034302594744, + "aggregate_prefill_tps": 164.63034302594744 + }, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3672ac37f298", + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "fb6e67c7120b", + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "completion": "truncated", + "finish_reasons": [ + "length" + ], + "tool_calls": 0, + "tool_sha256": null + } + ], + "client_intervals": [ + { + "start": 258797.914455238, + "first": 258798.308065151, + "last": 258816.074821483, + "end": 258816.074907035, + "elapsed_s": 18.160451797011774, + "chunk_offsets_s": [ + 0.3936099130078219, + 0.9022324869874865, + 1.037177772988798, + 1.1893055849941447, + 1.343464290985139, + 1.4999137480044737, + 1.6502359329897445, + 1.8162534990115091, + 1.974022595997667, + 2.1311625209928025, + 2.3010272969841026, + 2.4658905350079294, + 2.6357348790043034, + 2.813808106991928, + 2.9825562670012005, + 3.1502223720017355, + 3.3178933410090394, + 3.4815229079977144, + 3.658796052011894, + 3.8269181119976565, + 3.995077100000344, + 4.155956986011006, + 4.324910923984135, + 4.488965822005412, + 4.661734040011652, + 4.831061436008895, + 5.00140650299727, + 5.168065417994512, + 5.335663362988271, + 5.502439062984195, + 5.674083482008427, + 5.847279014997184, + 6.019870705000358, + 6.1912258740048856, + 6.359137054008897, + 6.527053976984462, + 6.697854822996305, + 6.868101186002605, + 7.036268174997531, + 7.208345541002927, + 7.375374619005015, + 7.5489797230111435, + 7.724507047998486, + 7.8920966729929205, + 8.083394515997497, + 8.292035799007863, + 8.50645380601054, + 8.719630462001078, + 8.927999406994786, + 9.146560866007349, + 9.372159794002073, + 9.593698855984258, + 9.799902475002455, + 9.96985818099347, + 10.148576037987368, + 10.321835988987004, + 10.488332167995395, + 10.656577797984937, + 10.826171772991074, + 10.988072387001012, + 11.157503928989172, + 11.323628248996101, + 11.487974335002946, + 11.649570498004323, + 11.818516548984917, + 11.982887818012387, + 12.148443640006008, + 12.312120152986608, + 12.479959685006179, + 12.648607829993125, + 12.81658608300495, + 12.984945586009417, + 13.150436911004363, + 13.310331176006002, + 13.46686172299087, + 13.631683988001896, + 13.799396207003156, + 13.96468700299738, + 14.130760844011093, + 14.297872739000013, + 14.462832413002616, + 14.630617224989692, + 14.791952844010666, + 14.956529043003684, + 15.124921506998362, + 15.290980132005643, + 15.45457880498725, + 15.612391120987013, + 15.781299667985877, + 15.946113821002655, + 16.113124628987862, + 16.280179419991327, + 16.454064511985052, + 16.619930832006503, + 16.78829160000896, + 16.95133362998604, + 17.110142399993492, + 17.270849086984526, + 17.43898895799066, + 17.61022092899657, + 17.77545542101143, + 17.92136196399224, + 18.05218656899524, + 18.160366244992474 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 167.71221900125965, + "p95": 213.17665599053726, + "max": 508.6225739796646 + } + }, + { + "start": 258797.914839592, + "first": 258798.501490317, + "last": 258816.07477289, + "end": 258816.075448527, + "elapsed_s": 18.160608934995253, + "chunk_offsets_s": [ + 0.5866507249884307, + 0.9019600859901402, + 1.0366157539829146, + 1.1885905730014201, + 1.3431486419867724, + 1.4995949940057471, + 1.6500834839825984, + 1.815821224998217, + 1.9738998280081432, + 2.130996088992106, + 2.300907839991851, + 2.4657896389835514, + 2.635616557992762, + 2.8136122660071123, + 2.9825363470008597, + 3.150082995998673, + 3.317849788989406, + 3.4815376609913073, + 3.65853552200133, + 3.8267559990053996, + 3.994941563985776, + 4.155831593991024, + 4.324774779001018, + 4.48882463699556, + 4.661597303987946, + 4.8309200599906035, + 5.001309207000304, + 5.167969673988409, + 5.335396754002431, + 5.502356246986892, + 5.6740154339931905, + 5.847155527007999, + 6.019742784992559, + 6.190974736993667, + 6.359038077993318, + 6.526432245998876, + 6.6977474949962925, + 6.86804073798703, + 7.036115245980909, + 7.208421685994836, + 7.375483676005388, + 7.549195900995983, + 7.724513447989011, + 7.891853855981026, + 8.083402739983285, + 8.291824757994618, + 8.506320157990558, + 8.719489949988201, + 8.927746365981875, + 9.146292816993082, + 9.371967680985108, + 9.593517303990666, + 9.799672153982101, + 9.969549011002528, + 10.148304069007281, + 10.32178125300561, + 10.48818271100754, + 10.656456486001844, + 10.826055229001213, + 10.988050402986119, + 11.157287784008076, + 11.323434264981188, + 11.488036686991109, + 11.649357857007999, + 11.818727831006981, + 11.982846155005973, + 12.148295750987018, + 12.312179993983591, + 12.479777059983462, + 12.648619701998541, + 12.816307458007941, + 12.984981843008427, + 13.150453520007432, + 13.310307415988063, + 13.46660386599251, + 13.63155734699103, + 13.799328350985888, + 13.964574459008873, + 14.130751227989094, + 14.297712226980366, + 14.46280494198436, + 14.630664105992764, + 14.791834746982204, + 14.95662485199864, + 15.124340799986385, + 15.290826802985976, + 15.454326323990244, + 15.61250995399314, + 15.781155892007519, + 15.945876284007682, + 16.113009908003733, + 16.280044891987927, + 16.453964399988763, + 16.619588173984084, + 16.78821009598323, + 16.950996444007615, + 17.109592028980842, + 17.270415100996615, + 17.43877076500212, + 17.60989375898498, + 17.775140394980554, + 17.921024937997572, + 18.052120777982054, + 18.159933297982207 + ], + "chunk_gaps_ms": { + "count": 103, + "p50": 167.59706599987112, + "p95": 213.1697919976432, + "max": 315.3093610017095 + } + }, + { + "start": 258797.914275061, + "first": 258798.115604022, + "last": 258815.835641777, + "end": 258815.836226676, + "elapsed_s": 17.92195161501877, + "chunk_offsets_s": [ + 0.2013289610040374, + 0.9022863749996759, + 1.0372859170020092, + 1.189248625014443, + 1.3433349459955934, + 1.500001908018021, + 1.6507431840000208, + 1.81627055502031, + 1.9743957339960616, + 2.131429291010136, + 2.3013342100020964, + 2.4662895140063483, + 2.636094657005742, + 2.814097645023139, + 2.9828615490114316, + 3.1505784380133264, + 3.3181795670243446, + 3.482250177010428, + 3.659215910010971, + 3.8272120020119473, + 3.9954091499967035, + 4.156251228007022, + 4.325431775010657, + 4.489252399012912, + 4.662103306007339, + 4.83137644600356, + 5.001715849008178, + 5.168383564014221, + 5.3360467410238925, + 5.502827577001881, + 5.674460684007499, + 5.8475445530202705, + 6.020233715011273, + 6.1916662770090625, + 6.359526879998157, + 6.527131769020343, + 6.698232185997767, + 6.868470356013859, + 7.036562768014846, + 7.208782984002028, + 7.375878942024428, + 7.549946448998526, + 7.724987259018235, + 7.892678789008642, + 8.08377581401146, + 8.292556938016787, + 8.506763472018065, + 8.719892720022472, + 8.928504130017245, + 9.146996405004757, + 9.372763702005614, + 9.593993050017161, + 9.80044215900125, + 9.970448888023384, + 10.148947161011165, + 10.322114103008062, + 10.48861300200224, + 10.65695612100535, + 10.82646943902364, + 10.988340676005464, + 11.1580234200228, + 11.323901243013097, + 11.488327233004384, + 11.649840660014888, + 11.819160825019935, + 11.983183516014833, + 12.14877021801658, + 12.312651692016516, + 12.480515816016123, + 12.648930248018587, + 12.816994852997595, + 12.98547637401498, + 13.150924946006853, + 13.31079873102135, + 13.467392830003519, + 13.632013126014499, + 13.799742225004593, + 13.964989229018101, + 14.131226494995644, + 14.29818965299637, + 14.463153135002358, + 14.631126908003353, + 14.792329998017522, + 14.956878773024073, + 15.124788226006785, + 15.291313430003356, + 15.45496451901272, + 15.612724291015184, + 15.78160979799577, + 15.946668417018373, + 16.113466839015018, + 16.280534318007994, + 16.45438257799833, + 16.619878623023396, + 16.78864984199754, + 16.95137830200838, + 17.10993412701646, + 17.270646125019994, + 17.439059118012665, + 17.6101641440182, + 17.77532706799684, + 17.92136671600747 + ], + "chunk_gaps_ms": { + "count": 101, + "p50": 167.72909899009392, + "p95": 213.1292480044067, + "max": 700.9574139956385 + } + }, + { + "start": 258797.914170308, + "first": 258798.691669751, + "last": 258816.250262809, + "end": 258816.250547179, + "elapsed_s": 18.33637687098235, + "chunk_offsets_s": [ + 0.7774994429782964, + 0.9021676709817257, + 1.0372057409840636, + 1.1895283710036892, + 1.3436510769824963, + 1.4999342119845096, + 1.6504388939938508, + 1.8167217259760946, + 1.9744226789916866, + 2.131598075997317, + 2.301499459979823, + 2.4663248260039836, + 2.636138097004732, + 2.8143766869907267, + 2.9831339189840946, + 3.150597686995752, + 3.318632593989605, + 3.4824348019901663, + 3.65926703097648, + 3.82736865899642, + 3.995455022988608, + 4.156413116987096, + 4.3253400629910175, + 4.489408976980485, + 4.662145178997889, + 4.831526766996831, + 5.001888009981485, + 5.16854906899971, + 5.3362091750022955, + 5.5028685379948, + 5.67448338898248, + 5.847737962991232, + 6.020276787981857, + 6.191713877982693, + 6.359566256986, + 6.527401564002503, + 6.698260473989649, + 6.868507827981375, + 7.036716737988172, + 7.208748375996947, + 7.375778221990913, + 7.549401501979446, + 7.724927690986078, + 7.892596308985958, + 8.083808822993888, + 8.292431401001522, + 8.506925505993422, + 8.72008747298969, + 8.928650083980756, + 9.147042964992579, + 9.372559588984586, + 9.594374573003734, + 9.800665168993874, + 9.970468296989566, + 10.149204571003793, + 10.32238549698377, + 10.488975355983712, + 10.656972472992493, + 10.82665352098411, + 10.988653173990315, + 11.15787250699941, + 11.324211340979673, + 11.488638610986527, + 11.650119509984506, + 11.819331657985458, + 11.98345591800171, + 12.149073212000076, + 12.312539867998566, + 12.480337607004913, + 12.64922567398753, + 12.817276950983796, + 12.985423828999046, + 13.150866913987556, + 13.31074973900104, + 13.467639887996484, + 13.632168662996264, + 13.799937890988076, + 13.965184173983289, + 14.131160302000353, + 14.298625384981278, + 14.46341328098788, + 14.63101941999048, + 14.792374333977932, + 14.957190694985911, + 15.125111027999083, + 15.291364470991539, + 15.455223304976244, + 15.613041796983453, + 15.78177051898092, + 15.946717424987582, + 16.113744968984975, + 16.2805733109999, + 16.454543938976713, + 16.620043040980818, + 16.788813411985757, + 16.95154062297661, + 17.110140623990446, + 17.27098502399167, + 17.439363967976533, + 17.61045139399357, + 17.77560860599624, + 17.92158884499804, + 18.052524411992636, + 18.160488805995556, + 18.230102503992384, + 18.286907367000822, + 18.33609250097652 + ], + "chunk_gaps_ms": { + "count": 106, + "p50": 167.63312250259332, + "p95": 208.62257800763473, + "max": 225.51662399200723 + } + } + ], + "equal_alone": [ + true, + true, + true, + true + ], + "comparisons": [ + { + "concurrent": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3463a68eb11294263084e2693634c78c7c4ab3b865ef9dfd2d27affae273681b", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "96f9af0c0dc9258a9a4f2b3ebae309da1fa22d9d1a801a15b65c40ffc6bcfa6b", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "3672ac37f2982882b4f48addb244ea161614266385c684249a4628f6fa209963", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "complete": true, + "error": null, + "thinking": "off" + } + }, + { + "concurrent": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + }, + "alone": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + }, + "serial": { + "tokens": 256, + "token_sha256": "fb6e67c7120bf830a1d4680094431b139e59d04b4458ee67e4d672b5cf69c81e", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "complete": true, + "error": null, + "thinking": "off" + } + } + ] + } + ] + } + ], + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + }, + "collector_us_per_chunk": 2.47, + "thinking_switch": true, + "thinking_applicable": true +} \ No newline at end of file diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/free-before.txt b/docs/receipts/glm-fp4local-3a56d4eb/ex/free-before.txt new file mode 100644 index 00000000000..69278e577e4 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/free-before.txt @@ -0,0 +1,2 @@ +Mem: 123 5 115 0 3 118 +Mem: 123 4 118 0 0 118 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/free-ready.txt b/docs/receipts/glm-fp4local-3a56d4eb/ex/free-ready.txt new file mode 100644 index 00000000000..023c3d3c950 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/free-ready.txt @@ -0,0 +1,2 @@ +Mem: 123 110 12 0 0 12 +Mem: 123 111 12 0 0 12 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/golden.json b/docs/receipts/glm-fp4local-3a56d4eb/ex/golden.json new file mode 100644 index 00000000000..830a18caefe --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/golden.json @@ -0,0 +1,41 @@ +{ + "count": { + "n": 512, + "token_sha256": "ba28cfb7c5b94418cb274891300c856ef827ac5d647505c33d6793a240e7ce48", + "text": "Count 1..N? User says count upward from one, one number per line. Probably continue pattern? Just count 1 to 204? Ambiguous; likely mirror 204 lines. I'll do 1–204.1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78\n79\n80\n81\n82\n83\n84\n85\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\n100\n101\n102\n103\n104\n105\n106\n107\n108\n109\n110\n111\n112\n113\n114\n115\n116\n117\n118\n119\n120\n121\n122\n123\n124\n125\n126\n127\n128\n129\n130\n131\n132\n133\n134\n135\n136\n137\n138\n139\n140\n141\n142\n143\n144\n145\n146\n147\n148\n149\n150\n151\n152\n153\n154\n155\n156\n157\n158\n159\n160\n161\n162\n163\n164\n165\n166\n167\n168\n169\n170\n171\n172\n173\n174\n175\n176\n177\n178\n179\n180\n181\n182\n183\n184\n185\n186\n187\n188\n189\n190\n191\n192\n193\n194\n195\n196\n197\n198\n199\n200\n201\n202\n203\n204<|user|>The user wants me to count upward from one, one number per line. The previous response counted 1 to 204. Now the user says \"Continue\" — so I should continue counting from 205.\n\nLet me continue from 205.205\n", + "seconds": { + "drafts": 11.6, + "plain": 23.67 + }, + "drafts": { + "per_round": 4.19672131147541, + "accepted": 0.7358490566037735 + } + }, + "prose": { + "n": 512, + "token_sha256": "dae7e2a5c84e5b6fb9d32a16a36fdb3abfa616b94c936b672c01ed51b18a08a6", + "text": "# 古代の道から現代の物流へ――日本の道路網に刻まれた時間\n\n日本の国土を飛行機から眺めると、幹線道路や鉄道、高速道路が幾重にも絡み合う様子が見える。一見すると現代ならではの風景に思えるが、その多くは実に千数百年前、古代の国家が描いた「道」の設計思想を色濃く受け継いでいる。古代の道路網と現代の物流網のあいだには、断絶ではなく連続の糸が張り巡らされているのである。\n\n## 律令国家が描いた幹線の原型\n\n七世紀後半、律令国家は都と地方を結ぶ官道を整備した。なかでも有名なのが東海道、東山道、北陸道、山陽道、南海道、西海道といった「七道」である。中央から諸国に派遣される使者や、地方から都へ運ばれる租税・貢納物は、この道網を通じて流れた。駅家が約十六キロメートルごとに置かれ、馬や人夫が常時待機していたという。これはまさに古代の「物流インフラ」であり、国家の存立を支える動脈だった。\n\n注目すべきは、これらの道が単に二点間を結ぶのではなく、地形と既存の集落配置を考慮しながら、後世の生活圏を規定するように引かれたことである。たとえば東海道のルートは、鎌倉時代の鎌倉街道、江戸時代の五街道、そして現代の国道一号線や東海道新幹線・東名高速道路へと、ほぼ同じ地理的骨格を保ちながら継承されてきた。山や河川の渡河点、峠の位置といった自然条件は千年経っても変わらない。だからこそ、古代人が選んだ「通りやすい場所」は、現代のエンジニアが選ぶ場所とも重なるのである。\n\n## 駅制から宿場町、そして物流拠点へ\n\n古代の駅家", + "seconds": { + "drafts": 17.07, + "plain": 23.76 + }, + "drafts": { + "per_round": 1.9248120300751879, + "accepted": 0.4803921568627451 + } + }, + "code": { + "n": 512, + "token_sha256": "db45a54eb863ca46490cb8b9f235656c7b78494b7a175833d8b62403517c25f3", + "text": "Write a module with TTL LRU cache and tests.```python\n\"\"\"\nttl_lru_cache.py\n\nA thread-safe LRU cache with per-entry TTL (time-to-live) expiry.\n\nFeatures\n--------\n- Least-Recently-Used eviction when the capacity is exceeded.\n- Per-entry time-to-live: expired entries are treated as missing and\n purged lazily on access (and opportunistically during writes).\n- Thread safety via a single re-entrant lock.\n- Full type hints and docstrings.\n- Self-contained unit tests runnable via `python ttl_lru_cache.py`\n or `pytest ttl_lru_cache.py`.\n\nRequires Python 3.9+ (uses built-in generics).\n\"\"\"\n\nfrom __future__ import annotations\n\nimport threading\nimport time\nimport unittest\nfrom collections import OrderedDict\nfrom typing import Callable, Generic, Hashable, Optional, TypeVar\n\n__all__ = [\"TTLCache\", \"TTLCacheError\"]\n\nK = TypeVar(\"K\", bound=Hashable)\nV = TypeVar(\"V\")\n\n\nclass TTLCacheError(Exception):\n \"\"\"Base exception for TTLCache errors.\"\"\"\n\n\nclass TTLCache(Generic[K, V]):\n \"\"\"\n A fixed-capacity, thread-safe LRU cache whose entries expire\n after a configurable time-to-live.\n\n Args:\n maxsize: Maximum number of entries. Must be > 0.\n ttl: Default time-to-live in seconds for entries that do not\n specify one. Must be > 0. May be ``None`` to mean\n \"no expiry\" for entries inserted without an explicit ttl.\n\n Example:\n >>> cache = TTLCache(maxsize=2, ttl=60)\n >>> cache.put(\"a\", 1)\n >>> cache.get(\"a\")\n 1\n \"\"\"\n\n def __init__(\n self,\n maxsize: int,\n ttl: Optional[float] = None,\n clock: Callable[[], float] = time.monotonic,\n ) -> None:\n if maxsize <= 0:\n raise ValueError(\"maxsize must be a positive integer\")\n if ttl is not None and ttl <= 0:\n raise ValueError(\"ttl must be positive or None\")\n\n self._maxsize = maxsize\n self._default_ttl = ttl\n self._clock = clock # injectable for testing\n self._lock = threading.RLock()\n # Maps key -> (value, expiry_deadline or None). OrderedDict gives\n # us", + "seconds": { + "drafts": 13.57, + "plain": 23.73 + }, + "drafts": { + "per_round": 3.011764705882353, + "accepted": 0.6861167002012073 + } + } +} \ No newline at end of file diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/memory-rank0.json b/docs/receipts/glm-fp4local-3a56d4eb/ex/memory-rank0.json new file mode 100644 index 00000000000..2c6b32c50b7 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/memory-rank0.json @@ -0,0 +1,5989 @@ +{ + "schema": 1, + "rank": 0, + "context_tokens_operator_label": 40960, + "pid": 2010306, + "process_start_ns": 258073155300728, + "process_exit_ns": 258833861658218, + "returncode": 0, + "resident_peak": { + "status": "recorded", + "bytes": 8354926592, + "scope": "Linux wait4 lifetime peak RSS, fresh process per context; not resettable" + }, + "physical_footprint": { + "status": "unsupported", + "bytes": null, + "reason": "Linux RSS/PSS is not a total unified-memory physical-footprint peak" + }, + "samples": [ + { + "monotonic_ns": 258073155853258, + "status": "recorded", + "VmHWM_bytes": 1589248, + "VmRSS_bytes": 1589248, + "Pss_bytes": 976896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258074156243267, + "status": "recorded", + "VmHWM_bytes": 1310375936, + "VmRSS_bytes": 1310375936, + "Pss_bytes": 1327202304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258075168630168, + "status": "recorded", + "VmHWM_bytes": 2389753856, + "VmRSS_bytes": 2256687104, + "Pss_bytes": 2250289152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258076189876764, + "status": "recorded", + "VmHWM_bytes": 2994454528, + "VmRSS_bytes": 2991710208, + "Pss_bytes": 2947634176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258077216964880, + "status": "recorded", + "VmHWM_bytes": 3020374016, + "VmRSS_bytes": 2925768704, + "Pss_bytes": 2922501120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258078243350501, + "status": "recorded", + "VmHWM_bytes": 3020374016, + "VmRSS_bytes": 2800979968, + "Pss_bytes": 2825866240, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258079269055036, + "status": "recorded", + "VmHWM_bytes": 3020374016, + "VmRSS_bytes": 2749288448, + "Pss_bytes": 2747571200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258080296623808, + "status": "recorded", + "VmHWM_bytes": 3020374016, + "VmRSS_bytes": 2999238656, + "Pss_bytes": 2995993600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258081330606888, + "status": "recorded", + "VmHWM_bytes": 5764988928, + "VmRSS_bytes": 2976051200, + "Pss_bytes": 2975267840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258082359905214, + "status": "recorded", + "VmHWM_bytes": 5764988928, + "VmRSS_bytes": 3931078656, + "Pss_bytes": 4088441856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258083395582727, + "status": "recorded", + "VmHWM_bytes": 5764988928, + "VmRSS_bytes": 2981380096, + "Pss_bytes": 2976545792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258084424310004, + "status": "recorded", + "VmHWM_bytes": 5764988928, + "VmRSS_bytes": 5010993152, + "Pss_bytes": 5031169024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258085462556611, + "status": "recorded", + "VmHWM_bytes": 5764988928, + "VmRSS_bytes": 2970116096, + "Pss_bytes": 2966854656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258086488852285, + "status": "recorded", + "VmHWM_bytes": 5764988928, + "VmRSS_bytes": 5728112640, + "Pss_bytes": 5732826112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258087527717800, + "status": "recorded", + "VmHWM_bytes": 5770248192, + "VmRSS_bytes": 3073605632, + "Pss_bytes": 3205749760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258088583726458, + "status": "recorded", + "VmHWM_bytes": 5770248192, + "VmRSS_bytes": 5027233792, + "Pss_bytes": 5030001664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258089648322521, + "status": "recorded", + "VmHWM_bytes": 5770248192, + "VmRSS_bytes": 2971070464, + "Pss_bytes": 2967809024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258090695174216, + "status": "recorded", + "VmHWM_bytes": 5770248192, + "VmRSS_bytes": 5739327488, + "Pss_bytes": 5737688064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258091762635999, + "status": "recorded", + "VmHWM_bytes": 5770248192, + "VmRSS_bytes": 3000328192, + "Pss_bytes": 2997066752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258092808637444, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 2849120256, + "Pss_bytes": 2846669824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258093856702312, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 3658153984, + "Pss_bytes": 3661839360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258094908303298, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 2999996416, + "Pss_bytes": 2996206592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258095958865371, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 4113096704, + "Pss_bytes": 4119141376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258097016095305, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 3000811520, + "Pss_bytes": 2997550080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258098067700034, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 3677560832, + "Pss_bytes": 2735483904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258099112446078, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 3571064832, + "Pss_bytes": 3670834176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258100157727745, + "status": "recorded", + "VmHWM_bytes": 5772787712, + "VmRSS_bytes": 4781711360, + "Pss_bytes": 4830645248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258101221222305, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2975887360, + "Pss_bytes": 2971640832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258102268847369, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 4782960640, + "Pss_bytes": 3942804480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258103322454387, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2984120320, + "Pss_bytes": 2980441088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258104371578732, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2988679168, + "Pss_bytes": 2985430016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258105400371080, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2961391616, + "Pss_bytes": 2958142464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258106428723686, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 5268942848, + "Pss_bytes": 5255060480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258107468556928, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2893660160, + "Pss_bytes": 2893483008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258108495963810, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 5455724544, + "Pss_bytes": 5504928768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258109539827945, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 4125433856, + "Pss_bytes": 4148231168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258110574270215, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2973192192, + "Pss_bytes": 2934948864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258111626689200, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 3385991168, + "Pss_bytes": 3416921088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258112670579365, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2858721280, + "Pss_bytes": 2858750976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258113698289760, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2927693824, + "Pss_bytes": 2923421696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258114726543153, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2852384768, + "Pss_bytes": 2856764416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258115753995044, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 3164086272, + "Pss_bytes": 3160445952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258116781276154, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2907967488, + "Pss_bytes": 2913212416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258117809050487, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 3881459712, + "Pss_bytes": 3876369408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258118840029415, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 4529623040, + "Pss_bytes": 4527932416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258119875030256, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2958077952, + "Pss_bytes": 2943185920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258120901843974, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2930470912, + "Pss_bytes": 2927223808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258121931486653, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2721136640, + "Pss_bytes": 2718999552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258122956543539, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2892099584, + "Pss_bytes": 2889896960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258123984926925, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 2931580928, + "Pss_bytes": 2928333824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258125015373766, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 3152351232, + "Pss_bytes": 3168306176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258126046921048, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 4786262016, + "Pss_bytes": 4788151296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258127083081494, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 5521559552, + "Pss_bytes": 5690147840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258128128319124, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 4190339072, + "Pss_bytes": 4199941120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258129161913998, + "status": "recorded", + "VmHWM_bytes": 5774905344, + "VmRSS_bytes": 5250101248, + "Pss_bytes": 5179745280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258130199503936, + "status": "recorded", + "VmHWM_bytes": 6467584000, + "VmRSS_bytes": 5528539136, + "Pss_bytes": 5550330880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258131238645038, + "status": "recorded", + "VmHWM_bytes": 7321653248, + "VmRSS_bytes": 7321653248, + "Pss_bytes": 7388603392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258132289919644, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 4934262784, + "Pss_bytes": 4930884608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258133325409536, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 4944240640, + "Pss_bytes": 4940862464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258134361061914, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 4944240640, + "Pss_bytes": 4940862464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258135396264326, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 4944240640, + "Pss_bytes": 4940862464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258136431571527, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 4945027072, + "Pss_bytes": 4941648896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258137466749979, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1251237888, + "Pss_bytes": 1247982592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258138478778289, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1244979200, + "Pss_bytes": 1236066304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258139490413210, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220534272, + "Pss_bytes": 1217232896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258140520497009, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220608000, + "Pss_bytes": 1217306624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258141543358474, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220616192, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258142580520941, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220616192, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258143614228580, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220616192, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258144636495430, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220632576, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258145671868109, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220640768, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258146689394559, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220648960, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258147707361240, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220657152, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258148726130121, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220661248, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258149754112876, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220669440, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258150776717448, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220673536, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258151813907410, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220677632, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258152838611265, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220681728, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258153863784119, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220751360, + "Pss_bytes": 1217318912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258154895104239, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220751360, + "Pss_bytes": 1217318912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258155918573268, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220751360, + "Pss_bytes": 1217314816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258156937987401, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220825088, + "Pss_bytes": 1217392640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258157965593835, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220825088, + "Pss_bytes": 1217392640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258158990065810, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220825088, + "Pss_bytes": 1217392640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258160013547351, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220825088, + "Pss_bytes": 1217392640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258161040022768, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220833280, + "Pss_bytes": 1217392640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258162078174599, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220837376, + "Pss_bytes": 1217392640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258163104439767, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1220841472, + "Pss_bytes": 1217388544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258164136405288, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1202450432, + "Pss_bytes": 1197232128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258165149407276, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1120772096, + "Pss_bytes": 1117319168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258166160620604, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1120772096, + "Pss_bytes": 1117319168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258167171420445, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1122672640, + "Pss_bytes": 1119073280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258168189432951, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1122840576, + "Pss_bytes": 1119142912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258169208820588, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123221504, + "Pss_bytes": 1119523840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258170230605649, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123229696, + "Pss_bytes": 1119532032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258171253682336, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123250176, + "Pss_bytes": 1119552512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258172274837961, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123336192, + "Pss_bytes": 1119638528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258173298137810, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123348480, + "Pss_bytes": 1119650816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258174321072252, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123360768, + "Pss_bytes": 1119663104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258175343358919, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123373056, + "Pss_bytes": 1119675392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258176364028958, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123377152, + "Pss_bytes": 1119679488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258177386132208, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123385344, + "Pss_bytes": 1119687680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258178407713971, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123389440, + "Pss_bytes": 1119691776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258179429258345, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123872768, + "Pss_bytes": 1120175104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258180442758043, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123872768, + "Pss_bytes": 1120175104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258181462773201, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123872768, + "Pss_bytes": 1120175104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258182492984960, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123876864, + "Pss_bytes": 1120179200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258183512931598, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123885056, + "Pss_bytes": 1120187392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258184533009873, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123885056, + "Pss_bytes": 1120183296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258185554475614, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123889152, + "Pss_bytes": 1120191488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258186574804953, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123893248, + "Pss_bytes": 1120195584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258187594636182, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123893248, + "Pss_bytes": 1120195584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258188613921572, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123893248, + "Pss_bytes": 1120195584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258189633887753, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123893248, + "Pss_bytes": 1120195584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258190654010498, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123897344, + "Pss_bytes": 1120199680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258191674660098, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123901440, + "Pss_bytes": 1120203776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258192694569490, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123901440, + "Pss_bytes": 1120203776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258193713973875, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123901440, + "Pss_bytes": 1120203776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258194743683309, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123901440, + "Pss_bytes": 1120203776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258195764447421, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123905536, + "Pss_bytes": 1120207872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258196783892906, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123905536, + "Pss_bytes": 1120207872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258197802959592, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123905536, + "Pss_bytes": 1120207872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258198822537741, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123905536, + "Pss_bytes": 1120207872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258199839814697, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123909632, + "Pss_bytes": 1120211968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258200860224265, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123909632, + "Pss_bytes": 1120211968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258201880923663, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123909632, + "Pss_bytes": 1120211968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258202901157862, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1123934208, + "Pss_bytes": 1120236544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258203922965529, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124184064, + "Pss_bytes": 1120490496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258204955423270, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124188160, + "Pss_bytes": 1120490496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258205978224214, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124196352, + "Pss_bytes": 1120494592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258207000415526, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124200448, + "Pss_bytes": 1120498688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258208023125676, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124212736, + "Pss_bytes": 1120515072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258209045374979, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124286464, + "Pss_bytes": 1120588800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258210068996726, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124290560, + "Pss_bytes": 1120592896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258211089536844, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124294656, + "Pss_bytes": 1120596992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258212110626872, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124302848, + "Pss_bytes": 1120605184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258213133328465, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124306944, + "Pss_bytes": 1120613376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258214155028711, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124311040, + "Pss_bytes": 1120613376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258215175741405, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124319232, + "Pss_bytes": 1120621568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258216198653265, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124323328, + "Pss_bytes": 1120625664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258217219907857, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124335616, + "Pss_bytes": 1120634880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258218242168889, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124339712, + "Pss_bytes": 1120646144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258219267477717, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258220281901259, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258221297623660, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258222318017208, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258223338425912, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258224367641115, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258225389187736, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258226409602611, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124491264, + "Pss_bytes": 1120793600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258227429415566, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124495360, + "Pss_bytes": 1120797696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258228450954758, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124495360, + "Pss_bytes": 1120797696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258229472048303, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124495360, + "Pss_bytes": 1120797696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258230492639817, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124495360, + "Pss_bytes": 1120797696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258231515447522, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124499456, + "Pss_bytes": 1120801792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258232542785207, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124499456, + "Pss_bytes": 1120801792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258233559087429, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124507648, + "Pss_bytes": 1120809984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258234579748941, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124507648, + "Pss_bytes": 1120809984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258235600263704, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124507648, + "Pss_bytes": 1120809984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258236619917090, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124511744, + "Pss_bytes": 1120814080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258237641640186, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124511744, + "Pss_bytes": 1120814080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258238663415158, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124511744, + "Pss_bytes": 1120814080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258239684516434, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124511744, + "Pss_bytes": 1120814080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258240706318325, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124519936, + "Pss_bytes": 1120822272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258241727992667, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124519936, + "Pss_bytes": 1120822272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258242749045409, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124519936, + "Pss_bytes": 1120822272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258243771420801, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124556800, + "Pss_bytes": 1120859136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258244787802933, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124810752, + "Pss_bytes": 1121113088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258245811815797, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124814848, + "Pss_bytes": 1121117184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258246836675485, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124823040, + "Pss_bytes": 1121125376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258247859693838, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124827136, + "Pss_bytes": 1121129472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258248882169872, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124909056, + "Pss_bytes": 1121211392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258249905582122, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124917248, + "Pss_bytes": 1121219584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258250928979976, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124921344, + "Pss_bytes": 1120367616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258251953631120, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124929536, + "Pss_bytes": 1121231872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258252976495953, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124933632, + "Pss_bytes": 1121235968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258254000282491, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124941824, + "Pss_bytes": 1120249856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258255024789212, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124954112, + "Pss_bytes": 1121256448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258256049945204, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124962304, + "Pss_bytes": 1121264640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258257074692669, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1120956416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258258093478953, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1121043456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258259117718278, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1121043456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258260139354777, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1121043456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258261159672711, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1121043456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258262181513409, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1121043456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258263202341369, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124741120, + "Pss_bytes": 1121043456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258264222909187, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124745216, + "Pss_bytes": 1121047552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258265244449077, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124753408, + "Pss_bytes": 1121055744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258266261655619, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124753408, + "Pss_bytes": 1121055744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258267278481058, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124753408, + "Pss_bytes": 1121055744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258268301616103, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124757504, + "Pss_bytes": 1121059840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258269323713257, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124757504, + "Pss_bytes": 1121059840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258270346156033, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124757504, + "Pss_bytes": 1121059840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258271367679030, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124757504, + "Pss_bytes": 1121059840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258272389650162, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124757504, + "Pss_bytes": 1121059840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258273421031955, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124757504, + "Pss_bytes": 1121059840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258274441960863, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124761600, + "Pss_bytes": 1121063936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258275462804990, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124761600, + "Pss_bytes": 1121063936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258276485710316, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124761600, + "Pss_bytes": 1121063936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258277507675655, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124769792, + "Pss_bytes": 1121072128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258278528830897, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124769792, + "Pss_bytes": 1121065984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258279552359787, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124769792, + "Pss_bytes": 1121072128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258280574919748, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124909056, + "Pss_bytes": 1121211392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258281601543157, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125036032, + "Pss_bytes": 1121338368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258282626281744, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125076992, + "Pss_bytes": 1121379328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258283649107091, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125154816, + "Pss_bytes": 1121457152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258284671343798, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125187584, + "Pss_bytes": 1121489920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258285705568814, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125236736, + "Pss_bytes": 1121539072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258286725897085, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125326848, + "Pss_bytes": 1121633280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258287747451462, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125093376, + "Pss_bytes": 1121395712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258288768630800, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125142528, + "Pss_bytes": 1121444864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258289786060376, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125187584, + "Pss_bytes": 1121489920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258290807695195, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125171200, + "Pss_bytes": 1121477632, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258291827785384, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125224448, + "Pss_bytes": 1121526784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258292847750936, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125273600, + "Pss_bytes": 1121575936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258293867635754, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125257216, + "Pss_bytes": 1121559552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258294886845388, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125302272, + "Pss_bytes": 1121604608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258295906153569, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125289984, + "Pss_bytes": 1121592320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258296924461476, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125269504, + "Pss_bytes": 1121571840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258297945636394, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1124999168, + "Pss_bytes": 1121301504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258298971377884, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125048320, + "Pss_bytes": 1121350656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258299994266801, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125076992, + "Pss_bytes": 1121379328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258301011548698, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125130240, + "Pss_bytes": 1121432576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258302032729469, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125163008, + "Pss_bytes": 1121465344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258303056626353, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125199872, + "Pss_bytes": 1121502208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258304078901823, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125273600, + "Pss_bytes": 1121575936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258305102975834, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125007360, + "Pss_bytes": 1121309696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258306124522090, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125048320, + "Pss_bytes": 1121350656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258307145530762, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125109760, + "Pss_bytes": 1121412096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258308167885333, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125146624, + "Pss_bytes": 1121448960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258309200716061, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125183488, + "Pss_bytes": 1121485824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258310222841276, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125253120, + "Pss_bytes": 1121555456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258311246020885, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125076992, + "Pss_bytes": 1121379328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258312267684664, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125117952, + "Pss_bytes": 1121420288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258313289661855, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125179392, + "Pss_bytes": 1121481728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258314310842022, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125212160, + "Pss_bytes": 1121514496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258315333279926, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125249024, + "Pss_bytes": 1121551360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258316355443111, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125326848, + "Pss_bytes": 1121629184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258317375530128, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125707776, + "Pss_bytes": 1122010112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258318397422454, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125789696, + "Pss_bytes": 1122092032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258319418166105, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125892096, + "Pss_bytes": 1122194432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258320441475245, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125953536, + "Pss_bytes": 1122255872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258321465074485, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125998592, + "Pss_bytes": 1122300928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258322487952908, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126146048, + "Pss_bytes": 1122448384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258323511072936, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126207488, + "Pss_bytes": 1122522112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258324526656284, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125789696, + "Pss_bytes": 1122092032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258325548895337, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125867520, + "Pss_bytes": 1122169856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258326571523706, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125982208, + "Pss_bytes": 1122284544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258327594699362, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126043648, + "Pss_bytes": 1122345984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258328617768860, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126084608, + "Pss_bytes": 1122386944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258329640123684, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126219776, + "Pss_bytes": 1122522112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258330662039726, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125785600, + "Pss_bytes": 1122087936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258331687573166, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125867520, + "Pss_bytes": 1122169856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258332711444184, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125953536, + "Pss_bytes": 1122255872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258333734753329, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126043648, + "Pss_bytes": 1122345984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258334750802837, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126100992, + "Pss_bytes": 1122403328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258335771992889, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126162432, + "Pss_bytes": 1122464768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258336794784376, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126240256, + "Pss_bytes": 1122542592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258337817530138, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126359040, + "Pss_bytes": 1122665472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258338839332473, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126969344, + "Pss_bytes": 1123272704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258339862667044, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127124992, + "Pss_bytes": 1123431424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258340888369135, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127161856, + "Pss_bytes": 1123468288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258341913437017, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127337984, + "Pss_bytes": 1123640320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258342936415275, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127444480, + "Pss_bytes": 1123746816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258343962186590, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127555072, + "Pss_bytes": 1123857408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258344985070757, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127657472, + "Pss_bytes": 1123959808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258346006560070, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127911424, + "Pss_bytes": 1124213760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258347028747982, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127940096, + "Pss_bytes": 1124283392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258348044475957, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126969344, + "Pss_bytes": 1123292160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258349067805513, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127129088, + "Pss_bytes": 1123435520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258350090777806, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127231488, + "Pss_bytes": 1123533824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258351113685781, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127428096, + "Pss_bytes": 1123726336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258352135561674, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127522304, + "Pss_bytes": 1123820544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258353158760504, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127616512, + "Pss_bytes": 1123914752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258354181373606, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127723008, + "Pss_bytes": 1124025344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258355203324163, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127981056, + "Pss_bytes": 1124283392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258356225816470, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126785024, + "Pss_bytes": 1123087360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258357249809652, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126891520, + "Pss_bytes": 1123193856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258358274146439, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127030784, + "Pss_bytes": 1123333120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258359299458466, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127137280, + "Pss_bytes": 1123439616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258360324634703, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127321600, + "Pss_bytes": 1123623936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258361339350963, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127419904, + "Pss_bytes": 1123722240, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258362359476393, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127514112, + "Pss_bytes": 1123824640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258363381187738, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127616512, + "Pss_bytes": 1123927040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258364403562994, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127870464, + "Pss_bytes": 1124180992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258365425813116, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126567936, + "Pss_bytes": 1122870272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258366451996335, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126641664, + "Pss_bytes": 1122944000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258367476484475, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126694912, + "Pss_bytes": 1122997248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258368494872407, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126727680, + "Pss_bytes": 1123030016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258369518297171, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126793216, + "Pss_bytes": 1123095552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258370542006418, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126850560, + "Pss_bytes": 1123152896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258371566716538, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126895616, + "Pss_bytes": 1123197952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258372590537056, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126993920, + "Pss_bytes": 1123296256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258373612423981, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126973440, + "Pss_bytes": 1123275776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258374636447257, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126723584, + "Pss_bytes": 1123025920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258375657667304, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126776832, + "Pss_bytes": 1123083264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258376708466978, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126842368, + "Pss_bytes": 1123144704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258377729158692, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126895616, + "Pss_bytes": 1123197952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258378751037790, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126891520, + "Pss_bytes": 1123193856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258379770941808, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126948864, + "Pss_bytes": 1123251200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258380793137793, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126944768, + "Pss_bytes": 1123247104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258381814709010, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127002112, + "Pss_bytes": 1123304448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258382836341221, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126993920, + "Pss_bytes": 1123296256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258383858223021, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127051264, + "Pss_bytes": 1123357696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258384880866731, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127112704, + "Pss_bytes": 1123415040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258385900824461, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126739968, + "Pss_bytes": 1123046400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258386924148421, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126797312, + "Pss_bytes": 1123099648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258387948303603, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126858752, + "Pss_bytes": 1123161088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258388973068744, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126907904, + "Pss_bytes": 1123210240, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258389996709802, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126948864, + "Pss_bytes": 1123255296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258391021108114, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126961152, + "Pss_bytes": 1123263488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258392044049268, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127006208, + "Pss_bytes": 1123308544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258393068869092, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126739968, + "Pss_bytes": 1123042304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258394092120109, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126797312, + "Pss_bytes": 1123099648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258395123563080, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126842368, + "Pss_bytes": 1123148800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258396147181128, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126912000, + "Pss_bytes": 1123214336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258397170060311, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126961152, + "Pss_bytes": 1123263488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258398193422635, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126944768, + "Pss_bytes": 1123247104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258399218658236, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127026688, + "Pss_bytes": 1123333120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258400241876997, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126604800, + "Pss_bytes": 1122904064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258401268128177, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126645760, + "Pss_bytes": 1122941952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258402287695401, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126694912, + "Pss_bytes": 1122997248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258403316405624, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126756352, + "Pss_bytes": 1123058688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258404341046515, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126793216, + "Pss_bytes": 1123095552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258405365896017, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126838272, + "Pss_bytes": 1123140608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258406390103342, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126854656, + "Pss_bytes": 1123156992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258407413039206, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126899712, + "Pss_bytes": 1123202048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258408438077277, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126961152, + "Pss_bytes": 1123263488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258409463365400, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127051264, + "Pss_bytes": 1123353600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258410488244627, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127141376, + "Pss_bytes": 1123443712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258411511784457, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127239680, + "Pss_bytes": 1123550208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258412536961354, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127317504, + "Pss_bytes": 1123619840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258413561429338, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127391232, + "Pss_bytes": 1123693568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258414584674501, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127464960, + "Pss_bytes": 1123771392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258415608966313, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127604224, + "Pss_bytes": 1123906560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258416634089124, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127538688, + "Pss_bytes": 1123841024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258417658787855, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126916096, + "Pss_bytes": 1123222528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258418680927278, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127002112, + "Pss_bytes": 1123304448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258419704689656, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127088128, + "Pss_bytes": 1123398656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258420729110089, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127206912, + "Pss_bytes": 1123509248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258421754369281, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127280640, + "Pss_bytes": 1123582976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258422777104205, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127350272, + "Pss_bytes": 1123652608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258423802054216, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127415808, + "Pss_bytes": 1123718144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258424827442568, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127497728, + "Pss_bytes": 1123800064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258425852406312, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127497728, + "Pss_bytes": 1123800064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258426877716317, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127043072, + "Pss_bytes": 1123345408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258427899993714, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127120896, + "Pss_bytes": 1123423232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258428924842040, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127215104, + "Pss_bytes": 1123517440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258429948584347, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127321600, + "Pss_bytes": 1123632128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258430973826729, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127403520, + "Pss_bytes": 1123705856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258431997904770, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127477248, + "Pss_bytes": 1123779584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258433020144483, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127550976, + "Pss_bytes": 1123857408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258434044167312, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127686144, + "Pss_bytes": 1123988480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258435068595667, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127677952, + "Pss_bytes": 1123980288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258436088718142, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127743488, + "Pss_bytes": 1124049920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258437115221521, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127567360, + "Pss_bytes": 1123869696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258438135988293, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127718912, + "Pss_bytes": 1124021248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258439163210289, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127874560, + "Pss_bytes": 1124176896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258440185749668, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127976960, + "Pss_bytes": 1123359744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258441208529803, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128177664, + "Pss_bytes": 1124480000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258442231555398, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128292352, + "Pss_bytes": 1124594688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258443254220784, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128394752, + "Pss_bytes": 1123715072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258444276550524, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128501248, + "Pss_bytes": 1124803584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258445303299907, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128620032, + "Pss_bytes": 1124922368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258446327801455, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128804352, + "Pss_bytes": 1125023744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258447349610030, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128849408, + "Pss_bytes": 1125151744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258448371797010, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128984576, + "Pss_bytes": 1125286912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258449393493189, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127563264, + "Pss_bytes": 1123881984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258450415484044, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127673856, + "Pss_bytes": 1123984384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258451439473441, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127825408, + "Pss_bytes": 1124131840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258452463455832, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127931904, + "Pss_bytes": 1124242432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258453491925148, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128128512, + "Pss_bytes": 1124434944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258454517622033, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128235008, + "Pss_bytes": 1124537344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258455543299593, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128357888, + "Pss_bytes": 1124664320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258456570855567, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128480768, + "Pss_bytes": 1124783104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258457594434639, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128726528, + "Pss_bytes": 1125028864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258458621013667, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128837120, + "Pss_bytes": 1125139456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258459648173101, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128878080, + "Pss_bytes": 1125184512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258460670015802, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127591936, + "Pss_bytes": 1123894272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258461692150394, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127677952, + "Pss_bytes": 1123981312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258462715472628, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127817216, + "Pss_bytes": 1124135936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258463755846325, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127956480, + "Pss_bytes": 1124258816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258464797428624, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128054784, + "Pss_bytes": 1124357120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258465839710689, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128263680, + "Pss_bytes": 1124566016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258466882662520, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128361984, + "Pss_bytes": 1124664320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258467922276862, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128493056, + "Pss_bytes": 1124795392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258468965346794, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128574976, + "Pss_bytes": 1124877312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258469997834938, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128828928, + "Pss_bytes": 1125131264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258471038110331, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128747008, + "Pss_bytes": 1125049344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258472083408124, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128841216, + "Pss_bytes": 1125159936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258473126546994, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126764544, + "Pss_bytes": 1123140608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258474168287794, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126838272, + "Pss_bytes": 1123144704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258475213165783, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126887424, + "Pss_bytes": 1123189760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258476256042450, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126948864, + "Pss_bytes": 1123255296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258477297568072, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126989824, + "Pss_bytes": 1123296256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258478341412925, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127026688, + "Pss_bytes": 1123333120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258479385276757, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127104512, + "Pss_bytes": 1123406848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258480425465370, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126928384, + "Pss_bytes": 1123230720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258481469695384, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126993920, + "Pss_bytes": 1123296256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258482513657128, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127051264, + "Pss_bytes": 1123357696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258483556769812, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127092224, + "Pss_bytes": 1123394560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258484602798964, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127174144, + "Pss_bytes": 1123476480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258485647375150, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126965248, + "Pss_bytes": 1123267584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258486689964622, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127022592, + "Pss_bytes": 1123324928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258487736357031, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127063552, + "Pss_bytes": 1123361792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258488781176505, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127178240, + "Pss_bytes": 1123480576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258489827414309, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127313408, + "Pss_bytes": 1123623936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258490872768414, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127399424, + "Pss_bytes": 1123697664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258491916436416, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127165952, + "Pss_bytes": 1123464192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258492961017689, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127211008, + "Pss_bytes": 1123509248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258494006733419, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127272448, + "Pss_bytes": 1123570688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258495053952504, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127301120, + "Pss_bytes": 1123607552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258496097279313, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127337984, + "Pss_bytes": 1123636224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258497147534084, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127186432, + "Pss_bytes": 1123484672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258498191205491, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127264256, + "Pss_bytes": 1123566592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258499231199342, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127325696, + "Pss_bytes": 1123623936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258500271188635, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127374848, + "Pss_bytes": 1123677184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258501310386613, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127440384, + "Pss_bytes": 1122783232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258502348106089, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127419904, + "Pss_bytes": 1123725312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258503390256105, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127460864, + "Pss_bytes": 1123762176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258504428298691, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127514112, + "Pss_bytes": 1123819520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258505466280462, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127501824, + "Pss_bytes": 1123803136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258506503580199, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127555072, + "Pss_bytes": 1123856384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258507549793673, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127538688, + "Pss_bytes": 1123840000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258508587341304, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127251968, + "Pss_bytes": 1123553280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258509624401782, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127284736, + "Pss_bytes": 1123586048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258510660449312, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127333888, + "Pss_bytes": 1123636224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258511696315452, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127383040, + "Pss_bytes": 1123685376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258512731734214, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127370752, + "Pss_bytes": 1123673088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258513767408005, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127415808, + "Pss_bytes": 1123722240, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258514802932596, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127469056, + "Pss_bytes": 1123775488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258515838844296, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127452672, + "Pss_bytes": 1123755008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258516874436428, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127501824, + "Pss_bytes": 1123808256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258517910414148, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127485440, + "Pss_bytes": 1123787776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258518945169591, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127538688, + "Pss_bytes": 1123841024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258519980513760, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127297024, + "Pss_bytes": 1123599360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258521016891889, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127346176, + "Pss_bytes": 1123652608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258522053194308, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127395328, + "Pss_bytes": 1123697664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258523088346081, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127448576, + "Pss_bytes": 1123747840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258524128759217, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127497728, + "Pss_bytes": 1123800064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258525169032401, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127489536, + "Pss_bytes": 1123791872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258526204394710, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127530496, + "Pss_bytes": 1123836928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258527244137768, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127518208, + "Pss_bytes": 1123824640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258528282095217, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127567360, + "Pss_bytes": 1123873792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258529320165084, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127555072, + "Pss_bytes": 1123857408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258530358384507, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127198720, + "Pss_bytes": 1123501056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258531405481905, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127247872, + "Pss_bytes": 1123554304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258532442048601, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127305216, + "Pss_bytes": 1123607552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258533479327912, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127288832, + "Pss_bytes": 1123591168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258534515941429, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127346176, + "Pss_bytes": 1123648512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258535552244241, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127329792, + "Pss_bytes": 1123632128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258536581422245, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127362560, + "Pss_bytes": 1123664896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258537611082797, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127411712, + "Pss_bytes": 1123713024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258538649402236, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127399424, + "Pss_bytes": 1123700736, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258539687028217, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127448576, + "Pss_bytes": 1123749888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258540724183653, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127436288, + "Pss_bytes": 1123737600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258541760560206, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127231488, + "Pss_bytes": 1123532800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258542803396208, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127284736, + "Pss_bytes": 1123586048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258543846213012, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127342080, + "Pss_bytes": 1123647488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258544885176883, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127378944, + "Pss_bytes": 1123680256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258545927491432, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127415808, + "Pss_bytes": 1123717120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258546967679442, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127211008, + "Pss_bytes": 1123512320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258548008992005, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127260160, + "Pss_bytes": 1123566592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258549050094120, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127309312, + "Pss_bytes": 1123611648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258550091790785, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127354368, + "Pss_bytes": 1123656704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258551134991749, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127387136, + "Pss_bytes": 1123697664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258552176255920, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127419904, + "Pss_bytes": 1123759104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258553203423798, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127227392, + "Pss_bytes": 1122583552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258554244559684, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127280640, + "Pss_bytes": 1123582976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258555286744057, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127337984, + "Pss_bytes": 1123640320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258556328204685, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127370752, + "Pss_bytes": 1123673088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258557369982388, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127407616, + "Pss_bytes": 1123709952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258558410436485, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127469056, + "Pss_bytes": 1123779584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258559450988488, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127497728, + "Pss_bytes": 1123800064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258560496233530, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127563264, + "Pss_bytes": 1123873792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258561537324869, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127620608, + "Pss_bytes": 1123922944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258562580951825, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127710720, + "Pss_bytes": 1124013056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258563624259821, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127755776, + "Pss_bytes": 1124062208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258564682809352, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127817216, + "Pss_bytes": 1124119552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258565725433284, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127862272, + "Pss_bytes": 1124168704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258566768310867, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127976960, + "Pss_bytes": 1124279296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258567814889978, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127452672, + "Pss_bytes": 1123755008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258568857034297, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127510016, + "Pss_bytes": 1123816448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258569900057582, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127571456, + "Pss_bytes": 1123873792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258570933512363, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127616512, + "Pss_bytes": 1123918848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258571967374109, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127710720, + "Pss_bytes": 1124013056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258573008735949, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127759872, + "Pss_bytes": 1124062208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258574051763435, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127817216, + "Pss_bytes": 1124119552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258575093283952, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127866368, + "Pss_bytes": 1124168704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258576137423560, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127981056, + "Pss_bytes": 1124283392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258577181853779, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127538688, + "Pss_bytes": 1123841024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258578226820852, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127600128, + "Pss_bytes": 1123902464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258579275368316, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127665664, + "Pss_bytes": 1123968000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258580321364535, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127755776, + "Pss_bytes": 1124058112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258581361854481, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127809024, + "Pss_bytes": 1124111360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258582407720063, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127862272, + "Pss_bytes": 1124168704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258583449150082, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127915520, + "Pss_bytes": 1124214784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258584495715320, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127989248, + "Pss_bytes": 1124291584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258585544591165, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127624704, + "Pss_bytes": 1123927040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258586587733441, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127915520, + "Pss_bytes": 1124217856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258587635815013, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127993344, + "Pss_bytes": 1124299776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258588683034742, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128099840, + "Pss_bytes": 1124402176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258589728763343, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128165376, + "Pss_bytes": 1124467712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258590777752511, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128259584, + "Pss_bytes": 1124561920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258591821949122, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127477248, + "Pss_bytes": 1123714048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258592859890993, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127288832, + "Pss_bytes": 1123599360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258593905444080, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127346176, + "Pss_bytes": 1123668992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258594946894728, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127424000, + "Pss_bytes": 1123726336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258595990416175, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127481344, + "Pss_bytes": 1122823168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258597030805604, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127481344, + "Pss_bytes": 1123795968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258598073071318, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127596032, + "Pss_bytes": 1123910656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258599112304344, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127747584, + "Pss_bytes": 1124049920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258600152654898, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127354368, + "Pss_bytes": 1123664896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258601194197541, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127444480, + "Pss_bytes": 1123746816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258602235122215, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127534592, + "Pss_bytes": 1123836928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258603281890478, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127628800, + "Pss_bytes": 1123931136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258604319569454, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127677952, + "Pss_bytes": 1123980288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258605353117111, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127731200, + "Pss_bytes": 1124033536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258606383586911, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127858176, + "Pss_bytes": 1124160512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258607420524560, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127936000, + "Pss_bytes": 1124242432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258608463873738, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127993344, + "Pss_bytes": 1124295680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258609512381335, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128062976, + "Pss_bytes": 1124365312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258610560015855, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128128512, + "Pss_bytes": 1124430848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258611603901523, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128194048, + "Pss_bytes": 1124496384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258612645600426, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128316928, + "Pss_bytes": 1124619264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258613684853300, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128448000, + "Pss_bytes": 1124750336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258614726149916, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127424000, + "Pss_bytes": 1123726336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258615770252440, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127510016, + "Pss_bytes": 1123808256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258616815647581, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127591936, + "Pss_bytes": 1123890176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258617865069501, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127686144, + "Pss_bytes": 1123992576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258618909135437, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127743488, + "Pss_bytes": 1124070400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258619952369178, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127809024, + "Pss_bytes": 1124111360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258620998451899, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127907328, + "Pss_bytes": 1124209664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258622044753230, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127960576, + "Pss_bytes": 1124283392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258623092544012, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128030208, + "Pss_bytes": 1124335616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258624138306640, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128099840, + "Pss_bytes": 1124409344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258625184366567, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128165376, + "Pss_bytes": 1124466688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258626222535631, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128292352, + "Pss_bytes": 1124593664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258627277736434, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128419328, + "Pss_bytes": 1124720640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258628323449420, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127682048, + "Pss_bytes": 1123987456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258629367710558, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126699008, + "Pss_bytes": 1123008512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258630415084934, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126764544, + "Pss_bytes": 1123069952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258631458340694, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126805504, + "Pss_bytes": 1123110912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258632502861471, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126875136, + "Pss_bytes": 1123176448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258633548665522, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126920192, + "Pss_bytes": 1123221504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258634591568196, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126936576, + "Pss_bytes": 1123237888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258635635870289, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126977536, + "Pss_bytes": 1123287040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258636679100041, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127030784, + "Pss_bytes": 1123221504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258637705418601, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126764544, + "Pss_bytes": 1123065856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258638737713392, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126805504, + "Pss_bytes": 1123106816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258639777367686, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126862848, + "Pss_bytes": 1123164160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258640818975083, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126899712, + "Pss_bytes": 1123201024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258641859918076, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126936576, + "Pss_bytes": 1122319360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258642900155323, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126944768, + "Pss_bytes": 1123247104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258643938439712, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127002112, + "Pss_bytes": 1123308544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258644974531032, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126707200, + "Pss_bytes": 1123011584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258646017566829, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126768640, + "Pss_bytes": 1123070976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258647063074772, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126809600, + "Pss_bytes": 1123127296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258648105999883, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126875136, + "Pss_bytes": 1123176448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258649147513788, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126916096, + "Pss_bytes": 1123221504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258650188708540, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127002112, + "Pss_bytes": 1123315712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258651229404315, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126989824, + "Pss_bytes": 1123295232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258652271528596, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126801408, + "Pss_bytes": 1123102720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258653318031947, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126862848, + "Pss_bytes": 1123164160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258654360211911, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126907904, + "Pss_bytes": 1123209216, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258655401832018, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126973440, + "Pss_bytes": 1123278848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258656442920411, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127026688, + "Pss_bytes": 1123328000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258657481448358, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127112704, + "Pss_bytes": 1123415040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258658522438546, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127075840, + "Pss_bytes": 1123378176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258659556438227, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127055360, + "Pss_bytes": 1123361792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258660597914853, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126785024, + "Pss_bytes": 1123087360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258661635392351, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126842368, + "Pss_bytes": 1123144704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258662672935004, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126895616, + "Pss_bytes": 1123202048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258663709079985, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126891520, + "Pss_bytes": 1123197952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258664744895461, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126952960, + "Pss_bytes": 1123255296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258665781409744, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127006208, + "Pss_bytes": 1123247104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258666817403849, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127006208, + "Pss_bytes": 1123312640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258667854112663, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127063552, + "Pss_bytes": 1123365888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258668889167549, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127051264, + "Pss_bytes": 1123357696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258669924018115, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127116800, + "Pss_bytes": 1123419136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258670959634800, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126694912, + "Pss_bytes": 1122997248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258671988388787, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126739968, + "Pss_bytes": 1123050496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258673016904358, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126801408, + "Pss_bytes": 1123107840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258674053072746, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126858752, + "Pss_bytes": 1123165184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258675089188496, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126854656, + "Pss_bytes": 1123156992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258676124165680, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126907904, + "Pss_bytes": 1123214336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258677159930022, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126903808, + "Pss_bytes": 1123206144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258678195367612, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126965248, + "Pss_bytes": 1123267584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258679229555468, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126957056, + "Pss_bytes": 1123259392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258680265572617, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127010304, + "Pss_bytes": 1123316736, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258681301559399, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127006208, + "Pss_bytes": 1123308544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258682336507759, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126658048, + "Pss_bytes": 1122960384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258683372934291, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126719488, + "Pss_bytes": 1123021824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258684408097248, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126780928, + "Pss_bytes": 1123083264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258685443307695, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126764544, + "Pss_bytes": 1123074048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258686475629629, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126825984, + "Pss_bytes": 1123132416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258687511480531, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126821888, + "Pss_bytes": 1123128320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258688546140595, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126883328, + "Pss_bytes": 1123185664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258689584182138, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126875136, + "Pss_bytes": 1123177472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258690621790351, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126932480, + "Pss_bytes": 1123234816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258691657623691, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126981632, + "Pss_bytes": 1123283968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258692689227758, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126846464, + "Pss_bytes": 1123152896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258693727750397, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126670336, + "Pss_bytes": 1122056192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258694765238968, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126727680, + "Pss_bytes": 1123030016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258695802973445, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126785024, + "Pss_bytes": 1123091456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258696839990224, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126785024, + "Pss_bytes": 1123087360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258697877105820, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126842368, + "Pss_bytes": 1123144704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258698913421749, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126895616, + "Pss_bytes": 1123202048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258699949051099, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126895616, + "Pss_bytes": 1123202048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258700986432606, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126952960, + "Pss_bytes": 1123259392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258702023455775, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126944768, + "Pss_bytes": 1123247104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258703059136410, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126998016, + "Pss_bytes": 1123308544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258704095077896, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126617088, + "Pss_bytes": 1122919424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258705136997693, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126666240, + "Pss_bytes": 1122968576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258706168677186, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126694912, + "Pss_bytes": 1122993152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258707214299586, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126760448, + "Pss_bytes": 1123066880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258708256479709, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126809600, + "Pss_bytes": 1123116032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258709300345428, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126789120, + "Pss_bytes": 1123095552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258710341750797, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126871040, + "Pss_bytes": 1123173376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258711382456819, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126920192, + "Pss_bytes": 1123226624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258712422984121, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126637568, + "Pss_bytes": 1122939904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258713467246504, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126678528, + "Pss_bytes": 1122984960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258714509262971, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126744064, + "Pss_bytes": 1123046400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258715550849852, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126789120, + "Pss_bytes": 1123095552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258716593128179, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126834176, + "Pss_bytes": 1123136512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258717633675488, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126850560, + "Pss_bytes": 1123152896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258718674901107, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126891520, + "Pss_bytes": 1123197952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258719719885280, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126662144, + "Pss_bytes": 1122964480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258720760826900, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126711296, + "Pss_bytes": 1123013632, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258721801086069, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126772736, + "Pss_bytes": 1123075072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258722845156256, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126817792, + "Pss_bytes": 1123120128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258723885889959, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126797312, + "Pss_bytes": 1123107840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258724925044677, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126871040, + "Pss_bytes": 1123173376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258725959042644, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126916096, + "Pss_bytes": 1123218432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258727001153880, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126817792, + "Pss_bytes": 1123120128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258728046182063, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126899712, + "Pss_bytes": 1123210240, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258729090881286, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126969344, + "Pss_bytes": 1123271680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258730135010171, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127043072, + "Pss_bytes": 1123345408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258731178221980, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127112704, + "Pss_bytes": 1123415040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258732224265040, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127165952, + "Pss_bytes": 1123476480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258733265471606, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127223296, + "Pss_bytes": 1123533824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258734308667514, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127284736, + "Pss_bytes": 1123591168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258735351515550, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127350272, + "Pss_bytes": 1123652608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258736394422531, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127333888, + "Pss_bytes": 1123640320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258737436968951, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127391232, + "Pss_bytes": 1123693568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258738481651547, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126924288, + "Pss_bytes": 1123226624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258739515994525, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126969344, + "Pss_bytes": 1123271680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258740549908799, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127026688, + "Pss_bytes": 1123329024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258741597179687, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127108608, + "Pss_bytes": 1123410944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258742641577501, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127190528, + "Pss_bytes": 1123405824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258743683180548, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127231488, + "Pss_bytes": 1123533824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258744730275359, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127292928, + "Pss_bytes": 1123595264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258745774994971, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127292928, + "Pss_bytes": 1123591168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258746821451573, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127415808, + "Pss_bytes": 1123714048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258747868619924, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127464960, + "Pss_bytes": 1123767296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258748914998944, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127518208, + "Pss_bytes": 1123820544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258749962293122, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126858752, + "Pss_bytes": 1123161088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258751002964332, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126928384, + "Pss_bytes": 1123230720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258752045700884, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126985728, + "Pss_bytes": 1123288064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258753090292250, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127055360, + "Pss_bytes": 1123369984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258754134026379, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127133184, + "Pss_bytes": 1123435520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258755179108934, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127186432, + "Pss_bytes": 1123492864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258756222853466, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127243776, + "Pss_bytes": 1123554304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258757265902827, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127239680, + "Pss_bytes": 1123546112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258758308403562, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127292928, + "Pss_bytes": 1123595264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258759345293526, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127129088, + "Pss_bytes": 1123443712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258760380400695, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126797312, + "Pss_bytes": 1123099648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258761423291660, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126920192, + "Pss_bytes": 1123222528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258762472801597, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127010304, + "Pss_bytes": 1123329024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258763512662737, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127108608, + "Pss_bytes": 1123410944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258764559493587, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127194624, + "Pss_bytes": 1123496960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258765603409284, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127264256, + "Pss_bytes": 1123578880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258766644176498, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127370752, + "Pss_bytes": 1123670016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258767686638188, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127477248, + "Pss_bytes": 1123779584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258768731857433, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127555072, + "Pss_bytes": 1123857408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258769777979101, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127612416, + "Pss_bytes": 1123914752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258770822298038, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127686144, + "Pss_bytes": 1123988480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258771864486340, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127763968, + "Pss_bytes": 1124074496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258772906124943, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127768064, + "Pss_bytes": 1124070400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258773939179572, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127829504, + "Pss_bytes": 1124131840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258774981848792, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127997440, + "Pss_bytes": 1124299776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258776028241349, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128099840, + "Pss_bytes": 1124414464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258777069459315, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128177664, + "Pss_bytes": 1124480000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258778111813304, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128239104, + "Pss_bytes": 1124541440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258779155034405, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128198144, + "Pss_bytes": 1124500480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258780196031493, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126912000, + "Pss_bytes": 1123222528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258781237119990, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127018496, + "Pss_bytes": 1123329024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258782277016194, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127145472, + "Pss_bytes": 1123447808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258783318243014, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127219200, + "Pss_bytes": 1123521536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258784360865782, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127284736, + "Pss_bytes": 1123587072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258785407556304, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127387136, + "Pss_bytes": 1122769920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258786448355590, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127493632, + "Pss_bytes": 1123795968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258787491941935, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127567360, + "Pss_bytes": 1123877888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258788530864539, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127645184, + "Pss_bytes": 1123947520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258789573759618, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127714816, + "Pss_bytes": 1124017152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258790615415474, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127784448, + "Pss_bytes": 1124086784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258791658472669, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127727104, + "Pss_bytes": 1124029440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258792703176595, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127886848, + "Pss_bytes": 1124201472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258793737363543, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127989248, + "Pss_bytes": 1124291584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258794777993493, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128058880, + "Pss_bytes": 1124361216, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258795824982814, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128124416, + "Pss_bytes": 1124439040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258796866427540, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128132608, + "Pss_bytes": 1124434944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258797907429833, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1126764544, + "Pss_bytes": 1123296256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258798942406967, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127325696, + "Pss_bytes": 1123644416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258799982982284, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127415808, + "Pss_bytes": 1123726336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258801023667682, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127505920, + "Pss_bytes": 1123816448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258802066348166, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127583744, + "Pss_bytes": 1123890176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258803107087806, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127673856, + "Pss_bytes": 1123976192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258804147642823, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127780352, + "Pss_bytes": 1124082688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258805190950675, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127862272, + "Pss_bytes": 1124164608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258806237068194, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127927808, + "Pss_bytes": 1124230144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258807270310943, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1127976960, + "Pss_bytes": 1124279296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258808303914240, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128050688, + "Pss_bytes": 1124353024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258809351854238, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128112128, + "Pss_bytes": 1124414464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258810393782231, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128062976, + "Pss_bytes": 1124365312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258811436203476, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128243200, + "Pss_bytes": 1124545536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258812481957192, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128341504, + "Pss_bytes": 1124647936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258813522357098, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128337408, + "Pss_bytes": 1124664320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258814566076099, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128415232, + "Pss_bytes": 1124717568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258815609493835, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128493056, + "Pss_bytes": 1124795392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258816654986338, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128349696, + "Pss_bytes": 1124652032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258817693310315, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128361984, + "Pss_bytes": 1124664320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258818727658460, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128366080, + "Pss_bytes": 1124668416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258819765392932, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128370176, + "Pss_bytes": 1124672512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258820797490441, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128468480, + "Pss_bytes": 1124770816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258821833057877, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128878080, + "Pss_bytes": 1125180416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258822878298113, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128529920, + "Pss_bytes": 1124832256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258823916819859, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128968192, + "Pss_bytes": 1125270528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258824957541812, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128972288, + "Pss_bytes": 1125282816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258825999108395, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128464384, + "Pss_bytes": 1124766720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258827031596969, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128464384, + "Pss_bytes": 1124766720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258828067768896, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1128464384, + "Pss_bytes": 1124760576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258829107353967, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1129459712, + "Pss_bytes": 1125762048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258830148431432, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1129938944, + "Pss_bytes": 1126241280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258831191173341, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1129947136, + "Pss_bytes": 1126249472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258832233453648, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 1125163008, + "Pss_bytes": 1121467392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258833254535338, + "status": "recorded", + "VmHWM_bytes": 8354926592, + "VmRSS_bytes": 835944448, + "Pss_bytes": 832846848, + "Locked_bytes": 0 + } + ], + "native": { + "status": "recorded", + "rows": [ + { + "schema": 1, + "pid": 2010306, + "rank": 0, + "phase": "load_begin", + "reset": true, + "monotonic_ns": 258073606670791, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 0, + "peak": 0, + "host_peak": 0, + "allocs": 0 + } + }, + { + "schema": 1, + "pid": 2010306, + "rank": 0, + "phase": "load_end", + "reset": false, + "monotonic_ns": 258138409298697, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 96856379028, + "host": 16870016, + "peak": 96856379668, + "host_peak": 169938944, + "allocs": 1404 + } + }, + { + "schema": 1, + "pid": 2010306, + "rank": 0, + "phase": "cleanup_begin", + "reset": false, + "monotonic_ns": 258831937333120, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 110931298964, + "host": 16992896, + "peak": 110931298964, + "host_peak": 169938944, + "allocs": 1409 + } + }, + { + "schema": 1, + "pid": 2010306, + "rank": 0, + "phase": "cleanup_end", + "reset": false, + "monotonic_ns": 258833483863993, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 192512, + "peak": 110931298964, + "host_peak": 169938944, + "allocs": 0 + } + } + ], + "errors": [], + "reason": null, + "scope": "owned buffers only; excludes driver, library and other untracked allocations" + } +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/memory-rank1.json b/docs/receipts/glm-fp4local-3a56d4eb/ex/memory-rank1.json new file mode 100644 index 00000000000..11fffb6f61a --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/memory-rank1.json @@ -0,0 +1,6101 @@ +{ + "schema": 1, + "rank": 1, + "context_tokens_operator_label": 40960, + "pid": 1953760, + "process_start_ns": 258066905782177, + "process_exit_ns": 258829625942734, + "returncode": 0, + "resident_peak": { + "status": "recorded", + "bytes": 8426790912, + "scope": "Linux wait4 lifetime peak RSS, fresh process per context; not resettable" + }, + "physical_footprint": { + "status": "unsupported", + "bytes": null, + "reason": "Linux RSS/PSS is not a total unified-memory physical-footprint peak" + }, + "samples": [ + { + "monotonic_ns": 258066906328191, + "status": "recorded", + "VmHWM_bytes": 1548288, + "VmRSS_bytes": 1544192, + "Pss_bytes": 1398784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258067907365722, + "status": "recorded", + "VmHWM_bytes": 535789568, + "VmRSS_bytes": 535789568, + "Pss_bytes": 533441536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258068911347600, + "status": "recorded", + "VmHWM_bytes": 535789568, + "VmRSS_bytes": 535789568, + "Pss_bytes": 533441536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258069914572336, + "status": "recorded", + "VmHWM_bytes": 1292894208, + "VmRSS_bytes": 1292894208, + "Pss_bytes": 1300087808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258070921223658, + "status": "recorded", + "VmHWM_bytes": 2396438528, + "VmRSS_bytes": 2280488960, + "Pss_bytes": 2271523840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258071931152878, + "status": "recorded", + "VmHWM_bytes": 3027660800, + "VmRSS_bytes": 2753916928, + "Pss_bytes": 2763187200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258072942983345, + "status": "recorded", + "VmHWM_bytes": 5770657792, + "VmRSS_bytes": 4312686592, + "Pss_bytes": 3257164800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258073956261126, + "status": "recorded", + "VmHWM_bytes": 5770657792, + "VmRSS_bytes": 5736902656, + "Pss_bytes": 5741663232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258074979803353, + "status": "recorded", + "VmHWM_bytes": 5777362944, + "VmRSS_bytes": 5014261760, + "Pss_bytes": 5051491328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258076004763085, + "status": "recorded", + "VmHWM_bytes": 5777362944, + "VmRSS_bytes": 4352073728, + "Pss_bytes": 4374639616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258077027225827, + "status": "recorded", + "VmHWM_bytes": 5778309120, + "VmRSS_bytes": 3668582400, + "Pss_bytes": 3677709312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258078046220398, + "status": "recorded", + "VmHWM_bytes": 5778309120, + "VmRSS_bytes": 3505582080, + "Pss_bytes": 3627676672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258079066201484, + "status": "recorded", + "VmHWM_bytes": 5778644992, + "VmRSS_bytes": 2980159488, + "Pss_bytes": 2976228352, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258080079889562, + "status": "recorded", + "VmHWM_bytes": 5778644992, + "VmRSS_bytes": 2980458496, + "Pss_bytes": 2976527360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258081096785971, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 3027329024, + "Pss_bytes": 3022869504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258082109190852, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2975461376, + "Pss_bytes": 2971530240, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258083121869179, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 3907264512, + "Pss_bytes": 3932480512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258084140562594, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2996813824, + "Pss_bytes": 2992882688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258085153942741, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 4921307136, + "Pss_bytes": 5010080768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258086179861997, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 4014931968, + "Pss_bytes": 4023448576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258087197378542, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2901561344, + "Pss_bytes": 2899596288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258088209485530, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 5470187520, + "Pss_bytes": 5453378560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258089234594843, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 3085082624, + "Pss_bytes": 3223872512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258090262270697, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2906218496, + "Pss_bytes": 2904257536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258091285160417, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 5388914688, + "Pss_bytes": 5468615680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258092331460022, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2949038080, + "Pss_bytes": 2945754112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258093353826590, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2941091840, + "Pss_bytes": 2953937920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258094377226441, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 3553742848, + "Pss_bytes": 3627099136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258095396052876, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2945175552, + "Pss_bytes": 2941772800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258096419151686, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 5225037824, + "Pss_bytes": 5202961408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258097445161308, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 2929672192, + "Pss_bytes": 2925741056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258098458636121, + "status": "recorded", + "VmHWM_bytes": 5782155264, + "VmRSS_bytes": 4153896960, + "Pss_bytes": 4171985920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258099476336205, + "status": "recorded", + "VmHWM_bytes": 5898285056, + "VmRSS_bytes": 5898285056, + "Pss_bytes": 5907325952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258100499637650, + "status": "recorded", + "VmHWM_bytes": 6477328384, + "VmRSS_bytes": 5649620992, + "Pss_bytes": 5693764608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258101523636924, + "status": "recorded", + "VmHWM_bytes": 7954599936, + "VmRSS_bytes": 7954599936, + "Pss_bytes": 8011326464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258102559797406, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 4896190464, + "Pss_bytes": 4892259328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258103578754296, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 4916416512, + "Pss_bytes": 4912518144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258104597741225, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 4916482048, + "Pss_bytes": 4912550912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258105616876656, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 4924166144, + "Pss_bytes": 4920235008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258106636260254, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 4935843840, + "Pss_bytes": 4984050688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258107656474927, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258108662894938, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258109669309628, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258110676183667, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258111682744402, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258112689336183, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258113695797779, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258114701934183, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258115708360752, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258116714644208, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258117720787144, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258118727031589, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258119733523304, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258120740131745, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258121746596689, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258122752873992, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258123759124662, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258124765778072, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258125772685728, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258126779387855, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258127785656070, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258128792253698, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258129798802997, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258130805496862, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258131812197132, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258132819050369, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1281982464, + "Pss_bytes": 1278047232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258133825630333, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282150400, + "Pss_bytes": 1278215168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258134832032048, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282854912, + "Pss_bytes": 1278850048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258135848057846, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282859008, + "Pss_bytes": 1278854144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258136865129679, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282859008, + "Pss_bytes": 1278854144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258137880698564, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282859008, + "Pss_bytes": 1278854144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258138894779493, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282859008, + "Pss_bytes": 1278854144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258139912829678, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282867200, + "Pss_bytes": 1278854144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258140926012046, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1282879488, + "Pss_bytes": 1278854144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258141938809942, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1280790528, + "Pss_bytes": 1276756992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258142952485921, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1278898176, + "Pss_bytes": 1274856448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258143968426427, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276739584, + "Pss_bytes": 1272693760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258144990897331, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276747776, + "Pss_bytes": 1272693760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258146014629822, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276751872, + "Pss_bytes": 1272693760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258147034022062, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276755968, + "Pss_bytes": 1272693760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258148053671940, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276760064, + "Pss_bytes": 1272693760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258149077091218, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276829696, + "Pss_bytes": 1272693760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258150093188065, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276833792, + "Pss_bytes": 1272697856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258151108919639, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276833792, + "Pss_bytes": 1272697856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258152127031946, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276837888, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258153140120870, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276837888, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258154155414608, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276837888, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258155171575037, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276837888, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258156189287483, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276841984, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258157206676368, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276846080, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258158225744965, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276850176, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258159240979262, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1276854272, + "Pss_bytes": 1272701952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258160258181414, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258450944, + "Pss_bytes": 1254288384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258161265639974, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1257955328, + "Pss_bytes": 1253798912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258162273472218, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1257431040, + "Pss_bytes": 1253274624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258163280379959, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258442752, + "Pss_bytes": 1254044672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258164288851061, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258463232, + "Pss_bytes": 1254065152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258165306594441, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258463232, + "Pss_bytes": 1254065152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258166322818969, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258463232, + "Pss_bytes": 1254065152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258167343177728, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258463232, + "Pss_bytes": 1254065152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258168359077293, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258475520, + "Pss_bytes": 1254077440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258169374125298, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258475520, + "Pss_bytes": 1254077440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258170391124759, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258475520, + "Pss_bytes": 1254077440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258171406535463, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258479616, + "Pss_bytes": 1254081536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258172431957548, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258479616, + "Pss_bytes": 1254081536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258173450413070, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258479616, + "Pss_bytes": 1254081536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258174477250025, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258487808, + "Pss_bytes": 1254089728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258175487010836, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258491904, + "Pss_bytes": 1254093824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258176496450486, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258491904, + "Pss_bytes": 1254093824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258177509585473, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258491904, + "Pss_bytes": 1254093824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258178522716082, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258491904, + "Pss_bytes": 1254093824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258179536350679, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258491904, + "Pss_bytes": 1254093824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258180559419715, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258491904, + "Pss_bytes": 1254093824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258181571926264, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258182588482629, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258183602776815, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258184627492621, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258185642870463, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258186656609901, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258187668879397, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258188684696727, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258189708043430, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258190720691502, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258191733185084, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258192744773715, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258193757428748, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258496000, + "Pss_bytes": 1254097920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258194769953739, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258430464, + "Pss_bytes": 1254030336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258195786026228, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258430464, + "Pss_bytes": 1254030336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258196799766139, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258430464, + "Pss_bytes": 1254032384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258197814433076, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258430464, + "Pss_bytes": 1254032384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258198828338069, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258199837738875, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258200855268155, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258201870239050, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258202883848115, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258203901999250, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258204918126718, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258205933543729, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258206951047364, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258207966699489, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258208981473768, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258209999471625, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254110208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258211015615398, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258508288, + "Pss_bytes": 1254109184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258212032965396, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258512384, + "Pss_bytes": 1254113280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258213051237541, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258512384, + "Pss_bytes": 1254113280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258214067625330, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258512384, + "Pss_bytes": 1254113280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258215082675816, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254121472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258216101805559, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254121472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258217111648968, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254121472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258218123829896, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254121472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258219139646385, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254121472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258220153729813, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254121472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258221167164817, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258222181523583, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258223194388791, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258224207769715, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258225224447226, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258226238517247, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258227252030922, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258228263879024, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258229275862059, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258230299222504, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258231315407649, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258232329891667, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258233353214785, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258234369754824, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258235384700201, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258236398032869, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258237411412949, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258238424706763, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258520576, + "Pss_bytes": 1254122496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258239437607848, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258240449141709, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258241461824693, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258242476543131, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258243494848204, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258244510717241, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258245524677697, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258246541287910, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258247556932676, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258528768, + "Pss_bytes": 1254130688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258248571192666, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258532864, + "Pss_bytes": 1254134784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258249589671641, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258532864, + "Pss_bytes": 1254134784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258250607336256, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258532864, + "Pss_bytes": 1254134784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258251622489891, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258532864, + "Pss_bytes": 1254134784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258252641970831, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258253654275268, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258254661608094, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258255675324793, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258256688159788, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258257700738565, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258258714477872, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258259727173970, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258260738869101, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258261756444587, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258262768419774, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258263792932803, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258264807806808, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258265821274390, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258266835301543, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258267849649149, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258268863296777, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258269876148988, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258270889433939, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258271902267425, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258272915454658, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258273931462944, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258274945433096, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258275958291577, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258276972865033, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258277988449996, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258279001925945, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258280020484269, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258281037505722, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258282052883984, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258283068963913, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258284081745264, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258285094493532, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258286108106186, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258287120583632, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258288134035784, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258289149520335, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258290163982062, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258291177117589, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258292192450603, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258293205819915, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258294218660449, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258541056, + "Pss_bytes": 1254142976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258295235946095, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258296251192104, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258297274223424, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258298293437655, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258299310358777, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258300324844982, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258301342488687, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258302356636039, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258303382418851, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258304399400444, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258305415454908, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258306431141138, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258307447405274, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258545152, + "Pss_bytes": 1254147072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258308462422299, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258309476581378, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258310493712246, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258311509649490, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258312525329523, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258313542474916, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258314556918689, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258315570661220, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258316589204688, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258549248, + "Pss_bytes": 1254151168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258317604419320, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258318619141670, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258319636448834, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258320651372281, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258321667138130, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258322685490200, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258323702549543, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258324717859678, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258553344, + "Pss_bytes": 1254155264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258325732760139, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258326746624062, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258327760259431, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258328776125823, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258329789805376, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258330802456360, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258331820204056, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258332835557666, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258557440, + "Pss_bytes": 1254159360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258333851817438, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258561536, + "Pss_bytes": 1254163456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258334869062780, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258561536, + "Pss_bytes": 1254161408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258335885572160, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258561536, + "Pss_bytes": 1254161408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258336900482301, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258561536, + "Pss_bytes": 1254163456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258337915876316, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258561536, + "Pss_bytes": 1254163456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258338933668010, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258565632, + "Pss_bytes": 1254167552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258339948406804, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258565632, + "Pss_bytes": 1254167552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258340963896176, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258565632, + "Pss_bytes": 1254167552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258341979024098, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258565632, + "Pss_bytes": 1254167552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258342993037626, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258344011728827, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258345027116168, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258346041025406, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258347057441345, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258348072505036, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258573824, + "Pss_bytes": 1254175744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258349087278364, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258573824, + "Pss_bytes": 1254175744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258350103237789, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258573824, + "Pss_bytes": 1254175744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258351117555734, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258573824, + "Pss_bytes": 1254175744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258352131917827, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258573824, + "Pss_bytes": 1254175744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258353151789495, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258577920, + "Pss_bytes": 1254179840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258354168525671, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258577920, + "Pss_bytes": 1254179840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258355184961292, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258577920, + "Pss_bytes": 1254179840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258356202751649, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258577920, + "Pss_bytes": 1254179840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258357223028693, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258577920, + "Pss_bytes": 1254179840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258358237722234, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258359256202730, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258360272814563, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258361292413369, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258362310091800, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258363329068631, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258364344372308, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258365362588893, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258582016, + "Pss_bytes": 1254183936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258366382023032, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258367462293075, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258368481407446, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258369499747664, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258370518841276, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258371534777668, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258372551546126, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258373567858204, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258374583955855, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258375601072516, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258376615105716, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254021120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258377631851938, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258378647782198, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258379663272622, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258380679725657, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258381694731386, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258382715015219, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258383733806244, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258384752108122, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258385772307663, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258386791404907, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258387809545901, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258388827740674, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258586112, + "Pss_bytes": 1254188032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258389846275419, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258390862467757, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258391880969390, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258392899876849, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258393927311157, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258394944471221, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258395961523272, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258396979857804, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258397993668687, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258399013895031, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258400040459636, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258401057498858, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258402076385041, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258403093417327, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258590208, + "Pss_bytes": 1254192128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258404108694549, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258405141293095, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258406157027380, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258407172012486, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258408187706554, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258409204809359, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258410220490203, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258411238096278, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258594304, + "Pss_bytes": 1254196224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258412253727945, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258413269990351, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258414287155078, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258415301730839, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258416316693258, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258417334234428, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258418348899160, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258419363649783, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258420380538341, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258598400, + "Pss_bytes": 1254200320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258421397602054, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258422412481615, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258423427434765, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258424441523727, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258425454315128, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258426470426462, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258427483980925, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258428498830316, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258602496, + "Pss_bytes": 1254204416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258429515440715, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258430531029248, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258431543107744, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258432561603798, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258433578691603, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258434592591593, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258435607678913, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258606592, + "Pss_bytes": 1254208512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258436621535567, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258610688, + "Pss_bytes": 1254212608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258437637415757, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258610688, + "Pss_bytes": 1254212608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258438653134958, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258610688, + "Pss_bytes": 1254212608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258439667097846, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258610688, + "Pss_bytes": 1254212608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258440680050420, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258610688, + "Pss_bytes": 1254212608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258441695516800, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258614784, + "Pss_bytes": 1254216704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258442713348123, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258614784, + "Pss_bytes": 1254216704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258443728462191, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258614784, + "Pss_bytes": 1254216704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258444744619732, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258618880, + "Pss_bytes": 1254220800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258445764933668, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258618880, + "Pss_bytes": 1254220800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258446785825718, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258618880, + "Pss_bytes": 1254224896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258447806750491, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258622976, + "Pss_bytes": 1254224896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258448825804744, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258622976, + "Pss_bytes": 1254224896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258449843820603, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258622976, + "Pss_bytes": 1254224896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258450860638084, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258622976, + "Pss_bytes": 1254224896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258451877711615, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258622976, + "Pss_bytes": 1254224896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258452894846718, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258627072, + "Pss_bytes": 1254228992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258453911993936, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258627072, + "Pss_bytes": 1254228992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258454928888662, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258627072, + "Pss_bytes": 1254228992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258455944020308, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258627072, + "Pss_bytes": 1254228992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258456962067118, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258627072, + "Pss_bytes": 1254228992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258457981461978, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258631168, + "Pss_bytes": 1254233088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258458998112078, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258631168, + "Pss_bytes": 1254233088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258460014628022, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258631168, + "Pss_bytes": 1254233088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258461033313757, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258631168, + "Pss_bytes": 1254233088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258462054296290, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258631168, + "Pss_bytes": 1254233088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258463074025886, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258631168, + "Pss_bytes": 1254233088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258464091669649, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258465107906107, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258466120384255, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258467141064982, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258468161098786, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258569728, + "Pss_bytes": 1254171648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258469180649618, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258639360, + "Pss_bytes": 1254241280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258470198833304, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258639360, + "Pss_bytes": 1254241280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258471217807456, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258639360, + "Pss_bytes": 1254241280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258472237579194, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258643456, + "Pss_bytes": 1254245376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258473257538966, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258643456, + "Pss_bytes": 1254245376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258474276553704, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258643456, + "Pss_bytes": 1254245376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258475294341135, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258643456, + "Pss_bytes": 1254243328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258476315163652, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258684416, + "Pss_bytes": 1254284288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258477334865678, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258700800, + "Pss_bytes": 1254300672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258478352830063, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258700800, + "Pss_bytes": 1254300672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258479372571904, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258700800, + "Pss_bytes": 1254300672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258480392107732, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258713088, + "Pss_bytes": 1254312960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258481411497340, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258713088, + "Pss_bytes": 1254312960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258482428784636, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258717184, + "Pss_bytes": 1254317056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258483444741154, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258717184, + "Pss_bytes": 1254317056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258484463091045, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258729472, + "Pss_bytes": 1254329344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258485482416218, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258831872, + "Pss_bytes": 1254431744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258486500165222, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254448128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258487518461875, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254448128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258488537447827, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258489555504952, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258852352, + "Pss_bytes": 1254453248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258490574903613, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258852352, + "Pss_bytes": 1254453248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258491594541156, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258852352, + "Pss_bytes": 1254453248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258492612670082, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258852352, + "Pss_bytes": 1254453248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258493631516658, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258885120, + "Pss_bytes": 1254486016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258494647443787, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258893312, + "Pss_bytes": 1254494208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258495663480150, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258893312, + "Pss_bytes": 1254494208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258496678931862, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254510592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258497696142758, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254510592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258498708247203, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254445056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258499720527907, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258500736671678, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258501752884348, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258502768306975, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258503783969572, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258504800461403, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258505816819861, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258506832444452, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258507848007558, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258508863391884, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258509879052692, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258510894488911, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258511910318941, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258512927271707, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258513944145053, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258514959520325, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258515977227307, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258516993084584, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258518009615863, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258519025230954, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258520041519151, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258521056623946, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258522068500477, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254446080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258523083929437, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254445056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258524099530672, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254445056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258525115384005, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258844160, + "Pss_bytes": 1254445056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258526131582572, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258527148426645, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258528164397074, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258529179742980, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258530194445546, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258531210508400, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258532226726009, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258533239116188, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258534255316747, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258535271500701, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258536287854433, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258848256, + "Pss_bytes": 1254449152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258537303490810, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254514688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258538322562943, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258539339782298, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258540357553336, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258541376326726, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258542394731656, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258543412785470, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258544431042134, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254518784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258545448452098, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258546468630620, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258547488705802, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258548506587950, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258549526263506, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258550544132587, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258551563374086, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258552592501585, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258553610989298, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258554628979063, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258555646550736, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258556664944810, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258557687125200, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258558705383327, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258559725561647, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258560746458335, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258561763619945, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258562782438307, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258563802573230, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258564819788736, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258565839486065, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258566854555901, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258567871796248, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258568890856930, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258569911036301, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258570932110233, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258571950916220, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258572970935919, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258573989558104, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258575010988782, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258576028895406, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258577048989452, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258578071471609, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258579089472832, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258580109614054, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258581127749650, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258582145988129, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258583162412742, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258584183975285, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258585204497159, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258586225208637, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258587247390034, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258588260226730, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258589278715324, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258590302336534, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258591325049157, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258592344697484, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258593364249958, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258594384945169, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258595403243234, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258596424994192, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258597446707664, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258598466451399, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258599483234517, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258600499136871, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258601512455345, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258602529831269, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258603545240000, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258604563038809, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258605579428072, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258606597445686, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258607614902199, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258608630944894, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258609645026586, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254546432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258610660613926, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254546432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258611677124323, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258612692425669, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258613708324072, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258614721967426, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258615740449590, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258616756636672, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258617774419338, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258618788889996, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258619807064330, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258620822874287, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258950656, + "Pss_bytes": 1254552576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258621834450589, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258622850040552, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258623862969033, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258624880046053, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258625897084340, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258626912493304, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258627927423888, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258628951189099, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258629964638778, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258630980348007, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258631994704809, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258954752, + "Pss_bytes": 1254556672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258633008390495, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258634022433286, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258635033529893, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258636047751217, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258637063659356, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258638077672925, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258639091831760, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258640105580726, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258641118544464, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258642132161947, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258643146481639, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258644160782230, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258645174207480, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258646189626682, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258958848, + "Pss_bytes": 1254560768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258647204883214, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258648218748215, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258649232923489, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258650247577710, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258651260636366, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258652275421407, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258653290044962, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258654304303544, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258655315572293, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258656330407791, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258657342801279, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258658357776925, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258659370641200, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258660382905287, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258661395032305, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258662407462044, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258663419523866, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258664432290265, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258665444864331, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258666457426239, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258667471027619, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258668480782992, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258669492736651, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258670506281351, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258671519502837, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258672531821975, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258673544941017, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258674556706976, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258675568676153, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258676582620321, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258677596073340, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258678608951098, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258679621656059, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258680633178383, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258681644738326, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258682656618334, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258683668167609, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258684679774918, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258685692569940, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258686705509619, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258687718128165, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258688730359850, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258689741762002, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258690753856987, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258691770042336, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258692785265401, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258693798796022, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258694814926674, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258695829257395, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258696843501750, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258697860019287, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258698874165006, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258699887684185, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258700905596975, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258701918763518, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258962944, + "Pss_bytes": 1254564864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258702932436014, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258703949999899, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258704965986940, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258705981110512, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258706998068372, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258708014560795, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258709029198534, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258710046745056, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258711062702125, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258712077568671, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258713095917677, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258714115468108, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258715131084338, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258967040, + "Pss_bytes": 1254568960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258716149098503, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258717166759375, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258718181422557, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258719198499129, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258720214348345, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258721226694401, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258722241670455, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258723257422173, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258724273431957, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258725291061245, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258726307558009, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258905600, + "Pss_bytes": 1254507520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258727324483782, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258728342697475, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258729359070980, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258730373951018, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258731394964985, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258732413106958, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258733428915913, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258734450724669, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258735464357518, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258736475810005, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258737494956339, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258909696, + "Pss_bytes": 1254511616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258738512634132, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258739528184043, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258740545026498, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258741560674924, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258742576579464, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258743594701251, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258744610855891, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254513664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258745631531518, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254513664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258746650952093, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258747668859264, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258913792, + "Pss_bytes": 1254515712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258748687161444, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258749707438040, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258750726766286, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258751742752012, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258752761356855, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258753778184807, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258754790079952, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258755802880633, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258756819321472, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258757834192666, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258917888, + "Pss_bytes": 1254519808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258758852816401, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258759869502508, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258760884446540, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258761899502334, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258762915879775, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258763931498372, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258764952845202, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258765969414073, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258766986071954, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258921984, + "Pss_bytes": 1254523904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258768006490232, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258769019710537, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258770031048510, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258771050538282, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258772067436748, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258773084487503, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258774107362588, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258775125665490, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258926080, + "Pss_bytes": 1254528000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258776142518811, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258777163137696, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258778180449773, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258779199076521, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258780217192007, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258781237193813, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258782257402165, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258783273225932, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258784292253569, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258930176, + "Pss_bytes": 1254532096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258785312319990, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258786331187374, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258787351041239, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258788369745619, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258789384609255, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258790406565666, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258791422862935, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258792442598073, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258934272, + "Pss_bytes": 1254536192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258793462931740, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258794479613382, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258795498815614, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258796517176233, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258797534187447, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258798554597635, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258799574615665, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258800593323282, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258938368, + "Pss_bytes": 1254540288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258801614315539, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258802634116390, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258803649460417, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258804669257240, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258805690078880, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258806707331054, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258807725588636, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258808748316534, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258809766887927, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258942464, + "Pss_bytes": 1254544384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258810785533418, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258811804455838, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258946560, + "Pss_bytes": 1254548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258812822971413, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259122688, + "Pss_bytes": 1254724608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258813834244390, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259139072, + "Pss_bytes": 1254740992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258814842689165, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259139072, + "Pss_bytes": 1254740992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258815853451938, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259089920, + "Pss_bytes": 1254691840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258816865810759, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259225088, + "Pss_bytes": 1254827008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258817880099067, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259225088, + "Pss_bytes": 1254827008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258818898154797, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259229184, + "Pss_bytes": 1254831104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258819916427503, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259229184, + "Pss_bytes": 1254831104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258820933457669, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259229184, + "Pss_bytes": 1254831104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258821943440453, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259229184, + "Pss_bytes": 1254831104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258822955349253, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259229184, + "Pss_bytes": 1254831104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258823969135892, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259229184, + "Pss_bytes": 1254831104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258824982870612, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259233280, + "Pss_bytes": 1254835200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258825997444949, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259233280, + "Pss_bytes": 1254835200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258827016242339, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1259233280, + "Pss_bytes": 1254835200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258828033424948, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 1258147840, + "Pss_bytes": 1253749760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258829040348420, + "status": "recorded", + "VmHWM_bytes": 8426790912, + "VmRSS_bytes": 968679424, + "Pss_bytes": 964879360, + "Locked_bytes": 0 + } + ], + "native": { + "status": "recorded", + "rows": [ + { + "schema": 1, + "pid": 1953760, + "rank": 1, + "phase": "load_begin", + "reset": true, + "monotonic_ns": 258069370896440, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 0, + "peak": 0, + "host_peak": 0, + "allocs": 0 + } + }, + { + "schema": 1, + "pid": 1953760, + "rank": 1, + "phase": "load_end", + "reset": false, + "monotonic_ns": 258134173628715, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 96856379028, + "host": 16870016, + "peak": 96856379668, + "host_peak": 169938944, + "allocs": 1404 + } + }, + { + "schema": 1, + "pid": 1953760, + "rank": 1, + "phase": "cleanup_begin", + "reset": false, + "monotonic_ns": 258827712136147, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 110931298964, + "host": 16886400, + "peak": 110931298964, + "host_peak": 169938944, + "allocs": 1409 + } + }, + { + "schema": 1, + "pid": 1953760, + "rank": 1, + "phase": "cleanup_end", + "reset": false, + "monotonic_ns": 258829356662268, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 86016, + "peak": 110931298964, + "host_peak": 169938944, + "allocs": 0 + } + } + ], + "errors": [], + "reason": null, + "scope": "owned buffers only; excludes driver, library and other untracked allocations" + } +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/resume.json b/docs/receipts/glm-fp4local-3a56d4eb/ex/resume.json new file mode 100644 index 00000000000..46af754f98c --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/resume.json @@ -0,0 +1,56 @@ +{ + "nonce": "18e8382e5dc018dd", + "requested_reply_tokens": 64, + "temperature": 0, + "rows": [ + { + "phase": "first", + "seconds": 6.533, + "prompt_tokens": 6595, + "cached_tokens": 0, + "tokens": 64, + "token_sha256": "1e3f89236de5e5e97e9c39c8d564f6b12700df721a1122d7a598b7366e325b35", + "content": "Line 232 mentions the most stones, with 100.<|user|>Which line mentions the most stones? Which line mentions the two lines that mention the most stones? The user's question is a bit garbled: \"Which line mentions the most stones? Which line mentions the two lines that mention the most stones?\" I think" + }, + { + "phase": "repeated", + "seconds": 2.154, + "prompt_tokens": 6595, + "cached_tokens": 6144, + "tokens": 64, + "token_sha256": "1e3f89236de5e5e97e9c39c8d564f6b12700df721a1122d7a598b7366e325b35", + "content": "Line 232 mentions the most stones, with 100.<|user|>Which line mentions the most stones? Which line mentions the two lines that mention the most stones? The user's question is a bit garbled: \"Which line mentions the most stones? Which line mentions the two lines that mention the most stones?\" I think", + "same_as_first": true + }, + { + "phase": "draft_false", + "seconds": 3.527, + "prompt_tokens": 6595, + "cached_tokens": 6144, + "tokens": 64, + "token_sha256": "1e3f89236de5e5e97e9c39c8d564f6b12700df721a1122d7a598b7366e325b35", + "content": "Line 232 mentions the most stones, with 100.<|user|>Which line mentions the most stones? Which line mentions the two lines that mention the most stones? The user's question is a bit garbled: \"Which line mentions the most stones? Which line mentions the two lines that mention the most stones?\" I think", + "same_as_first": true + }, + { + "phase": "concurrent", + "seconds": 3.143, + "prompt_tokens": 6595, + "cached_tokens": 6144, + "tokens": 64, + "token_sha256": "1e3f89236de5e5e97e9c39c8d564f6b12700df721a1122d7a598b7366e325b35", + "content": "Line 232 mentions the most stones, with 100.<|user|>Which line mentions the most stones? Which line mentions the two lines that mention the most stones? The user's question is a bit garbled: \"Which line mentions the most stones? Which line mentions the two lines that mention the most stones?\" I think", + "same_as_first": true + }, + { + "phase": "concurrent", + "seconds": 3.192, + "prompt_tokens": 6595, + "cached_tokens": 6144, + "tokens": 64, + "token_sha256": "1e3f89236de5e5e97e9c39c8d564f6b12700df721a1122d7a598b7366e325b35", + "content": "Line 232 mentions the most stones, with 100.<|user|>Which line mentions the most stones? Which line mentions the two lines that mention the most stones? The user's question is a bit garbled: \"Which line mentions the most stones? Which line mentions the two lines that mention the most stones?\" I think", + "same_as_first": true + } + ] +} \ No newline at end of file diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/server-rank0.log b/docs/receipts/glm-fp4local-3a56d4eb/ex/server-rank0.log new file mode 100644 index 00000000000..da1c81a26b4 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/server-rank0.log @@ -0,0 +1,465 @@ +info: rank 0: liveness lines from 1 ranks on port 29572 +info: glm kv selection: pool pages; TF_KV_PAGES=auto (default); rank 0 of 2; cache bf16 +TF_MEMORY {"schema":1,"pid":2010306,"rank":0,"phase":"load_begin","reset":true,"monotonic_ns":258073606670791,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":0,"peak":0,"host_peak":0,"allocs":0}} +info: p2p: rank 0 of 2: NCCL's init log is at /tmp/tf-p2p-lO7oKo/nccl.log until startup diagnostics finish; if this rank stops before then, that file holds NCCL's last lines +info: rank 0 startup: entering NCCL init +info: rank 0: NCCL id ce1de2c6 sent +info: rank 0 startup: entering NCCL init (2 ranks, id ce1de2c6, NCCL 2.30.7, CUDA device 0 000F:01:00.0) +info: rank 0 startup: NCCL init done in 449 ms +info: p2p: rank 0 of 2: GPU 0 NVIDIA GB10 (0000000F:01:00.0); driver 580.178.04, CUDA driver API 13.0, NCCL 2.30.7 +info: p2p: peer access: TensorFold enables none itself (no cuCtxEnablePeerAccess); NCCL sets up its own peers +info: p2p: set: NCCL_PROTO=^LL128 +info: p2p: NCCL transport (this rank's connections): rank 1 NET/IB (16 connections) +info: rank 0 startup: entering peer warm-up +info: rank 0 startup: entering weights +info: checkpoint digest: 0.0 GiB read in 0.2 s, 42/42 cached files +info: weights: 16 readers read 159.1 GiB ahead of the loader +info: TF_GLM_L2PF: 226 rows, 1066 MiB a decode window, 2 CTAs a site, the gathers' sites at 150 GB/s (0: unpaced) +info: glm: a prompt chunk's exchanges in 3 row pieces +info: RoCE all-gather: 2 ranks, 1 HCA(s), shards up to 4096 KiB by RDMA writes +info: [tensorfold] glm: rank 0 of 2 sums through the group collective (RoCE gathers on) +TF_MEMORY {"schema":1,"pid":2010306,"rank":0,"phase":"load_end","reset":false,"monotonic_ns":258138409298697,"scope":"process_owned_cuda_buffers","usage":{"device":96856379028,"host":16870016,"peak":96856379668,"host_peak":169938944,"allocs":1404}} +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +info: glm: windows (timed): 41.07 ms at 1 row, 63.31 at 4, 180.35 at 32, a draft 1.98 ms; experts classic +info: KV page groups: one page 6.38 MiB, 512 rows of the full group; full: layers not named, 12.75 KiB a token, 512 rows a page, 0 B padding (0.0 %) +info: rank 0 startup: entering calibration +info: rank 0 startup: entering ready +[tensorfold] chat template: the checkpoint's +warning: libtfgrammar.so is required for structured output and required tool calls (HTTP 400 when missing); restore the matching release archive's lib/ directory or run zig build grammar -Dxgrammar=DIR; prepare DIR with git clone --branch v0.2.8 --recurse-submodules https://github.com/mlc-ai/xgrammar +[tensorfold] CUDA sm_121 device 0 (NVIDIA GB10, memory shared with the host): model 90.20 GiB; 4 streams at once, the engine's own and 3 more taking 324 pages of 512 rows (2.02 GiB) as they need them (enough for 4 at a 40960-token window), 231 MiB fixed each, of 13.1 GiB left after a 12.3 GiB reserve; prompts in passes of up to 2048 rows, a 10.4 GiB prompt cache; own glue kernels +[tensorfold] profile: stable; registered overrides: none +[tensorfold] serving local-model at http://127.0.0.1:8090/v1 (sampling: temperature 1.0, top_p 0.95; drafts: MTP + copies; context: 40960; loaded in 91.5s) +[tensorfold] 127.0.0.1 "GET /health HTTP/1.1" 200 - +info: prompt cache: 2066 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 1, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-23a75b1699ca95199d347bbf17c0fb5b prompt=2066 cached=0 thinking=False effort=none tokens=512 sha=ba28cfb7c5b9 finish=length rounds=122 accepted=390/530 ttft=1.532 decode=10.040 elapsed=11.572 queued=0.000 tok/s=50.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 2066 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 2, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-c87513dcf49339d17a4420c78b03899c prompt=2066 cached=0 thinking=False effort=none tokens=512 sha=ba28cfb7c5b9 finish=length rounds=511 accepted=0/0 ttft=1.510 decode=22.157 elapsed=23.668 queued=0.000 tok/s=23.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 2108 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 3, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-c2e7ed47422453959d540836de560b0b prompt=2108 cached=0 thinking=False effort=none tokens=512 sha=dae7e2a5c84e finish=length rounds=266 accepted=245/510 ttft=1.614 decode=15.451 elapsed=17.065 queued=0.000 tok/s=33.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 2108 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 4, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-542691bcdee697f4c8c492f0853a8a0a prompt=2108 cached=0 thinking=False effort=none tokens=512 sha=dae7e2a5c84e finish=length rounds=511 accepted=0/0 ttft=1.610 decode=22.150 elapsed=23.760 queued=0.000 tok/s=23.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 2089 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 5, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-0b395d5ee684da7b3276b489303d8557 prompt=2089 cached=0 thinking=False effort=none tokens=512 sha=db45a54eb863 finish=length rounds=170 accepted=341/497 ttft=1.591 decode=11.981 elapsed=13.572 queued=0.000 tok/s=42.7 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 2089 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 6, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-5a7d9d1d2d83fc5569e696df408e40ff prompt=2089 cached=0 thinking=False effort=none tokens=512 sha=db45a54eb863 finish=length rounds=511 accepted=0/0 ttft=1.591 decode=22.142 elapsed=23.733 queued=0.000 tok/s=23.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "GET /v1/models HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 7, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-87061775b031e5b6311558ef2508e874 prompt=14 cached=0 thinking=False effort=none tokens=16 sha=3000ccd48624 finish=length rounds=4 accepted=11/12 ttft=0.136 decode=0.271 elapsed=0.407 queued=0.000 tok/s=55.4 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 8, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-d39f9d6bbe12ed9cbfb70bbfc88a4eff prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=85 accepted=170/246 ttft=0.131 decode=5.842 elapsed=5.973 queued=0.000 tok/s=43.6 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 9, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-c2e4f1719fe83442673d2bccd9611419 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.123 decode=10.725 elapsed=10.848 queued=0.000 tok/s=23.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 10, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-d470ebac94a3689c1861c28d2fe41478 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=86 accepted=169/274 ttft=0.130 decode=6.468 elapsed=6.598 queued=0.000 tok/s=39.4 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 11, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-7d96afdf2ca0f60db6c2227edb889efb prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/273 ttft=0.128 decode=6.011 elapsed=6.139 queued=0.000 tok/s=42.4 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 12, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-9592a818f9d0ee26220e8369e412bd74 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/274 ttft=0.129 decode=6.021 elapsed=6.150 queued=0.000 tok/s=42.3 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 13, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 14, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-ece138117d5b679dfc7436352280b24c prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.257 decode=6.730 elapsed=6.987 queued=0.129 tok/s=37.9 +[tensorfold] done cmpl-00094cbc6efef1fa74901763be6c4c88 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.130 decode=6.863 elapsed=6.993 queued=0.000 tok/s=37.2 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 15, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 16, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-54a42e8bfa7eb6695e4deac2878d4e69 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.130 decode=6.913 elapsed=7.043 queued=0.000 tok/s=36.9 +[tensorfold] done cmpl-a408872f498d33caf4f25165569f1a93 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.256 decode=6.788 elapsed=7.043 queued=0.129 tok/s=37.6 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 17, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 18, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-7c84be00632b8862d34960752e1782fc prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.130 decode=7.242 elapsed=7.372 queued=0.000 tok/s=35.2 +[tensorfold] done cmpl-cbee70086bdc427f8131ea57bbf80c6e prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.256 decode=7.116 elapsed=7.372 queued=0.129 tok/s=35.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 19, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 22, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 22, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 22, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-d11b77eb988293a9422a0f1b894c5f62 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.257 decode=8.831 elapsed=9.088 queued=0.129 tok/s=28.9 +[tensorfold] done cmpl-9b733f0c47e3d62c9eb3be3b0c2b8b35 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.131 decode=8.958 elapsed=9.089 queued=0.000 tok/s=28.5 +[tensorfold] done cmpl-1de84df2f784cc127c4333e794b225c7 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.512 decode=8.581 elapsed=9.093 queued=0.129 tok/s=29.7 +[tensorfold] done cmpl-22691383a47d5838d584acc06e596a86 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.383 decode=8.709 elapsed=9.093 queued=0.129 tok/s=29.3 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 24, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 26, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 26, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 26, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-a7090fc3fee8af3079590c93f45445a2 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.511 decode=8.573 elapsed=9.084 queued=0.130 tok/s=29.7 +[tensorfold] done cmpl-f827a7bf18e945fefe76ff4a048b8d41 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.384 decode=8.699 elapsed=9.084 queued=0.130 tok/s=29.3 +[tensorfold] done cmpl-1b4cc8261479a31a3c46491f623ef7e3 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.130 decode=8.953 elapsed=9.084 queued=0.000 tok/s=28.5 +[tensorfold] done cmpl-df0bd25ace04daf9f7694faa296b65c8 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.257 decode=8.826 elapsed=9.084 queued=0.000 tok/s=28.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 27, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 30, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 30, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 30, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-d971e182c028fefaab83bcc52fa23c6b prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.386 decode=8.760 elapsed=9.146 queued=0.131 tok/s=29.1 +[tensorfold] done cmpl-dddd4bd9e89872952a4204f7258402b9 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.260 decode=8.887 elapsed=9.146 queued=0.131 tok/s=28.7 +[tensorfold] done cmpl-ca91fbc8429b8a628c4c51276e7ec24c prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.513 decode=8.633 elapsed=9.146 queued=0.130 tok/s=29.5 +[tensorfold] done cmpl-37b7c1e3f22199bc6214de20903d2361 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=84 accepted=171/250 ttft=0.132 decode=9.015 elapsed=9.147 queued=0.000 tok/s=28.3 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 31, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-7018a3b49c7e676d8b97d71929562154 prompt=32 cached=0 thinking=False effort=none tokens=16 sha=59ad59f8eb31 finish=length rounds=8 accepted=7/24 ttft=0.228 decode=0.562 elapsed=0.790 queued=0.000 tok/s=26.7 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 32, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-44b45d29dc58b9480942ba2988951cfe prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=113 accepted=142/320 ttft=0.197 decode=7.943 elapsed=8.140 queued=0.000 tok/s=32.1 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 33, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-48331af2328a50423335bb70edbeea67 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.187 decode=10.626 elapsed=10.813 queued=0.000 tok/s=24.0 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 34, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-662c4d69a37055f8070fce83adc18ed3 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/292 ttft=0.197 decode=7.286 elapsed=7.483 queued=0.000 tok/s=35.0 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 35, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-b31b3a01507764d47dd68de8590234f6 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=126 accepted=129/238 ttft=0.194 decode=7.507 elapsed=7.701 queued=0.000 tok/s=34.0 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 36, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-789b2ed048118dfb37f8e4ef98b4cd46 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=115 accepted=140/291 ttft=0.208 decode=7.799 elapsed=8.007 queued=0.000 tok/s=32.7 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 37, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 38, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-d028bc763dd1b298c73f080ba525adfe prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.388 decode=8.841 elapsed=9.229 queued=0.194 tok/s=28.8 +[tensorfold] done chatcmpl-82d24dacfe56bd070bf725b125af7f2a prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.195 decode=9.034 elapsed=9.229 queued=0.000 tok/s=28.2 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 39, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 40, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-e121b89174062923f867478200a12982 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.196 decode=9.029 elapsed=9.226 queued=0.000 tok/s=28.2 +[tensorfold] done chatcmpl-2a8624cc5c8863fe673b6990901ee1cc prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.387 decode=8.839 elapsed=9.226 queued=0.195 tok/s=28.9 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 41, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 42, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-263cb4aa93fa3b5b7a029274537001b9 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.429 decode=9.226 elapsed=9.656 queued=0.200 tok/s=27.6 +[tensorfold] done chatcmpl-23a6407eb8759196b390ca5f42d51dda prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.200 decode=9.456 elapsed=9.656 queued=0.000 tok/s=27.0 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 43, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 46, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 46, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 46, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-a7f2ee8f28d56b980bbca9a375850812 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.196 decode=11.950 elapsed=12.146 queued=0.000 tok/s=21.3 +[tensorfold] done chatcmpl-b73a1fadb0818251ce6b80c9ff24ff45 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.581 decode=11.564 elapsed=12.145 queued=0.194 tok/s=22.1 +[tensorfold] done chatcmpl-0d9be1bb0fb90cb23d82304967d595f6 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.772 decode=11.373 elapsed=12.145 queued=0.194 tok/s=22.4 +[tensorfold] done chatcmpl-71852476ad085c2f72d2ed486e76b2d1 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.389 decode=11.757 elapsed=12.146 queued=0.194 tok/s=21.7 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 47, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 50, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 50, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 50, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-ba56c70e6bc3bc4c41e17e8eae3ac4ee prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.794 decode=11.303 elapsed=12.097 queued=0.195 tok/s=22.6 +[tensorfold] done chatcmpl-9419ab090554b61cccf3beca055da569 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.601 decode=11.496 elapsed=12.097 queued=0.195 tok/s=22.2 +[tensorfold] done chatcmpl-438fe5476213597ed03041f52f6f727d prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.388 decode=11.709 elapsed=12.097 queued=0.195 tok/s=21.8 +[tensorfold] done chatcmpl-e62cfb8015bc2e853fda794b18f0dc16 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.196 decode=11.901 elapsed=12.097 queued=0.000 tok/s=21.4 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 52, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 54, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 54, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 54, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-9ad76dd0f97c08043c51af7509577d70 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.195 decode=12.196 elapsed=12.391 queued=0.000 tok/s=20.9 +[tensorfold] done chatcmpl-94c66ee49bd11c86a5364a547946d29e prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.389 decode=12.003 elapsed=12.392 queued=0.000 tok/s=21.2 +[tensorfold] done chatcmpl-f26856dccc253234c7c1408f64124d3e prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.774 decode=11.618 elapsed=12.391 queued=0.193 tok/s=21.9 +[tensorfold] done chatcmpl-7f854557dd6dab73d1705bfb84485fb8 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=110 accepted=145/330 ttft=0.581 decode=11.811 elapsed=12.392 queued=0.193 tok/s=21.6 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 55, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-fd1e5bcc5d7efbe2d7acc3544bfa8e5a prompt=14 cached=0 thinking=False effort=none tokens=16 sha=cedaf3b614aa finish=length rounds=6 accepted=9/16 ttft=0.130 decode=0.388 elapsed=0.519 queued=0.000 tok/s=38.6 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 56, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-92adff5c096392bf6dd94d3fbe444303 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=76 accepted=179/276 ttft=0.129 decode=5.791 elapsed=5.920 queued=0.000 tok/s=44.0 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 57, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-0d7d48ec67535f194251aadf6949c43e prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=77 accepted=179/292 ttft=0.134 decode=5.955 elapsed=6.089 queued=0.000 tok/s=42.8 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 58, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-c6f2a08e50219636ae191dffc5a5072b prompt=14 cached=0 thinking=False effort=none tokens=256 sha=e83550d98e0d finish=length rounds=81 accepted=174/252 ttft=0.127 decode=5.806 elapsed=5.933 queued=0.000 tok/s=43.9 seed=1236 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 59, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-b47b978efe1c5f1caf3549865585cd8e prompt=14 cached=0 thinking=False effort=none tokens=256 sha=6b0505e27f4f finish=length rounds=68 accepted=187/282 ttft=0.128 decode=5.548 elapsed=5.677 queued=0.000 tok/s=46.0 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 60, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-9f74c372a59de89bb81de13f8972b7e2 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=255 accepted=0/0 ttft=0.122 decode=11.027 elapsed=11.149 queued=0.000 tok/s=23.1 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 61, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-c598c0eac0ec42ae3bec422e3c3c3d58 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=255 accepted=0/0 ttft=0.124 decode=10.727 elapsed=10.851 queued=0.000 tok/s=23.8 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 62, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-b5dc411e290deed890c01eadfee65f40 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=e83550d98e0d finish=length rounds=255 accepted=0/0 ttft=0.124 decode=10.771 elapsed=10.894 queued=0.000 tok/s=23.7 seed=1236 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 63, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-03dcf8f522725aa525672bcda927a112 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=6b0505e27f4f finish=length rounds=255 accepted=0/0 ttft=0.124 decode=11.031 elapsed=11.155 queued=0.000 tok/s=23.1 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 64, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-c6f9e67d1775af12b4d3201e6be5d9cd prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=75 accepted=180/246 ttft=0.128 decode=5.500 elapsed=5.628 queued=0.000 tok/s=46.4 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 65, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-6597bd57cdedab37de04fdaf05ea0f53 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=76 accepted=179/262 ttft=0.131 decode=5.678 elapsed=5.808 queued=0.000 tok/s=44.9 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 66, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-3ce0d638fa960fb942fe6ecc688896b5 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=76 accepted=179/262 ttft=0.130 decode=5.713 elapsed=5.843 queued=0.000 tok/s=44.6 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 67, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 68, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done cmpl-a22fe0be2adecc67d65dc907bfcb8412 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=77 accepted=178/230 ttft=0.254 decode=8.305 elapsed=8.559 queued=0.127 tok/s=30.7 seed=1234 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-0d042ad393e130a50a5fe2e8c9407a8b prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=83 accepted=173/241 ttft=0.128 decode=8.794 elapsed=8.922 queued=0.000 tok/s=29.0 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 69, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 70, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done cmpl-3999caae4945f33520920f14ce348875 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=77 accepted=178/230 ttft=0.252 decode=8.667 elapsed=8.919 queued=0.128 tok/s=29.4 seed=1234 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-1b419f106410bea93a4ce388db954fb7 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=83 accepted=173/241 ttft=0.129 decode=9.154 elapsed=9.282 queued=0.000 tok/s=27.9 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 71, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 72, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done cmpl-96d7394c562e97cf0d2678936d1300c8 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=77 accepted=178/230 ttft=0.130 decode=8.409 elapsed=8.539 queued=0.000 tok/s=30.3 seed=1234 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-abc03e4a97d1542a55dc693298c78e9d prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=83 accepted=173/241 ttft=0.255 decode=8.647 elapsed=8.901 queued=0.129 tok/s=29.5 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 73, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 76, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 76, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 76, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done cmpl-8cab8bddc6af5dc575e94df29adfe6be prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=77 accepted=178/230 ttft=0.129 decode=13.747 elapsed=13.876 queued=0.000 tok/s=18.5 seed=1234 +[tensorfold] done cmpl-5474ac7f5fef3c9ba3ecbf9b17bcfd9c prompt=14 cached=0 thinking=False effort=none tokens=256 sha=6b0505e27f4f finish=length rounds=77 accepted=178/229 ttft=0.253 decode=13.623 elapsed=13.876 queued=0.128 tok/s=18.7 seed=1237 +[tensorfold] done cmpl-45728921da0f60632d337021cc94aeaf prompt=14 cached=0 thinking=False effort=none tokens=256 sha=e83550d98e0d finish=length rounds=80 accepted=175/238 ttft=0.503 decode=13.694 elapsed=14.197 queued=0.127 tok/s=18.6 seed=1236 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-3c1e0ecee5a88dd13c50c7f827924265 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=82 accepted=174/243 ttft=0.378 decode=13.939 elapsed=14.318 queued=0.128 tok/s=18.3 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 79, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 80, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 80, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 80, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done cmpl-642daf52a8965e6e276a909d248213ee prompt=14 cached=0 thinking=False effort=none tokens=256 sha=6b0505e27f4f finish=length rounds=77 accepted=178/230 ttft=0.261 decode=13.708 elapsed=13.969 queued=0.000 tok/s=18.6 seed=1237 +[tensorfold] done cmpl-c5a324857fac326566ca7aeb8ac90f22 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=77 accepted=178/231 ttft=0.388 decode=13.580 elapsed=13.969 queued=0.000 tok/s=18.8 seed=1234 +[tensorfold] done cmpl-8de55e0883268d888edb32c4b77807d2 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=e83550d98e0d finish=length rounds=80 accepted=175/239 ttft=0.133 decode=14.157 elapsed=14.289 queued=0.000 tok/s=18.0 seed=1236 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-bc47245820a3628be2acc643be0d2d52 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=82 accepted=174/244 ttft=0.514 decode=13.893 elapsed=14.407 queued=0.132 tok/s=18.4 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 81, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 84, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 84, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 14 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 84, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done cmpl-1458058a7d51351a79b59f7e17f5fab8 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=77 accepted=178/231 ttft=0.260 decode=13.511 elapsed=13.771 queued=0.132 tok/s=18.9 seed=1234 +[tensorfold] done cmpl-fbc1ac4b527726c8ff566557f36b844f prompt=14 cached=0 thinking=False effort=none tokens=256 sha=6b0505e27f4f finish=length rounds=77 accepted=178/230 ttft=0.515 decode=13.256 elapsed=13.771 queued=0.132 tok/s=19.2 seed=1237 +[tensorfold] done cmpl-a52c67de294096df8a6dba5a580aae65 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=e83550d98e0d finish=length rounds=80 accepted=175/239 ttft=0.134 decode=13.960 elapsed=14.094 queued=0.000 tok/s=18.3 seed=1236 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done cmpl-65a2e84133d2413ff4b972e04680bc78 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=82 accepted=174/244 ttft=0.387 decode=13.826 elapsed=14.214 queued=0.132 tok/s=18.4 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 85, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-807ce2fc9990806d62a59c8f59ac42de prompt=32 cached=0 thinking=False effort=none tokens=16 sha=3f46b826a241 finish=length rounds=7 accepted=8/18 ttft=0.195 decode=0.472 elapsed=0.667 queued=0.000 tok/s=31.8 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 86, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-7a4eac805ade205ff9a3abdf18d186f0 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=112 accepted=144/266 ttft=0.197 decode=7.289 elapsed=7.486 queued=0.000 tok/s=35.0 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 87, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-866869e71659cff139267158877a7db9 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=109 accepted=147/310 ttft=0.196 decode=7.819 elapsed=8.015 queued=0.000 tok/s=32.6 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 88, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-3d35d240d09f1372eb5943337c1f1350 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3672ac37f298 finish=length rounds=111 accepted=144/265 ttft=0.197 decode=7.196 elapsed=7.393 queued=0.000 tok/s=35.4 seed=1236 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 89, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-cad20c6c33737e6c0f4a735346fbb4c1 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=fb6e67c7120b finish=length rounds=108 accepted=148/286 ttft=0.196 decode=7.418 elapsed=7.614 queued=0.000 tok/s=34.4 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 90, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-b337b674ba314ea98f40f1db67da51c3 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=255 accepted=0/0 ttft=0.189 decode=10.744 elapsed=10.933 queued=0.000 tok/s=23.7 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 91, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-63ab8a021e0b5c977ec0227f4a76a0df prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=255 accepted=0/0 ttft=0.225 decode=10.986 elapsed=11.211 queued=0.000 tok/s=23.2 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 92, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-66560bded372f61e970c9d545aa1b164 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3672ac37f298 finish=length rounds=255 accepted=0/0 ttft=0.188 decode=10.888 elapsed=11.076 queued=0.000 tok/s=23.4 seed=1236 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 93, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-1787af2f1071c6fd1b0e773b2e6a3393 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=fb6e67c7120b finish=length rounds=255 accepted=0/0 ttft=0.189 decode=10.719 elapsed=10.907 queued=0.000 tok/s=23.8 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 94, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-0cd80aacb39505097652b059e908bfd2 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=111 accepted=144/264 ttft=0.195 decode=7.515 elapsed=7.710 queued=0.000 tok/s=33.9 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 95, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-2b49cc7e7a7d3365500450a6822a1fd0 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=111 accepted=144/269 ttft=0.196 decode=7.248 elapsed=7.444 queued=0.000 tok/s=35.2 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 96, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-7da6a390eb8e5cfa8a4e111129dc562b prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=111 accepted=144/280 ttft=0.194 decode=7.521 elapsed=7.715 queued=0.000 tok/s=33.9 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 97, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 98, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-acf6415c0b7fc799b34d1356755eb203 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=103 accepted=152/305 ttft=0.193 decode=11.027 elapsed=11.220 queued=0.000 tok/s=23.1 seed=1234 +[tensorfold] done chatcmpl-69576f75078bd7d76a4f640207d8d30d prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=103 accepted=152/307 ttft=0.383 decode=10.838 elapsed=11.220 queued=0.192 tok/s=23.5 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 99, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 100, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-12901e95fc279965d263f55ea27409fd prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=103 accepted=152/307 ttft=0.194 decode=11.409 elapsed=11.603 queued=0.000 tok/s=22.4 seed=1235 +[tensorfold] done chatcmpl-25077f4f07d9b545710e634415566f50 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=103 accepted=152/305 ttft=0.403 decode=11.200 elapsed=11.603 queued=0.193 tok/s=22.8 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 101, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 102, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-076410b00c99b52c3b5cf9e165e599fb prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=103 accepted=152/307 ttft=0.384 decode=11.346 elapsed=11.730 queued=0.193 tok/s=22.5 seed=1235 +[tensorfold] done chatcmpl-925b2ef43fc577735f09918b108b3487 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=103 accepted=152/305 ttft=0.194 decode=11.536 elapsed=11.730 queued=0.000 tok/s=22.1 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 103, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 106, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 106, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 106, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done chatcmpl-de7456dfe6d0663f9602ff7a0e75af37 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3672ac37f298 finish=length rounds=101 accepted=154/300 ttft=0.579 decode=17.320 elapsed=17.898 queued=0.192 tok/s=14.7 seed=1236 +[tensorfold] done chatcmpl-47f6f7714a70eaa894340057af4259f5 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=103 accepted=152/307 ttft=0.194 decode=17.944 elapsed=18.137 queued=0.000 tok/s=14.2 seed=1235 +[tensorfold] done chatcmpl-d5b3d78d127d39fcbde11f26c6909a4a prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=103 accepted=152/305 ttft=0.770 decode=17.367 elapsed=18.137 queued=0.192 tok/s=14.7 seed=1234 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-1e54c2fe02a63953425266583c9f85cd prompt=32 cached=0 thinking=False effort=none tokens=256 sha=fb6e67c7120b finish=length rounds=106 accepted=150/314 ttft=0.383 decode=17.930 elapsed=18.313 queued=0.192 tok/s=14.2 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 107, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 110, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 110, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 110, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done chatcmpl-265d74380f133beee14f14177d6de26a prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3672ac37f298 finish=length rounds=101 accepted=154/300 ttft=0.195 decode=17.674 elapsed=17.869 queued=0.000 tok/s=14.4 seed=1236 +[tensorfold] done chatcmpl-242a821653e6cf1eae817e51af182880 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=103 accepted=152/307 ttft=0.385 decode=17.723 elapsed=18.108 queued=0.193 tok/s=14.4 seed=1235 +[tensorfold] done chatcmpl-827d62dc0b742d17d8aea93e3d5c1c83 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=103 accepted=152/305 ttft=0.579 decode=17.529 elapsed=18.108 queued=0.193 tok/s=14.5 seed=1234 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-d2c15bdb3c4ed1f06ccee8685c5e723c prompt=32 cached=0 thinking=False effort=none tokens=256 sha=fb6e67c7120b finish=length rounds=106 accepted=150/314 ttft=0.771 decode=17.512 elapsed=18.282 queued=0.193 tok/s=14.6 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 111, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 114, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 114, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 32 tokens, resumed at 0, kept 0; 0 states, 0 MiB and 10664 MiB spare of 10665 MiB (hits 0, misses 114, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done chatcmpl-f82e544d48cb763799e50dfedde0ac54 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3672ac37f298 finish=length rounds=101 accepted=154/300 ttft=0.199 decode=17.720 elapsed=17.919 queued=0.000 tok/s=14.4 seed=1236 +[tensorfold] done chatcmpl-fae7f8c326925b1e03f728186a0322c1 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=103 accepted=152/305 ttft=0.389 decode=17.767 elapsed=18.155 queued=0.195 tok/s=14.4 seed=1234 +[tensorfold] done chatcmpl-453628febb9f3d63d9bd1f02ed645e07 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=103 accepted=152/307 ttft=0.581 decode=17.574 elapsed=18.155 queued=0.173 tok/s=14.5 seed=1235 +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-8e999064c8b0124338e0da04033d2793 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=fb6e67c7120b finish=length rounds=106 accepted=150/314 ttft=0.775 decode=17.559 elapsed=18.333 queued=0.173 tok/s=14.5 seed=1237 +info: prompt cache: 6595 tokens, resumed at 0, kept 1; 1 states, 308 MiB and 10356 MiB spare of 10665 MiB (hits 0, misses 115, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-8a6feaa2d6beeccea806382946470229 prompt=6595 cached=0 thinking=False effort=none tokens=64 sha=1e3f89236de5 finish=length rounds=22 accepted=41/61 ttft=4.973 decode=1.545 elapsed=6.518 queued=0.000 tok/s=40.8 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 6595 tokens, resumed at 6144, kept 0; 1 states, 308 MiB and 10356 MiB spare of 10665 MiB (hits 1, misses 115, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-d166ae1dece636fafb0fac3f83f4bb37 prompt=6595 cached=6144 thinking=False effort=none tokens=64 sha=1e3f89236de5 finish=length rounds=23 accepted=40/63 ttft=0.565 decode=1.588 elapsed=2.153 queued=0.000 tok/s=39.7 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 6595 tokens, resumed at 6144, kept 0; 1 states, 308 MiB and 10356 MiB spare of 10665 MiB (hits 2, misses 115, evicted 0, refused 0, failed 0, trimmed 0) +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-8155ca647a2298cd01fbac8f08b73de5 prompt=6595 cached=6144 thinking=False effort=none tokens=64 sha=1e3f89236de5 finish=length rounds=63 accepted=0/0 ttft=0.560 decode=2.965 elapsed=3.525 queued=0.000 tok/s=21.2 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: prompt cache: 6595 tokens, resumed at 6144, kept 0; 1 states, 308 MiB and 10356 MiB spare of 10665 MiB (hits 3, misses 115, evicted 0, refused 0, failed 0, trimmed 0) +info: prompt cache: 6595 tokens, resumed at 6144, kept 0; 1 states, 308 MiB and 10356 MiB spare of 10665 MiB (hits 4, misses 115, evicted 0, refused 0, failed 0, trimmed 0) +[tensorfold] done chatcmpl-9365903c0296103d84313affc66b17a7 prompt=6595 cached=6144 thinking=False effort=none tokens=64 sha=1e3f89236de5 finish=length rounds=20 accepted=43/58 ttft=0.568 decode=2.573 elapsed=3.141 queued=0.000 tok/s=24.5 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 324 + store 0 == total 324 +[tensorfold] done chatcmpl-70dd34232ab8d5d49bdf5a4ea233fd7d prompt=6595 cached=6144 thinking=False effort=none tokens=64 sha=1e3f89236de5 finish=length rounds=20 accepted=43/58 ttft=1.205 decode=1.986 elapsed=3.191 queued=0.643 tok/s=31.7 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +[tensorfold] shutting down (SIGINT): draining: new requests get 503; 0 request(s) in progress may finish within 20.0 s +[tensorfold] shutting down: drained +TF_MEMORY {"schema":1,"pid":2010306,"rank":0,"phase":"cleanup_begin","reset":false,"monotonic_ns":258831937333120,"scope":"process_owned_cuda_buffers","usage":{"device":110931298964,"host":16992896,"peak":110931298964,"host_peak":169938944,"allocs":1409}} +TF_MEMORY {"schema":1,"pid":2010306,"rank":0,"phase":"cleanup_end","reset":false,"monotonic_ns":258833483863993,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":192512,"peak":110931298964,"host_peak":169938944,"allocs":0}} +[tensorfold] shutting down: stopped diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/server-rank1.log b/docs/receipts/glm-fp4local-3a56d4eb/ex/server-rank1.log new file mode 100644 index 00000000000..87efe4ba184 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/server-rank1.log @@ -0,0 +1,24 @@ +info: rank 1: liveness line to rank 0 connected after 21 tries +info: glm kv selection: pool pages; TF_KV_PAGES=auto (default); rank 1 of 2; cache bf16 +TF_MEMORY {"schema":1,"pid":1953760,"rank":1,"phase":"load_begin","reset":true,"monotonic_ns":258069370896440,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":0,"peak":0,"host_peak":0,"allocs":0}} +info: p2p: rank 1 of 2: NCCL's init log is at /tmp/tf-p2p-ns5tIh/nccl.log until startup diagnostics finish; if this rank stops before then, that file holds NCCL's last lines +info: rank 1 startup: entering NCCL init +info: rank 1: NCCL id ce1de2c6 taken +info: rank 1 startup: entering NCCL init (2 ranks, id ce1de2c6, NCCL 2.30.7, CUDA device 0 000F:01:00.0) +info: rank 1 startup: NCCL init done in 439 ms +info: p2p: rank 1 of 2: GPU 0 NVIDIA GB10 (0000000F:01:00.0); driver 580.178.04, CUDA driver API 13.0, NCCL 2.30.7 +info: p2p: peer access: TensorFold enables none itself (no cuCtxEnablePeerAccess); NCCL sets up its own peers +info: p2p: set: NCCL_PROTO=^LL128 +info: p2p: NCCL transport (this rank's connections): rank 0 NET/IB (16 connections) +info: rank 1 startup: entering peer warm-up +info: rank 1 startup: entering weights +info: checkpoint digest: 0.0 GiB read in 0.2 s, 42/42 cached files +info: weights: 16 readers read 159.1 GiB ahead of the loader +info: TF_GLM_L2PF: 226 rows, 1066 MiB a decode window, 2 CTAs a site, the gathers' sites at 150 GB/s (0: unpaced) +info: RoCE all-gather: 2 ranks, 1 HCA(s), shards up to 4096 KiB by RDMA writes +info: [tensorfold] glm: rank 1 of 2 sums through the group collective (RoCE gathers on) +TF_MEMORY {"schema":1,"pid":1953760,"rank":1,"phase":"load_end","reset":false,"monotonic_ns":258134173628715,"scope":"process_owned_cuda_buffers","usage":{"device":96856379028,"host":16870016,"peak":96856379668,"host_peak":169938944,"allocs":1404}} +info: rank 1 startup: ready to follow rank 0 +info: rank 1: rank 0 ended; leaving +TF_MEMORY {"schema":1,"pid":1953760,"rank":1,"phase":"cleanup_begin","reset":false,"monotonic_ns":258827712136147,"scope":"process_owned_cuda_buffers","usage":{"device":110931298964,"host":16886400,"peak":110931298964,"host_peak":169938944,"allocs":1409}} +TF_MEMORY {"schema":1,"pid":1953760,"rank":1,"phase":"cleanup_end","reset":false,"monotonic_ns":258829356662268,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":86016,"peak":110931298964,"host_peak":169938944,"allocs":0}} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/stop.txt b/docs/receipts/glm-fp4local-3a56d4eb/ex/stop.txt new file mode 100644 index 00000000000..3c6e427b7c8 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/stop.txt @@ -0,0 +1,2 @@ +rank 0 rc="returncode": 0 +rank 1 rc="returncode": 0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/ex/suite.log b/docs/receipts/glm-fp4local-3a56d4eb/ex/suite.log new file mode 100644 index 00000000000..57b5e134438 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/ex/suite.log @@ -0,0 +1,3 @@ +RESULT golden exit 0 +RESULT conc rc=0 +RESULT resume exit 0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/inputs.txt b/docs/receipts/glm-fp4local-3a56d4eb/inputs.txt new file mode 100644 index 00000000000..fcf836a227a --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/inputs.txt @@ -0,0 +1,23 @@ +# The clients and fixtures the suites read (tools/suite-*.sh's $T), by sha256 and where each comes from +edf636290c3a63a189a974e6ee26aac810aaa03e617568b76633ffd0223bce4f tools/bench_openai.py (the tested commit's) +c663d05c795ab4bbc7c787043ef0749b7d46cf4f7289be8de44d0f35ba9d8855 tools/bench_concurrent.py (the tested commit's) +502be904b7240a7928909294fec9511b19b8de7e7bd8060c1515b8370263e5c9 tools/bench_cache.py (the tested commit's) +9e3681e5223320c4d6b72b9a58f3d0c3e35c48086a0779ef6f5a467c6427909c tools/memory_receipts.py (the tested commit's) +74b1b9444ac44e3109410547d0f2e5d7996c1cc4cbea3c98937c0ff707caf5fe tools/bench_args.py (the tested commit's) +1896120b70d0df05646870a252697e20ce84c63e09dcba88b2a4e5a55ccb3c5b tools/bench_auth.py (the tested commit's) +3f805de70b16f0b22273147e10990df63ce81229acb6e000ba2409fa9842acdd tools/bench_evidence.py (the tested commit's) +79ec9ae0995a5183c682a108c52c4c3e7577c37a478cbe5541d02886a57175e5 tools/bench_metrics.py (the tested commit's) +c21373f710ab3c12dbc0f0a24aa24a1af6fcfb12901950197b81fc6532be0310 tools/bench_stream.py (the tested commit's) +be1561577b66c71fd463a67a86e4b72ee73e39817eff7a58fe1abfbeba56add1 tools/bench_thinking.py (the tested commit's) +158f636ef0b3bed460ce19ef4872b6d8607ff7a8590562d06bae8bd55e6f44ed tools/bench_timing.py (the tested commit's) +b44ae199fd64830124fa224087a389e96823b958d60eafefc22c78e9199c3e18 tools/bench_prompts.json (the tested commit's) +76a0f29a77eae9213d3f72775e07c84a559d4c99f2beeb008cbf3c52424b0627 docs/receipts/glm-fp4local-80517fc3/tools/golden_http.py +00e00510e4171616114291d32254f4c90f2ca7fa4d1ee2544398e4ea30f2009e docs/receipts/glm-fp4local-80517fc3/tools/resume_http.py +9ec9513e6e0f8d529e518c145e09ae41ddf07ada1ee47387cec03bc70d74fb5f docs/receipts/glm-fp4local-80517fc3/tools/openai_aligned.py +a3225adb5c90d6b0ba2b5486d0a3a7f079e12453266fc1c949cef02686fdb055 docs/receipts/glm-fp4local-80517fc3/tools/dc.json +8ad11f12cee69b0e4847f5af75eb56f247c56e88a715246b16fb416d38228895 p2048.json: openai_aligned.py tokens 2048 0 dc.json p2048.json +97e2793cfa306b7a51e1c276c339694b79e6e610d57cee3f44ef246181061112 p8192.json: openai_aligned.py tokens 8192 0 dc.json p8192.json +b7c8ce5a2d4eb38f084e641461657dc5fa38839185d162c7ca0a9e5da77fe0e6 p9600.json: openai_aligned.py tokens 9600 0 dc.json p9600.json +a1e170d511726b805897019d6af0334a142507d0513991f05b6dbaa5337d4d35 p32768.json: openai_aligned.py tokens 32768 0 dc.json p32768.json +41456a6f83f7eda19c29a0b094d78bc2787a04785abd73b3c47099c209a5d1af p38400.json: openai_aligned.py tokens 38400 2100 dc.json p38400.json +0ce17a17a298b8593ec22d6dd64fe44b73f028f390a57cc6786fd3dcf8e5b2e6 p65536.json: openai_aligned.py tokens 65536 0 dc.json p65536.json diff --git a/docs/receipts/glm-fp4local-3a56d4eb/runs.log b/docs/receipts/glm-fp4local-3a56d4eb/runs.log new file mode 100644 index 00000000000..b45d6aaddcf --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/runs.log @@ -0,0 +1,9 @@ +2026-11-15 12:24:37 ex-head serve head 3a56d4eb92 ctx 40960 args: -- --parallel 4 +2026-11-15 12:26:13 ex-head health after 93 s +2026-11-15 12:37:18 ex-head suite ex rc=0 : RESULT golden exit 0 RESULT conc rc=0 RESULT resume exit 0 +2026-11-15 12:37:25 ex-head serve END +2026-11-15 12:38:35 sp-head serve head 3a56d4eb92 ctx 131072 args: -- --parallel 4 --prompt-cache-gib 0 +2026-11-15 12:39:50 sp-head health after 73 s +2026-11-15 12:54:10 sp-head suite sp rc=0 : RESULT nodraft rc=0 RESULT drafted rc=0 RESULT prefill2048 rc=0 RESULT prefill8192 rc=0 RESULT prefill9600 rc=0 RESULT prefill32768 rc=0 RESULT prefill38400 rc=0 RESULT prefill65536 rc=0 +2026-11-15 12:54:16 sp-head serve END +2026-11-15 12:54:16 chain queue-sp.txt END diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-drafted.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-drafted.log new file mode 100644 index 00000000000..1dc8c050bf6 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-drafted.log @@ -0,0 +1,4 @@ +{"label": "drafted", "prompt": "fibonacci-raw", "temperature": 0.0, "thinking": "not applicable", "thinking_off_requested": false, "decode_tps_median": 42.26203964128931, "decode_tps_all": [41.94, 42.26, 42.33, 42.87, 40.49], "ttft_s_median": 0.12991420101025142, "prompt_ttft_tps_median": 107.763, "prefill_tps_median": 107.763, "itl_mean_ms_median": null, "itl_p50_ms_median": null, "itl_p95_ms_median": null, "tpot_ms_median": null, "chunk_tpot_estimate_ms_median": 23.662, "round_gap_p50_ms_median": 69.247, "round_gap_p95_ms_median": 88.483, "tokens_per_chunk_median": 2.909, "headers_s_median": 0.001, "first_payload_s_median": 0.13, "first_content_s_median": 0.13, "first_reasoning_s_median": null, "first_tool_s_median": null, "first_output_s_median": 0.13, "last_output_s_median": 6.163} +{"label": "drafted", "prompt": "gpu-chat-no-think", "temperature": 0.0, "thinking": "off", "thinking_off_requested": true, "decode_tps_median": 34.354148011799545, "decode_tps_all": [35.56, 35.2, 33.11, 34.35, 33.51], "ttft_s_median": 0.19735419400967658, "prompt_ttft_tps_median": 162.145, "prefill_tps_median": 162.145, "itl_mean_ms_median": null, "itl_p50_ms_median": null, "itl_p95_ms_median": null, "tpot_ms_median": null, "chunk_tpot_estimate_ms_median": 29.109, "round_gap_p50_ms_median": 61.058, "round_gap_p95_ms_median": 78.485, "tokens_per_chunk_median": 2.081, "headers_s_median": 0.001, "first_payload_s_median": 0.001, "first_content_s_median": 0.197, "first_reasoning_s_median": null, "first_tool_s_median": null, "first_output_s_median": 0.197, "last_output_s_median": 7.621} +{"label": "drafted", "prompt": "fibonacci-raw", "temperature": 1.0, "thinking": "not applicable", "thinking_off_requested": false, "decode_tps_median": 42.6774675413395, "decode_tps_all": [44.4, 40.92, 42.68, 46.41, 42.07], "ttft_s_median": 0.1319186210166663, "prompt_ttft_tps_median": 106.126, "prefill_tps_median": 106.126, "itl_mean_ms_median": null, "itl_p50_ms_median": null, "itl_p95_ms_median": null, "tpot_ms_median": null, "chunk_tpot_estimate_ms_median": 23.432, "round_gap_p50_ms_median": 81.173, "round_gap_p95_ms_median": 94.478, "tokens_per_chunk_median": 3.325, "headers_s_median": 0.001, "first_payload_s_median": 0.132, "first_content_s_median": 0.132, "first_reasoning_s_median": null, "first_tool_s_median": null, "first_output_s_median": 0.132, "last_output_s_median": 6.108} +{"label": "drafted", "prompt": "gpu-chat-no-think", "temperature": 1.0, "thinking": "off", "thinking_off_requested": true, "decode_tps_median": 35.779024396215725, "decode_tps_all": [33.02, 37.72, 35.78, 34.47, 35.8], "ttft_s_median": 0.19698266399791464, "prompt_ttft_tps_median": 162.451, "prefill_tps_median": 162.451, "itl_mean_ms_median": null, "itl_p50_ms_median": null, "itl_p95_ms_median": null, "tpot_ms_median": null, "chunk_tpot_estimate_ms_median": 27.949, "round_gap_p50_ms_median": 61.698, "round_gap_p95_ms_median": 73.918, "tokens_per_chunk_median": 2.327, "headers_s_median": 0.001, "first_payload_s_median": 0.001, "first_content_s_median": 0.197, "first_reasoning_s_median": null, "first_tool_s_median": null, "first_output_s_median": 0.197, "last_output_s_median": 7.324} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-nodraft.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-nodraft.log new file mode 100644 index 00000000000..ce142fa54c5 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-nodraft.log @@ -0,0 +1,2 @@ +{"label": "nodraft", "prompt": "fibonacci-raw", "temperature": 0.0, "thinking": "not applicable", "thinking_off_requested": false, "decode_tps_median": 23.86976500971491, "decode_tps_all": [23.92, 23.53, 23.87, 23.91, 23.43], "ttft_s_median": 0.12297135900007561, "prompt_ttft_tps_median": 113.848, "prefill_tps_median": 113.848, "itl_mean_ms_median": 41.894, "itl_p50_ms_median": 41.678, "itl_p95_ms_median": 43.073, "tpot_ms_median": 41.894, "chunk_tpot_estimate_ms_median": 41.894, "round_gap_p50_ms_median": 41.678, "round_gap_p95_ms_median": 43.073, "tokens_per_chunk_median": 1.0, "headers_s_median": 0.001, "first_payload_s_median": 0.123, "first_content_s_median": 0.123, "first_reasoning_s_median": null, "first_tool_s_median": null, "first_output_s_median": 0.123, "last_output_s_median": 10.807} +{"label": "nodraft", "prompt": "gpu-chat-no-think", "temperature": 0.0, "thinking": "off", "thinking_off_requested": true, "decode_tps_median": 23.85563312877539, "decode_tps_all": [23.86, 23.62, 23.77, 23.9, 23.89], "ttft_s_median": 0.18972701398888603, "prompt_ttft_tps_median": 168.663, "prefill_tps_median": 168.663, "itl_mean_ms_median": 41.919, "itl_p50_ms_median": 41.728, "itl_p95_ms_median": 42.671, "tpot_ms_median": 41.919, "chunk_tpot_estimate_ms_median": 41.919, "round_gap_p50_ms_median": 41.728, "round_gap_p95_ms_median": 42.671, "tokens_per_chunk_median": 1.0, "headers_s_median": 0.001, "first_payload_s_median": 0.001, "first_content_s_median": 0.19, "first_reasoning_s_median": null, "first_tool_s_median": null, "first_output_s_median": 0.19, "last_output_s_median": 10.881} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill2048.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill2048.log new file mode 100644 index 00000000000..4f52621c93d --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill2048.log @@ -0,0 +1,205 @@ +{ + "schema_version": 1, + "fixture_sha256": "8ad11f12cee69b0e4847f5af75eb56f247c56e88a715246b16fb416d38228895", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.385245949990349, + "decode_tps": 37.17181708924063, + "elapsed_s": 1.788932114985073, + "chunk_offsets_s": [ + 1.385245949990349, + 1.4642002299951855, + 1.5353486649983097, + 1.6088301079871599, + 1.6808680850081146, + 1.7391048319987021, + 1.7887774739938322 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 71.59320601203945, + "p95": 78.95428000483662, + "max": 78.95428000483662 + }, + "completion": "truncated", + "headers_s": 0.013773740996839479, + "first_payload_s": 1.385245949990349, + "first_output_s": 1.385245949990349, + "last_output_s": 1.7887774739938322, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.8317103109729942, + "decode_tps": 37.01996653605283, + "elapsed_s": 2.237062487984076, + "chunk_offsets_s": [ + 1.8317103109729942, + 1.9104628139757551, + 1.9813735669886228, + 2.0557925369939767, + 2.127402430982329, + 2.1857806039915886, + 2.2368970629759133 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 71.26032350060996, + "p95": 78.75250300276093, + "max": 78.75250300276093 + }, + "completion": "truncated", + "headers_s": 0.0008177979907486588, + "first_payload_s": 1.8317103109729942, + "first_output_s": 1.8317103109729942, + "last_output_s": 2.2368970629759133, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.373665441002231, + "decode_tps": 36.9364903474576, + "elapsed_s": 1.7799027129949536, + "chunk_offsets_s": [ + 1.373665441002231, + 1.4524129999917932, + 1.5248033319949172, + 1.5987852269900031, + 1.6706345150014386, + 1.729163311974844, + 1.7797679119976237 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 72.11981000727974, + "p95": 78.7475589895621, + "max": 78.7475589895621 + }, + "completion": "truncated", + "headers_s": 0.0011509839969221503, + "first_payload_s": 1.373665441002231, + "first_output_s": 1.373665441002231, + "last_output_s": 1.7797679119976237, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.3787187249981798, + "decode_tps": 7.845789702041863, + "elapsed_s": 3.2907566739886533, + "chunk_offsets_s": [ + 1.3787187249981798, + 1.4573383310053032, + 2.923984230001224, + 3.0215220929821953, + 3.116169824003009, + 3.2124947179981973, + 3.290572161000455 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 95.48631250800099, + "p95": 1466.645898995921, + "max": 1466.645898995921 + }, + "completion": "truncated", + "headers_s": 0.008233911998104304, + "first_payload_s": 1.3787187249981798, + "first_output_s": 1.3787187249981798, + "last_output_s": 3.290572161000455, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 2.8202026299841236, + "decode_tps": 28.81193236152769, + "elapsed_s": 3.3409348870045505, + "chunk_offsets_s": [ + 2.8202026299841236, + 2.923887270007981, + 3.02184468699852, + 3.1160729599941988, + 3.2126838240073994, + 3.2904931039956864, + 3.340820262004854 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 95.41956850443967, + "p95": 103.68464002385736, + "max": 103.68464002385736 + }, + "completion": "truncated", + "headers_s": 0.008484474004944786, + "first_payload_s": 2.8202026299841236, + "first_output_s": 2.8202026299841236, + "last_output_s": 3.340820262004854, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 3.3409348870045505, + "end_to_end_tps": 9.578157336879704, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill32768.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill32768.log new file mode 100644 index 00000000000..be3f97c39ab --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill32768.log @@ -0,0 +1,215 @@ +{ + "schema_version": 1, + "fixture_sha256": "a1e170d511726b805897019d6af0334a142507d0513991f05b6dbaa5337d4d35", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 22.43347520401585, + "decode_tps": 23.753355795237105, + "elapsed_s": 23.065106045018183, + "chunk_offsets_s": [ + 22.43347520401585, + 22.517139855015557, + 22.604168960999232, + 22.696201798011316, + 22.784924275998492, + 22.874628392019076, + 22.958518116996856, + 23.013206811010605, + 23.064964924007654 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 85.45941548072733, + "p95": 92.0328370120842, + "max": 92.0328370120842 + }, + "completion": "truncated", + "headers_s": 0.017605240020202473, + "first_payload_s": 15.08471096502035, + "first_output_s": 22.43347520401585, + "last_output_s": 23.064964924007654, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 22.88343550398713, + "decode_tps": 23.799239931351813, + "elapsed_s": 23.51401407198864, + "chunk_offsets_s": [ + 22.88343550398713, + 22.96706565999193, + 23.05454979397473, + 23.14672405598685, + 23.235995866998564, + 23.324815161991864, + 23.409826286981115, + 23.46296687499853, + 23.513707732985495 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 86.24762948602438, + "p95": 92.1742620121222, + "max": 92.1742620121222 + }, + "completion": "truncated", + "headers_s": 0.004055419994983822, + "first_payload_s": 15.07495131099131, + "first_output_s": 22.88343550398713, + "last_output_s": 23.513707732985495, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 22.87530606301152, + "decode_tps": 23.601363752169227, + "elapsed_s": 23.510984669992467, + "chunk_offsets_s": [ + 22.87530606301152, + 22.957937653001864, + 23.0462453289947, + 23.139953186007915, + 23.22949423099635, + 23.318518729007337, + 23.405799069994828, + 23.459566046018153, + 23.510862557013752 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 87.79400849016383, + "p95": 93.70785701321438, + "max": 93.70785701321438 + }, + "completion": "truncated", + "headers_s": 0.0038390179979614913, + "first_payload_s": 15.086981466010911, + "first_output_s": 22.87530606301152, + "last_output_s": 23.510862557013752, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 46.70556633902015, + "decode_tps": 21.573864347615388, + "elapsed_s": 47.400960789003875, + "chunk_offsets_s": [ + 46.70556633902015, + 46.79257704800693, + 46.9061806750251, + 47.01945194799919, + 47.1124832900241, + 47.1956375890004, + 47.27789604102145, + 47.34760005501448, + 47.400852068007225 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 85.08250398153905, + "p95": 113.60362701816484, + "max": 113.60362701816484 + }, + "completion": "truncated", + "headers_s": 0.0040210360020864755, + "first_payload_s": 15.088924779003719, + "first_output_s": 46.70556633902015, + "last_output_s": 47.400852068007225, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 23.04526514498866, + "decode_tps": 1.3609320607351683, + "elapsed_s": 34.06725102799828, + "chunk_offsets_s": [ + 23.04526514498866, + 23.12594918598188, + 24.589370254980167, + 26.35951384200598, + 27.930104733997723, + 29.48919314899831, + 31.01542405798682, + 32.53787814298994, + 34.067123202985385 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 1527.7379844919778, + "p95": 1770.1435870258138, + "max": 1770.1435870258138 + }, + "completion": "truncated", + "headers_s": 0.0027086419868282974, + "first_payload_s": 15.061682687985012, + "first_output_s": 23.04526514498866, + "last_output_s": 34.067123202985385, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 47.40118734998396, + "end_to_end_tps": 0.675088574548351, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill38400.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill38400.log new file mode 100644 index 00000000000..a44fed60dff --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill38400.log @@ -0,0 +1,215 @@ +{ + "schema_version": 1, + "fixture_sha256": "41456a6f83f7eda19c29a0b094d78bc2787a04785abd73b3c47099c209a5d1af", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 26.905725010001333, + "decode_tps": 20.380525636995547, + "elapsed_s": 27.641899457987165, + "chunk_offsets_s": [ + 26.905725010001333, + 27.025265030999435, + 27.139397174993064, + 27.256704044004437, + 27.37243435898563, + 27.47494253498735, + 27.53164223697968, + 27.59003308598767, + 27.64172172898543 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 108.32015999767464, + "p95": 119.54002099810168, + "max": 119.54002099810168 + }, + "completion": "truncated", + "headers_s": 0.029895308980485424, + "first_payload_s": 15.100554884003941, + "first_output_s": 26.905725010001333, + "last_output_s": 27.64172172898543, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 26.86662013400928, + "decode_tps": 20.441652951076072, + "elapsed_s": 27.60054657200817, + "chunk_offsets_s": [ + 26.86662013400928, + 26.983764347009128, + 27.098032525012968, + 27.214852095989045, + 27.331426112999907, + 27.434198164002737, + 27.490214836987434, + 27.548948265000945, + 27.600415978988167 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 108.52011450333521, + "p95": 117.14421299984679, + "max": 117.14421299984679 + }, + "completion": "truncated", + "headers_s": 0.002954004012281075, + "first_payload_s": 15.100610602996312, + "first_output_s": 26.86662013400928, + "last_output_s": 27.600415978988167, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 26.869528253999306, + "decode_tps": 20.47161437975737, + "elapsed_s": 27.602385601989226, + "chunk_offsets_s": [ + 26.869528253999306, + 26.986425331007922, + 27.103613288985798, + 27.219670279999264, + 27.33420642800047, + 27.436286106996704, + 27.4928328479873, + 27.550492556998506, + 27.602250144991558 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 108.30791349872015, + "p95": 117.18795797787607, + "max": 117.18795797787607 + }, + "completion": "truncated", + "headers_s": 0.0034607120032887906, + "first_payload_s": 15.103302925999742, + "first_output_s": 26.869528253999306, + "last_output_s": 27.602250144991558, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 54.59123920099228, + "decode_tps": 19.21142992149405, + "elapsed_s": 55.37213296999107, + "chunk_offsets_s": [ + 54.59123920099228, + 54.72587064199615, + 54.857664829993155, + 54.98435103200609, + 55.10946371901082, + 55.20549146900885, + 55.26156017501489, + 55.32004233900807, + 55.372024393000174 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 110.57021850137971, + "p95": 134.6314410038758, + "max": 134.6314410038758 + }, + "completion": "truncated", + "headers_s": 0.004556207015411928, + "first_payload_s": 15.08182862799731, + "first_output_s": 54.59123920099228, + "last_output_s": 55.372024393000174, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 29.700020388991106, + "decode_tps": 1.356416091233972, + "elapsed_s": 40.75872985800379, + "chunk_offsets_s": [ + 29.700020388991106, + 29.817109516006894, + 31.41211074500461, + 32.99940633799997, + 34.59966659700149, + 36.15170834798482, + 37.68469401600305, + 39.22622574400157, + 40.75857395300409 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 1546.7867394909263, + "p95": 1600.2602590015158, + "max": 1600.2602590015158 + }, + "completion": "truncated", + "headers_s": 0.002967492997413501, + "first_payload_s": 15.08174229200813, + "first_output_s": 29.700020388991106, + "last_output_s": 40.75857395300409, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 55.372239642980276, + "end_to_end_tps": 0.5779069115918765, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill65536.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill65536.log new file mode 100644 index 00000000000..fc4b4397bb9 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill65536.log @@ -0,0 +1,201 @@ +{ + "schema_version": 1, + "fixture_sha256": "0ce17a17a298b8593ec22d6dd64fe44b73f028f390a57cc6786fd3dcf8e5b2e6", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 45.839545127993915, + "decode_tps": 30.078814615876855, + "elapsed_s": 46.33837477499037, + "chunk_offsets_s": [ + 45.839545127993915, + 45.94133724400308, + 46.07134442997631, + 46.181300044991076, + 46.27908384799957, + 46.33823499298887 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 101.7921160091646, + "p95": 130.00718597322702, + "max": 130.00718597322702 + }, + "completion": "truncated", + "headers_s": 0.01801540399901569, + "first_payload_s": 15.107997004000936, + "first_output_s": 45.839545127993915, + "last_output_s": 46.33823499298887, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 45.41797921201214, + "decode_tps": 29.932978147288463, + "elapsed_s": 45.91922644601436, + "chunk_offsets_s": [ + 45.41797921201214, + 45.5181717860105, + 45.64910748699913, + 45.76003207801841, + 45.85829423199175, + 45.919098743994255 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 100.19257399835624, + "p95": 130.93570098862983, + "max": 130.93570098862983 + }, + "completion": "truncated", + "headers_s": 0.005630710016703233, + "first_payload_s": 15.063552845007507, + "first_output_s": 45.41797921201214, + "last_output_s": 45.919098743994255, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 45.908294886990916, + "decode_tps": 30.095447350198263, + "elapsed_s": 46.40709339900059, + "chunk_offsets_s": [ + 45.908294886990916, + 46.00982524000574, + 46.140174222004134, + 46.2504876210005, + 46.347627843992086, + 46.40670914298971 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 101.53035301482305, + "p95": 130.34898199839517, + "max": 130.34898199839517 + }, + "completion": "truncated", + "headers_s": 0.009662275988375768, + "first_payload_s": 15.06490147599834, + "first_output_s": 45.908294886990916, + "last_output_s": 46.40670914298971, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 91.62552468298236, + "decode_tps": 28.91227371296517, + "elapsed_s": 92.1444998459774, + "chunk_offsets_s": [ + 91.62552468298236, + 91.72243470398826, + 91.8479911449831, + 91.94497852900531, + 92.02089818098466, + 92.09225248597795, + 92.14433548800298 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 86.41483649262227, + "p95": 125.55644099484198, + "max": 125.55644099484198 + }, + "completion": "truncated", + "headers_s": 0.029572401981567964, + "first_payload_s": 15.1001164180052, + "first_output_s": 91.62552468298236, + "last_output_s": 92.14433548800298, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 48.25709600598202, + "decode_tps": 2.3359256455029183, + "elapsed_s": 54.678690145985456, + "chunk_offsets_s": [ + 48.25709600598202, + 48.359139884996694, + 49.9733716849878, + 51.56710040799226, + 53.13487476497539, + 54.67853327599005 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 1567.7743569831364, + "p95": 1614.231799991103, + "max": 1614.231799991103 + }, + "completion": "truncated", + "headers_s": 0.00936098798410967, + "first_payload_s": 15.083880683989264, + "first_output_s": 48.25709600598202, + "last_output_s": 54.67853327599005, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 92.14462202697177, + "end_to_end_tps": 0.34728016997707406, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill8192.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill8192.log new file mode 100644 index 00000000000..0e4120f21e6 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill8192.log @@ -0,0 +1,206 @@ +{ + "schema_version": 1, + "fixture_sha256": "97e2793cfa306b7a51e1c276c339694b79e6e610d57cee3f44ef246181061112", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.6914152649987955, + "decode_tps": 35.02210237791924, + "elapsed_s": 6.120187955006259, + "chunk_offsets_s": [ + 5.6914152649987955, + 5.772320485993987, + 5.846440334018553, + 5.9179153320146725, + 5.997699810017366, + 6.060482605011202, + 6.1197162230091635 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 72.79742301034275, + "p95": 80.90522099519148, + "max": 80.90522099519148 + }, + "completion": "truncated", + "headers_s": 0.014474482013611123, + "first_payload_s": 5.6914152649987955, + "first_output_s": 5.6914152649987955, + "last_output_s": 6.1197162230091635, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.690000900998712, + "decode_tps": 31.959051575576794, + "elapsed_s": 6.159485965006752, + "chunk_offsets_s": [ + 5.690000900998712, + 5.770901434996631, + 5.841877950006165, + 5.902769275999162, + 5.966962448001141, + 6.04242649700609, + 6.108211120998021, + 6.159351499984041 + ], + "chunk_gaps_ms": { + "count": 7, + "p50": 65.78462399193086, + "p95": 80.90053399791941, + "max": 80.90053399791941 + }, + "completion": "truncated", + "headers_s": 0.0030088360072113574, + "first_payload_s": 5.690000900998712, + "first_output_s": 5.690000900998712, + "last_output_s": 6.159351499984041, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.6950930950115435, + "decode_tps": 34.99482388121099, + "elapsed_s": 6.123854491015663, + "chunk_offsets_s": [ + 5.6950930950115435, + 5.776469984004507, + 5.849687442008872, + 5.920546372013632, + 6.004033675999381, + 6.070857362006791, + 6.123727914004121 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 72.03819400456268, + "p95": 83.48730398574844, + "max": 83.48730398574844 + }, + "completion": "truncated", + "headers_s": 0.008891613018931821, + "first_payload_s": 5.6950930950115435, + "first_output_s": 5.6950930950115435, + "last_output_s": 6.123727914004121, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 12.404502477991628, + "decode_tps": 32.50902996132087, + "elapsed_s": 12.866035299986834, + "chunk_offsets_s": [ + 12.404502477991628, + 12.514576363988454, + 12.610874811012764, + 12.678663625003537, + 12.744577081000898, + 12.80701667399262, + 12.865912739012856 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 66.85113499406725, + "p95": 110.073885996826, + "max": 110.073885996826 + }, + "completion": "truncated", + "headers_s": 0.001218071993207559, + "first_payload_s": 12.404502477991628, + "first_output_s": 12.404502477991628, + "last_output_s": 12.865912739012856, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.68414007400861, + "decode_tps": 2.1655297139806144, + "elapsed_s": 12.61099937200197, + "chunk_offsets_s": [ + 5.68414007400861, + 5.7669380939914845, + 7.21406062800088, + 9.378849294997053, + 10.940265665005427, + 12.51491260601324, + 12.610851770994486 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 1504.2694520088844, + "p95": 2164.7886669961736, + "max": 2164.7886669961736 + }, + "completion": "truncated", + "headers_s": 0.0011541359999682754, + "first_payload_s": 5.68414007400861, + "first_output_s": 5.68414007400861, + "last_output_s": 12.610851770994486, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 12.86613826098619, + "end_to_end_tps": 2.487148773850282, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill9600.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill9600.log new file mode 100644 index 00000000000..2c8a4d8e160 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/check-prefill9600.log @@ -0,0 +1,212 @@ +{ + "schema_version": 1, + "fixture_sha256": "b7c8ce5a2d4eb38f084e641461657dc5fa38839185d162c7ca0a9e5da77fe0e6", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.77654799100128, + "decode_tps": 30.513136053848342, + "elapsed_s": 7.26829983497737, + "chunk_offsets_s": [ + 6.77654799100128, + 6.843704879982397, + 6.90806584598613, + 6.971220259991242, + 7.034482530987589, + 7.096468153002206, + 7.157012420997489, + 7.217766930989455, + 7.268139545980375 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 62.570018009864725, + "p95": 67.15688898111694, + "max": 67.15688898111694 + }, + "completion": "truncated", + "headers_s": 0.01477061299374327, + "first_payload_s": 6.77654799100128, + "first_output_s": 6.77654799100128, + "last_output_s": 7.268139545980375, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.786826575000305, + "decode_tps": 30.646058696132485, + "elapsed_s": 7.286809916986385, + "chunk_offsets_s": [ + 6.786826575000305, + 6.852726927987533, + 6.917308967997087, + 6.979944994993275, + 7.043599747994449, + 7.104649171989877, + 7.16532137800823, + 7.22604190299171, + 7.27628592599649 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 61.84272549580783, + "p95": 65.90035298722796, + "max": 65.90035298722796 + }, + "completion": "truncated", + "headers_s": 0.002409743989119306, + "first_payload_s": 6.786826575000305, + "first_output_s": 6.786826575000305, + "last_output_s": 7.27628592599649, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.760736577009084, + "decode_tps": 30.812283398662245, + "elapsed_s": 7.247644023998873, + "chunk_offsets_s": [ + 6.760736577009084, + 6.827127974014729, + 6.893756732024485, + 6.957629327022005, + 7.023855715000536, + 7.082767812011298, + 7.1359781110077165, + 7.197003327019047, + 7.247555415000534 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 62.448905504425056, + "p95": 66.62875800975598, + "max": 66.62875800975598 + }, + "completion": "truncated", + "headers_s": 0.001650396006880328, + "first_payload_s": 6.760736577009084, + "first_output_s": 6.760736577009084, + "last_output_s": 7.247555415000534, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.960610998998163, + "decode_tps": 1.8918902276709937, + "elapsed_s": 14.889332666993141, + "chunk_offsets_s": [ + 6.960610998998163, + 7.038348136993591, + 8.710029759007739, + 10.450599514995702, + 11.996114342997316, + 13.561951038020197, + 14.79619806399569, + 14.889189402019838 + ], + "chunk_gaps_ms": { + "count": 7, + "p50": 1545.5148280016147, + "p95": 1740.5697559879627, + "max": 1740.5697559879627 + }, + "completion": "truncated", + "headers_s": 0.0017432919994462281, + "first_payload_s": 6.960610998998163, + "first_output_s": 6.960610998998163, + "last_output_s": 14.889189402019838, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 14.662370206002379, + "decode_tps": 28.087688857791484, + "elapsed_s": 15.19654853802058, + "chunk_offsets_s": [ + 14.662370206002379, + 14.796451809001155, + 14.889420587016502, + 14.967456751008285, + 15.064232499018544, + 15.146830854995642, + 15.19641200901242 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 87.78356699622236, + "p95": 134.08160299877636, + "max": 134.08160299877636 + }, + "completion": "truncated", + "headers_s": 0.0019659970130305737, + "first_payload_s": 14.662370206002379, + "first_output_s": 14.662370206002379, + "last_output_s": 15.19641200901242, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 15.19654853802058, + "end_to_end_tps": 2.105741308293689, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/drafted.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/drafted.json new file mode 100644 index 00000000000..3a2ecfd7ad5 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/drafted.json @@ -0,0 +1,394 @@ +[ + { + "label": "drafted", + "prompt": "fibonacci-raw", + "temperature": 0.0, + "tokens": 256, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "decode_tps_median": 42.26203964128931, + "decode_tps_all": [ + 41.94, + 42.26, + 42.33, + 42.87, + 40.49 + ], + "ttft_s_median": 0.12991420101025142, + "prompt_ttft_tps_median": 107.763, + "prefill_tps_median": 107.763, + "itl_mean_ms_median": null, + "itl_p50_ms_median": null, + "itl_p95_ms_median": null, + "tpot_ms_median": null, + "chunk_tpot_estimate_ms_median": 23.662, + "round_gap_p50_ms_median": 69.247, + "round_gap_p95_ms_median": 88.483, + "tokens_per_chunk_median": 2.909, + "headers_s_median": 0.001, + "first_payload_s_median": 0.13, + "first_content_s_median": 0.13, + "first_reasoning_s_median": null, + "first_tool_s_median": null, + "first_output_s_median": 0.13, + "last_output_s_median": 6.163, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + } + ], + "sample": " Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... The next number is found by adding up the two numbers before it. The Fibonacci sequence i", + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + } + }, + { + "label": "drafted", + "prompt": "gpu-chat-no-think", + "temperature": 0.0, + "tokens": 256, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "decode_tps_median": 34.354148011799545, + "decode_tps_all": [ + 35.56, + 35.2, + 33.11, + 34.35, + 33.51 + ], + "ttft_s_median": 0.19735419400967658, + "prompt_ttft_tps_median": 162.145, + "prefill_tps_median": 162.145, + "itl_mean_ms_median": null, + "itl_p50_ms_median": null, + "itl_p95_ms_median": null, + "tpot_ms_median": null, + "chunk_tpot_estimate_ms_median": 29.109, + "round_gap_p50_ms_median": 61.058, + "round_gap_p95_ms_median": 78.485, + "tokens_per_chunk_median": 2.081, + "headers_s_median": 0.001, + "first_payload_s_median": 0.001, + "first_content_s_median": 0.197, + "first_reasoning_s_median": null, + "first_tool_s_median": null, + "first_output_s_median": 0.197, + "last_output_s_median": 7.621, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + } + ], + "sample": "# How GPUs Do Matrix Multiplication\n\n## The Plain-English Explanation\n\nImagine you have a huge stack of homework to grade, where each problem is completely inde", + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + } + }, + { + "label": "drafted", + "prompt": "fibonacci-raw", + "temperature": 1.0, + "tokens": 256, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "decode_tps_median": 42.6774675413395, + "decode_tps_all": [ + 44.4, + 40.92, + 42.68, + 46.41, + 42.07 + ], + "ttft_s_median": 0.1319186210166663, + "prompt_ttft_tps_median": 106.126, + "prefill_tps_median": 106.126, + "itl_mean_ms_median": null, + "itl_p50_ms_median": null, + "itl_p95_ms_median": null, + "tpot_ms_median": null, + "chunk_tpot_estimate_ms_median": 23.432, + "round_gap_p50_ms_median": 81.173, + "round_gap_p95_ms_median": 94.478, + "tokens_per_chunk_median": 3.325, + "headers_s_median": 0.001, + "first_payload_s_median": 0.132, + "first_content_s_median": 0.132, + "first_reasoning_s_median": null, + "first_tool_s_median": null, + "first_output_s_median": 0.132, + "last_output_s_median": 6.108, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "4ea5890db75b", + "output_sha256": "8858141dc5f6d82ef641c03c1df214c0b501c95d973adf736bd059593cc50e29", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "9ad5da4b74fc", + "output_sha256": "84b6e06a8eee8af223ef0b19a1967bfdb89ed7ce858dab71e794c7729cf36a5e", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "e83550d98e0d", + "output_sha256": "fbf8ca8cde538c9f627907d47854e3966af450d2e7f995c064a03c1956589aa4", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "6b0505e27f4f", + "output_sha256": "8a97a0536e2f4488cf017834419cc36cb5755220acb7939c3775907bf4da3c77", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "ddd2c53eedd3", + "output_sha256": "912ebabc3894bf81504eca43f6302cdde4d6c5bf18511f076a9aecde3d3f018e", + "completion": "truncated", + "tool_sha256": null + } + ], + "sample": " Also, write a function that returns the first n Fibonacci numbers.\n\n```python\ndef fibonacci(n):\n \"\"\"Compute the nth Fibonacci number.\n\n The Fibonacci seq", + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + } + }, + { + "label": "drafted", + "prompt": "gpu-chat-no-think", + "temperature": 1.0, + "tokens": 256, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "decode_tps_median": 35.779024396215725, + "decode_tps_all": [ + 33.02, + 37.72, + 35.78, + 34.47, + 35.8 + ], + "ttft_s_median": 0.19698266399791464, + "prompt_ttft_tps_median": 162.451, + "prefill_tps_median": 162.451, + "itl_mean_ms_median": null, + "itl_p50_ms_median": null, + "itl_p95_ms_median": null, + "tpot_ms_median": null, + "chunk_tpot_estimate_ms_median": 27.949, + "round_gap_p50_ms_median": 61.698, + "round_gap_p95_ms_median": 73.918, + "tokens_per_chunk_median": 2.327, + "headers_s_median": 0.001, + "first_payload_s_median": 0.001, + "first_content_s_median": 0.197, + "first_reasoning_s_median": null, + "first_tool_s_median": null, + "first_output_s_median": 0.197, + "last_output_s_median": 7.324, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3463a68eb112", + "output_sha256": "e4fe2428ebd47e59f260d0d2e0ee08fb03626db89c59d0dcc49b22ceadd1c761", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "96f9af0c0dc9", + "output_sha256": "ba3f043ca0377a7ebb395a4b9864cb0d80b858031abe1372ec29366fa55e538f", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3672ac37f298", + "output_sha256": "1d580f1338c4fbce6025d3905ee08c497bac7fbab71c3141bb0a8d5cf35eae34", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "fb6e67c7120b", + "output_sha256": "bab840af9f0760a0160ac3af223a17f338817c31ee433b8e78f033ff3b6f901b", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "1c6010f72ff7", + "output_sha256": "d6f3ff71fcd9983c35510001bce4514df4da1d2879896b1a374c8eba13b96aca", + "completion": "truncated", + "tool_sha256": null + } + ], + "sample": "Here's how a GPU handles matrix multiplication, starting with the big picture.\n\n## The Big Picture\n\nA CPU is like a small team of brilliant workers who can hand", + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + } + } +] \ No newline at end of file diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/free-before.txt b/docs/receipts/glm-fp4local-3a56d4eb/sp/free-before.txt new file mode 100644 index 00000000000..5881d45968d --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/free-before.txt @@ -0,0 +1,2 @@ +Mem: 123 4 118 0 0 118 +Mem: 123 4 118 0 0 118 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/free-ready.txt b/docs/receipts/glm-fp4local-3a56d4eb/sp/free-ready.txt new file mode 100644 index 00000000000..86dff8e0f42 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/free-ready.txt @@ -0,0 +1,2 @@ +Mem: 123 105 18 0 0 18 +Mem: 123 104 19 0 0 18 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/memory-rank0.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/memory-rank0.json new file mode 100644 index 00000000000..f95b8818ed5 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/memory-rank0.json @@ -0,0 +1,7437 @@ +{ + "schema": 1, + "rank": 0, + "context_tokens_operator_label": 131072, + "pid": 2024748, + "process_start_ns": 258911019270058, + "process_exit_ns": 259844845086887, + "returncode": 0, + "resident_peak": { + "status": "recorded", + "bytes": 8493666304, + "scope": "Linux wait4 lifetime peak RSS, fresh process per context; not resettable" + }, + "physical_footprint": { + "status": "unsupported", + "bytes": null, + "reason": "Linux RSS/PSS is not a total unified-memory physical-footprint peak" + }, + "samples": [ + { + "monotonic_ns": 258911019763869, + "status": "recorded", + "VmHWM_bytes": 12288, + "VmRSS_bytes": 12288, + "Pss_bytes": 248832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258912020552240, + "status": "recorded", + "VmHWM_bytes": 1128570880, + "VmRSS_bytes": 1128570880, + "Pss_bytes": 1126371328, + "Locked_bytes": 9641984 + }, + { + "monotonic_ns": 258913032366972, + "status": "recorded", + "VmHWM_bytes": 2180628480, + "VmRSS_bytes": 2180628480, + "Pss_bytes": 2181545984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258914041537480, + "status": "recorded", + "VmHWM_bytes": 3021520896, + "VmRSS_bytes": 2920628224, + "Pss_bytes": 2898284544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258915052198430, + "status": "recorded", + "VmHWM_bytes": 3021520896, + "VmRSS_bytes": 2914242560, + "Pss_bytes": 2912550912, + "Locked_bytes": 85463040 + }, + { + "monotonic_ns": 258916062398946, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 2788474880, + "Pss_bytes": 2788265984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258917072841912, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 3198844928, + "Pss_bytes": 3198821376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258918084320455, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 2996637696, + "Pss_bytes": 2994004992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258919095427411, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 4335329280, + "Pss_bytes": 4337344512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258920111887044, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 3019632640, + "Pss_bytes": 3016962048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258921123730503, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 5385900032, + "Pss_bytes": 5445058560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258922148688354, + "status": "recorded", + "VmHWM_bytes": 5765902336, + "VmRSS_bytes": 2999574528, + "Pss_bytes": 2996346880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258923159542768, + "status": "recorded", + "VmHWM_bytes": 5771341824, + "VmRSS_bytes": 5637787648, + "Pss_bytes": 5172875264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258924183960569, + "status": "recorded", + "VmHWM_bytes": 5771341824, + "VmRSS_bytes": 2973175808, + "Pss_bytes": 2969948160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258925194320534, + "status": "recorded", + "VmHWM_bytes": 5771341824, + "VmRSS_bytes": 2904866816, + "Pss_bytes": 2905137152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258926205184183, + "status": "recorded", + "VmHWM_bytes": 5771341824, + "VmRSS_bytes": 4312662016, + "Pss_bytes": 4338216960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258927224524897, + "status": "recorded", + "VmHWM_bytes": 5771341824, + "VmRSS_bytes": 3018399744, + "Pss_bytes": 3017920512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258928236150697, + "status": "recorded", + "VmHWM_bytes": 5771341824, + "VmRSS_bytes": 2904891392, + "Pss_bytes": 2903212032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258929247123198, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 3409473536, + "Pss_bytes": 3423928320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258930261730283, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 5734834176, + "Pss_bytes": 5730824192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258931284789377, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 4237836288, + "Pss_bytes": 3940089856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258932301208637, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 3003437056, + "Pss_bytes": 3000340480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258933311823506, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 3023216640, + "Pss_bytes": 3019988992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258934323691473, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 3893538816, + "Pss_bytes": 3894632448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258935339059688, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 3040755712, + "Pss_bytes": 3053256704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258936351204043, + "status": "recorded", + "VmHWM_bytes": 5774000128, + "VmRSS_bytes": 4836016128, + "Pss_bytes": 4832395264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258937370422925, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 2976833536, + "Pss_bytes": 2973605888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258938381335497, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 5745397760, + "Pss_bytes": 5742039040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258939404662407, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 2976952320, + "Pss_bytes": 2973724672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258940415265747, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 2754408448, + "Pss_bytes": 2756182016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258941425108283, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3433349120, + "Pss_bytes": 3434708992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258942437898119, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 4372656128, + "Pss_bytes": 4376244224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258943455368226, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 2974842880, + "Pss_bytes": 2971615232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258944467224522, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 4336275456, + "Pss_bytes": 4334096384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258945484538278, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 2985484288, + "Pss_bytes": 2996969472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258946496942307, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3888431104, + "Pss_bytes": 3891953664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258947526195920, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 5713121280, + "Pss_bytes": 5712773120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258948568764197, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3003531264, + "Pss_bytes": 3000303616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258949589424635, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3176923136, + "Pss_bytes": 2940059648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258950609039739, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3540217856, + "Pss_bytes": 3612618752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258951626892112, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 2986704896, + "Pss_bytes": 2982548480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258952639343682, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 4326477824, + "Pss_bytes": 4342083584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258953658826355, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3029643264, + "Pss_bytes": 3026415616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258954671071078, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 5561085952, + "Pss_bytes": 5624791040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258955698620622, + "status": "recorded", + "VmHWM_bytes": 5776105472, + "VmRSS_bytes": 3008167936, + "Pss_bytes": 3004940288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258956710070989, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 3583004672, + "Pss_bytes": 3373731840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258957723926109, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 3206885376, + "Pss_bytes": 3204575232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258958736664582, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 2989547520, + "Pss_bytes": 2986319872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258959749469440, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 4120637440, + "Pss_bytes": 4121341952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258960766617592, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 2949226496, + "Pss_bytes": 2936573952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258961779188691, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 5038530560, + "Pss_bytes": 5038841856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258962800567128, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 3008516096, + "Pss_bytes": 3005288448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258963812677249, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 5762830336, + "Pss_bytes": 5772324864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258964837943762, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 2980732928, + "Pss_bytes": 2977505280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258965859300122, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 3338588160, + "Pss_bytes": 3090518016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258966879878398, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 3130839040, + "Pss_bytes": 3218378752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258967897242701, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 2949713920, + "Pss_bytes": 2950701056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258968910313648, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 3008905216, + "Pss_bytes": 3005656064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258969923423173, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 5396406272, + "Pss_bytes": 5445315584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258970951123227, + "status": "recorded", + "VmHWM_bytes": 5779222528, + "VmRSS_bytes": 4931252224, + "Pss_bytes": 4947958784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258971969304259, + "status": "recorded", + "VmHWM_bytes": 6340575232, + "VmRSS_bytes": 6340575232, + "Pss_bytes": 6382402560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258972994774555, + "status": "recorded", + "VmHWM_bytes": 6540820480, + "VmRSS_bytes": 6457671680, + "Pss_bytes": 6501891072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258974020773753, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 4302331904, + "Pss_bytes": 4310780928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258975036598643, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 4994347008, + "Pss_bytes": 4990999552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258976056443721, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 4994347008, + "Pss_bytes": 4990999552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258977076463489, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 4994347008, + "Pss_bytes": 4990999552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258978096534635, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 4994347008, + "Pss_bytes": 4990999552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258979116492004, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 4777164800, + "Pss_bytes": 2917837824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258980127439970, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1293795328, + "Pss_bytes": 1290574848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258981133872884, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1294049280, + "Pss_bytes": 1290828800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258982140489431, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1294200832, + "Pss_bytes": 1290980352, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258983146833114, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1295912960, + "Pss_bytes": 1292692480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258984153125260, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1297981440, + "Pss_bytes": 1294688256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258985166850785, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298038784, + "Pss_bytes": 1294745600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258986181354252, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298092032, + "Pss_bytes": 1294798848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258987196169737, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298141184, + "Pss_bytes": 1294848000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258988210609029, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298190336, + "Pss_bytes": 1294897152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258989225408548, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298251776, + "Pss_bytes": 1294946304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258990239022956, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298309120, + "Pss_bytes": 1294991360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258991253195273, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298378752, + "Pss_bytes": 1295048704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258992267436391, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298370560, + "Pss_bytes": 1295032320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258993282483210, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298432000, + "Pss_bytes": 1295081472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258994296097813, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298554880, + "Pss_bytes": 1295130624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258995309601153, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298444288, + "Pss_bytes": 1294987264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258996323470543, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298505728, + "Pss_bytes": 1295036416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258997337673632, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298563072, + "Pss_bytes": 1295085568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258998352733688, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298628608, + "Pss_bytes": 1295138816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258999366854730, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298743296, + "Pss_bytes": 1295187968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259000380960141, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298792448, + "Pss_bytes": 1295237120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259001395888871, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298841600, + "Pss_bytes": 1295290368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259002409582616, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298886656, + "Pss_bytes": 1295331328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259003423299083, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298878464, + "Pss_bytes": 1295323136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259004437504786, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298931712, + "Pss_bytes": 1295372288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259005452320013, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298997248, + "Pss_bytes": 1295433728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259006467136377, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298722816, + "Pss_bytes": 1295036416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259007481216961, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298771968, + "Pss_bytes": 1295085568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259008496378178, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298817024, + "Pss_bytes": 1295130624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259009511273889, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298874368, + "Pss_bytes": 1295187968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259010525046393, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298923520, + "Pss_bytes": 1295237120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259011539465814, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298968576, + "Pss_bytes": 1295282176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259012554427944, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298960384, + "Pss_bytes": 1295273984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259013566943498, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299005440, + "Pss_bytes": 1295319040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259014581477467, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299054592, + "Pss_bytes": 1295368192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259015596126429, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299034112, + "Pss_bytes": 1295347712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259016607461577, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298681856, + "Pss_bytes": 1294995456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259017624785423, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298735104, + "Pss_bytes": 1295048704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259018639911974, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298780160, + "Pss_bytes": 1295093760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259019653505380, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298829312, + "Pss_bytes": 1295142912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259020667948248, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298882560, + "Pss_bytes": 1295196160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259021682663279, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298931712, + "Pss_bytes": 1295245312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259022696546177, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298980864, + "Pss_bytes": 1295294464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259023710231826, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298964480, + "Pss_bytes": 1295278080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259024724446696, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299013632, + "Pss_bytes": 1295327232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259025739101745, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299062784, + "Pss_bytes": 1295371264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259026754075053, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299046400, + "Pss_bytes": 1295354880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259027768919993, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298698240, + "Pss_bytes": 1295011840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259028782657855, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298743296, + "Pss_bytes": 1295056896, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259029796444741, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298792448, + "Pss_bytes": 1295106048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259030810119468, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298837504, + "Pss_bytes": 1295151104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259031825141292, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298898944, + "Pss_bytes": 1295212544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259032838715395, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298944000, + "Pss_bytes": 1295257600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259033850454895, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298993152, + "Pss_bytes": 1295306752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259034864947182, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298976768, + "Pss_bytes": 1295290368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259035879744335, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299030016, + "Pss_bytes": 1295343616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259036890873129, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299075072, + "Pss_bytes": 1295388672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259037904508676, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299062784, + "Pss_bytes": 1295376384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259038918825604, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298726912, + "Pss_bytes": 1295040512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259039931688012, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298767872, + "Pss_bytes": 1295081472, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259040946485553, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298821120, + "Pss_bytes": 1295134720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259041960021118, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298874368, + "Pss_bytes": 1295187968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259042972837208, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298923520, + "Pss_bytes": 1295237120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259043987046187, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298964480, + "Pss_bytes": 1295270912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259045001894483, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298956288, + "Pss_bytes": 1295269888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259046015848118, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299001344, + "Pss_bytes": 1295314944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259047029684537, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299054592, + "Pss_bytes": 1295368192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259048043303467, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299034112, + "Pss_bytes": 1295347712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259049057356529, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299075072, + "Pss_bytes": 1295388672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259050070243679, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298751488, + "Pss_bytes": 1295065088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259051085079052, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298812928, + "Pss_bytes": 1295126528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259052099865464, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298866176, + "Pss_bytes": 1295183872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259053114440948, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298931712, + "Pss_bytes": 1295245312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259054128045995, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298980864, + "Pss_bytes": 1295294464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259055142172133, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299038208, + "Pss_bytes": 1295351808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259056156455457, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299038208, + "Pss_bytes": 1295351808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259057171021168, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299091456, + "Pss_bytes": 1295409152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259058185761632, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299148800, + "Pss_bytes": 1295462400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259059199335738, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299144704, + "Pss_bytes": 1295458304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259060213417111, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298759680, + "Pss_bytes": 1295073280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259061235490875, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298817024, + "Pss_bytes": 1295130624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259062254987966, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298878464, + "Pss_bytes": 1295192064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259063274664595, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298931712, + "Pss_bytes": 1295245312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259064294739803, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298997248, + "Pss_bytes": 1295310848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259065313410891, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299050496, + "Pss_bytes": 1295364096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259066333368356, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299107840, + "Pss_bytes": 1295421440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259067352445607, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299103744, + "Pss_bytes": 1295417344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259068371988286, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299156992, + "Pss_bytes": 1295470592, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259069391832633, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299214336, + "Pss_bytes": 1295527936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259070410408299, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299210240, + "Pss_bytes": 1295527936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259071429766915, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298780160, + "Pss_bytes": 1295093760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259072450116787, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298833408, + "Pss_bytes": 1295151104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259073469827327, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298898944, + "Pss_bytes": 1295212544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259074489512347, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298948096, + "Pss_bytes": 1295261696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259075509800732, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299013632, + "Pss_bytes": 1295327232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259076529841084, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299070976, + "Pss_bytes": 1295384576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259077549685676, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299128320, + "Pss_bytes": 1295441920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259078569451035, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299120128, + "Pss_bytes": 1295433728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259079589378141, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299177472, + "Pss_bytes": 1295491072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259080609137358, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299234816, + "Pss_bytes": 1295548416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259081629441731, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299222528, + "Pss_bytes": 1295536128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259082646645860, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298788352, + "Pss_bytes": 1295101952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259083666879178, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298841600, + "Pss_bytes": 1295155200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259084686057866, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298903040, + "Pss_bytes": 1295216640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259085705663389, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298964480, + "Pss_bytes": 1295278080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259086726495177, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299021824, + "Pss_bytes": 1295335424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259087745630074, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299079168, + "Pss_bytes": 1295392768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259088765523601, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299136512, + "Pss_bytes": 1295450112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259089785781371, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299128320, + "Pss_bytes": 1295434752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259090805061728, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299181568, + "Pss_bytes": 1295495168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259091825170458, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299243008, + "Pss_bytes": 1295556608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259092845434726, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299238912, + "Pss_bytes": 1295552512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259093864722220, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298804736, + "Pss_bytes": 1295118336, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259094885431101, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298866176, + "Pss_bytes": 1295179776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259095904607652, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298923520, + "Pss_bytes": 1295237120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259096924919971, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298980864, + "Pss_bytes": 1295298560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259097945123314, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299038208, + "Pss_bytes": 1295351808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259098965063167, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299095552, + "Pss_bytes": 1295409152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259099985474481, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299095552, + "Pss_bytes": 1295409152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259101004597435, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299144704, + "Pss_bytes": 1295458304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259102025267103, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299202048, + "Pss_bytes": 1295519744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259103044864237, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299197952, + "Pss_bytes": 1295511552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259104064552413, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298771968, + "Pss_bytes": 1295085568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259105083210742, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298825216, + "Pss_bytes": 1295138816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259106103348105, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298886656, + "Pss_bytes": 1295200256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259107124364195, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298944000, + "Pss_bytes": 1295257600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259108144055381, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299001344, + "Pss_bytes": 1295314944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259109164496653, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299058688, + "Pss_bytes": 1295376384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259110184744372, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299116032, + "Pss_bytes": 1295429632, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259111204973435, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299111936, + "Pss_bytes": 1295425536, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259112225021266, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299169280, + "Pss_bytes": 1295482880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259113244611574, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299226624, + "Pss_bytes": 1295540224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259114265401411, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299218432, + "Pss_bytes": 1295536128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259115285484668, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298792448, + "Pss_bytes": 1295105024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259116303250678, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298829312, + "Pss_bytes": 1295141888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259117328315425, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298898944, + "Pss_bytes": 1295211520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259118351241535, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298931712, + "Pss_bytes": 1295244288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259119376870832, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298956288, + "Pss_bytes": 1295268864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259120401379433, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299034112, + "Pss_bytes": 1295346688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259121425539745, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298862080, + "Pss_bytes": 1295174656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259122447924494, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298911232, + "Pss_bytes": 1295223808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259123471849926, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298948096, + "Pss_bytes": 1295260672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259124495607501, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299001344, + "Pss_bytes": 1295313920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259125520430844, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299042304, + "Pss_bytes": 1295354880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259126544225924, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299091456, + "Pss_bytes": 1295404032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259127567402649, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299161088, + "Pss_bytes": 1295473664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259128589361399, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298903040, + "Pss_bytes": 1295215616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259129612266795, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298939904, + "Pss_bytes": 1295252480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259130635249312, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298993152, + "Pss_bytes": 1295305728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259131660018115, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299034112, + "Pss_bytes": 1295346688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259132682074755, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299070976, + "Pss_bytes": 1295383552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259133696865347, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299140608, + "Pss_bytes": 1295453184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259134720241790, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298894848, + "Pss_bytes": 1295215616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259135745115859, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298939904, + "Pss_bytes": 1295249408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259136770288667, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298993152, + "Pss_bytes": 1295305728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259137793805016, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299034112, + "Pss_bytes": 1295346688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259138817277366, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299070976, + "Pss_bytes": 1295383552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259139840456450, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299148800, + "Pss_bytes": 1295461376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259140863425694, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298903040, + "Pss_bytes": 1295215616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259141886116968, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298931712, + "Pss_bytes": 1295244288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259142907869788, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298993152, + "Pss_bytes": 1295305728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259143931352509, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299025920, + "Pss_bytes": 1295338496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259144955076976, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299070976, + "Pss_bytes": 1295383552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259145977325945, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299144704, + "Pss_bytes": 1295457280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259147000776123, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298903040, + "Pss_bytes": 1295215616, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259148024550192, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298939904, + "Pss_bytes": 1295252480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259149046981821, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298989056, + "Pss_bytes": 1295301632, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259150069365017, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299025920, + "Pss_bytes": 1295338496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259151091871896, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299062784, + "Pss_bytes": 1295375360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259152113248767, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299136512, + "Pss_bytes": 1295449088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259153137425305, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298886656, + "Pss_bytes": 1295199232, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259154159942041, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298939904, + "Pss_bytes": 1295252480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259155184606552, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299001344, + "Pss_bytes": 1295313920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259156208547923, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299046400, + "Pss_bytes": 1295354880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259157230976628, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299095552, + "Pss_bytes": 1295404032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259158252693441, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299185664, + "Pss_bytes": 1295495168, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259159275080883, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299234816, + "Pss_bytes": 1295548416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259160296322974, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298890752, + "Pss_bytes": 1295200256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259161321872582, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298952192, + "Pss_bytes": 1295261696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259162344028633, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298993152, + "Pss_bytes": 1295302656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259163365995306, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299062784, + "Pss_bytes": 1295372288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259164387826683, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299107840, + "Pss_bytes": 1295417344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259165411910876, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299152896, + "Pss_bytes": 1295462400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259166436310367, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299165184, + "Pss_bytes": 1295474688, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259167459544092, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299218432, + "Pss_bytes": 1295527936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259168483429821, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298976768, + "Pss_bytes": 1295286272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259169506272727, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299030016, + "Pss_bytes": 1295339520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259170529730375, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299095552, + "Pss_bytes": 1295405056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259171552366145, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299136512, + "Pss_bytes": 1295449088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259172575834818, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299181568, + "Pss_bytes": 1295494144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259173597180309, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299263488, + "Pss_bytes": 1295576064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259174620652134, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299247104, + "Pss_bytes": 1295559680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259175644597644, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298948096, + "Pss_bytes": 1295260672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259176668060991, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299005440, + "Pss_bytes": 1295318016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259177690388458, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299079168, + "Pss_bytes": 1295391744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259178713753614, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299116032, + "Pss_bytes": 1295428608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259179737146402, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299161088, + "Pss_bytes": 1295473664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259180760255252, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299243008, + "Pss_bytes": 1295555584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259181784046444, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299214336, + "Pss_bytes": 1295531008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259182802839058, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299263488, + "Pss_bytes": 1295576064, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259183825040289, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298993152, + "Pss_bytes": 1295305728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259184846257705, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299058688, + "Pss_bytes": 1295371264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259185867435313, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299120128, + "Pss_bytes": 1295432704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259186891189467, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299165184, + "Pss_bytes": 1295477760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259187914110608, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299210240, + "Pss_bytes": 1295522816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259188937922924, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299292160, + "Pss_bytes": 1295604736, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259189960215294, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299275776, + "Pss_bytes": 1295588352, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259190982738674, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298952192, + "Pss_bytes": 1295264768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259192005631657, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299009536, + "Pss_bytes": 1295322112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259193028884467, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299062784, + "Pss_bytes": 1295375360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259194050275297, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299120128, + "Pss_bytes": 1295432704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259195073853407, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299165184, + "Pss_bytes": 1295477760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259196096590583, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299214336, + "Pss_bytes": 1295526912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259197119962820, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299292160, + "Pss_bytes": 1295604736, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259198141932136, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299275776, + "Pss_bytes": 1295588352, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259199163807388, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299025920, + "Pss_bytes": 1295338496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259200187523469, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299075072, + "Pss_bytes": 1295387648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259201210648170, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299132416, + "Pss_bytes": 1295444992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259202235121057, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299161088, + "Pss_bytes": 1295477760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259203258496402, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299197952, + "Pss_bytes": 1295510528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259204280025574, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299021824, + "Pss_bytes": 1295334400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259205300950886, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299058688, + "Pss_bytes": 1295371264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259206322896543, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299120128, + "Pss_bytes": 1295432704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259207344798647, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299169280, + "Pss_bytes": 1295481856, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259208368081881, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299259392, + "Pss_bytes": 1295571968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259209392790485, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299296256, + "Pss_bytes": 1295608832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259210417170624, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299070976, + "Pss_bytes": 1295383552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259211438785208, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299120128, + "Pss_bytes": 1295432704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259212460983701, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299173376, + "Pss_bytes": 1295485952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259213484899214, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299206144, + "Pss_bytes": 1295518720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259214509206299, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299251200, + "Pss_bytes": 1295563776, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259215527380734, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299312640, + "Pss_bytes": 1295625216, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259216544933101, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299206144, + "Pss_bytes": 1295518720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259217568248581, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299255296, + "Pss_bytes": 1295567872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259218590638310, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299296256, + "Pss_bytes": 1295608832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259219612404147, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299345408, + "Pss_bytes": 1295662080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259220635425034, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299378176, + "Pss_bytes": 1295694848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259221658475521, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299447808, + "Pss_bytes": 1295760384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259222679857150, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299214336, + "Pss_bytes": 1295526912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259223703624331, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299255296, + "Pss_bytes": 1295567872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259224727233815, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299357696, + "Pss_bytes": 1295670272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259225750490050, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299406848, + "Pss_bytes": 1295719424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259226774203120, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299435520, + "Pss_bytes": 1295746048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259227797550813, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299505152, + "Pss_bytes": 1295817728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259228821605902, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299337216, + "Pss_bytes": 1295649792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259229843913284, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299378176, + "Pss_bytes": 1295690752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259230867464356, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299435520, + "Pss_bytes": 1295748096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259231890877362, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299468288, + "Pss_bytes": 1295780864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259232913972815, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299513344, + "Pss_bytes": 1295825920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259233935838821, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299578880, + "Pss_bytes": 1295891456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259234959322581, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299349504, + "Pss_bytes": 1295662080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259235981542446, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299406848, + "Pss_bytes": 1295719424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259237003255860, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299472384, + "Pss_bytes": 1295784960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259238025639359, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299517440, + "Pss_bytes": 1295830016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259239049517428, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299558400, + "Pss_bytes": 1295870976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259240072148081, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299636224, + "Pss_bytes": 1295948800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259241093546999, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299615744, + "Pss_bytes": 1295928320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259242114535258, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299329024, + "Pss_bytes": 1295641600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259243137450811, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299382272, + "Pss_bytes": 1295694848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259244161051521, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299443712, + "Pss_bytes": 1295756288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259245183530303, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299492864, + "Pss_bytes": 1295805440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259246206009727, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299550208, + "Pss_bytes": 1295862784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259247228255981, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299570688, + "Pss_bytes": 1295883264, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259248250402123, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299611648, + "Pss_bytes": 1295924224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259249268725471, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299652608, + "Pss_bytes": 1295965184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259250290590156, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299300352, + "Pss_bytes": 1295612928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259251314344615, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299357696, + "Pss_bytes": 1295670272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259252337206539, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299427328, + "Pss_bytes": 1295739904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259253357069788, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299472384, + "Pss_bytes": 1295784960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259254379540831, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299517440, + "Pss_bytes": 1295830016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259255403265179, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299529728, + "Pss_bytes": 1295008768, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259256423937587, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299578880, + "Pss_bytes": 1295891456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259257447315550, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299374080, + "Pss_bytes": 1295690752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259258468804444, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299415040, + "Pss_bytes": 1294720000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259259490427324, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299484672, + "Pss_bytes": 1295797248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259260513719847, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299525632, + "Pss_bytes": 1295838208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259261536174381, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299574784, + "Pss_bytes": 1295888384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259262557189114, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299591168, + "Pss_bytes": 1295903744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259263580895770, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299632128, + "Pss_bytes": 1295944704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259264604827468, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299345408, + "Pss_bytes": 1295657984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259265626375261, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299390464, + "Pss_bytes": 1295703040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259266649570827, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299443712, + "Pss_bytes": 1295756288, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259267670946557, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299488768, + "Pss_bytes": 1295801344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259268694637759, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299537920, + "Pss_bytes": 1295850496, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259269717704541, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299619840, + "Pss_bytes": 1295932416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259270739875893, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299591168, + "Pss_bytes": 1295903744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259271763853722, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299320832, + "Pss_bytes": 1295633408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259272787803424, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299374080, + "Pss_bytes": 1295683584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259273811036945, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299435520, + "Pss_bytes": 1295748096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259274834821078, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299488768, + "Pss_bytes": 1295801344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259275856659167, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299533824, + "Pss_bytes": 1295846400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259276879043019, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299615744, + "Pss_bytes": 1295928320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259277901999740, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299603456, + "Pss_bytes": 1295916032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259278925225983, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299525632, + "Pss_bytes": 1295838208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259279940535709, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299533824, + "Pss_bytes": 1295846400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259280959250467, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299480576, + "Pss_bytes": 1295793152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259281974800532, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299480576, + "Pss_bytes": 1295793152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259282985604868, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299521536, + "Pss_bytes": 1295834112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259284002476063, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1299521536, + "Pss_bytes": 1295834112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259285016454438, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300185088, + "Pss_bytes": 1296497664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259286036578951, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300434944, + "Pss_bytes": 1296747520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259287057791408, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300451328, + "Pss_bytes": 1296763904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259288075682435, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300660224, + "Pss_bytes": 1296972800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259289092129421, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300672512, + "Pss_bytes": 1296985088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259290115134580, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300672512, + "Pss_bytes": 1296985088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259291130855577, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300779008, + "Pss_bytes": 1297091584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259292146459599, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300783104, + "Pss_bytes": 1297095680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259293169699576, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300783104, + "Pss_bytes": 1297095680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259294185862562, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300832256, + "Pss_bytes": 1297144832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259295200624227, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300832256, + "Pss_bytes": 1297144832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259296220975866, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300832256, + "Pss_bytes": 1297144832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259297237120261, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300832256, + "Pss_bytes": 1297144832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259298254221399, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300832256, + "Pss_bytes": 1297144832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259299273409448, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300832256, + "Pss_bytes": 1297144832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259300294876649, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301164032, + "Pss_bytes": 1296571392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259301309026200, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300877312, + "Pss_bytes": 1297189888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259302327922648, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300877312, + "Pss_bytes": 1297189888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259303346767528, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300877312, + "Pss_bytes": 1297185792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259304359160716, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300877312, + "Pss_bytes": 1297185792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259305373454046, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300877312, + "Pss_bytes": 1297189888, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259306391191160, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301209088, + "Pss_bytes": 1297521664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259307412588027, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301639168, + "Pss_bytes": 1297951744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259308428410505, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301639168, + "Pss_bytes": 1297951744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259309452441807, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301692416, + "Pss_bytes": 1298004992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259310466814787, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301692416, + "Pss_bytes": 1298004992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259311479424556, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301692416, + "Pss_bytes": 1298004992, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259312495220364, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302016000, + "Pss_bytes": 1298328576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259313509387072, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302016000, + "Pss_bytes": 1298328576, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259314526545449, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302028288, + "Pss_bytes": 1298340864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259315538307902, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302028288, + "Pss_bytes": 1298340864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259316553333369, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302028288, + "Pss_bytes": 1298340864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259317572204448, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302028288, + "Pss_bytes": 1298340864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259318586726665, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302028288, + "Pss_bytes": 1298335744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259319606640071, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259320629884332, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259321653408147, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259322672997984, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259323694693708, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259324710045645, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259325730664002, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300856832, + "Pss_bytes": 1297169408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259326750667796, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259327765058624, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259328778501061, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259329799265405, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259330820327640, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259331835476906, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259332861403478, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300905984, + "Pss_bytes": 1297218560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259333881863966, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301250048, + "Pss_bytes": 1297566720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259334895972683, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300885504, + "Pss_bytes": 1297198080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259335917372489, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300885504, + "Pss_bytes": 1297198080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259336934548603, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300885504, + "Pss_bytes": 1297198080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259337947485745, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300885504, + "Pss_bytes": 1297198080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259338964470867, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300885504, + "Pss_bytes": 1297198080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259339986436439, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1300885504, + "Pss_bytes": 1297198080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259341003059335, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301225472, + "Pss_bytes": 1297538048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259342026580567, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301663744, + "Pss_bytes": 1297976320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259343043955613, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301663744, + "Pss_bytes": 1297976320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259344066836361, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301725184, + "Pss_bytes": 1298037760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259345081515614, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301725184, + "Pss_bytes": 1298037760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259346101241093, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301725184, + "Pss_bytes": 1298037760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259347121069805, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301725184, + "Pss_bytes": 1298037760, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259348139157226, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302048768, + "Pss_bytes": 1298361344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259349158778946, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302048768, + "Pss_bytes": 1298361344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259350178729100, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302052864, + "Pss_bytes": 1298365440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259351195503665, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302052864, + "Pss_bytes": 1298365440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259352214201956, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302052864, + "Pss_bytes": 1298365440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259353233132889, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302052864, + "Pss_bytes": 1298365440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259354252894563, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302052864, + "Pss_bytes": 1298365440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259355265634126, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302061056, + "Pss_bytes": 1298373632, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259356284105793, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1301274624, + "Pss_bytes": 1297591296, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259357306729504, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259358320316722, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259359336449494, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259360352258216, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259361369718518, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259362392244838, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259363409803781, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259364434442453, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298741248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259365451470001, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259366474446391, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259367487245847, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259368501214863, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259369517102837, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259370532058805, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259371546704547, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259372559777751, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259373574194676, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259374594870237, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259375608742391, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259376622425313, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259377638243545, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259378651116750, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259379665448029, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259380688448551, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259381712467753, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259382726786777, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259383743052583, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259384767781263, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259385783818188, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259386806575447, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259387824338896, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259388847958290, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259389868998034, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259390888403832, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259391908174705, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259392924896133, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259393945380243, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259394960139082, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259395979051454, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259397005450230, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259398021458007, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259399045082588, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259400061813507, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259401085567578, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259402103867372, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302409216, + "Pss_bytes": 1298721792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259403119754926, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259404134064549, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259405147458263, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259406165199126, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259407185372359, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259408206908129, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259409227999081, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259410250505642, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298762752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259411264110847, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259412279110782, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259413291985391, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259414306037224, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259415321331434, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259416334338685, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259417351527613, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259418376501042, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259419393476593, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259420419582542, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259421434565008, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259422458408527, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259423473475986, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259424494418270, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259425513314252, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302454272, + "Pss_bytes": 1298766848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259426528956500, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304768512, + "Pss_bytes": 1301081088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259427544463836, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304768512, + "Pss_bytes": 1301081088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259428564902933, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304768512, + "Pss_bytes": 1301081088, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259429582179962, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259430601225946, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259431620889424, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301277696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259432642974886, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301277696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259433664444472, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259434684257983, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259435701117443, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259436720618409, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259437739210281, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259438754573827, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259439770574530, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259440792225720, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259441809324847, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259442835368755, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259443853616099, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259444876706980, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259445896802289, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259446913336358, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259447934371930, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259448954038372, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304969216, + "Pss_bytes": 1301281792, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259449967329652, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305526272, + "Pss_bytes": 1301838848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259450986339131, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305526272, + "Pss_bytes": 1301838848, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259452005136161, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305530368, + "Pss_bytes": 1301842944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259453021451574, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305530368, + "Pss_bytes": 1301842944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259454042064377, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305530368, + "Pss_bytes": 1301842944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259455059899353, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305534464, + "Pss_bytes": 1301847040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259456077830203, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305534464, + "Pss_bytes": 1301842944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259457096126303, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305534464, + "Pss_bytes": 1301847040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259458108907789, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305534464, + "Pss_bytes": 1301847040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259459123408168, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305538560, + "Pss_bytes": 1301851136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259460142475122, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305538560, + "Pss_bytes": 1301851136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259461156522346, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259462171022758, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259463184439274, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259464199678316, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259465218849880, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259466231836299, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259467252552147, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259468272471125, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259469294850153, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259470311407109, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259471335274756, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259472352460613, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302433792, + "Pss_bytes": 1298746368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259473372744300, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302990848, + "Pss_bytes": 1299303424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259474397517329, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259475411171211, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259476426567009, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259477440893344, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259478464270942, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259479480201864, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259480494764986, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259481509034314, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259482523772829, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259483534920536, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259484549759245, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259485563305977, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259486576120752, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259487590565699, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259488603736061, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259489616791655, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259490629883634, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259491644586327, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259492659354526, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259493672848620, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259494686154649, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259495698409599, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259496712965269, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259497725821552, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259498738676843, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259499753502420, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259500772214776, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259501785806073, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298790400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259502808715067, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259503825360897, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259504838844562, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259505850788025, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259506864030329, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259507876250403, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259508889636868, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259509903146471, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259510915057727, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259511929008982, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259512941964933, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259513954624964, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259514967404755, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259515979822288, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259516990837619, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259518002938655, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259519017010872, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259520030999217, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259521043385823, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259522058106941, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259523072194552, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259524084410245, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259525099287414, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259526114404312, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259527126667367, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259528139405641, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259529158523304, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302986752, + "Pss_bytes": 1299299328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259530179763557, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259531199009397, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259532224311183, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259533237115988, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259534251763573, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259535275893672, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259536289680260, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259537311837129, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259538332908024, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259539355200415, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259540376406559, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259541397179660, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259542413284810, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259543438303701, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259544454885622, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259545475628228, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259546499609577, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259547522182980, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298787328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259548541055238, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259549561498627, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259550580680584, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259551600458609, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259552616348655, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259553638729083, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259554653283265, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259555669881525, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302478848, + "Pss_bytes": 1298791424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259556687754034, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302978560, + "Pss_bytes": 1299291136, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259557708918566, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304776704, + "Pss_bytes": 1301089280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259558722731352, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304776704, + "Pss_bytes": 1301089280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259559737162047, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259560752944079, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259561771849460, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259562793200683, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259563817404118, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259564832931349, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259565845425680, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259566867589645, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259567881262064, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259568894092590, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259569912769924, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259570926032229, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259571940590351, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259572955620685, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259573968843535, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259574992036117, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259576004702499, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259577019469873, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259578037365923, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259579051887231, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259580066470252, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259581080279395, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259582094747023, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259583115935610, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259584129563409, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259585143746748, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301322752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259586157741781, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305010176, + "Pss_bytes": 1301318656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259587177305462, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305497600, + "Pss_bytes": 1301806080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259588195095130, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305497600, + "Pss_bytes": 1301814272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259589215577634, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305501696, + "Pss_bytes": 1301814272, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259590234894033, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305505792, + "Pss_bytes": 1301818368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259591254162113, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305505792, + "Pss_bytes": 1301818368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259592277537053, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305440256, + "Pss_bytes": 1301752832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259593297905588, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305448448, + "Pss_bytes": 1301754880, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259594315185607, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305448448, + "Pss_bytes": 1301761024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259595335150204, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305448448, + "Pss_bytes": 1301761024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259596347770191, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305448448, + "Pss_bytes": 1301761024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259597360103344, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1305448448, + "Pss_bytes": 1301761024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259598379497474, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259599395657006, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259600408536211, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259601422692146, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259602435161941, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259603447684569, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259604462113162, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259605474448717, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259606488109354, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259607501091506, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259608514993264, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259609527725511, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259610542438331, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302482944, + "Pss_bytes": 1298795520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259611557362290, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1302970368, + "Pss_bytes": 1299282944, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259612578326642, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259613594390352, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259614614276585, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259615636188545, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259616652814244, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259617671363669, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259618691072606, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259619709240972, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259620730006797, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259621747297750, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259622771023675, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259623784228232, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259624798533309, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259625819146926, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259626831403813, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259627846853331, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259628862558130, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259629875516943, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259630896288194, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259631909044526, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259632923144403, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259633940488015, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259634953426701, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259635967837183, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259636982407313, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259637995254843, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259639010853167, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299986432, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259640029947184, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259641044232771, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259642066400516, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259643085366308, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259644100430674, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259645124437422, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259646138547374, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259647151379018, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259648174898629, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259649186896202, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259650199414849, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259651217315308, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259652244181684, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259653262355677, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259654289299112, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259655306593705, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259656321732735, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259657344368138, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303678976, + "Pss_bytes": 1299991552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259658365916668, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304387584, + "Pss_bytes": 1300700160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259659390852979, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259660415334863, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259661437058835, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259662459732701, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259663484039211, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259664499145579, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259665520813251, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259666536487218, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259667560381477, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259668577352676, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259669601031297, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259670615838596, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259671638901674, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259672654474277, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259673669594680, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259674686838104, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259675705699659, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259676725180695, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259677741029386, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259678765572066, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259679781627559, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259680804551149, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259681826561830, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259682838248604, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259683854301204, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259684874505057, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299963904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259685892983807, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259686909402286, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259687933363593, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259688948983391, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259689969685140, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259690984637271, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259692000155074, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259693016616004, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259694039920049, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259695058090474, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259696074455970, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259697097427866, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259698115436998, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259699133478755, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259700155614817, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259701178322871, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259702193941223, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259703215669487, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303658496, + "Pss_bytes": 1299971072, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259704236680120, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304367104, + "Pss_bytes": 1300679680, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259705259250387, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259706279614493, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259707294766998, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259708319170990, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259709336381199, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300024320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259710359905105, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300024320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259711376168697, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259712397908381, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259713413904907, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259714435317634, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259715453799308, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259716466640934, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259717487615916, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259718505623828, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259719529850535, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259720545980114, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259721573187796, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259722591427819, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259723616220009, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259724632215988, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259725646641584, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259726665397957, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259727681618385, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259728704734720, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259729721886456, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259730737976070, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300026368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259731760792897, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259732777398810, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259733796455132, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259734816620400, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259735832688044, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259736848239974, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259737869872336, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259738885956680, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259739908164928, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259740925393582, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259741942688819, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259742965638149, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259743981664526, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259744997868563, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259746020483586, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259747039258104, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259748056305452, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259749078946360, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259750099115429, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303715840, + "Pss_bytes": 1300028416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259751117406010, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307029504, + "Pss_bytes": 1303342080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259752140411075, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307029504, + "Pss_bytes": 1303342080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259753163193463, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259754177922635, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259755191367297, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259756205879576, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259757219640599, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259758234441813, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259759247911717, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259760260990923, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259761276019319, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259762288357725, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259763300863985, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259764315298713, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259765328153385, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259766340677475, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259767353490752, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259768365617033, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259769379052222, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259770393938788, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259771406579417, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259772422070390, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259773434706699, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259774450134421, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307426816, + "Pss_bytes": 1303739392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259775469874433, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259776482381801, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303741440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259777501672275, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259778515273447, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259779536817913, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259780552188147, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259781572916006, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259782590323440, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259783615018814, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259784634842631, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259785652127270, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259786673057307, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259787688848834, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259788705077364, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259789725047119, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259790741062619, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259791755839185, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259792778089712, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259793796592089, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259794814248699, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259795839238207, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259796860008876, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259797878670482, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259798902596586, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1307430912, + "Pss_bytes": 1303743488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259799923917690, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1308135424, + "Pss_bytes": 1304448000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259800943456288, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1308139520, + "Pss_bytes": 1304452096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259801956726386, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1308139520, + "Pss_bytes": 1304452096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259802973386304, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1308139520, + "Pss_bytes": 1304452096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259803990729443, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1308139520, + "Pss_bytes": 1304452096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259805014813647, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1308143616, + "Pss_bytes": 1304456192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259806035133175, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259807055936539, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259808071909526, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259809094291516, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259810109970690, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259811124207261, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259812139841145, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259813160416890, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259814176494846, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259815193487824, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259816211146008, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259817232873314, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259818258385365, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259819276346971, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259820302824281, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259821318873906, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259822342334201, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259823360227407, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259824383193692, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259825402154019, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259826417714746, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259827442356923, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259828458996548, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259829476448889, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259830499137737, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259831514614225, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259832538060760, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259833556846611, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259834573804937, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259835596657491, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259836614759183, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259837630137542, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259838652841061, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259839671433133, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259840687398101, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259841713581658, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1303748608, + "Pss_bytes": 1300061184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259842734427519, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1304453120, + "Pss_bytes": 1300765696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259843757693864, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 1298395136, + "Pss_bytes": 1294710784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259844769352496, + "status": "recorded", + "VmHWM_bytes": 8493666304, + "VmRSS_bytes": 178106368, + "Pss_bytes": 175020032, + "Locked_bytes": 0 + } + ], + "native": { + "status": "recorded", + "rows": [ + { + "schema": 1, + "pid": 2024748, + "rank": 0, + "phase": "load_begin", + "reset": true, + "monotonic_ns": 258911517948816, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 0, + "peak": 0, + "host_peak": 0, + "allocs": 0 + } + }, + { + "schema": 1, + "pid": 2024748, + "rank": 0, + "phase": "load_end", + "reset": false, + "monotonic_ns": 258980784188075, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 96911922324, + "host": 16870016, + "peak": 96911922964, + "host_peak": 169938944, + "allocs": 1404 + } + }, + { + "schema": 1, + "pid": 2024748, + "rank": 0, + "phase": "cleanup_begin", + "reset": false, + "monotonic_ns": 259843262027702, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 104510839188, + "host": 16984704, + "peak": 104510839188, + "host_peak": 169938944, + "allocs": 1408 + } + }, + { + "schema": 1, + "pid": 2024748, + "rank": 0, + "phase": "cleanup_end", + "reset": false, + "monotonic_ns": 259844603257912, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 184320, + "peak": 104510839188, + "host_peak": 169938944, + "allocs": 0 + } + } + ], + "errors": [], + "reason": null, + "scope": "owned buffers only; excludes driver, library and other untracked allocations" + } +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/memory-rank1.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/memory-rank1.json new file mode 100644 index 00000000000..7d18c58a2f6 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/memory-rank1.json @@ -0,0 +1,7442 @@ +{ + "schema": 1, + "rank": 1, + "context_tokens_operator_label": 131072, + "pid": 1965426, + "process_start_ns": 258904767358806, + "process_exit_ns": 259840640589206, + "returncode": 0, + "resident_peak": { + "status": "recorded", + "bytes": 8488894464, + "scope": "Linux wait4 lifetime peak RSS, fresh process per context; not resettable" + }, + "physical_footprint": { + "status": "unsupported", + "bytes": null, + "reason": "Linux RSS/PSS is not a total unified-memory physical-footprint peak" + }, + "samples": [ + { + "monotonic_ns": 258904767833078, + "status": "recorded", + "VmHWM_bytes": 1159168, + "VmRSS_bytes": 1159168, + "Pss_bytes": 1270784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258905768501519, + "status": "recorded", + "VmHWM_bytes": 534355968, + "VmRSS_bytes": 534355968, + "Pss_bytes": 532007936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258906772333894, + "status": "recorded", + "VmHWM_bytes": 534355968, + "VmRSS_bytes": 534355968, + "Pss_bytes": 532004864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258907776065357, + "status": "recorded", + "VmHWM_bytes": 1151447040, + "VmRSS_bytes": 1151447040, + "Pss_bytes": 1147581440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258908782246244, + "status": "recorded", + "VmHWM_bytes": 2160549888, + "VmRSS_bytes": 2160549888, + "Pss_bytes": 2157716480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258909790735978, + "status": "recorded", + "VmHWM_bytes": 3024973824, + "VmRSS_bytes": 2944237568, + "Pss_bytes": 2952672256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258910801227374, + "status": "recorded", + "VmHWM_bytes": 5768019968, + "VmRSS_bytes": 4129746944, + "Pss_bytes": 4115956736, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258911818922092, + "status": "recorded", + "VmHWM_bytes": 5768019968, + "VmRSS_bytes": 3262152704, + "Pss_bytes": 3358295040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258912835579085, + "status": "recorded", + "VmHWM_bytes": 5775286272, + "VmRSS_bytes": 2975510528, + "Pss_bytes": 2970903552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258913846734869, + "status": "recorded", + "VmHWM_bytes": 5775286272, + "VmRSS_bytes": 2975752192, + "Pss_bytes": 2971821056, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258914858271310, + "status": "recorded", + "VmHWM_bytes": 5775847424, + "VmRSS_bytes": 3009847296, + "Pss_bytes": 3017233408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258915869414377, + "status": "recorded", + "VmHWM_bytes": 5775847424, + "VmRSS_bytes": 2973478912, + "Pss_bytes": 2982392832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258916881019237, + "status": "recorded", + "VmHWM_bytes": 5776039936, + "VmRSS_bytes": 4315803648, + "Pss_bytes": 3283874816, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258917893451473, + "status": "recorded", + "VmHWM_bytes": 5776039936, + "VmRSS_bytes": 5491101696, + "Pss_bytes": 5493883904, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258918918063378, + "status": "recorded", + "VmHWM_bytes": 5776039936, + "VmRSS_bytes": 4609646592, + "Pss_bytes": 4653642752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258919940570581, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4054974464, + "Pss_bytes": 4107060224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258920960040638, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 3007938560, + "Pss_bytes": 3004007424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258921972578240, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4164300800, + "Pss_bytes": 3258266624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258922985381314, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 3423166464, + "Pss_bytes": 3448189952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258924011020488, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 2942832640, + "Pss_bytes": 2970637312, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258925033161059, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4281323520, + "Pss_bytes": 4361540608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258926068918609, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 3058872320, + "Pss_bytes": 3082540032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258927092993325, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4590460928, + "Pss_bytes": 4577817600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258928130921515, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 2985742336, + "Pss_bytes": 2981811200, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258929154988265, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 3471667200, + "Pss_bytes": 3470353408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258930182423989, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 3399966720, + "Pss_bytes": 3412644864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258931210869762, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 5658783744, + "Pss_bytes": 5672723456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258932257071261, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4235243520, + "Pss_bytes": 4254823424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258933288599769, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 2994900992, + "Pss_bytes": 2996478976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258934312393806, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 5648199680, + "Pss_bytes": 5635879936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258935354334146, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4296167424, + "Pss_bytes": 4361155584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258936389804942, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 2979360768, + "Pss_bytes": 2975433728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258937415269574, + "status": "recorded", + "VmHWM_bytes": 5779537920, + "VmRSS_bytes": 4227428352, + "Pss_bytes": 4258472960, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258938445172458, + "status": "recorded", + "VmHWM_bytes": 5941542912, + "VmRSS_bytes": 5941542912, + "Pss_bytes": 5954589696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258939485619269, + "status": "recorded", + "VmHWM_bytes": 6536310784, + "VmRSS_bytes": 5700644864, + "Pss_bytes": 5772280832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258940526542304, + "status": "recorded", + "VmHWM_bytes": 8197529600, + "VmRSS_bytes": 8197529600, + "Pss_bytes": 8228086784, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258941588420326, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 4990734336, + "Pss_bytes": 4986676224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258942623336843, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 4990734336, + "Pss_bytes": 4986676224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258943657311122, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 4990734336, + "Pss_bytes": 4986676224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258944691295883, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 4991389696, + "Pss_bytes": 4987331584, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258945725400356, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 4237340672, + "Pss_bytes": 4182950912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258946756889362, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258947768383447, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258948779338637, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258949789923878, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258950801018238, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258951811915849, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258952822592453, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258953833775793, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258954844729807, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258955855426847, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258956866954383, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258957878045969, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258958888856052, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258959899920345, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258960910395151, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258961920710647, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258962932271134, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258963943270200, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258964953945459, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258965965407822, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258966976243996, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258967986859755, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258968997597546, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258970008382316, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258971018943550, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258972029875042, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258973040509191, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258974050965149, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258975061891284, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1291866112, + "Pss_bytes": 1287934976, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258976072552797, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1292267520, + "Pss_bytes": 1288336384, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258977084130166, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1123098624, + "Pss_bytes": 1118934016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258978094784657, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1120444416, + "Pss_bytes": 1116316672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258979105657676, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1115566080, + "Pss_bytes": 1111828480, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258980117225177, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117110272, + "Pss_bytes": 1113251840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258981137512334, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117233152, + "Pss_bytes": 1113366528, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258982168964504, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117237248, + "Pss_bytes": 1113370624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258983185310932, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117270016, + "Pss_bytes": 1113403392, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258984205468204, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117274112, + "Pss_bytes": 1113402368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258985237123162, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117286400, + "Pss_bytes": 1113402368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258986256752822, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117298688, + "Pss_bytes": 1113402368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258987277188882, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117306880, + "Pss_bytes": 1113402368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258988298521182, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117319168, + "Pss_bytes": 1113402368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258989318015310, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117331456, + "Pss_bytes": 1113402368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258990339216397, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117405184, + "Pss_bytes": 1113406464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258991359974253, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117487104, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258992380393599, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117499392, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258993401777346, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117515776, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258994432556747, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117581312, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258995453478785, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117581312, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258996473312952, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117581312, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258997495124287, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117581312, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258998515098537, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117581312, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 258999536141010, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117581312, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259000555952591, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117589504, + "Pss_bytes": 1113451520, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259001577097851, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259002599022775, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259003619416870, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259004640860918, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259005660935480, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259006682379465, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259007702628621, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259008723524066, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259009744526216, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259010765466223, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259011784449785, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117569024, + "Pss_bytes": 1113308160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259012815559672, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259013834813636, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259014856638366, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259015887947297, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259016908417039, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113478144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259017928103325, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113478144, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259018949084221, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259019969567247, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259020990402865, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259022011857044, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259023032761449, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117741056, + "Pss_bytes": 1113480192, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259024053383999, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259025074193862, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259026104530981, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259027126473629, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259028146514793, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259029168057508, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259030188921184, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259031209861614, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259032231321244, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259033251620509, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117761536, + "Pss_bytes": 1113500672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259034273365789, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259035293259024, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259036314068404, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259037335247000, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259038355359358, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259039376246229, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259040397643708, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259041417591414, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259042438704224, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259043459335819, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259044480079127, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117786112, + "Pss_bytes": 1113525248, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259045497606376, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259046518279830, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259047537767703, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259048558036152, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259049578040122, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259050598461997, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259051619145665, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259052650083469, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259053670429203, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259054691441866, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259055712512625, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117806592, + "Pss_bytes": 1113545728, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259056733476458, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259057754933956, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259058774757328, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259059795833948, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259060816364922, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259061835694698, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259062857240328, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259063878261577, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259064899124250, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259065920491148, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259066941681456, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259067962519268, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259068982625947, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259070003271026, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259071023805578, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259072044522515, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259073064810125, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259074085110952, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259075104931141, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259076126040594, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259077146321632, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259078164122802, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259079194622905, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259080215543898, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259081234561118, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259082254563938, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259083276054469, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259084296745370, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259085317449152, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259086338387127, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259087358882032, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259088379549705, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259089400984082, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259090421804845, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259091442434010, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259092462882071, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259093484587300, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259094514896539, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259095536076666, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259096555754364, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259097576942878, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259098598121185, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259099630187931, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259100657964233, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259101679350575, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1112761344, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259102700710149, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259103721534333, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259104741876086, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1112704000, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259105762984560, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259106783532987, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259107804227783, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113548800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259108822733557, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259109842259588, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259110862771363, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259111883281507, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259112908385360, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259113931026303, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259114955722798, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259115981400878, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117810688, + "Pss_bytes": 1113549824, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259117003782977, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259118027248131, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259119050971703, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259120072953565, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259121095151300, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259122118548843, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259123142351666, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259124166312874, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259125190801251, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259126214456637, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259127237429625, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259128261712053, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117814784, + "Pss_bytes": 1113553920, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259129285790113, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259130309540639, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259131334074494, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259132356071887, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259133378836992, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259134402767522, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259135425896997, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259136449535880, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259137472073774, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259138496078307, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259139519033226, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259140542528977, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259141566449177, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117818880, + "Pss_bytes": 1113558016, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259142590082034, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259143614112012, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259144637371111, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259145656532486, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259146678908116, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259147702387249, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259148725729824, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259149749693311, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259150773793535, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259151808512102, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259152832094248, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259153853295485, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259154887737224, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117822976, + "Pss_bytes": 1113562112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259155909162670, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117827072, + "Pss_bytes": 1113566208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259156932555428, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117827072, + "Pss_bytes": 1113566208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259157955744491, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259158979612370, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259160002600731, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259161026176468, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259162049438494, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259163072322777, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259164094748038, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259165117635107, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259166140905633, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259167164670079, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259168187673614, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117831168, + "Pss_bytes": 1113570304, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259169210547503, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113574400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259170234569967, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113574400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259171258084113, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113574400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259172281362980, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113574400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259173305020343, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113574400, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259174327889532, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113573376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259175351136529, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113572352, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259176374554231, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113572352, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259177398285646, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113571328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259178420042759, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113571328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259179442608544, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113571328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259180466867625, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113571328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259181490289411, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117835264, + "Pss_bytes": 1113571328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259182514108462, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113575424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259183537612234, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113575424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259184561775030, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113575424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259185584765508, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113575424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259186606697460, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113575424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259187630026451, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113575424, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259188652815732, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113576448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259189675448677, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113576448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259190699645494, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113576448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259191722228250, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113576448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259192746068909, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113576448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259193768937729, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117839360, + "Pss_bytes": 1113576448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259194791555111, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117978624, + "Pss_bytes": 1113715712, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259195814504573, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117982720, + "Pss_bytes": 1113719808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259196837069621, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117982720, + "Pss_bytes": 1113719808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259197860591916, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117982720, + "Pss_bytes": 1113719808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259198885696531, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117982720, + "Pss_bytes": 1113719808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259199919907907, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117982720, + "Pss_bytes": 1113719808, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259200944188620, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117995008, + "Pss_bytes": 1113732096, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259201966919831, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117999104, + "Pss_bytes": 1113737216, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259202989697267, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1117999104, + "Pss_bytes": 1113737216, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259204013110896, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118056448, + "Pss_bytes": 1113794560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259205035565390, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118056448, + "Pss_bytes": 1113794560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259206057940492, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118060544, + "Pss_bytes": 1113798656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259207125542967, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118060544, + "Pss_bytes": 1113798656, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259208147552728, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118064640, + "Pss_bytes": 1113802752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259209170476777, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118064640, + "Pss_bytes": 1113802752, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259210194072186, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118076928, + "Pss_bytes": 1113815040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259211217093820, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118076928, + "Pss_bytes": 1113815040, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259212235711154, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118208000, + "Pss_bytes": 1113946112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259213260943396, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118208000, + "Pss_bytes": 1113946112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259214283879049, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118208000, + "Pss_bytes": 1113946112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259215306689374, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118208000, + "Pss_bytes": 1113946112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259216331134724, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118208000, + "Pss_bytes": 1113946112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259217354550714, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118208000, + "Pss_bytes": 1113946112, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259218376586947, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118212096, + "Pss_bytes": 1113950208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259219399805435, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118212096, + "Pss_bytes": 1113950208, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259220423296580, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118269440, + "Pss_bytes": 1114007552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259221448769900, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259222474340197, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259223497413616, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259224521244668, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259225546081464, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259226568290582, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259227591408949, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259228613651525, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259229636765509, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259230661021925, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259231683915735, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259232706583705, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259233730456268, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118273536, + "Pss_bytes": 1114011648, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259234754316335, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259235778141843, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259236800920553, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259237824089007, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259238857357086, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259239878806183, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259240901278560, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259241923944585, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259242945528804, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259243967980816, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259244988961789, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259246022351201, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259247044453646, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118277632, + "Pss_bytes": 1114015744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259248067657276, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114020864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259249091179482, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259250114388857, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259251137213081, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1113187328, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259252161209705, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259253183303451, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259254206980684, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114020864, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259255237844489, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259256260748525, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259257282922657, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259258305471735, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259259327565373, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118281728, + "Pss_bytes": 1114019840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259260351514787, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114022912, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259261373042955, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259262394642740, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259263417055085, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259264439270583, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259265461651265, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259266483651773, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259267508635590, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259268532451826, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259269554978383, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259270578026925, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259271600930667, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259272621660187, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118285824, + "Pss_bytes": 1114023936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259273644872107, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118289920, + "Pss_bytes": 1114028032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259274667341612, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118453760, + "Pss_bytes": 1114191872, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259275686912735, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118466048, + "Pss_bytes": 1114204160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259276703096982, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118478336, + "Pss_bytes": 1114216448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259277721048764, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118478336, + "Pss_bytes": 1114216448, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259278734583303, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118486528, + "Pss_bytes": 1114224640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259279755370492, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118486528, + "Pss_bytes": 1114224640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259280767988776, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118494720, + "Pss_bytes": 1114232832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259281782329236, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118494720, + "Pss_bytes": 1114232832, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259282805923865, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118507008, + "Pss_bytes": 1114245120, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259283820040951, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118679040, + "Pss_bytes": 1114417152, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259284832943269, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118691328, + "Pss_bytes": 1114429440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259285850268146, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118699520, + "Pss_bytes": 1114437632, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259286868851837, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118797824, + "Pss_bytes": 1114535936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259287890405320, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114540032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259288908423541, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114540032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259289932375391, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118818304, + "Pss_bytes": 1114556416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259290945949938, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118818304, + "Pss_bytes": 1114556416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259291963642865, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118818304, + "Pss_bytes": 1114556416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259292983208961, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259294005180367, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259295020798194, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259296044675360, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259297064178626, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118793728, + "Pss_bytes": 1114531840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259298083215173, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118793728, + "Pss_bytes": 1114531840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259299101403161, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114548224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259300114706657, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114548224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259301127602011, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114548224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259302143140355, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114548224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259303163713848, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259304179419873, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259305202407718, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118793728, + "Pss_bytes": 1114531840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259306215757378, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118793728, + "Pss_bytes": 1114531840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259307228797519, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118793728, + "Pss_bytes": 1114531840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259308240713550, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114540032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259309257953481, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114540032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259310273854006, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114548224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259311290031652, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114548224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259312306625058, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118822400, + "Pss_bytes": 1114560512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259313321905873, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118773248, + "Pss_bytes": 1114511360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259314334142563, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118773248, + "Pss_bytes": 1114511360, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259315347864965, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118789632, + "Pss_bytes": 1114527744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259316370239393, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118789632, + "Pss_bytes": 1114527744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259317391700815, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118789632, + "Pss_bytes": 1114527744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259318406057762, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118806016, + "Pss_bytes": 1114544128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259319418599479, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118806016, + "Pss_bytes": 1114544128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259320433537867, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118806016, + "Pss_bytes": 1114544128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259321455690571, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118810112, + "Pss_bytes": 1114546176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259322476542988, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118826496, + "Pss_bytes": 1114562560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259323490560930, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118826496, + "Pss_bytes": 1114562560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259324509442070, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118826496, + "Pss_bytes": 1114562560, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259325528694554, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118781440, + "Pss_bytes": 1114517504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259326543658018, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118781440, + "Pss_bytes": 1114517504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259327566623236, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118781440, + "Pss_bytes": 1114517504, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259328581664685, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118785536, + "Pss_bytes": 1114521600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259329594068953, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118785536, + "Pss_bytes": 1114521600, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259330614143839, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114537984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259331637596916, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114537984, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259332653406655, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118818304, + "Pss_bytes": 1114554368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259333666080605, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118818304, + "Pss_bytes": 1114554368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259334681026842, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118818304, + "Pss_bytes": 1114554368, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259335693452297, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118822400, + "Pss_bytes": 1114557440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259336712080004, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118822400, + "Pss_bytes": 1114557440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259337735279293, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118785536, + "Pss_bytes": 1114522624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259338751320459, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118785536, + "Pss_bytes": 1114522624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259339775544724, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118785536, + "Pss_bytes": 1114522624, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259340794177282, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114539008, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259341814140863, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118801920, + "Pss_bytes": 1114540032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259342833576302, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118806016, + "Pss_bytes": 1114544128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259343849382543, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118806016, + "Pss_bytes": 1114544128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259344863222259, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118814208, + "Pss_bytes": 1114552320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259345877212567, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118822400, + "Pss_bytes": 1114560512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259346893371754, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118822400, + "Pss_bytes": 1114560512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259347907580431, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118830592, + "Pss_bytes": 1114568704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259348922803268, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259349936814459, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118777344, + "Pss_bytes": 1114515456, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259350956359470, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118781440, + "Pss_bytes": 1114519552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259351971949941, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118781440, + "Pss_bytes": 1114519552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259352995762934, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118797824, + "Pss_bytes": 1114535936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259354012655549, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118797824, + "Pss_bytes": 1114535936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259355032236162, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118797824, + "Pss_bytes": 1114535936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259356047771371, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118814208, + "Pss_bytes": 1114552320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259357070124224, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118814208, + "Pss_bytes": 1114552320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259358085464698, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118830592, + "Pss_bytes": 1114568704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259359107696800, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118830592, + "Pss_bytes": 1114568704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259360124157898, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118830592, + "Pss_bytes": 1114568704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259361146705329, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259362167715898, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259363187595236, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259364202061202, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259365222867773, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259366238130412, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259367252492412, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259368267255420, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114620928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259369288739576, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114588160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259370308891990, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114588160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259371333015186, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114588160, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259372353333217, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114604544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259373386485207, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114604544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259374399141900, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114604544, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259375410469315, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114620928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259376427799606, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114620928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259377444759514, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114620928, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259378457815746, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259379479753923, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259380494598411, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259381518849948, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259382533772356, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259383565188001, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259384581697689, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259385599961489, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259386620452296, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259387641022015, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259388660221319, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259389684139517, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259390700086985, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259391720143075, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118867456, + "Pss_bytes": 1114605568, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259392736775279, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259393759723912, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259394774577047, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118883840, + "Pss_bytes": 1114621952, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259395807240794, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259396821841978, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259397843434358, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118851072, + "Pss_bytes": 1114589184, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259398865400243, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259399877738342, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259400891442889, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259401912867799, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259402936006741, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259403951023416, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259404975633782, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259405997178806, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259407016625672, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259408028433009, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259409045676309, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114608640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259410058478830, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259411071367895, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259412084348944, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259413098133049, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259414113294738, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114592256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259415126653517, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114592256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259416138440345, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114608640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259417150864869, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114608640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259418164666193, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114608640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259419179636301, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259420193363226, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259421206173512, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259422218032663, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114625024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259423241132463, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114592256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259424257454012, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114592256, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259425276811256, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114608640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259426291858967, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114608640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259427303888985, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259428318314202, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259429331610859, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259430343889215, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259431358705152, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259432372152772, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259433386733239, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259434407462342, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259435421289723, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259436435252671, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259437448600229, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259438463418459, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118887936, + "Pss_bytes": 1114626048, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259439477734273, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259440490405769, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259441503162577, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118855168, + "Pss_bytes": 1114593280, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259442517035689, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1118871552, + "Pss_bytes": 1114609664, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259443529416594, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259444550838358, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259445563058865, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259446577424970, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259447595547554, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259448610074300, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259449624576983, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101934592, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259450645164527, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101885440, + "Pss_bytes": 1097623552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259451657917372, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101885440, + "Pss_bytes": 1097623552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259452679417332, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259453699564189, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101901824, + "Pss_bytes": 1097639936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259454718767415, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101901824, + "Pss_bytes": 1097639936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259455733706309, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259456754067791, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259457774127978, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259458789902601, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101934592, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259459806109688, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101934592, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259460826740884, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097628672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259461845240962, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097628672, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259462869364445, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097629696, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259463886190413, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097646080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259464908748826, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097646080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259465925498171, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097646080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259466949695352, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097662464, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259467963763308, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097661440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259468985579723, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097661440, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259470008298842, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259471024990430, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259472042210802, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259473063864819, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259474084961253, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259475117154688, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259476142376785, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259477161958165, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259478177951901, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259479190361735, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259480206315775, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259481234163568, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259482249718474, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259483272497183, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259484287465370, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259485301459845, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259486321233278, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259487336989242, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259488359181522, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259489375043342, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259490399628133, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259491415441315, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259492436712301, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259493452949051, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259494473555367, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259495492941380, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259496511640993, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259497528010545, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259498542426803, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259499556101621, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259500570873927, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259501594147748, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259502606591097, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259503621193532, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259504632508082, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259505647319478, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259506661855659, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259507673496978, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259508688715624, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259509702501358, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259510716300838, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259511729668573, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259512752567663, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259513764517321, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259514778875425, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259515792742539, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259516804655030, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259517819552271, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259518833323465, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259519844705206, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259520859125569, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259521872954621, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259522884717674, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259523897571959, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259524917348289, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259525938881337, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259526954558358, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259527979237869, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259528992609068, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259530005378188, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259531022738458, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259532034022235, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259533048773467, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259534066339129, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259535077997004, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259536092779741, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259537112404347, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259538126375182, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259539150317322, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259540163918974, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259541177475473, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259542201906079, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259543214988452, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259544237736947, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259545249943481, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259546268901660, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259547290635325, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259548312349087, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259549332658225, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259550353072581, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259551371379114, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259552388357920, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259553407508453, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259554430784568, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259555445770512, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259556457981867, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259557475008963, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259558498825112, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259559519551806, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259560538719382, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259561553248577, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259562573997433, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259563589052165, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259564603843729, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259565621090284, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259566637413864, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259567651763398, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259568666598116, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259569683712977, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259570704335260, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259571720733786, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259572745496307, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259573760928146, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259574786247276, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259575800456813, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259576824570152, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259577838084186, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259578852136684, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259579866850398, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259580879084850, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259581895599556, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101897728, + "Pss_bytes": 1097635840, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259582916399443, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101905920, + "Pss_bytes": 1097644032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259583936889651, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101905920, + "Pss_bytes": 1097644032, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259584959806098, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101914112, + "Pss_bytes": 1097652224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259585973876519, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101922304, + "Pss_bytes": 1097660416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259586991713290, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101922304, + "Pss_bytes": 1097660416, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259588009899709, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259589022420723, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101938688, + "Pss_bytes": 1097676800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259590037527257, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101938688, + "Pss_bytes": 1097676800, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259591053893198, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101885440, + "Pss_bytes": 1097623552, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259592072950930, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259593089055928, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259594103632528, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101901824, + "Pss_bytes": 1097639936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259595121420325, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259596144788776, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259597159160321, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259598170853788, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101934592, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259599190875057, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101934592, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259600203115372, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101934592, + "Pss_bytes": 1097672704, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259601216965799, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259602232512928, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259603245327292, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259604259639831, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259605275500834, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097646080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259606289080686, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101914112, + "Pss_bytes": 1097650176, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259607306595481, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101914112, + "Pss_bytes": 1097652224, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259608331357999, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259609348071275, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259610366936021, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101930496, + "Pss_bytes": 1097668608, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259611386869248, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259612408598793, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259613428507172, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259614443747778, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259615467113916, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259616487039912, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259617506771317, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259618530190431, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259619542061025, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259620553803204, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259621576414416, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259622588829715, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259623603298341, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259624620497877, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259625632512057, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259626652597401, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259627665294957, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259628677677890, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259629697354579, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259630711094711, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259631723105725, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259632739984113, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259633752272615, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259634767093565, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259635787694207, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259636800803670, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259637819191850, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259638841196461, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259639857230947, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259640880119844, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259641894960062, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259642907228489, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259643930373504, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259644941773580, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259645953547927, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259646968617530, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259647990426317, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259649013704520, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259650031594463, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259651058207014, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259652073154586, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259653088992217, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259654109932157, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259655133902514, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259656154820701, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259657168726382, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259658191083671, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259659206906289, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259660228876458, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259661249280560, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259662274043271, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259663288566197, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259664312358430, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259665327774493, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259666352641931, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259667370592243, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259668395227285, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259669409793589, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259670435951367, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259671451517035, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259672474039519, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259673490976032, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259674510180591, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259675527726316, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259676544013824, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259677565537609, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259678578983846, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259679600651951, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259680614414128, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1096849408, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259681635892691, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259682656065948, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259683670903899, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1096816640, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259684690550422, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259685706121237, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259686719027468, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1096833024, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259687743711139, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259688764633416, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259689783991086, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1096787968, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259690806052907, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259691825169465, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259692845181092, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259693868662473, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259694889173470, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259695908201161, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259696933466109, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259697947887755, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259698967607901, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259699993244258, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259701013510496, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259702033021013, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259703046884592, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259704067870296, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259705081479373, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259706103622225, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259707116027500, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259708131809871, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259709154870529, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259710169419049, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259711191411797, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259712205146012, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259713221465144, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259714241983101, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259715256937292, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259716278059025, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259717293137831, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259718310894434, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259719331957026, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259720352821463, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259721376395763, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259722396563451, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259723420232268, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259724435611420, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259725457145233, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259726478424057, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259727497536619, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259728520359978, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259729535993699, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259730558438334, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259731581112184, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259732597022327, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259733623054640, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259734638967524, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097646080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259735660549952, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097646080, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259736681224498, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259737697829302, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259738719866092, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259739738769224, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259740750727127, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259741769328468, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259742791848512, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259743809517069, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259744827865125, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259745852095560, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259746873391511, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259747892358718, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259748909278661, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259749922959587, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259750936590891, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259751948833570, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259752962656743, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259753976149730, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259754991476208, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259756004464648, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259757017146711, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259758032053250, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259759045586205, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259760056845924, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097630720, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259761071444126, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259762088436601, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259763102074553, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097647104, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259764115840377, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259765127844689, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097663488, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259766139901384, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259767154446624, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259768173729576, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259769185147546, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259770201395902, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259771223386998, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259772235236585, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259773253387005, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259774265375118, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259775289395911, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259776303322636, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259777325927762, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259778340938617, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259779363971203, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259780384425813, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259781398527540, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259782424393185, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259783440690504, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259784454845250, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259785478025362, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259786494622939, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259787508443593, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259788533649437, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259789552724755, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259790566902388, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259791591547240, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259792610821213, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259793625021564, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259794648144876, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259795674462267, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101901824, + "Pss_bytes": 1097639936, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259796690200437, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259797704607924, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259798721779657, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259799740773809, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101918208, + "Pss_bytes": 1097656320, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259800763654790, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259801778257238, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259802794714121, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259803816931790, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259804832421741, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259805854145367, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259806865921276, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259807886830469, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259808900080040, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259809924593447, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259810940164710, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259811961611080, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259812976699135, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259813994098290, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259815013858740, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259816029272305, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259817051784696, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259818066421623, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259819083373540, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259820103709858, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259821118120222, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259822139151722, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259823158252978, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259824172369003, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259825191827707, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259826211421135, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259827227240219, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259828250574903, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259829266320996, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259830283626288, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259831304932760, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259832321128049, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101910016, + "Pss_bytes": 1097648128, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259833335785743, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259834358901933, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259835376898540, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101926400, + "Pss_bytes": 1097664512, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259836392260683, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259837418202274, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259838440360611, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101893632, + "Pss_bytes": 1097631744, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259839464274694, + "status": "recorded", + "VmHWM_bytes": 8488894464, + "VmRSS_bytes": 1101451264, + "Pss_bytes": 1097189376, + "Locked_bytes": 0 + }, + { + "monotonic_ns": 259840475786612, + "status": "unsupported", + "rollup_status": "unmeasured" + } + ], + "native": { + "status": "recorded", + "rows": [ + { + "schema": 1, + "pid": 1965426, + "rank": 1, + "phase": "load_begin", + "reset": true, + "monotonic_ns": 258907280608202, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 0, + "peak": 0, + "host_peak": 0, + "allocs": 0 + } + }, + { + "schema": 1, + "pid": 1965426, + "rank": 1, + "phase": "load_end", + "reset": false, + "monotonic_ns": 258976546697042, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 96911922324, + "host": 16870016, + "peak": 96911922964, + "host_peak": 169938944, + "allocs": 1404 + } + }, + { + "schema": 1, + "pid": 1965426, + "rank": 1, + "phase": "cleanup_begin", + "reset": false, + "monotonic_ns": 259839030940230, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 104510839188, + "host": 16890496, + "peak": 104510839188, + "host_peak": 169938944, + "allocs": 1408 + } + }, + { + "schema": 1, + "pid": 1965426, + "rank": 1, + "phase": "cleanup_end", + "reset": false, + "monotonic_ns": 259840357835947, + "scope": "process_owned_cuda_buffers", + "usage": { + "device": 0, + "host": 90112, + "peak": 104510839188, + "host_peak": 169938944, + "allocs": 0 + } + } + ], + "errors": [], + "reason": null, + "scope": "owned buffers only; excludes driver, library and other untracked allocations" + } +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/nodraft.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/nodraft.json new file mode 100644 index 00000000000..b3ddfbb5ceb --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/nodraft.json @@ -0,0 +1,198 @@ +[ + { + "label": "nodraft", + "prompt": "fibonacci-raw", + "temperature": 0.0, + "tokens": 256, + "thinking": "not applicable", + "thinking_off_requested": false, + "thinking_switch": true, + "thinking_applicable": true, + "decode_tps_median": 23.86976500971491, + "decode_tps_all": [ + 23.92, + 23.53, + 23.87, + 23.91, + 23.43 + ], + "ttft_s_median": 0.12297135900007561, + "prompt_ttft_tps_median": 113.848, + "prefill_tps_median": 113.848, + "itl_mean_ms_median": 41.894, + "itl_p50_ms_median": 41.678, + "itl_p95_ms_median": 43.073, + "tpot_ms_median": 41.894, + "chunk_tpot_estimate_ms_median": 41.894, + "round_gap_p50_ms_median": 41.678, + "round_gap_p95_ms_median": 43.073, + "tokens_per_chunk_median": 1.0, + "headers_s_median": 0.001, + "first_payload_s_median": 0.123, + "first_content_s_median": 0.123, + "first_reasoning_s_median": null, + "first_tool_s_median": null, + "first_output_s_median": 0.123, + "last_output_s_median": 10.807, + "evidence": [ + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 14, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "3fcd20ce2fb0", + "output_sha256": "64589a335b074e19ecfe5509272975612b804e23d390b19a86b0ff9691cb70fa", + "completion": "truncated", + "tool_sha256": null + } + ], + "sample": " Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... The next number is found by adding up the two numbers before it. The Fibonacci sequence i", + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + } + }, + { + "label": "nodraft", + "prompt": "gpu-chat-no-think", + "temperature": 0.0, + "tokens": 256, + "thinking": "off", + "thinking_off_requested": true, + "thinking_switch": true, + "thinking_applicable": true, + "decode_tps_median": 23.85563312877539, + "decode_tps_all": [ + 23.86, + 23.62, + 23.77, + 23.9, + 23.89 + ], + "ttft_s_median": 0.18972701398888603, + "prompt_ttft_tps_median": 168.663, + "prefill_tps_median": 168.663, + "itl_mean_ms_median": 41.919, + "itl_p50_ms_median": 41.728, + "itl_p95_ms_median": 42.671, + "tpot_ms_median": 41.919, + "chunk_tpot_estimate_ms_median": 41.919, + "round_gap_p50_ms_median": 41.728, + "round_gap_p95_ms_median": 42.671, + "tokens_per_chunk_median": 1.0, + "headers_s_median": 0.001, + "first_payload_s_median": 0.001, + "first_content_s_median": 0.19, + "first_reasoning_s_median": null, + "first_tool_s_median": null, + "first_output_s_median": 0.19, + "last_output_s_median": 10.881, + "evidence": [ + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + }, + { + "prompt_tokens": 32, + "cached_tokens": 0, + "tokens": 256, + "cache_state": "cold", + "complete": true, + "token_sha": "98f95af2c394", + "output_sha256": "631efb36da29c99e1df3cd4d0d43d8c651caa1c915c75b14b9d9a923c6212d75", + "completion": "truncated", + "tool_sha256": null + } + ], + "sample": "# How GPUs Do Matrix Multiplication\n\n## The Plain-English Explanation\n\nImagine you have a huge stack of homework to grade, where each problem is completely inde", + "deprecated_keys": { + "prefill_tps": "deprecated: same value as prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time", + "aggregate_prefill_tps": "deprecated: same value as aggregate_prompt_ttft_tps; prompt tokens over client TTFT, not the engine's prefill time" + } + } +] \ No newline at end of file diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill2048.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill2048.json new file mode 100644 index 00000000000..4f52621c93d --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill2048.json @@ -0,0 +1,205 @@ +{ + "schema_version": 1, + "fixture_sha256": "8ad11f12cee69b0e4847f5af75eb56f247c56e88a715246b16fb416d38228895", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.385245949990349, + "decode_tps": 37.17181708924063, + "elapsed_s": 1.788932114985073, + "chunk_offsets_s": [ + 1.385245949990349, + 1.4642002299951855, + 1.5353486649983097, + 1.6088301079871599, + 1.6808680850081146, + 1.7391048319987021, + 1.7887774739938322 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 71.59320601203945, + "p95": 78.95428000483662, + "max": 78.95428000483662 + }, + "completion": "truncated", + "headers_s": 0.013773740996839479, + "first_payload_s": 1.385245949990349, + "first_output_s": 1.385245949990349, + "last_output_s": 1.7887774739938322, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.8317103109729942, + "decode_tps": 37.01996653605283, + "elapsed_s": 2.237062487984076, + "chunk_offsets_s": [ + 1.8317103109729942, + 1.9104628139757551, + 1.9813735669886228, + 2.0557925369939767, + 2.127402430982329, + 2.1857806039915886, + 2.2368970629759133 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 71.26032350060996, + "p95": 78.75250300276093, + "max": 78.75250300276093 + }, + "completion": "truncated", + "headers_s": 0.0008177979907486588, + "first_payload_s": 1.8317103109729942, + "first_output_s": 1.8317103109729942, + "last_output_s": 2.2368970629759133, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.373665441002231, + "decode_tps": 36.9364903474576, + "elapsed_s": 1.7799027129949536, + "chunk_offsets_s": [ + 1.373665441002231, + 1.4524129999917932, + 1.5248033319949172, + 1.5987852269900031, + 1.6706345150014386, + 1.729163311974844, + 1.7797679119976237 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 72.11981000727974, + "p95": 78.7475589895621, + "max": 78.7475589895621 + }, + "completion": "truncated", + "headers_s": 0.0011509839969221503, + "first_payload_s": 1.373665441002231, + "first_output_s": 1.373665441002231, + "last_output_s": 1.7797679119976237, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 1.3787187249981798, + "decode_tps": 7.845789702041863, + "elapsed_s": 3.2907566739886533, + "chunk_offsets_s": [ + 1.3787187249981798, + 1.4573383310053032, + 2.923984230001224, + 3.0215220929821953, + 3.116169824003009, + 3.2124947179981973, + 3.290572161000455 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 95.48631250800099, + "p95": 1466.645898995921, + "max": 1466.645898995921 + }, + "completion": "truncated", + "headers_s": 0.008233911998104304, + "first_payload_s": 1.3787187249981798, + "first_output_s": 1.3787187249981798, + "last_output_s": 3.290572161000455, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 2048, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "137bf282b566", + "token_sha256": "137bf282b566e046a493193cefdd05d41b775a1bd75f45601fb9700d8e4aa85e", + "output_sha256": "0825dd0f6baa82236ce47fadad062c824c965ee046273d3806a4c71cd0be9dde", + "ttft_s": 2.8202026299841236, + "decode_tps": 28.81193236152769, + "elapsed_s": 3.3409348870045505, + "chunk_offsets_s": [ + 2.8202026299841236, + 2.923887270007981, + 3.02184468699852, + 3.1160729599941988, + 3.2126838240073994, + 3.2904931039956864, + 3.340820262004854 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 95.41956850443967, + "p95": 103.68464002385736, + "max": 103.68464002385736 + }, + "completion": "truncated", + "headers_s": 0.008484474004944786, + "first_payload_s": 2.8202026299841236, + "first_output_s": 2.8202026299841236, + "last_output_s": 3.340820262004854, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 3.3409348870045505, + "end_to_end_tps": 9.578157336879704, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill32768.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill32768.json new file mode 100644 index 00000000000..be3f97c39ab --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill32768.json @@ -0,0 +1,215 @@ +{ + "schema_version": 1, + "fixture_sha256": "a1e170d511726b805897019d6af0334a142507d0513991f05b6dbaa5337d4d35", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 22.43347520401585, + "decode_tps": 23.753355795237105, + "elapsed_s": 23.065106045018183, + "chunk_offsets_s": [ + 22.43347520401585, + 22.517139855015557, + 22.604168960999232, + 22.696201798011316, + 22.784924275998492, + 22.874628392019076, + 22.958518116996856, + 23.013206811010605, + 23.064964924007654 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 85.45941548072733, + "p95": 92.0328370120842, + "max": 92.0328370120842 + }, + "completion": "truncated", + "headers_s": 0.017605240020202473, + "first_payload_s": 15.08471096502035, + "first_output_s": 22.43347520401585, + "last_output_s": 23.064964924007654, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 22.88343550398713, + "decode_tps": 23.799239931351813, + "elapsed_s": 23.51401407198864, + "chunk_offsets_s": [ + 22.88343550398713, + 22.96706565999193, + 23.05454979397473, + 23.14672405598685, + 23.235995866998564, + 23.324815161991864, + 23.409826286981115, + 23.46296687499853, + 23.513707732985495 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 86.24762948602438, + "p95": 92.1742620121222, + "max": 92.1742620121222 + }, + "completion": "truncated", + "headers_s": 0.004055419994983822, + "first_payload_s": 15.07495131099131, + "first_output_s": 22.88343550398713, + "last_output_s": 23.513707732985495, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 22.87530606301152, + "decode_tps": 23.601363752169227, + "elapsed_s": 23.510984669992467, + "chunk_offsets_s": [ + 22.87530606301152, + 22.957937653001864, + 23.0462453289947, + 23.139953186007915, + 23.22949423099635, + 23.318518729007337, + 23.405799069994828, + 23.459566046018153, + 23.510862557013752 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 87.79400849016383, + "p95": 93.70785701321438, + "max": 93.70785701321438 + }, + "completion": "truncated", + "headers_s": 0.0038390179979614913, + "first_payload_s": 15.086981466010911, + "first_output_s": 22.87530606301152, + "last_output_s": 23.510862557013752, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 46.70556633902015, + "decode_tps": 21.573864347615388, + "elapsed_s": 47.400960789003875, + "chunk_offsets_s": [ + 46.70556633902015, + 46.79257704800693, + 46.9061806750251, + 47.01945194799919, + 47.1124832900241, + 47.1956375890004, + 47.27789604102145, + 47.34760005501448, + 47.400852068007225 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 85.08250398153905, + "p95": 113.60362701816484, + "max": 113.60362701816484 + }, + "completion": "truncated", + "headers_s": 0.0040210360020864755, + "first_payload_s": 15.088924779003719, + "first_output_s": 46.70556633902015, + "last_output_s": 47.400852068007225, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 32768, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "6c910c6362b5", + "token_sha256": "6c910c6362b5fc328d113ecb01e1e6f80a855d09e74ac9b413706b9b1275c89b", + "output_sha256": "6fe8813f949e004c060b5b7ec70d6d3d6db0b89c18142930fa4512f12e8735bc", + "ttft_s": 23.04526514498866, + "decode_tps": 1.3609320607351683, + "elapsed_s": 34.06725102799828, + "chunk_offsets_s": [ + 23.04526514498866, + 23.12594918598188, + 24.589370254980167, + 26.35951384200598, + 27.930104733997723, + 29.48919314899831, + 31.01542405798682, + 32.53787814298994, + 34.067123202985385 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 1527.7379844919778, + "p95": 1770.1435870258138, + "max": 1770.1435870258138 + }, + "completion": "truncated", + "headers_s": 0.0027086419868282974, + "first_payload_s": 15.061682687985012, + "first_output_s": 23.04526514498866, + "last_output_s": 34.067123202985385, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 47.40118734998396, + "end_to_end_tps": 0.675088574548351, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill38400.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill38400.json new file mode 100644 index 00000000000..a44fed60dff --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill38400.json @@ -0,0 +1,215 @@ +{ + "schema_version": 1, + "fixture_sha256": "41456a6f83f7eda19c29a0b094d78bc2787a04785abd73b3c47099c209a5d1af", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 26.905725010001333, + "decode_tps": 20.380525636995547, + "elapsed_s": 27.641899457987165, + "chunk_offsets_s": [ + 26.905725010001333, + 27.025265030999435, + 27.139397174993064, + 27.256704044004437, + 27.37243435898563, + 27.47494253498735, + 27.53164223697968, + 27.59003308598767, + 27.64172172898543 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 108.32015999767464, + "p95": 119.54002099810168, + "max": 119.54002099810168 + }, + "completion": "truncated", + "headers_s": 0.029895308980485424, + "first_payload_s": 15.100554884003941, + "first_output_s": 26.905725010001333, + "last_output_s": 27.64172172898543, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 26.86662013400928, + "decode_tps": 20.441652951076072, + "elapsed_s": 27.60054657200817, + "chunk_offsets_s": [ + 26.86662013400928, + 26.983764347009128, + 27.098032525012968, + 27.214852095989045, + 27.331426112999907, + 27.434198164002737, + 27.490214836987434, + 27.548948265000945, + 27.600415978988167 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 108.52011450333521, + "p95": 117.14421299984679, + "max": 117.14421299984679 + }, + "completion": "truncated", + "headers_s": 0.002954004012281075, + "first_payload_s": 15.100610602996312, + "first_output_s": 26.86662013400928, + "last_output_s": 27.600415978988167, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 26.869528253999306, + "decode_tps": 20.47161437975737, + "elapsed_s": 27.602385601989226, + "chunk_offsets_s": [ + 26.869528253999306, + 26.986425331007922, + 27.103613288985798, + 27.219670279999264, + 27.33420642800047, + 27.436286106996704, + 27.4928328479873, + 27.550492556998506, + 27.602250144991558 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 108.30791349872015, + "p95": 117.18795797787607, + "max": 117.18795797787607 + }, + "completion": "truncated", + "headers_s": 0.0034607120032887906, + "first_payload_s": 15.103302925999742, + "first_output_s": 26.869528253999306, + "last_output_s": 27.602250144991558, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 54.59123920099228, + "decode_tps": 19.21142992149405, + "elapsed_s": 55.37213296999107, + "chunk_offsets_s": [ + 54.59123920099228, + 54.72587064199615, + 54.857664829993155, + 54.98435103200609, + 55.10946371901082, + 55.20549146900885, + 55.26156017501489, + 55.32004233900807, + 55.372024393000174 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 110.57021850137971, + "p95": 134.6314410038758, + "max": 134.6314410038758 + }, + "completion": "truncated", + "headers_s": 0.004556207015411928, + "first_payload_s": 15.08182862799731, + "first_output_s": 54.59123920099228, + "last_output_s": 55.372024393000174, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 38400, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "00efe51d9743", + "token_sha256": "00efe51d9743455b156a63c4b0680c35365994e32a80b778f4c6634f6a1d34ff", + "output_sha256": "386135aa99debf6d56925276a8089a42be2c76302390d6734d63ab097c8145b9", + "ttft_s": 29.700020388991106, + "decode_tps": 1.356416091233972, + "elapsed_s": 40.75872985800379, + "chunk_offsets_s": [ + 29.700020388991106, + 29.817109516006894, + 31.41211074500461, + 32.99940633799997, + 34.59966659700149, + 36.15170834798482, + 37.68469401600305, + 39.22622574400157, + 40.75857395300409 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 1546.7867394909263, + "p95": 1600.2602590015158, + "max": 1600.2602590015158 + }, + "completion": "truncated", + "headers_s": 0.002967492997413501, + "first_payload_s": 15.08174229200813, + "first_output_s": 29.700020388991106, + "last_output_s": 40.75857395300409, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 55.372239642980276, + "end_to_end_tps": 0.5779069115918765, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill65536.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill65536.json new file mode 100644 index 00000000000..fc4b4397bb9 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill65536.json @@ -0,0 +1,201 @@ +{ + "schema_version": 1, + "fixture_sha256": "0ce17a17a298b8593ec22d6dd64fe44b73f028f390a57cc6786fd3dcf8e5b2e6", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 45.839545127993915, + "decode_tps": 30.078814615876855, + "elapsed_s": 46.33837477499037, + "chunk_offsets_s": [ + 45.839545127993915, + 45.94133724400308, + 46.07134442997631, + 46.181300044991076, + 46.27908384799957, + 46.33823499298887 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 101.7921160091646, + "p95": 130.00718597322702, + "max": 130.00718597322702 + }, + "completion": "truncated", + "headers_s": 0.01801540399901569, + "first_payload_s": 15.107997004000936, + "first_output_s": 45.839545127993915, + "last_output_s": 46.33823499298887, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 45.41797921201214, + "decode_tps": 29.932978147288463, + "elapsed_s": 45.91922644601436, + "chunk_offsets_s": [ + 45.41797921201214, + 45.5181717860105, + 45.64910748699913, + 45.76003207801841, + 45.85829423199175, + 45.919098743994255 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 100.19257399835624, + "p95": 130.93570098862983, + "max": 130.93570098862983 + }, + "completion": "truncated", + "headers_s": 0.005630710016703233, + "first_payload_s": 15.063552845007507, + "first_output_s": 45.41797921201214, + "last_output_s": 45.919098743994255, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 45.908294886990916, + "decode_tps": 30.095447350198263, + "elapsed_s": 46.40709339900059, + "chunk_offsets_s": [ + 45.908294886990916, + 46.00982524000574, + 46.140174222004134, + 46.2504876210005, + 46.347627843992086, + 46.40670914298971 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 101.53035301482305, + "p95": 130.34898199839517, + "max": 130.34898199839517 + }, + "completion": "truncated", + "headers_s": 0.009662275988375768, + "first_payload_s": 15.06490147599834, + "first_output_s": 45.908294886990916, + "last_output_s": 46.40670914298971, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 91.62552468298236, + "decode_tps": 28.91227371296517, + "elapsed_s": 92.1444998459774, + "chunk_offsets_s": [ + 91.62552468298236, + 91.72243470398826, + 91.8479911449831, + 91.94497852900531, + 92.02089818098466, + 92.09225248597795, + 92.14433548800298 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 86.41483649262227, + "p95": 125.55644099484198, + "max": 125.55644099484198 + }, + "completion": "truncated", + "headers_s": 0.029572401981567964, + "first_payload_s": 15.1001164180052, + "first_output_s": 91.62552468298236, + "last_output_s": 92.14433548800298, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 65536, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "25bd8aee46ca", + "token_sha256": "25bd8aee46cadcb1ba880c0508887335c6743a0fd784befaa40c4b9ad171784e", + "output_sha256": "b948a2e63d1489e267dfe67bb0033b5edd9f81618e4c4bb5b060120baf0c7d51", + "ttft_s": 48.25709600598202, + "decode_tps": 2.3359256455029183, + "elapsed_s": 54.678690145985456, + "chunk_offsets_s": [ + 48.25709600598202, + 48.359139884996694, + 49.9733716849878, + 51.56710040799226, + 53.13487476497539, + 54.67853327599005 + ], + "chunk_gaps_ms": { + "count": 5, + "p50": 1567.7743569831364, + "p95": 1614.231799991103, + "max": 1614.231799991103 + }, + "completion": "truncated", + "headers_s": 0.00936098798410967, + "first_payload_s": 15.083880683989264, + "first_output_s": 48.25709600598202, + "last_output_s": 54.67853327599005, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 92.14462202697177, + "end_to_end_tps": 0.34728016997707406, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill8192.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill8192.json new file mode 100644 index 00000000000..0e4120f21e6 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill8192.json @@ -0,0 +1,206 @@ +{ + "schema_version": 1, + "fixture_sha256": "97e2793cfa306b7a51e1c276c339694b79e6e610d57cee3f44ef246181061112", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.6914152649987955, + "decode_tps": 35.02210237791924, + "elapsed_s": 6.120187955006259, + "chunk_offsets_s": [ + 5.6914152649987955, + 5.772320485993987, + 5.846440334018553, + 5.9179153320146725, + 5.997699810017366, + 6.060482605011202, + 6.1197162230091635 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 72.79742301034275, + "p95": 80.90522099519148, + "max": 80.90522099519148 + }, + "completion": "truncated", + "headers_s": 0.014474482013611123, + "first_payload_s": 5.6914152649987955, + "first_output_s": 5.6914152649987955, + "last_output_s": 6.1197162230091635, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.690000900998712, + "decode_tps": 31.959051575576794, + "elapsed_s": 6.159485965006752, + "chunk_offsets_s": [ + 5.690000900998712, + 5.770901434996631, + 5.841877950006165, + 5.902769275999162, + 5.966962448001141, + 6.04242649700609, + 6.108211120998021, + 6.159351499984041 + ], + "chunk_gaps_ms": { + "count": 7, + "p50": 65.78462399193086, + "p95": 80.90053399791941, + "max": 80.90053399791941 + }, + "completion": "truncated", + "headers_s": 0.0030088360072113574, + "first_payload_s": 5.690000900998712, + "first_output_s": 5.690000900998712, + "last_output_s": 6.159351499984041, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.6950930950115435, + "decode_tps": 34.99482388121099, + "elapsed_s": 6.123854491015663, + "chunk_offsets_s": [ + 5.6950930950115435, + 5.776469984004507, + 5.849687442008872, + 5.920546372013632, + 6.004033675999381, + 6.070857362006791, + 6.123727914004121 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 72.03819400456268, + "p95": 83.48730398574844, + "max": 83.48730398574844 + }, + "completion": "truncated", + "headers_s": 0.008891613018931821, + "first_payload_s": 5.6950930950115435, + "first_output_s": 5.6950930950115435, + "last_output_s": 6.123727914004121, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 12.404502477991628, + "decode_tps": 32.50902996132087, + "elapsed_s": 12.866035299986834, + "chunk_offsets_s": [ + 12.404502477991628, + 12.514576363988454, + 12.610874811012764, + 12.678663625003537, + 12.744577081000898, + 12.80701667399262, + 12.865912739012856 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 66.85113499406725, + "p95": 110.073885996826, + "max": 110.073885996826 + }, + "completion": "truncated", + "headers_s": 0.001218071993207559, + "first_payload_s": 12.404502477991628, + "first_output_s": 12.404502477991628, + "last_output_s": 12.865912739012856, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 8192, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "16934a472edb", + "token_sha256": "16934a472edb726f994bea61db080fa63a57360bcc293cef9f819f2a3c33ee2a", + "output_sha256": "49d6e728223e33b9cc9914aec35b002000bbda5f94b6e3f817a1bcb1e14413b2", + "ttft_s": 5.68414007400861, + "decode_tps": 2.1655297139806144, + "elapsed_s": 12.61099937200197, + "chunk_offsets_s": [ + 5.68414007400861, + 5.7669380939914845, + 7.21406062800088, + 9.378849294997053, + 10.940265665005427, + 12.51491260601324, + 12.610851770994486 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 1504.2694520088844, + "p95": 2164.7886669961736, + "max": 2164.7886669961736 + }, + "completion": "truncated", + "headers_s": 0.0011541359999682754, + "first_payload_s": 5.68414007400861, + "first_output_s": 5.68414007400861, + "last_output_s": 12.610851770994486, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 12.86613826098619, + "end_to_end_tps": 2.487148773850282, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill9600.json b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill9600.json new file mode 100644 index 00000000000..2c8a4d8e160 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/prefill9600.json @@ -0,0 +1,212 @@ +{ + "schema_version": 1, + "fixture_sha256": "b7c8ce5a2d4eb38f084e641461657dc5fa38839185d162c7ca0a9e5da77fe0e6", + "requested_reply_tokens": 16, + "temperature": 0, + "seed": 1234, + "rows": [ + { + "phase": "first", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.77654799100128, + "decode_tps": 30.513136053848342, + "elapsed_s": 7.26829983497737, + "chunk_offsets_s": [ + 6.77654799100128, + 6.843704879982397, + 6.90806584598613, + 6.971220259991242, + 7.034482530987589, + 7.096468153002206, + 7.157012420997489, + 7.217766930989455, + 7.268139545980375 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 62.570018009864725, + "p95": 67.15688898111694, + "max": 67.15688898111694 + }, + "completion": "truncated", + "headers_s": 0.01477061299374327, + "first_payload_s": 6.77654799100128, + "first_output_s": 6.77654799100128, + "last_output_s": 7.268139545980375, + "tool_calls": 0, + "tool_sha256": null + }, + { + "phase": "repeated", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.786826575000305, + "decode_tps": 30.646058696132485, + "elapsed_s": 7.286809916986385, + "chunk_offsets_s": [ + 6.786826575000305, + 6.852726927987533, + 6.917308967997087, + 6.979944994993275, + 7.043599747994449, + 7.104649171989877, + 7.16532137800823, + 7.22604190299171, + 7.27628592599649 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 61.84272549580783, + "p95": 65.90035298722796, + "max": 65.90035298722796 + }, + "completion": "truncated", + "headers_s": 0.002409743989119306, + "first_payload_s": 6.786826575000305, + "first_output_s": 6.786826575000305, + "last_output_s": 7.27628592599649, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "repeated", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.760736577009084, + "decode_tps": 30.812283398662245, + "elapsed_s": 7.247644023998873, + "chunk_offsets_s": [ + 6.760736577009084, + 6.827127974014729, + 6.893756732024485, + 6.957629327022005, + 7.023855715000536, + 7.082767812011298, + 7.1359781110077165, + 7.197003327019047, + 7.247555415000534 + ], + "chunk_gaps_ms": { + "count": 8, + "p50": 62.448905504425056, + "p95": 66.62875800975598, + "max": 66.62875800975598 + }, + "completion": "truncated", + "headers_s": 0.001650396006880328, + "first_payload_s": 6.760736577009084, + "first_output_s": 6.760736577009084, + "last_output_s": 7.247555415000534, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 6.960610998998163, + "decode_tps": 1.8918902276709937, + "elapsed_s": 14.889332666993141, + "chunk_offsets_s": [ + 6.960610998998163, + 7.038348136993591, + 8.710029759007739, + 10.450599514995702, + 11.996114342997316, + 13.561951038020197, + 14.79619806399569, + 14.889189402019838 + ], + "chunk_gaps_ms": { + "count": 7, + "p50": 1545.5148280016147, + "p95": 1740.5697559879627, + "max": 1740.5697559879627 + }, + "completion": "truncated", + "headers_s": 0.0017432919994462281, + "first_payload_s": 6.960610998998163, + "first_output_s": 6.960610998998163, + "last_output_s": 14.889189402019838, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + }, + { + "phase": "concurrent", + "prompt_tokens": 9600, + "cached_tokens": 0, + "tokens": 16, + "cache_state": "cold", + "complete": true, + "token_sha": "64d847aaef1e", + "token_sha256": "64d847aaef1e72928679616ff60805655ddd0882159f67bdb0269cd572f479e5", + "output_sha256": "34d716560073b85b56970480f53e96e12bfb8e1b0c49c9cf5a3148c8c8883173", + "ttft_s": 14.662370206002379, + "decode_tps": 28.087688857791484, + "elapsed_s": 15.19654853802058, + "chunk_offsets_s": [ + 14.662370206002379, + 14.796451809001155, + 14.889420587016502, + 14.967456751008285, + 15.064232499018544, + 15.146830854995642, + 15.19641200901242 + ], + "chunk_gaps_ms": { + "count": 6, + "p50": 87.78356699622236, + "p95": 134.08160299877636, + "max": 134.08160299877636 + }, + "completion": "truncated", + "headers_s": 0.0019659970130305737, + "first_payload_s": 14.662370206002379, + "first_output_s": 14.662370206002379, + "last_output_s": 15.19641200901242, + "tool_calls": 0, + "tool_sha256": null, + "equal_first_tokens": true, + "equal_first_output": true + } + ], + "concurrent_timing": { + "requested_requests": 2, + "timed_requests": 2, + "makespan_s": 15.19654853802058, + "end_to_end_tps": 2.105741308293689, + "timing_valid": true + }, + "qualified": true +} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/server-rank0.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/server-rank0.log new file mode 100644 index 00000000000..a2b8f030498 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/server-rank0.log @@ -0,0 +1,230 @@ +info: rank 0: liveness lines from 1 ranks on port 29572 +info: glm kv selection: pool pages; TF_KV_PAGES=auto (default); rank 0 of 2; cache bf16 +TF_MEMORY {"schema":1,"pid":2024748,"rank":0,"phase":"load_begin","reset":true,"monotonic_ns":258911517948816,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":0,"peak":0,"host_peak":0,"allocs":0}} +info: p2p: rank 0 of 2: NCCL's init log is at /tmp/tf-p2p-XHHQUc/nccl.log until startup diagnostics finish; if this rank stops before then, that file holds NCCL's last lines +info: rank 0 startup: entering NCCL init +info: rank 0: NCCL id ce1de2c6 sent +info: rank 0 startup: entering NCCL init (2 ranks, id ce1de2c6, NCCL 2.30.7, CUDA device 0 000F:01:00.0) +info: rank 0 startup: NCCL init done in 539 ms +info: p2p: rank 0 of 2: GPU 0 NVIDIA GB10 (0000000F:01:00.0); driver 580.178.04, CUDA driver API 13.0, NCCL 2.30.7 +info: p2p: peer access: TensorFold enables none itself (no cuCtxEnablePeerAccess); NCCL sets up its own peers +info: p2p: set: NCCL_PROTO=^LL128 +info: p2p: NCCL transport (this rank's connections): rank 1 NET/IB (16 connections) +info: rank 0 startup: entering peer warm-up +info: rank 0 startup: entering weights +info: checkpoint digest: 0.0 GiB read in 0.2 s, 42/42 cached files +info: weights: 16 readers read 159.1 GiB ahead of the loader +info: TF_GLM_L2PF: 226 rows, 1066 MiB a decode window, 2 CTAs a site, the gathers' sites at 150 GB/s (0: unpaced) +info: glm: a prompt chunk's exchanges in 3 row pieces +info: RoCE all-gather: 2 ranks, 1 HCA(s), shards up to 4096 KiB by RDMA writes +info: [tensorfold] glm: rank 0 of 2 sums through the group collective (RoCE gathers on) +TF_MEMORY {"schema":1,"pid":2024748,"rank":0,"phase":"load_end","reset":false,"monotonic_ns":258980784188075,"scope":"process_owned_cuda_buffers","usage":{"device":96911922324,"host":16870016,"peak":96911922964,"host_peak":169938944,"allocs":1404}} +info: glm: windows (kept): 41.07 ms at 1 row, 63.31 at 4, 180.35 at 32, a draft 1.98 ms; experts classic +info: KV page groups: one page 6.38 MiB, 512 rows of the full group; full: layers not named, 12.75 KiB a token, 512 rows a page, 0 B padding (0.0 %) +info: rank 0 startup: entering calibration +info: rank 0 startup: entering ready +[tensorfold] chat template: the checkpoint's +warning: libtfgrammar.so is required for structured output and required tool calls (HTTP 400 when missing); restore the matching release archive's lib/ directory or run zig build grammar -Dxgrammar=DIR; prepare DIR with git clone --branch v0.2.8 --recurse-submodules https://github.com/mlc-ai/xgrammar +[tensorfold] CUDA sm_121 device 0 (NVIDIA GB10, memory shared with the host): model 90.26 GiB; 4 streams at once, the engine's own and 3 more taking 1028 pages of 512 rows (6.40 GiB) as they need them (enough for 4 at a 131072-token window), 231 MiB fixed each, of 13.0 GiB left after a 12.3 GiB reserve; prompts in passes of up to 2048 rows, no prompt cache; own glue kernels +[tensorfold] profile: stable; registered overrides: none +[tensorfold] serving local-model at http://127.0.0.1:8090/v1 (sampling: temperature 1.0, top_p 0.95; drafts: MTP + copies; context: 131072; loaded in 71.5s) +[tensorfold] 127.0.0.1 "GET /health HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "GET /v1/models HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-62f9517b6873e3ef302db4b504e40343 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.132 decode=10.695 elapsed=10.827 queued=0.000 tok/s=23.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-6d8f8022077d55526179602643902773 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.122 decode=10.662 elapsed=10.784 queued=0.000 tok/s=23.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-0170f6882421a4c1ed934cf8c00b0525 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.121 decode=10.837 elapsed=10.958 queued=0.000 tok/s=23.5 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-1664897dd58e6e244e629073b0c8281d prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.123 decode=10.683 elapsed=10.807 queued=0.000 tok/s=23.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-e9dc726707559fc2565d263809affd43 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.122 decode=10.665 elapsed=10.788 queued=0.000 tok/s=23.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-7078301194e5a076cad045fa18fb52b2 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=255 accepted=0/0 ttft=0.121 decode=10.882 elapsed=11.003 queued=0.000 tok/s=23.4 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-4cf8881ffee20be1f925cb24c0485031 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.187 decode=10.695 elapsed=10.883 queued=0.000 tok/s=23.8 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-3fe976205a4664bcdfbd8efa3380a6f8 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.191 decode=10.690 elapsed=10.880 queued=0.000 tok/s=23.9 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-bb04c9e57832684646c38e1188f2166b prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.187 decode=10.798 elapsed=10.985 queued=0.000 tok/s=23.6 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-093850b3eadefd7fa51ad9057725c7e7 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.255 decode=10.728 elapsed=10.982 queued=0.000 tok/s=23.8 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-afb0ce5c98505de447653e68368f369f prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.189 decode=10.671 elapsed=10.859 queued=0.000 tok/s=23.9 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-3f39a2632779e84de8df0481a95d0702 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=255 accepted=0/0 ttft=0.189 decode=10.672 elapsed=10.861 queued=0.000 tok/s=23.9 +[tensorfold] 127.0.0.1 "GET /v1/models HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-8a2b9df77fbd2f9da1bf504fe516cd2f prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=87 accepted=168/329 ttft=0.157 decode=6.569 elapsed=6.726 queued=0.000 tok/s=38.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-53c6cdbe8ca874db0701ac838efd978a prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=90 accepted=165/265 ttft=0.127 decode=6.080 elapsed=6.208 queued=0.000 tok/s=41.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-859fa5f1926967a2915521e0f5485c0a prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=86 accepted=169/276 ttft=0.128 decode=6.034 elapsed=6.162 queued=0.000 tok/s=42.3 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-b84e3f04c9eba402ef48c990160214bd prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=87 accepted=168/265 ttft=0.129 decode=6.025 elapsed=6.154 queued=0.000 tok/s=42.3 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-5ec62814c94291cbb5e6deb4cf163957 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=85 accepted=170/268 ttft=0.129 decode=5.949 elapsed=6.078 queued=0.000 tok/s=42.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-346210a43646a349de732d774faee816 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=3fcd20ce2fb0 finish=length rounds=87 accepted=168/268 ttft=0.130 decode=6.298 elapsed=6.428 queued=0.000 tok/s=40.5 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-6c2022de9e55a606ed403921c0f5acce prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=129 accepted=126/243 ttft=0.196 decode=7.655 elapsed=7.851 queued=0.000 tok/s=33.3 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-3daf609e9b412f73469b1c9000e4d8fb prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=117 accepted=138/242 ttft=0.195 decode=7.171 elapsed=7.366 queued=0.000 tok/s=35.6 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-f6c36fe1a05596b5a9b9eeed8d10b6e3 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=113 accepted=142/273 ttft=0.197 decode=7.244 elapsed=7.441 queued=0.000 tok/s=35.2 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-09449e46bfd8f96606d1e55efbd2052f prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=122 accepted=133/258 ttft=0.196 decode=7.701 elapsed=7.898 queued=0.000 tok/s=33.1 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-f677da72cb7b11ca8832e516c00c3d57 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=123 accepted=132/247 ttft=0.198 decode=7.423 elapsed=7.621 queued=0.000 tok/s=34.4 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-7c7b0aa8f0099803819d6892993a4eee prompt=32 cached=0 thinking=False effort=none tokens=256 sha=98f95af2c394 finish=length rounds=124 accepted=131/260 ttft=0.195 decode=7.609 elapsed=7.804 queued=0.000 tok/s=33.5 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-96e4771f6860b27750bf8dcdb826aab6 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=72 accepted=183/270 ttft=0.129 decode=5.589 elapsed=5.718 queued=0.000 tok/s=45.6 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-8510138711af0ec8a166427c6c3ea404 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=4ea5890db75b finish=length rounds=76 accepted=179/270 ttft=0.130 decode=5.743 elapsed=5.872 queued=0.000 tok/s=44.4 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-21dd9ab9ddf11c26e4ad8c0a0e650ff4 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=9ad5da4b74fc finish=length rounds=77 accepted=179/290 ttft=0.130 decode=6.232 elapsed=6.363 queued=0.000 tok/s=40.9 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-ee41725cf23d33773fafcb9055af2c2e prompt=14 cached=0 thinking=False effort=none tokens=256 sha=e83550d98e0d finish=length rounds=73 accepted=182/318 ttft=0.132 decode=5.975 elapsed=6.107 queued=0.000 tok/s=42.7 seed=1236 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-57a9f5ff2ad0e8e0d71aa339ed4b671f prompt=14 cached=0 thinking=False effort=none tokens=256 sha=6b0505e27f4f finish=length rounds=65 accepted=190/295 ttft=0.133 decode=5.495 elapsed=5.628 queued=0.000 tok/s=46.4 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-f20da9a9395908af8691a01986b299b9 prompt=14 cached=0 thinking=False effort=none tokens=256 sha=ddd2c53eedd3 finish=length rounds=81 accepted=174/286 ttft=0.131 decode=6.061 elapsed=6.192 queued=0.000 tok/s=42.1 seed=1238 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-dd509035e7efd921bc639752cc123d17 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=110 accepted=146/259 ttft=0.198 decode=7.120 elapsed=7.319 queued=0.000 tok/s=35.8 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-dd42ddd2033c9840447bdf7d63028282 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3463a68eb112 finish=length rounds=128 accepted=128/218 ttft=0.195 decode=7.723 elapsed=7.919 queued=0.000 tok/s=33.0 seed=1234 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-159a50439ebd6564e46bf51993d84db8 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=96f9af0c0dc9 finish=length rounds=107 accepted=148/236 ttft=0.200 decode=6.760 elapsed=6.960 queued=0.000 tok/s=37.7 seed=1235 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-4d1354c8eda21a9c0d67a3232e54994a prompt=32 cached=0 thinking=False effort=none tokens=256 sha=3672ac37f298 finish=length rounds=109 accepted=146/261 ttft=0.196 decode=7.127 elapsed=7.323 queued=0.000 tok/s=35.8 seed=1236 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-6a4512fcf419380715b860744ad855ea prompt=32 cached=0 thinking=False effort=none tokens=256 sha=fb6e67c7120b finish=length rounds=109 accepted=147/291 ttft=0.196 decode=7.399 elapsed=7.595 queued=0.000 tok/s=34.5 seed=1237 +[tensorfold] 127.0.0.1 "POST /v1/chat/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done chatcmpl-791250a6d13f9fb8c0504e6eac3175f0 prompt=32 cached=0 thinking=False effort=none tokens=256 sha=1c6010f72ff7 finish=length rounds=116 accepted=139/230 ttft=0.199 decode=7.124 elapsed=7.322 queued=0.000 tok/s=35.8 seed=1238 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-1b6c55bf0dccab03770e323c9ac684e0 prompt=2048 cached=0 thinking=False effort=none tokens=16 sha=137bf282b566 finish=length rounds=6 accepted=9/15 ttft=1.372 decode=0.403 elapsed=1.775 queued=0.000 tok/s=37.2 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-ca5fb6c6522052bbd9c16332b9f69a6f prompt=2048 cached=0 thinking=False effort=none tokens=16 sha=137bf282b566 finish=length rounds=6 accepted=9/15 ttft=1.831 decode=0.405 elapsed=2.236 queued=0.000 tok/s=37.0 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-eccbc117846b540deb5237b3a3a68dad prompt=2048 cached=0 thinking=False effort=none tokens=16 sha=137bf282b566 finish=length rounds=6 accepted=9/15 ttft=1.373 decode=0.406 elapsed=1.779 queued=0.000 tok/s=36.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] done cmpl-941fd385164b9fcc03102f419e9daa9d prompt=2048 cached=0 thinking=False effort=none tokens=16 sha=137bf282b566 finish=length rounds=6 accepted=9/15 ttft=1.378 decode=1.912 elapsed=3.290 queued=0.000 tok/s=7.8 +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-d14ea73c7423eec92c5fa6337130adb5 prompt=2048 cached=0 thinking=False effort=none tokens=16 sha=137bf282b566 finish=length rounds=6 accepted=9/15 ttft=2.819 decode=0.521 elapsed=3.340 queued=1.455 tok/s=28.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-39de352f5bf39c2a9747926d6e39b950 prompt=8192 cached=0 thinking=False effort=none tokens=16 sha=16934a472edb finish=length rounds=6 accepted=9/17 ttft=5.677 decode=0.428 elapsed=6.106 queued=0.000 tok/s=35.0 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-a88efe3fc9beb1bf584026678fb47c5b prompt=8192 cached=0 thinking=False effort=none tokens=16 sha=16934a472edb finish=length rounds=7 accepted=8/17 ttft=5.687 decode=0.469 elapsed=6.157 queued=0.000 tok/s=32.0 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-2fc7f5b614a83ab7a1c58054bf762d6b prompt=8192 cached=0 thinking=False effort=none tokens=16 sha=16934a472edb finish=length rounds=6 accepted=9/17 ttft=5.687 decode=0.428 elapsed=6.116 queued=0.000 tok/s=35.0 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] done cmpl-5efa77199f532a619bee24b6edeff937 prompt=8192 cached=0 thinking=False effort=none tokens=16 sha=16934a472edb finish=length rounds=6 accepted=9/17 ttft=5.683 decode=6.927 elapsed=12.610 queued=0.000 tok/s=2.2 +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-00beb75127cbb0cdfa670ec612d8b573 prompt=8192 cached=0 thinking=False effort=none tokens=16 sha=16934a472edb finish=length rounds=6 accepted=9/15 ttft=12.404 decode=0.461 elapsed=12.865 queued=2.127 tok/s=32.5 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-2c1147fdd4c13ccba0b4b34b7e94caa4 prompt=9600 cached=0 thinking=False effort=none tokens=16 sha=64d847aaef1e finish=length rounds=8 accepted=7/15 ttft=6.762 decode=0.492 elapsed=7.254 queued=0.000 tok/s=30.5 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-36f5594a783c16321e3f1fd49562dc66 prompt=9600 cached=0 thinking=False effort=none tokens=16 sha=64d847aaef1e finish=length rounds=8 accepted=7/15 ttft=6.785 decode=0.490 elapsed=7.275 queued=0.000 tok/s=30.6 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-7f6239d52938633fc75a8a8fb037e5bd prompt=9600 cached=0 thinking=False effort=none tokens=16 sha=64d847aaef1e finish=length rounds=8 accepted=7/14 ttft=6.759 decode=0.487 elapsed=7.246 queued=0.000 tok/s=30.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] done cmpl-6c95bd1af38f4a1d64932661952bfd9e prompt=9600 cached=0 thinking=False effort=none tokens=16 sha=64d847aaef1e finish=length rounds=7 accepted=8/20 ttft=6.959 decode=7.929 elapsed=14.888 queued=0.000 tok/s=1.9 +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-e3b1750fc4730a7c73249756b500ed60 prompt=9600 cached=0 thinking=False effort=none tokens=16 sha=64d847aaef1e finish=length rounds=6 accepted=9/24 ttft=14.661 decode=0.534 elapsed=15.195 queued=2.132 tok/s=28.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-23c22a1ea26cf6e7159e16076d9ec4b6 prompt=32768 cached=0 thinking=False effort=none tokens=16 sha=6c910c6362b5 finish=length rounds=8 accepted=7/30 ttft=22.418 decode=0.632 elapsed=23.049 queued=0.000 tok/s=23.7 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-3123328711e0344ac8675cfc9fc25600 prompt=32768 cached=0 thinking=False effort=none tokens=16 sha=6c910c6362b5 finish=length rounds=8 accepted=7/30 ttft=22.881 decode=0.630 elapsed=23.511 queued=0.000 tok/s=23.8 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-b3708eb4dad9259d2deda82760c3ba33 prompt=32768 cached=0 thinking=False effort=none tokens=16 sha=6c910c6362b5 finish=length rounds=8 accepted=7/30 ttft=22.873 decode=0.636 elapsed=23.509 queued=0.000 tok/s=23.6 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] done cmpl-900fc6e5f8b5b75262a9e7e1639b534a prompt=32768 cached=0 thinking=False effort=none tokens=16 sha=6c910c6362b5 finish=length rounds=8 accepted=7/28 ttft=23.043 decode=11.022 elapsed=34.065 queued=0.000 tok/s=1.4 +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-c6d4c2a8846aa61ff2ca09f7b2115eed prompt=32768 cached=0 thinking=False effort=none tokens=16 sha=6c910c6362b5 finish=length rounds=8 accepted=7/38 ttft=46.703 decode=0.696 elapsed=47.398 queued=2.123 tok/s=21.6 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-0f0199fff5c9b3466e0cea1303fbe3cd prompt=38400 cached=0 thinking=False effort=none tokens=16 sha=00efe51d9743 finish=length rounds=8 accepted=8/45 ttft=26.883 decode=0.736 elapsed=27.620 queued=0.000 tok/s=20.4 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-d37381dbe3e0e92213f0878147b143c0 prompt=38400 cached=0 thinking=False effort=none tokens=16 sha=00efe51d9743 finish=length rounds=8 accepted=8/45 ttft=26.865 decode=0.734 elapsed=27.599 queued=0.000 tok/s=20.4 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-5485eed0f8e91ef3db0e333fb79ff72c prompt=38400 cached=0 thinking=False effort=none tokens=16 sha=00efe51d9743 finish=length rounds=8 accepted=8/45 ttft=26.867 decode=0.733 elapsed=27.600 queued=0.000 tok/s=20.5 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] done cmpl-4ac0363509245c75bbcff93033ab15f3 prompt=38400 cached=0 thinking=False effort=none tokens=16 sha=00efe51d9743 finish=length rounds=8 accepted=8/42 ttft=29.698 decode=11.059 elapsed=40.757 queued=0.000 tok/s=1.4 +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-596e658d6e17e51530fcb3e3590e74b9 prompt=38400 cached=0 thinking=False effort=none tokens=16 sha=00efe51d9743 finish=length rounds=8 accepted=8/52 ttft=54.589 decode=0.781 elapsed=55.370 queued=2.126 tok/s=19.2 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-e20a5d99c4f4850047341dc490c68ecc prompt=65536 cached=0 thinking=False effort=none tokens=16 sha=25bd8aee46ca finish=length rounds=5 accepted=10/34 ttft=45.824 decode=0.499 elapsed=46.323 queued=0.000 tok/s=30.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-24abd84323e0a960c3ff811a2549e4a9 prompt=65536 cached=0 thinking=False effort=none tokens=16 sha=25bd8aee46ca finish=length rounds=5 accepted=10/34 ttft=45.415 decode=0.501 elapsed=45.917 queued=0.000 tok/s=29.9 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-1fce1f4a56932fd3ea8d1b9a870fd2eb prompt=65536 cached=0 thinking=False effort=none tokens=16 sha=25bd8aee46ca finish=length rounds=5 accepted=10/34 ttft=45.904 decode=0.499 elapsed=46.403 queued=0.000 tok/s=30.1 +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] 127.0.0.1 "POST /v1/completions HTTP/1.1" 200 - +[tensorfold] done cmpl-1c257d15eef255a4a3205e71f440c38d prompt=65536 cached=0 thinking=False effort=none tokens=16 sha=25bd8aee46ca finish=length rounds=5 accepted=10/34 ttft=48.253 decode=6.422 elapsed=54.674 queued=0.000 tok/s=2.3 +info: kv pool idle: promised 0, free 1028 + store 0 == total 1028 +[tensorfold] done cmpl-923f745a4329a0245cbe262f7e589591 prompt=65536 cached=0 thinking=False effort=none tokens=16 sha=25bd8aee46ca finish=length rounds=6 accepted=9/30 ttft=91.611 decode=0.519 elapsed=92.130 queued=2.101 tok/s=28.9 +[tensorfold] shutting down (SIGINT): draining: new requests get 503; 0 request(s) in progress may finish within 20.0 s +[tensorfold] shutting down: drained +TF_MEMORY {"schema":1,"pid":2024748,"rank":0,"phase":"cleanup_begin","reset":false,"monotonic_ns":259843262027702,"scope":"process_owned_cuda_buffers","usage":{"device":104510839188,"host":16984704,"peak":104510839188,"host_peak":169938944,"allocs":1408}} +TF_MEMORY {"schema":1,"pid":2024748,"rank":0,"phase":"cleanup_end","reset":false,"monotonic_ns":259844603257912,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":184320,"peak":104510839188,"host_peak":169938944,"allocs":0}} +[tensorfold] shutting down: stopped diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/server-rank1.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/server-rank1.log new file mode 100644 index 00000000000..ac739bbb133 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/server-rank1.log @@ -0,0 +1,24 @@ +info: rank 1: liveness line to rank 0 connected after 21 tries +info: glm kv selection: pool pages; TF_KV_PAGES=auto (default); rank 1 of 2; cache bf16 +TF_MEMORY {"schema":1,"pid":1965426,"rank":1,"phase":"load_begin","reset":true,"monotonic_ns":258907280608202,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":0,"peak":0,"host_peak":0,"allocs":0}} +info: p2p: rank 1 of 2: NCCL's init log is at /tmp/tf-p2p-C0ttA3/nccl.log until startup diagnostics finish; if this rank stops before then, that file holds NCCL's last lines +info: rank 1 startup: entering NCCL init +info: rank 1: NCCL id ce1de2c6 taken +info: rank 1 startup: entering NCCL init (2 ranks, id ce1de2c6, NCCL 2.30.7, CUDA device 0 000F:01:00.0) +info: rank 1 startup: NCCL init done in 531 ms +info: p2p: rank 1 of 2: GPU 0 NVIDIA GB10 (0000000F:01:00.0); driver 580.178.04, CUDA driver API 13.0, NCCL 2.30.7 +info: p2p: peer access: TensorFold enables none itself (no cuCtxEnablePeerAccess); NCCL sets up its own peers +info: p2p: set: NCCL_PROTO=^LL128 +info: p2p: NCCL transport (this rank's connections): rank 0 NET/IB (16 connections) +info: rank 1 startup: entering peer warm-up +info: rank 1 startup: entering weights +info: checkpoint digest: 0.0 GiB read in 0.2 s, 42/42 cached files +info: weights: 16 readers read 159.1 GiB ahead of the loader +info: TF_GLM_L2PF: 226 rows, 1066 MiB a decode window, 2 CTAs a site, the gathers' sites at 150 GB/s (0: unpaced) +info: RoCE all-gather: 2 ranks, 1 HCA(s), shards up to 4096 KiB by RDMA writes +info: [tensorfold] glm: rank 1 of 2 sums through the group collective (RoCE gathers on) +TF_MEMORY {"schema":1,"pid":1965426,"rank":1,"phase":"load_end","reset":false,"monotonic_ns":258976546697042,"scope":"process_owned_cuda_buffers","usage":{"device":96911922324,"host":16870016,"peak":96911922964,"host_peak":169938944,"allocs":1404}} +info: rank 1 startup: ready to follow rank 0 +info: rank 1: rank 0 ended; leaving +TF_MEMORY {"schema":1,"pid":1965426,"rank":1,"phase":"cleanup_begin","reset":false,"monotonic_ns":259839030940230,"scope":"process_owned_cuda_buffers","usage":{"device":104510839188,"host":16890496,"peak":104510839188,"host_peak":169938944,"allocs":1408}} +TF_MEMORY {"schema":1,"pid":1965426,"rank":1,"phase":"cleanup_end","reset":false,"monotonic_ns":259840357835947,"scope":"process_owned_cuda_buffers","usage":{"device":0,"host":90112,"peak":104510839188,"host_peak":169938944,"allocs":0}} diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/stop.txt b/docs/receipts/glm-fp4local-3a56d4eb/sp/stop.txt new file mode 100644 index 00000000000..3c6e427b7c8 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/stop.txt @@ -0,0 +1,2 @@ +rank 0 rc="returncode": 0 +rank 1 rc="returncode": 0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/sp/suite.log b/docs/receipts/glm-fp4local-3a56d4eb/sp/suite.log new file mode 100644 index 00000000000..f08f514e86c --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/sp/suite.log @@ -0,0 +1,8 @@ +RESULT nodraft rc=0 +RESULT drafted rc=0 +RESULT prefill2048 rc=0 +RESULT prefill8192 rc=0 +RESULT prefill9600 rc=0 +RESULT prefill32768 rc=0 +RESULT prefill38400 rc=0 +RESULT prefill65536 rc=0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/build.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/build.sh new file mode 100644 index 00000000000..7452d48d746 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Build each tree under ~/fl-receipt given on the command line with the GB10 kernels; writes ~/fl-receipt/build-.{log,done}. +export PATH=/usr/local/bin:$PATH +for t in "$@"; do + cd ~/fl-receipt/$t || exit 1 + { zig build -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=121 && zig build native -Dnvcc=/usr/local/cuda/bin/nvcc -Dtp-nvcc=/usr/local/cuda/bin/nvcc; echo "rc=$?"; } > ~/fl-receipt/build-$t.log 2>&1 + tail -1 ~/fl-receipt/build-$t.log > ~/fl-receipt/build-$t.done +done diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/chain.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/chain.sh new file mode 100755 index 00000000000..d814d36296e --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/chain.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# usage: chain.sh QUEUE; runs each nonblank line of QUEUE as run.sh's arguments, one launch after another. +cd ~/fl-receipt +while read -r line; do [ -n "$line" ] && eval ./run.sh $line < /dev/null; done < "$1" +echo "$(date '+%F %T') chain $1 END" >> ~/fl-receipt/runs.log diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/fl-env.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/fl-env.sh new file mode 100644 index 00000000000..04e218677d9 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/fl-env.sh @@ -0,0 +1,5 @@ +# GLM-5.3-Flash FP4-Local at TP=2 over the hosts' direct link; sourced by rank.sh on both hosts. +export TF_GLM_WORLD=2 NCCL_COMM_ID=192.0.2.1:29571 NCCL_SOCKET_IFNAME=enp1s0f1np1 NCCL_IB_HCA=rocep1s0f1 +export LD_LIBRARY_PATH=$HOME/fl-receipt/nccl +GLM=$HOME/.cache/huggingface/hub/models--nvidia--GLM-5.3-Flash-FP4-Local/snapshots/76348ddb2be2e35e39ecfc00e75dc07703f4f3d5 +PORT=8090 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/queue.txt b/docs/receipts/glm-fp4local-3a56d4eb/tools/queue.txt new file mode 100644 index 00000000000..7f971e0cfc0 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/queue.txt @@ -0,0 +1,2 @@ +head ex-head ex 40960 -- --parallel 4 +head sp-head sp 131072 -- --parallel 4 --prompt-cache-gib 0 diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/rank.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/rank.sh new file mode 100755 index 00000000000..89fa8e530ba --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/rank.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# usage: rank.sh RANK TREE LABEL CTX [VAR=VAL...] -- [serve args...]; one rank of ~/fl-receipt/TREE, detached, under +# memory_receipts.py (out/LABEL/mem-rankN/, its process.log is the server log); its pid in ~/fl-receipt/rankN.pid. +r=$1 tree=$2 label=$3 ctx=$4; shift 4 +. ~/fl-receipt/fl-env.sh +while [ $# -gt 0 ] && [ "$1" != -- ]; do export "$1"; shift; done; shift +out=~/fl-receipt/out/$label; mkdir -p $out +cd ~/fl-receipt/$tree || exit 1 +TF_GLM_RANK=$r setsid nohup python3 ~/fl-receipt/tools/memory_receipts.py --rank $r --context-tokens $ctx --interval 1 \ + --output $out/mem-rank$r -- zig-out/native/bin/tensorfold-native serve "$GLM" --host 127.0.0.1 --port $PORT \ + --name local-model --no-update-check --context $ctx "$@" > $out/wrap-rank$r.log 2>&1 < /dev/null & +echo $! > ~/fl-receipt/rank$r.pid diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/run.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/run.sh new file mode 100644 index 00000000000..5d76a485923 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/run.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# usage (on rank 0's host): run.sh TREE LABEL SUITE CTX [VAR=VAL...] -- [serve args...] +# Starts rank 1 on the peer, then rank 0 here, waits for health, runs suite-SUITE.sh, stops both; logs in out/LABEL. +tree=$1 label=$2 suite=$3 ctx=$4; shift 4 +. ~/fl-receipt/fl-env.sh +out=~/fl-receipt/out/$label; [ -e $out ] && { echo "$out exists"; exit 1; }; mkdir -p $out +log() { echo "$(date '+%F %T') $label $*" | tee -a ~/fl-receipt/runs.log; } +log "serve $tree $(cd ~/fl-receipt/$tree && git log -1 --format=%h 2>/dev/null || cat .tree 2>/dev/null) ctx $ctx args: $*" +free -g | sed -n 2p > $out/free-before.txt; ssh host-b 'free -g | sed -n 2p' >> $out/free-before.txt +ssh host-b "~/fl-receipt/rank.sh 1 $tree $label $ctx $(printf '%q ' "$@")" +sleep 2 +~/fl-receipt/rank.sh 0 $tree $label $ctx "$@" +t0=$(date +%s); ok=0 +for i in $(seq 1 400); do + sleep 3 + curl -s -m 2 127.0.0.1:$PORT/health >/dev/null 2>&1 && { ok=1; break; } + kill -0 $(cat ~/fl-receipt/rank0.pid) 2>/dev/null || break +done +if [ $ok = 1 ]; then + log "health after $(( $(date +%s) - t0 )) s" + free -g | sed -n 2p > $out/free-ready.txt; ssh host-b 'free -g | sed -n 2p' >> $out/free-ready.txt + (cd $out && bash ~/fl-receipt/suite-$suite.sh $PORT) > $out/suite.log 2>&1 + log "suite $suite rc=$? : $(grep -h '^RESULT' $out/suite.log | tr '\n' ' ')" +else + log "NOT READY"; tail -5 $out/mem-rank0/process.log +fi +~/fl-receipt/stop.sh 0; ssh host-b '~/fl-receipt/stop.sh 1' +sleep 3; scp -q -r host-b:fl-receipt/out/$label/mem-rank1 $out/ 2>/dev/null +for r in 0 1; do echo "rank $r rc=$(grep -o '"returncode": [-0-9]*' $out/mem-rank$r/receipt.json 2>/dev/null)"; done | tee -a $out/stop.txt +log "serve END" diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/stop.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/stop.sh new file mode 100755 index 00000000000..a4cfdb1ddb8 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/stop.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# usage: stop.sh RANK; SIGINT to the wrapper rank.sh started (it forwards to the server), then waits up to 120 s. +pid=$(cat ~/fl-receipt/rank$1.pid 2>/dev/null) || exit 0 +kill -INT $pid 2>/dev/null +for i in $(seq 1 120); do kill -0 $pid 2>/dev/null || exit 0; sleep 1; done +echo "rank $1 still up after 120 s; SIGKILL"; pkill -9 -P $pid; kill -9 $pid diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/suite-ex.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/suite-ex.sh new file mode 100644 index 00000000000..61df1a0bb68 --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/suite-ex.sh @@ -0,0 +1,6 @@ +# Exactness on one server (run.sh runs it in out/LABEL): drafted = plain, concurrent = alone, resumed = cold. +P=$1; T=~/fl-receipt/tools; B=http://127.0.0.1:$P +python3 $T/golden_http.py $P $T/dc.json golden.json > check-golden.log 2>&1; echo "RESULT golden $(tail -1 check-golden.log)" +python3 $T/bench_concurrent.py $B local-model --levels 1,2,4 --tokens 256 --reps 3 --temperatures 0,1 --alone --serial \ + --label ex --output conc.json > check-conc.log 2>&1; echo "RESULT conc rc=$?" +python3 $T/resume_http.py $P resume.json > check-resume.log 2>&1; echo "RESULT resume $(tail -1 check-resume.log)" diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/suite-sp.sh b/docs/receipts/glm-fp4local-3a56d4eb/tools/suite-sp.sh new file mode 100644 index 00000000000..b3b1a4b366b --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/suite-sp.sh @@ -0,0 +1,10 @@ +# Speed on one server started with --prompt-cache-gib 0: decode plain and drafted, then cold prompts by size. +P=$1; T=~/fl-receipt/tools; B=http://127.0.0.1:$P +python3 $T/openai_aligned.py nodraft $B local-model --tokens 256 --reps 5 --temperatures 0 --label nodraft \ + --output nodraft.json > check-nodraft.log 2>&1; echo "RESULT nodraft rc=$?" +python3 $T/bench_openai.py $B local-model --tokens 256 --reps 5 --temperatures 0,1 --label drafted \ + --output drafted.json > check-drafted.log 2>&1; echo "RESULT drafted rc=$?" +for n in 2048 8192 9600 32768 38400 65536; do + python3 $T/bench_cache.py $B local-model --prompt-file $T/p$n.json --tokens 16 --require-cold \ + --output prefill$n.json > check-prefill$n.log 2>&1; echo "RESULT prefill$n rc=$?" +done diff --git a/docs/receipts/glm-fp4local-3a56d4eb/tools/summarize.py b/docs/receipts/glm-fp4local-3a56d4eb/tools/summarize.py new file mode 100644 index 00000000000..ee63d294f6e --- /dev/null +++ b/docs/receipts/glm-fp4local-3a56d4eb/tools/summarize.py @@ -0,0 +1,113 @@ +"""The receipt's tables from run.sh's output folders (out/LABEL): startup and memory for every run, then each suite's +checks and timings. Markdown to stdout; a failed or missing check prints FAIL. Standard library only. + + python3 summarize.py OUT_DIR LABEL... +""" +import json +import os +import re +import statistics +import sys + + +def path(d, r, run, published): + """A rank's file as run.sh leaves it (mem-rankN/NAME) or as the receipt publishes it.""" + p = os.path.join(d, f"mem-rank{r}", run) + return p if os.path.exists(p) else os.path.join(d, published.format(r)) + + +def log(d, r): + return open(path(d, r, "process.log", "server-rank{}.log"), errors="replace").read() + + +def startup(d): + text = log(d, 0) + def find(pat): + m = re.search(pat, text) + return m.group(1) if m else "-" + gib = 2 ** 30 + mem = [] + for r in (0, 1): + rec = json.load(open(path(d, r, "receipt.json", "memory-rank{}.json"))) + rows = {x["phase"]: x["usage"] for x in rec["native"]["rows"]} + mem.append(f"rank {r}: {rows['load_end']['device'] / gib:.2f} at load end, {rows['cleanup_begin']['peak'] / gib:.2f} peak, " + f"{rows['cleanup_end']['device'] / gib:.2f} after cleanup, exit {rec['returncode']}") + return {"loaded": find(r"loaded in ([0-9.]+)s"), "digest": find(r"checkpoint digest: ([^\n]+)"), + "plan": find(r"\(NVIDIA GB10[^)]*\): ([^\n]+)"), "windows": find(r"glm: windows (\((?:timed|kept)\): [^\n]+)"), + "drafts": find(r"drafts: ([^;]+);"), "memory": "; ".join(mem)} + + +def ex(d): + out = [] + g = json.load(open(os.path.join(d, "golden.json"))) + gl = open(os.path.join(d, "check-golden.log")).read() + for kind in ("count", "prose", "code"): + ok = f"PASS {kind}: drafts and plain equal" in gl + rnd = re.search(rf"{kind} drafts: \d+ tokens, \w+, ([0-9.]+) s, ([0-9.]+) a round", gl) + out.append(f"| golden {kind} | `{g[kind]['token_sha256'][:12]}` | {'PASS' if ok else 'FAIL'} drafted = plain, " + f"{float(rnd.group(2)):.2f} tokens a round, {rnd.group(1)} s for 512 |") + c = json.load(open(os.path.join(d, "conc.json"))) + bad = 0 + for cell in c["cells"]: + a, s = cell["alone"], cell["serial"] + bad += a["unequal"] + a["failed"] + s["unequal"] + s["failed"] + cell["failed"] + n = len(c["cells"]) + out.append(f"| concurrent | {n} cells | {'PASS' if bad == 0 else 'FAIL'}: every reply = its alone run = `\"draft\": false` " + f"({sum(x['alone']['equal'] for x in c['cells'])} and {sum(x['serial']['equal'] for x in c['cells'])} equal, {bad} not) |") + r = json.load(open(os.path.join(d, "resume.json")))["rows"] + first = r[0]["token_sha256"] + same = all(x["token_sha256"] == first for x in r) + cached = sorted({x["cached_tokens"] for x in r[1:]}) + out.append(f"| resume | `{first[:12]}` | {'PASS' if same and r[0]['cached_tokens'] == 0 and min(cached) > 0 else 'FAIL'}: " + f"{len(r) - 1} resumed replies ({', '.join(x['phase'] for x in r[1:])}) from {cached} cached of " + f"{r[0]['prompt_tokens']} = cold |") + rows = ["| prompt | t | streams | aggregate tok/s | per stream | first token max (s) |", "| --- | ---: | ---: | ---: | ---: | ---: |"] + for cell in c["cells"]: + rows.append(f"| {cell['prompt']} | {cell['temperature']:g} | {cell['streams']} | {cell['aggregate_tps']} | " + f"{cell['per_stream_tps']} | {cell['ttft_s_max']} |") + return out, rows + + +def sp(d): + rows = ["| decode | prompt | t | median tok/s | all | tokens a reply equal |", "| --- | --- | ---: | ---: | --- | --- |"] + for kind in ("nodraft", "drafted"): + for r in json.load(open(os.path.join(d, f"{kind}.json"))): + shas = {e["token_sha"] for e in r["evidence"]} + same = "yes" if r["temperature"] == 0 and len(shas) == 1 else ("n/a (sampled)" if r["temperature"] else "NO") + rows.append(f"| {'`\"draft\": false`' if kind == 'nodraft' else 'drafted'} | {r['prompt']} | {r['temperature']:g} | " + f"{r['decode_tps_median']:.1f} | {', '.join(f'{x:g}' for x in r['decode_tps_all'])} | {same} |") + pre = ["| cold prompt (tokens) | first token, s (first, two repeats) | prompt tok/s (median) | two at once, s | cached | ids equal |", + "| ---: | --- | ---: | --- | --- | --- |"] + for n in (2048, 8192, 9600, 32768, 38400, 65536): + p = os.path.join(d, f"prefill{n}.json") + if not os.path.exists(p): + pre.append(f"| {n} | FAIL: no result | | | | |") + continue + r = json.load(open(p))["rows"] + t = [x["ttft_s"] for x in r if x["phase"] in ("first", "repeated")] + two = sorted(x["ttft_s"] for x in r if x["phase"] == "concurrent") + pre.append(f"| {r[0]['prompt_tokens']:,} | {', '.join(f'{x:.2f}' for x in t)} | {r[0]['prompt_tokens'] / statistics.median(t):,.0f} | " + f"{', '.join(f'{x:.2f}' for x in two)} | " + f"{sorted({x['cached_tokens'] for x in r})} | {'yes' if len({x['token_sha256'] for x in r}) == 1 else 'NO'} |") + return rows, pre + + +def main(base, labels): + for label in labels: + d = os.path.join(base, label) + s = startup(d) + print(f"### {label}\n\n- loaded in {s['loaded']} s; digest {s['digest']}; drafts {s['drafts']}") + print(f"- plan: {s['plan']}\n- windows: {s['windows']}\n- memory (GiB, process-owned CUDA buffers): {s['memory']}\n") + if os.path.exists(os.path.join(d, "golden.json")): + checks, rows = ex(d) + print("| check | ids | result |\n| --- | --- | --- |") + print("\n".join(checks) + "\n") + print("\n".join(rows) + "\n") + if os.path.exists(os.path.join(d, "nodraft.json")): + rows, pre = sp(d) + print("\n".join(rows) + "\n") + print("\n".join(pre) + "\n") + + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2:]) diff --git a/docs/recipes/glm-5.3-flash-cuda.md b/docs/recipes/glm-5.3-flash-cuda.md index b882983940f..4eb79aed667 100644 --- a/docs/recipes/glm-5.3-flash-cuda.md +++ b/docs/recipes/glm-5.3-flash-cuda.md @@ -5,7 +5,7 @@ The native CUDA build serves GLM-5.3-Flash at tensor parallel over hosts: from N ([1.1.0](../../CHANGELOG.md#110), [the checkpoint](glm-5.3-flash.md#exl3)), and in [1.1.5](../../CHANGELOG.md#115) (#1050) from NVIDIA's FP4-Local checkpoint as stored and from XSFP4, which keeps FP4-Local's tensors outside the routed experts. Jammed XSFP4, in [1.2.3](../../CHANGELOG.md#123) ([#2041](https://github.com/ashhart/TensorFold/pull/2041)), holds those experts at block 32 in the `csf0_v1` form and loads the same way. -Jammed XSFP4 NZ5, on `main` after 1.2.7 ([#2894](https://github.com/ashhart/TensorFold/pull/2894)), is Jammed XSFP4 refitted with E2M1's -0 code read as +5 (`NVFP4_NZ5`) and loads the same way. +Jammed XSFP4 NZ5, in [1.2.10](../../CHANGELOG.md#1210) ([#2894](https://github.com/ashhart/TensorFold/pull/2894)), is Jammed XSFP4 refitted with E2M1's -0 code read as +5 (`NVFP4_NZ5`) and loads the same way. Rank 0 serves HTTP and the other ranks follow its steps, with MTP drafts, concurrent streams and kept prompt states. The [Python 0.6.6 recipe](glm-5.3-flash.md) and its `--tp`, `--rank` and `--master` flags belong to the frozen engine. @@ -36,6 +36,12 @@ in 302.1 s, and rank 0 reported `model 96.11 GiB; 1 stream at once, 3.16 GiB eac left after a 12.2 GiB reserve` and a 5.8 GiB prompt cache ([#1040](https://github.com/ashhart/TensorFold/issues/1040)). +FP4-Local takes the same commands with its own name: `tensorfold pull +nvidia/GLM-5.3-Flash-FP4-Local@76348ddb2be2e35e39ecfc00e75dc07703f4f3d5`, then `nvidia/GLM-5.3-Flash-FP4-Local` on every +rank. Its [receipt on `main`](../receipts/glm-fp4local-3a56d4eb/README.md) (`3a56d4eb92`, two GB10 at TP=2) has drafted +replies equal to plain, concurrent to alone and resumed to cold, 90.2 GiB of model a rank, 23.9 tok/s plain and 34 to 42 +drafted at one stream, and about 1,430 prompt tokens a second from 2,048 to 65,536 tokens. + ## Requests - `--vision` on every rank reads images and video: rank 0's tower encodes them and sends their rows and spans to the @@ -213,6 +219,18 @@ missing link (#1971). The ring also needs these NCCL settings at start (#1971): - `NCCL_ALGO=Ring`, and a graph for each rank that receives on the port toward the previous rank and sends toward the next. +For switchless RoCE links on separate IPv4 subnets, use NCCL 2.30.7 or later: [subnet-aware +routing](https://github.com/NVIDIA/nccl/blob/v2.30.7-1/src/transport/net_ib/connect.cc#L61-L62) +first shipped in [v2.30.7-1](https://github.com/NVIDIA/nccl/commit/5c1c4288e6627e9b442eda997aa6ee9136cda0bd). +Point each rank at a newer `libnccl.so.2` with `LD_LIBRARY_PATH=/path/to/nccl/lib`, retaining other trusted library +directories. +Set `NCCL_IB_SUBNET_AWARE_ROUTING=1` and `NCCL_IB_SUBNET_PREFIX_LEN=24`, keeping the settings above; +the prefix must match the links' IPv4 subnets (24 for /24). +On every rank, check `rank N startup: entering NCCL init (..., NCCL X.Y.Z, ...)` and `NCCL_DEBUG=INFO` +for the selected NIC and subnet-aware overrides. +With gather prefill, replacing 2.28.9 with a build reporting 2.30.7 and enabling these settings fixed startup timeouts +and completed requests. + `TF_GLM_ROCE_MULTI=1` with `TF_TP_ROCE_RELAY=1` relays gathers through both neighbours on such a ring instead of NCCL (#2352, opt-in, four ranks only). Gathers up to `TF_TP_ROCE_RELAY_MAX_KB` a rank go on the wire (64 KiB by default, 4 to 1024); larger ones, reductions and exchanges stay on NCCL. On the ring with gather, @Bizuayeu measured diff --git a/docs/recipes/idol-cuda.md b/docs/recipes/idol-cuda.md new file mode 100644 index 00000000000..0d0a2aed547 --- /dev/null +++ b/docs/recipes/idol-cuda.md @@ -0,0 +1,61 @@ +# Idol's denoiser on CUDA + +Idol's denoiser (see `idol.md`) on the CUDA runtime, beside the Metal family and driven by the same case driver +(`zig/tests/idol_run.zig`): `tf-idol` on Metal and on CUDA reads the same case and runs the same gates. The image +encoders, the decoders and the PLY writer are not ported, and nothing registers with the lane engine or the server. + +**Where it has run.** The kernel contract and the synthetic case have passed on a GB10 (sm_121) and on an RTX 5090 +(sm_120). + +- GB10, nvcc 13.0, on `05ab1990a` (GustavBlack's [run][gb10-current] of 15 Nov on #1767): `idol-contract` gives + `SUMMARY idol: 13 kernels, 13 pass gates 1-4, 0 fail; 3 controls: 3 red as planted, 0 missed`, and `tf-idol` on the + shared synthetic case (`idol-synthetic-case-2731c229`) has 100 of 100 branch-steps within the gate, all 23 joint + blocks passing at `blocks 0` and a repeat with identical bytes; its 50 steps took 53.04 s. Its peak memory is not + recorded yet. +- Earlier GB10 contract runs on `776a3335d` ([run][gb10]) and on `c3a6c0cb7`, after the controls moved to their own + header ([run][gb10-rerun]), gave the same SUMMARY line. Both come before `36828402d`, which recompiled the norm + kernels. +- RTX 5090, CUDA 13.3 (nvcc 13.3.73), on `f5b88dd98` ([run][rtx5090]): `idol-contract` gives the same SUMMARY line, + and `tf-idol` on the shared synthetic case (`idol-synthetic-case-2731c229`) has 100 of 100 branch-steps within the + gate and a repeat with identical bytes. Idol's CUDA sources are unchanged since `f5b88dd98`. + +[gb10-current]: https://github.com/ashhart/TensorFold/pull/1767#issuecomment-6886995407 +[gb10]: https://github.com/ashhart/TensorFold/pull/1767#issuecomment-6777718609 +[gb10-rerun]: https://github.com/ashhart/TensorFold/pull/1767#issuecomment-6802382536 +[rtx5090]: https://github.com/ashhart/TensorFold/pull/1767#issuecomment-6869833180 + +`Model.load` admits sm_121 (GB10) and sm_120 (RTX 50, RTX PRO Blackwell) and refuses any other GPU by name. + +## Precision + +The same contract as on Metal, in CUDA's own terms: + +- fp16 block projections on cuBLASLt (`CUBLAS_COMPUTE_32F`, fp16 inputs, fp32 output); `idol.cu` adds the bias to + those fp32 sums and rounds once to fp16, GELU after it. +- RePo's maps, the condition embedding and the output projection in fp32 on cuBLASLt with `CUBLAS_COMPUTE_32F` and + fp32 inputs: true fp32 (no TF32), so no hi/lo split is needed here. +- LayerNorms in fp32, rounded to fp16; the modulation in fp16 ops. +- Attention: `idol_attention.cuh`, head 64, fp16 q, k and v, fp32 scores, softmax and sums, scale 1/8, every query row + to every key row. It is Idol's own kernel: no shared attention template gains an instance. + The softmax denominator sums the fp32 P, and P is rounded to fp16 only for P·V; Metal's `id_attention` rounds P to + fp16 first and sums the rounded values. +- `idol.cu` builds with the glue flags (`--fmad=false`, IEEE division and square root). `F.normalize`'s clamp keeps a + NaN norm, as on Metal. + +## Kernel contract + +`tf-cuda-test idol-contract` runs gates 1-4 over every `idol.cu` kernel and the attention, with three controls that +each drop one fp16 rounding point; the full contract runs it among its family sets. Gate-5 records +(`zig/src/core/contract/idol_cuda_records.zig`) are nvcc 13.0's for sm_80, 86, 89, 120 and 121. On a GB10 and on +an RTX 5090 it gives the SUMMARY line above. On the 5090, nvcc 13.3's registers for four launches differ from the 13.0 +records, all within their bounds. + +## Run a case + +```sh +zig build idol-cuda +zig-out/bin/tf-idol WEIGHTS case/ +zig-out/bin/tf-idol WEIGHTS case/ blocks 0 +``` + +The case comes from `tools/zig/idol_case.py`, as in `idol.md`. diff --git a/docs/recipes/idol.md b/docs/recipes/idol.md new file mode 100644 index 00000000000..05fe83036f9 --- /dev/null +++ b/docs/recipes/idol.md @@ -0,0 +1,137 @@ +# Idol's denoiser on Metal + +Idol (speridlabs) turns one image into a 3D Gaussian splat. A 0.37B flow transformer denoises 8,192 latent rows of 16 +channels, conditioned on the image's DINOv3 and FLUX.2 VAE rows; two decoders then grow an octree from that latent and +emit the Gaussians. `zig/src/families/idol` runs the denoiser on the Metal runtime from the released checkpoint: + +- once an image: the condition embedding (DINOv3's 1,280 channels and the VAE's 128, each projected to 1,024 and + summed) and the two condition-refiner blocks (no modulation, affine LayerNorms); +- at each step: the two noise-refiner blocks over the latent rows, then the 24 joint blocks over 12,294 rows (8,192 + latent, 4,101 condition, one camera token), then the output head and the camera velocity. + +Every block is 16 heads of 64 at width 1,024 with a tanh-GELU MLP of 4,096. Its rotary is RePo: a learned map from +each row's LayerNorm to per-head 3D positions, angles from 10, 10 and 12 frequencies per axis. + +The sampler's defaults: 50 Euler steps, `t = 3u / (1 + 2u)`, guidance `v = 4 v_cond - 3 v_uncond` (two passes a step: +with the condition, and with zeros). + +The image encoders, the decoders and the PLY writer are not ported yet. `tools/zig/idol_case.py` runs the publisher's +SDK in torch, a development reference. It is a denoiser, not a token family: it does not register with the lane +engine, the server or `families.detect`. + +It runs on the M5's tensor units alone, the only chip it was checked on: `Model.load` refuses a GPU without them. + +## Checkpoint + +`speridlabs/idol` at `2731c2291fc65a797c5cb627a5e5526fc1490902`, Apache 2.0, ungated. `config.json` must name +`LatentSeqMMFlowModel` at the released geometry, and `denoiser.safetensors` must hold its 560 tensors; anything else is +refused. The reference is idol-sdk at `4702a7f00850e34b6e83a2170cc123c3e9570744` (Apache 2.0). + +## Precision + +The SDK loads the checkpoint's fp32 weights and converts the blocks' linear layers to fp16; everything else stays fp32. +This family keeps that split: + +- fp16 block projections with fp32 sums; the bias joins the sums before one fp16 rounding, GELU after it. +- LayerNorms in fp32, rounded to fp16; the modulation's shift and scale in fp16 ops, as torch's fp16 tensors run them. +- RePo in fp32: its LayerNorm, both 1,024 to 128 maps, the 128 to 48 map and the angles. +- Attention: fp16 q, k and v, fp32 scores and sums. q and k are rotated, then L2-normalized and scaled by the + checkpoint's gamma times 8. The tensor units take an fp32 P short, which left outputs 3.5e-4 low on average, so + `id_attention` rounds P to fp16 itself and sums the softmax's denominator over those same values. +- The condition embedding and the output projection in fp32; the time MLP, modulation and camera MLPs on the host. + +### The tensor units' fp32 matmul is not fp32 + +On the M5, a GEMM whose inputs are fp32 on the tensor units (`tfp::gemm_nax`, the Qwen-VL tower's +`qwv_gemm_f32`, MLX's fp32 matmul) truncates each input to 10 mantissa bits, toward zero (#1772): its error against +float64 is about 7.5e-4 of the result, against about 1e-7 for an fp32 FMA. RePo's maps at that precision move +block 8's attention out of its gate. + +`id_norm_split` therefore writes each RePo input row as fp16 `[hi | hi | lo]` (`lo = x - hi`), and the map's weights are +stored `[hi | lo | hi]`, scaled by a power of two so `lo` stays normal. One fp16 split-K GEMM with K = 3,072 then sums +`hi*hi + hi*lo + lo*hi` in fp32; `id_repo` undoes the scale. With it every block passes its gate. `id_gemm32`, +an fp32 FMA GEMM on simdgroup matrices, is exact but takes 0.47 s a forward if it runs RePo; it serves the condition +embedding (once an image) and the output projection. + +## Kernel contract + +`zig/tests/contract/metal_idol*.zig` registers every kernel of `idol.metal` and `idol_attention.metal`: + +- `id_linear`'s eight forms (plain and GELU, each tile tail) and the split-K halves `id_split_0` and `id_split_1`; +- `id_norm` (plain, affine, modulated), `id_norm32` (affine, modulated) and `id_norm_split`; +- `id_repo`, `id_qk`, `id_gate_add`, `id_embed`, `id_cond`, `id_bias32` and `id_gemm32`; +- the attention's four forms. + +Each output must lie in the range its fp32 steps allow at the SDK's fp16 rounding points. Nineteen controls drop or +add one rounding point or sum in fp16, and each must go red at its gate. One runs the tensor units' fp32 GEMM in +`id_gemm32`'s place: gate 4 misses it by 13 million times the exact-sum bound. `id_qk` keeps a NaN norm as +`F.normalize` does. Forms no engine call reaches (`id_linear_00` and `_10`, attention `01` and `10`, plain `id_norm`, +affine `id_norm32`) are checked at made-up shapes. The tensor-unit kernels do not build for M1 or M2 offline, as +MOSS-Image's do not; the rest build at their reserved thread counts. + +`tf-kernel-contract --only "metal idol"` on the M5 Ultra: + +``` +SUMMARY 27 kernels: 27 pass gates 1-4, 0 fail, 0 known findings; 19 controls: 19 red as planted, 0 missed; 0 limit problems +``` + +## Run a case + +`idol_case.py` imports the SDK's `dit.py`, `layers.py` and `sampler.py` only when each file's sha256 is the pinned +commit's, and the snapshot only when it is the pinned revision. + +```sh +hf download speridlabs/idol --revision 2731c2291fc65a797c5cb627a5e5526fc1490902 --local-dir WEIGHTS +git clone https://github.com/speridlabs/idol-sdk SDK && git -C SDK checkout 4702a7f00850e34b6e83a2170cc123c3e9570744 +python3 tools/zig/idol_case.py case WEIGHTS SDK case/ --features dino.safetensors vae.safetensors +python3 tools/zig/idol_case.py case WEIGHTS SDK case/ --synthetic-conditioning --cond-seed N # or: no encoders +python3 tools/zig/idol_case.py exact WEIGHTS SDK case/ # the same steps with an fp32 denoiser +python3 tools/zig/idol_case.py blocks WEIGHTS SDK case/ --step 0 # each block's input and output, fp16 and fp32 +zig build tf-idol -Dcpu=apple_m1 +zig-out/bin/tf-idol WEIGHTS case/ +zig-out/bin/tf-idol WEIGHTS case/ blocks 0 +``` + +The features are the SDK's own `feature1` [1, 4101, 1280] and `feature2` [1, 4101, 128] for an image. The case holds the +seeded noise (torch's CPU generator), the schedule, the SDK's input, both velocities and camera velocities at every +step, and its final sample. `exact` adds fp32 velocities on the same inputs; `blocks` adds every block's input and +output at one step, and each joint block run alone in fp32 on the SDK's fp16 input. + +`tf-idol` gates: + +- **Each step**, both branches on the SDK's own input: cosine against the fp32 velocity within 2x the SDK's own + distance (`1 - cos`). Worst row over the run within 2x the SDK's worst row. Fifty fp16 steps make single rows chaotic, + so the per-row gate runs per block instead: +- **Each block** alone on the SDK's fp16 input, against that block in fp32: worst row and cosine within 2x the SDK's. +- **Repeat**: the same step twice, another between, byte for byte. + +It then runs the whole guided schedule from the noise, times it, and writes `sample.f32`. `reference.zig`'s tests plant +a 5% error in one row and require the gate to fail it. + +## Measured + +Setup: + +- Mac Studio M5 Ultra 256 GB, macOS 27; this commit's `tf-idol`. +- The SDK on torch 2.13.0 (MPS, fp16 blocks, `ATTN_BACKEND=sdpa`). +- The SDK's avocado example: its own DINOv3 and VAE features, seed 42, 50 steps, guidance 3. + +Results: + +- **Velocity**, both branches of all 50 steps on the SDK's own input (100 of 100 pass): + - against the SDK: cosine 0.999998 or better; + - against fp32: our worst row over the run 0.0474, the SDK's 0.0398; per step our `1 - cos` is the SDK's within + the 2x bound at every step, and the smaller at 75 of the 100. +- **Blocks**, at steps 1 and 41, each of the 23 joint blocks after the first on the SDK's input: all pass, worst rows + 0.0008 to 0.0017 against fp32, where the SDK's are 0.0007 to 0.0025. +- **Sample:** our 50 guided steps from the same noise end at cosine 0.999993 to the SDK's sample. +- **Repeat:** identical bytes. +- **Speed**, one session: 0.275 s a forward (27.5 s for 50 guided steps), 3.4x the SDK's 0.939 s (the median of its + 100). Load 0.2 to 1.6 s; the condition, once an image, 0.07 s. +- **Memory:** 1.84 GB peak process footprint (`/usr/bin/time -l`, the whole `tf-idol` run with its case), the + denoiser's fp16 weights in shared Metal buffers. + +The shared synthetic case (release `idol-synthetic-case-2731c229`, `--synthetic-conditioning`), jayleaton's run of +`tf-idol` at 9aaf5d318 on an M5 Ultra: exit 0, 100 of 100 branch-steps pass, worst row over the run 0.0932 against the +SDK's 0.1009, `blocks 0` all 23 joint blocks pass, repeat identical bytes, final cosine 0.998918, 27.55 s for 50 guided +steps. diff --git a/docs/recipes/qwen3.8-27b.md b/docs/recipes/qwen3.8-27b.md index 478350c3cad..76485984510 100644 --- a/docs/recipes/qwen3.8-27b.md +++ b/docs/recipes/qwen3.8-27b.md @@ -22,6 +22,17 @@ tensorfold pull z-lab/Qwen3.8-27B-DFlash2 tensorfold serve TensorFold/Qwen3.8-27B-MLX-4bit --drafter z-lab/Qwen3.8-27B-DFlash2 --name bench ``` +With thinking on, serve with `--thinking-budget 4096`; a client can set its own positive `thinking_budget` per request +([API](../api.md#request-fields)). Measured on GPQA Diamond (198 questions) with TensorFold 1.2.7, +`TensorFold/Qwen3.8-27B-MLX-4bit` and the DFlash2 drafter on one GB10, the model card's thinking sampling, a +16,384-token reply limit and one attempt per question and setting: without a budget 78 of 198 replies were cut at the +limit and with 4096 none were; the correct share went from 58.1% to 82.8%, and the 198 questions finished 3.2 times +sooner (60 against 194 minutes at 8 parallel requests). Budgets from 4096 to 8192 measured the same within noise, and +2048 was too tight. The table, the method and the per-question files are in +[#3323](https://github.com/ashhart/TensorFold/issues/3323). + +`--thinking-reserve` ([API](../api.md#reasoning)) keeps a client's `max_tokens` for the answer; it was not tested. + A lone Metal DFlash2 stream can verify 16, 32 or 64 rows (`TF_QWEN27_WINDOW`), on tensor units and earlier chips. Both device classes retain the 16-row default. Startup prices every row count through the selected width, in a width-tagged cache. diff --git a/docs/recipes/training-a-drafter.md b/docs/recipes/training-a-drafter.md index 4a1df718ff9..5c9e2dacaae 100644 --- a/docs/recipes/training-a-drafter.md +++ b/docs/recipes/training-a-drafter.md @@ -109,6 +109,50 @@ over 213.6M tokens. On Kolibri's held-out recordings it accepts 1.937 / 1.321 / German), against 1.38 / 1.23 / 0.95 for the chain drafter it replaced. Those slices chose the checkpoint, so they are development numbers, not a test set. +## Adapting a released drafter + +In the Qwen3.8-27B DSpine-b16 pilot below, no adapted checkpoint beat the released drafter on the independent agent set: +the short budget lost the least rather than gaining. Budget a warm-started adaptation from a few passes over the +scarcest class at a low learning rate, rather than from throughput times a time budget. With replacement and fixed class +quotas, estimate +`expected draws per context = class batch slots * training steps / available class contexts`. +These draws are not complete epochs. Save early checkpoints and follow each class's held-out curve before extending +the run; a first snapshot taken after many repeats can miss the useful part of an adaptation. + +In the [pilot][dspine-pilot], 203 agent contexts with four of nine batch slots had about 13 expected draws each by the +first checkpoint at step 662 of two 5,300-step runs at peak learning rate 3e-5. A 660-step run at peak learning rate +1e-5, with one agent slot, ended at about 3.3 draws per context. Offline tree acceptance on the independent agent set +(110 prompts, 48 SWE instances), tokens per round, with the paired difference to the released drafter and its 95% +group-bootstrap interval: + +| Checkpoint | Steps | Tokens per round | Difference | +| --- | ---: | ---: | --- | +| Released DSpine-b16 | none | 6.079 | | +| Short run, peak LR 1e-5 | 660 | 6.053 | -0.026 [-0.116, +0.048] | +| Long run, SpecForge PR 1038 objective, first checkpoint | 662 of 5,300 | 5.922 | -0.157 [-0.226, -0.091] | +| Long run, loss cut at the first miss, final checkpoint | 5,296 of 5,300 | 5.868 | -0.211 [-0.317, -0.126] | + +The short run stayed closest to the released drafter; both long runs fell significantly below it. The schedule, +objective and class quotas changed together: this supports a short adaptation budget, not an isolated learning-rate +effect or a universal setting. Five later checkpoints were also scored on this set after the first three (a 660-step +run at 5e-6, a 1,320-step run at 1e-5 and three of the expanded-agent run below); none beat the released drafter +either (-0.013 to -0.085). + +Split agent development data by session or repository, and check transfer on a scaffold and tool format absent from +training. Later turns repeat earlier context, and repository holdout alone does not test a different agent framework. +Keep the independent set out of training and checkpoint ranking, and disclose retrospective selection. If that +framework later enters the training mix, label the result as held-out task/repository transfer instead. + +More framework variety is a hypothesis to test. The later expanded-agent run's [selected checkpoint][am] +(step 823) still did not demonstrate improved transfer: on the same 110 prompts its offline delta was -0.0745 tokens +per round, with a paired 95% group-bootstrap interval of [-0.1758, +0.0197]. Mini-SWE was now represented in training, +and duration and quotas changed too, so this was neither an unseen-framework test nor a data-only ablation. An +interval spanning zero does not establish non-regression. Qualify served speed separately, per class, with unchanged +replies; offline acceptance estimates alone do not establish a speedup. + +[dspine-pilot]: https://github.com/ashhart/TensorFold/issues/2667#issuecomment-6822414789 +[am]: https://huggingface.co/Maxrio/Qwen3.8-27B-DSpine-b16-TF4bit-AgentMix/tree/a494b31c665d66719b9fc963f167e9cd7c8419d1 + ## Check it in TensorFold - **Replies.** Drafted replies equal `"draft": false` ones, greedy and sampled with a seed, solo and concurrent, and a diff --git a/docs/supported-models.md b/docs/supported-models.md index 5210af930da..fb81ddcda14 100644 --- a/docs/supported-models.md +++ b/docs/supported-models.md @@ -38,7 +38,7 @@ Conversions are explicitly marked: their upstream weights need the linked conver | GLM-5.3-Flash, FP4-Local | `tensorfold pull nvidia/GLM-5.3-Flash-FP4-Local@76348ddb2be2e35e39ecfc00e75dc07703f4f3d5` | Two GB10s at TP=2, or three at TP=3 over a ring of direct links: @Bizuayeu loaded it as stored and served it at both sizes. 165.3 GiB of weights, 13% less than NVFP4's. | [Native CUDA](recipes/glm-5.3-flash-cuda.md), in 1.1.5 (#1050). NVIDIA's mixed-precision checkpoint: NVFP4 routed experts, FP8 for most of the rest. As close to BF16 as NVFP4 at its smaller size ([receipt](receipts/glm-fp4local-80517fc3/README.md)). | | GLM-5.3-Flash, XSFP4 | `tensorfold pull Bizuayeu/GLM-5.3-Flash-XSFP4@88736f916f8939607fde8a4b881dcae749f7551d` | Two GB10s at TP=2, or three at TP=3 over a ring of direct links: @Bizuayeu served it at both sizes. 165.7 GiB of weights. | [Native CUDA](recipes/glm-5.3-flash-cuda.md), in 1.1.5 through FP4-Local's path. FP4-Local with its routed experts refitted from the BF16 weights and a smoothing folded in, on the same kernels. Closer to BF16 than FP4-Local and NVFP4 by all three measures in [its card](https://huggingface.co/Bizuayeu/GLM-5.3-Flash-XSFP4#measured). | | GLM-5.3-Flash, Jammed XSFP4 | `tensorfold pull Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4@0a22bb46ecef3d0f5f96e41dc6011be12974fbf1` | Two GB10s at TP=2, or three at TP=3 over a ring of direct links: @Bizuayeu served it at both sizes. 160.2 GiB of weights; at TP=2 each GB10 holds [6.6 GiB less](https://huggingface.co/Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4#memory) than at block 16. | [Native CUDA](recipes/glm-5.3-flash-cuda.md), in 1.2.3 (#2041). Refitted from BF16 at block 32 with XSFP4's smoothing, each row's scales packed (`csf0_v1`, read only by this path), at XSFP4's speed. Its KL and top-1 are nearer BF16 than NVIDIA's two checkpoints', short of XSFP4's ([its card](https://huggingface.co/Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4#measured)). | -| GLM-5.3-Flash, Jammed XSFP4 NZ5 | `tensorfold pull Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4-NZ5@1c900ea0294e28a8e9ab56c1156c0338eed60aef` | Two GB10s at TP=2: @Bizuayeu served it. 160.2 GiB of weights. | [Native CUDA](recipes/glm-5.3-flash-cuda.md), on main after 1.2.7 (#2894). Jammed XSFP4 refitted with E2M1's -0 code read as +5 (`NVFP4_NZ5`, read only by this path). Nearer BF16 than Jammed XSFP4 ([its card](https://huggingface.co/Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4-NZ5#measured)). | +| GLM-5.3-Flash, Jammed XSFP4 NZ5 | `tensorfold pull Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4-NZ5@1c900ea0294e28a8e9ab56c1156c0338eed60aef` | Two GB10s at TP=2: @Bizuayeu served it. 160.2 GiB of weights. | [Native CUDA](recipes/glm-5.3-flash-cuda.md), in 1.2.10 (#2894). Jammed XSFP4 refitted with E2M1's -0 code read as +5 (`NVFP4_NZ5`, read only by this path). Nearer BF16 than Jammed XSFP4 ([its card](https://huggingface.co/Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4-NZ5#measured)). | | GLM-5.3, EXLR8 `home` | `tensorfold pull kindlingai/glm-5.3-exlr8-k2-k3-k4@f459f5d0272a529403dd9b3fd32f771f4250a0d4 --exlr8 home --node 0/2 --dir ~/models/glm-5.3-exlr8-home` | Two M5 Ultra Macs, 256 GB each; about 160 GB resident per Mac at 8k context / four streams. | [Two-Mac recipe](glm-5.3-exlr8.md). Use `--node 1/2` on the other Mac; Thunderbolt 5 and MCDMA required. No CUDA backend. | | LFM2.5-24B-A2B, MLX 4 / 6 / 8-bit | `tensorfold pull LiquidAI/LFM2.5-24B-A2B-MLX-4bit@667408d494bde191c2cb9dd4f4549827816b9275`
`tensorfold pull LiquidAI/LFM2.5-24B-A2B-MLX-6bit@1deec53eb49571e21cdcbf82fd5839248f07ed88`
`tensorfold pull LiquidAI/LFM2.5-24B-A2B-MLX-8bit@67ab417dd02d0c9545802a726df668620eae049d` | One Mac (M4 Pro checked), or one NVIDIA GPU with the 4-bit export (GB10 checked). | [Native recipe](recipes/lfm2.5-24b-a2b.md) ([CUDA](recipes/lfm2.5-24b-a2b.md#cuda)), [release history](../CHANGELOG.md). Weights: LFM Open License v1.0. | | Qwen3.6-35B-A3B, MLX with MTP | `tensorfold pull TensorFold/Qwen3.6-35B-A3B-MLX-4bit-MTP@81169a9bc511a27c1b4eedb77a2cd98ced431847` | One GB10; 20.9 GB checkpoint. | [Qwen3.6](recipes/qwen3.6-moe.md). Native CUDA receipt here. Metal also registers this model type; the recipe's Metal commands describe Python 0.6.6. | diff --git a/docs/web.md b/docs/web.md index 1fc59272c6f..b630c9b9a37 100644 --- a/docs/web.md +++ b/docs/web.md @@ -19,6 +19,8 @@ The application's exit status is retained. With either stdin or stdout redirected, without `uv`, or with `TENSORFOLD_WEB_NO_PROMPT=1`, the launcher prints manual commands and exits 1. It never installs in those cases. A negative or empty answer does the same. +If `uv` is missing, follow [uv's installation guide](https://docs.astral.sh/uv/getting-started/installation/) and +make sure `uv` is on PATH before running the printed `uv tool install` command. An already installed application starts without prompting in all of these cases. Builds without an explicit `-Dversion` never install automatically: their printed command targets the manifest version, which is identified as a manual suggestion rather than the development build's release tag. diff --git a/packaging/README.md b/packaging/README.md index b337ed78813..0b9aafcac4e 100644 --- a/packaging/README.md +++ b/packaging/README.md @@ -1,11 +1,15 @@ # Building native release archives The release owner chooses `MAJOR.MINOR.PATCH`. No new release number is set here. -Use the pinned Zig in `.zig-version`, a Mac with the Xcode macOS SDK, and qualified CUDA fatbins: +Use the pinned Zig in `.zig-version`, a Mac with the Xcode macOS SDK, and qualified CUDA fatbins. +The release build also needs the [pinned XGrammar checkout](../zig/src/platform/grammar_library.zig) with its submodules. ```sh -zig build dist -Dversion=MAJOR.MINOR.PATCH -Ddist-fatbins=/absolute/path/to/fatbins -j2 -zig build dist-smoke -Dversion=MAJOR.MINOR.PATCH -Ddist-fatbins=/absolute/path/to/fatbins -j2 +git clone --branch v0.2.8 --recurse-submodules https://github.com/mlc-ai/xgrammar /absolute/path/to/xgrammar +zig build dist -Dversion=MAJOR.MINOR.PATCH -Ddist-fatbins=/absolute/path/to/fatbins \ + -Dxgrammar=/absolute/path/to/xgrammar -j2 +zig build dist-smoke -Dversion=MAJOR.MINOR.PATCH -Ddist-fatbins=/absolute/path/to/fatbins \ + -Dxgrammar=/absolute/path/to/xgrammar -j2 ``` `dist` builds all three native servers and writes archives and companion SHA-256 files to `zig-out/dist/`. @@ -32,41 +36,18 @@ Python packages or model weights. There is no Python dependency in the packaging ## CUDA box inputs -The CUDA box produces one flat directory, supplied as `-Ddist-fatbins=DIR`, with -`zig build fatbins -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=80,86,120,121`: Ampere (sm_80 and sm_86), RTX 50-series and -RTX PRO Blackwell (sm_120), and GB10 (sm_121). `dist` refuses a file that lacks an image for any of the four. All of -these files are required: - -```text -DIR/ - gdn.fatbin - probe.fatbin - qmm_group.fatbin - qmm_prefill.fatbin - experts.fatbin - experts_prefill.fatbin - experts_pack.fatbin - prefill_attention.fatbin - scan_rows.fatbin - nemotron_ops.fatbin - torch_argmax.fatbin - torch_topk.fatbin - torch_pointwise.fatbin - torch_indexing.fatbin - torch_movement.fatbin - torch_nemotron_constants.fatbin -``` - -Build this input on the CUDA box with the same pinned Zig and qualified nvcc: +Build the release inputs on the CUDA box with the pinned Zig version and a qualified nvcc. ```sh -zig build fatbins -Dtarget=x86_64-linux-gnu -Dnvcc=/path/to/nvcc -Dsm=121 -# Input for the Mac release builder is the resulting zig-out/fatbin/ directory. +zig build fatbins -Dtarget=x86_64-linux-gnu -Dnvcc=/path/to/nvcc -Dsm=80,86,120,121 ``` -`-Dsm` chooses the GPU SASS targets, independently of the Linux host CPU. The existing build defaults to SM121. -Use another list only after qualifying those GPUs. The same fatbins are embedded into the x86_64 and aarch64 -servers; they contain GPU machine code, not host CPU code. Missing input files fail the build. +Pass the complete `zig-out/fatbin/` directory to `-Ddist-fatbins` on the Mac release builder. +The [CUDA kernel catalog](../zig/build/cuda_kernels.zig) lists the required files. `dist` requires each +fatbin to contain SASS for Ampere (sm_80 and sm_86), RTX 50 and RTX PRO Blackwell (sm_120), and GB10 (sm_121). + +For local development, `-Dsm` can select the test GPU, independently of the Linux host CPU. +The same release fatbins are embedded into the x86_64 and aarch64 servers. The release build does not install or download nvcc, create cubins, or run a GPU. The captured Triton set is a separate optional input, supplied as `-Ddist-cuda-aot=DIR`: diff --git a/tools/conformance.py b/tools/conformance.py index d49f94e10cd..7bc6af81d74 100644 --- a/tools/conformance.py +++ b/tools/conformance.py @@ -2,13 +2,17 @@ """Served exactness gates for one family profile: drafted, repeat, concurrent, resumed, refusals, cancel and evict. Each gate prints one PASS or FAIL line with its counts; any FAIL exits 1. Equality is the reply's full token-id hash -(``tensorfold.token_sha256``), so a reply without one is unverified and fails its gate. +(``tensorfold.token_sha256``, reasoning included), so a reply without one, or without a token, is unverified and fails +its gate: two empty replies hash the same. -- drafted: every prompt, greedy and seeded-sampled, equals its ``"draft": false`` reply; at least one draft must be - accepted, or the gate fails as vacuous. -- repeat: the drafted replies again, one at a time, equal the first ones. +- drafted: every prompt, greedy and seeded-sampled, equals its ``"draft": false`` reply; each sampling mode must + accept a draft and the plain replies must draft none, or the gate fails as vacuous. +- repeat: the drafted replies again, one at a time, equal the first ones; a sampled reply under another seed must + differ from its first for some prompt, or the seed never reached the sampler and the gate fails. - concurrent: at each level, that many requests at once (drafted and plain) each equal their solo reply; a long - prompt sent among three decoding streams leaves them unchanged and equals its solo reply. + prompt sent among three decoding streams leaves them unchanged and equals its solo reply. While each batch runs, + ``GET /v1/load`` must show at least two chat requests open at once, or the batch never overlapped and fails; at + each level the drafted rows must accept a draft and the plain rows draft none. - resumed: a multi-turn chat on the cached server equals the same chat on a server with the prompt cache off; the fresh side must report ``cached_tokens == 0`` and every later resumed turn ``cached_tokens > 0``. A profile's ``conversation_context_items`` puts a long document in the first turn, for families that keep only long prompts. @@ -61,6 +65,7 @@ def lifecycle_gaps(profile: dict) -> list[str]: return [g for g in SKIPPABLE if not (isinstance(skip, dict) and skip.get(g)) and not (isinstance(profile.get(g), dict) and profile[g].get(NEEDS[g]))] SHA256 = re.compile(r"[0-9a-f]{64}") +POLL_S = 0.005 # seconds between the census reads that look for overlapping requests def reply_row(status: int, doc) -> dict: @@ -104,8 +109,9 @@ def count(value): def same(a: dict, b: dict): - """True or False when both replies carry a full token hash; None (unverified) otherwise.""" - if a.get("error") or b.get("error") or not a.get("sha") or not b.get("sha"): + """True or False when both replies carry a full token hash and a token; None (unverified) otherwise.""" + if a.get("error") or b.get("error") or not a.get("sha") or not b.get("sha") or not a.get("tokens") \ + or not b.get("tokens"): return None return a["sha"] == b["sha"] @@ -128,17 +134,43 @@ def equality_gate(name: str, pairs, extra_ok=True, extra="") -> dict: return {"gate": name, "passed": passed, "counts": counts, "line": equal_line(counts) + extra} -def drafted_gate(pairs) -> dict: - """drafted == plain over (plain, drafted) pairs; fails as vacuous when no drafted reply accepted a draft.""" - accepted = sum(d.get("accepted", 0) for _, d in pairs) - drafted = sum(d.get("drafted", 0) for _, d in pairs) - gate = equality_gate("drafted == plain", pairs, accepted > 0, f"; {accepted} of {drafted} drafts accepted") - gate["counts"].update(accepted=accepted, drafted=drafted) - if accepted == 0: - gate["line"] += " (vacuous: no draft accepted)" +def drafted_gate(by_mode: dict) -> dict: + """drafted == plain over each mode's (plain, drafted) pairs; vacuous if a mode accepts no draft or plain drafts.""" + pairs = [pair for mode_pairs in by_mode.values() for pair in mode_pairs] + accepted, drafted = sum(d.get("accepted", 0) for _, d in pairs), sum(d.get("drafted", 0) for _, d in pairs) + idle = [mode for mode, mode_pairs in by_mode.items() if not sum(d.get("accepted", 0) for _, d in mode_pairs)] + plain = sum(p.get("drafted", 0) for p, _ in pairs) + extra = f"; {accepted} of {drafted} drafts accepted" + gate = equality_gate("drafted == plain", pairs, not idle and not plain, extra) + gate["counts"].update(accepted=accepted, drafted=drafted, plain_drafted=plain) + if idle: + gate["line"] += f" (vacuous: no draft accepted {'/'.join(idle)})" + if plain: + gate["line"] += f"; the plain replies drafted {plain} tokens (\"draft\": false not honoured)" return gate +def seeded_problem(pairs) -> str | None: + """Why the sampled arm is unproven: each (first, other seed) pair is equal, so the seed never reached sampling.""" + vacuous = pairs and not any(same(a, b) is False for a, b in pairs) + return f"another seed gave the same reply for all {len(pairs)} prompts tried (the seed never reached sampling)" \ + if vacuous else None + + +def batch_drafts_problem(drafts: dict) -> str | None: + """Why drafting under batching is unproven: a level whose drafted rows accept none, or whose plain rows draft.""" + idle = [level for level, (accepted, _) in drafts.items() if not accepted] + plain = {level: drafted for level, (_, drafted) in drafts.items() if drafted} + return f"drafted rows accepted no draft at {idle}; plain rows drafted at {plain}" if idle or plain else None + + +def overlap_problem(peaks) -> str | None: + """Why concurrency is unproven: a batch whose census never showed two chat requests open at once.""" + alone = len([p for p in peaks if not p or p < 2]) + return f"{alone} of {len(peaks)} batches never showed two chat requests open at once in GET /v1/load" \ + if alone else None + + def resumed_gate(turns) -> dict: """resumed == fresh over per-turn (fresh, resumed) pairs, with the cache counts both sides must show.""" counts = tally(turns) @@ -246,6 +278,25 @@ def inventory(items: int) -> str: return "An inventory: " + " ".join(f"crate{i % 89}-{(i * 6151) % 997}" for i in range(items)) +def watched(client: Client, run): + """``run()``'s result and, in a list, the most chat requests ``GET /v1/load`` showed open at once meanwhile.""" + from conformance_lifecycle import census + done, peak = threading.Event(), [None] + + def poll(): + while not done.is_set(): + seen = (census(client) or {}).get("active") + peak[0] = max(peak[0] or 0, seen) if type(seen) is int else peak[0] + done.wait(POLL_S) + thread = threading.Thread(target=poll, daemon=True) + thread.start() + try: + return run(), peak + finally: + done.set() + thread.join(timeout=60) + + def together(client: Client, bodies, delays=None) -> list: """Send every body at once (or after its delay) and return the reply rows in order.""" out = [None] * len(bodies) @@ -286,9 +337,8 @@ def record(self, kind, key, row): return row def drafted(self) -> dict: - pairs = [(self.solo(n, m, False), self.solo(n, m, True)) for n in self.plan.profile["prompts"] - for m in self.plan.modes] - return drafted_gate(pairs) + return drafted_gate({m: [(self.solo(n, m, False), self.solo(n, m, True)) for n in self.plan.profile["prompts"]] + for m in self.plan.modes}) def repeat(self) -> dict: pairs = [] @@ -297,30 +347,52 @@ def repeat(self) -> dict: first = self.solo(n, m, True) again = self.client.post(self.plan.ask(n, m, True, self.plan.plant == "repeat")) pairs.append((first, self.record("repeat", (n, m, True), again))) - return equality_gate("repeat == first", pairs) + problem = seeded_problem(self.other_seeds()) + return equality_gate("repeat == first", pairs, not problem, "; " + (problem or "another seed differs")) + + def other_seeds(self) -> list: + """(first, next seed) pairs of sampled drafted replies, prompt by prompt until one differs.""" + out = [] + for m, mode in self.plan.modes.items(): + for n in self.plan.profile["prompts"] if mode.get("temperature") else []: + body = self.plan.ask(n, m, True, self.plan.plant == "drafted") # the drafted solo's seed + body["seed"] += 1 + out.append((self.solo(n, m, True), self.record("other-seed", (n, m), self.client.post(body)))) + if same(*out[-1]) is False: + break + return out def concurrent(self) -> dict: names, pairs, planted = list(self.plan.profile["prompts"]), [], self.plan.plant == "concurrent" levels = self.plan.profile.get("levels", [1, 2, 4, 8]) + peaks, drafts = [], {} for level in levels: for draft in (True, False): for mode in self.plan.modes: picks = [names[i % len(names)] for i in range(level)] - rows = together(self.client, [self.plan.ask(n, mode, draft, planted) for n in picks]) + bodies = [self.plan.ask(n, mode, draft, planted) for n in picks] + rows, peak = watched(self.client, lambda: together(self.client, bodies)) + peaks += [peak[0]] if level > 1 else [] for n, row in zip(picks, rows): row = self.record(f"concurrent{level}", (n, mode, draft), row) pairs.append((self.solo(n, mode, draft), row)) + drafts.setdefault(level, [0, 0])[not draft] += row.get("accepted" if draft else "drafted") or 0 mixed = 0 for draft in (True, False): for mode in self.plan.modes: picks = names[:3] + ["long"] bodies = [self.plan.ask(n, mode, draft, planted) for n in picks] - rows = together(self.client, bodies, delays=[0, 0, 0, 0.5]) + rows, peak = watched(self.client, lambda: together(self.client, bodies, [0, 0, 0, 0.5])) + peaks.append(peak[0]) mixed += len(rows) for n, row in zip(picks, rows): pairs.append((self.solo(n, mode, draft), self.record("mixed", (n, mode, draft), row))) - return equality_gate("concurrent == solo", pairs, extra=f" (levels {levels}, drafted and plain, " - f"{mixed} with a long prompt among decoders)") + drafts.setdefault("mixed", [0, 0])[not draft] += row.get("accepted" if draft else "drafted") or 0 + self.rows.append({"kind": "overlap", "peaks": peaks}) + problem = "; ".join(filter(None, (overlap_problem(peaks), batch_drafts_problem(drafts)))) + extra = f" (levels {levels}, drafted and plain, {mixed} with a long prompt among decoders); " + return equality_gate("concurrent == solo", pairs, not problem, + extra + (problem or f"chat requests open at once: {min(peaks)} to {max(peaks)}")) def refusals(self) -> dict: results = [] diff --git a/tools/draft_divergence.md b/tools/draft_divergence.md new file mode 100644 index 00000000000..58cd3010db9 --- /dev/null +++ b/tools/draft_divergence.md @@ -0,0 +1,142 @@ +# Exact drafted/plain tokens near BF16 ties + +`draft_divergence.py` selects a small set of token prefixes from recorded greedy +traces, then compares one serial completion with requested draft caps 1, 4 and 8. +Every token ID must match. A `near-tie` label explains a mismatch; it never waives +one. Selection and labels reuse `zig/qwen27_margins.py`'s BF16 spacing rule. + +Run from the repository root. Python's standard library is sufficient. The +`--replay` mode opens no endpoint and needs no model or GPU: + +```sh +python3 tools/draft_divergence.py \ + --recording tools/tests/fixtures/draft_divergence/recording.json \ + --profiles tools/tests/fixtures/draft_divergence/profiles.json \ + --replay tools/tests/fixtures/draft_divergence/equal.json \ + --lookback 2 --tokens 8 --output equal-result.json +``` + +The example prints exactly: + +```text +DRAFT_DIVERGENCE status=pass cases=1 comparisons=3 divergences=0 +``` + +Replacing `equal.json` with `divergent.json` exits 1 and identifies the first +mismatch at output index 2 for requested depth 4. These files are **synthetic unit +fixtures**, not measurements of a checkpoint, backend, GPU or numerical error. + +## Recordings and selection + +A recording has `schema: 1`, an `identity` object of nonempty strings, and `traces`. +Use pinned checkpoint, tokenizer, backend, precision and configuration identifiers +in the identity; every endpoint profile must repeat the same identity exactly. +This is the operator's declaration, not server attestation. + +Each trace has a unique `name`, a nonempty `prompt` of token IDs, generated +`tokens`, and one ordered raw `top2` row per generated token: + +```json +{ + "schema": 1, + "identity": {"checkpoint": "pinned-revision", "tokenizer": "pinned-tokenizer", "backend": "precision-and-config"}, + "traces": [{"name": "example", "prompt": [1, 2], "tokens": [12], + "top2": [{"ids": [12, 99], "logits": [16.0, 15.9375], "position": 2}]}] +} +``` + +`position` is the absolute zero-based generated token position, including the +prompt. Its first entry is `len(prompt)`. The first top-two ID must equal the +recorded greedy token. All logits must be finite raw scores, ordered largest +first. Do not substitute log-softmax values: BF16 spacing depends on absolute +magnitude and is not invariant under that transformation. + +Select positions whose margin is at most one BF16 spacing of the highest raw +logit. Defaults: at most 8 distinct prefixes, up to 8 generated tokens before +the tie, and up to 32 generated tokens per run. Cases are ranked by margin divided +by spacing, then name. Their prompt is the original token prefix, with no text +round trip. Increase `--tokens` above `--lookback`; windows stop at the end of the +recording. No selected positions is an error, not a passing empty test. + +## Served endpoints and draft depths + +The current server accepts `draft: false/true`; it has no per-request depth cap. +Configure one server endpoint per supported cap using that family's actual +configuration. Do not add a fictitious `draft_depth` request field. Each profile +has `depth`, `url`, `model` and the recording's exact `identity`. The fixture +`profiles.json` illustrates this shape but contains placeholder URLs only. + +For a real family run, prepare `recording.json` from that same checkpoint, +tokenizer, backend and configuration, and `profiles.json` from its configured +servers. Run on the hardware selected for the family: + +```sh +python3 tools/draft_divergence.py --recording recording.json \ + --profiles profiles.json --depths 1,4,8 --cases 8 --lookback 8 --tokens 32 \ + --timeout 120 --output divergence-result.json +``` + +For each requested cap, the nearest supplied supported cap is selected; ties +choose the smaller cap. JSON records both numbers. Different configured caps +require distinct URLs. The operator must ensure their configurations differ +only in draft cap and all resolve to the same model. Caps are configuration +metadata; the response does not attest the actual draft length at every round. + +The lowest-cap endpoint also provides the serial reference with `draft: false`. +Requests use `/v1/completions`, token-ID-array prompts, greedy sampling, +`ignore_eos: true`, `return_token_ids: true` and nonstreaming responses. A base URL +may end with `/v1` or `/v1/completions`. Redirects are refused. Authentication is +not implemented; URLs containing credentials or query strings are refused. + +The tool requires `tensorfold.token_ids`, a matching `tensorfold.drafts` boolean, +and consistent completion-token counts. It also requires positive +`speculative.drafted` work for each drafted run. Equality without observed draft +work, an early stop, or failure of the serial run to reproduce the selected +recording window yields `incomplete`, never `pass`. + +## Divergence JSON and logits + +Every case contains serial and drafted IDs and the first mismatch for each cap. +`output_index` is zero-based within the generated window; `absolute_position` +includes the complete prompt. A length mismatch reports a null missing token. +Any mismatch returns `divergent`, even if coverage is also incomplete. + +The current API does not expose raw logits. Its logprobs are not raw logits and +are never used here. JSON retains the source recording's two raw scores and +reports each `recorded_logits_for_tokens` entry only when the first-divergence +history matches that recording and its token is present in the recorded top two. +These are historical scores, not new plain/drafted measurements. Missing scores +are null. +Live results leave `plain_top2` and `drafted_top2` null. + +Offline observations may additionally carry per-run raw captures. Their shape is +`{"response": , "top2": }`. A replay file maps +`CASE:plain` and `CASE:REQUESTED_DEPTH` to these observations; `CASE` is +`TRACE_NAME:SOURCE_GENERATED_INDEX`. The tool's output retains the observations +and can itself be replayed by saving its `observations` object as a replay file. +Each optional capture must align with that run's IDs and absolute positions. +When both captures are supplied, `plain_top2` and `drafted_top2` report both +measured score pairs and the shared helper labels `near-tie` or `bug`. Without +them, `recorded-near-tie` explicitly describes the historical source alone. +Never claim fresh per-run logits from an ordinary live API result. + +Exit codes: 0 strict equality with complete coverage, 1 any divergence, 2 an +incomplete run or malformed input/response. A JSON file and one summary line are +written for completed evaluations and handled errors. Endpoint errors stop the +run and produce `status: error`; rerun that input after resolving the endpoint. + +## Fixture checks + +```sh +python3 -m pytest tools/tests/test_draft_divergence.py +python3 -m pytest tools/tests +``` + +The new fixture tests also run without pytest: + +```sh +python3 -m unittest discover -s tools/tests -p test_draft_divergence.py -v +``` + +Fixture checks exercise request construction with an injected client. They do +not run a device, open a socket, or replace the family's actual hardware check. diff --git a/tools/draft_divergence.py b/tools/draft_divergence.py new file mode 100644 index 00000000000..a041a01db84 --- /dev/null +++ b/tools/draft_divergence.py @@ -0,0 +1,291 @@ +"""Compare exact drafted/plain IDs on token-prefix prompts selected from recorded raw-logit near-ties.""" +from __future__ import annotations + +import argparse +import hashlib +import itertools +import json +import math +from pathlib import Path +import urllib.error +import urllib.parse +import urllib.request + +from zig.qwen27_margins import bf16_spacing, verdict + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def ids(value): + require(isinstance(value, list) and value, "expected nonempty token IDs") + require(all(type(x) is int and 0 <= x < 2**32 for x in value), "invalid token ID") + return value + + +def top2(row, position): + require(isinstance(row, dict), "missing raw top-two record") + tokens, logits = ids(row.get("ids")), row.get("logits") + require(len(tokens) == 2 and tokens[0] != tokens[1], "expected two distinct top-two IDs") + require(isinstance(logits, list) and len(logits) == 2, "expected two raw logits, not logprobs") + require(all(type(x) in (int, float) and math.isfinite(x) for x in logits), "nonfinite raw logit") + require(logits[0] >= logits[1], "top-two logits are not ordered") + require(row.get("position", position) == position, "raw-logit position is not aligned") + return {"ids": tokens, "logits": logits, "position": position} + + +def near(row): + return row["logits"][0] - row["logits"][1] <= bf16_spacing(row["logits"][0]) + + +def select_prompts(recording, limit=8, lookback=8, tokens=32): + require(type(limit) is int and 1 <= limit <= 64, "case limit must be 1..64") + require(type(tokens) is int and 1 <= tokens <= 512, "token limit must be 1..512") + require(type(lookback) is int and 0 <= lookback < tokens, "lookback must be below token limit") + require(isinstance(recording, dict) and type(recording.get("schema")) is int + and recording["schema"] == 1, "recording schema missing") + identity = recording.get("identity") + require(isinstance(identity, dict) and identity + and all(isinstance(k, str) and isinstance(v, str) and v for k, v in identity.items()), "identity missing") + traces = recording.get("traces") + require(isinstance(traces, list) and traces, "no recorded traces") + candidates, names = [], set() + for trace in traces: + require(isinstance(trace, dict), "invalid trace") + name = trace.get("name") + require(isinstance(name, str) and name and name not in names, "trace names must be unique") + names.add(name) + prompt, emitted = ids(trace.get("prompt")), ids(trace.get("tokens")) + rows = trace.get("top2") + require(isinstance(rows, list) and len(rows) == len(emitted), "one raw top-two row per emitted ID required") + rows = [top2(row, len(prompt) + i) for i, row in enumerate(rows)] + require(all(row["ids"][0] == token for row, token in zip(rows, emitted)), "recording must be greedy") + for i, row in enumerate(rows): + if not near(row): + continue + start = max(0, i - lookback) + prefix = prompt + emitted[:start] + count = min(tokens, len(emitted) - start) + candidates.append({"id": f"{name}:{i}", "prompt": prefix, "tokens": emitted[start:start + count], + "top2": rows[start:start + count], "near_tie_offset": i - start, + "source_position": len(prompt) + i, "margin": row["logits"][0] - row["logits"][1], + "bf16_spacing": bf16_spacing(row["logits"][0])}) + candidates.sort(key=lambda c: (c["margin"] / c["bf16_spacing"], c["id"])) + selected, seen = [], set() + for case in candidates: + key = tuple(case["prompt"]) + if key not in seen: + selected.append(case) + seen.add(key) + if len(selected) == limit: + break + require(selected, "no recorded BF16 near-ties selected") + return selected + + +def completion_url(base): + base = base.rstrip("/") + if base.endswith("/v1/completions"): + return base + return base + ("/completions" if base.endswith("/v1") else "/v1/completions") + + +def profiles_for(profiles, identity, depths): + require(isinstance(profiles, list) and profiles, "no configured endpoint profiles") + seen, urls = set(), set() + for p in profiles: + require(isinstance(p, dict), "invalid endpoint profile") + depth = p.get("depth") + require(type(depth) is int and 1 <= depth <= 128 and depth not in seen, "invalid/duplicate configured depth") + require(p.get("identity") == identity, "checkpoint/tokenizer/backend identity mismatch") + require(isinstance(p.get("model"), str) and p["model"], "profile model missing") + require(isinstance(p.get("url"), str), "endpoint URL missing") + u = urllib.parse.urlsplit(p["url"]) + require(u.scheme in ("http", "https") and u.hostname and not u.username and not u.password + and not u.query and not u.fragment, "invalid endpoint URL or URL credentials") + endpoint = completion_url(p["url"]) + require(endpoint not in urls, "different depth caps need separately configured endpoints") + seen.add(depth) + urls.add(endpoint) + require(depths and all(type(d) is int and 1 <= d <= 128 for d in depths), "invalid requested depths") + require(len(set(depths)) == len(depths), "duplicate requested depth") + return [(d, min(profiles, key=lambda p: (abs(p["depth"] - d), p["depth"]))) for d in depths] + + +def request(case, profile, drafted): + return {"model": profile["model"], "prompt": case["prompt"], "max_tokens": len(case["tokens"]), + "temperature": 0, "top_k": 0, "top_p": 1, "min_p": 0, "seed": 1234, + "draft": drafted, "ignore_eos": True, "return_token_ids": True, "stream": False} + + +def observe(observation, body, case): + require(isinstance(observation, dict) and isinstance(observation.get("response"), dict), "response missing") + response = observation["response"] + require("error" not in response and response.get("model") == body["model"], "server error or model mismatch") + choices = response.get("choices") + require(isinstance(choices, list) and len(choices) == 1 and isinstance(choices[0], dict), "expected one completion") + finish = choices[0].get("finish_reason") + require(finish in ("length", "stop"), "incomplete/refused completion") + runtime = response.get("tensorfold", {}) + require(isinstance(runtime, dict), "token runtime missing") + emitted = ids(runtime.get("token_ids")) + require(runtime.get("drafts") is body["draft"], "serial/draft switch not acknowledged") + require(isinstance(response.get("usage"), dict), "usage missing") + usage = response["usage"].get("completion_tokens") + require(type(usage) is int and usage == len(emitted), "ID/usage count mismatch") + require(len(emitted) <= body["max_tokens"], "server exceeded requested length") + speculative = response.get("speculative", {}) + require(isinstance(speculative, dict), "invalid speculative counters") + drafted = speculative.get("drafted") + require(drafted is None or (type(drafted) is int and drafted >= 0), "invalid draft-work counter") + if not body["draft"]: + require(drafted in (None, 0), "serial reference performed draft work") + rows = observation.get("top2") + if rows is not None: + require(isinstance(rows, list) and len(rows) == len(emitted), "captured logits/IDs are not aligned") + rows = [top2(row, len(case["prompt"]) + i) for i, row in enumerate(rows)] + require(all(r["ids"][0] == t for r, t in zip(rows, emitted)), "capture and emitted argmax disagree") + return {"tokens": emitted, "top2": rows, "finish_reason": finish, "drafted": drafted, + "complete": finish == "length" and len(emitted) == body["max_tokens"], + "draft_work_observed": not body["draft"] or (drafted is not None and drafted > 0)} + + +def first_difference(case, plain, drafted): + for i, (wanted, actual) in enumerate(itertools.zip_longest(plain["tokens"], drafted["tokens"])): + if wanted == actual: + continue + recorded = case["top2"][i] if i < len(case["top2"]) else None + same_history = plain["tokens"][:i] == case["tokens"][:i] + scores = dict(zip(recorded["ids"], recorded["logits"])) if recorded and same_history else {} + a = plain["top2"][i] if plain["top2"] and i < len(plain["top2"]) else None + b = drafted["top2"][i] if drafted["top2"] and i < len(drafted["top2"]) else None + label = "divergence" + if a and b and wanted is not None and actual is not None: + label = verdict(a, b, wanted, actual)["verdict"] + elif recorded and same_history and {wanted, actual} == set(recorded["ids"]) and near(recorded): + label = "recorded-near-tie" + return {"output_index": i, "absolute_position": len(case["prompt"]) + i, + "plain_token_id": wanted, "drafted_token_id": actual, "label": label, + "strict_equal": False, "plain_top2": a, "drafted_top2": b, + "recorded_top2": recorded, "recorded_history_matches": same_history, + "recorded_logits_for_tokens": {"plain": scores.get(wanted), "drafted": scores.get(actual)}, + "logit_source": "raw per-run captures when supplied; otherwise recorded source, never API logprobs"} + return None + + +def evaluate(recording, profiles, fetch, depths=(1, 4, 8), limit=8, lookback=8, tokens=32): + cases = select_prompts(recording, limit, lookback, tokens) + selected = profiles_for(profiles, recording["identity"], depths) + plain_profile = min(profiles, key=lambda p: p["depth"]) + results, observations = [], {} + divergent, complete = False, True + for case in cases: + body = request(case, plain_profile, False) + observation = fetch(plain_profile, body, case["id"], "plain") + observations[case["id"] + ":plain"] = observation + plain = observe(observation, body, case) + reproduced = plain["tokens"] == case["tokens"] + complete = complete and plain["complete"] and reproduced + variants = [] + for depth, profile in selected: + body = request(case, profile, True) + observation = fetch(profile, body, case["id"], str(depth)) + observations[case["id"] + ":" + str(depth)] = observation + run = observe(observation, body, case) + difference = first_difference(case, plain, run) + divergent = divergent or difference is not None + complete = complete and run["complete"] and run["draft_work_observed"] + variants.append({"requested_depth": depth, "configured_depth": profile["depth"], + "depth_control": "operator-configured endpoint cap, not per-request API control", + "run": run, "first_divergence": difference, "token_equal": difference is None}) + results.append({"id": case["id"], "prompt": case["prompt"], "source_position": case["source_position"], + "near_tie_offset": case["near_tie_offset"], "recorded_margin": case["margin"], + "bf16_spacing": case["bf16_spacing"], "source_reproduced": reproduced, + "plain": plain, "variants": variants}) + status = "divergent" if divergent else "pass" if complete else "incomplete" + return {"schema": 1, "status": status, "passed": status == "pass", "identity": recording["identity"], + "identity_source": "recording and operator profiles; not server-attested", + "near_tie_policy": "BF16 labels are diagnostics; every token divergence fails", + "cases": results, "observations": observations} + + +class NoRedirect(urllib.request.HTTPRedirectHandler): + def redirect_request(self, req, fp, code, msg, headers, newurl): + raise ValueError("endpoint redirect refused") + + +def live_fetch(timeout): + opener = urllib.request.build_opener(NoRedirect()) + + def fetch(profile, body, case_id, depth): + req = urllib.request.Request(completion_url(profile["url"]), data=json.dumps(body, allow_nan=False).encode(), + headers={"Content-Type": "application/json", "Accept": "application/json"}) + with opener.open(req, timeout=timeout) as response: + data = response.read(16 * 1024 * 1024 + 1) + require(len(data) <= 16 * 1024 * 1024, "response too large") + return {"response": decode(data)} + + return fetch + + +def decode(data): + def reject(value): + raise ValueError("nonfinite JSON number") + return json.loads(data, parse_constant=reject) + + +def load(path): + return decode(Path(path).read_text()) + + +def summary(report): + cases = report.get("cases", []) + comparisons = sum(len(c["variants"]) for c in cases) + differences = sum(v["first_divergence"] is not None for c in cases for v in c["variants"]) + line = f"DRAFT_DIVERGENCE status={report['status']} cases={len(cases)} comparisons={comparisons} divergences={differences}" + first = next(((c, v) for c in cases for v in c["variants"] if v["first_divergence"]), None) + if first: + c, v = first + line += f" first={json.dumps(c['id'])}@{v['first_divergence']['output_index']} depth={v['requested_depth']}" + return line + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--recording", type=Path, required=True) + parser.add_argument("--profiles", type=Path, required=True) + parser.add_argument("--replay", type=Path, help="Offline observations keyed CASE:plain or CASE:requested-depth") + parser.add_argument("--output", type=Path, required=True) + parser.add_argument("--depths", default="1,4,8") + parser.add_argument("--cases", type=int, default=8) + parser.add_argument("--lookback", type=int, default=8) + parser.add_argument("--tokens", type=int, default=32) + parser.add_argument("--timeout", type=float, default=120) + args = parser.parse_args(argv) + try: + require(math.isfinite(args.timeout) and args.timeout > 0, "timeout must be finite and positive") + recording, profiles = load(args.recording), load(args.profiles) + if args.replay: + replay = load(args.replay) + + def fetch(profile, body, case_id, depth): + return replay[case_id + ":" + depth] + else: + fetch = live_fetch(args.timeout) + report = evaluate(recording, profiles, fetch, tuple(int(x) for x in args.depths.split(",")), + args.cases, args.lookback, args.tokens) + report["mode"] = "recorded-replay" if args.replay else "served-endpoint" + report["input_sha256"] = {"recording": hashlib.sha256(args.recording.read_bytes()).hexdigest(), + "profiles": hashlib.sha256(args.profiles.read_bytes()).hexdigest()} + except (ValueError, KeyError, TypeError, AttributeError, IndexError, OverflowError, OSError, + urllib.error.URLError) as error: + report = {"schema": 1, "status": "error", "passed": False, "error": str(error)} + args.output.write_text(json.dumps(report, indent=2, allow_nan=False) + "\n") + print(summary(report)) + return 0 if report["passed"] else 1 if report["status"] == "divergent" else 2 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tools/lfm3/serve_check.py b/tools/lfm3/serve_check.py index feaf54fa02f..e1a1754b11e 100644 --- a/tools/lfm3/serve_check.py +++ b/tools/lfm3/serve_check.py @@ -98,7 +98,7 @@ def request(self, item, draft=False, gate=None): headers={'Content-Type': 'application/json'}) if gate: gate.wait(timeout=30) - evidence, usage, runtime, text = Evidence(), {}, {}, [] + evidence, usage, runtime, speculative, text = Evidence(), {}, {}, {}, [] complete = False try: with urllib.request.urlopen(request, timeout=180) as response: @@ -114,11 +114,14 @@ def request(self, item, draft=False, gate=None): raise RuntimeError(str(event['error'])) usage = event.get('usage') or usage runtime = event.get('tensorfold') or runtime + speculative = event.get('speculative') or speculative for choice in event.get('choices', []): evidence.add(choice) text.append(choice.get('text') or (choice.get('delta') or {}).get('content') or '') result = evidence.finish(usage, runtime, complete) result['text'] = ''.join(text) + result['sampling'] = runtime.get('sampling') + result['accepted'], result['drafted'] = speculative.get('accepted'), speculative.get('drafted') if not complete: result['error'] = 'incomplete_stream' return result @@ -245,6 +248,8 @@ def check(name, passed, evidence=None, skip=False): result = server.request(item) baselines[name] = result check(name + '/fresh_plain', result.get('complete') and bool(result.get('token_sha256')), result) + if item.get('temperature'): # the reply names its sampler: "exact" when sampled, "greedy" otherwise + check(name + '/sampler_ran', result.get('sampling') == 'exact', result) if 'long_prefix' in baselines: check('long_prefix/length_over_256', (baselines['long_prefix'].get('prompt_tokens') or 0) > 256, baselines['long_prefix'].get('prompt_tokens')) @@ -252,9 +257,14 @@ def check(name, passed, evidence=None, skip=False): receipt['logs'].append(server.log.name) receipt['commands'].append(server.command) if not args.cancel_only: + drafts = {'accepted': 0, 'plain_drafted': 0} for name, item in items.items(): for draft in (False, True): result = server.request(item, draft=draft) + if draft: + drafts['accepted'] += result.get('accepted') or 0 + else: + drafts['plain_drafted'] += result.get('drafted') or 0 if name == 'edited_prefix' and not draft: check('edited_prefix/no_stale_prefix_reuse', result.get('cached_tokens') == 0, result) check(name + ('/drafted_equals_fresh' if draft else '/plain_equals_fresh'), @@ -266,6 +276,8 @@ def check(name, passed, evidence=None, skip=False): if name == 'edited_prefix': result = server.request(item) check('edited_prefix/matches_cache_off', token_equal(result, baselines[name]), result) + # drafted == fresh tests drafting only if a draft landed, and plain == fresh only if plain drafted none + check('drafts/exercised', drafts['accepted'] > 0 and drafts['plain_drafted'] == 0, drafts) for level in (1, 2, 4): names = ['code', 'chat'] if not args.sampled else ['code', 'chat', 'sampled_code', 'sampled_chat'] for name in names: diff --git a/tools/replay_request.py b/tools/replay_request.py new file mode 100644 index 00000000000..f8ce92e4bd3 --- /dev/null +++ b/tools/replay_request.py @@ -0,0 +1,282 @@ +"""List, clear or replay requests from a TENSORFOLD_REQUEST_JOURNAL and compare the reply with the journaled one.""" +import argparse +import base64 +import copy +import hashlib +import json +import os +import sys +import time +import urllib.error +import urllib.parse +import urllib.request +from pathlib import Path + +FILES = 4 # the current file and three rotated ones, as request_journal.zig keeps them +QUARANTINE_S = 24 * 60 * 60 # a quarantine lapses a day after its crash + + +class ReplayError(ValueError): + pass + + +def journal_files(path): + """The kept files oldest first: path.3, path.2, path.1, then path itself.""" + path = Path(path) + older = [Path(f'{path}.{n}') for n in range(FILES - 1, 0, -1)] + return [p for p in older if p.exists()] + [path] + + +def read_journal(path, now=None): + """Each request's records by id, read as the server reads them; unreadable lines are passed over.""" + entries, pending, crashes, skipped = {}, set(), {}, 0 + now = time.time() if now is None else now + for file in journal_files(path): + for line in file.read_bytes().split(b'\n')[:-1]: # the last piece is empty or a torn line + try: + record = json.loads(line) + except ValueError: + record = None + if not isinstance(record, dict) or record.get('version') != 1: + skipped += 1 + continue + kind, request_id = record.get('kind'), record.get('id') + if kind == 'stop': + pending.clear() + elif kind == 'clear' and record.get('all'): + crashes.clear() + elif kind == 'clear': + crashes.pop(record.get('fingerprint'), None) + elif kind == 'start': + entries[request_id] = {'start': record, 'prepared': None, 'finish': None, 'quarantine': []} + pending.add(request_id) + elif kind == 'quarantine' and record.get('at', 0) + QUARANTINE_S > now: + crashes[record.get('fingerprint')] = crashes.get(record.get('fingerprint'), 0) + 1 + if request_id not in entries or kind not in ('prepared', 'finish', 'quarantine'): + continue + entry = entries[request_id] + if kind == 'prepared': + entry['prepared'] = record # the last one made the reply (a compacted request has several) + continue + if kind == 'finish': + entry['finish'] = record + else: + entry['quarantine'].append(record) + pending.discard(request_id) + for entry in entries.values(): + entry['refused'] = crashes.get(entry['start'].get('fingerprint'), 0) >= 2 # in flight at two crashes + entry['in_flight'] = entry['start']['id'] in pending + return entries, skipped + + +def output_of(raw, stream): + """What the model produced, without what differs between two runs of one request (ids, times, cache hits).""" + def merge(into, delta): + for key, value in delta.items(): + if key in ('id', 'role'): + continue + if key == 'tool_calls': + calls = into.setdefault('tool_calls', {}) + for call in value: + merge(calls.setdefault(str(call.get('index', len(calls))), {}), call) + elif isinstance(value, str) and isinstance(into.get(key), str): + into[key] += value + elif isinstance(value, list) and isinstance(into.get(key), list): + into[key].extend(copy.deepcopy(value)) + elif isinstance(value, dict) and isinstance(into.get(key), dict): + merge(into[key], value) + elif value is not None or key not in into: + into[key] = copy.deepcopy(value) + + def tail(payload, out): + usage = payload.get('usage') or {} + for key in ('prompt_tokens', 'completion_tokens'): + if key in usage: + out[key] = usage[key] + for key in ('stop_sequence', 'error'): + if key in payload: + out[key] = payload[key] + runtime = payload.get('tensorfold') + if isinstance(runtime, dict) and 'token_sha256' in runtime: + out['token_sha256'] = runtime['token_sha256'] + + out, choices = {}, {} + payloads = [json.loads(line[6:]) for line in raw.split(b'\n') if line.startswith(b'data: ') and line != b'data: [DONE]'] if stream else [json.loads(raw)] + for payload in payloads: + for choice in payload.get('choices') or []: + body = {k: v for k, v in choice.items() if k not in ('delta', 'message', 'index')} + body.update(choice.get('delta') or choice.get('message') or {}) + merge(choices.setdefault(str(choice.get('index', 0)), {}), body) + tail(payload, out) + out['choices'] = choices + return json.dumps(out, ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode() + + +def redacted(value): + if value == '': + return True + if isinstance(value, dict): + return any(redacted(v) for v in value.values()) + if isinstance(value, list): + return any(redacted(v) for v in value) + return False + + +def request_body(entry, replacement=None): + """The journaled body, or its restored copy, with the seed the server drew when the client sent none.""" + body = copy.deepcopy(replacement if replacement is not None else entry['start'].get('body')) + if body is None: + raise ReplayError('the body was too large to journal; supply it with --body FILE') + if not isinstance(body, dict): + raise ReplayError('the request body must be a JSON object') + if redacted(body): + raise ReplayError('the request has redacted media; supply the original with --body FILE') + prepared = entry['prepared'] + if 'seed' not in body and prepared and prepared.get('seed') is not None: + body['seed'] = prepared['seed'] + return body + + +def reference(entry): + finish = entry['finish'] + if finish is None: + return None + raw = finish.get('reply_base64') + return base64.b64decode(raw, validate=True) if raw is not None else None + + +def http_send(url, body, key=None): + headers = {'Content-Type': 'application/json'} + if key: + headers['Authorization'] = 'Bearer ' + key + request = urllib.request.Request(url, data=json.dumps(body).encode(), headers=headers, method='POST') + try: + with urllib.request.urlopen(request, timeout=900) as response: + return response.status, response.read() + except urllib.error.HTTPError as error: + return error.code, error.read() + + +def replay(entry, base, send, *, replacement=None, whole_body=False, allow_quarantined=False): + """One send of the request; equal is True, False, or None when the journal holds no reply to compare.""" + request_id = entry['start']['id'] + if entry['quarantine'] and not allow_quarantined: + raise ReplayError(f'{request_id} was in flight at a crash; pass --allow-quarantined to send it on purpose') + path = entry['start'].get('path') + if path not in ('/v1/chat/completions', '/v1/completions'): + raise ReplayError('the journal names a route replay does not send') + parsed = urllib.parse.urlsplit(base) + if parsed.scheme not in ('http', 'https') or not parsed.netloc or parsed.username or parsed.password or parsed.query or parsed.fragment or parsed.path not in ('', '/'): + raise ReplayError('--base must be an http(s) origin with no credentials, path or query') + body = request_body(entry, replacement) + status, actual = send(base.rstrip('/') + path, body) + finish, expected = entry['finish'], reference(entry) + result = {'id': request_id, 'actual_status': status, 'actual_bytes': len(actual), 'actual_sha256': hashlib.sha256(actual).hexdigest()} + if finish is None: + return dict(result, comparison='no_reference', equal=None), actual + result.update(expected_status=finish.get('status'), expected_bytes=finish.get('reply_bytes'), expected_sha256=finish.get('reply_sha256')) + stream = bool(finish.get('stream')) + if whole_body: + result['comparison'] = 'whole_body' + if expected is None: + result.update(equal=status == finish.get('status') and result['actual_sha256'] == finish.get('reply_sha256'), first_difference=None) + return result, actual + left, right = expected, actual + elif expected is None: + try: + tokens = json.loads(output_of(actual, stream)).get('token_sha256') + except ValueError: + tokens = None + result.update(comparison='tokens', equal=status == finish.get('status') and tokens is not None and tokens == finish.get('token_sha256'), first_difference=None) + return result, actual + else: + result['comparison'] = 'output' + try: + left, right = output_of(expected, stream), output_of(actual, stream) + except ValueError: + left, right = expected, actual + different = next((i for i, (x, y) in enumerate(zip(left, right)) if x != y), None) + if different is None and len(left) != len(right): + different = min(len(left), len(right)) + result.update(equal=status == finish.get('status') and left == right, first_difference=different, compared_bytes=[len(left), len(right)]) + return result, actual + + +def locked(path): + """True when a server holds the journal's lock; the lock is released when this process exits.""" + fd = os.open(f'{path}.lock', os.O_RDWR | getattr(os, 'O_NOFOLLOW', 0)) + try: + if os.name == 'nt': + import msvcrt + msvcrt.locking(fd, msvcrt.LK_NBLCK, 1) + else: + import fcntl + fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + except OSError: + os.close(fd) + return True + return False + + +def clear(path, target, entries): + """Appends a clear record while no server holds the journal; the next start serves those requests again.""" + if locked(path): + raise ReplayError('a server holds this journal; stop it, clear, then start it again') + record = {'version': 1, 'kind': 'clear', 'at': int(time.time())} + if target == 'all': + record['all'] = True + else: + entry = entries.get(target) + record['fingerprint'] = entry['start']['fingerprint'] if entry else target + if len(record['fingerprint']) != 64: + raise ReplayError('name a journaled request id, a 64-character fingerprint, or all') + fd = os.open(path, os.O_WRONLY | os.O_APPEND | getattr(os, 'O_NOFOLLOW', 0)) + try: + os.write(fd, (json.dumps(record, separators=(',', ':')) + '\n').encode()) + finally: + os.close(fd) + return record + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('journal') + parser.add_argument('--list', action='store_true', help='list the journaled requests; nothing is sent') + parser.add_argument('--clear', metavar='ID|FINGERPRINT|all', help='lift a quarantine (stop the server first)') + parser.add_argument('--id', help='the request to replay') + parser.add_argument('--base', help='the server origin, such as http://127.0.0.1:8080') + parser.add_argument('--body', help='the original request JSON, when its media were redacted or it was too large') + parser.add_argument('--key-env', default='TENSORFOLD_API_KEY', help='the variable that holds the API key') + parser.add_argument('--whole-body', action='store_true', help='compare every reply byte, ids and timings included') + parser.add_argument('--allow-quarantined', action='store_true', help='send a request that was in flight at a crash') + parser.add_argument('--output', help='write the reply bytes to this file (owner-only)') + args = parser.parse_args(argv) + entries, skipped = read_journal(args.journal) + if skipped: + print(f'{skipped} unreadable record(s) passed over', file=sys.stderr) + if args.list: + rows = [{'id': key, 'at': e['start'].get('at'), 'path': e['start'].get('path'), 'fingerprint': e['start'].get('fingerprint'), + 'outcome': e['finish'].get('outcome') if e['finish'] else 'in_flight' if e['in_flight'] else 'unfinished', + 'crashes': len(e['quarantine']), 'refused': e['refused']} for key, e in entries.items()] + print(json.dumps(rows, indent=2)) + return 0 + if args.clear: + print(json.dumps(clear(args.journal, args.clear, entries))) + return 0 + if not args.id or not args.base or args.id not in entries: + parser.error('name a journaled --id and a --base, or use --list or --clear') + replacement = json.loads(Path(args.body).read_text()) if args.body else None + result, actual = replay(entries[args.id], args.base, lambda url, body: http_send(url, body, os.environ.get(args.key_env)), replacement=replacement, whole_body=args.whole_body, allow_quarantined=args.allow_quarantined) + if args.output: + fd = os.open(args.output, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) + with os.fdopen(fd, 'wb') as out: + out.write(actual) + print(json.dumps(result, indent=2)) + return 2 if result['equal'] is None else 0 if result['equal'] else 1 + + +if __name__ == '__main__': + try: + raise SystemExit(main()) + except (ReplayError, OSError, ValueError) as error: + raise SystemExit(f'replay_request: {error}') diff --git a/tools/test_replay_request.py b/tools/test_replay_request.py new file mode 100644 index 00000000000..3aedfa00fc5 --- /dev/null +++ b/tools/test_replay_request.py @@ -0,0 +1,181 @@ +"""replay_request.py on journal fixtures; every send goes to a fake server, and no socket is opened.""" +import base64 +import contextlib +import hashlib +import importlib.util +import io +import json +import os +import tempfile +import time +import unittest +from pathlib import Path +from unittest.mock import patch + +spec = importlib.util.spec_from_file_location('replay_request', Path(__file__).with_name('replay_request.py')) +r = importlib.util.module_from_spec(spec) +spec.loader.exec_module(r) + +FP = 'ab' * 32 +TOKENS = 'c0' * 32 + + +def whole(content, reply_id='chatcmpl-1', created=1, tokens=TOKENS, seconds=0.5): + return json.dumps({'id': reply_id, 'object': 'chat.completion', 'created': created, 'model': 'm', + 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': content}, 'finish_reason': 'stop'}], + 'usage': {'prompt_tokens': 3, 'completion_tokens': 2, 'prompt_tokens_details': {'cached_tokens': 0}}, + 'tensorfold': {'token_sha256': tokens, 'seconds': seconds}}).encode() + + +def streamed(pieces, reply_id='chatcmpl-1', keepalive=False): + frames = [{'id': reply_id, 'choices': [{'index': 0, 'delta': {'role': 'assistant'}, 'finish_reason': None}]}] + frames += [{'id': reply_id, 'choices': [{'index': 0, 'delta': {'content': p}, 'finish_reason': None}]} for p in pieces] + frames.append({'id': reply_id, 'choices': [{'index': 0, 'delta': {}, 'finish_reason': 'stop'}], 'tensorfold': {'token_sha256': TOKENS}}) + out = b''.join(b'data: ' + json.dumps(f).encode() + b'\n\n' for f in frames) + return (b': keepalive\n\n' if keepalive else b'') + out + b'data: [DONE]\n\n' + + +class FakeServer: + def __init__(self, reply, status=200): + self.reply, self.status, self.calls = reply, status, [] + + def send(self, url, body): + self.calls.append((url, body)) + return self.status, self.reply + + +class ReplayTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.addCleanup(self.tmp.cleanup) + self.path = Path(self.tmp.name) / 'requests.jsonl' + + def write(self, records, path=None): + (path or self.path).write_text(''.join(json.dumps(dict(version=1, **x)) + '\n' for x in records)) + + def journal(self, reply=whole('ok'), stream=False, body=None, seed=42, kept=True): + start = {'kind': 'start', 'id': 'r', 'at': int(time.time()), 'path': '/v1/chat/completions', 'fingerprint': FP, 'seed': None, + 'body': {'messages': [{'role': 'user', 'content': 'hi'}], 'temperature': 1} if body is None else body} + finish = {'kind': 'finish', 'id': 'r', 'status': 200, 'stream': stream, 'outcome': 'completed', 'reply_bytes': len(reply), + 'reply_sha256': hashlib.sha256(reply).hexdigest(), 'token_sha256': TOKENS} + if kept: + finish['reply_base64'] = base64.b64encode(reply).decode() + self.write([start, {'kind': 'prepared', 'id': 'r', 'seed': seed}, finish]) + return r.read_journal(self.path)[0]['r'] + + def test_the_drawn_seed_is_sent_and_equal_output_passes_despite_new_ids_and_timings(self): + server = FakeServer(whole('ok', reply_id='chatcmpl-2', created=2, seconds=0.9)) + result, _ = r.replay(self.journal(), 'http://example.test', server.send) + self.assertTrue(result['equal']) + self.assertEqual(result['comparison'], 'output') + self.assertEqual(server.calls[0][0], 'http://example.test/v1/chat/completions') + self.assertEqual(server.calls[0][1]['seed'], 42) + own = self.journal(body={'messages': [], 'seed': 7}) + server = FakeServer(whole('ok')) + r.replay(own, 'http://example.test', server.send) + self.assertEqual(server.calls[0][1]['seed'], 7) # the client's own seed is never replaced + + def test_different_text_or_tokens_are_a_reported_mismatch(self): + result, _ = r.replay(self.journal(), 'http://example.test', FakeServer(whole('oK')).send) + self.assertFalse(result['equal']) + self.assertIsNotNone(result['first_difference']) + result, _ = r.replay(self.journal(), 'http://example.test', FakeServer(whole('ok', tokens='d1' * 32)).send) + self.assertFalse(result['equal']) + self.assertFalse(r.replay(self.journal(), 'http://example.test', FakeServer(whole('ok'), 500).send)[0]['equal']) + + def test_whole_body_compares_every_byte(self): + entry = self.journal() + self.assertTrue(r.replay(entry, 'http://example.test', FakeServer(whole('ok')).send, whole_body=True)[0]['equal']) + result, _ = r.replay(entry, 'http://example.test', FakeServer(whole('ok', reply_id='chatcmpl-2')).send, whole_body=True) + self.assertFalse(result['equal']) + self.assertEqual(result['comparison'], 'whole_body') + + def test_a_stream_compares_its_output_whatever_its_frames_and_keepalives(self): + entry = self.journal(streamed(['o', 'k']), stream=True) + self.assertTrue(r.replay(entry, 'http://example.test', FakeServer(streamed(['ok'], 'chatcmpl-9', True)).send)[0]['equal']) + self.assertFalse(r.replay(entry, 'http://example.test', FakeServer(streamed(['o', 'h'])).send)[0]['equal']) + self.assertFalse(r.replay(entry, 'http://example.test', FakeServer(streamed(['ok'], keepalive=True)).send, whole_body=True)[0]['equal']) + + def test_a_reply_too_large_to_keep_is_compared_by_its_token_hash(self): + entry = self.journal(kept=False) + result, _ = r.replay(entry, 'http://example.test', FakeServer(whole('anything')).send) + self.assertEqual(result['comparison'], 'tokens') + self.assertTrue(result['equal']) + self.assertFalse(r.replay(entry, 'http://example.test', FakeServer(whole('ok', tokens='d1' * 32)).send)[0]['equal']) + + def test_redacted_media_and_an_omitted_body_need_the_original_before_any_send(self): + for body in ({'messages': [{'content': [{'type': 'image_url', 'image_url': {'url': ''}}]}]}, None): + server = FakeServer(whole('ok')) + entry = self.journal(body=body if body else {}) + if body is None: + entry['start'].pop('body') + with self.assertRaises(r.ReplayError): + r.replay(entry, 'http://example.test', server.send) + self.assertEqual(server.calls, []) + self.assertTrue(r.replay(entry, 'http://example.test', server.send, replacement={'messages': []})[0]['equal']) + + def test_a_crashed_request_is_sent_only_on_purpose_and_has_no_reference(self): + crash = {'kind': 'quarantine', 'id': 'r', 'fingerprint': FP, 'at': int(time.time())} + self.write([{'kind': 'start', 'id': 'r', 'path': '/v1/chat/completions', 'fingerprint': FP, 'body': {'messages': []}}, crash, crash]) + entry = r.read_journal(self.path)[0]['r'] + self.assertTrue(entry['refused']) + server = FakeServer(b'{}') + with self.assertRaises(r.ReplayError): + r.replay(entry, 'http://example.test', server.send) + self.assertEqual(server.calls, []) + result, _ = r.replay(entry, 'http://example.test', server.send, allow_quarantined=True) + self.assertIsNone(result['equal']) + self.assertEqual(result['comparison'], 'no_reference') + + def test_rotated_files_are_read_oldest_first_and_torn_or_bad_lines_passed_over(self): + self.write([{'kind': 'start', 'id': 'r', 'path': '/v1/completions', 'fingerprint': FP, 'body': {}}], Path(f'{self.path}.2')) + self.path.write_bytes(b'bad\n' + json.dumps({'version': 1, 'kind': 'finish', 'id': 'r', 'status': 200}).encode() + b'\n{"kind":') + entries, skipped = r.read_journal(self.path) + self.assertEqual(skipped, 1) + self.assertEqual(entries['r']['finish']['status'], 200) + self.assertFalse(entries['r']['in_flight']) + + def test_two_recent_crashes_refuse_and_a_lapsed_one_or_a_clear_does_not(self): + old = int(time.time()) - r.QUARANTINE_S - 1 + start = {'kind': 'start', 'id': 'r', 'path': '/v1/completions', 'fingerprint': FP, 'body': {}} + lapsed, recent = ({'kind': 'quarantine', 'id': 'r', 'fingerprint': FP, 'at': at} for at in (old, int(time.time()))) + self.write([start, lapsed, recent]) + self.assertFalse(r.read_journal(self.path)[0]['r']['refused']) + self.write([start, recent, recent]) + self.assertTrue(r.read_journal(self.path)[0]['r']['refused']) + self.write([start, recent, recent, {'kind': 'clear', 'fingerprint': FP}]) + self.assertFalse(r.read_journal(self.path)[0]['r']['refused']) + + def test_route_and_origin_are_checked_before_any_send(self): + entry, server = self.journal(), FakeServer(b'{}') + for base in ('file:///tmp/a', 'http://name:secret@example.test', 'http://example.test/v1', 'http://example.test/?a=1'): + with self.assertRaises(r.ReplayError): + r.replay(entry, base, server.send) + entry['start']['path'] = '/admin' + with self.assertRaises(r.ReplayError): + r.replay(entry, 'http://example.test', server.send) + self.assertEqual(server.calls, []) + + @unittest.skipIf(os.name == 'nt', 'the lock is flock here; Windows locks a byte') + def test_cli_list_never_sends_a_mismatch_exits_one_and_clear_waits_for_the_server_to_stop(self): + import fcntl + self.journal() + quiet = contextlib.redirect_stdout(io.StringIO()) + with patch.object(r, 'http_send', side_effect=AssertionError('no send')), quiet: + self.assertEqual(r.main([str(self.path), '--list']), 0) + with patch.object(r, 'http_send', return_value=(200, whole('no'))), quiet: + self.assertEqual(r.main([str(self.path), '--id', 'r', '--base', 'http://example.test']), 1) + lock = os.open(f'{self.path}.lock', os.O_RDWR | os.O_CREAT, 0o600) + self.addCleanup(os.close, lock) + fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) # as a running server holds it + with self.assertRaises(r.ReplayError): + r.clear(self.path, 'r', r.read_journal(self.path)[0]) + fcntl.flock(lock, fcntl.LOCK_UN) + with quiet: + self.assertEqual(r.main([str(self.path), '--clear', 'r']), 0) + last = json.loads(self.path.read_text().splitlines()[-1]) + self.assertEqual((last['kind'], last['fingerprint']), ('clear', FP)) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/tests/fake_served_api.py b/tools/tests/fake_served_api.py index 619091c1bcd..19fc1b64267 100644 --- a/tools/tests/fake_served_api.py +++ b/tools/tests/fake_served_api.py @@ -12,12 +12,26 @@ - cancel_reply: the request a client left answers differently the next time it arrives. - cancel_health: a server a client left answers ``/health`` with an error. - evict: a chat turn pushed out of the prompt cache reports it (0 cached) but answers from the stale state. +- undrafted: no request drafts, so a drafted reply runs the plain path. +- plain_drafts: a ``"draft": false`` request drafts anyway, so both arms run the same drafted path. +- sampled_drafts: a sampled request drafts nothing, so drafting is exercised only greedy. +- unsampled: temperature and seed never reach the sampler; a sampled request gets the greedy reply. +- serial: the server takes one request at a time, so requests sent together never overlap in it. +- empty: every reply is empty (no tokens), so every pair of replies hashes the same. ``running(..., warm=S)`` keeps the server busy (one running, more waiting) for ``S`` seconds after each reply, as a server that prefills the chat's next turn in the background; ``lanes_free=False`` leaves ``capacity.lanes_free`` out of ``GET /v1/load``, as a server without lanes. -The cached server reports five cached tokens for a later chat turn (more than one message). It keeps the prompts it +A request is counted in ``GET /v1/load``'s running and active chat requests while open. One that finds another in +flight within ``PARTNER_WINDOW`` stays open ``HOLD`` seconds more; a request alone leaves after the window. While a +client polls the census (two reads within ``WATCHED`` seconds, the last that recent), a request waits +``WATCHED_WINDOW`` for a partner, as threads sent together can start a scheduler tick apart (about 16 ms on Windows), +and a pair stays open until a census counts two open at once (at most ``COUNTED`` seconds), so however slow a census +read is, one taken meanwhile sees them. + +The cached server reports five cached tokens for a later chat turn (more than one message), and for a one-message +prompt it answered before. It keeps the prompts it answered in an LRU of ``CAPACITY`` entries; a prompt pushed out reports 0 until it is asked again. ``GET /v1/load``, ``/metrics`` and ``/health`` show the lanes open streams hold, the disconnects counted and the server's health. @@ -42,20 +56,26 @@ import time FAULTS = ("drafted", "repeat", "concurrent", "resumed", "refusals", "cancel_lane", "cancel_free", "cancel_reply", - "cancel_health", "evict") + "cancel_health", "evict", "undrafted", "plain_drafts", "sampled_drafts", "unsampled", "serial", "empty") BATCH_WINDOW = 0.15 # seconds a lone request waits for a partner under the concurrent fault DONE = b"data: [DONE]\n\n" HASHES = {"token_sha": "d" * 12, "token_sha256": "d" * 64} CAPACITY = 4 # prompt cache entries the cached server keeps LANES = 8 TOKEN_GAP = 0.0002 # seconds between streamed events +PARTNER_WINDOW = 0.01 # seconds a request waits for another to share the server with +HOLD = 0.025 # seconds a request that shares the server stays open, when no census is being read +WATCHED_WINDOW = 0.06 # seconds a request waits for a partner while a census is read +WATCHED = 0.1 # a census read this recent, after one this close before it, is a client polling +COUNTED = 0.5 # most seconds a pair waits for a census to count it, while watched -def doc(sha="a" * 64, cached=0, accepted=2, drafted=3, text="hi"): +def doc(sha="a" * 64, cached=0, accepted=2, drafted=3, text="hi", tokens=4, sampling="greedy", prompt=9): """A chat completion body carrying the fields the kit reads.""" - return {"choices": [{"message": {"content": text}}], "tensorfold": {"token_sha256": sha}, - "speculative": {"accepted": accepted, "drafted": drafted}, - "usage": {"prompt_tokens": 9, "completion_tokens": 4, "prompt_tokens_details": {"cached_tokens": cached}}} + return {"choices": [{"message": {"content": text}}], "tensorfold": {"token_sha256": sha, "sampling": sampling}, + "speculative": {"rounds": int(drafted > 0), "accepted": accepted, "drafted": drafted}, + "usage": {"prompt_tokens": prompt, "completion_tokens": tokens, + "prompt_tokens_details": {"cached_tokens": cached}}} def refusal(body, fault=None): @@ -71,8 +91,13 @@ def refusal(body, fault=None): return None +def messages_of(body) -> list: + """A chat request's messages; a completion request's prompt as one user message.""" + return body.get("messages") or [{"role": "user", "content": body.get("prompt", "")}] + + def text_of(body) -> str: - return " ".join(m.get("content", "") for m in body.get("messages", [])) + return " ".join(m.get("content", "") for m in messages_of(body)) def event(chunk: dict) -> bytes: @@ -130,6 +155,10 @@ def script(tokens: list[tuple], sizes: list[int], *, finish: str | None = "stop" return steps + ([DONE] if done else []) +class FixtureHTTPServer(http.server.ThreadingHTTPServer): + request_queue_size = 128 # Allow the full concurrent batch to connect while handler threads start. + + class FakeEngine(http.server.BaseHTTPRequestHandler): """The reply hash depends on the messages and, when sampling, the seed; never on draft, cache, batch or stream.""" @@ -140,7 +169,11 @@ def do_GET(self): server = self.server if self.path == "/v1/load": with server.lock: - busy, warming = server.streams + server.leaked, time.monotonic() < server.warm_until + busy, warming = server.streams + server.leaked + server.inflight, time.monotonic() < server.warm_until + server.census_gap, server.census_at = time.monotonic() - server.census_at, time.monotonic() + if busy > 1: + server.overlaps += 1 + server.cond.notify_all() capacity = {"mode": "window", "lanes_free": LANES - busy - server.lost} if server.lanes_free else {} return self.reply(200, {"lanes": LANES, "running": busy + warming, "waiting": 19 * warming, "http_active": {"chat_completions": busy}, "capacity": capacity}) @@ -160,6 +193,20 @@ def do_POST(self): if error: return self.reply(400, {"error": {"message": error, "type": "invalid_request_error"}}) key = json.dumps({k: v for k, v in body.items() if k not in ("stream", "stream_options")}, sort_keys=True) + with server.one if server.fault == "serial" else contextlib.nullcontext(): + payload = self.answer(body, key) + # Out of flight before the reply is written: the client's next request must not find this one counted. + if body.get("stream"): + self.play(streamed(payload, body.get("max_tokens", 16), TOKEN_GAP), key) + else: + self.reply(200, payload) + with server.lock: + server.warm_until = time.monotonic() + server.warm + time.sleep(server.linger) + + def answer(self, body, key) -> dict: + """The reply's body, computed while the request is counted in flight.""" + server, messages = self.server, messages_of(body) with server.lock: server.seen[key] = server.seen.get(key, 0) + 1 arrival = server.seen[key] @@ -167,34 +214,38 @@ def do_POST(self): after_cut = key in server.cut server.cut.discard(key) try: - batched = self.batched() if server.fault == "concurrent" else False - seed = body["seed"] if body.get("temperature") else None - cached, stale = self.lookup(body["messages"]) + watched = time.monotonic() - server.census_at < WATCHED and server.census_gap < WATCHED # a poller + window = WATCHED_WINDOW if watched else PARTNER_WINDOW + batched = self.batched(BATCH_WINDOW if server.fault == "concurrent" else window) + if batched: + self.counted() if watched else time.sleep(HOLD) + sampled = bool(body.get("temperature")) and server.fault != "unsampled" + cached, stale = self.lookup(messages) salt = "stale" if stale else "after a cut" if after_cut and server.fault == "cancel_reply" else None - salt = salt or self.salt(body, arrival, batched) - sha = hashlib.sha256(json.dumps([body["messages"], seed, salt]).encode()).hexdigest() - self.keep(body["messages"]) - accepted = 2 if body.get("draft", True) else 0 - payload = doc(sha=sha, cached=cached, accepted=accepted, drafted=accepted, text="r" + sha[:6]) + salt = salt or self.salt(body, arrival, batched and server.fault == "concurrent") + seed = body.get("seed") if sampled else None + sha = hashlib.sha256(json.dumps([messages, seed, salt]).encode()).hexdigest() + self.keep(messages) + drafts = (body.get("draft", True) or server.fault == "plain_drafts") and server.fault != "undrafted" + accepted = 2 if drafts and not (sampled and server.fault == "sampled_drafts") else 0 + if server.fault == "empty": + return doc(sha=hashlib.sha256(b"").hexdigest(), cached=cached, accepted=accepted, drafted=accepted, + text="", tokens=0) + return doc(sha=sha, cached=cached, accepted=accepted, drafted=accepted, text="r" + sha[:6], + sampling="exact" if sampled else "greedy", prompt=max(9, len(text_of(body)) // 4)) finally: with server.lock: server.inflight -= 1 - # Out of flight before the reply is written: the client's next request must not find this one still counted. - if body.get("stream"): - self.play(streamed(payload, body.get("max_tokens", 16), TOKEN_GAP), key) - else: - self.reply(200, payload) - with server.lock: - server.warm_until = time.monotonic() + server.warm - time.sleep(server.linger) def lookup(self, messages): """Cached tokens for the prompt, and whether the evict fault answers from an evicted prompt.""" server = self.server - if not server.cache or len(messages) < 2: + if not server.cache: return 0, False with server.lock: whole = json.dumps(messages) + if len(messages) < 2: + return (5 if whole in server.kept else 0), False if whole in server.evicted: return 0, server.fault == "evict" return (0 if server.fault == "resumed" and whole not in server.kept else 5), False @@ -212,12 +263,19 @@ def keep(self, messages): while len(server.kept) > CAPACITY: server.evicted.add(server.kept.popitem(last=False)[0]) - def batched(self) -> bool: - """True when another request shares the server with this one within the batch window.""" + def batched(self, window: float) -> bool: + """True when another request shares the server with this one within ``window`` seconds.""" server = self.server with server.cond: server.cond.notify_all() - return server.cond.wait_for(lambda: server.inflight > 1, timeout=BATCH_WINDOW) + return server.cond.wait_for(lambda: server.inflight > 1, timeout=window) + + def counted(self): + """Wait, at most ``COUNTED`` seconds, for a ``GET /v1/load`` that counts two chat requests open at once.""" + server = self.server + with server.cond: + mark = server.overlaps + server.cond.wait_for(lambda: server.overlaps > mark, timeout=COUNTED) def salt(self, body, arrival, batched): """A planted fault changes the reply by adding a salt to its hash; None leaves it correct.""" @@ -268,12 +326,13 @@ def play(self, steps, key=None): @contextlib.contextmanager def running(cache=False, fault=None, linger=0.0, steps=None, warm=0.0, lanes_free=True): """One fake on 127.0.0.1 port 0, yielding its base URL; stopped on exit.""" - server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), FakeEngine) + server = FixtureHTTPServer(("127.0.0.1", 0), FakeEngine) server.cache, server.fault, server.seen, server.inflight, server.linger = cache, fault, {}, 0, linger server.steps, server.kept, server.evicted, server.cut = steps, collections.OrderedDict(), set(), set() - server.streams = server.leaked = server.lost = server.disconnects = 0 + server.streams = server.leaked = server.lost = server.disconnects = server.overlaps = 0 server.warm, server.warm_until, server.lanes_free = warm, 0.0, lanes_free - server.lock = threading.Lock() + server.census_at, server.census_gap = -1e9, 1e9 # no census read yet + server.lock, server.one = threading.Lock(), threading.Lock() server.cond = threading.Condition(server.lock) thread = threading.Thread(target=server.serve_forever, kwargs={"poll_interval": 0.01}, daemon=True) thread.start() diff --git a/tools/tests/fixtures/draft_divergence/README.md b/tools/tests/fixtures/draft_divergence/README.md new file mode 100644 index 00000000000..0e3b7d5bf2c --- /dev/null +++ b/tools/tests/fixtures/draft_divergence/README.md @@ -0,0 +1,9 @@ +These JSON files are synthetic recorded-format unit fixtures, authored for the +harness. They are not captures from any model or hardware. `recording.json` has +eight greedy tokens and a BF16-near tie at generated index 2. `profiles.json` +contains three placeholder endpoints with configured caps 1, 4 and 8. + +`equal.json` records identical serial/drafted token streams. `divergent.json` +changes only the depth-4 token at index 2 from 12 to 99, reversing the two +synthetic contenders in that run's raw-logit capture. Both margins are within +one BF16 spacing, but exact token equality must fail. diff --git a/tools/tests/fixtures/draft_divergence/divergent.json b/tools/tests/fixtures/draft_divergence/divergent.json new file mode 100644 index 00000000000..a04b04d060c --- /dev/null +++ b/tools/tests/fixtures/draft_divergence/divergent.json @@ -0,0 +1,486 @@ +{ + "fixture:2:plain": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": false + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 0 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + }, + "fixture:2:1": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": true + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 7 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + }, + "fixture:2:4": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 99, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": true + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 7 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 99, + 12 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + }, + "fixture:2:8": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": true + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 7 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + } +} diff --git a/tools/tests/fixtures/draft_divergence/equal.json b/tools/tests/fixtures/draft_divergence/equal.json new file mode 100644 index 00000000000..9aa0944680e --- /dev/null +++ b/tools/tests/fixtures/draft_divergence/equal.json @@ -0,0 +1,486 @@ +{ + "fixture:2:plain": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": false + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 0 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + }, + "fixture:2:1": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": true + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 7 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + }, + "fixture:2:4": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": true + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 7 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + }, + "fixture:2:8": { + "response": { + "model": "fixture-model", + "choices": [ + { + "index": 0, + "text": "fixture only", + "finish_reason": "length" + } + ], + "tensorfold": { + "token_ids": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "drafts": true + }, + "usage": { + "completion_tokens": 8 + }, + "speculative": { + "drafted": 7 + } + }, + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + } +} diff --git a/tools/tests/fixtures/draft_divergence/profiles.json b/tools/tests/fixtures/draft_divergence/profiles.json new file mode 100644 index 00000000000..0a268983213 --- /dev/null +++ b/tools/tests/fixtures/draft_divergence/profiles.json @@ -0,0 +1,32 @@ +[ + { + "depth": 1, + "url": "http://fixture.invalid:8001", + "model": "fixture-model", + "identity": { + "checkpoint": "Org/RecordedFixture@0000000000000000000000000000000000000000", + "tokenizer": "fixture-tokenizer", + "backend": "recorded-unit-fixture" + } + }, + { + "depth": 4, + "url": "http://fixture.invalid:8004", + "model": "fixture-model", + "identity": { + "checkpoint": "Org/RecordedFixture@0000000000000000000000000000000000000000", + "tokenizer": "fixture-tokenizer", + "backend": "recorded-unit-fixture" + } + }, + { + "depth": 8, + "url": "http://fixture.invalid:8008", + "model": "fixture-model", + "identity": { + "checkpoint": "Org/RecordedFixture@0000000000000000000000000000000000000000", + "tokenizer": "fixture-tokenizer", + "backend": "recorded-unit-fixture" + } + } +] diff --git a/tools/tests/fixtures/draft_divergence/recording.json b/tools/tests/fixtures/draft_divergence/recording.json new file mode 100644 index 00000000000..016ab31d4ff --- /dev/null +++ b/tools/tests/fixtures/draft_divergence/recording.json @@ -0,0 +1,117 @@ +{ + "schema": 1, + "identity": { + "checkpoint": "Org/RecordedFixture@0000000000000000000000000000000000000000", + "tokenizer": "fixture-tokenizer", + "backend": "recorded-unit-fixture" + }, + "traces": [ + { + "name": "fixture", + "prompt": [ + 1, + 2 + ], + "tokens": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17 + ], + "top2": [ + { + "ids": [ + 10, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 2 + }, + { + "ids": [ + 11, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 3 + }, + { + "ids": [ + 12, + 99 + ], + "logits": [ + 16.0, + 15.9375 + ], + "position": 4 + }, + { + "ids": [ + 13, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 5 + }, + { + "ids": [ + 14, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 6 + }, + { + "ids": [ + 15, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 7 + }, + { + "ids": [ + 16, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 8 + }, + { + "ids": [ + 17, + 99 + ], + "logits": [ + 16.0, + 14.0 + ], + "position": 9 + } + ] + } + ] +} diff --git a/tools/tests/test_bench_cache_agents.py b/tools/tests/test_bench_cache_agents.py index 9a60cf2b0a0..cc628f70d95 100644 --- a/tools/tests/test_bench_cache_agents.py +++ b/tools/tests/test_bench_cache_agents.py @@ -125,9 +125,11 @@ def __init__(self, sent): arrivals = iter([sent + 1, sent + 2, sent + 3]) self.clock = lambda: next(arrivals) - with patch.object(bench.bench_stream, "Collector", TimedCollector): + with patch.object(bench, "time") as clock, patch.object(bench.bench_stream, "Collector", TimedCollector): + clock.perf_counter.return_value = 10.0 code, report, _ = invoke(Fixture("role_first")) self.assertEqual(code, 0) + self.assertTrue(report["rows"]) self.assertTrue(all(row["ttft_s"] == 3 for row in report["rows"])) def test_unsupported_thinking_switch_is_omitted_and_its_mode_is_recorded(self): diff --git a/tools/tests/test_bench_conformance.py b/tools/tests/test_bench_conformance.py index 45daa86425b..2f685b10484 100644 --- a/tools/tests/test_bench_conformance.py +++ b/tools/tests/test_bench_conformance.py @@ -45,6 +45,12 @@ def test_same_needs_two_full_hashes(self): self.assertIsNone(same(a, {**a, "error": "x"})) self.assertEqual(tally([(a, a), (a, b), (a, {})]), {"equal": 1, "unequal": 1, "unverified": 1}) + def test_empty_replies_are_unverified(self): + # Two empty replies hash the same: equal without a token is no evidence. + empty = reply_row(200, doc(tokens=0, text="")) + self.assertIsNone(same(empty, empty)) + self.assertIsNone(same(reply_row(200, doc()), {**reply_row(200, doc()), "tokens": None})) + def test_equality_gate_fails_on_unequal_unverified_or_empty(self): a, b = reply_row(200, doc()), reply_row(200, doc(sha="b" * 64)) self.assertTrue(equality_gate("g", [(a, a)])["passed"]) @@ -54,10 +60,29 @@ def test_equality_gate_fails_on_unequal_unverified_or_empty(self): def test_drafted_gate_is_vacuous_without_an_accepted_draft(self): plain, drafted = reply_row(200, doc(accepted=0, drafted=0)), reply_row(200, doc(accepted=0, drafted=7)) - gate = drafted_gate([(plain, drafted)]) + gate = drafted_gate({"greedy": [(plain, drafted)]}) self.assertFalse(gate["passed"]) self.assertIn("vacuous", gate["line"]) - self.assertTrue(drafted_gate([(plain, reply_row(200, doc()))])["passed"]) + self.assertTrue(drafted_gate({"greedy": [(plain, reply_row(200, doc()))]})["passed"]) + + def test_drafted_gate_needs_drafts_in_each_mode_and_none_in_plain(self): + plain, good, idle = (reply_row(200, doc(accepted=a, drafted=d)) for a, d in ((0, 0), (2, 3), (0, 3))) + sampled_idle = drafted_gate({"greedy": [(plain, good)], "sampled": [(plain, idle)]}) + self.assertFalse(sampled_idle["passed"]) + self.assertIn("no draft accepted sampled", sampled_idle["line"]) + both_drafted = drafted_gate({"greedy": [(good, good)]}) + self.assertFalse(both_drafted["passed"]) + self.assertIn("plain replies drafted 3 tokens", both_drafted["line"]) + + def test_seeded_and_overlap_problems(self): + a, b = reply_row(200, doc()), reply_row(200, doc(sha="b" * 64)) + self.assertIsNone(conformance.seeded_problem([(a, a), (a, b)])) + self.assertIn("never reached sampling", conformance.seeded_problem([(a, a)])) + self.assertIsNone(conformance.overlap_problem([2, 8])) + self.assertIn("2 of 3 batches", conformance.overlap_problem([2, 1, None])) + self.assertIsNone(conformance.batch_drafts_problem({2: [5, 0], "mixed": [1, 0]})) + self.assertIn("accepted no draft at [2]; plain rows drafted at {'mixed': 3}", + conformance.batch_drafts_problem({2: [0, 0], "mixed": [1, 3]})) def test_resumed_gate_asserts_both_cache_counts(self): def turns(fresh_cached, resumed_cached): @@ -134,7 +159,10 @@ class GateRunTests(unittest.TestCase): NAMES = {"drafted": "drafted == plain", "repeat": "repeat == first", "concurrent": "concurrent == solo", "resumed": "resumed == fresh", "refusals": "refusals", "cancel": "cancel", "evict": "evict", - "cancel_lane": "cancel", "cancel_free": "cancel", "cancel_reply": "cancel", "cancel_health": "cancel"} + "cancel_lane": "cancel", "cancel_free": "cancel", "cancel_reply": "cancel", "cancel_health": "cancel", + "undrafted": "drafted == plain", "plain_drafts": "drafted == plain", "sampled_drafts": "drafted == plain", + "unsampled": "repeat == first", "serial": "concurrent == solo", "empty": "drafted == plain"} + JSON_ONLY = ("undrafted", "sampled_drafts", "unsampled", "serial") # faults the stream test leaves out GATE_OF = {fault: name.split()[0] for fault, name in NAMES.items() if fault in FAULTS} # the gate a fault turns red def run_kit(self, *extra, fault=None, shape=None, **changes): @@ -180,6 +208,30 @@ def test_fault_resumed_reports_no_cached_tokens(self): def test_fault_listed_refusal_accepted(self): self.assert_only_red("refusals") + def test_fault_no_draft_lands(self): + # Batched drafted rows accept no draft either, so concurrency fails as unproven drafting too. + self.assert_only_red("undrafted", also=("concurrent == solo",)) + + def test_fault_plain_arm_drafts(self): + self.assert_only_red("plain_drafts", also=("concurrent == solo",)) + + def test_fault_sampled_arm_drafts_nothing(self): + self.assert_only_red("sampled_drafts") + + def test_fault_seed_never_reaches_sampling(self): + # Only the cached fake carries the fault, so its sampled chat also differs from the clean cache-off fake's. + self.assert_only_red("unsampled", also=("resumed == fresh",)) + + def test_fault_requests_never_overlap(self): + self.assert_only_red("serial") + + def test_fault_empty_replies_fail_every_exactness_gate(self): + code, lines = self.run_kit("--gates", "drafted,repeat,concurrent,resumed", fault="empty") + self.assertEqual(code, 1, lines) + self.assertEqual(len(lines), 4, lines) + self.assertTrue(all(line.startswith("FAIL") and " unverified" in line for line in lines), lines) + self.assertTrue(all(" 0 unverified" not in line for line in lines), lines) + def test_fault_cancel_keeps_a_lane(self): # A request left running keeps the server from ever going idle, so evict has no idle census either. self.assert_only_red("cancel_lane", also=("evict",)) @@ -257,7 +309,8 @@ def test_streamed_replies_pass_clean_and_each_fault_turns_its_gate_red(self): self.assertEqual(code, 0, lines) self.assertEqual(len(lines), len(conformance.GATES)) self.assertTrue(all(line.startswith("PASS") for line in lines), lines) - for fault, gate in self.GATE_OF.items(): + # the streamed reader's draft and token counts: two faults suffice; the others change nothing it reads + for fault, gate in ((f, g) for f, g in self.GATE_OF.items() if f not in self.JSON_ONLY): with self.subTest(fault=fault): code, lines = self.run_kit("--stream", "--gates", gate, fault=fault) self.assertEqual(code, 1, lines) diff --git a/tools/tests/test_bench_lfm3_serve_check.py b/tools/tests/test_bench_lfm3_serve_check.py new file mode 100644 index 00000000000..3bc31164b77 --- /dev/null +++ b/tools/tests/test_bench_lfm3_serve_check.py @@ -0,0 +1,68 @@ +"""tools/lfm3/serve_check.py on the fake served API: clean it passes; unexercised drafts or sampling fail by name.""" +import contextlib +import importlib.util +import io +import json +from pathlib import Path +import sys +import tempfile +import unittest +from unittest import mock + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from fake_served_api import fake + +SPEC = importlib.util.spec_from_file_location("lfm3_serve_check", Path(__file__).resolve().parents[1] / "lfm3" / + "serve_check.py") +check = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(check) + + +def fake_server(fault): + """``serve_check.Server`` with a fake served API (with ``fault``) in place of the native binary.""" + + class Fake(check.Server): + def __enter__(self): + self.command = ["fake", str(self.cache)] + self.log = tempfile.NamedTemporaryFile(mode="w+b", dir=self.log_directory, delete=False) + self.running = fake(self.cache > 0, fault) + self.base = self.running.__enter__() + return self + + def __exit__(self, *exc): + self.running.__exit__(*exc) + self.log.close() + return Fake + + +def run(fault=None): + """The exit code and the failed checks' names of one ``--sampled`` run against the fake.""" + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + (root / "config.json").write_text(json.dumps({"model_type": "lfm3"})) + (root / "binary").write_bytes(b"fake") + argv = ["serve_check.py", "--binary", str(root / "binary"), "--model-dir", str(root), "--output", + str(root / "out.json"), "--sampled"] + with mock.patch.object(check, "Server", fake_server(fault)), mock.patch.object(sys, "argv", argv), \ + mock.patch.object(check.tempfile, "mkdtemp", lambda prefix: tmp), \ + contextlib.redirect_stdout(io.StringIO()): + code = check.main() + receipt = json.loads((root / "out.json").read_text()) + return code, [t["name"] for t in receipt["tests"] if t["status"] == "failed"] + + +class Lfm3ServeCheckTests(unittest.TestCase): + def test_clean_fake_passes(self): + self.assertEqual(run(), (0, [])) + + def test_unexercised_drafts_fail(self): + for fault in ("undrafted", "plain_drafts"): + with self.subTest(fault=fault): + self.assertEqual(run(fault), (1, ["drafts/exercised"])) + + def test_a_sampler_that_never_ran_fails(self): + self.assertEqual(run("unsampled"), (1, ["sampled_code/sampler_ran", "sampled_chat/sampler_ran"])) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_bench_qwen27_http_gate.py b/tools/tests/test_bench_qwen27_http_gate.py new file mode 100644 index 00000000000..b6260139f2a --- /dev/null +++ b/tools/tests/test_bench_qwen27_http_gate.py @@ -0,0 +1,43 @@ +"""tools/zig/qwen27_http_gate.py's reply check on fake served replies: a drafted reply must propose and accept.""" +import json +from pathlib import Path +import sys +import unittest +import urllib.request + +sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "zig")) +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import qwen27_http_gate +from fake_served_api import fake + +TOKENS = [11, 22, 33] + + +def reply(fault, draft): + """The fake's reply to one request, its runtime fields set as the CLI receipt's tokens give them.""" + with fake(False, fault) as url: + body = {"messages": [{"role": "user", "content": "hi"}], "max_tokens": len(TOKENS), "draft": draft} + request = urllib.request.Request(url + "/v1/chat/completions", json.dumps(body).encode(), + {"Content-Type": "application/json"}) + with urllib.request.urlopen(request, timeout=10) as answer: + doc = json.load(answer) + digest = qwen27_http_gate.hashlib.sha256(",".join(map(str, TOKENS)).encode()).hexdigest()[:12] + doc["tensorfold"].update(token_sha=digest, drafts=draft) + doc["usage"].update(prompt_tokens=2, completion_tokens=len(TOKENS)) + return doc + + +class DraftCheckTests(unittest.TestCase): + def test_drafted_and_plain_replies_pass(self): + for draft in (True, False): + self.assertEqual(qwen27_http_gate.check(reply(None, draft), [1, 2], TOKENS, draft)["drafts"], draft) + + def test_a_drafted_reply_that_accepted_nothing_fails(self): + doc = reply("undrafted", True) + doc["speculative"].update(rounds=4, drafted=12) # verified rounds whose drafts all missed + with self.assertRaisesRegex(ValueError, "did not exercise draft verification"): + qwen27_http_gate.check(doc, [1, 2], TOKENS, True) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_bench_serve_check.py b/tools/tests/test_bench_serve_check.py new file mode 100644 index 00000000000..a2820410ef6 --- /dev/null +++ b/tools/tests/test_bench_serve_check.py @@ -0,0 +1,52 @@ +"""zig/tests/qwen35/serve_check.py against the fake served API: clean it passes, and each planted fault fails by name.""" +import subprocess +import sys +import unittest +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from fake_served_api import fake + +SCRIPT = Path(__file__).resolve().parents[2] / "zig" / "tests" / "qwen35" / "serve_check.py" + + +def run(fault=None): + """The script's exit code and its FAIL lines, against a cached fake with ``fault`` and a cache-off fake.""" + with fake(True, fault) as url, fake(False) as fresh: + done = subprocess.run([sys.executable, str(SCRIPT), url, "fake", "8", fresh], capture_output=True, text=True, + timeout=120) + return done.returncode, [line for line in done.stdout.splitlines() if line.startswith("FAIL")] + + +class ServeCheckTests(unittest.TestCase): + def test_clean_fake_passes(self): + self.assertEqual(run(), (0, [])) + + def test_a_resume_that_resumed_nothing_fails(self): + # The vacuous pass of #2460: a later turn that resumed no tokens compared two fresh replies. + code, failed = run("resumed") + self.assertEqual(code, 1) + self.assertEqual([line.split(":")[0] for line in failed], ["FAIL resumed == fresh"], failed) + self.assertIn("resumed no tokens", failed[0]) + + def test_unexercised_drafts_fail(self): + for fault, labels in (("plain_drafts", ["greedy", "t0.8"]), ("sampled_drafts", ["t0.8"])): + with self.subTest(fault=fault): + code, failed = run(fault) + self.assertEqual(code, 1) + self.assertEqual([line.split(":")[0] for line in failed], [f"FAIL {x}" for x in labels], failed) + self.assertTrue(all("drafted == serial" in line for line in failed), failed) + + def test_a_sampler_that_never_ran_fails(self): + code, failed = run("unsampled") + self.assertEqual(code, 1) + self.assertEqual(failed, ["FAIL t0.8: the same twice, unlike greedy"]) + + def test_empty_replies_are_never_equal(self): + code, failed = run("empty") + self.assertEqual(code, 1) + self.assertGreaterEqual(len(failed), 10, failed) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_draft_divergence.py b/tools/tests/test_draft_divergence.py new file mode 100644 index 00000000000..25629b36fb0 --- /dev/null +++ b/tools/tests/test_draft_divergence.py @@ -0,0 +1,293 @@ +"""Recorded synthetic fixtures exercise strict IDs, BF16 diagnostics and served/replay request contracts.""" +import contextlib +import copy +import io +import json +from pathlib import Path +import sys +import tempfile +import unittest +from unittest.mock import patch + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +import draft_divergence as harness + +FIXTURES = Path(__file__).parent / "fixtures" / "draft_divergence" + + +class DraftDivergenceTests(unittest.TestCase): + def setUp(self): + self.recording = harness.load(FIXTURES / "recording.json") + self.profiles = harness.load(FIXTURES / "profiles.json") + self.equal = harness.load(FIXTURES / "equal.json") + self.calls = [] + + def evaluate(self, observations=None, **kwargs): + observations = self.equal if observations is None else observations + + def fetch(profile, body, case_id, depth): + self.calls.append((copy.deepcopy(profile), copy.deepcopy(body), case_id, depth)) + return copy.deepcopy(observations[case_id + ":" + depth]) + + return harness.evaluate(self.recording, self.profiles, fetch, lookback=2, tokens=8, **kwargs) + + def test_equal_runs_and_exact_request_contract(self): + report = self.evaluate() + self.assertTrue(report["passed"]) + self.assertEqual(report["status"], "pass") + case, = report["cases"] + self.assertEqual(case["near_tie_offset"], 2) + self.assertTrue(case["source_reproduced"]) + self.assertEqual([v["configured_depth"] for v in case["variants"]], [1, 4, 8]) + self.assertTrue(all(v["token_equal"] for v in case["variants"])) + self.assertEqual(len(self.calls), 4) + for index, (profile, body, name, depth) in enumerate(self.calls): + self.assertEqual(body["prompt"], [1, 2]) + self.assertEqual(body["max_tokens"], 8) + self.assertEqual(body["temperature"], 0) + self.assertIs(body["draft"], index > 0) + self.assertIs(body["return_token_ids"], True) + self.assertIs(body["ignore_eos"], True) + self.assertIs(body["stream"], False) + self.assertEqual(body["model"], profile["model"]) + self.assertNotIn("draft_depth", body) + self.assertEqual(name, "fixture:2") + self.assertEqual(depth, ["plain", "1", "4", "8"][index]) + self.assertEqual(harness.summary(report), + "DRAFT_DIVERGENCE status=pass cases=1 comparisons=3 divergences=0") + + def test_divergence_at_token_n_reports_both_raw_captures(self): + report = self.evaluate(harness.load(FIXTURES / "divergent.json")) + self.assertFalse(report["passed"]) + self.assertEqual(report["status"], "divergent") + difference = report["cases"][0]["variants"][1]["first_divergence"] + self.assertEqual((difference["output_index"], difference["absolute_position"]), (2, 4)) + self.assertEqual((difference["plain_token_id"], difference["drafted_token_id"]), (12, 99)) + self.assertEqual(difference["plain_top2"]["ids"], [12, 99]) + self.assertEqual(difference["drafted_top2"]["ids"], [99, 12]) + self.assertEqual(difference["plain_top2"]["logits"], [16.0, 15.9375]) + self.assertEqual(difference["drafted_top2"]["logits"], [16.0, 15.9375]) + self.assertEqual(difference["label"], "near-tie") + self.assertIs(difference["strict_equal"], False) + self.assertIn('first="fixture:2"@2 depth=4', harness.summary(report)) + + def test_bf16_boundary_is_inclusive_and_uses_absolute_raw_logits(self): + row = self.recording["traces"][0]["top2"][2] + row["logits"] = [16, 15.875] + case, = harness.select_prompts(self.recording, lookback=1, tokens=8) + self.assertEqual(case["bf16_spacing"], 0.125) + self.assertEqual(case["prompt"], [1, 2, 10]) + self.assertEqual(case["near_tie_offset"], 1) + row["logits"][1] = 15.874 + with self.assertRaisesRegex(ValueError, "no recorded BF16 near-ties"): + harness.select_prompts(self.recording) + self.assertTrue(harness.near({"logits": [16, 15.9375]})) + self.assertFalse(harness.near({"logits": [-0.68, -0.7425]})) + + def test_nearest_supported_caps_are_reported(self): + for profile, depth in zip(self.profiles, [1, 3, 6]): + profile["depth"] = depth + report = self.evaluate() + self.assertTrue(report["passed"]) + variants = report["cases"][0]["variants"] + self.assertEqual([(v["requested_depth"], v["configured_depth"]) for v in variants], + [(1, 1), (4, 3), (8, 6)]) + self.assertIn("not per-request", variants[0]["depth_control"]) + + def test_no_draft_work_never_passes(self): + for value in (0, None): + observations = copy.deepcopy(self.equal) + observations["fixture:2:4"]["response"]["speculative"]["drafted"] = value + with self.subTest(value=value): + report = self.evaluate(observations) + self.assertEqual(report["status"], "incomplete") + self.assertFalse(report["passed"]) + + def test_equal_early_stops_do_not_pass(self): + observations = copy.deepcopy(self.equal) + for observation in observations.values(): + response = observation["response"] + response["tensorfold"]["token_ids"] = response["tensorfold"]["token_ids"][:2] + response["usage"]["completion_tokens"] = 2 + response["choices"][0]["finish_reason"] = "stop" + observation["top2"] = observation["top2"][:2] + report = self.evaluate(observations) + self.assertEqual(report["status"], "incomplete") + self.assertFalse(report["passed"]) + + def test_length_difference_has_missing_id_and_fails(self): + observations = copy.deepcopy(self.equal) + observation = observations["fixture:2:4"] + observation["response"]["tensorfold"]["token_ids"].pop() + observation["response"]["usage"]["completion_tokens"] -= 1 + observation["response"]["choices"][0]["finish_reason"] = "stop" + observation["top2"].pop() + report = self.evaluate(observations) + self.assertEqual(report["status"], "divergent") + difference = report["cases"][0]["variants"][1]["first_divergence"] + self.assertEqual(difference["output_index"], 7) + self.assertEqual(difference["plain_token_id"], 17) + self.assertIsNone(difference["drafted_token_id"]) + + def test_live_shape_without_raw_captures_labels_historical_logits(self): + observations = harness.load(FIXTURES / "divergent.json") + for observation in observations.values(): + observation.pop("top2") + report = self.evaluate(observations) + difference = report["cases"][0]["variants"][1]["first_divergence"] + self.assertFalse(report["passed"]) + self.assertEqual(difference["label"], "recorded-near-tie") + self.assertIsNone(difference["plain_top2"]) + self.assertIsNone(difference["drafted_top2"]) + self.assertEqual(difference["recorded_logits_for_tokens"], {"plain": 16.0, "drafted": 15.9375}) + self.assertIn("recorded source", difference["logit_source"]) + + def test_changed_plain_history_does_not_reuse_source_logits(self): + observations = harness.load(FIXTURES / "divergent.json") + for observation in observations.values(): + observation.pop("top2") + observation["response"]["tensorfold"]["token_ids"][0] = 77 + report = self.evaluate(observations) + difference = report["cases"][0]["variants"][1]["first_divergence"] + self.assertFalse(difference["recorded_history_matches"]) + self.assertEqual(difference["recorded_logits_for_tokens"], {"plain": None, "drafted": None}) + self.assertEqual(difference["label"], "divergence") + + def test_nonreproduced_source_never_passes_even_when_modes_agree(self): + observations = copy.deepcopy(self.equal) + for observation in observations.values(): + observation.pop("top2") + observation["response"]["tensorfold"]["token_ids"][0] = 77 + report = self.evaluate(observations) + self.assertEqual(report["status"], "incomplete") + self.assertFalse(report["cases"][0]["source_reproduced"]) + + def test_malformed_responses_refused(self): + mutations = [ + lambda r: r["tensorfold"].pop("token_ids"), + lambda r: r["tensorfold"]["token_ids"].__setitem__(0, True), + lambda r: r["tensorfold"].__setitem__("drafts", True), + lambda r: r["usage"].__setitem__("completion_tokens", 7), + lambda r: r.__setitem__("model", "wrong"), + lambda r: r["choices"][0].__setitem__("finish_reason", "error"), + lambda r: r.__setitem__("error", "failure"), + lambda r: r["speculative"].__setitem__("drafted", 2), + ] + for index, mutate in enumerate(mutations): + observations = copy.deepcopy(self.equal) + mutate(observations["fixture:2:plain"]["response"]) + with self.subTest(mutation=index), self.assertRaises(ValueError): + self.evaluate(observations) + + def test_bad_recorded_logits_refused(self): + mutations = [ + lambda r: r.__setitem__("logits", [15, 16]), + lambda r: r.__setitem__("logits", [float("nan"), 15]), + lambda r: r.__setitem__("logits", [float("inf"), 15]), + lambda r: r.__setitem__("ids", [12, 12]), + lambda r: r.__setitem__("ids", [13, 99]), + lambda r: r.__setitem__("position", 999), + ] + for index, mutate in enumerate(mutations): + recording = copy.deepcopy(self.recording) + mutate(recording["traces"][0]["top2"][2]) + with self.subTest(mutation=index), self.assertRaises(ValueError): + harness.select_prompts(recording) + + def test_bad_profiles_refused(self): + mutations = [ + lambda p: p[1]["identity"].__setitem__("tokenizer", "different"), + lambda p: p[1].__setitem__("depth", 1), + lambda p: p[1].__setitem__("url", p[0]["url"] + "/"), + lambda p: p[1].__setitem__("url", p[0]["url"] + "/v1/completions"), + lambda p: p[1].__setitem__("url", "http://secret@fixture.invalid"), + lambda p: p[1].__setitem__("url", "http://fixture.invalid?key=secret"), + ] + for index, mutate in enumerate(mutations): + profiles = copy.deepcopy(self.profiles) + mutate(profiles) + with self.subTest(mutation=index), self.assertRaises(ValueError): + harness.profiles_for(profiles, self.recording["identity"], (1, 4, 8)) + + def test_distinct_prefix_selection_is_bounded(self): + trace = self.recording["traces"][0] + trace["top2"][3]["logits"] = [16, 15.99] + cases = harness.select_prompts(self.recording, limit=1, lookback=0, tokens=4) + self.assertEqual(len(cases), 1) + self.assertEqual(cases[0]["id"], "fixture:3") + self.assertEqual(cases[0]["prompt"], [1, 2, 10, 11, 12]) + self.assertEqual(cases[0]["tokens"], [13, 14, 15, 16]) + + def test_bad_per_run_capture_refused(self): + observations = copy.deepcopy(self.equal) + observations["fixture:2:4"]["top2"][2]["ids"] = [99, 12] + with self.assertRaisesRegex(ValueError, "argmax disagree"): + self.evaluate(observations) + + def test_redirect_is_refused(self): + with self.assertRaisesRegex(ValueError, "redirect refused"): + harness.NoRedirect().redirect_request(None, None, 302, "found", {}, "http://fixture.invalid") + + def test_cli_replay_is_offline_and_exit_codes_are_strict(self): + with tempfile.TemporaryDirectory() as directory: + output = Path(directory) / "result.json" + for filename, code, status in [("equal.json", 0, "pass"), ("divergent.json", 1, "divergent")]: + stdout = io.StringIO() + with patch.object(harness, "live_fetch", side_effect=AssertionError("unexpected HTTP")): + with contextlib.redirect_stdout(stdout): + actual = harness.main(["--recording", str(FIXTURES / "recording.json"), "--profiles", + str(FIXTURES / "profiles.json"), "--replay", str(FIXTURES / filename), + "--lookback", "2", "--tokens", "8", "--output", str(output)]) + self.assertEqual(actual, code) + report = json.loads(output.read_text()) + self.assertEqual(report["status"], status) + self.assertEqual(report["mode"], "recorded-replay") + self.assertEqual(len(stdout.getvalue().splitlines()), 1) + self.assertIn("input_sha256", report) + + def test_cli_errors_are_json_and_one_summary_line(self): + with tempfile.TemporaryDirectory() as directory: + output = Path(directory) / "result.json" + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + code = harness.main(["--recording", str(FIXTURES / "recording.json"), "--profiles", + str(FIXTURES / "profiles.json"), "--depths", "1,1", "--replay", + str(FIXTURES / "equal.json"), "--output", str(output)]) + self.assertEqual(code, 2) + self.assertEqual(json.loads(output.read_text())["status"], "error") + self.assertEqual(len(stdout.getvalue().splitlines()), 1) + + def test_nonfinite_json_refused(self): + with tempfile.TemporaryDirectory() as directory: + source = Path(directory) / "nonfinite.json" + source.write_text('{"logit": NaN}') + with self.assertRaisesRegex(ValueError, "nonfinite"): + harness.load(source) + + def test_served_client_posts_exact_ids_without_network(self): + class Reply: + def __enter__(self): + return self + + def __exit__(self, *args): + return False + + def read(self, size): + return json.dumps(self_response).encode() + + self_response = self.equal["fixture:2:plain"]["response"] + case, = harness.select_prompts(self.recording, lookback=2, tokens=8) + body = harness.request(case, self.profiles[0], False) + with patch.object(harness.urllib.request, "build_opener") as build: + build.return_value.open.return_value = Reply() + observation = harness.live_fetch(12)(self.profiles[0], body, case["id"], "plain") + (request,), kwargs = build.return_value.open.call_args + self.assertEqual(request.full_url, "http://fixture.invalid:8001/v1/completions") + self.assertEqual(request.get_method(), "POST") + self.assertEqual(json.loads(request.data), body) + self.assertEqual(kwargs, {"timeout": 12}) + self.assertEqual(observation["response"], self_response) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/zig/idol_case.py b/tools/zig/idol_case.py new file mode 100644 index 00000000000..9f356ff0472 --- /dev/null +++ b/tools/zig/idol_case.py @@ -0,0 +1,257 @@ +#!/usr/bin/env python3 +"""Idol reference cases for tf-idol from the publisher's idol-sdk (torch): the denoiser's schedule and its blocks.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import sys +import time +from pathlib import Path + +USAGE = """\ + case WEIGHTS SDK OUT --features F [F] noise, each step's input and both velocities, the final sample + case WEIGHTS SDK OUT --synthetic-conditioning --cond-seed N + the same, on feature1 and feature2 drawn N(0, 1) from seed N (no encoders) + blocks WEIGHTS SDK CASE [--step S] every block's rows at step S, and each block in float32 on its input + exact WEIGHTS SDK CASE [--steps N] both velocities in float32 on the case's first N inputs (the ruler) +WEIGHTS is a speridlabs/idol snapshot; SDK an idol-sdk checkout at the pinned commit. F holds feature1 (DINOv3 rows +[1, 4101, 1280]) and feature2 (FLUX.2 VAE rows [1, 4101, 128]), in one file or two, as the SDK's ImageEncoder returns. +""" + +SDK_COMMIT = "4702a7f00850e34b6e83a2170cc123c3e9570744" +SDK_SHA256 = { + "idol/models/dit.py": "fbe725cc478b0acd245d9404ac8d9df327ebfbf79fe51c954d94b005c5bd6af4", + "idol/models/layers.py": "2dbf24107396194636c9a2e89e7acee1bcf91b14dba1b4cde0318cb85b3f482f", + "idol/sampler.py": "532987b5599be678361c2fcf566335bb3e1b0171696f985818d10b7460bfc8b0", +} +WEIGHTS_REVISION = "2731c2291fc65a797c5cb627a5e5526fc1490902" +DENOISER_ARGS = {"q_token_length": 8192, "in_channels": 16, "cam_channels": 5, "model_channels": 1024, + "cond_channels": 1280, "cond2_channels": 128, "num_blocks": 24, "num_refiner_blocks": 2, + "num_heads": 16, "mlp_ratio": 4} + + +def sdk(path: str): + """The SDK's denoiser and sampler, imported once each file used has the pinned commit's sha256.""" + root = Path(path) + for name, want in SDK_SHA256.items(): + digest = hashlib.sha256((root / name).read_bytes()).hexdigest() + if digest != want: + sys.exit(f"{root / name} has sha256 {digest}; this tool runs only idol-sdk {SDK_COMMIT[:12]}'s ({want})") + sys.path.insert(0, str(root)) + from idol.models.dit import LatentSeqMMFlowModel + from idol.sampler import sample_flow + return LatentSeqMMFlowModel, sample_flow + + +def denoiser(weights: str, sdk_dir: str, device: str): + """The SDK's denoiser with the snapshot's weights, strictly loaded, as IdolPipeline builds it.""" + import torch + from safetensors.torch import load_file + + model_cls, _ = sdk(sdk_dir) + config = json.loads((Path(weights) / "config.json").read_text()) + args = config["denoiser"]["args"] + if config["denoiser"]["name"] != "LatentSeqMMFlowModel" or args != DENOISER_ARGS: + sys.exit(f"{weights}/config.json is not speridlabs/idol {WEIGHTS_REVISION[:12]}'s denoiser") + model = model_cls(**args) + model.load_state_dict(load_file(str(Path(weights) / "denoiser.safetensors")), strict=True) + return model.eval().requires_grad_(False).to(torch.device(device)) + + +def features(paths: list[str]): + """feature1 and feature2 [1, 4101, C] float32 from one or two safetensors files.""" + from safetensors.torch import load_file + + found = {} + for path in paths: + found.update(load_file(path)) + for key, width in (("feature1", 1280), ("feature2", 128)): + if key not in found or tuple(found[key].shape) != (1, 4101, width): + sys.exit(f"the features need {key} [1, 4101, {width}]") + return found["feature1"].float(), found["feature2"].float() + + +def synthetic(seed: int): + """feature1 and feature2 [1, 4101, C] float32 drawn N(0, 1) from `seed`, in that order, in place of the encoders.""" + import torch + + gen = torch.Generator("cpu").manual_seed(seed) + return tuple(torch.randn((1, 4101, width), generator=gen, dtype=torch.float32) for width in (1280, 128)) + + +def condition(f1, f2, device: str): + """The sampler's cond and neg_cond (both streams zeroed), as IdolPipeline passes them.""" + from tensordict import TensorDict + + cond = TensorDict({"feature1": f1, "feature2": f2}, batch_size=1, device=device) + return cond, cond.apply(lambda x: x * 0) + + +def sample(latent, camera, device: str): + """The sampler's TensorDict for one latent [8192, 16] and camera [5].""" + from tensordict import TensorDict + + return TensorDict({"latent": latent[None].to(device), "camera": camera.view(1, 1, 5).to(device)}, batch_size=1, + device=device) + + +def flush(device: str) -> None: + import torch + + if device == "mps": + torch.mps.synchronize() + + +def case(args) -> int: + import torch + from safetensors.torch import save_file + + out = Path(args.out_dir) + out.mkdir(parents=True, exist_ok=True) + model = denoiser(args.weights, args.sdk, args.device) + _, sample_flow = sdk(args.sdk) + f1, f2 = synthetic(args.cond_seed) if args.synthetic_conditioning else features(args.features) + cond, neg = condition(f1, f2, args.device) + gen = torch.Generator("cpu").manual_seed(args.seed) + latent = torch.randn((8192, 16), generator=gen, dtype=torch.float32) + camera = torch.randn((5,), generator=gen, dtype=torch.float32) + calls = [] + forward = model.forward + + def recorded(x, t, c): + mark = time.perf_counter() + v = forward(x, t, c) + flush(args.device) + calls.append({"latent": x["latent"][0].float().cpu(), "camera": x["camera"][0, 0].float().cpu(), + "t": float(t[0]), "negative": bool(c["feature1"].abs().max() == 0), + "v": v["latent"][0].float().cpu(), "v_camera": v["camera"][0, 0].float().cpu(), + "s": time.perf_counter() - mark}) + return v + + model.forward = recorded + with torch.no_grad(): + final = sample_flow(model, sample(latent, camera, args.device), cond=cond, neg_cond=neg, steps=args.steps, + rescale_t=args.rescale_t, cfg_strength=args.cfg, verbose=False, batch_cfg=False) + model.forward = forward + pos, negs = calls[0::2], calls[1::2] + if args.cfg <= 0 or any(c["negative"] for c in pos) or not all(c["negative"] for c in negs): + sys.exit("the sampler's calls are not (conditional, negative) pairs") + stack = lambda rows, key: torch.stack([r[key] for r in rows]).contiguous() + tensors = {"feature1": f1[0].contiguous(), "feature2": f2[0].contiguous(), "latent": latent, "camera": camera, + "timesteps": torch.tensor([c["t"] for c in pos], dtype=torch.float32), + "inputs": stack(pos, "latent"), "inputs_camera": stack(pos, "camera"), + "velocity": stack(pos, "v"), "velocity_camera": stack(pos, "v_camera"), + "velocity_negative": stack(negs, "v"), "velocity_negative_camera": stack(negs, "v_camera"), + "sample": final["latent"][0].float().cpu().contiguous(), + "sample_camera": final["camera"][0, 0].float().cpu().contiguous()} + save_file(tensors, str(out / "case.safetensors")) + meta = {"seed": args.seed, "steps": args.steps, "cfg": args.cfg, "rescale_t": args.rescale_t, + "device": args.device, "torch": torch.__version__, "sdk": SDK_COMMIT, "weights": WEIGHTS_REVISION, + "conditioning": {"synthetic": True, "cond_seed": args.cond_seed} if args.synthetic_conditioning else + {"synthetic": False}, "torch_forward_s": [round(c["s"], 3) for c in calls]} + (out / "reference.json").write_text(json.dumps(meta, indent=1) + "\n") + times = sorted(meta["torch_forward_s"]) + print(json.dumps({k: v for k, v in meta.items() if k != "torch_forward_s"} | {"median_forward_s": times[len(times) // 2]})) + return 0 + + +def blocks(args) -> int: + """Each block's rows in the conditional forward at one step, and each block again in float32 on the same input.""" + import copy + + import torch + from safetensors.torch import load_file, save_file + + case_dir = Path(args.case_dir) + data = load_file(str(case_dir / "case.safetensors")) + model = denoiser(args.weights, args.sdk, args.device) + cond, _ = condition(data["feature1"][None], data["feature2"][None], args.device) + seen = {} + + def keep(name): + def hook(_module, _inputs, output): + seen[name] = output.detach().contiguous() + return hook + + stages = [("noise_refiner", model.noise_refiner), ("context_refiner", model.context_refiner), ("block", model.blocks)] + hooks = [m.register_forward_hook(keep(f"{name}.{i}")) for name, layers in stages for i, m in enumerate(layers)] + x = sample(data["inputs"][args.step], data["inputs_camera"][args.step], args.device) + t = data["timesteps"][args.step : args.step + 1].to(args.device) + with torch.no_grad(): + v = model(x, t, cond) + for h in hooks: + h.remove() + # the ruler: each joint block in float32 on the fp16 rows the SDK fed it, with an unrounded modulation + t_emb = model.t_embedder(t) + t_mod = model.adaLN_modulation(t_emb).float() + exact = {} + for i in range(1, len(model.blocks)): + block = copy.deepcopy(model.blocks[i]).float() + h = seen[f"block.{i - 1}"].float() + exact[f"block.{i}"] = block(h, mod=t_mod, rotary_emb=model.repo_layers[i](h))[0].cpu().contiguous() + del block + tensors = {k: x[0].cpu().contiguous() for k, x in seen.items()} + tensors["velocity"] = v["latent"][0].float().cpu().contiguous() + tensors["velocity_camera"] = v["camera"][0, 0].float().cpu().contiguous() + save_file(tensors, str(case_dir / f"blocks{args.step}.safetensors")) + save_file(exact, str(case_dir / f"blocks{args.step}_f32.safetensors")) + drift = (tensors["velocity"] - data["velocity"][args.step]).abs().max().item() + print(json.dumps({"step": args.step, "tensors": len(tensors), "velocity_max_abs_vs_case": drift})) + return 0 + + +def exact(args) -> int: + """Both branches in float32 throughout on the case's own inputs: the fp16 reference's distance from exact.""" + import torch + from safetensors.torch import load_file, save_file + + case_dir = Path(args.case_dir) + data = load_file(str(case_dir / "case.safetensors")) + model = denoiser(args.weights, args.sdk, args.device).float() + model.dtype = torch.float32 + cond, neg = condition(data["feature1"][None], data["feature2"][None], args.device) + keys = ("velocity", "velocity_camera", "velocity_negative", "velocity_negative_camera") + rows = {k: [] for k in keys} + with torch.no_grad(): + for s in range(min(args.steps, data["inputs"].shape[0])): + x = sample(data["inputs"][s], data["inputs_camera"][s], args.device) + t = data["timesteps"][s : s + 1].to(args.device) + for prefix, c in (("velocity", cond), ("velocity_negative", neg)): + v = model(x, t, c) + rows[prefix].append(v["latent"][0].float().cpu()) + rows[prefix + "_camera"].append(v["camera"][0, 0].float().cpu()) + save_file({k + "_f32": torch.stack(v).contiguous() for k, v in rows.items()}, str(case_dir / "exact.safetensors")) + print(json.dumps({"steps": len(rows["velocity"])})) + return 0 + + +def main(argv: list[str]) -> int: + ap = argparse.ArgumentParser(description=__doc__, epilog=USAGE, formatter_class=argparse.RawDescriptionHelpFormatter) + sub = ap.add_subparsers(dest="cmd", required=True) + for name in ("case", "blocks", "exact"): + p = sub.add_parser(name) + p.add_argument("weights") + p.add_argument("sdk") + p.add_argument("out_dir" if name == "case" else "case_dir") + p.add_argument("--device", default="mps", choices=("mps", "cpu", "cuda")) + if name == "case": + given = p.add_mutually_exclusive_group(required=True) + given.add_argument("--features", nargs="+") + given.add_argument("--synthetic-conditioning", action="store_true") + p.add_argument("--cond-seed", type=int, default=0) + p.add_argument("--seed", type=int, default=42) + p.add_argument("--steps", type=int, default=50) + p.add_argument("--cfg", type=float, default=3.0) + p.add_argument("--rescale-t", type=float, default=3.0) + elif name == "blocks": + p.add_argument("--step", type=int, default=0) + else: + p.add_argument("--steps", type=int, default=50) + args = ap.parse_args(argv) + return {"case": case, "blocks": blocks, "exact": exact}[args.cmd](args) + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/tools/zig/qwen27_http_gate.py b/tools/zig/qwen27_http_gate.py index 9c80e3b5ef6..3d7e08f2c22 100644 --- a/tools/zig/qwen27_http_gate.py +++ b/tools/zig/qwen27_http_gate.py @@ -21,8 +21,8 @@ def check(reply, ids, tokens, drafted): if runtime["token_sha"] != digest or runtime["drafts"] is not drafted: raise ValueError("served token SHA or draft mode differs from CLI") speculative = reply["speculative"] - if drafted and (speculative["rounds"] <= 0 or speculative["drafted"] <= 0): - raise ValueError("drafted server request did not exercise draft verification") + if drafted and (speculative["rounds"] <= 0 or speculative["drafted"] <= 0 or speculative["accepted"] <= 0): + raise ValueError("drafted server request did not exercise draft verification (no draft proposed or accepted)") return {"token_sha": digest, "drafts": drafted, "usage": usage, "runtime": runtime, "speculative": speculative} diff --git a/web/tensorfold_web/bench_stream.py b/web/tensorfold_web/bench_stream.py index 0881437310a..a1e2df42c02 100644 --- a/web/tensorfold_web/bench_stream.py +++ b/web/tensorfold_web/bench_stream.py @@ -67,12 +67,16 @@ def _stream(client: httpx.Client, url: str, headers: dict, body: dict, cancel: t rep.end_at = time.perf_counter() return buf = "" + trailing_cr = False for chunk in r.iter_text(): if cancel.is_set(): rep.error = "cancelled" break - # normalised on what has gathered, not chunk by chunk: a CRLF can arrive split between two chunks - buf = (buf + chunk).replace("\r\n", "\n") + # A CR already ended its line, so skip the LF if its CRLF arrived in two chunks. + if trailing_cr: + chunk = chunk.removeprefix("\n") + trailing_cr = chunk.endswith("\r") + buf += chunk.replace("\r\n", "\n").replace("\r", "\n") while "\n\n" in buf: event, buf = buf.split("\n\n", 1) data = "\n".join(line[5:].strip() for line in event.split("\n") if line.startswith("data:")) diff --git a/web/tensorfold_web/conversations.py b/web/tensorfold_web/conversations.py index 0e6fda0d1f0..6ce1aafacc0 100644 --- a/web/tensorfold_web/conversations.py +++ b/web/tensorfold_web/conversations.py @@ -142,8 +142,8 @@ def _db(self) -> sqlite3.Connection: def create(self, body: object) -> dict: fields = validate(body) now = time.time() - doc = {"id": uuid.uuid4().hex[:12], "created": now, "updated": now, "messages": fields.get("messages", []), - "settings": fields.get("settings", {}), "title": fields.get("title"), "rev": 1} + doc = {"id": uuid.uuid4().hex[:12], "created": now, "updated": now, "messages": [], "settings": {}, + "title": None, **fields, "rev": 1} with self._lock, self._db() as db: db.execute("insert into conversations (id, created, updated, title, doc) values (?,?,?,?,?)", (doc["id"], now, now, doc["title"], json.dumps(doc))) diff --git a/web/tensorfold_web/data/native-version.json b/web/tensorfold_web/data/native-version.json index 62489a58e78..204b54e293b 100644 --- a/web/tensorfold_web/data/native-version.json +++ b/web/tensorfold_web/data/native-version.json @@ -1 +1 @@ -{"version":"1.2.4"} +{"version":"1.2.10"} diff --git a/web/tensorfold_web/engine.py b/web/tensorfold_web/engine.py index 1c131c2c98a..3ec69d3e17b 100644 --- a/web/tensorfold_web/engine.py +++ b/web/tensorfold_web/engine.py @@ -287,7 +287,7 @@ def target(self) -> tuple[int, str, str | None]: """The generation, address and key, read together.""" with self.target_lock: - return self.generation, self.settings.engine_url.rstrip("/"), self.key_in_use() + return self.generation, settings_mod.engine_root(self.settings.engine_url), self.key_in_use() def retargeted(self) -> None: """The address or the key changed (the caller holds ``target_lock``): readings begun before are not used.""" @@ -319,7 +319,9 @@ def say(line: str, **kw: bool) -> None: if size > 1024**2: # only the tail: the file may be up to LOG_MAX_BYTES f.seek(size - 1024**2) f.readline() # from the next whole line - for line in f.read().split("\n")[:-1][-LOG_LINES:]: + replayed = f.read().split("\n") + buf = replayed.pop() + for line in replayed[-LOG_LINES:]: say(_redrawn(line), earlier=True) say(f"[web] found the engine a previous TensorFold Web started (pid {child.pid}); it kept running") elif f is not None: @@ -344,6 +346,7 @@ def say(line: str, **kw: bool) -> None: # POSIX O_APPEND permits truncation; review inherited offsets before supporting Windows engines. if os.path.getsize(log) > LOG_MAX_BYTES: os.truncate(log, 0) + buf = "" f.seek(0) time.sleep(0.2) if f is not None: diff --git a/web/tensorfold_web/engines.py b/web/tensorfold_web/engines.py index a9186c3dad7..1fbbf73f946 100644 --- a/web/tensorfold_web/engines.py +++ b/web/tensorfold_web/engines.py @@ -7,7 +7,7 @@ import httpx from . import native -from .settings import Settings +from .settings import Settings, engine_root @dataclass @@ -108,7 +108,7 @@ def _json(client: httpx.Client, url: str, headers: dict) -> dict | None: def identify(url: str, *, key: str | None = None, client: httpx.Client | None = None) -> Endpoint: - base = url.rstrip("/").removesuffix("/v1") + base = engine_root(url) headers = {"Authorization": f"Bearer {key}"} if key else {} own = client or httpx.Client(trust_env=False, timeout=3.0) try: diff --git a/web/tensorfold_web/recipes.py b/web/tensorfold_web/recipes.py index 877a7e312a7..9b4b12a42a5 100644 --- a/web/tensorfold_web/recipes.py +++ b/web/tensorfold_web/recipes.py @@ -6,10 +6,11 @@ import shlex import time from dataclasses import dataclass, field +from threading import Event import httpx -from . import httpread +from . import bench, httpread KINDS = {"chat": "Chat front ends", "agent": "Coding agents", "assistant": "Personal agents", "sdk": "Code"} CHECK_LABELS = { @@ -350,10 +351,10 @@ def run_check(check: str, c: Ctx, client: httpx.Client, extra: dict | None = Non if check == "chat_stream": body = {"model": c.model, "stream": True, "max_tokens": 256, "messages": [{"role": "user", "content": "Reply with the word ready."}]} - with client.stream("POST", base + "/v1/chat/completions", json=body, headers=_headers(c.key)) as r: - if r.status_code != 200: # at most 4 KB and 10 s of it: an error that trickles ends here - return _out(check, False, f"{r.status_code}: {httpread.error_text(r)[:160]}", t0) - text, _ = _stream_text(r) + reply = bench.stream_once(client, base + "/v1/chat/completions", _headers(c.key), body, Event()) + if reply.error: + return _out(check, False, reply.error[:200], t0) + text = reply.text + reply.reasoning return _out(check, bool(text.strip()), f"{len(text)} characters streamed" if text else "an empty reply", t0) if check == "tool_call": body = {"model": c.model, "max_tokens": 1024, "tool_choice": "auto", diff --git a/web/tensorfold_web/replay.py b/web/tensorfold_web/replay.py index b5f6a24da1f..5461a5cac95 100644 --- a/web/tensorfold_web/replay.py +++ b/web/tensorfold_web/replay.py @@ -52,7 +52,7 @@ def _start(self, cid: str, target: dict) -> dict: if not isinstance(target.get("url"), str) or not target.get("model"): raise ValueError("another engine needs its address and a model") # a user or password in the address would be kept in the replay's title, settings and exports - url = settings_mod._engine_url(target["url"]).removesuffix("/v1") + url = settings_mod.engine_root(settings_mod._engine_url(target["url"])) target = {**target, "url": url} base, key, model, engine = url, target.get("key") or None, target["model"], target.get("label") or url else: @@ -136,6 +136,9 @@ def _go(self, rid: str, rev: int, src: dict, base: str, key: str | None, model: self.current.update(turn=i, question=m["content"][:2000], live_text="", live_reasoning="") rep = bench.stream_once(client, base + "/v1/chat/completions", headers, body, self._cancel, on_text=self._show) + if rep.error == "cancelled": + self.current["status"] = "cancelled" + break mm = bench.measure(rep) outcome = "error" if rep.error else "length" if rep.finish == "length" else "done" out += [{"role": "user", "content": m["content"], "turn": i}, diff --git a/web/tensorfold_web/server.py b/web/tensorfold_web/server.py index 32129cc4f42..edf669eafec 100644 --- a/web/tensorfold_web/server.py +++ b/web/tensorfold_web/server.py @@ -96,7 +96,7 @@ def create_app(*, settings: settings_mod.Settings | None = None, engine: Engine dl = Downloads() - proxy = Proxy(lambda: s.engine_url, eng.key_in_use, target=lambda: eng.target()[1:]) + proxy = Proxy(lambda: settings_mod.engine_root(s.engine_url), eng.key_in_use, target=lambda: eng.target()[1:]) def bench_target() -> tuple[str, str | None, str | None]: h = eng.status() @@ -104,7 +104,7 @@ def bench_target() -> tuple[str, str | None, str | None]: if h.status == "running": # a bare /health behind a key names no model: /v1/models does model = h.model or next(iter(engines.identify(s.engine_url, key=eng.key_in_use()).models), None) - return s.engine_url.rstrip("/").removesuffix("/v1"), eng.key_in_use(), model + return settings_mod.engine_root(s.engine_url), eng.key_in_use(), model runner = bench.Bench(bench_store or bench.Store(settings_mod.config_dir() / "bench.sqlite"), bench_target) @@ -410,7 +410,7 @@ def lesson_target() -> living.Target: h = eng.status() if h.status != "running" or not served_copy(): raise RuntimeError("serve a living copy first (Teach, then Serve)") - base = s.engine_url.rstrip("/").removesuffix("/v1") + base = settings_mod.engine_root(s.engine_url) return living.Target(base, eng.key_in_use(), h.model or eng.model or "") # left halfway by a stopped TensorFold Web @@ -470,7 +470,7 @@ def settled(name: str) -> None: def engine_get(path: str) -> httpx.Response: key = eng.key_in_use() - return httpx.get(trust_env=False, url=s.engine_url.rstrip("/").removesuffix("/v1") + path, timeout=10.0, + return httpx.get(trust_env=False, url=settings_mod.engine_root(s.engine_url) + path, timeout=10.0, headers={"Authorization": f"Bearer {key}"} if key else {}) def no_store(resp: Response) -> Response: diff --git a/web/tensorfold_web/server_connect.py b/web/tensorfold_web/server_connect.py index 6b64f6f4c04..be96ef2b60a 100644 --- a/web/tensorfold_web/server_connect.py +++ b/web/tensorfold_web/server_connect.py @@ -20,6 +20,7 @@ connect_ctx, lan_hostname, ) +from .settings import engine_root def install(app, eng, s, token) -> None: @@ -27,7 +28,8 @@ def install(app, eng, s, token) -> None: def connect(where: str = "here", relay: str = ""): h = eng.last_health or eng.health() - c = connect_ctx(s.engine_url, h.model if h else None, share=s.share, api_key=eng.key_in_use()) + root = engine_root(s.engine_url) + c = connect_ctx(root, h.model if h else None, share=s.share, api_key=eng.key_in_use()) if where == "away": u = urlsplit(relay) # a name or address and a port, nothing else: the recipes paste it into a shell @@ -38,10 +40,10 @@ def connect(where: str = "here", relay: str = ""): c = recipes.Ctx(base=base, key=s.api_key or eng.key_in_use() or "YOUR-KEY", model=c.model, docker_base=base, away=True) # asked of the engine itself (on its own address): a coding agent needs a long window, and its recipe says so - window = recipes.served_window(recipes.Ctx(base=s.engine_url.rstrip("/").removesuffix("/v1"), + window = recipes.served_window(recipes.Ctx(base=root, key=eng.key_in_use() or "local", model=c.model)) \ if h and h.status == "running" else None - return {"engine_url": s.engine_url, "share": s.share, + return {"engine_url": root, "share": s.share, "lan_url": f"http://{lan_hostname()}:{s.engine_port()}" if s.share else None, # the key that opens the engine now; a new one waiting for the restart is not copied before it works "api_key": eng.key_in_use(), "key_pending_restart": eng.key_pending_restart(), @@ -62,13 +64,13 @@ def connect_test(body: dict[str, Any]): if h.status != "running": raise HTTPException(409, "no model is being served; start one from Models") model = h.model or next(iter(engines.identify(s.engine_url, key=eng.key_in_use()).models), None) - c = recipes.Ctx(base=s.engine_url.rstrip("/").removesuffix("/v1"), key=eng.key_in_use() or "local", + c = recipes.Ctx(base=engine_root(s.engine_url), key=eng.key_in_use() or "local", model=model or "") return recipes.test(rec, c) @app.get("/api/connect/compose/open-webui") def connect_compose(): h = eng.last_health or eng.health() - c = connect_ctx(s.engine_url, h.model if h else None, share=s.share, api_key=eng.key_in_use()) + c = connect_ctx(engine_root(s.engine_url), h.model if h else None, share=s.share, api_key=eng.key_in_use()) return Response(recipes.compose(c), media_type="text/yaml", headers={"Content-Disposition": 'attachment; filename="docker-compose.yml"'}) diff --git a/web/tensorfold_web/server_engine.py b/web/tensorfold_web/server_engine.py index 8f1ece2e637..155adb80954 100644 --- a/web/tensorfold_web/server_engine.py +++ b/web/tensorfold_web/server_engine.py @@ -87,7 +87,7 @@ def access(request: Request): open_without_key = None if not engine_local: # does the engine answer anyone, without its key? try: - r = httpx.get(trust_env=False, url=s.engine_url.rstrip("/") + "/v1/models", timeout=2.0) + r = httpx.get(trust_env=False, url=settings_mod.engine_root(s.engine_url) + "/v1/models", timeout=2.0) open_without_key = r.status_code == 200 except httpx.HTTPError: open_without_key = None diff --git a/web/tensorfold_web/server_lessons.py b/web/tensorfold_web/server_lessons.py index 292d6aab35e..020e67e4b5a 100644 --- a/web/tensorfold_web/server_lessons.py +++ b/web/tensorfold_web/server_lessons.py @@ -16,6 +16,7 @@ living_versions, ) from .gate import Busy +from .settings import engine_root def install(app, cat, chore, chore_cancel, chore_lock, copy_name, creating, eng, gate, launch, lesson_target, run_chore, s, served_copy, teacher, wait_running) -> None: @@ -241,7 +242,7 @@ def living_facts(name: str): graph: dict = {} if served_copy() == name: try: - r = httpx.get(trust_env=False, url=s.engine_url.rstrip("/").removesuffix("/v1") + "/v1/slide/graph", timeout=5.0, + r = httpx.get(trust_env=False, url=engine_root(s.engine_url) + "/v1/slide/graph", timeout=5.0, headers={"Authorization": f"Bearer {eng.key_in_use()}"} if eng.key_in_use() else {}) graph = r.json() if r.status_code == 200 else {} except (httpx.HTTPError, ValueError): diff --git a/web/tensorfold_web/service.py b/web/tensorfold_web/service.py index b041f048d98..4cbe405c8bf 100644 --- a/web/tensorfold_web/service.py +++ b/web/tensorfold_web/service.py @@ -79,7 +79,7 @@ def _path_env() -> str: def plan(*, port: int = 8090, host: str = "127.0.0.1", token_file: Path | None = None) -> Plan: conf = settings_mod.config_dir() - token_file = token_file or conf / "web-token" + token_file = token_file.absolute() if token_file is not None else conf / "web-token" cmd = [*studio_command(), "--no-browser", "--token-file", str(token_file)] if port != 8090: cmd += ["--port", str(port)] diff --git a/web/tensorfold_web/settings.py b/web/tensorfold_web/settings.py index eb66a3d7b46..9024acc9eb0 100644 --- a/web/tensorfold_web/settings.py +++ b/web/tensorfold_web/settings.py @@ -23,6 +23,17 @@ def config_dir() -> Path: return Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "tensorfold-web" +def engine_root(url: str) -> str: + """Accept an OpenAI API base URL while keeping the server's reverse-proxy prefix.""" + + with contextlib.suppress(ValueError): + parts = urlsplit(url) + path = parts.path.rstrip("/") + if parts.scheme in ("http", "https") and parts.netloc and path.endswith("/v1"): + return parts._replace(path=path.removesuffix("/v1")).geturl() + return url.rstrip("/") + + @dataclass class Settings: engine_url: str = DEFAULT_ENGINE @@ -151,6 +162,8 @@ def load() -> Settings: data = json.loads(path().read_text()) except (OSError, ValueError): return Settings() + if not isinstance(data, dict): + return Settings() return Settings(**{k: v for k, v in data.items() if k in Settings.__dataclass_fields__}) diff --git a/web/tensorfold_web/storage.py b/web/tensorfold_web/storage.py index 47832424e3b..0db48b62611 100644 --- a/web/tensorfold_web/storage.py +++ b/web/tensorfold_web/storage.py @@ -76,24 +76,26 @@ def clean(conf: Path, kind: str, older_than_days: float | None, *, dry_run: bool return {"kind": kind, "matched": 0, "removed": 0, "dry_run": dry_run} where, args = _where(k, cutoff) with _connect(p) as db: + if k.id == "bench" and not dry_run: + db.execute("begin immediate") if k.id == "conversations": # a pin lives in the document: a pinned conversation is kept kept = [i for i, doc in db.execute(f"select id, doc from conversations{where}", args) if not _pinned(doc)] n = len(kept) else: n = db.execute(f"select count(*) from {k.table}{where}", args).fetchone()[0] - removed = 0 - if not dry_run and n: + removed = series_removed = 0 + if not dry_run and (n or (k.id == "bench" and cutoff is None)): if k.id == "bench": - ids = [r[0] for r in db.execute(f"select id from runs{where}", args)] + ids = None if cutoff is None else {r[0] for r in db.execute(f"select id from runs{where}", args)} removed = db.execute(f"delete from runs{where}", args).rowcount - _drop_series_of(db, set(ids)) + series_removed = _drop_empty_series(db, ids) elif k.id == "conversations": removed = db.executemany("delete from conversations where id = ?", [(i,) for i in kept]).rowcount else: removed = db.execute(f"delete from {k.table}{where}", args).rowcount if k.id == "usage" and cutoff is None: db.execute("delete from state") # the baseline goes too: the next reading starts afresh - if removed: + if removed or series_removed: with sqlite3.connect(p, timeout=10) as db: db.execute("vacuum") # give the space back return {"kind": kind, "matched": n, "removed": removed, "dry_run": dry_run} @@ -106,17 +108,25 @@ def _pinned(doc: str) -> bool: return False -def _drop_series_of(db: sqlite3.Connection, run_ids: set[str]) -> None: - """A comparison series is kept while one of its runs is; one whose runs all went goes too.""" +def _drop_empty_series(db: sqlite3.Connection, deleted_ids: set[str] | None) -> int: + """Remove finished comparisons with no retained runs, limited to affected comparisons for age cleanup.""" try: rows = db.execute("select id, doc from series").fetchall() except sqlite3.Error: - return - for sid, doc in rows: - runs = [r for r in (json.loads(doc).get("runs") or []) if r] - if runs and all(r in run_ids for r in runs): - db.execute("delete from series where id = ?", (sid,)) + return 0 + retained_ids = {r[0] for r in db.execute("select id from runs")} + removed = 0 + for sid, raw in rows: + doc = json.loads(raw) + runs = [r for r in (doc.get("runs") or []) if r] + if not runs or doc.get("status") == "running": + continue + if deleted_ids is not None and deleted_ids.isdisjoint(runs): + continue + if retained_ids.isdisjoint(runs): + removed += db.execute("delete from series where id = ?", (sid,)).rowcount + return removed # -- models in the Hugging Face cache --------------------------------------------------------------------------------- diff --git a/web/tests/test_bench.py b/web/tests/test_bench.py index 1b0cd2da6b1..3df07d3e833 100644 --- a/web/tests/test_bench.py +++ b/web/tests/test_bench.py @@ -435,6 +435,28 @@ def test_stream_errors_and_cut_streams_are_not_successes(events, error): assert (rep.error is None) if error is None else (error in rep.error) +def test_stream_mixed_line_endings_do_not_split_json_text(): + import json + import threading + + import httpx + + text = "first\u0085second\u2028third\u2029fourth" + event = json.dumps({"choices": [{"delta": {"content": text}}]}, ensure_ascii=False).encode() + + class Stream(httpx.SyncByteStream): + def __iter__(self): + yield b"data: " + event + b"\r" + yield b"\n\r" + yield b"\ndata: [DONE]\r\r" + raise AssertionError("the reader requested bytes after DONE") + + transport = httpx.MockTransport(lambda _r: httpx.Response(200, stream=Stream())) + with httpx.Client(transport=transport) as client: + reply = bench.stream_once(client, "http://engine/v1/chat/completions", {}, {}, threading.Event()) + assert reply.text == text and reply.error is None + + def test_an_engine_elsewhere_is_judged_by_its_address(): import socket diff --git a/web/tests/test_conversations.py b/web/tests/test_conversations.py index 70b1463d62a..d34777328ae 100644 --- a/web/tests/test_conversations.py +++ b/web/tests/test_conversations.py @@ -181,6 +181,33 @@ def fake_stream(*_a, **_k): +@pytest.mark.parametrize(("fields", "expected"), [ + ({"pinned": True, "folder": " Work "}, {"pinned": True, "folder": "Work"}), + ({"pinned": False, "folder": None}, {"pinned": False, "folder": None}), + ({}, {}), +]) +def test_conversation_creation_keeps_optional_organization_fields(tmp_path, fields, expected): + from fastapi import FastAPI + + from tensorfold_web import server_chat + + app = FastAPI() + server_chat.install(app, conversations.Conversations(tmp_path / "chat.sqlite"), None, None) + with TestClient(app) as client: + response = client.post("/api/conversations", json={"title": "Planning", **fields}) + assert response.status_code == 200 + created = response.json() + stored = client.get(f"/api/conversations/{created['id']}").json() + row = client.get("/api/conversations").json()["conversations"][0] + folders = client.get("/api/conversation-folders").json()["folders"] + + for doc in (created, stored): + assert {key: doc[key] for key in ("pinned", "folder") if key in doc} == expected + assert doc["title"] == "Planning" and doc["rev"] == 1 + assert row["pinned"] is expected.get("pinned", False) and row["folder"] == expected.get("folder") + assert folders == ([{"name": "Work", "count": 1}] if expected.get("folder") else []) + + def test_pins_and_folders(tmp_path): from tensorfold_web.conversations import Conversations diff --git a/web/tests/test_engine_base_url.py b/web/tests/test_engine_base_url.py new file mode 100644 index 00000000000..c83d9093301 --- /dev/null +++ b/web/tests/test_engine_base_url.py @@ -0,0 +1,61 @@ +import json + +import httpx +import pytest +from fastapi import FastAPI +from fastapi.testclient import TestClient + +from tensorfold_web import engine, gate, recipes, server_connect, server_settings, settings + + +@pytest.mark.parametrize("source", ["settings-api", "saved-on-disk"]) +@pytest.mark.parametrize(("address", "prefix"), [ + ("http://fixture.test/proxy", "/proxy"), + ("http://fixture.test/proxy/v1/", "/proxy"), + ("http://fixture.test/proxy/v1/v1", "/proxy/v1"), +]) +def test_compatible_engine_address_may_end_in_v1(tmp_path, monkeypatch, source, address, prefix): + def respond(request): + if request.url.path == prefix + "/health": + return httpx.Response(200, json={"status": "ok"}) + if request.url.path == prefix + "/v1/models": + return httpx.Response(200, json={"data": [{"id": "fixture"}]}) + return httpx.Response(404) + + monkeypatch.setattr(settings, "config_dir", lambda: tmp_path) + if source == "saved-on-disk": + settings.path().write_text(json.dumps({"engine_url": address, "remote": True})) + cfg = settings.load() + eng = engine.Engine(cfg) + eng._client.close() + eng._client = httpx.Client(transport=httpx.MockTransport(respond)) + try: + monkeypatch.setattr(recipes, "served_window", lambda _: None) + app = FastAPI() + server_settings.install(app, eng, gate.Gate(), cfg, lambda: settings.save(cfg), cfg.to_dict) + server_connect.install(app, eng, cfg, None) + with TestClient(app) as client: + if source == "settings-api": + saved = client.put("/api/settings", json={"engine_url": address, "remote": True}) + assert saved.status_code == 200 + assert settings.load().engine_url == (address.rstrip("/") if source == "settings-api" else address) + health = eng.health() + connect = client.get("/api/connect").json() + root = "http://fixture.test" + prefix + assert connect["engine_url"] == root + jan = next(r for r in connect["snippets"] if r["id"] == "jan") + assert (health.status, health.model, jan["snippet"].splitlines()[1]) == ( + "running", "fixture", "Base URL " + root + "/v1" + ) + finally: + eng._client.close() + + +@pytest.mark.parametrize(("address", "expected"), [ + ("http://v1", "http://v1"), + ("http://v1/v1/", "http://v1"), + ("https://fixture.test/proxy/v10", "https://fixture.test/proxy/v10"), + ("https://[::1]:8080/proxy/v1", "https://[::1]:8080/proxy"), +]) +def test_engine_url_normalizes_the_api_path_without_changing_the_authority(address, expected): + assert settings.engine_root(address) == expected diff --git a/web/tests/test_engine_survives.py b/web/tests/test_engine_survives.py index 6541bb8a0d6..f7ee5737669 100644 --- a/web/tests/test_engine_survives.py +++ b/web/tests/test_engine_survives.py @@ -112,3 +112,51 @@ def test_a_kill_after_a_stop_that_took_too_long_is_a_stop_too(tmp_path): popen.kill() eng._pump(child, log, False) assert popen.returncode == -9 and eng.exit_code == 0 and eng.status().status != "failed" + + +@pytest.mark.parametrize(("initial", "appended", "expected", "tokens"), [ + ("", "new\n", ["new"], None), + ("old\n", "new\n", ["old", "new"], None), + ("ready\n[tensorfold] context window ", "32,768 tokens\n", + ["ready", "[tensorfold] context window 32,768 tokens"], 32768), +]) +def test_replay_keeps_unfinished_line(tmp_path, initial, appended, expected, tokens): + eng = Engine(Settings()) + log = tmp_path / "engine.log" + log.write_text(initial, encoding="utf-8") + + class Child: + pid, popen, returncode = 101, None, 0 + + def alive(self): + with log.open("a", encoding="utf-8") as writer: + writer.write(appended) + return False + + eng.proc = Child() + eng._pump(eng.proc, log, replay=True) + assert [line.split(" ", 1)[1] for line in eng.log if "[web]" not in line] == expected + assert eng.startup.get("context_tokens") == tokens + + +def test_log_truncation_discards_replayed_partial_line(tmp_path, monkeypatch): + eng = Engine(Settings()) + log = tmp_path / "engine.log" + log.write_text("unfinished old", encoding="utf-8") + monkeypatch.setattr(engine_mod, "LOG_MAX_BYTES", 1) + + class Child: + pid, popen, returncode = 101, None, 0 + calls = 0 + + def alive(self): + self.calls += 1 + if self.calls == 1: + return True + log.write_text("fresh\n", encoding="utf-8") + return False + + monkeypatch.setattr(engine_mod.time, "sleep", lambda _: None) + eng.proc = Child() + eng._pump(eng.proc, log, replay=True) + assert [line.split(" ", 1)[1] for line in eng.log if "[web]" not in line] == ["fresh"] diff --git a/web/tests/test_recipes.py b/web/tests/test_recipes.py index d651f1fcb06..d3d5a596d57 100644 --- a/web/tests/test_recipes.py +++ b/web/tests/test_recipes.py @@ -1,9 +1,13 @@ +import json import time +from types import SimpleNamespace +import httpx import pytest +from fastapi import FastAPI from fastapi.testclient import TestClient -from tensorfold_web import recipes +from tensorfold_web import recipes, server_connect from tensorfold_web import settings as settings_mod from tensorfold_web.catalog import Catalog from tensorfold_web.engine import Engine @@ -104,3 +108,48 @@ def test_the_new_agents_are_written_for_the_place_and_window(): assert 'primary: "tensorfold/Nemo"' in recipes.SNIPPETS["openclaw"](away) and "modelRoles" in recipes.SNIPPETS["omp"](away) kinds = {r.id: r.kind for r in recipes.RECIPES} assert kinds["openclaw"] == kinds["hermes"] == "assistant" and "continue" not in kinds + + +def _event(data): + return b"data: " + json.dumps(data).encode() + b"\n\n" + + +@pytest.mark.parametrize("case", ["failed", "truncated", "done", "finish-reason", "bare-cr"]) +def test_connect_probe_needs_a_successful_stream(monkeypatch, case): + partial = _event({"choices": [{"delta": {"content": "re"}, "finish_reason": None}]}) + closed = b"data: [DONE]\n\n" + finished = _event({"choices": [{"delta": {"content": "ady"}, "finish_reason": "stop"}]}) + error = _event({"error": {"message": "fixture decode stopped", "type": "server_error"}}) + tail, detail = { + "failed": (error + closed, "fixture decode stopped"), + "truncated": (b"", "before the engine finished"), + "done": (finished + closed, "5 characters streamed"), + "finish-reason": (finished, "5 characters streamed"), + "bare-cr": (finished + closed, "5 characters streamed"), + }[case] + + def respond(request): + if request.url.path == "/v1/models": + return httpx.Response(200, json={"data": [{"id": "fixture"}]}) + assert request.url.path == "/v1/chat/completions" + content = partial + tail + if case == "bare-cr": + content = content.replace(b"\n", b"\r") + return httpx.Response(200, content=content, headers={"Content-Type": "text/event-stream"}) + + client_type = httpx.Client + monkeypatch.setattr(recipes, "httpx", SimpleNamespace( + Client=lambda **kwargs: client_type(transport=httpx.MockTransport(respond), **kwargs), + Timeout=httpx.Timeout, + HTTPError=httpx.HTTPError, + )) + app = FastAPI() + engine = SimpleNamespace(status=lambda: SimpleNamespace(status="running", model="fixture"), key_in_use=lambda: None) + server_connect.install(app, engine, SimpleNamespace(engine_url="http://fixture.test"), None) + with TestClient(app) as client: + response = client.post("/api/connect/test", json={"recipe": "python"}) + assert response.status_code == 200 + result = response.json() + assert result["checks"][0]["ok"] + assert result["ok"] is result["checks"][1]["ok"] is (case in ("done", "finish-reason", "bare-cr")) + assert detail in result["checks"][1]["detail"] diff --git a/web/tests/test_replay.py b/web/tests/test_replay.py index 6f78feea520..0f4a5da403a 100644 --- a/web/tests/test_replay.py +++ b/web/tests/test_replay.py @@ -1,8 +1,14 @@ +import json +import threading import time +from types import SimpleNamespace +import httpx import pytest +from fastapi import FastAPI from fastapi.testclient import TestClient +from tensorfold_web import conversations, replay, server_chat from tensorfold_web import settings as settings_mod from tensorfold_web.catalog import Catalog from tensorfold_web.engine import Engine @@ -90,3 +96,66 @@ def test_a_replay_uses_the_settings_each_reply_was_written_with(tmp_path, monkey assert body["temperature"] == 0.0 and body["draft"] is False cur = client.get("/api/replay").json()["current"] # what a watching page read as it was written assert cur["turn"] == 0 and cur["question"] == "First question" and cur["live_text"] + + +def _reply_event(text): + msg = {"choices": [{"delta": {"content": text}, "finish_reason": None}]} + return f"data: {json.dumps(msg)}\n\n".encode() + + +class _PausedReply(httpx.SyncByteStream): + def __init__(self, waiting): + self.waiting = waiting + self.closed = threading.Event() + + def __iter__(self): + yield _reply_event("Partial reply") + self.waiting.set() + self.closed.wait(3) + + def close(self): + self.closed.set() + + +@pytest.mark.parametrize("completed", [0, 1]) +def test_stop_during_final_turn_keeps_only_completed_turns(tmp_path, monkeypatch, completed): + waiting = threading.Event() + calls = 0 + + def respond(request): + nonlocal calls + assert request.url.path == "/v1/chat/completions" + calls += 1 + if calls <= completed: + return httpx.Response(200, content=_reply_event("Completed reply") + b"data: [DONE]\n\n") + return httpx.Response(200, stream=_PausedReply(waiting)) + + monkeypatch.setattr(replay, "httpx", SimpleNamespace( + Client=lambda **kwargs: httpx.Client(transport=httpx.MockTransport(respond), **kwargs), + Timeout=httpx.Timeout, + )) + chats = conversations.Conversations(tmp_path / "chat.sqlite") + replays = replay.Replays(chats, lambda: ("http://fixture.test", None, "model", "engine")) + app = FastAPI() + server_chat.install(app, chats, None, replays) + client = TestClient(app) + messages = [] + for i in range(completed + 1): + messages.extend([{"role": "user", "content": f"Question {i}"}, + {"role": "assistant", "content": "Original"}]) + orig = client.post("/api/conversations", json={"messages": messages}).json() + run = client.post(f"/api/conversations/{orig['id']}/replay", json={}).json() + assert waiting.wait(3) + assert client.get("/api/replay").json()["current"]["live_text"] == "Partial reply" + assert client.post("/api/replay/cancel").json() == {"cancelling": True} + replays._thread.join(5) + progress = client.get("/api/replay").json() + saved = client.get(f"/api/conversations/{run['id']}").json() + assert not progress["busy"] + assert progress["current"]["status"] == "cancelled" + assert progress["current"]["done"] == completed + assert saved["settings"]["replay_status"] == "cancelled" + expected = [] + for i in range(completed): + expected.extend((f"Question {i}", "Completed reply")) + assert [message["content"] for message in saved["messages"]] == expected diff --git a/web/tests/test_service.py b/web/tests/test_service.py index 9ffc651e360..4c0c483e7d3 100644 --- a/web/tests/test_service.py +++ b/web/tests/test_service.py @@ -1,4 +1,5 @@ import plistlib +import shlex from pathlib import Path import pytest @@ -76,6 +77,35 @@ def test_macos_agent(home, monkeypatch): assert any(c[:2] == ("launchctl", "bootstrap") for c in calls) +@pytest.mark.parametrize("platform", ["linux", "macos"]) +def test_service_uses_callers_relative_token_path(home, monkeypatch, platform): + tmp, _, calls = home + caller = tmp / "invoking folder" + caller.mkdir() + fixture = caller / "fixture" + fixture.write_text("synthetic") + path = caller / "web token" + path.symlink_to(fixture.name) + monkeypatch.chdir(caller) + monkeypatch.setattr(service, "platform_name", lambda: platform) + + plan = service.plan(token_file=Path(path.name)) + assert plan.token_file == path + if platform == "macos": + doc = plistlib.loads(plan.content.encode()) + working_dir, args = doc["WorkingDirectory"], doc["ProgramArguments"] + else: + unit = dict(line.split("=", 1) for line in plan.content.splitlines() + if line.startswith(("WorkingDirectory=", "ExecStart="))) + working_dir, args = unit["WorkingDirectory"], shlex.split(unit["ExecStart"]) + emitted = Path(args[args.index("--token-file") + 1]) + assert emitted == path + assert Path(working_dir) == tmp + monkeypatch.chdir(working_dir) + assert emitted.read_text() == "synthetic" + assert not calls + + def test_other_platforms_refused(monkeypatch): monkeypatch.setattr(service, "platform_name", lambda: "win32") with pytest.raises(RuntimeError): diff --git a/web/tests/test_settings.py b/web/tests/test_settings.py index c5ae363bb12..440a8db1c41 100644 --- a/web/tests/test_settings.py +++ b/web/tests/test_settings.py @@ -1,11 +1,12 @@ +import pytest + +from tensorfold_web import settings def test_secret_files_are_private_from_the_first_byte(tmp_path, monkeypatch): import os import stat - from tensorfold_web import settings as settings_mod - created = [] real_open = os.open @@ -14,7 +15,25 @@ def spy(path, flags, mode=0o777, *a, **k): return real_open(path, flags, mode, *a, **k) monkeypatch.setattr(os, "open", spy) - settings_mod.write_private(tmp_path / "s.json", '{"api_key": "k"}') + settings.write_private(tmp_path / "s.json", '{"api_key": "k"}') assert created == [0o600] assert stat.S_IMODE((tmp_path / "s.json").stat().st_mode) == 0o600 assert not [p for p in tmp_path.iterdir() if p.name.endswith(".tmp")] + + +@pytest.mark.parametrize("raw", ["[]", "null", '"old settings"', "17", "false", "{"]) +def test_invalid_settings_root_uses_defaults_without_rewriting_file(tmp_path, monkeypatch, raw): + config = tmp_path / "settings.json" + config.write_text(raw, encoding="utf-8") + monkeypatch.setattr(settings, "path", lambda: config) + + assert settings.load() == settings.Settings() + assert config.read_text(encoding="utf-8") == raw + + +def test_load_keeps_known_fields_from_a_settings_object(tmp_path, monkeypatch): + config = tmp_path / "settings.json" + config.write_text('{"theme":"dark","unknown":true}', encoding="utf-8") + monkeypatch.setattr(settings, "path", lambda: config) + + assert settings.load() == settings.Settings(theme="dark") diff --git a/web/tests/test_storage.py b/web/tests/test_storage.py index 43218edf61e..8247842ad49 100644 --- a/web/tests/test_storage.py +++ b/web/tests/test_storage.py @@ -57,6 +57,45 @@ def test_dry_run_then_clean_bench_keeps_running_and_mixed_series(conf): assert {r[0] for r in db.execute("select id from series")} == {"s-mixed"} +def test_clean_bench_across_passes_preserves_active_and_unrelated_series(conf): + path = conf / "bench.sqlite" + with sqlite3.connect(path) as db: + series = { + "running": {"status": "running", "runs": ["old", "new", None]}, + "failed-before-run": {"status": "failed", "runs": [None, None]}, + "existing-orphan": {"status": "done", "runs": ["already-deleted"]}, + } + db.executemany("insert into series values (?, ?, ?)", + [(sid, NOW, json.dumps(doc)) for sid, doc in series.items()]) + + assert storage.clean(conf, "bench", 30, dry_run=False, now=NOW)["removed"] == 1 + with sqlite3.connect(path) as db: + assert {row[0] for row in db.execute("select id from series")} == {*series, "s-mixed"} + + assert storage.clean(conf, "bench", 1, dry_run=False, now=NOW)["removed"] == 1 + with sqlite3.connect(path) as db: + assert {row[0] for row in db.execute("select id from runs")} == {"older-running"} + assert {row[0] for row in db.execute("select id from series")} == set(series) + + +def test_clean_all_bench_repairs_an_orphan_when_no_runs_match(tmp_path): + path = tmp_path / "bench.sqlite" + bench.Store(path) + with sqlite3.connect(path) as db: + db.execute("create table series (id text primary key, created real not null, doc text not null)") + db.execute("insert into series values ('orphan', ?, ?)", + (NOW, json.dumps({"status": "done", "runs": ["already-deleted"]}))) + + preview = storage.clean(tmp_path, "bench", None, dry_run=True) + assert preview == {"kind": "bench", "matched": 0, "removed": 0, "dry_run": True} + with sqlite3.connect(path) as db: + assert db.execute("select id from series").fetchall() == [("orphan",)] + + assert storage.clean(tmp_path, "bench", None, dry_run=False) == {**preview, "dry_run": False} + with sqlite3.connect(path) as db: + assert db.execute("select id from series").fetchall() == [] + + def test_clean_everything_of_a_kind(conf): assert storage.clean(conf, "conversations", 30, dry_run=False, now=NOW)["removed"] == 1 assert storage.clean(conf, "usage", None, dry_run=False, now=NOW)["removed"] == 2 diff --git a/zig/build/checkpoint_io_host.zig b/zig/build/checkpoint_io_host.zig index 583d42f9b1e..4bba10bb4e9 100644 --- a/zig/build/checkpoint_io_host.zig +++ b/zig/build/checkpoint_io_host.zig @@ -13,6 +13,8 @@ pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget) void { .dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = core, .filters = &.{"part:"} })).step); if (mode == .debug) b.step("test-fp8-block-host", "The shared block-FP8 reader and exact scale widening (core/quant/fp8.zig)") .dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = core, .filters = &.{"fp8 block:"} })).step); + if (mode == .debug) b.step("test-gptq-reader-host", "The shared GPTQ reader on a synthetic checkpoint, against binary64 (core/quant/gptq.zig)") + .dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = core, .filters = &.{"gptq:"} })).step); const qwen = b.createModule(.{ .root_source_file = b.path("zig/src/families/qwen3_5/loader.zig"), .target = target, .optimize = mode, .link_libc = true, .imports = &.{.{ .name = "core", .module = core }} }); step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = qwen, .filters = &.{"Qwen shard integrity:"} })).step); } diff --git a/zig/build/cluster_host.zig b/zig/build/cluster_host.zig index a68cdf5f000..338029250c3 100644 --- a/zig/build/cluster_host.zig +++ b/zig/build/cluster_host.zig @@ -1,4 +1,4 @@ -//! The cluster's membership and bring-up over fake links, on the build host with no GPU. +//! Cluster membership, bring-up, and config validate on the build host with no GPU. const std = @import("std"); pub fn steps(b: *std.Build) void { @@ -8,5 +8,14 @@ pub fn steps(b: *std.Build) void { const canon = @import("cuda_engines.zig").canonModule(b, host, .debug); const bringup = b.createModule(.{ .root_source_file = b.path("zig/src/cluster/bringup.zig"), .target = host, .link_libc = true, .imports = &.{ .{ .name = "fabric", .module = fabric }, .{ .name = "canon", .module = canon } } }); const run = b.addRunArtifact(b.addTest(.{ .root_module = bringup })); - b.step("test-cluster-membership-host", "Cluster membership and bring-up over fake links, without a GPU").dependOn(&run.step); + const core = b.createModule(.{ .root_source_file = b.path("zig/src/core/root.zig"), .target = host, .link_libc = true }); + core.addImport("gpu_memory", @import("gpu_memory.zig").module(b, host)); + core.addImport("tokenizer", b.createModule(.{ .root_source_file = b.path("zig/src/core/tokenizer/tokenizer.zig"), .target = host, .link_libc = true })); + const validate = b.createModule(.{ .root_source_file = b.path("zig/src/cluster/validate.zig"), .target = host, .link_libc = true, .imports = &.{ .{ .name = "fabric", .module = fabric }, .{ .name = "canon", .module = canon }, .{ .name = "core", .module = core } } }); + const validate_run = b.addRunArtifact(b.addTest(.{ .root_module = validate, .filters = &.{"config validate:"} })); + const step = b.step("test-cluster-membership-host", "Cluster membership, bring-up, and config validate, without a GPU"); + step.dependOn(&run.step); + step.dependOn(&validate_run.step); + const exe = b.addExecutable(.{ .name = "tf-config-validate", .root_module = b.createModule(.{ .root_source_file = b.path("zig/src/cluster/validate_main.zig"), .target = host, .link_libc = true, .imports = &.{ .{ .name = "fabric", .module = fabric }, .{ .name = "canon", .module = canon }, .{ .name = "core", .module = core } } }) }); + b.step("tf-config-validate", "Validate a cluster.json without planning or probes").dependOn(&b.addInstallArtifact(exe, .{}).step); } diff --git a/zig/build/cuda.zig b/zig/build/cuda.zig index 2491b89e49b..711a1bfbab9 100644 --- a/zig/build/cuda.zig +++ b/zig/build/cuda.zig @@ -120,7 +120,7 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu for (exlr8_build.denseModules(b, target, optimize, exlr8, exlr8_tests[0])) |m| runner.addImport(m.name, m.module); runner.addImport("glm_cuda", glmCuda(b, target, optimize, cuda, mods.core, mods.lanes, mods.heat, mods.api)); @import("minimax_cuda.zig").targets(b, target, optimize, strip, cuda, mods.core, mods.lanes, runner); - for ([_]struct { []const u8, *std.Build.Module }{ .{ "kolibri1", kolibri1Module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "dory", @import("dory.zig").module(b, target, optimize, cuda, mods.core, mods.lanes) } }) |m| runner.addImport(m[0], m[1]); + for ([_]struct { []const u8, *std.Build.Module }{ .{ "kolibri1", kolibri1Module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "dory", @import("dory.zig").module(b, target, optimize, cuda, mods.core, mods.lanes) }, .{ "idol_cuda", @import("idol_cuda.zig").targets(b, target, optimize, strip, cuda, mods.core) } }) |m| runner.addImport(m[0], m[1]); runner.addImport("gemma4_cuda", @import("gemma4_cuda.zig").module(b, target, optimize, cuda, mods.core, mods.lanes)); runner.addImport("spark25", @import("spark25.zig").module(b, target, optimize, cuda, mods.core, mods.lanes)); runner.addImport("moss_image_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/moss_image/cuda_kernels.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{.{ .name = "cuda", .module = cuda }} })); diff --git a/zig/build/cuda_family_host.zig b/zig/build/cuda_family_host.zig index 3151f423d02..f96afd6fd21 100644 --- a/zig/build/cuda_family_host.zig +++ b/zig/build/cuda_family_host.zig @@ -19,6 +19,7 @@ pub fn steps(b: *std.Build, cuda: *std.Build.Module, mods: anytype, step: *std.B b.step("test-memory-pressure-host", "Shared memory-pressure governor, admission and cache shedding without devices").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.api, .filters = &.{"memory pressure:"} })).step); b.step("test-qwen35-shapes-host", "Captured window buckets for one and 2-8 rows without devices").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.qwen35, .filters = &.{"one-row and 2-8-row"} })).step); @import("minimax_cuda.zig").hostTests(b, host, cuda, mods.core, mods.lanes, step); + @import("idol_cuda.zig").hostTests(b, cuda, mods.core, step); @import("cuda_groups_host.zig").host(b, cuda, mods, step); const prefill = b.addRunArtifact(b.addTest(.{ .root_module = mods.qwen35, .filters = &.{ "Qwen stepped prefill:", "Qwen whole prefill:", "Qwen prefill opening:", "a yielded pass keeps its completed prefix" } })); b.step("test-qwen35-prefill-host", "Stepped, whole, opening and interrupted prompt lifecycle without devices").dependOn(&prefill.step); diff --git a/zig/build/cuda_kernels.zig b/zig/build/cuda_kernels.zig index b0a1e837b3c..2d63d3b0dbc 100644 --- a/zig/build/cuda_kernels.zig +++ b/zig/build/cuda_kernels.zig @@ -149,6 +149,7 @@ pub const kernels = [_]Kernel{ .{ .name = "glm_index", .flags = &.{"-O3"} }, // a prompt chunk's DSA scores and top-512 pools .{ .name = "minimax_m3", .flags = glue }, // ours: MiniMax-M3.1-Flash's glue (norms, RoPE prep, routing, DSpark, tower RoPE) .{ .name = "minimax_m3_attn", .flags = glue }, // ours: MiniMax-M3.1-Flash's indexer and block-sparse attention + .{ .name = "idol", .flags = glue }, // ours: Idol's denoiser glue and its fp16 head-64 attention .{ .name = "glm_quant", .flags = torch_ops }, // ours: GLM's draft-only weight quantizers, torch at load in the Python family .{ .name = "exl3_linear", .flags = &.{ "-O3", "--expt-relaxed-constexpr" } }, // exl3/linear.cu's device code, tensorfold_exl3_linear_v5 .{ .name = "exl3_experts", .flags = &.{ "-O3", "--expt-relaxed-constexpr" } }, // exl3/experts.cu's device code, tensorfold_exl3_experts diff --git a/zig/build/cuda_server_host.zig b/zig/build/cuda_server_host.zig index 7eb27628359..42986c3230d 100644 --- a/zig/build/cuda_server_host.zig +++ b/zig/build/cuda_server_host.zig @@ -68,6 +68,7 @@ pub fn steps(b: *std.Build, host: std.Build.ResolvedTarget, cuda: *std.Build.Mod media_gate.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.core, .filters = &.{ "qwen_vl", "video" } })).step); b.step("test-http-limits-host", "Total HTTP read deadlines and connection admission without shaders").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{"HTTP limits:"} })).step); b.step("test-server-recovery-host", "Incomplete replies, token allocation and bounded SSE storage without shaders").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{"Server recovery:"} })).step); + b.step("test-request-journal-host", "The request journal's records, rotation and crash quarantine on a fake engine").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{"request journal:"} })).step); b.step("test-prompt-interior-host", "Last-user metadata excludes later messages without shaders").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{"interior prompt:"} })).step); b.step("test-cors-template-host", "Exact CORS and special-preserving template route regressions").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{ "CORS", "apply-template:" } })).step); b.step("test-ocr-host", "OCR route readers, shared page steps and dialects without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{"ocr "} })).step); diff --git a/zig/build/drama3_host.zig b/zig/build/drama3_host.zig index 3c7c3262cc3..334f768f619 100644 --- a/zig/build/drama3_host.zig +++ b/zig/build/drama3_host.zig @@ -26,7 +26,7 @@ pub fn native(b: *std.Build, step: *std.Build.Step, family: *std.Build.Module, c if (family.import_table.get("metal")) |runtime| mod.addImport("metal", runtime); if (cuda) |c| mod.addImport("cuda", c); step.dependOn(&b.addObject(.{ .name = name, .root_module = mod }).step); - const tests = b.addTest(.{ .root_module = mod, .filters = &.{ "native silence guard:", "drama reference cache:", "drama admission:" } }); + const tests = b.addTest(.{ .root_module = mod, .filters = &.{ "native silence guard:", "drama reference cache:", "drama admission:", "drama voice encode:" } }); step.dependOn(&b.addRunArtifact(tests).step); } diff --git a/zig/build/glm_checks.zig b/zig/build/glm_checks.zig index facabb1be36..e18cf76b9a3 100644 --- a/zig/build/glm_checks.zig +++ b/zig/build/glm_checks.zig @@ -29,6 +29,94 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu "tf-glm-rows-speed", "GLM-5.3-Flash one-row decode products at the checkpoints' shapes: GPU time a launch, GB/s, a token by class", ).dependOn(&b.addInstallArtifact(speed, .{}).step); + const index = b.addExecutable(.{ .name = "tf-glm-index-speed", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_index_speed.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-index-speed", "GLM-5.3-Flash's decode indexer and sparse attention at long positions: GPU time a launch").dependOn(&b.addInstallArtifact(index, .{}).step); + const psel = b.addExecutable(.{ .name = "tf-glm-prompt-select", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_prompt_select.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-prompt-select", "GLM-5.3-Flash's prompt index scores and key lists at long positions, mark and merge against glm_index_select, bit for bit, GPU time").dependOn(&b.addInstallArtifact(psel, .{}).step); + const kda = b.addExecutable(.{ .name = "tf-glm-kda-speed", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_kda_speed.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + const mrows = b.addExecutable(.{ .name = "tf-glm-moe-rows", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_moe_rows.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-moe-rows", "GLM-5.3-Flash's decode experts of 1-16 rows at two and four outputs a simdgroup, bit for bit, GPU time").dependOn(&b.addInstallArtifact(mrows, .{}).step); + const arows = b.addExecutable(.{ .name = "tf-glm-attn-rows", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_attn_rows.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-attn-rows", "GLM-5.3-Flash's dense latent attention of a window's rows in three launches against each row's own, bit for bit, GPU time").dependOn(&b.addInstallArtifact(arows, .{}).step); + const hrows = b.addExecutable(.{ .name = "tf-glm-hc-rows", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_hc_rows.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-hc-rows", "GLM-5.3-Flash's hyper-connection boundary of a decode window, the expand's parts on six threadgroups against one, bit for bit, GPU time").dependOn(&b.addInstallArtifact(hrows, .{}).step); + const route_one = b.addExecutable(.{ .name = "tf-glm-route-one", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_route_one.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-route-one", "GLM-5.3-Flash's router and indexer-gate logits of a one-row window against tf_route_logits, bit for bit, GPU time").dependOn(&b.addInstallArtifact(route_one, .{}).step); + const route_sel = b.addExecutable(.{ .name = "tf-glm-route-select", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_route_select.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-route-select", "GLM-5.3-Flash's route select of 1-16 rows against the kept reference kernel, byte for byte, GPU time").dependOn(&b.addInstallArtifact(route_sel, .{}).step); + const norms = b.addExecutable(.{ .name = "tf-glm-mla-norms", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_mla_norms.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine }, .{ .name = "kernel_sources", .module = sources } }, + }) }); + b.step("tf-glm-mla-norms", "GLM-5.3-Flash's MLA key norm, indexer key norm and indexer weights in one launch against the kept kernels, bit for bit, GPU time").dependOn(&b.addInstallArtifact(norms, .{}).step); + const pick = b.addExecutable(.{ .name = "tf-glm-moe-pick", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_moe_pick.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-moe-pick", "GLM-5.3-Flash's one-row experts with the route select replayed in the gate/up groups against the select launch, byte for byte, GPU time").dependOn(&b.addInstallArtifact(pick, .{}).step); + b.step("tf-glm-kda-speed", "GLM-5.3-Flash's fused KDA decode step: the window kernel against kda_rows bit for bit, GPU time").dependOn(&b.addInstallArtifact(kda, .{}).step); + const mgroups = b.addExecutable(.{ .name = "tf-glm-mm-groups", .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/glm_mm_groups.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "tensorfold", .module = engine } }, + }) }); + b.step("tf-glm-mm-groups", "GLM-5.3-Flash's prompt experts and dense products in column groups against core/affine_mm.zig's, bit for bit, GPU time").dependOn(&b.addInstallArtifact(mgroups, .{}).step); } /// tf-glm-sample-check and test-glm-sampling: the real GLM sampler against its host reference, no checkpoint. diff --git a/zig/build/hip.zig b/zig/build/hip.zig index 7d0da890b63..558f908831a 100644 --- a/zig/build/hip.zig +++ b/zig/build/hip.zig @@ -168,6 +168,7 @@ pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil native_ocr.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.native.import_table.get("glm_ocr").?, .filters = &.{"GLM-OCR native admission:"} })).step); b.step("test-hip-family-offers-host", "HIP optional native family metadata without device execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.native, .filters = &.{"HIP optional family offers:"} })).step); b.step("test-hip-native-options-host", "Shared HIP native open settings without device execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.serve, .filters = &.{"HIP native options:"} })).step); + @import("hip_followers.zig").steps(b, &.{ host.serve, host.flashnext, host.nemotron }); @import("dots_mocr.zig").hipTests(b, host.hip, test_step); b.step("test-dots-native-host", "dots.mocr registry, reasoning, and unsupported flags without GPU execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.native, .filters = &.{ "dots refuses", "every registered family", "a HIP family declares replies without reasoning" } })).step); @import("lighton_hip.zig").host(b, host.lighton, test_step); @@ -543,7 +544,6 @@ pub fn kernelObjects(b: *std.Build, hipcc: []const u8, hipcc_resolved: []const u } return b.createModule(.{ .root_source_file = files.add("kernels.zig", b.fmt("pub const arch = \"{s}\";\n{s}pub const images = [_][]align(8) const u8{{ {s}}};\n", .{ arch, decls, refs })) }); } - /// The HIP compiler as the build found it, the device bitcode it links, and whether gfx1100 relaxes branches earlier. pub const Hipcc = struct { name: []const u8, resolved: []const u8, device_lib: ?[]const u8, relax_branches: bool = false }; diff --git a/zig/build/hip_followers.zig b/zig/build/hip_followers.zig new file mode 100644 index 00000000000..df1cf2cef1a --- /dev/null +++ b/zig/build/hip_followers.zig @@ -0,0 +1,17 @@ +//! The HIP followers' step parsers: what rank 0 sends a rank above it, taken or refused (#3042, #3081), no device. +const std = @import("std"); + +/// Tests by name: the shared loop's and each family worker's step parsers, and the sender they pair with. +pub const parsers = [_][]const u8{ + "security: a step from the link", // protocol.zig and flashnext/hip/worker.zig (#3042) + "security: rank 0's page and slot", // protocol.zig's bounds the Nemotron and Qwen workers use (#3081) + "security: a begin's cache slot", // flashnext/hip/worker.zig (#3081) + "a sender ", // protocol.zig: what rank 0's Sender puts in a message + "the words of a prefill message", // nemotron/hip/worker.zig +}; + +/// `test-hip-followers-host` over the host modules (hip_serve, Flash Next HIP, Nemotron HIP) with inert kernels. +pub fn steps(b: *std.Build, modules: []const *std.Build.Module) void { + const step = b.step("test-hip-followers-host", "HIP follower step parsers and their refusals without device execution"); + for (modules) |m| step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m, .filters = &parsers })).step); +} diff --git a/zig/build/host_ci.zig b/zig/build/host_ci.zig index b14c7136b4c..5d60271c9f3 100644 --- a/zig/build/host_ci.zig +++ b/zig/build/host_ci.zig @@ -114,6 +114,7 @@ const linux_hip = [_][]const u8{ "test-hip-blas-host", "test-hip-contract-select-host", "test-hip-family-offers-host", + "test-hip-followers-host", "test-hip-native-options-host", "test-hip-pair-contract-host", "test-lighton-hip-contract-host", diff --git a/zig/build/idol_cuda.zig b/zig/build/idol_cuda.zig new file mode 100644 index 00000000000..5457afc86b6 --- /dev/null +++ b/zig/build/idol_cuda.zig @@ -0,0 +1,34 @@ +//! Idol's CUDA denoiser in the build: its kernels for tf-cuda-test's contract, tf-idol on CUDA, its host tests. +const std = @import("std"); + +/// The family's module over the runtime and the core. +pub fn module(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module, core: *std.Build.Module) *std.Build.Module { + return b.createModule(.{ .root_source_file = b.path("zig/src/families/idol/cuda.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = core } } }); +} + +/// The launchers alone (idol.cu's kernels), as tf-cuda-test's contract imports them. +fn launchers(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module) *std.Build.Module { + return b.createModule(.{ .root_source_file = b.path("zig/src/families/idol/cuda_kernels.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{.{ .name = "cuda", .module = cuda }} }); +} + +/// tf-idol, the case driver on the first GPU; returns the launchers for tf-cuda-test's `runner` (idol-contract). +pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, strip: ?bool, cuda: *std.Build.Module, core: *std.Build.Module) *std.Build.Module { + const tool = b.createModule(.{ .root_source_file = b.path("zig/tests/idol_cuda.zig"), .target = target, .optimize = optimize, .link_libc = true, .strip = strip, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = core }, .{ .name = "idol", .module = module(b, target, optimize, cuda, core) } } }); + const exe = b.addExecutable(.{ .name = "tf-idol", .root_module = tool }); + b.installArtifact(exe); + b.step("idol-cuda", "Build tf-idol: Idol's denoiser on a reference case on CUDA").dependOn(&b.addInstallArtifact(exe, .{}).step); + return launchers(b, target, optimize, cuda); +} + +/// The family's host tests (config, schedule, scratch, admission, launch geometry, contract ranges) in `all`. +pub fn hostTests(b: *std.Build, cuda: *std.Build.Module, core: *std.Build.Module, all: *std.Build.Step) void { + const host = b.graph.host; + const run = b.addRunArtifact(b.addTest(.{ .root_module = module(b, host, .debug, cuda, core) })); + const refs = b.createModule(.{ .root_source_file = b.path("zig/tests/cuda/contract_idol_host.zig"), .target = host, .optimize = .debug, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = core }, .{ .name = "idol_cuda", .module = launchers(b, host, .debug, cuda) } } }); + const ref_run = b.addRunArtifact(b.addTest(.{ .root_module = refs })); + const step = b.step("test-idol-cuda-host", "Idol's CUDA denoiser host tests and contract references (no GPU work)"); + for ([_]*std.Build.Step{ &run.step, &ref_run.step }) |s| { + step.dependOn(s); + all.dependOn(s); + } +} diff --git a/zig/build/kernel_contract.zig b/zig/build/kernel_contract.zig index ddb0e9cb81d..cfc7fd5e47a 100644 --- a/zig/build/kernel_contract.zig +++ b/zig/build/kernel_contract.zig @@ -29,6 +29,17 @@ pub fn hostTests(b: *std.Build, family: *std.Build.Step) void { }) })); b.step("test-llama-controls-host", "Llama's source controls plant one fault without a device or shader compiler").dependOn(&llama_controls.step); step.dependOn(&llama_controls.step); + const ling_mla_controls = b.addRunArtifact(b.addTest(.{ .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/contract/metal_ling_mla_controls.zig"), + .target = b.graph.host, + .optimize = .debug, + .imports = &.{ + .{ .name = "contract", .module = module(b, b.graph.host, .debug) }, + .{ .name = "ling_metal", .module = b.createModule(.{ .root_source_file = b.path("zig/kernels/metal/ling/sources.zig") }) }, + }, + }) })); + b.step("test-ling-mla-controls-host", "Ling MLA source controls plant one fault without a device or shader compiler").dependOn(&ling_mla_controls.step); + step.dependOn(&ling_mla_controls.step); const mapping_tf = b.createModule(.{ .root_source_file = b.path("zig/lfm2_mapping_tf.zig"), .imports = &.{ .{ .name = "metal", .module = mapping_stub }, .{ .name = "kernel_sources", .module = mapping_stub }, @@ -160,6 +171,19 @@ pub fn metal(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil }, }) }); b.step("test-ling-kda-gpu", "Ling KDA mixer on this GPU against kda.zig, using k3_kda").dependOn(&b.addRunArtifact(ling_kda_gpu).step); + const ling_mla_gpu = b.addTest(.{ .root_module = b.createModule(.{ + .root_source_file = b.path("zig/tests/ling_mla_gpu.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + .imports = &.{ + .{ .name = "metal", .module = metal_mod }, + .{ .name = "mla", .module = b.createModule(.{ .root_source_file = b.path("zig/src/families/ling/mla.zig") }) }, + .{ .name = "kimi_metallib", .module = kimi_metallib }, + .{ .name = "ling_metal", .module = b.createModule(.{ .root_source_file = b.path("zig/kernels/metal/ling/sources.zig") }) }, + }, + }) }); + b.step("test-ling-mla-gpu", "Ling MLA mixer on this GPU around k3_mla, against mla.zig").dependOn(&b.addRunArtifact(ling_mla_gpu).step); } /// Linux: `kernel-contract` runs tf-cuda-test's kernel-contract command (kernels from -Dnvcc or -Dfatbins). diff --git a/zig/build/ling_host.zig b/zig/build/ling_host.zig index b802cbd518a..5706cc8e41c 100644 --- a/zig/build/ling_host.zig +++ b/zig/build/ling_host.zig @@ -7,6 +7,6 @@ pub fn tests(b: *std.Build, target: std.Build.ResolvedTarget, test_step: *std.Bu .target = target, }); const run = b.addRunArtifact(b.addTest(.{ .root_module = root })); - b.step("test-ling-host", "Ling family package: config, names, tiny fixtures, synth JSON, grouped routing, KDA mixer").dependOn(&run.step); + b.step("test-ling-host", "Ling family package: config, names, tiny fixtures, synth JSON, grouped routing, KDA mixer, MLA RoPE and mixer").dependOn(&run.step); test_step.dependOn(&run.step); } diff --git a/zig/build/metal_image_programs.zig b/zig/build/metal_image_programs.zig new file mode 100644 index 00000000000..27530a26948 --- /dev/null +++ b/zig/build/metal_image_programs.zig @@ -0,0 +1,18 @@ +//! The image families' Metal programs (tf-qwen-image, tf-moss-image*, tf-idol, tf-uocr-*) for metal_targets.zig. + +/// One engine program: its executable name, root file, step description and optional C source. +pub const Program = struct { name: []const u8, path: []const u8, about: []const u8, c_source: ?[]const u8 = null }; + +/// Their rows, in their place between tf-qwen-vision and tf-glm-attn-probe. +pub const rows = [_]Program{ + .{ .name = "tf-qwen-image", .path = "zig/tests/qwen_image.zig", .about = "Qwen-Image-2.1's transformer on a reference case: each step compared, then the schedule timed" }, + .{ .name = "tf-moss-image", .path = "zig/tests/moss_image.zig", .about = "MOSS-Image on a reference case: each step's two branches compared, then the guided schedule timed and decoded" }, + .{ .name = "tf-moss-image-encoder", .path = "zig/tests/moss_image_encoder.zig", .about = "MOSS-Image's prompt encoder on a reference case: the ids checked, each step gated against float32, then timed" }, + .{ .name = "tf-moss-image-decoder", .path = "zig/tests/moss_image_decoder.zig", .about = "MOSS-Image's image decoder on latents, gated against float64 beside torch float32, then timed" }, + .{ .name = "tf-moss-image-blocks", .path = "zig/tests/moss_image_blocks.zig", .about = "MOSS-Image's transformer on one step, each block alone gated against float32, repeated byte for byte" }, + .{ .name = "tf-moss-image-generate", .path = "zig/tests/moss_image_generate.zig", .about = "MOSS-Image from options alone: prompts, schedule and noise, then the decoder's picture" }, + .{ .name = "tf-idol", .path = "zig/tests/idol.zig", .about = "Idol's denoiser on a reference case: each step's two branches compared, then the guided schedule timed" }, + .{ .name = "tf-uocr-decode", .path = "zig/tests/uocr/decode.zig", .about = "Unlimited-OCR-2 end to end on a page against a reference dump: prompt, layers, logits, greedy reply" }, + .{ .name = "tf-uocr-vision", .path = "zig/tests/uocr/vision.zig", .about = "Unlimited-OCR-2's image encoder on a reference dump's pixels: SAM gated against float32, CLIP and the projector reported" }, + .{ .name = "tf-uocr-blocks", .path = "zig/tests/uocr/blocks.zig", .about = "Unlimited-OCR-2's image encoder step by step: each SAM block, the neck, CLIP's front, each CLIP layer and the projector alone against float32" }, +}; diff --git a/zig/build/metal_targets.zig b/zig/build/metal_targets.zig index 0658d51b36a..d451bd41292 100644 --- a/zig/build/metal_targets.zig +++ b/zig/build/metal_targets.zig @@ -12,6 +12,7 @@ const exlr8_build = @import("exlr8.zig"); const server_build = @import("server.zig"); const golden_build = @import("golden.zig"); const contract_build = @import("kernel_contract.zig"); +const image_programs = @import("metal_image_programs.zig"); const metal_lists = @import("metal_source_lists.zig"); const kernels = metal_lists.kernels; const generated = metal_lists.generated; @@ -344,7 +345,7 @@ pub fn metalTargets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: s const pack_cache_run = b.addRunArtifact(pack_cache_cases); b.step("test-flashnext-pack-cache", "CPU-only atomic Flash Next pack cache lifecycle").dependOn(&pack_cache_run.step); test_step.dependOn(&pack_cache_run.step); - const engine_programs = [_]struct { name: []const u8, path: []const u8, about: []const u8, c_source: ?[]const u8 = null }{ + const engine_programs = [_]image_programs.Program{ .{ .name = "tf-qwen35-check", .path = "zig/tests/qwen35_check.zig", .about = "Qwen3.5-2B checkpoint and native operations" }, .{ .name = "tf-qwen35-forward", .path = "zig/tests/qwen35_forward.zig", .about = "Qwen3.5-2B native teacher-forced logits" }, .{ .name = "tf-qwen35-exact", .path = "zig/tests/qwen35_exact.zig", .about = "Qwen3.5-2B forward and committed-state exactness" }, @@ -380,15 +381,7 @@ pub fn metalTargets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: s .{ .name = "tf-glm-vision", .path = "zig/tests/glm_vision.zig", .about = "GLM-5.3-Flash's image tower on an image or a reference dump's patches, compared with the dump" }, .{ .name = "tf-glm-video", .path = "zig/tests/glm_video.zig", .about = "GLM-5.3-Flash's video preparation on a clip (libtfvideo), written for tools/zig/glm_video_fixtures.py" }, .{ .name = "tf-qwen-vision", .path = "zig/tests/qwen_vision.zig", .about = "The Qwen-VL tower on picture files: patches, grids and merged rows written for a float32 reference" }, - .{ .name = "tf-qwen-image", .path = "zig/tests/qwen_image.zig", .about = "Qwen-Image-2.1's transformer on a reference case: each step compared, then the schedule timed" }, - .{ .name = "tf-moss-image", .path = "zig/tests/moss_image.zig", .about = "MOSS-Image on a reference case: each step's two branches compared, then the guided schedule timed and decoded" }, - .{ .name = "tf-moss-image-encoder", .path = "zig/tests/moss_image_encoder.zig", .about = "MOSS-Image's prompt encoder on a reference case: the ids checked, each step gated against float32, then timed" }, - .{ .name = "tf-moss-image-decoder", .path = "zig/tests/moss_image_decoder.zig", .about = "MOSS-Image's image decoder on latents, gated against float64 beside torch float32, then timed" }, - .{ .name = "tf-moss-image-blocks", .path = "zig/tests/moss_image_blocks.zig", .about = "MOSS-Image's transformer on one step, each block alone gated against float32, repeated byte for byte" }, - .{ .name = "tf-moss-image-generate", .path = "zig/tests/moss_image_generate.zig", .about = "MOSS-Image from options alone: prompts, schedule and noise, then the decoder's picture" }, - .{ .name = "tf-uocr-decode", .path = "zig/tests/uocr/decode.zig", .about = "Unlimited-OCR-2 end to end on a page against a reference dump: prompt, layers, logits, greedy reply" }, - .{ .name = "tf-uocr-vision", .path = "zig/tests/uocr/vision.zig", .about = "Unlimited-OCR-2's image encoder on a reference dump's pixels: SAM gated against float32, CLIP and the projector reported" }, - .{ .name = "tf-uocr-blocks", .path = "zig/tests/uocr/blocks.zig", .about = "Unlimited-OCR-2's image encoder step by step: each SAM block, the neck, CLIP's front, each CLIP layer and the projector alone against float32" }, + } ++ image_programs.rows ++ [_]image_programs.Program{ .{ .name = "tf-glm-attn-probe", .path = "zig/tests/glm_attn_probe.zig", .about = "GLM-5.3-Flash's dense latent attention kernels on given inputs (scores, probabilities, outputs)" }, .{ .name = "tf-moe-bench", .path = "zig/tests/moe_bench.zig", .about = "Routed-expert prompt kernels from .metal files on a skewed routing: chained speed, bits against the first" }, .{ .name = "tf-mm-bench", .path = "zig/tests/mm_bench.zig", .about = "Prompt matmul kernels from .metal files: chained speed at one shape, bits against the first, error against fp64" }, diff --git a/zig/cuda_checkpoint_cache_host.zig b/zig/cuda_checkpoint_cache_host.zig index 816caa056cb..dd95787a1e6 100644 --- a/zig/cuda_checkpoint_cache_host.zig +++ b/zig/cuda_checkpoint_cache_host.zig @@ -109,10 +109,11 @@ test "CUDA load cache: DeepSeek finishes backbone and DSpark before the pack swe test "CUDA load cache: Flash Next sweep follows MTP and retains live PLE files" { const s = @embedFile("src/families/flashnext/cuda_lanes_load.zig"); - const drop = std.mem.indexOf(u8, s, ".dropPageCache(io, dir, e.ngram.files.items)") orelse return error.NoPleExclusion; + const drop = std.mem.indexOf(u8, s, ".dropPageCache(gpa, io, dir, e.ngram.files.items)") orelse return error.NoPleExclusion; try t.expect(std.mem.indexOf(u8, s, "mtp.Head.init").? < drop); const owner = @embedFile("src/families/flashnext/cuda_prompt_wt.zig"); - try t.expect(std.mem.indexOf(u8, owner, "if (!runtimePages(self.f.names.keys())) self.f.release(std.heap.page_allocator)") != null); + try t.expect(std.mem.indexOf(u8, owner, "if (runtimePage(name)) keep.append(scratch, self.f.get(name).?.bytes) catch return;") != null); + try t.expect(std.mem.indexOf(u8, owner, "self.f.releaseExcept(keep.items, scratch)") != null); } test "CUDA load cache: LFM2 decision model releases its direct-read fallback" { @@ -137,7 +138,7 @@ test "CUDA load cache: every TP load scope defers file advice through all-rank r const read = std.mem.indexOfPos(u8, source, start, last) orelse return error.NoLastLoad; try t.expect(start < read and read < ready); if (std.mem.eql(u8, path, "flashnext/cuda_lanes_load.zig")) { - const drop = std.mem.indexOf(u8, source, "dropPageCache(io,") orelse return error.NoSweep; + const drop = std.mem.indexOf(u8, source, "dropPageCache(gpa, io,") orelse return error.NoSweep; try t.expect(drop < ready); } } diff --git a/zig/kernels/cuda/contract_controls_set.cu b/zig/kernels/cuda/contract_controls_set.cu index bfd71fc467b..424f36bfd83 100644 --- a/zig/kernels/cuda/contract_controls_set.cu +++ b/zig/kernels/cuda/contract_controls_set.cu @@ -5,3 +5,4 @@ #include "contract_dense_controls.cuh" #include "contract_experts_bf16_controls.cuh" #include "contract_nemo_audio_controls.cuh" +#include "contract_idol_controls.cuh" diff --git a/zig/kernels/cuda/contract_idol_controls.cuh b/zig/kernels/cuda/contract_idol_controls.cuh new file mode 100644 index 00000000000..39daddbfdf9 --- /dev/null +++ b/zig/kernels/cuda/contract_idol_controls.cuh @@ -0,0 +1,53 @@ +// Gate 3: Idol's glue (idol.cu) with one fp16 rounding dropped each; the intervals hold idol-sdk's rounding points. +#pragma once + +#include +#include + +#include "common/reduce.cuh" + +namespace tf_ctl_idol { +__device__ __forceinline__ float h(float x) { return __half2float(__float2half_rn(x)); } +__device__ __forceinline__ float ld(const __half* p) { return __half2float(*p); } +} // namespace tf_ctl_idol + +// tf_idol_norm modulating the unrounded LayerNorm: fp16(fp16(y s1) + sh) where idol-sdk rounds y first. +extern "C" __global__ void __launch_bounds__(256) tf_ctl_idol_norm_late(const __half* X, const float* W, const float* B, + const __half* S1, const __half* SH, __half* Y, + int width, float eps, int mode) { + using namespace tf_ctl_idol; + __shared__ float part[8]; + const __half* x = X + (size_t)blockIdx.x * width; + float a = 0.0f, q = 0.0f; + for (int i = threadIdx.x; i < width; i += 256) a += ld(x + i); + const float mean = tf_common::block_sum_serial(a, part) / (float)width; + for (int i = threadIdx.x; i < width; i += 256) q += (ld(x + i) - mean) * (ld(x + i) - mean); + const float inv = 1.0f / sqrtf(tf_common::block_sum_serial(q, part) / (float)width + eps); + for (int i = threadIdx.x; i < width; i += 256) { + float v = (ld(x + i) - mean) * inv; + v = mode == 1 ? h(v * W[i] + B[i]) : h(h(v * ld(S1 + i)) + ld(SH + i)); + Y[(size_t)blockIdx.x * width + i] = __float2half_rn(v); + } +} + +// tf_idol_gate_add with g y left in fp32: fp16(x + g y) where idol-sdk rounds g y to fp16 first. +extern "C" __global__ void __launch_bounds__(256) tf_ctl_idol_gate_add_once(__half* X, const __half* Y, const __half* G, + int width, int rows) { + using namespace tf_ctl_idol; + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= width || r >= rows) return; + const size_t i = (size_t)r * width + c; + X[i] = __float2half_rn(ld(X + i) + ld(G + c) * ld(Y + i)); +} + +// tf_idol_bias taking GELU of the fp32 sum: fp16(GELU(acc + b)) where idol-sdk rounds the linear's output first. +extern "C" __global__ void __launch_bounds__(256) tf_ctl_idol_bias_late(const float* ACC, const __half* B, __half* Y, + int width, int rows, int act) { + using namespace tf_ctl_idol; + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= width || r >= rows) return; + const size_t i = (size_t)r * width + c; + float v = ACC[i] + ld(B + c); + if (act) v = 0.5f * v * (1.0f + tanhf(0.7978845608028654f * (v + 0.044715f * v * v * v))); + Y[i] = __float2half_rn(act ? v : h(v)); +} diff --git a/zig/kernels/cuda/idol.cu b/zig/kernels/cuda/idol.cu new file mode 100644 index 00000000000..4ce9c14d1c1 --- /dev/null +++ b/zig/kernels/cuda/idol.cu @@ -0,0 +1,190 @@ +// Idol's denoiser glue on CUDA: idol.metal's steps op for op, fp16 rows rounded where idol-sdk's torch code rounds. +#include +#include +#include + +#include "common/reduce.cuh" +#include "idol_attention.cuh" + +namespace tf_idol { + +using tf_common::warp_sum; + +typedef __half f16; + +__device__ __forceinline__ float h(float x) { return __half2float(__float2half_rn(x)); } +__device__ __forceinline__ float ld(const f16* p) { return __half2float(*p); } + +// The row's mean and 1 / sqrt(var + eps), each sum in fp32: LayerNorm32's statistics. +__device__ __forceinline__ void stats(const f16* x, int width, float eps, float* part, float& mean, float& inv) { + float a = 0.0f; + for (int i = threadIdx.x; i < width; i += 256) a += ld(x + i); + mean = tf_common::block_sum_serial(a, part) / (float)width; + float q = 0.0f; + for (int i = threadIdx.x; i < width; i += 256) { + const float d = ld(x + i) - mean; + q += d * d; + } + inv = 1.0f / sqrtf(tf_common::block_sum_serial(q, part) / (float)width + eps); +} + +// F.normalize's clamp_min(1e-12) as torch does it: a NaN norm stays NaN (fmaxf would drop it). +__device__ __forceinline__ float clamp_min(float n) { return n < 1e-12f ? 1e-12f : n; } + +// torch's tanh GELU of an fp16 value, in fp32. +__device__ __forceinline__ float gelu(float x) { + const float inner = 0.7978845608028654f * (x + 0.044715f * x * x * x); + return 0.5f * x * (1.0f + tanhf(inner)); +} + +} // namespace tf_idol + +using namespace tf_idol; + +// LayerNorm32 of an fp16 row to fp16: affine (mode 1) in fp32 before the rounding, modulated (mode 2) in fp16 after. +extern "C" __global__ void __launch_bounds__(256) tf_idol_norm(const f16* __restrict__ X, const float* __restrict__ W, + const float* __restrict__ B, const f16* __restrict__ S1, + const f16* __restrict__ SH, f16* __restrict__ Y, int width, + float eps, int mode) { + __shared__ float part[8]; + const f16* x = X + (size_t)blockIdx.x * width; + f16* y = Y + (size_t)blockIdx.x * width; + float mean, inv; + stats(x, width, eps, part, mean, inv); + for (int i = threadIdx.x; i < width; i += 256) { + float v = (ld(x + i) - mean) * inv; + if (mode == 1) v = v * W[i] + B[i]; + v = h(v); + if (mode == 2) v = h(h(v * ld(S1 + i)) + ld(SH + i)); + y[i] = __float2half_rn(v); + } +} + +// LayerNorm of an fp16 row kept in fp32: affine (mode 1) y w + b, or modulated (mode 2) y (1 + w) + b. +extern "C" __global__ void __launch_bounds__(256) tf_idol_norm32(const f16* __restrict__ X, const float* __restrict__ W, + const float* __restrict__ B, float* __restrict__ Y, + int width, float eps, int mode) { + __shared__ float part[8]; + const f16* x = X + (size_t)blockIdx.x * width; + float* y = Y + (size_t)blockIdx.x * width; + float mean, inv; + stats(x, width, eps, part, mean, inv); + for (int i = threadIdx.x; i < width; i += 256) { + const float v = (ld(x + i) - mean) * inv; + y[i] = mode == 2 ? v * (1.0f + W[i]) + B[i] : v * W[i] + B[i]; + } +} + +// RePo: d = final_map(silu(gate) content), 3 a head; angles clamp_mul(d, freqs) pi as cos, sin [rows, 16, 32]. +extern "C" __global__ void __launch_bounds__(64) tf_idol_repo(const float* __restrict__ GC, const float* __restrict__ WF, + const float* __restrict__ F, float* __restrict__ CS, + float* __restrict__ SN, int rows) { + __shared__ float u[128]; + __shared__ float d[48]; + const int row = blockIdx.x, t = threadIdx.x; + if (row >= rows) return; + const float* g = GC + (size_t)row * 256; + for (int i = t; i < 128; i += 64) { + const float a = g[i]; + u[i] = (a / (1.0f + expf(-a))) * g[128 + i]; + } + __syncthreads(); + if (t < 48) { + float s = 0.0f; + for (int k = 0; k < 128; ++k) s = __fmaf_rn(u[k], WF[t * 128 + k], s); + d[t] = s; + } + __syncthreads(); + for (int i = t; i < 512; i += 64) { + const int hd = i / 32, j = i % 32; + const int axis = j < 10 ? 0 : (j < 20 ? 1 : 2); + const float x = d[hd * 3 + axis], fr = F[j]; + const float ft = tanhf(fr); + const float ang = (x * ft + x * (fr - ft)) * 3.14159265358979323846f; + CS[(size_t)row * 512 + i] = cosf(ang); + SN[(size_t)row * 512 + i] = sinf(ang); + } +} + +// q, k of qkv rows turned by cos, sin (to fp16), F.normalize times gamma times `scale`; v copied. A warp a head. +extern "C" __global__ void __launch_bounds__(256) tf_idol_qk(const f16* __restrict__ QKV, const float* __restrict__ GQ, + const float* __restrict__ GK, const float* __restrict__ CS, + const float* __restrict__ SN, f16* __restrict__ OUT, int rows, + float scale) { + const int r = blockIdx.x, hd = blockIdx.y * 8 + (threadIdx.x >> 5), lane = threadIdx.x & 31; + if (hd >= 16 || r >= rows) return; + const size_t from = (size_t)r * 3072 + hd * 64 + lane * 2; + const size_t at = (size_t)r * 512 + hd * 32 + lane; + const float c = CS[at], s = SN[at]; + const float q0 = ld(QKV + from), q1 = ld(QKV + from + 1); + const float k0 = ld(QKV + from + 1024), k1 = ld(QKV + from + 1025); + const float rq0 = h(q0 * c - q1 * s), rq1 = h(q0 * s + q1 * c); + const float rk0 = h(k0 * c - k1 * s), rk1 = h(k0 * s + k1 * c); + const float qn = clamp_min(sqrtf(warp_sum(rq0 * rq0 + rq1 * rq1))); + const float kn = clamp_min(sqrtf(warp_sum(rk0 * rk0 + rk1 * rk1))); + const int gi = hd * 64 + lane * 2; + f16* o = OUT + from; + o[0] = __float2half_rn(rq0 / qn * GQ[gi] * scale); + o[1] = __float2half_rn(rq1 / qn * GQ[gi + 1] * scale); + o[1024] = __float2half_rn(rk0 / kn * GK[gi] * scale); + o[1025] = __float2half_rn(rk1 / kn * GK[gi + 1] * scale); + o[2048] = QKV[from + 2048]; + o[2049] = QKV[from + 2049]; +} + +// x = fp16(x + fp16(g y)) by column; g is a modulation gate, or ones for an ungated residual. In place. +extern "C" __global__ void __launch_bounds__(256) tf_idol_gate_add(f16* __restrict__ X, const f16* __restrict__ Y, + const f16* __restrict__ G, int width, int rows) { + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= width || r >= rows) return; + const size_t i = (size_t)r * width + c; + X[i] = __float2half_rn(ld(X + i) + h(ld(G + c) * ld(Y + i))); +} + +// y = fp16(acc + b): a block linear's fp32 sums and its fp16 bias, one rounding; then fp16(GELU(y)) when `act`. +extern "C" __global__ void __launch_bounds__(256) tf_idol_bias(const float* __restrict__ ACC, const f16* __restrict__ B, + f16* __restrict__ Y, int width, int rows, int act) { + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= width || r >= rows) return; + const size_t i = (size_t)r * width + c; + float v = h(ACC[i] + ld(B + c)); + if (act) v = gelu(v); + Y[i] = __float2half_rn(v); +} + +// x = fp16(fp16(z w^T + b) + pe): the latent's input projection (16 inputs, fp32) and its fp16 position embedding. +extern "C" __global__ void __launch_bounds__(256) tf_idol_embed(const float* __restrict__ Z, const float* __restrict__ W, + const float* __restrict__ B, const f16* __restrict__ PE, + f16* __restrict__ X, int rows) { + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= 1024 || r >= rows) return; + float s = 0.0f; +#pragma unroll + for (int k = 0; k < 16; ++k) s = __fmaf_rn(Z[(size_t)r * 16 + k], W[c * 16 + k], s); + const size_t i = (size_t)r * 1024 + c; + X[i] = __float2half_rn(h(s + B[c]) + ld(PE + i)); +} + +// y = fp16((a + ba) + (c + bc)) by column: the two condition projections' fp32 sums and biases. +extern "C" __global__ void __launch_bounds__(256) tf_idol_cond(const float* __restrict__ A, const float* __restrict__ BA, + const float* __restrict__ C, const float* __restrict__ BC, + f16* __restrict__ Y, int width, int rows) { + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= width || r >= rows) return; + const size_t i = (size_t)r * width + c; + Y[i] = __float2half_rn((A[i] + BA[c]) + (C[i] + BC[c])); +} + +// y += b by column in fp32 (an fp32 Linear's bias), in place. +extern "C" __global__ void __launch_bounds__(256) tf_idol_bias32(float* __restrict__ Y, const float* __restrict__ B, + int width, int rows) { + const int c = blockIdx.y * 256 + threadIdx.x, r = blockIdx.x; + if (c >= width || r >= rows) return; + Y[(size_t)r * width + c] += B[c]; +} + +// Full attention at head width 64 over fp16 packed rows; idol_attention.cuh has the body. +extern "C" __global__ void __launch_bounds__(256) tf_idol_attention(const f16* __restrict__ qkv, f16* __restrict__ out, + int W, int HO, float scale) { + tf_idol_attn::full<64, 8>(qkv, out, W, HO, scale); +} diff --git a/zig/kernels/cuda/idol_attention.cuh b/zig/kernels/cuda/idol_attention.cuh new file mode 100644 index 00000000000..48965457360 --- /dev/null +++ b/zig/kernels/cuda/idol_attention.cuh @@ -0,0 +1,185 @@ +// Idol's attention: vision_kernel's row arithmetic over fp16 q, k, v and P (fp32 scores, softmax, sums), its own copy. +#pragma once + +#include +#include +#include + +#include "common/qmm_frag.cuh" + +namespace tf_idol_attn { + +using qmm_frag::commit; +using qmm_frag::cp16z; +using qmm_frag::ldmatrix4; +using qmm_frag::ldmatrix4t; + +constexpr int BN = 64; // keys a tile +constexpr float LOG2E = 1.4426950408889634f; + +__device__ __forceinline__ void mma(float (&d)[4], const uint32_t (&a)[4], uint32_t b0, uint32_t b1) { + const uint32_t b[2] = {b0, b1}; + qmm_frag::mma_f16_v(d, a, b); +} + +__device__ __forceinline__ void mma0(float (&d)[4], const uint32_t (&a)[4], uint32_t b0, uint32_t b1) { + d[0] = d[1] = d[2] = d[3] = 0.0f; + mma(d, a, b0, b1); +} + +__device__ __forceinline__ float texp(float x) { + float y; + asm("ex2.approx.f32 %0, %1;\n" : "=f"(y) : "f"(__fmul_rn(x, LOG2E))); + return y; +} + +__device__ __forceinline__ float tdiv(float a, float b) { + float y; + asm("div.full.f32 %0, %1, %2;\n" : "=f"(y) : "f"(a), "f"(b)); + return y; +} + +__device__ __forceinline__ uint32_t pack(float lo, float hi) { + __half2 v = __floats2half2_rn(lo, hi); + return *reinterpret_cast(&v); +} + +__device__ __forceinline__ float rowsum(const float (&c)[8]) { + float w[8]; +#pragma unroll + for (int j = 0; j < 8; ++j) { + const float x = __fadd_rn(c[j], __shfl_xor_sync(0xffffffffu, c[j], 2)); + w[j] = __fadd_rn(x, __shfl_xor_sync(0xffffffffu, x, 1)); + } + return __fadd_rn(__fadd_rn(__fadd_rn(w[0], w[4]), __fadd_rn(w[2], w[6])), + __fadd_rn(__fadd_rn(w[1], w[5]), __fadd_rn(w[3], w[7]))); +} + +// Every row over every key, a block a head and 16 WARPS rows: qkv [W, 3 HO D] fp16 -> out [W, HO D] fp16. +template +__device__ __forceinline__ void full(const __half* __restrict__ qkv, __half* __restrict__ out, int W, int HO, + float scale) { + static_assert(D % 16 == 0, "whole 16-dim steps"); + constexpr int C = D / 8, RS = C + 1, K16 = D / 16, NT = BN / 8, THREADS = 32 * WARPS; + extern __shared__ uint4 smem[]; + const int warp = threadIdx.x / 32, lane = threadIdx.x % 32, g = lane / 4, qd = lane % 4, mt = lane / 8; + const int head = blockIdx.y, wrow = (blockIdx.x * WARPS + warp) * 16, last = W - 1, tiles = (W + BN - 1) / BN; + const int64_t stride = 3LL * HO * D; + const __half* __restrict__ q = qkv + head * D; + const __half* __restrict__ kc = qkv + (HO + head) * D; + const __half* __restrict__ vc = qkv + (2 * HO + head) * D; + auto stage = [&](int t) { // tile t's K rows then V rows into buffer t % 2 + uint4* dst = smem + (t & 1) * 2 * BN * RS; + for (int i = threadIdx.x; i < 2 * BN * C; i += THREADS) { + const int kv = i / (BN * C), r = (i / C) % BN, c = i % C, key = t * BN + r; + const bool in = key < W; + cp16z(dst + (kv * BN + r) * RS + c, (kv ? vc : kc) + (int64_t)(in ? key : 0) * stride + c * 8, in); + } + commit(); + }; + uint32_t qa[K16][4]; + const int r0 = wrow + g, r1 = r0 + 8; + { + const uint32_t* q0 = reinterpret_cast(q + (int64_t)min(r0, last) * stride); + const uint32_t* q1 = reinterpret_cast(q + (int64_t)min(r1, last) * stride); +#pragma unroll + for (int k = 0; k < K16; ++k) { + qa[k][0] = r0 < W ? q0[8 * k + qd] : 0u; + qa[k][1] = r1 < W ? q1[8 * k + qd] : 0u; + qa[k][2] = r0 < W ? q0[8 * k + qd + 4] : 0u; + qa[k][3] = r1 < W ? q1[8 * k + qd + 4] : 0u; + } + } + float o[C][4]; +#pragma unroll + for (int i = 0; i < C; ++i) o[i][0] = o[i][1] = o[i][2] = o[i][3] = 0.0f; + float m0 = -INFINITY, m1 = -INFINITY, l0 = 0.0f, l1 = 0.0f; + stage(0); + for (int t = 0; t < tiles; ++t) { + qmm_frag::wait<0>(); + __syncthreads(); // tile t landed, and every warp is done with tile t - 1 + if (t + 1 < tiles) stage(t + 1); + const uint4* ks = smem + (t & 1) * 2 * BN * RS; + const uint4* vs = ks + BN * RS; + float sc[NT][4]; +#pragma unroll + for (int k = 0; k < K16; ++k) { +#pragma unroll + for (int n = 0; n < NT; n += 2) { + uint32_t b[4]; + ldmatrix4(b, ks + (8 * (n + mt / 2) + lane % 8) * RS + 2 * k + mt % 2); + if (k == 0) { + mma0(sc[n], qa[k], b[0], b[1]); + mma0(sc[n + 1], qa[k], b[2], b[3]); + } else { + mma(sc[n], qa[k], b[0], b[1]); + mma(sc[n + 1], qa[k], b[2], b[3]); + } + } + } + const int kb = t * BN + 2 * qd; + float tm0 = -INFINITY, tm1 = -INFINITY; +#pragma unroll + for (int n = 0; n < NT; ++n) { + const int c = kb + 8 * n; + sc[n][0] = c <= last ? __fmul_rn(sc[n][0], scale) : -INFINITY; + sc[n][1] = c + 1 <= last ? __fmul_rn(sc[n][1], scale) : -INFINITY; + sc[n][2] = c <= last ? __fmul_rn(sc[n][2], scale) : -INFINITY; + sc[n][3] = c + 1 <= last ? __fmul_rn(sc[n][3], scale) : -INFINITY; + tm0 = fmaxf(tm0, fmaxf(sc[n][0], sc[n][1])); + tm1 = fmaxf(tm1, fmaxf(sc[n][2], sc[n][3])); + } + for (int x = 1; x <= 2; x *= 2) { + tm0 = fmaxf(tm0, __shfl_xor_sync(0xffffffffu, tm0, x)); + tm1 = fmaxf(tm1, __shfl_xor_sync(0xffffffffu, tm1, x)); + } + const bool act0 = tm0 != -INFINITY, act1 = tm1 != -INFINITY; + const float n0 = act0 ? fmaxf(m0, tm0) : m0, n1 = act1 ? fmaxf(m1, tm1) : m1; + const float a0 = act0 ? (m0 == -INFINITY ? 0.0f : texp(__fsub_rn(m0, n0))) : 1.0f; + const float a1 = act1 ? (m1 == -INFINITY ? 0.0f : texp(__fsub_rn(m1, n1))) : 1.0f; + float c0[NT], c1[NT]; +#pragma unroll + for (int n = 0; n < NT; ++n) { + const int c = kb + 8 * n; + sc[n][0] = act0 && c <= last ? texp(__fsub_rn(sc[n][0], n0)) : 0.0f; + sc[n][1] = act0 && c + 1 <= last ? texp(__fsub_rn(sc[n][1], n0)) : 0.0f; + sc[n][2] = act1 && c <= last ? texp(__fsub_rn(sc[n][2], n1)) : 0.0f; + sc[n][3] = act1 && c + 1 <= last ? texp(__fsub_rn(sc[n][3], n1)) : 0.0f; + c0[n] = __fadd_rn(sc[n][0], sc[n][1]); + c1[n] = __fadd_rn(sc[n][2], sc[n][3]); + } + l0 = __fmaf_rn(l0, a0, rowsum(c0)); + l1 = __fmaf_rn(l1, a1, rowsum(c1)); + m0 = n0; + m1 = n1; +#pragma unroll + for (int i = 0; i < C; ++i) { + o[i][0] = __fmul_rn(o[i][0], a0); + o[i][1] = __fmul_rn(o[i][1], a0); + o[i][2] = __fmul_rn(o[i][2], a1); + o[i][3] = __fmul_rn(o[i][3], a1); + } +#pragma unroll + for (int j = 0; j < NT / 2; ++j) { // 16-key chunks, in key order for every output tile + const uint32_t pa[4] = {pack(sc[2 * j][0], sc[2 * j][1]), pack(sc[2 * j][2], sc[2 * j][3]), + pack(sc[2 * j + 1][0], sc[2 * j + 1][1]), pack(sc[2 * j + 1][2], sc[2 * j + 1][3])}; +#pragma unroll + for (int i = 0; i < C; i += 2) { + uint32_t b[4]; + ldmatrix4t(b, vs + (16 * j + 8 * (mt % 2) + lane % 8) * RS + i + mt / 2); + mma(o[i], pa, b[0], b[1]); + mma(o[i + 1], pa, b[2], b[3]); + } + } + } +#pragma unroll + for (int i = 0; i < C; ++i) { + const int d = 8 * i + 2 * qd; + if (r0 < W) + *reinterpret_cast(out + ((int64_t)r0 * HO + head) * D + d) = pack(tdiv(o[i][0], l0), tdiv(o[i][1], l0)); + if (r1 < W) + *reinterpret_cast(out + ((int64_t)r1 * HO + head) * D + d) = pack(tdiv(o[i][2], l1), tdiv(o[i][3], l1)); + } +} + +} // namespace tf_idol_attn diff --git a/zig/kernels/cuda/nvfp4_experts.cu b/zig/kernels/cuda/nvfp4_experts.cu index 27a7cfaba9c..5a360758b93 100644 --- a/zig/kernels/cuda/nvfp4_experts.cu +++ b/zig/kernels/cuda/nvfp4_experts.cu @@ -11,37 +11,18 @@ namespace tf_nvfp4_experts { constexpr int BLOCK4 = 36; -__device__ __forceinline__ uint4 ld_nc(const uint4* p) { return tf_common::ld_nc(p); } - using tf_common::fp4pair; using tf_common::e4m3f; -template +// A k32 group's stage: the lane's words (Word = uint2 for half a unit's two n8 tiles), its scales and inputs. +template struct Stage { - uint4 w[M]; + Word w[M]; uint4 s[M]; uint2 xa[2], xb[2]; }; -template -__device__ __forceinline__ void load_stage(Stage& st, const uint4* blk, int g, int lane, int t, - const __nv_bfloat16* x0, const __nv_bfloat16* x1, bool v0, bool v1) { - const uint4* b = blk + (size_t)g * (M * BLOCK4); -#pragma unroll - for (int m = 0; m < M; ++m) { - st.w[m] = ld_nc(b + m * BLOCK4 + lane); - st.s[m] = ld_nc(b + m * BLOCK4 + 32 + t); - } - const uint2 zero = make_uint2(0u, 0u); - const int k0 = g * 32 + 4 * t; -#pragma unroll - for (int h = 0; h < 2; ++h) { - st.xa[h] = v0 ? __ldg(reinterpret_cast(x0 + k0 + 16 * h)) : zero; - st.xb[h] = v1 ? __ldg(reinterpret_cast(x1 + k0 + 16 * h)) : zero; - } -} - template __device__ __forceinline__ void compute_stage(float (&acc)[M][1][NTW][4], const Stage& st, bool hi) { #pragma unroll @@ -68,33 +49,124 @@ __device__ __forceinline__ void compute_stage(float (&acc)[M][1][NTW][4], const } } -template -__device__ __forceinline__ void k_loop(float (&acc)[M][1][NTW][4], const uint4* blk, int KG, int lane, int t, +#if __CUDA_ARCH__ == 1210 +// GB10's register form of Ring: two k32 stages held in registers, each refilled as soon as it has been summed. +#define TF_RING_STORAGE +template +struct Ring { + __device__ __forceinline__ void load(Stage& st, int g, int lane, int t, int jh, const uint4* blk, const __nv_bfloat16* x0, const __nv_bfloat16* x1, bool v0, bool v1) { - constexpr int D = 2; - Stage st[D]; -#pragma unroll - for (int d = 0; d < D; ++d) - if (d < KG) load_stage(st[d], blk, d, lane, t, x0, x1, v0, v1); - for (int g0 = 0; g0 < KG; g0 += D) { -#pragma unroll - for (int d = 0; d < D; ++d) { - const int g = g0 + d; - if (g < KG) { - compute_stage(acc, st[d], v1); - if (g + D < KG) load_stage(st[d], blk, g + D, lane, t, x0, x1, v0, v1); + const uint4* b = blk + (size_t)g * (M * BLOCK4); +#pragma unroll + for (int m = 0; m < M; ++m) { + if constexpr (sizeof(Word) == 16) + st.w[m] = tf_common::ld_nc(b + m * BLOCK4 + lane); + else + st.w[m] = tf_common::ld_nc2(reinterpret_cast(b + m * BLOCK4 + lane) + jh); + st.s[m] = tf_common::ld_nc(b + m * BLOCK4 + 32 + t); + } + const uint2 zero = make_uint2(0u, 0u); + const int k0 = g * 32 + 4 * t; +#pragma unroll + for (int h = 0; h < 2; ++h) { + st.xa[h] = v0 ? __ldg(reinterpret_cast(x0 + k0 + 16 * h)) : zero; + st.xb[h] = v1 ? __ldg(reinterpret_cast(x1 + k0 + 16 * h)) : zero; + } + } + + // All KG groups in k order: `sum` takes each group's stage. + template + __device__ __forceinline__ void run(int KG, int, int lane, int t, int jh, const uint4* blk, const __nv_bfloat16* x0, + const __nv_bfloat16* x1, bool v0, bool v1, Sum sum) { + constexpr int D = 2; + Stage st[D]; +#pragma unroll + for (int d = 0; d < D; ++d) + if (d < KG) load(st[d], d, lane, t, jh, blk, x0, x1, v0, v1); + for (int g0 = 0; g0 < KG; g0 += D) { +#pragma unroll + for (int d = 0; d < D; ++d) { + const int g = g0 + d; + if (g < KG) { + sum(st[d]); + if (g + D < KG) load(st[d], g + D, lane, t, jh, blk, x0, x1, v0, v1); + } } } } -} +}; +#else +#define TF_RING_STORAGE __shared__ +// A warp's ring of D shared k32 stages, filled by cp.async: the next D - 1 groups load while one group sums. +template +struct Ring { + static constexpr int D = 4; + Word w[WARPS][D][M][32]; // a lane's words + uint4 s[WARPS][D][M][4]; // the group's scales, read by t + uint2 x[WARPS][D][4][32]; // a lane's x0 then x1 inputs, h = 0 and 1 + + // Group g into stage g % D: words (half jh of each lane's uint4 when Word is uint2), scales, the rows' inputs. + __device__ __forceinline__ void issue(int g, int wi, int lane, int t, int jh, const uint4* blk, + const __nv_bfloat16* x0, const __nv_bfloat16* x1, bool v0, bool v1) { + const uint4* b = blk + (size_t)g * (M * BLOCK4); + const int d = g % D, k0 = g * 32 + 4 * t; +#pragma unroll + for (int m = 0; m < M; ++m) { + if constexpr (sizeof(Word) == 16) + tf_common::cp16(&w[wi][d][m][lane], b + m * BLOCK4 + lane); + else + tf_common::cp8(&w[wi][d][m][lane], reinterpret_cast(b + m * BLOCK4 + lane) + jh); + if (lane < 4) tf_common::cp16(&s[wi][d][m][lane], b + m * BLOCK4 + 32 + lane); + } +#pragma unroll + for (int h = 0; h < 2; ++h) { + if (v0) tf_common::cp8(&x[wi][d][h][lane], x0 + k0 + 16 * h); + if (v1) tf_common::cp8(&x[wi][d][2 + h][lane], x1 + k0 + 16 * h); + } + } + + // All KG groups in k order: `sum` takes each group's stage once its loads land. + template + __device__ __forceinline__ void run(int KG, int wi, int lane, int t, int jh, const uint4* blk, + const __nv_bfloat16* x0, const __nv_bfloat16* x1, bool v0, bool v1, Sum sum) { +#pragma unroll + for (int d = 0; d < D - 1; ++d) { + if (d < KG) issue(d, wi, lane, t, jh, blk, x0, x1, v0, v1); + tf_common::cp_commit(); + } + const uint2 zero = make_uint2(0u, 0u); + for (int g = 0; g < KG; ++g) { + if (g + D - 1 < KG) issue(g + D - 1, wi, lane, t, jh, blk, x0, x1, v0, v1); + tf_common::cp_commit(); + tf_common::cp_wait(); + __syncwarp(); + const int d = g % D; + Stage st; +#pragma unroll + for (int m = 0; m < M; ++m) { + st.w[m] = w[wi][d][m][lane]; + st.s[m] = s[wi][d][m][t]; + } +#pragma unroll + for (int h = 0; h < 2; ++h) { + st.xa[h] = v0 ? x[wi][d][h][lane] : zero; + st.xb[h] = v1 ? x[wi][d][2 + h][lane] : zero; + } + sum(st); + __syncwarp(); // every lane has read stage d before the next issue refills it + } + } +}; +#endif // One unit of the decode form: a warp's 32 columns of item `unit / NB` over all K, then the epilogue. -template -__device__ __forceinline__ void unit_full(int unit, int lane, int gq, int t, const __nv_bfloat16* __restrict__ X, - int x_stride, int slots, const uint4* __restrict__ W, - const float* __restrict__ scale, int KG, int NB, const int* __restrict__ items, - const int* __restrict__ members, void* __restrict__ out, int N, float limit, - int skip) { +template +__device__ __forceinline__ void unit_full(int unit, int lane, int gq, int t, int wi, + const __nv_bfloat16* __restrict__ X, int x_stride, int slots, + const uint4* __restrict__ W, const float* __restrict__ scale, int KG, int NB, + const int* __restrict__ items, const int* __restrict__ members, + void* __restrict__ out, int N, float limit, int skip) { + TF_RING_STORAGE Ring ring; const int it = unit / NB, cb = unit - it * NB; const int e = __ldg(items + 3 * it), first = __ldg(items + 3 * it + 1), cnt = __ldg(items + 3 * it + 2); if (e == skip) return; @@ -111,7 +183,7 @@ __device__ __forceinline__ void unit_full(int unit, int lane, int gq, int t, con for (int m = 0; m < M; ++m) #pragma unroll for (int j = 0; j < NTW; ++j) acc[m][0][j][0] = acc[m][0][j][1] = acc[m][0][j][2] = acc[m][0][j][3] = 0.f; - k_loop(acc, blk, KG, lane, t, x0, x1, v0, v1); + ring.run(KG, wi, lane, t, 0, blk, x0, x1, v0, v1, [&](const Stage& st) { compute_stage(acc, st, v1); }); #pragma unroll for (int m = 0; m < M; ++m) { const float g = __ldg(scale + e * M + m); @@ -133,7 +205,8 @@ __global__ void __launch_bounds__(WARPS * 32) const int lane = threadIdx.x & 31, gq = lane >> 2, t = lane & 3; const int units = __ldg(counts) * NB; for (int unit = blockIdx.x * WARPS + (threadIdx.x >> 5); unit < units; unit += gridDim.x * WARPS) - unit_full(unit, lane, gq, t, X, x_stride, slots, W, scale, KG, NB, items, members, out, N, limit, skip); + unit_full(unit, lane, gq, t, threadIdx.x >> 5, X, x_stride, slots, W, scale, KG, NB, items, + members, out, N, limit, skip); } // The decode form's units dealt in equal waves: ceil(units / waves) warps run, the others leave at once. @@ -150,36 +223,13 @@ __global__ void __launch_bounds__(WARPS * 32) const int run = (units + waves - 1) / waves, w = blockIdx.x * WARPS + (threadIdx.x >> 5); if (w >= run) return; for (int unit = w; unit < units; unit += run) - unit_full(unit, lane, gq, t, X, x_stride, slots, W, scale, KG, NB, items, members, out, N, limit, skip); + unit_full(unit, lane, gq, t, threadIdx.x >> 5, X, x_stride, slots, W, scale, KG, NB, items, + members, out, N, limit, skip); } // Half a unit's stage: the lane's words of n8 tiles 2jh and 2jh + 1, all its scales, its inputs. template -struct Half { - uint2 w[M]; - uint4 s[M]; - uint2 xa[2], xb[2]; -}; - -__device__ __forceinline__ uint2 ld_nc2(const void* p) { return tf_common::ld_nc2(p); } - -template -__device__ __forceinline__ void load_half(Half& st, const uint4* blk, int g, int lane, int t, int jh, - const __nv_bfloat16* x0, const __nv_bfloat16* x1, bool v0, bool v1) { - const uint4* b = blk + (size_t)g * (M * BLOCK4); -#pragma unroll - for (int m = 0; m < M; ++m) { - st.w[m] = ld_nc2(reinterpret_cast(b + m * BLOCK4 + lane) + jh); - st.s[m] = ld_nc(b + m * BLOCK4 + 32 + t); - } - const uint2 zero = make_uint2(0u, 0u); - const int k0 = g * 32 + 4 * t; -#pragma unroll - for (int h = 0; h < 2; ++h) { - st.xa[h] = v0 ? __ldg(reinterpret_cast(x0 + k0 + 16 * h)) : zero; - st.xb[h] = v1 ? __ldg(reinterpret_cast(x1 + k0 + 16 * h)) : zero; - } -} +using Half = Stage; // compute_stage's sums for tiles j = 2jh + jj: scale word 2h + jh, byte pair jj * 16. template @@ -248,10 +298,10 @@ __global__ void __launch_bounds__(WARPS * 32) const float* __restrict__ scale, int KG, int NB, const int* __restrict__ items, const int* __restrict__ counts, const int* __restrict__ members, void* __restrict__ out, int N, float limit, int skip) { - constexpr int D = 2; - const int lane = threadIdx.x & 31, gq = lane >> 2, t = lane & 3; + TF_RING_STORAGE Ring ring; + const int lane = threadIdx.x & 31, gq = lane >> 2, t = lane & 3, wi = threadIdx.x >> 5; const int units = __ldg(counts) * NB * 2; - for (int unit = blockIdx.x * WARPS + (threadIdx.x >> 5); unit < units; unit += gridDim.x * WARPS) { + for (int unit = blockIdx.x * WARPS + wi; unit < units; unit += gridDim.x * WARPS) { const int it = unit / (NB * 2), rest = unit - it * NB * 2, cb = rest >> 1, jh = rest & 1; const int e = __ldg(items + 3 * it), first = __ldg(items + 3 * it + 1), cnt = __ldg(items + 3 * it + 2); if (e == skip) continue; @@ -268,20 +318,7 @@ __global__ void __launch_bounds__(WARPS * 32) for (int m = 0; m < M; ++m) #pragma unroll for (int j = 0; j < 2; ++j) acc[m][j][0] = acc[m][j][1] = acc[m][j][2] = acc[m][j][3] = 0.f; - Half st[D]; -#pragma unroll - for (int d = 0; d < D; ++d) - if (d < KG) load_half(st[d], blk, d, lane, t, jh, x0, x1, v0, v1); - for (int g0 = 0; g0 < KG; g0 += D) { -#pragma unroll - for (int d = 0; d < D; ++d) { - const int g = g0 + d; - if (g < KG) { - compute_half(acc, st[d], v1, jh); - if (g + D < KG) load_half(st[d], blk, g + D, lane, t, jh, x0, x1, v0, v1); - } - } - } + ring.run(KG, wi, lane, t, jh, blk, x0, x1, v0, v1, [&](const Half& st) { compute_half(acc, st, v1, jh); }); #pragma unroll for (int m = 0; m < M; ++m) { const float g = __ldg(scale + e * M + m); diff --git a/zig/kernels/metal/core/hc_boundary.metal b/zig/kernels/metal/core/hc_boundary.metal index 728069f9c6b..4aace8d0018 100644 --- a/zig/kernels/metal/core/hc_boundary.metal +++ b/zig/kernels/metal/core/hc_boundary.metal @@ -2,20 +2,45 @@ #include using namespace metal; -// Defines: TF_D (stream width, multiple of 1024), TF_ITERS (Sinkhorn iterations), TF_HC_EPS_INT (split's eps in 1e-9). +// Defines: TF_D (stream width, 1024s), TF_ITERS, TF_HC_EPS_INT (split's eps in 1e-9), TF_HC_TOPK (a MoE's picks). constant constexpr int S = 4, F = S * TF_D, MIX = (2 + S) * S, SLICES = F / 1024, PARTS = MIX + 1; #pragma clang fp contract(off) inline float hc_sq_acc(float acc, float v) { return v * v + acc; } inline float hc_add_nc(float a, float b) { return a + b; } +inline float hc_mul_add(float acc, float a, float b) { return a * b + acc; } #pragma clang fp contract(on) +// A thread's 4 branch columns: BRANCH's, or (MOE) glm's combine of a MoE's rows BRANCH [rows, topk + 1, D] by W. +template +inline void hc_branch4(const device bfloat* BRANCH, const device float* W, int r, int d, thread float* b) { + if (!MOE) { + for (int i = 0; i < 4; i++) b[i] = float(BRANCH[size_t(r) * TF_D + d + i]); + return; + } + const device bfloat4* y = (const device bfloat4*)(BRANCH + size_t(r) * (TF_HC_TOPK + 1) * TF_D + d); + const bfloat4 y0 = y[0]; + float acc[4]; + for (int i = 0; i < 4; i++) acc[i] = W[r * TF_HC_TOPK] * float(y0[i]); + for (int k = 1; k < TF_HC_TOPK; k++) { + const bfloat4 yk = y[k * (TF_D / 4)]; + const float w = W[r * TF_HC_TOPK + k]; + for (int i = 0; i < 4; i++) acc[i] = hc_mul_add(acc[i], w, float(yk[i])); + } + const bfloat4 ys = y[TF_HC_TOPK * (TF_D / 4)]; + for (int i = 0; i < 4; i++) { + const bfloat v = bfloat(acc[i]) + ys[i]; + b[i] = float(v); + } +} + // (SLICES, rows) of 256: slice j's thread t expands 1024 j + 4 t..; squares + 24 mixes into PART [rows, SLICES, 25]. -template +template [[kernel]] void tf_hc_expand_mix(const device bfloat* XOLD [[buffer(0)]], const device bfloat* BRANCH [[buffer(1)]], const device float* POST [[buffer(2)]], const device float* COMB [[buffer(3)]], const device uint4* FNP [[buffer(4)]], device bfloat* XNEW [[buffer(5)]], - device float* PART [[buffer(6)]], uint2 tg [[threadgroup_position_in_grid]], + device float* PART [[buffer(6)]], const device float* W [[buffer(7)]], + uint2 tg [[threadgroup_position_in_grid]], uint2 tpos [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], uint sg [[simdgroup_index_in_threadgroup]]) { threadgroup float red[8][PARTS]; @@ -24,12 +49,17 @@ template const device bfloat* xo = XOLD + size_t(r) * F; float vals[4]; float ss = 0.0f; + float br[4]; + if (EXPAND) { + const int f0 = 1024 * j + 4 * int(t), s0 = f0 / TF_D; // a thread's 4 columns: one stream's + hc_branch4(BRANCH, W, r, f0 - s0 * TF_D, br); + } for (int tn = 0; tn < 4; tn++) { const int f = 1024 * j + 4 * int(t) + tn; float v; if (EXPAND) { const int s = f / TF_D, d = f - s * TF_D; - const float y = POST[r * S + s] * float(BRANCH[size_t(r) * TF_D + d]); + const float y = POST[r * S + s] * br[tn]; const device float* c = COMB + r * S * S; float mm = c[0 * S + s] * float(xo[0 * TF_D + d]); mm = fma(c[1 * S + s], float(xo[1 * TF_D + d]), mm); @@ -78,6 +108,84 @@ template template [[host_name("tf_hc_expand_mix")]] [[kernel]] decltype(tf_hc_expand_mix) tf_hc_expand_mix; template [[host_name("tf_hc_first_mix")]] [[kernel]] decltype(tf_hc_expand_mix) tf_hc_expand_mix; +template [[host_name("tf_hc_expand_mix_moe")]] [[kernel]] decltype(tf_hc_expand_mix) tf_hc_expand_mix; + +// tf_hc_expand_mix's parts on MIX / 4 groups a slice (z: 4 mixes; z 0 also squares, streams): the same sums, order. +template +[[kernel]] void tf_hc_expand_mix_parts(const device bfloat* XOLD [[buffer(0)]], const device bfloat* BRANCH [[buffer(1)]], + const device float* POST [[buffer(2)]], const device float* COMB [[buffer(3)]], + const device uint4* FNP [[buffer(4)]], device bfloat* XNEW [[buffer(5)]], + device float* PART [[buffer(6)]], const device float* W [[buffer(7)]], + uint3 tg [[threadgroup_position_in_grid]], + uint3 tpos [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + threadgroup float red[8][5]; + const int j = int(tg.x), r = int(tg.y), og = int(tg.z); + const uint t = tpos.x; + const device bfloat* xo = XOLD + size_t(r) * F; + float vals[4]; + float ss = 0.0f; + float br[4]; + if (EXPAND) { + const int f0 = 1024 * j + 4 * int(t), s0 = f0 / TF_D; // a thread's 4 columns: one stream's + hc_branch4(BRANCH, W, r, f0 - s0 * TF_D, br); + } + for (int tn = 0; tn < 4; tn++) { + const int f = 1024 * j + 4 * int(t) + tn; + float v; + if (EXPAND) { + const int s = f / TF_D, d = f - s * TF_D; + const float y = POST[r * S + s] * br[tn]; + const device float* c = COMB + r * S * S; + float mm = c[0 * S + s] * float(xo[0 * TF_D + d]); + mm = fma(c[1 * S + s], float(xo[1 * TF_D + d]), mm); + mm = fma(c[2 * S + s], float(xo[2 * TF_D + d]), mm); + mm = fma(c[3 * S + s], float(xo[3 * TF_D + d]), mm); + const bfloat nb = bfloat(hc_add_nc(y, mm)); + if (og == 0) XNEW[size_t(r) * F + f] = nb; + v = float(nb); + } else { + v = float(xo[f]); + } + vals[tn] = v; + ss = hc_sq_acc(ss, v); + } + float acc[5]; + { + const device uint4* w = FNP + (size_t(og * 8 + int(sg)) * 32 + lane) * SLICES * 2 + j * 2; + float inter[4][4]; + for (int h = 0; h < 2; h++) { + const uint4 v = w[h]; + const uint words[4] = {v.x, v.y, v.z, v.w}; + for (int k = 0; k < 4; k++) { + const int e = h * 8 + k * 2; + inter[e / 4][e % 4] = as_type(words[k] << 16); + inter[(e + 1) / 4][(e + 1) % 4] = as_type(words[k] & 0xffff0000u); + } + } + for (int tm = 0; tm < 4; tm++) { + float a = 0.0f; + for (int tn = 0; tn < 4; tn++) a += inter[tm][tn] * vals[tn]; + acc[tm] = a; + } + } + acc[4] = ss; + const int parts = og == 0 ? 5 : 4; + for (int i = 0; i < parts; i++) { + const float v = simd_sum(acc[i]); + if (lane == 0) red[sg][i] = v; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (int(t) < parts) { + float a = red[0][t]; + for (int k = 1; k < 8; k++) a += red[k][t]; + PART[(size_t(r) * SLICES + j) * PARTS + (t < 4 ? og * 4 + int(t) : MIX)] = a; + } +} + +template [[host_name("tf_hc_expand_mix_parts")]] [[kernel]] decltype(tf_hc_expand_mix_parts) tf_hc_expand_mix_parts; +template [[host_name("tf_hc_first_mix_parts")]] [[kernel]] decltype(tf_hc_expand_mix_parts) tf_hc_expand_mix_parts; +template [[host_name("tf_hc_expand_mix_parts_moe")]] [[kernel]] decltype(tf_hc_expand_mix_parts) tf_hc_expand_mix_parts; // In-place pending branch to the streams (one prompt buffer): TF_D / 4 a row, 4 stream columns each, read before write. [[kernel]] void tf_hc_expand_inplace(device bfloat* X [[buffer(0)]], const device bfloat* BRANCH [[buffer(1)]], @@ -106,50 +214,41 @@ inline float4 hc_col4(float4 v) { return v + simd_shuffle_xor(v, ushort(2)); } -// 1024 a row: slice sums in order, mixes by 1/norm, then the split (pre, post, Sinkhorn), streams collapsed, normed. +// A row's slice sums for parts 0..24 in order (lane l: part l), the mixes by 1/norm on lanes 0..23: the split's values. +inline float hc_mix_lane(const device float* PART, int r, uint lane, float eps) { + float a = 0.0f; + if (lane < (uint)PARTS) { + const device float* p = PART + size_t(r) * SLICES * PARTS + lane; + a = p[0]; + for (int j = 1; j < SLICES; j++) a += p[j * PARTS]; + } + const float sq = simd_shuffle(a, ushort(MIX)); + return a * metal::precise::rsqrt(sq / float(F) + eps); +} + +// (rows, 2) of 1024: group 0 collapses by pre and norms (one barrier), group 1 post and the comb; one group's bits. [[kernel]] void tf_hc_split(const device bfloat* X [[buffer(0)]], const device float* PART [[buffer(1)]], const constant float* SCALE [[buffer(2)]], const device float* BASEV [[buffer(3)]], const device bfloat* NORMW [[buffer(4)]], const constant float* EPS [[buffer(5)]], device bfloat* NORMED [[buffer(6)]], device float* POST_OUT [[buffer(7)]], - device float* COMB_OUT [[buffer(8)]], uint tg [[threadgroup_position_in_grid]], - uint t [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + device float* COMB_OUT [[buffer(8)]], uint2 tg [[threadgroup_position_in_grid]], + uint2 tpos [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], uint sg [[simdgroup_index_in_threadgroup]]) { constexpr float HC_EPS = TF_HC_EPS_INT * 1e-9; - const int r = int(tg); - threadgroup float tot[PARTS]; - threadgroup float mixes[MIX]; - threadgroup float red[32]; - threadgroup float pre_s[S]; - threadgroup float inv_s[1]; - device const bfloat* xs = X + size_t(r) * F; - float xv[4][S]; // this thread's 4 columns of the streams, loaded while the mixes and the Sinkhorn run - for (int i = 0; i < 4; ++i) { - for (int s = 0; s < S; ++s) xv[i][s] = float(xs[s * TF_D + int(t) * 4 + i]); - } - if (int(t) < PARTS) { - const device float* p = PART + size_t(r) * SLICES * PARTS + t; - float a = p[0]; - for (int j = 1; j < SLICES; j++) a += p[j * PARTS]; - tot[t] = a; - } - threadgroup_barrier(mem_flags::mem_threadgroup); - if (int(t) < MIX) mixes[t] = tot[t] * metal::precise::rsqrt(tot[MIX] / float(F) + EPS[0]); - threadgroup_barrier(mem_flags::mem_threadgroup); - if (sg == 0) { + const uint t = tpos.x; + const int r = int(tg.x); + const uint llane = metal::min(lane, (uint)(S - 1)); + if (tg.y == 1) { // post and the Sinkhorn comb + if (sg != 0) return; constexpr int BASE_OFF = 2 * S; - const float pre_scale = SCALE[0], post_scale = SCALE[1], comb_scale = SCALE[2]; + const float mix = hc_mix_lane(PART, r, lane, EPS[0]); + const float post_scale = SCALE[1], comb_scale = SCALE[2]; const float active = (lane < (uint)S) ? 1.0f : 0.0f; - const uint llane = metal::min(lane, (uint)(S - 1)); - const float pre_z = mixes[llane] * pre_scale + BASEV[llane]; - const float post_z = mixes[S + llane] * post_scale + BASEV[S + llane]; - const float pre_v = 1.0f / (1.0f + metal::fast::exp(-pre_z)) + HC_EPS; + const float post_z = simd_shuffle(mix, ushort(S + llane)) * post_scale + BASEV[S + llane]; const float post_v = 2.0f / (1.0f + metal::fast::exp(-post_z)); - if (lane < (uint)S) { - pre_s[lane] = pre_v; - POST_OUT[r * S + lane] = post_v; - } - const float4 m4 = float4(mixes[BASE_OFF + llane * S], mixes[BASE_OFF + llane * S + 1], mixes[BASE_OFF + llane * S + 2], - mixes[BASE_OFF + llane * S + 3]); + if (lane < (uint)S) POST_OUT[r * S + lane] = post_v; + const float4 m4 = float4(simd_shuffle(mix, ushort(BASE_OFF + llane * S)), simd_shuffle(mix, ushort(BASE_OFF + llane * S + 1)), + simd_shuffle(mix, ushort(BASE_OFF + llane * S + 2)), simd_shuffle(mix, ushort(BASE_OFF + llane * S + 3))); float4 v = (m4 * comb_scale + *(const device float4*)(BASEV + BASE_OFF + llane * S)) * active; const float row_max = metal::max(metal::max(v.x, v.y), metal::max(v.z, v.w)); const float4 e = metal::fast::exp(v - row_max) * active; @@ -162,9 +261,24 @@ inline float4 hc_col4(float4 v) { rr *= col_inv; } if (lane < (uint)S) *(device float4*)(COMB_OUT + r * S * S + lane * S) = rr; + return; + } + threadgroup float red[32]; + device const bfloat* xs = X + size_t(r) * F; + float xv[4][S]; // this thread's 4 columns of the streams, loaded while the mixes run + for (int i = 0; i < 4; ++i) { + for (int s = 0; s < S; ++s) xv[i][s] = float(xs[s * TF_D + int(t) * 4 + i]); + } + float p0, p1, p2, p3; + { // every simdgroup its own pre (lanes 0..3), the one-group split's sums + const float mix = hc_mix_lane(PART, r, lane, EPS[0]); + const float pre_z = mix * SCALE[0] + BASEV[llane]; + const float pre_v = 1.0f / (1.0f + metal::fast::exp(-pre_z)) + HC_EPS; + p0 = simd_shuffle(pre_v, ushort(0)); + p1 = simd_shuffle(pre_v, ushort(1)); + p2 = simd_shuffle(pre_v, ushort(2)); + p3 = simd_shuffle(pre_v, ushort(3)); } - threadgroup_barrier(mem_flags::mem_threadgroup); - const float p0 = pre_s[0], p1 = pre_s[1], p2 = pre_s[2], p3 = pre_s[3]; float xc[4]; float acc = 0.0f; for (int i = 0; i < 4; ++i) { @@ -173,17 +287,11 @@ inline float4 hc_col4(float4 v) { acc = hc_sq_acc(acc, xc[i]); } acc = simd_sum(acc); - if (sg == 0) red[lane] = 0.0f; - threadgroup_barrier(mem_flags::mem_threadgroup); if (lane == 0) red[sg] = acc; threadgroup_barrier(mem_flags::mem_threadgroup); - if (sg == 0) { - const float a = simd_sum(red[lane]); - if (lane == 0) inv_s[0] = metal::precise::rsqrt(a / float(TF_D) + EPS[0]); - } - threadgroup_barrier(mem_flags::mem_threadgroup); + const float inv = metal::precise::rsqrt(simd_sum(red[lane]) / float(TF_D) + EPS[0]); // every simdgroup the same for (int i = 0; i < 4; ++i) { const int d = int(t) * 4 + i; - NORMED[size_t(r) * TF_D + d] = NORMW[d] * bfloat(xc[i] * inv_s[0]); + NORMED[size_t(r) * TF_D + d] = NORMW[d] * bfloat(xc[i] * inv); } } diff --git a/zig/kernels/metal/core/moe_route.metal b/zig/kernels/metal/core/moe_route.metal index 0d5df32b2fd..78b800c762d 100644 --- a/zig/kernels/metal/core/moe_route.metal +++ b/zig/kernels/metal/core/moe_route.metal @@ -69,7 +69,60 @@ struct RouteArgs { float scale; }; -// 512 threads: each row's top-k by sigmoid + bias (ties to the lower id), weights, then this Mac's groups, pick lists. +// Row r's first n picks by sigmoid + bias in every lane: the largest score (simd_max), its lowest id (simd_min). +inline void tf_route_picks(const device float* LOGITS, const device float* BIAS, int r, uint lane, int n, thread int* pick, + thread float* w) { + float c[PER], sc[PER]; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < TF_E) { + sc[j] = tf_sigmoid_precise(LOGITS[r * TF_E + id]); + c[j] = sc[j] + BIAS[id]; + } else { + sc[j] = 0.0f; c[j] = -INFINITY; + } + } + for (int k = 0; k < TF_TOPK; k++) { + if (k >= n) continue; + float best = -INFINITY, bsc = 0.0f; + int bid = TF_E; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < TF_E && (c[j] > best || (c[j] == best && id < bid))) { best = c[j]; bid = id; bsc = sc[j]; } + } + const float top = simd_max(best); // no lane's best is NaN: a NaN score never passes the compares + bid = simd_min(best == top ? bid : TF_E); + bsc = simd_shuffle(bsc, ushort(bid % 32)); + pick[k] = bid; + w[k] = bid < TF_E ? bsc : 0.0f; + for (int j = 0; j < PER; j++) + if (j * 32 + int(lane) == bid) c[j] = -INFINITY; + } +} + +// The picks' weights: normalized in pick order, then scaled. +inline void tf_route_weights(thread const float* w, float scale, device float* out) { + float total = w[0]; + for (int k = 1; k < TF_TOPK; k++) total = total + w[k]; + for (int k = 0; k < TF_TOPK; k++) out[k] = (w[k] / total) * scale; +} + +// A one-row MoE kernel's pick u, the select's picks replayed; `write`: lane 0 writes the picks and weights too. +inline int tf_route_pick_at(const device float* LOGITS, const device float* BIAS, int u, uint lane, bool write, + device int* PICK, device float* WTS, float scale) { + int p[TF_TOPK]; + float w[TF_TOPK]; + tf_route_picks(LOGITS, BIAS, 0, lane, write ? TF_TOPK : u + 1, p, w); + if (write && lane == 0) { + for (int k = 0; k < TF_TOPK; k++) PICK[k] = p[k]; + tf_route_weights(w, scale, WTS); + } + int e = p[0]; + for (int k = 1; k < TF_TOPK; k++) e = k == u ? p[k] : e; + return e; +} + +// 512 threads: each row's top-k by sigmoid + bias (tf_route_picks), weights, then this Mac's groups and pick lists. [[kernel]] void tf_route_select(const device float* LOGITS [[buffer(0)]], const device float* BIAS [[buffer(1)]], constant RouteArgs& a [[buffer(2)]], device int* PICK [[buffer(3)]], device float* WTS [[buffer(4)]], device int* LIDS [[buffer(5)]], @@ -81,51 +134,30 @@ struct RouteArgs { const int R = a.rows; const int e = int(t); threadgroup int picks[TF_MAXR * TF_TOPK]; + threadgroup uchar slot[TF_MAXR][TF_E]; // row r's pick k of expert e, 0xff unpicked threadgroup int offs[3][16]; if (int(g) < R) { const int r = int(g); - float c[PER], sc[PER]; - for (int j = 0; j < PER; j++) { - const int id = j * 32 + int(lane); - if (id < TF_E) { - sc[j] = tf_sigmoid_precise(LOGITS[r * TF_E + id]); - c[j] = sc[j] + BIAS[id]; - } else { - sc[j] = 0.0f; c[j] = -INFINITY; - } - } + for (int id = int(lane); id < TF_E; id += 32) slot[r][id] = 0xff; + simdgroup_barrier(mem_flags::mem_threadgroup); + int p[TF_TOPK]; float w[TF_TOPK]; - for (int k = 0; k < TF_TOPK; k++) { - float best = -INFINITY, bsc = 0.0f; - int bid = TF_E; - for (int j = 0; j < PER; j++) { - const int id = j * 32 + int(lane); - if (id < TF_E && (c[j] > best || (c[j] == best && id < bid))) { best = c[j]; bid = id; bsc = sc[j]; } - } - for (int off = 16; off > 0; off /= 2) { - const float ob = simd_shuffle_xor(best, off); - const int oi = simd_shuffle_xor(bid, off); - const float os = simd_shuffle_xor(bsc, off); - if (ob > best || (ob == best && oi < bid)) { best = ob; bid = oi; bsc = os; } - } - w[k] = bsc; - if (int(lane) == bid % 32) c[bid / 32] = -INFINITY; - if (lane == 0) { picks[r * TF_TOPK + k] = bid; PICK[r * TF_TOPK + k] = bid; } - } + tf_route_picks(LOGITS, BIAS, r, lane, TF_TOPK, p, w); if (lane == 0) { - float total = w[0]; - for (int k = 1; k < TF_TOPK; k++) total = total + w[k]; - for (int k = 0; k < TF_TOPK; k++) WTS[r * TF_TOPK + k] = (w[k] / total) * a.scale; + for (int k = 0; k < TF_TOPK; k++) { + picks[r * TF_TOPK + k] = p[k]; + PICK[r * TF_TOPK + k] = p[k]; + if (p[k] < TF_E) slot[r][p[k]] = uchar(k); + } + tf_route_weights(w, a.scale, WTS + r * TF_TOPK); } } threadgroup_barrier(mem_flags::mem_threadgroup); - // the held experts the window picked, ascending, with their member picks in pick order - int members[TF_MAXR]; + // the held experts the window picked, ascending, with their member picks in pick order (a row picks an expert once) int count = 0; - const bool held_id = e >= a.lo && e < a.hi; + const bool held_id = e >= a.lo && e < a.hi && e < TF_E; if (held_id) - for (int p = 0; p < R * TF_TOPK; p++) - if (picks[p] == e) members[count++] = p; + for (int r = 0; r < R; r++) count += slot[r][e] != 0xff ? 1 : 0; const int held = count > 0 ? 1 : 0; // each pick: computed here or by the peer const int pe = e < R * TF_TOPK ? picks[e] : -1; @@ -134,15 +166,20 @@ struct RouteArgs { const int b0 = simd_prefix_exclusive_sum(held), b1 = simd_prefix_exclusive_sum(mine), b2 = simd_prefix_exclusive_sum(theirs); if (lane == 31) { offs[0][g] = b0 + held; offs[1][g] = b1 + mine; offs[2][g] = b2 + theirs; } threadgroup_barrier(mem_flags::mem_threadgroup); - int o0 = 0, o1 = 0, o2 = 0, n0 = 0, n1 = 0, n2 = 0; - for (uint k = 0; k < 16; k++) { - if (k < g) { o0 += offs[0][k]; o1 += offs[1][k]; o2 += offs[2][k]; } - n0 += offs[0][k]; n1 += offs[1][k]; n2 += offs[2][k]; - } + // simdgroup g's offsets: the counts of the groups before it (integer sums, any order), and the totals + const int c0 = lane < 16 ? offs[0][lane] : 0, c1 = lane < 16 ? offs[1][lane] : 0, c2 = lane < 16 ? offs[2][lane] : 0; + const int o0 = simd_shuffle(simd_prefix_exclusive_sum(c0), ushort(g)), n0 = simd_sum(c0); + const int o1 = simd_shuffle(simd_prefix_exclusive_sum(c1), ushort(g)), n1 = simd_sum(c1); + const int o2 = simd_shuffle(simd_prefix_exclusive_sum(c2), ushort(g)), n2 = simd_sum(c2); if (held) { const int u = o0 + b0; LIDS[u] = e - a.lo; - for (int j = 0; j < TF_MAXR; j++) LMEM[u * TF_MAXR + j] = j < count ? members[j] : -1; + int j = 0; + for (int r = 0; r < R; r++) { + const int s = slot[r][e]; + if (s != 0xff) LMEM[u * TF_MAXR + j++] = r * TF_TOPK + s; + } + for (; j < TF_MAXR; j++) LMEM[u * TF_MAXR + j] = -1; } if (mine) MINE[o1 + b1] = e; if (theirs) THEIRS[o2 + b2] = e; diff --git a/zig/kernels/metal/glm_attn.metal b/zig/kernels/metal/glm_attn.metal index 2dcd02576ee..8e1528bb46c 100644 --- a/zig/kernels/metal/glm_attn.metal +++ b/zig/kernels/metal/glm_attn.metal @@ -9,26 +9,51 @@ inline void glm_join(thread frag& c, thread const frag& d) { c = (frag(0.0f) + c) + d; } -// S[64,n] = QK^T in 16-wide steps (simdgroup g: heads 16 g.., a threadgroup 32 keys); arg.y: two 256-dim halves joined. -[[kernel]] void glm_latent_scores(const device bfloat* q [[buffer(0)]], const device bfloat* keys [[buffer(1)]], - device bfloat* s [[buffer(2)]], constant int2& arg [[buffer(3)]], - uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], - uint lane [[thread_index_in_simdgroup]]) { - const int n = arg.x, col0 = int(tg.x) * 32, row0 = int(g) * 16; +// The query block scaled as glm_scale scales it: bf16(q * qs), exact for a power of two (QS; else as loaded). +template +inline void glm_q_scaled(thread frag& a, float qs) { + if (QS) + for (short e = 0; e < 8; e++) a[e] = bfloat(float(a[e]) * qs); +} + +// S[64,n] = QK^T in 16-wide steps (heads 16 hg.., keys 32 kb..), loads a step ahead; halves: two 256-dim halves joined. +template +inline void glm_scores_at(const device bfloat* q, const device bfloat* keys, device bfloat* s, int n, bool halves, + int kb, int hg, uint lane, float qs = 1.0f) { + const int col0 = kb * 32, row0 = hg * 16; const short2 home = frag_home(ushort(lane)); + const bool inside = col0 + 32 <= n; frag c0 = 0.0f, c1 = 0.0f, d0 = 0.0f, d1 = 0.0f; + frag a, b0, b1; + frag_get(a, q, 512, row0, 0, home); + glm_q_scaled(a, qs); + if (inside) { + frag_get_t(b0, keys, 512, col0, 0, home); + frag_get_t(b1, keys, 512, col0 + 16, 0, home); + } else { + frag_get_t_in(b0, keys, 512, col0, 0, home, n, 512); + frag_get_t_in(b1, keys, 512, col0 + 16, 0, home, n, 512); + } for (int k0 = 0; k0 < 512; k0 += 16) { - frag a, b0, b1; - frag_get_in(a, q, 512, row0, k0, home, 64, 512); - frag_get_t_in(b0, keys, 512, col0, k0, home, n, 512); - frag_get_t_in(b1, keys, 512, col0 + 16, k0, home, n, 512); - if (arg.y != 0 && k0 >= 256) { - mma_16x32(d0, d1, a, b0, b1); + const frag ca = a, cb0 = b0, cb1 = b1; + if (k0 + 16 < 512) { + frag_get(a, q, 512, row0, k0 + 16, home); + glm_q_scaled(a, qs); + if (inside) { + frag_get_t(b0, keys, 512, col0, k0 + 16, home); + frag_get_t(b1, keys, 512, col0 + 16, k0 + 16, home); + } else { + frag_get_t_in(b0, keys, 512, col0, k0 + 16, home, n, 512); + frag_get_t_in(b1, keys, 512, col0 + 16, k0 + 16, home, n, 512); + } + } + if (halves && k0 >= 256) { + mma_16x32(d0, d1, ca, cb0, cb1); } else { - mma_16x32(c0, c1, a, b0, b1); + mma_16x32(c0, c1, ca, cb0, cb1); } } - if (arg.y != 0) { + if (halves) { glm_join(c0, d0); glm_join(c1, d1); } @@ -36,27 +61,65 @@ inline void glm_join(thread frag& c, thread const frag& d) { frag_put_in(c1, s, n, row0, col0 + 16, home, 64, n); } +// One row: simdgroup g heads 16 g.., a threadgroup 32 keys; arg.y: two 256-dim halves joined (fewer than 256 keys). +[[kernel]] void glm_latent_scores(const device bfloat* q [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* s [[buffer(2)]], constant int2& arg [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]]) { + glm_scores_at(q, keys, s, arg.x, arg.y != 0, int(tg.x), int(g), lane); +} + +// A window's rows: row z has n0 + z keys; its query, scores and output `stride` apart; the queries' scale. +struct GlmAttnRows { + int n0, q_stride, s_stride, o_stride; + float q_scale; +}; + +// Each row as glm_scale then glm_latent_scores leave it: heads 16 (tg.y * simdgroups + g).., keys 32 tg.x.. +[[kernel]] void glm_latent_scores_rows(const device bfloat* q [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* s [[buffer(2)]], constant GlmAttnRows& a [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint sgs [[simdgroups_per_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + const int z = int(tg.z), n = a.n0 + z; + if (int(tg.x) * 32 >= n) return; + glm_scores_at(q + size_t(z) * a.q_stride, keys, s + size_t(z) * a.s_stride, n, n < 256, int(tg.x), + int(tg.y * sgs + g), lane, a.q_scale); +} + +// A values step's blocks at key k0: inside hi unchecked, else zeros past hi (the same values either way). +inline void glm_values_load(thread frag& a, thread frag& b0, thread frag& b1, + const device bfloat* p, const device bfloat* keys, int n, int hi, int k0, int row0, int col0, + short2 home) { + if (k0 + 16 <= hi) { + frag_get(a, p, n, row0, k0, home); + frag_get(b0, keys, 512, k0, col0, home); + frag_get(b1, keys, 512, k0, col0 + 16, home); + } else { + frag_get_in(a, p, n, row0, k0, home, 64, hi); + frag_get_in(b0, keys, 512, k0, col0, home, hi, 512); + frag_get_in(b1, keys, 512, k0, col0 + 16, home, hi, 512); + } +} + // Keys [lo, hi) of O += P K in 16-wide steps: whole 256-key blocks, then the rest rounded up to 32 (zeros past hi). inline void glm_values_run(thread frag& c0, thread frag& c1, const device bfloat* p, const device bfloat* keys, int n, int lo, int hi, int row0, int col0, short2 home) { const int len = hi - lo; const int steps = (len / 256) * 16 + ((len % 256) + 31) / 32 * 2; + if (steps == 0) return; + frag a, b0, b1; + glm_values_load(a, b0, b1, p, keys, n, hi, lo, row0, col0, home); for (int i = 0; i < steps; ++i) { - const int k0 = lo + 16 * i; - frag a, b0, b1; - frag_get_in(a, p, n, row0, k0, home, 64, hi); - frag_get_in(b0, keys, 512, k0, col0, home, hi, 512); - frag_get_in(b1, keys, 512, k0, col0 + 16, home, hi, 512); - mma_16x32(c0, c1, a, b0, b1); + const frag ca = a, cb0 = b0, cb1 = b1; + if (i + 1 < steps) glm_values_load(a, b0, b1, p, keys, n, hi, lo + 16 * (i + 1), row0, col0, home); + mma_16x32(c0, c1, ca, cb0, cb1); } } -// O[64,512] = PK in 16-wide steps (simdgroup g: heads 16 g.., a threadgroup 32 dims); arg.y > 0: keys [0, arg.y) apart. -[[kernel]] void glm_latent_values(const device bfloat* p [[buffer(0)]], const device bfloat* keys [[buffer(1)]], - device bfloat* o [[buffer(2)]], constant int2& arg [[buffer(3)]], - uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], - uint lane [[thread_index_in_simdgroup]]) { - const int n = arg.x, part = arg.y, col0 = int(tg.x) * 32, row0 = int(g) * 16; +// O[64,512] = PK in 16-wide steps (heads 16 hg.., dims 32 db..); part > 0: keys [0, part) apart. +inline void glm_values_at(const device bfloat* p, const device bfloat* keys, device bfloat* o, int n, int part, int db, + int hg, uint lane) { + const int col0 = db * 32, row0 = hg * 16; const short2 home = frag_home(ushort(lane)); frag c0 = 0.0f, c1 = 0.0f; glm_values_run(c0, c1, p, keys, n, 0, part > 0 ? part : n, row0, col0, home); @@ -69,3 +132,21 @@ inline void glm_values_run(thread frag& c0, thread frag& c1, const frag_put_in(c0, o, 512, row0, col0, home, 64, 512); frag_put_in(c1, o, 512, row0, col0 + 16, home, 64, 512); } + +// One row: simdgroup g heads 16 g.., a threadgroup 32 dims; arg.y > 0: keys [0, arg.y) apart. +[[kernel]] void glm_latent_values(const device bfloat* p [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* o [[buffer(2)]], constant int2& arg [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]]) { + glm_values_at(p, keys, o, arg.x, arg.y, int(tg.x), int(g), lane); +} + +// Each row as glm_latent_values leaves it (past 1,024 keys the first 1,024 apart, as the one-row launch sets). +[[kernel]] void glm_latent_values_rows(const device bfloat* p [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* o [[buffer(2)]], constant GlmAttnRows& a [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint sgs [[simdgroups_per_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + const int z = int(tg.z), n = a.n0 + z; + glm_values_at(p + size_t(z) * a.s_stride, keys, o + size_t(z) * a.o_stride, n, n > 1024 ? 1024 : 0, int(tg.x), + int(tg.y * sgs + g), lane); +} diff --git a/zig/kernels/metal/glm_glue.metal b/zig/kernels/metal/glm_glue.metal index 422f7938115..8edf610be93 100644 --- a/zig/kernels/metal/glm_glue.metal +++ b/zig/kernels/metal/glm_glue.metal @@ -14,17 +14,13 @@ kernel void glm_cast_f32(const device bfloat* x [[buffer(0)]], device float* y [ if (i < n) y[i] = float(x[i]); } -// MLX's rms_single_row on strided rows: thread t squares 4t..4t+3, simd_sum, a 32-slot simd_sum, precise rsqrt. -kernel void glm_rms(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], - device bfloat* y [[buffer(2)]], constant GlmRows& a [[buffer(3)]], - uint row [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]], - uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { - threadgroup float sg_sums[32]; - threadgroup float inv_rms[1]; - const uint width = uint(a.width), lo = 4 * t; - const device bfloat* src = x + size_t(row) * a.x_stride + lo; - device bfloat* dst = y + size_t(row) * a.y_stride + lo; - const device bfloat* gain = w + lo; +// MLX's rms_single_row on a row: thread t squares 4t..4t+3, simd_sum, a 32-slot simd_sum, precise rsqrt. +inline void glm_rms_row(const device bfloat* src, const device bfloat* gain, device bfloat* dst, uint width, float eps, + threadgroup float* sg_sums, threadgroup float* inv_rms, uint t, uint sg, uint lane) { + const uint lo = 4 * t; + src += lo; + dst += lo; + gain += lo; const bool whole = lo + 4 <= width; float v[4]; float sq = 0.0f; @@ -46,7 +42,7 @@ kernel void glm_rms(const device bfloat* x [[buffer(0)]], const device bfloat* w threadgroup_barrier(mem_flags::mem_threadgroup); if (sg == 0) { const float all = simd_sum(sg_sums[lane]); - if (lane == 0) inv_rms[0] = metal::precise::rsqrt(all / float(width) + a.eps); + if (lane == 0) inv_rms[0] = metal::precise::rsqrt(all / float(width) + eps); } threadgroup_barrier(mem_flags::mem_threadgroup); if (whole) { @@ -57,6 +53,16 @@ kernel void glm_rms(const device bfloat* x [[buffer(0)]], const device bfloat* w } } +kernel void glm_rms(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], + device bfloat* y [[buffer(2)]], constant GlmRows& a [[buffer(3)]], + uint row [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + threadgroup float sg_sums[32]; + threadgroup float inv_rms[1]; + glm_rms_row(x + size_t(row) * a.x_stride, w, y + size_t(row) * a.y_stride, uint(a.width), a.eps, sg_sums, inv_rms, t, + sg, lane); +} + // MLX's layer_norm_single_row (8 values a thread, 32 threads a row): the indexer's key norm with weight and bias. inline float glm_tg_sum(float x, threadgroup float* xs, uint lane, uint sg) { x = simd_sum(x); @@ -67,18 +73,14 @@ inline float glm_tg_sum(float x, threadgroup float* xs, uint lane, uint sg) { return simd_sum(x); } -kernel void glm_layer_norm(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], - const device bfloat* b [[buffer(2)]], device bfloat* y [[buffer(3)]], - constant GlmRows& a [[buffer(4)]], uint row [[threadgroup_position_in_grid]], - uint lid [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], - uint sg [[simdgroup_index_in_threadgroup]]) { +// A row of `axis`: threads past axis / 8 add zeros, so a larger group (glm_mla_norms') leaves the same bits. +inline void glm_ln_row(const device bfloat* x, const device bfloat* w, const device bfloat* b, device bfloat* y, int axis, + float eps, threadgroup float* local_buffer, uint lid, uint lane, uint sg) { constexpr int N_READS = 8; float thread_x[N_READS] = {0}; - threadgroup float local_buffer[32]; if (sg == 0) local_buffer[lane] = 0; - const int axis = a.width; - const device bfloat* xr = x + size_t(row) * a.x_stride + lid * N_READS; - device bfloat* out = y + size_t(row) * a.y_stride + lid * N_READS; + const device bfloat* xr = x + lid * N_READS; + device bfloat* out = y + lid * N_READS; const device bfloat* wr = w + lid * N_READS; const device bfloat* br = b + lid * N_READS; const bool safe = int(lid) * N_READS + N_READS <= axis; @@ -101,7 +103,7 @@ kernel void glm_layer_norm(const device bfloat* x [[buffer(0)]], const device bf normalizer += thread_x[i] * thread_x[i]; } normalizer = glm_tg_sum(normalizer, local_buffer, lane, sg); - normalizer = metal::precise::rsqrt(normalizer / axis + a.eps); + normalizer = metal::precise::rsqrt(normalizer / axis + eps); if (safe) { for (int i = 0; i < N_READS; i++) { thread_x[i] *= normalizer; @@ -115,6 +117,44 @@ kernel void glm_layer_norm(const device bfloat* x [[buffer(0)]], const device bf } } +kernel void glm_layer_norm(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], + const device bfloat* b [[buffer(2)]], device bfloat* y [[buffer(3)]], + constant GlmRows& a [[buffer(4)]], uint row [[threadgroup_position_in_grid]], + uint lid [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + threadgroup float local_buffer[32]; + glm_ln_row(x + size_t(row) * a.x_stride, w, b, y + size_t(row) * a.y_stride, a.width, a.eps, local_buffer, lid, lane, + sg); +} + +// An MLA layer's small launches after x_proj, group y: kv norm, key norm, index weights, query norm (their bits). +struct GlmMlaNorms { + int x_stride, kv_at, ik_at, iw_at, kv_width, ik_width, iw_width, q_width; + float kv_eps, ik_eps, iw_scale, q_eps; +}; + +kernel void glm_mla_norms(const device bfloat* xp [[buffer(0)]], const device bfloat* kv_w [[buffer(1)]], + device bfloat* keys [[buffer(2)]], const device bfloat* ik_w [[buffer(3)]], + const device bfloat* ik_b [[buffer(4)]], device bfloat* ik [[buffer(5)]], + device bfloat* iw [[buffer(6)]], constant GlmMlaNorms& a [[buffer(7)]], + const device bfloat* q_w [[buffer(8)]], device bfloat* qr [[buffer(9)]], + uint2 tg [[threadgroup_position_in_grid]], uint2 tp [[thread_position_in_threadgroup]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + threadgroup float sums[33]; + const uint t = tp.x; + const device bfloat* x = xp + size_t(tg.x) * a.x_stride; + if (tg.y == 0) { + glm_rms_row(x + a.kv_at, kv_w, keys + size_t(tg.x) * a.kv_width, uint(a.kv_width), a.kv_eps, sums, sums + 32, t, sg, + lane); + } else if (tg.y == 1) { + glm_ln_row(x + a.ik_at, ik_w, ik_b, ik + size_t(tg.x) * a.ik_width, a.ik_width, a.ik_eps, sums, t, lane, sg); + } else if (tg.y == 3) { + glm_rms_row(x, q_w, qr + size_t(tg.x) * a.q_width, uint(a.q_width), a.q_eps, sums, sums + 32, t, sg, lane); + } else if (int(t) < a.iw_width) { + iw[size_t(tg.x) * a.iw_width + t] = bfloat(float(x[a.iw_at + int(t)]) * a.iw_scale); + } +} + // The absorb q_nope [b, 256] @ W_k[h] [256, 512] (h = b % HEADS, kv_b's key rows) in affine_qvm's 4-bit sum order. kernel void glm_absorb(const device uint32_t* w [[buffer(0)]], const device bfloat* scales [[buffer(1)]], const device bfloat* biases [[buffer(2)]], const device bfloat* x [[buffer(3)]], diff --git a/zig/kernels/metal/glm_index_nax.metal b/zig/kernels/metal/glm_index_nax.metal index 1f55031f96a..921845be010 100644 --- a/zig/kernels/metal/glm_index_nax.metal +++ b/zig/kernels/metal/glm_index_nax.metal @@ -24,82 +24,67 @@ inline frag ix_frag(const device bfloat* r0, const device bfloat* r1, in #endif } -// Grid: 64-block, 64-row tiles; 4 simdgroups, 32 rows x 32 blocks; only read blocks stored, whole tiles beyond skipped. +// Grid: 64-block tiles of 16 rows a simdgroup (4 or 8: 64 or 128 rows), 64 blocks each; empty tiles skipped. [[kernel]] void glm_index_scores_nax(const device bfloat* iq [[buffer(0)]], const device bfloat* iw [[buffer(1)]], const device bfloat* pool [[buffer(2)]], device float* scores [[buffer(3)]], constant GlmScoreArgs& a [[buffer(4)]], uint sg [[simdgroup_index_in_threadgroup]], - uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]], + uint sgs [[simdgroups_per_threadgroup]]) { threadgroup bfloat tile[64 * PAD]; - const int b0 = int(tg.x) * 64, r0 = int(tg.y) * 64; - const int rows = min(64, int(a.rows) - r0); + const int tile_rows = 16 * int(sgs); + const int b0 = int(tg.x) * 64, r0 = int(tg.y) * tile_rows; + const int rows = min(tile_rows, int(a.rows) - r0); if (b0 >= (int(a.p0) + r0 + rows) / 4) return; // the tile's last row reads blocks below (p0 + row + 1) / 4 const uint t = sg * 32 + lane; - for (uint i = t; i < 64 * (DI / 8); i += 128) { // the 64 blocks' pooled keys, 16 bytes a load (past the pool: its last) + for (uint i = t; i < 64 * (DI / 8); i += 32 * sgs) { // the 64 blocks' pooled keys, 16 bytes a load (past the pool: its last) const uint rr = i / (DI / 8), cc = (i % (DI / 8)) * 8; const int b = min(b0 + int(rr), int(a.s_stride) - 1); *(threadgroup uint4*)(tile + rr * PAD + cc) = *(const device uint4*)(pool + size_t(b) * DI + cc); } threadgroup_barrier(mem_flags::mem_threadgroup); const short2 home = frag_home(ushort(lane)); - const int tm = 32 * int(sg / 2), tn = 32 * int(sg % 2); - const device bfloat* qr[2][2]; - const device bfloat* wr[2][2]; + const int tm = 16 * int(sg); + const device bfloat* qr[2]; + const device bfloat* wr[2]; TF_UNROLL - for (short m = 0; m < 2; m++) { - TF_UNROLL - for (short h = 0; h < 2; h++) { - const int r = tm + 16 * m + home.y + 8 * h; - const long at = long(r0 + (r < rows ? r : 0)); // a dead row reads a live one; its scores are never stored - qr[m][h] = iq + at * a.q_stride; - wr[m][h] = iw + at * a.w_stride; - } + for (short h = 0; h < 2; h++) { + const int r = tm + home.y + 8 * h; + const long at = long(r0 + (r < rows ? r : 0)); // a dead row reads a live one; its scores are never stored + qr[h] = iq + at * a.q_stride; + wr[h] = iw + at * a.w_stride; } - frag total[2][2]; + frag total[4]; TF_UNROLL - for (short m = 0; m < 2; m++) { - total[m][0] = frag(0); - total[m][1] = frag(0); - } + for (short j = 0; j < 4; j++) total[j] = frag(0); for (int hd = 0; hd < HI; hd++) { - frag s[2][2]; + frag s[4]; TF_UNROLL - for (short m = 0; m < 2; m++) { - s[m][0] = frag(0); - s[m][1] = frag(0); - } + for (short j = 0; j < 4; j++) s[j] = frag(0); TF_UNROLL for (short q = 0; q < DI / 16; q++) { - frag k0, k1; - frag_get_t(k0, (const threadgroup bfloat*)tile, PAD, tn, 16 * q, home); - frag_get_t(k1, (const threadgroup bfloat*)tile, PAD, tn + 16, 16 * q, home); + const frag qa = ix_frag(qr[0] + hd * DI, qr[1] + hd * DI, 16 * q, home); TF_UNROLL - for (short m = 0; m < 2; m++) { - const frag qa = ix_frag(qr[m][0] + hd * DI, qr[m][1] + hd * DI, 16 * q, home); - mma_16x32(s[m][0], s[m][1], qa, k0, k1); + for (short n = 0; n < 2; n++) { + frag k0, k1; + frag_get_t(k0, (const threadgroup bfloat*)tile, PAD, 32 * n, 16 * q, home); + frag_get_t(k1, (const threadgroup bfloat*)tile, PAD, 32 * n + 16, 16 * q, home); + mma_16x32(s[2 * n], s[2 * n + 1], qa, k0, k1); } } + const float w0 = float(wr[0][hd]), w1 = float(wr[1][hd]); TF_UNROLL - for (short m = 0; m < 2; m++) { - const float w0 = float(wr[m][0][hd]), w1 = float(wr[m][1][hd]); + for (short j = 0; j < 4; j++) { TF_UNROLL - for (short j = 0; j < 2; j++) { - TF_UNROLL - for (short e = 0; e < 8; e++) { - total[m][j][e] = fma(e < 4 ? w0 : w1, metal::max(s[m][j][e], 0.0f), total[m][j][e]); - } - } + for (short e = 0; e < 8; e++) total[j][e] = fma(e < 4 ? w0 : w1, metal::max(s[j][e], 0.0f), total[j][e]); } } TF_UNROLL - for (short m = 0; m < 2; m++) { + for (short j = 0; j < 4; j++) { TF_UNROLL - for (short j = 0; j < 2; j++) { - TF_UNROLL - for (short e = 0; e < 8; e++) { - const int r = tm + 16 * m + home.y + (e >> 2) * 8; - const int b = b0 + tn + 16 * j + home.x + TF_COL(e); - if (r < rows && b < (int(a.p0) + r0 + r + 1) / 4) scores[size_t(r0 + r) * a.s_stride + b] = total[m][j][e]; - } + for (short e = 0; e < 8; e++) { + const int r = tm + home.y + (e >> 2) * 8; + const int b = b0 + 16 * j + home.x + TF_COL(e); + if (r < rows && b < (int(a.p0) + r0 + r + 1) / 4) scores[size_t(r0 + r) * a.s_stride + b] = total[j][e]; } } } diff --git a/zig/kernels/metal/glm_kda_parts.metal b/zig/kernels/metal/glm_kda_parts.metal new file mode 100644 index 00000000000..3bb1264226e --- /dev/null +++ b/zig/kernels/metal/glm_kda_parts.metal @@ -0,0 +1,211 @@ +// A window's KDA step, each head on G threadgroups (D / G value columns each), then glm_kda_norm: kda_rows' values. +template +[[max_total_threads_per_threadgroup(32 * TY)]] +[[kernel]] void glm_kda_parts(const device bfloat16_t* P [[buffer(0)]], const constant int* P_shape [[buffer(1)]], + const device bfloat16_t* CS [[buffer(2)]], const device float* CW [[buffer(3)]], + const device uint32_t* FBW [[buffer(4)]], const device bfloat16_t* FBS [[buffer(5)]], + const device bfloat16_t* FBB [[buffer(6)]], const device uint32_t* GBW [[buffer(7)]], + const device bfloat16_t* GBS [[buffer(8)]], const device bfloat16_t* GBB [[buffer(9)]], + const device float* A [[buffer(10)]], const device float* DTB [[buffer(11)]], + const device float* ST [[buffer(12)]], device bfloat16_t* GATE [[buffer(13)]], + const constant float* LB [[buffer(14)]], device bfloat16_t* Y [[buffer(16)]], + device float* ST_OUT [[buffer(17)]], device bfloat16_t* CS_OUT [[buffer(18)]], + uint sgi [[simdgroup_index_in_threadgroup]], uint tid [[thread_index_in_threadgroup]], + uint3 tpos [[thread_position_in_threadgroup]], uint3 tgpos [[threadgroup_position_in_grid]]) { + const uint h = tgpos.z; + const uint part = tgpos.y; // value columns [dv0, dv0 + DV): their v, gates, recurrence; decays, q and k whole + const uint lane = tpos.x; + const uint ty = tpos.y; + constexpr int NT = 32 * TY; + constexpr int DV = D / G; + constexpr int NDK = D / 32; + constexpr int NDV = DV / TY; + constexpr int RBLK = D / 128; + constexpr int REXTRA = D - RBLK * 128; + constexpr uint W = (uint)(H * D); + constexpr uint C3 = 3u * W; + constexpr uint FA = C3; + constexpr uint GA = C3 + (uint)D; + constexpr uint BO = C3 + 2u * (uint)D; + static_assert(DV % TY == 0 && NDV >= 1, "whole value columns a thread"); + const uint dv0 = part * (uint)DV; + const int R = int(P_shape[0]); + const uint PS = (uint)P_shape[1]; + + threadgroup bfloat wq[RB][D]; + threadgroup bfloat wk[RB][D]; + threadgroup bfloat wv[RB][DV]; + threadgroup float wg[RB][D]; + threadgroup float wbeta[RB], wrq[RB], wrk[RB]; + + device const float* si = ST + (size_t)h * D * D; + float st[NDV][NDK]; + for (int j = 0; j < NDV; ++j) { + const uint dv = dv0 + ty + (uint)TY * (uint)j; + for (int i = 0; i < NDK; ++i) st[j][i] = si[(size_t)dv * D + NDK * lane + i]; + } + constexpr uint CSN = 3u * (uint)D * (uint)(TAPS - 1); // the conv window out (inputs only): a G-th each + for (uint idx = part * CSN / G + tid; idx < (part + 1u) * CSN / G; idx += NT) { + const uint m = idx / (3u * (uint)D); + const uint rem = idx - m * 3u * (uint)D; + const uint pp = rem / (uint)D; + const uint d = rem - pp * (uint)D; + const uint c = pp * W + h * (uint)D + d; + const int e = R + int(m); + CS_OUT[(size_t)m * C3 + c] = e < TAPS - 1 ? CS[(size_t)e * C3 + c] : P[(size_t)(e - (TAPS - 1)) * PS + c]; + } + const float a_h = A[h]; + const float lb = LB[0]; + + for (int r0 = 0; r0 < R; r0 += RB) { + const int n = min(RB, R - r0); + if (r0 > 0) threadgroup_barrier(mem_flags::mem_threadgroup); + { // every row's f_b (all D: the decays) and its columns' g_b, a quad an output (kda_rows' sums) + constexpr int PER = D / 4; + constexpr int KG = D / 64; + constexpr int FKB = D * FB / 8; + constexpr int GKB = D * GB / 8; + constexpr uint PO = (uint)(D + DV); // outputs a row + const uint q_id = tid / 4u, qlid = tid % 4u; + for (uint t = q_id; t < PO * (uint)n; t += (uint)(NT / 4)) { + const uint rl = t / PO; + const uint tt = t - rl * PO; + const uint proj = tt < (uint)D ? 0u : 1u; + const uint d = proj == 0u ? tt : dv0 + tt - (uint)D; + const uint row = h * (uint)D + d; + device const bfloat* prow = P + (size_t)(r0 + (int)rl) * PS; + device const bfloat* x = prow + (proj == 0u ? FA : GA) + qlid * (uint)PER; + const uint gi = row * (uint)KG + qlid / (uint)(64 / PER); + const float s = float(proj == 0u ? FBS[gi] : GBS[gi]); + const float bb = float(proj == 0u ? FBB[gi] : GBB[gi]); + float result; + if (proj == 0u) { + device const uint8_t* wb = (device const uint8_t*)FBW + (size_t)row * FKB + qlid * (PER * FB / 8); + result = quad_dot(x, wb, s, bb); + } else { + device const uint8_t* wb = (device const uint8_t*)GBW + (size_t)row * GKB + qlid * (PER * GB / 8); + result = quad_dot(x, wb, s, bb); + } + const float v = quad_sum(result); + if (qlid == 0u) { + if (proj == 0u) { + const float sa = float(bfloat(v)); + const float av = float(bfloat(sa)) + DTB[h * (uint)D + d]; + wg[rl][d] = metal::precise::exp(lb * mlx_sigmoid_precise(a_h * av)); + } else { + GATE[(size_t)(r0 + (int)rl) * W + h * (uint)D + d] = bfloat(v); + } + } + } + } + constexpr uint CO = 2u * (uint)D + (uint)DV; // q and k whole, this group's v + for (uint idx = tid; idx < CO * (uint)n; idx += NT) { // the short convolutions, SiLU + const uint rl = idx / CO; + const uint rem = idx - rl * CO; + const uint pp = rem < 2u * (uint)D ? rem / (uint)D : 2u; + const uint d = pp < 2u ? rem - pp * (uint)D : dv0 + rem - 2u * (uint)D; + const uint c = pp * W + h * (uint)D + d; + const int r = r0 + (int)rl; + float acc = 0.0f; + for (int j = 0; j < TAPS; ++j) { + const int e = r + j; + const bfloat xv = e < TAPS - 1 ? CS[(size_t)e * C3 + c] : P[(size_t)(e - (TAPS - 1)) * PS + c]; + const float term = float(xv) * CW[(size_t)j * C3 + c]; + acc = j == 0 ? term : acc + term; + } + const bfloat xb = bfloat(acc); + const bfloat sl = xb * mlx_sigmoid_precise(xb); + if (pp == 0u) wq[rl][d] = sl; + else if (pp == 1u) wk[rl][d] = sl; + else wv[rl][d - dv0] = sl; + } + if (tid < (uint)n) wbeta[tid] = float(mlx_sigmoid_precise(P[(size_t)(r0 + (int)tid) * PS + BO + h])); + threadgroup_barrier(mem_flags::mem_threadgroup); + for (uint rl = sgi; rl < (uint)n; rl += (uint)TY) { // row rl's q and k norms, kda_rows' order + float pq = 0.0f, pk = 0.0f; + for (int blk = 0; blk < RBLK; ++blk) { + const uint base = (uint)(blk * 128) + 4u * lane; + for (int i = 0; i < 4; ++i) { pq = sq_acc(pq, float(wq[rl][base + i])); pk = sq_acc(pk, float(wk[rl][base + i])); } + } + for (int i = 0; 4u * lane + (uint)i < (uint)REXTRA && i < 4; ++i) { + const uint at = (uint)(RBLK * 128) + 4u * lane + (uint)i; + pq = sq_acc(pq, float(wq[rl][at])); pk = sq_acc(pk, float(wk[rl][at])); + } + pq = simd_sum(pq); + pk = simd_sum(pk); + if (lane == 0u) { + wrq[rl] = metal::precise::rsqrt(pq + 1.0e-6f); + wrk[rl] = metal::precise::rsqrt(pk + 1.0e-6f); + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + { + const float qscale = metal::precise::rsqrt(float(D)); + for (uint idx = tid; idx < (uint)D * (uint)n; idx += NT) { + const uint rl = idx / (uint)D, d = idx - rl * (uint)D; + wq[rl][d] = bfloat((float(wq[rl][d]) * wrq[rl]) * qscale); + wk[rl][d] = bfloat(float(wk[rl][d]) * wrk[rl]); + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + for (int rl = 0; rl < n; ++rl) { // the recurrence on this group's columns; raw outputs straight out + const float beta = wbeta[rl]; + for (int j = 0; j < NDV; ++j) { + const uint dl = ty + (uint)TY * (uint)j; + float kv = 0.0f; + for (int i = 0; i < NDK; ++i) { + const uint s = NDK * lane + i; + st[j][i] = st[j][i] * wg[rl][s]; + kv += st[j][i] * float(wk[rl][s]); + } + kv = simd_sum(kv); + const float delta = (float(wv[rl][dl]) - kv) * beta; + float o = 0.0f; + for (int i = 0; i < NDK; ++i) { + const uint s = NDK * lane + i; + st[j][i] = st[j][i] + float(wk[rl][s]) * delta; + o += st[j][i] * float(wq[rl][s]); + } + o = simd_sum(o); + if (lane == 0u) Y[(size_t)(r0 + rl) * W + h * (uint)D + dv0 + dl] = bfloat(o); + } + } + } + device float* so = ST_OUT + (size_t)h * D * D; + for (int j = 0; j < NDV; ++j) { + const uint dv = dv0 + ty + (uint)TY * (uint)j; + for (int i = 0; i < NDK; ++i) so[(size_t)dv * D + NDK * lane + i] = st[j][i]; + } +} + +// (H / 8, rows) of 256: a simdgroup a row's head, glm_kda_parts' raw outputs normed and gated in place (kda_rows'). +template +[[kernel]] void glm_kda_norm(device bfloat16_t* Y [[buffer(0)]], const device bfloat16_t* GATE [[buffer(1)]], + const device float* ONW [[buffer(2)]], const constant float* EPS [[buffer(3)]], + uint sgi [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint2 tgpos [[threadgroup_position_in_grid]]) { + static_assert(D == 128, "a lane's four outputs are its norm partial's four"); + constexpr uint W = (uint)(H * D); + const uint h = tgpos.x * 8u + sgi; + if (h >= (uint)H) return; + device bfloat* y = Y + (size_t)tgpos.y * W + h * (uint)D; + const device bfloat* g = GATE + (size_t)tgpos.y * W + h * (uint)D; + float sy[4]; + float po = 0.0f; + for (int i = 0; i < 4; ++i) { + sy[i] = float(y[4u * lane + (uint)i]); + po = sq_acc(po, sy[i]); + } + po = simd_sum(po); + const float rn = metal::precise::rsqrt(po / (float)D + EPS[0]); + for (int i = 0; i < 4; ++i) { + const uint d = 4u * lane + (uint)i; + float x = sy[i] * rn; + x = ONW[d] * x; + x = x * mlx_sigmoid_precise(float(bfloat(float(g[d])))); + y[d] = bfloat(x); + } +} + +template [[host_name("glm_kda_parts")]] [[kernel]] decltype(glm_kda_parts<64, 128, 4, 16, 4, 4, 8, 2>) glm_kda_parts<64, 128, 4, 16, 4, 4, 8, 2>; +template [[host_name("glm_kda_norm")]] [[kernel]] decltype(glm_kda_norm<64, 128>) glm_kda_norm<64, 128>; diff --git a/zig/kernels/metal/glm_kda_window.metal b/zig/kernels/metal/glm_kda_window.metal new file mode 100644 index 00000000000..9f84425f26f --- /dev/null +++ b/zig/kernels/metal/glm_kda_window.metal @@ -0,0 +1,200 @@ + +// A window's KDA step in kda_rows' arithmetic: RB rows' gates and norms at once, the recurrence, outputs at once. +template +[[max_total_threads_per_threadgroup(1024)]] +[[kernel]] void glm_kda_window(const device bfloat16_t* P [[buffer(0)]], const constant int* P_shape [[buffer(1)]], + const device bfloat16_t* CS [[buffer(2)]], const device float* CW [[buffer(3)]], + const device uint32_t* FBW [[buffer(4)]], const device bfloat16_t* FBS [[buffer(5)]], + const device bfloat16_t* FBB [[buffer(6)]], const device uint32_t* GBW [[buffer(7)]], + const device bfloat16_t* GBS [[buffer(8)]], const device bfloat16_t* GBB [[buffer(9)]], + const device float* A [[buffer(10)]], const device float* DTB [[buffer(11)]], + const device float* ST [[buffer(12)]], const device float* ONW [[buffer(13)]], + const constant float* LB [[buffer(14)]], const constant float* EPS [[buffer(15)]], + device bfloat16_t* Y [[buffer(16)]], device float* ST_OUT [[buffer(17)]], + device bfloat16_t* CS_OUT [[buffer(18)]], uint sgi [[simdgroup_index_in_threadgroup]], + uint tid [[thread_index_in_threadgroup]], uint3 tpos [[thread_position_in_threadgroup]], + uint3 tgpos [[threadgroup_position_in_grid]]) { + const uint h = tgpos.z; + const uint lane = tpos.x; + const uint ty = tpos.y; + constexpr int NT = 32 * TY; + constexpr int NDK = D / 32; + constexpr int NDV = D / TY; + constexpr int RBLK = D / 128; + constexpr int REXTRA = D - RBLK * 128; + constexpr uint W = (uint)(H * D); + constexpr uint C3 = 3u * W; + constexpr uint FA = C3; + constexpr uint GA = C3 + (uint)D; + constexpr uint BO = C3 + 2u * (uint)D; + const int R = int(P_shape[0]); + const uint PS = (uint)P_shape[1]; + + // kda_rows' sq, sk, sv, sgate and sy are bf16 values held as floats: bf16 here holds them exactly + threadgroup bfloat wq[RB][D]; + threadgroup bfloat wk[RB][D]; + threadgroup bfloat wv[RB][D]; + threadgroup bfloat wgate[RB][D]; + threadgroup bfloat wy[RB][D]; + threadgroup float wg[RB][D]; + threadgroup float wbeta[RB], wrq[RB], wrk[RB], wrn[RB]; + + device const float* si = ST + (size_t)h * D * D; + float st[NDV][NDK]; + for (int j = 0; j < NDV; ++j) { + uint dv = ty + (uint)TY * (uint)j; + for (int i = 0; i < NDK; ++i) st[j][i] = si[(size_t)dv * D + NDK * lane + i]; + } + const float a_h = A[h]; + const float lb = LB[0]; + const float eps = EPS[0]; + + for (int r0 = 0; r0 < R; r0 += RB) { + const int n = min(RB, R - r0); + { // f_b and g_b of every row (a quad an output, kda_rows' sums), each decay computed where its f_b lands + constexpr int PER = D / 4; + constexpr int KG = D / 64; + constexpr int FKB = D * FB / 8; + constexpr int GKB = D * GB / 8; + const uint q_id = tid / 4u, qlid = tid % 4u; + for (uint t = q_id; t < 2u * (uint)D * (uint)n; t += (uint)(NT / 4)) { + const uint rl = t / (2u * (uint)D); + const uint tt = t - rl * 2u * (uint)D; + const uint proj = tt / (uint)D; + const uint d = tt - proj * (uint)D; + const uint row = h * (uint)D + d; + device const bfloat* prow = P + (size_t)(r0 + (int)rl) * PS; + device const bfloat* x = prow + (proj == 0u ? FA : GA) + qlid * (uint)PER; + const uint gi = row * (uint)KG + qlid / (uint)(64 / PER); + const float s = float(proj == 0u ? FBS[gi] : GBS[gi]); + const float bb = float(proj == 0u ? FBB[gi] : GBB[gi]); + float result; + if (proj == 0u) { + device const uint8_t* wb = (device const uint8_t*)FBW + (size_t)row * FKB + qlid * (PER * FB / 8); + result = quad_dot(x, wb, s, bb); + } else { + device const uint8_t* wb = (device const uint8_t*)GBW + (size_t)row * GKB + qlid * (PER * GB / 8); + result = quad_dot(x, wb, s, bb); + } + const float v = quad_sum(result); + if (qlid == 0u) { + if (proj == 0u) { + const float sa = float(bfloat(v)); + const float av = float(bfloat(sa)) + DTB[h * (uint)D + d]; + wg[rl][d] = metal::precise::exp(lb * mlx_sigmoid_precise(a_h * av)); + } else { + wgate[rl][d] = bfloat(v); + } + } + } + } + for (uint idx = tid; idx < 3u * (uint)D * (uint)n; idx += NT) { // the short convolutions, SiLU + const uint rl = idx / (3u * (uint)D); + const uint rem = idx - rl * 3u * (uint)D; + const uint part = rem / (uint)D; + const uint d = rem - part * (uint)D; + const uint c = part * W + h * (uint)D + d; + const int r = r0 + (int)rl; + float acc = 0.0f; + for (int j = 0; j < TAPS; ++j) { + const int e = r + j; + const bfloat xv = e < TAPS - 1 ? CS[(size_t)e * C3 + c] : P[(size_t)(e - (TAPS - 1)) * PS + c]; + const float term = float(xv) * CW[(size_t)j * C3 + c]; + acc = j == 0 ? term : acc + term; + } + const bfloat xb = bfloat(acc); + const bfloat sl = xb * mlx_sigmoid_precise(xb); + if (part == 0u) wq[rl][d] = sl; + else if (part == 1u) wk[rl][d] = sl; + else wv[rl][d] = sl; + } + if (tid < (uint)n) wbeta[tid] = float(mlx_sigmoid_precise(P[(size_t)(r0 + (int)tid) * PS + BO + h])); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sgi < (uint)n) { // row sgi's q and k norms, kda_rows' order + float pq = 0.0f, pk = 0.0f; + for (int blk = 0; blk < RBLK; ++blk) { + const uint base = (uint)(blk * 128) + 4u * lane; + for (int i = 0; i < 4; ++i) { pq = sq_acc(pq, float(wq[sgi][base + i])); pk = sq_acc(pk, float(wk[sgi][base + i])); } + } + for (int i = 0; 4u * lane + (uint)i < (uint)REXTRA && i < 4; ++i) { + const uint at = (uint)(RBLK * 128) + 4u * lane + (uint)i; + pq = sq_acc(pq, float(wq[sgi][at])); pk = sq_acc(pk, float(wk[sgi][at])); + } + pq = simd_sum(pq); + pk = simd_sum(pk); + if (lane == 0u) { + wrq[sgi] = metal::precise::rsqrt(pq + 1.0e-6f); + wrk[sgi] = metal::precise::rsqrt(pk + 1.0e-6f); + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + { + const float qscale = metal::precise::rsqrt(float(D)); + for (uint idx = tid; idx < (uint)D * (uint)n; idx += NT) { + const uint rl = idx / (uint)D, d = idx - rl * (uint)D; + wq[rl][d] = bfloat((float(wq[rl][d]) * wrq[rl]) * qscale); + wk[rl][d] = bfloat(float(wk[rl][d]) * wrk[rl]); + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + for (int rl = 0; rl < n; ++rl) { // the recurrence: each simdgroup its value columns, no other's + const float beta = wbeta[rl]; + for (int j = 0; j < NDV; ++j) { + const uint dv = ty + (uint)TY * (uint)j; + float kv = 0.0f; + for (int i = 0; i < NDK; ++i) { + const uint s = NDK * lane + i; + st[j][i] = st[j][i] * wg[rl][s]; + kv += st[j][i] * float(wk[rl][s]); + } + kv = simd_sum(kv); + const float delta = (float(wv[rl][dv]) - kv) * beta; + float o = 0.0f; + for (int i = 0; i < NDK; ++i) { + const uint s = NDK * lane + i; + st[j][i] = st[j][i] + float(wk[rl][s]) * delta; + o += st[j][i] * float(wq[rl][s]); + } + o = simd_sum(o); + if (lane == 0u) wy[rl][dv] = bfloat(o); + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sgi < (uint)n) { + float po = 0.0f; + for (int blk = 0; blk < RBLK; ++blk) { + const uint base = (uint)(blk * 128) + 4u * lane; + for (int i = 0; i < 4; ++i) po = sq_acc(po, float(wy[sgi][base + i])); + } + for (int i = 0; 4u * lane + (uint)i < (uint)REXTRA && i < 4; ++i) + po = sq_acc(po, float(wy[sgi][(uint)(RBLK * 128) + 4u * lane + (uint)i])); + po = simd_sum(po); + if (lane == 0u) wrn[sgi] = metal::precise::rsqrt(po / (float)D + eps); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + for (uint idx = tid; idx < (uint)D * (uint)n; idx += NT) { + const uint rl = idx / (uint)D, d = idx - rl * (uint)D; + float x = float(wy[rl][d]) * wrn[rl]; + x = ONW[d] * x; + x = x * mlx_sigmoid_precise(float(bfloat(float(wgate[rl][d])))); + Y[(size_t)(r0 + (int)rl) * W + h * (uint)D + d] = bfloat(x); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + } + device float* so = ST_OUT + (size_t)h * D * D; + for (int j = 0; j < NDV; ++j) { + const uint dv = ty + (uint)TY * (uint)j; + for (int i = 0; i < NDK; ++i) so[(size_t)dv * D + NDK * lane + i] = st[j][i]; + } + for (uint idx = tid; idx < 3u * (uint)D * (uint)(TAPS - 1); idx += NT) { + const uint m = idx / (3u * (uint)D); + const uint rem = idx - m * 3u * (uint)D; + const uint part = rem / (uint)D; + const uint d = rem - part * (uint)D; + const uint c = part * W + h * (uint)D + d; + const int e = R + int(m); + CS_OUT[(size_t)m * C3 + c] = e < TAPS - 1 ? CS[(size_t)e * C3 + c] : P[(size_t)(e - (TAPS - 1)) * PS + c]; + } +} +template [[host_name("glm_kda_window")]] [[kernel]] decltype(glm_kda_window<64, 128, 4, 32, 4, 4, 8>) glm_kda_window<64, 128, 4, 32, 4, 4, 8>; +template [[host_name("glm_kda_window_tp")]] [[kernel]] decltype(glm_kda_window<32, 128, 4, 32, 4, 4, 8>) glm_kda_window<32, 128, 4, 32, 4, 4, 8>; diff --git a/zig/kernels/metal/glm_mm_groups.metal b/zig/kernels/metal/glm_mm_groups.metal new file mode 100644 index 00000000000..adb4ff2fa0e --- /dev/null +++ b/zig/kernels/metal/glm_mm_groups.metal @@ -0,0 +1,143 @@ +// Prompt experts and dense products in column groups on the tensor units: 4-bit g64 tiles, 32 columns a group. +#if TF_GROUP != 64 || TF_BITS != 4 +#error "the column-group products read 4-bit codes in groups of 64" +#endif + +constant constexpr int GT_GROUP = 32; // column tiles a group + +// am_k_loop with each step's codes, scale and bias loaded a step ahead: the same tiles, MMAs and sums. +template +inline void gt_k_loop(thread frag (&acc)[TM][2], thread const AmRows& rows, int K, int live, + const device uchar* wq, const device bfloat* scales, const device bfloat* biases, + threadgroup bfloat* tile, threadgroup float* sb, int tn, uint t, short2 home) { + threadgroup bfloat* mine = tile + (t / 2) * PAD + 32 * (t % 2); + TF_UNROLL + for (short i = 0; i < TM; i++) { + acc[i][0] = frag(0); + acc[i][1] = frag(0); + } + Codes next = am_load(wq); + bfloat ns = scales[0], nb = biases[0]; + for (int k = 0; k < K; k += 64) { + const Codes cur = next; + const bfloat cs = ns, cb = nb; + if (k + 64 < K) { + next = am_load(wq + STEP_BYTES); + ns = scales[1]; + nb = biases[1]; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + am_codes(cur, mine); + if (t % 2 == 0) { + const float s = float(cs); + sb[t / 2] = s; + sb[64 + t / 2] = float(cb) - OFF * s; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (live > 16 * (TM - 1)) { + am_step(acc, rows, k, tile, sb, tn, home); + } else if (TM > 1 && live > 0) { + am_step(acc, rows, k, tile, sb, tn, home); + } + wq += STEP_BYTES; + scales += 1; + biases += 1; + } + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +// am_block on gt_k_loop, outputs scattered to rows dst[i]. +template +inline void gt_block(const device bfloat* x, int ldx, const device float* xs, int ldxs, int row, int rows, int K, + int ldy, int col, long wrow0, const device uint32_t* w, const device bfloat* scales, + const device bfloat* biases, device TF_OUT_T* y, threadgroup bfloat* tile, threadgroup float* sb, + uint sg, uint lane, const device int32_t* dst) { + constexpr int SM = BM / 2; + constexpr int TM = SM / 16; + const int t = int(sg) * 32 + int(lane); + const int tm = SM * int(sg / 2), tn = 32 * int(sg % 2), live = clamp(rows - tm, 0, SM); + const long wrow = wrow0 + t / 2; + const short2 home = frag_home(ushort(lane)); + const AmRows starts = am_rows(x, ldx, xs, ldxs, row, rows, tm, home, nullptr, 1); + frag acc[TM][2]; + gt_k_loop(acc, starts, K, live, (const device uchar*)w + wrow * (K * TF_BITS / 8) + HALF_BYTES * (t % 2), + scales + wrow * (K / TF_GROUP), biases + wrow * (K / TF_GROUP), tile, sb, tn, uint(t), home); + if (live > 0) am_scatter(acc, y, dst + row + tm, ldy, col + tn, live, home); +} + +// Launch id's row tile and column tile (`col`): groups of GT_GROUP columns, row tiles in order within a group. +template +inline int gt_order(uint id, constant MmArgs& a, thread int& col) { + const int T = min(a.rows, (a.rows + BM - 1) / BM + a.experts - 1), L = int(id); // the one-launch gathers' tile count + const int g = L / (T * GT_GROUP), rem = L - g * T * GT_GROUP; + col = g * GT_GROUP + rem % GT_GROUP; + return rem / GT_GROUP; +} + +// tf_affine_gather_glu_BM's gate, up and SwiGLU at the launch's row and column tiles. +template +[[kernel]] void glm_gather_glu(const device bfloat* X [[buffer(0)]], const device uint32_t* WG [[buffer(1)]], + const device bfloat* SG [[buffer(2)]], const device bfloat* BG [[buffer(3)]], + const device float* XS [[buffer(4)]], constant MmArgs& a [[buffer(5)]], + device bfloat* Y [[buffer(6)]], const device int32_t* OFFS [[buffer(7)]], + const device int32_t* ORDER [[buffer(8)]], const device uint32_t* WU [[buffer(9)]], + const device bfloat* SU [[buffer(10)]], const device bfloat* BU [[buffer(11)]], + constant float2& glu [[buffer(12)]], uint sg [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { + constexpr int SM = BM / 2, TM = SM / 16; + threadgroup bfloat tile[64 * PAD]; + threadgroup float sb[NG * 128]; + int expert, row, rows, ct; + const int rt = gt_order(tg.x, a, ct); + if (!am_tile(OFFS, a.experts, a.rows, rt, lane, expert, row, rows)) return; + const int c0 = ct * 32, t = int(sg) * 32 + int(lane), tr = t / 2; + const bool up = ((tr >> 4) & 1) != 0; + const long wrow = long(expert) * a.n + c0 + (tr >> 5) * 16 + (tr & 15); + const int tm = SM * int(sg / 2), tn = 32 * int(sg % 2), live = clamp(rows - tm, 0, SM); + const short2 home = frag_home(ushort(lane)); + const AmRows starts = am_rows(X, a.k, XS, a.k / TF_GROUP, row, rows, tm, home, ORDER, int(glu.x)); + frag acc[TM][2]; + gt_k_loop(acc, starts, a.k, live, (const device uchar*)(up ? WU : WG) + wrow * (a.k * TF_BITS / 8) + HALF_BYTES * (t % 2), + (up ? SU : SG) + wrow * (a.k / TF_GROUP), (up ? BU : BG) + wrow * (a.k / TF_GROUP), tile, sb, tn, uint(t), home); + am_store_glu(acc, Y + long(row + tm) * a.n + c0 + tn / 2, a.n, live, home, glu.y); +} + +// tf_affine_gather_scatter_BM at the launch's row and column tiles: sorted row i's outputs to row DST[i] of Y. +template +[[kernel]] void glm_gather_scatter(const device bfloat* X [[buffer(0)]], const device uint32_t* W [[buffer(1)]], + const device bfloat* S [[buffer(2)]], const device bfloat* B [[buffer(3)]], + const device float* XS [[buffer(4)]], constant MmArgs& a [[buffer(5)]], + device TF_OUT_T* Y [[buffer(6)]], const device int32_t* OFFS [[buffer(7)]], + const device int32_t* DST [[buffer(8)]], uint sg [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { + threadgroup bfloat tile[64 * PAD]; + threadgroup float sb[NG * 128]; + int expert, row, rows, ct; + const int rt = gt_order(tg.x, a, ct); + if (!am_tile(OFFS, a.experts, a.rows, rt, lane, expert, row, rows)) return; + const int col = ct * 64; + gt_block(X, a.k, XS, a.k / TF_GROUP, row, rows, a.k, a.n, col, long(expert) * a.n + col, W, S, B, Y, tile, sb, sg, + lane, DST); +} + +template [[host_name("glm_gather_glu_32")]] [[kernel]] decltype(glm_gather_glu<32>) glm_gather_glu<32>; +template [[host_name("glm_gather_glu_64")]] [[kernel]] decltype(glm_gather_glu<64>) glm_gather_glu<64>; +template [[host_name("glm_gather_scatter_32")]] [[kernel]] decltype(glm_gather_scatter<32>) glm_gather_scatter<32>; +template [[host_name("glm_gather_scatter_64")]] [[kernel]] decltype(glm_gather_scatter<64>) glm_gather_scatter<64>; + +// tf_affine_mm (64 x 64 tiles, a batch along z) in groups of GT_GROUP column tiles, the last group the rest. +[[kernel]] void glm_mm_grouped(const device bfloat* X [[buffer(0)]], const device uint32_t* W [[buffer(1)]], + const device bfloat* S [[buffer(2)]], const device bfloat* B [[buffer(3)]], + const device float* XS [[buffer(4)]], constant MmArgs& a [[buffer(5)]], + device TF_OUT_T* Y [[buffer(6)]], constant MmStrides& st [[buffer(7)]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint3 tg [[threadgroup_position_in_grid]]) { + threadgroup bfloat tile[64 * PAD]; + threadgroup float sb[NG * 128]; + const int T = (a.rows + 63) / 64, NC = a.n / 64, L = int(tg.x); + const int g = L / (T * GT_GROUP), gl = min(GT_GROUP, NC - g * GT_GROUP), rem = L - g * T * GT_GROUP; + const int row = (rem / gl) * 64, col = (g * GT_GROUP + rem % gl) * 64, b = int(tg.z); + am_block<64>(X + long(b) * st.x_batch, st.x_row, XS + long(b) * st.sums_batch * (a.k / TF_GROUP), + st.sums_row * (a.k / TF_GROUP), row, min(64, a.rows - row), a.k, st.y_row, col, + long(b) * st.w_batch + col, W, S, B, Y + long(b) * st.y_batch, tile, sb, sg, lane); +} diff --git a/zig/kernels/metal/glm_route_one.metal b/zig/kernels/metal/glm_route_one.metal new file mode 100644 index 00000000000..95ee154d194 --- /dev/null +++ b/zig/kernels/metal/glm_route_one.metal @@ -0,0 +1,43 @@ +// tf_route_logits for a one-row window (appended to core/moe_route.metal): row 0's sums alone, in the same order. +[[kernel]] void glm_route_logits_one(const device bfloat* X [[buffer(0)]], const device uint4* RP [[buffer(1)]], + constant int& rows [[buffer(2)]], device TF_OUT_T* OUT [[buffer(3)]], + uint2 tg [[threadgroup_position_in_grid]], + uint2 tpos [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint s [[simdgroup_index_in_threadgroup]]) { + threadgroup float part[8][4]; + const int q = int(tg.x); + const device uint4* w = RP + ((size_t(q) * 8 + s) * ITERS + PERL * lane) * 2; + float acc[4]; // [expert] + for (int tn = 0; tn < 4; tn++) acc[tn] = 0.0f; + for (int ii = 0; ii < PERL; ii++) { + float inter[4][4]; + for (int h = 0; h < 2; h++) { + const uint4 v = w[ii * 2 + h]; + const uint words[4] = {v.x, v.y, v.z, v.w}; + for (int j = 0; j < 4; j++) { + const int e = h * 8 + j * 2; + inter[e / 4][e % 4] = as_type(words[j] << 16); + inter[(e + 1) / 4][(e + 1) % 4] = as_type(words[j] & 0xffff0000u); + } + } + const device bfloat* x = X + 32 * (PERL * int(lane) + ii) + 4 * int(s); + for (int tm = 0; tm < 4; tm++) { + const float xv = float(x[tm]); + for (int tn = 0; tn < 4; tn++) acc[tn] += xv * inter[tm][tn]; + } + } + for (int tn = 0; tn < 4; tn++) { + const float v = simd_sum(acc[tn]); + if (lane == 0) part[s][tn] = v; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + const int o = int(tpos.x); + if (o < 4) { + float v = part[0][o]; + for (int k = 1; k < 8; k++) v += part[k][o]; +#ifdef TF_ROUND_LOGITS + v = float(bfloat(v)); +#endif + OUT[4 * q + o] = static_cast(v); + } +} diff --git a/zig/kernels/metal/glm_select.metal b/zig/kernels/metal/glm_select.metal new file mode 100644 index 00000000000..a635f2d3496 --- /dev/null +++ b/zig/kernels/metal/glm_select.metal @@ -0,0 +1,235 @@ +// GLM decode key lists on many threadgroups, glm_index_select's bytes (glm_glue.metal); a sampled floor is speed only. +#include +using namespace metal; + +struct GlmSelectArgs { + uint p0, top, width, s_stride, i_stride; +}; + +constant constexpr uint SPAN = 4096; // blocks a mark threadgroup covers: 128 words, 16 a simdgroup +constant constexpr uint MT = 256; // mark threads +constant constexpr uint NS = 2048; // sampled blocks: 256 runs of 8 at even spacing +constant constexpr uint AIM = 2048; // the marked blocks the floor aims at +constant constexpr uint T2 = 512; // merge threads +constant constexpr uint CAP = 3072; // candidates the merge holds + +// glm_order_key: a score's bits as a uint in the scores' order (-0 below +0, as glm_index_select ranks them). +inline uint sel_key(float v) { + const uint u = as_type(v); + return (u & 0x80000000u) ? ~u : (u | 0x80000000u); +} + +// Exclusive prefix sums of two counts over T2 threads (`part`: 2 T2 / 32 slots), and their totals. +inline uint2 sel_scan2(uint2 v, threadgroup uint* part, uint t, thread uint2& total) { + constexpr uint SG = T2 / 32; + const uint lane = t % 32, sg = t / 32; + const uint2 inside = uint2(simd_prefix_exclusive_sum(v.x), simd_prefix_exclusive_sum(v.y)); + if (lane == 31) { + part[sg] = inside.x + v.x; + part[SG + sg] = inside.y + v.y; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + uint2 base = 0, all = 0; + for (uint i = 0; i < SG; i++) { + const uint2 p = uint2(part[i], part[SG + i]); + base += i < sg ? p : uint2(0); + all += p; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + total = all; + return base + inside; +} + +// The keys a select reads: a row's scores in device memory, or candidates in threadgroup memory (in block order). +struct RowKeys { + const device float* s; + uint key(uint i) const { return sel_key(s[i]); } + uint block(uint i) const { return i; } +}; +struct CandKeys { + const threadgroup uint* k; + const threadgroup ushort* b; + uint key(uint i) const { return k[i]; } + uint block(uint i) const { return b[i]; } +}; + +struct SelShared { + atomic_uint hist[2048]; + uint prefix, need; + uint part[2 * T2 / 32]; +}; + +// The digit of `hist`'s 2048 bins holding the need-th largest: out[0] = prefix with it at `shift`, out[1] = need left. +template +inline void sel_digit(threadgroup atomic_uint* hist, uint need, uint prefix, uint shift, threadgroup uint* out, threadgroup uint* part, uint t) { + constexpr uint B = 2048 / T; + uint h[B], own = 0; + for (uint j = 0; j < B; j++) own += h[j] = atomic_load_explicit(&hist[2047 - B * t - j], memory_order_relaxed); + const uint incl = simd_prefix_inclusive_sum(own); + if (t % 32 == 31) part[t / 32] = incl; + threadgroup_barrier(mem_flags::mem_threadgroup); + uint above = incl - own; + for (uint i = 0; i < t / 32; i++) above += part[i]; + if (above < need && above + own >= need) { + uint d = 0; + for (uint j = 0; j < B; j++) { + if (above + h[j] >= need) { + d = 2047 - B * t - j; + break; + } + above += h[j]; + } + out[0] = prefix | (d << shift); + out[1] = need - above; + } + threadgroup_barrier(mem_flags::mem_threadgroup); +} + +// glm_index_select's choice of n keys (top <= n) as 4-entry runs in order; radix passes of 11, 11 and 10 bits. +template +inline void sel_core(threadgroup SelShared& sh, Src src, uint n, uint top, device int* out, uint t) { + uint prefix = 0, need = top; + threadgroup uint* res = &sh.prefix; + for (int pass = 0; pass < 3; pass++) { + const uint shift = pass == 0 ? 21u : (pass == 1 ? 10u : 0u); + const uint mask = pass == 2 ? 1023u : 2047u; + const uint hi_mask = pass == 0 ? 0u : (0xffffffffu << (shift + (pass == 2 ? 10u : 11u))); + for (uint i = t; i < 2048; i += T2) atomic_store_explicit(&sh.hist[i], 0u, memory_order_relaxed); + threadgroup_barrier(mem_flags::mem_threadgroup); + for (uint b = t; b < n; b += T2) { + const uint key = src.key(b); + if ((key & hi_mask) == (prefix & hi_mask)) atomic_fetch_add_explicit(&sh.hist[(key >> shift) & mask], 1u, memory_order_relaxed); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + sel_digit(sh.hist, need, prefix, shift, res, sh.part, t); + prefix = sh.prefix; + need = sh.need; + } + // in order: every key above the threshold, then the first `need` equal to it; each thread a run + const uint per = (n + T2 - 1) / T2; + const uint lo = min(t * per, n), hi = min(lo + per, n); + uint2 c = 0; + for (uint i = lo; i < hi; i++) { + const uint key = src.key(i); + c += uint2(key > prefix ? 1u : 0u, key == prefix ? 1u : 0u); + } + uint2 total; + uint2 before = sel_scan2(c, sh.part, t, total); + for (uint i = lo; i < hi; i++) { + const uint key = src.key(i); + if (key < prefix) continue; + const bool above = key > prefix; + if (above || before.y < need) { + const uint at = before.x + min(before.y, need); + const int b = int(src.block(i)); + for (uint j = 0; j < 4; j++) out[4 * at + j] = 4 * b + int(j); + } + before += uint2(above ? 1u : 0u, above ? 0u : 1u); + } +} + +// The floor of row r's scores [0, np): the lowest key of the 22-bit bin holding the need-th best of NS sampled blocks. +inline uint sel_floor(const device float* s, uint np, uint t, threadgroup atomic_uint* hist, threadgroup uint* sh) { + constexpr uint PT = NS / MT; + uint u[PT]; + for (uint j = 0; j < PT; j++) { + const uint q = t + j * MT; + u[j] = sel_key(s[uint(ulong(q / 8) * np / (NS / 8)) / 8 * 8 + q % 8]); + } + uint prefix = 0, need = max(uint(ulong(AIM) * NS / np), 1u); + for (int pass = 0; pass < 2; pass++) { + const uint shift = pass == 0 ? 21u : 10u; + for (uint i = t; i < 2048; i += MT) atomic_store_explicit(&hist[i], 0u, memory_order_relaxed); + threadgroup_barrier(mem_flags::mem_threadgroup); + for (uint j = 0; j < PT; j++) + if (pass == 0 || (u[j] >> 21) == (prefix >> 21)) atomic_fetch_add_explicit(&hist[(u[j] >> shift) & 2047u], 1u, memory_order_relaxed); + threadgroup_barrier(mem_flags::mem_threadgroup); + sel_digit(hist, need, prefix, shift, sh, sh + 2, t); + prefix = sh[0]; + need = sh[1]; + } + return prefix; +} + +// Grid (cdiv(blocks, SPAN), rows) of 256: span tg.x's blocks at or above row tg.y's floor (bit b of word w: 32 w + b). +[[kernel]] void glm_select_mark(const device float* scores [[buffer(0)]], device uint* bits [[buffer(1)]], + constant GlmSelectArgs& g [[buffer(2)]], constant uint& words [[buffer(3)]], + uint2 tg [[threadgroup_position_in_grid]], uint t [[thread_index_in_threadgroup]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + threadgroup atomic_uint hist[2048]; + threadgroup uint sh[2 + MT / 32]; + const uint row = tg.y, np = (g.p0 + row + 1) / 4; + const uint w0 = tg.x * (SPAN / 32); + if (np <= CAP || w0 * 32 >= np) return; + const device float* s = scores + size_t(row) * g.s_stride; + const uint floor_key = sel_floor(s, np, t, hist, sh); + const uint nw = min(SPAN / 32, (np + 31) / 32 - w0); + device uint* out = bits + size_t(row) * words; + constexpr uint WPS = SPAN / 32 / (MT / 32); // words a simdgroup marks, every load issued before the first compare + float v[WPS]; + for (uint m = 0; m < WPS; m++) { + const uint wi = sg + m * (MT / 32), i = (w0 + wi) * 32 + lane; + v[m] = wi < nw && i < np ? s[i] : 0.0f; + } + for (uint m = 0; m < WPS; m++) { + const uint wi = sg + m * (MT / 32), i = (w0 + wi) * 32 + lane; + const bool ge = wi < nw && i < np && sel_key(v[m]) >= floor_key; + const uint word = uint(ulong(simd_vote::vote_t(simd_ballot(ge)))); + if (lane == 0 && wi < nw) out[w0 + wi] = word; + } +} + +// A threadgroup a row: glm_index_select's key list, from the marked blocks when they hold TOP to CAP of them. +[[kernel]] void glm_select_merge(const device float* scores [[buffer(0)]], device int* indices [[buffer(1)]], + constant GlmSelectArgs& g [[buffer(2)]], constant uint& words [[buffer(3)]], + const device uint* bits [[buffer(4)]], uint row [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]]) { + threadgroup SelShared sh; + threadgroup uint ckey[CAP]; + threadgroup ushort cblock[CAP]; + const uint np = (g.p0 + row + 1) / 4, position = g.p0 + row; + const device float* s = scores + size_t(row) * g.s_stride; + device int* out = indices + size_t(row) * g.i_stride; + uint chosen = min(g.top, np); + if (g.top >= np) { // every block, in order + for (uint i = t; i < 4 * np; i += T2) out[i] = int(i); + } else if (np <= CAP) { // the whole row as candidates + float v[CAP / T2]; + for (uint m = 0; m < CAP / T2; m++) v[m] = t + m * T2 < np ? s[t + m * T2] : 0.0f; + for (uint m = 0; m < CAP / T2; m++) + if (t + m * T2 < np) { + ckey[t + m * T2] = sel_key(v[m]); + cblock[t + m * T2] = ushort(t + m * T2); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + sel_core(sh, CandKeys{ckey, cblock}, np, g.top, out, t); + } else { + const device uint* ge = bits + size_t(row) * words; + const uint nw = (np + 31) / 32, per = (nw + T2 - 1) / T2; + const uint wa = min(nw, t * per), wb = min(nw, wa + per); + uint count = 0; + for (uint w = wa; w < wb; w++) count += popcount(ge[w]); + uint2 all; + uint at = sel_scan2(uint2(count, 0), sh.part, t, all).x; + const uint n = all.x; + if (n >= g.top && n <= CAP && np <= 65536) { // the marked blocks in order, then their keys + for (uint w = wa; w < wb; w++) + for (uint m = ge[w]; m != 0; m &= m - 1) cblock[at++] = ushort(32 * w + ctz(m)); + threadgroup_barrier(mem_flags::mem_threadgroup); + float v[CAP / T2]; + for (uint m = 0; m < CAP / T2; m++) v[m] = t + m * T2 < n ? s[cblock[t + m * T2]] : 0.0f; + for (uint m = 0; m < CAP / T2; m++) + if (t + m * T2 < n) ckey[t + m * T2] = sel_key(v[m]); + threadgroup_barrier(mem_flags::mem_threadgroup); + sel_core(sh, CandKeys{ckey, cblock}, n, g.top, out, t); + } else { + sel_core(sh, RowKeys{s}, np, g.top, out, t); + } + } + threadgroup_barrier(mem_flags::mem_device); + const uint tail = (position + 1) % 4; + for (uint i = 4 * chosen + t; i < g.width; i += T2) { + const uint j = i - 4 * chosen; + out[i] = j < tail ? int(position + 1 - tail + j) : -1; + } +} diff --git a/zig/kernels/metal/glm_softmax_rows.metal b/zig/kernels/metal/glm_softmax_rows.metal new file mode 100644 index 00000000000..6d8f3ccecef --- /dev/null +++ b/zig/kernels/metal/glm_softmax_rows.metal @@ -0,0 +1,16 @@ +// A window's dense-attention softmaxes in one launch (appended to ops/softmax.metal): row z (grid y) n0 + z keys. + +// Each row tf_softmax_bf16's bits: threads past its keys hold -inf, adding zero as a smaller group's empty slots do. +struct GlmSoftmaxRows { + int n0, stride; +}; + +[[kernel]] void glm_softmax_rows(const device bfloat* X [[buffer(0)]], constant GlmSoftmaxRows& a [[buffer(1)]], + device bfloat* OUT [[buffer(2)]], uint sg [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint3 t [[thread_position_in_threadgroup]], + uint3 tg [[threadgroup_position_in_grid]]) { + threadgroup float tops[32]; + threadgroup float sums[32]; + const size_t at = size_t(tg.y) * a.stride; + tf_softmax_row(X + at, OUT + at, a.n0 + int(tg.y), tg.x, t.x, sg, lane, tops, sums); +} diff --git a/zig/kernels/metal/idol.metal b/zig/kernels/metal/idol.metal new file mode 100644 index 00000000000..f687b50e5a7 --- /dev/null +++ b/zig/kernels/metal/idol.metal @@ -0,0 +1,331 @@ +// Idol's denoiser steps after gemm_nax.metal: fp16 rows rounded where idol-sdk's torch code rounds them. + +inline float id_h(float x) { return float(half(x)); } + +// One threadgroup's sum of every thread's `v` (at most 1,024 threads), returned to all of them. +inline float id_sum(float v, threadgroup float* part, uint n, uint lane, uint sg) { + v = simd_sum(v); + if (lane == 0) part[sg] = v; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + float s = lane < (n + 31) / 32 ? part[lane] : 0.0f; + s = simd_sum(s); + if (lane == 0) part[32] = s; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + const float out = part[32]; + threadgroup_barrier(mem_flags::mem_threadgroup); + return out; +} + +// torch's tanh GELU of an fp16 value, computed in fp32. +inline float id_gelu(float x) { + const float inner = 0.7978845608028654f * (x + 0.044715f * x * x * x); + return 0.5f * x * (1.0f + metal::precise::tanh(inner)); +} + +// ---- y [M, N] = fp16(x w^T + b) (EPI 1: then GELU, rounded again): tfp::gemm_nax's block, fp32 sums ---- +template +inline void id_linear(const device half* A, const device half* B, const device half* bias, device half* D, + const device int* P, uint3 tg, uint sg, uint lane) { + constexpr int BM = 64, BN = 128, BK = 256, WN = 4; + const int tx = int(tg.x), ty = int(tg.y); + if (tx >= P[6] || ty >= P[7]) return; + const int lda = P[3], ldb = P[4], ldd = P[5]; + const int row = ty * BM + 32 * int(sg / WN), col = tx * BN + 32 * int(sg % WN); + A += long(row) * lda; + B += long(col) * ldb; + D += long(row) * ldd + col; + const int rows = AM ? 32 : min(32, P[0] - row), cols = AN ? 32 : min(32, P[1] - col); + const bool full = (AM || rows == 32) && (AN || cols == 32); + const short2 home = tfp::frag_home(ushort(lane)); + tfp::frag acc[2][2]; + if (full) { + tfp::gemm_block(acc, A, B, lda, ldb, P[2], P[9], rows, cols, home); + } else { + tfp::gemm_block(acc, A, B, lda, ldb, P[2], P[9], rows, cols, home); + } + TF_UNROLL + for (short j = 0; j < 2; j++) { + TF_UNROLL + for (short e = 0; e < 8; e++) { + const int c = col + 16 * j + home.x + TF_COL(e); + const float b = c < P[1] ? float(bias[c]) : 0.0f; + TF_UNROLL + for (short i = 0; i < 2; i++) { + const float v = id_h(acc[i][j][e] + b); + acc[i][j][e] = EPI == 1 ? id_gelu(v) : v; + } + } + } + if (full) { + tfp::gemm_store(acc, D, ldd, rows, cols, home); + } else if (rows > 0 && cols > 0) { + tfp::gemm_store(acc, D, ldd, rows, cols, home); + } +} + +#define ID_LINEAR(NAME, EPI, AM, AN) \ + [[max_total_threads_per_threadgroup(256)]] [[kernel]] void NAME( \ + const device half* A [[buffer(0)]], const device half* B [[buffer(1)]], const device int32_t* P [[buffer(2)]], \ + device half* D [[buffer(3)]], const device half* bias [[buffer(4)]], uint sg [[simdgroup_index_in_threadgroup]], \ + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { \ + id_linear(A, B, bias, D, P, tg, sg, lane); \ + } +ID_LINEAR(id_linear_00, 0, false, false) +ID_LINEAR(id_linear_01, 0, false, true) +ID_LINEAR(id_linear_10, 0, true, false) +ID_LINEAR(id_linear_11, 0, true, true) +ID_LINEAR(id_linear_gelu_00, 1, false, false) +ID_LINEAR(id_linear_gelu_01, 1, false, true) +ID_LINEAR(id_linear_gelu_10, 1, true, false) +ID_LINEAR(id_linear_gelu_11, 1, true, true) + +struct IdGemm32 { + uint M, N, K, ldy; +}; + +// y [M, N] (rows ldy apart) = x [M, K] w^T, fp32 FMA on 8x8 simdgroup matrices; K % 32, N % 64 (or N < 64, % 8) = 0. +[[max_total_threads_per_threadgroup(128)]] [[kernel]] void id_gemm32( + const device float* x [[buffer(0)]], const device float* w [[buffer(1)]], device float* y [[buffer(2)]], + constant IdGemm32& p [[buffer(3)]], uint2 tg [[threadgroup_position_in_grid]], uint t [[thread_index_in_threadgroup]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + constexpr uint BK = 32, LD = BK + 4; + threadgroup float ta[64 * LD]; + threadgroup float tb[64 * LD]; + threadgroup float stage[4][64]; + const uint row0 = tg.y * 64, col0 = tg.x * 64; + const uint r0 = (sg / 2) * 32, c0 = (sg % 2) * 32; + const uint cols = min(64u, p.N - col0); + simdgroup_float8x8 acc[4][4]; + for (uint i = 0; i < 4; i++) + for (uint j = 0; j < 4; j++) acc[i][j] = make_filled_simdgroup_matrix(0.0f); + for (uint k = 0; k < p.K; k += BK) { + // 64 x 32 of x and of w: 2,048 values each, 16 a thread as float4s; rows past M or N read as zeros + for (uint e = t; e < 64 * BK / 4; e += 128) { + const uint r = e / (BK / 4), c = (e % (BK / 4)) * 4; + const float4 va = row0 + r < p.M ? *(const device float4*)(x + ulong(row0 + r) * p.K + k + c) : float4(0.0f); + const float4 vb = r < cols ? *(const device float4*)(w + ulong(col0 + r) * p.K + k + c) : float4(0.0f); + *(threadgroup float4*)(ta + r * LD + c) = va; + *(threadgroup float4*)(tb + r * LD + c) = vb; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + for (uint kk = 0; kk < BK; kk += 8) { + simdgroup_float8x8 a[4], b[4]; + for (uint i = 0; i < 4; i++) simdgroup_load(a[i], ta + (r0 + 8 * i) * LD + kk, LD); + for (uint j = 0; j < 4; j++) simdgroup_load(b[j], tb + (c0 + 8 * j) * LD + kk, LD, ulong2(0, 0), true); + for (uint i = 0; i < 4; i++) + for (uint j = 0; j < 4; j++) simdgroup_multiply_accumulate(acc[i][j], a[i], b[j], acc[i][j]); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + } + for (uint i = 0; i < 4; i++) { + for (uint j = 0; j < 4; j++) { + const uint r = row0 + r0 + 8 * i, c = c0 + 8 * j; + if (r >= p.M || c >= cols) continue; + if (r + 8 <= p.M) { + simdgroup_store(acc[i][j], y + ulong(r) * p.ldy + col0 + c, p.ldy); + } else { + simdgroup_store(acc[i][j], stage[sg], 8); + simdgroup_barrier(mem_flags::mem_threadgroup); + for (uint e = lane; e < 64; e += 32) + if (r + e / 8 < p.M) y[ulong(r + e / 8) * p.ldy + col0 + c + e % 8] = stage[sg][e]; + simdgroup_barrier(mem_flags::mem_threadgroup); + } + } + } +} + +// c [M, N] fp32 = a [M, K] b^T over fp16 operands, tfp::gemm_splitk_nax's one partition (fp32 sums). +#define ID_SPLIT(NAME, AM) \ + [[max_total_threads_per_threadgroup(128)]] [[kernel]] void NAME( \ + const device half* A [[buffer(0)]], const device half* B [[buffer(1)]], const device int32_t* P [[buffer(2)]], \ + device float* C [[buffer(3)]], uint sg [[simdgroup_index_in_threadgroup]], \ + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { \ + tfp::gemm_splitk_nax(A, B, C, P, tg, sg, lane); \ + } +ID_SPLIT(id_split_0, false) +ID_SPLIT(id_split_1, true) + +struct IdNorm { + uint width; + float eps; + uint mode; // 0 plain, 1 affine (fp32 w, b), 2 modulated (fp16 1 + scale, shift) +}; + +// LayerNorm32 of an fp16 row in fp32, rounded to fp16; then affine in fp32, or modulated in fp16. A threadgroup a row. +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_norm( + const device half* x [[buffer(0)]], const device float* w [[buffer(1)]], const device float* b [[buffer(2)]], + const device half* s1 [[buffer(3)]], const device half* sh [[buffer(4)]], device half* y [[buffer(5)]], + constant IdNorm& p [[buffer(6)]], uint row [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]], + uint n [[threads_per_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + threadgroup float part[33]; + const device half* xr = x + ulong(row) * p.width; + device half* yr = y + ulong(row) * p.width; + float a = 0.0f; + for (uint i = t; i < p.width; i += n) a += float(xr[i]); + const float mean = id_sum(a, part, n, lane, sg) / float(p.width); + float q = 0.0f; + for (uint i = t; i < p.width; i += n) q += (float(xr[i]) - mean) * (float(xr[i]) - mean); + const float inv = metal::precise::rsqrt(id_sum(q, part, n, lane, sg) / float(p.width) + p.eps); + for (uint i = t; i < p.width; i += n) { + float v = (float(xr[i]) - mean) * inv; + if (p.mode == 1) v = v * w[i] + b[i]; + v = id_h(v); + if (p.mode == 2) v = id_h(id_h(v * float(s1[i])) + float(sh[i])); + yr[i] = half(v); + } +} + +// Affine LayerNorm32 of an fp16 row as fp16 [hi | hi | lo] of 3 * width: times [w_hi | w_lo | w_hi], near-fp32 sums. +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_norm_split( + const device half* x [[buffer(0)]], const device float* w [[buffer(1)]], const device float* b [[buffer(2)]], + device half* y [[buffer(3)]], constant IdNorm& p [[buffer(4)]], uint row [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]], uint n [[threads_per_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint sg [[simdgroup_index_in_threadgroup]]) { + threadgroup float part[33]; + const device half* xr = x + ulong(row) * p.width; + device half* yr = y + ulong(row) * 3 * p.width; + float a = 0.0f; + for (uint i = t; i < p.width; i += n) a += float(xr[i]); + const float mean = id_sum(a, part, n, lane, sg) / float(p.width); + float q = 0.0f; + for (uint i = t; i < p.width; i += n) q += (float(xr[i]) - mean) * (float(xr[i]) - mean); + const float inv = metal::precise::rsqrt(id_sum(q, part, n, lane, sg) / float(p.width) + p.eps); + for (uint i = t; i < p.width; i += n) { + const float v = (float(xr[i]) - mean) * inv * w[i] + b[i]; + const half hi = half(v); + yr[i] = hi; + yr[p.width + i] = hi; + yr[2 * p.width + i] = half(v - float(hi)); + } +} + +// LayerNorm of an fp16 row in fp32 kept in fp32: affine (w, b) when given, else times (1 + scale) plus shift (mode 2). +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_norm32( + const device half* x [[buffer(0)]], const device float* w [[buffer(1)]], const device float* b [[buffer(2)]], + device float* y [[buffer(3)]], constant IdNorm& p [[buffer(4)]], uint row [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]], uint n [[threads_per_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint sg [[simdgroup_index_in_threadgroup]]) { + threadgroup float part[33]; + const device half* xr = x + ulong(row) * p.width; + device float* yr = y + ulong(row) * p.width; + float a = 0.0f; + for (uint i = t; i < p.width; i += n) a += float(xr[i]); + const float mean = id_sum(a, part, n, lane, sg) / float(p.width); + float q = 0.0f; + for (uint i = t; i < p.width; i += n) q += (float(xr[i]) - mean) * (float(xr[i]) - mean); + const float inv = metal::precise::rsqrt(id_sum(q, part, n, lane, sg) / float(p.width) + p.eps); + for (uint i = t; i < p.width; i += n) { + const float v = (float(xr[i]) - mean) * inv; + yr[i] = p.mode == 2 ? v * (1.0f + w[i]) + b[i] : v * w[i] + b[i]; + } +} + +struct IdRepo { + uint rows; + uint stride; // fp32 values from one row's gate sums to the next; content sums follow gate's 128 + float inv; // the maps' power-of-two scale undone, exactly +}; + +// RePo: d = final_map(silu(gate) * content), 3 per head; angles clamp_mul(d, freqs) * pi as cos, sin [rows, 16, 32]. +[[max_total_threads_per_threadgroup(64)]] [[kernel]] void id_repo( + const device float* gc [[buffer(0)]], const device float* wf [[buffer(1)]], const device float* f [[buffer(2)]], + device float* cs [[buffer(3)]], device float* sn [[buffer(4)]], constant IdRepo& p [[buffer(5)]], + uint row [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]]) { + threadgroup float u[128]; + threadgroup float d[48]; + const device float* g = gc + ulong(row) * p.stride; + for (uint i = t; i < 128; i += 64) { + const float a = g[i] * p.inv; + u[i] = (a / (1.0f + metal::precise::exp(-a))) * (g[128 + i] * p.inv); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (t < 48) { + float s = 0.0f; + for (uint k = 0; k < 128; k++) s = fma(u[k], wf[t * 128 + k], s); + d[t] = s; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + // freqs: 10 x, 10 y, 12 z; each pair of the 32 takes its axis's offset + for (uint i = t; i < 512; i += 64) { + const uint h = i / 32, j = i % 32; + const uint axis = j < 10 ? 0 : (j < 20 ? 1 : 2); + const float x = d[h * 3 + axis], fr = f[j]; + const float ft = metal::precise::tanh(fr); + const float ang = (x * ft + x * (fr - ft)) * 3.14159265358979323846f; + cs[ulong(row) * 512 + i] = metal::precise::cos(ang); + sn[ulong(row) * 512 + i] = metal::precise::sin(ang); + } +} + +struct IdHeads { + uint rows; + float scale; // sqrt(head width): MultiHeadRMSNorm's +}; + +// q, k of qkv rows: pairs turned by the row and head's cos, sin; F.normalize * gamma * scale; out [16, rows, 64]. +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_qk( + const device half* qkv [[buffer(0)]], const device float* gq [[buffer(1)]], const device float* gk [[buffer(2)]], + const device float* cs [[buffer(3)]], const device float* sn [[buffer(4)]], device half* Q [[buffer(5)]], + device half* K [[buffer(6)]], device half* V [[buffer(7)]], constant IdHeads& p [[buffer(8)]], + uint2 tg [[threadgroup_position_in_grid]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + const uint r = tg.x, h = tg.y * 8 + sg; + if (h >= 16) return; + const ulong from = ulong(r) * 3072 + h * 64 + lane * 2; + const ulong at = ulong(r) * 512 + h * 32 + lane; + const float c = cs[at], s = sn[at]; + const float q0 = float(qkv[from]), q1 = float(qkv[from + 1]); + const float k0 = float(qkv[from + 1024]), k1 = float(qkv[from + 1025]); + const float rq0 = id_h(q0 * c - q1 * s), rq1 = id_h(q0 * s + q1 * c); + const float rk0 = id_h(k0 * c - k1 * s), rk1 = id_h(k0 * s + k1 * c); + // F.normalize's clamp_min keeps a NaN norm, where Metal's max would drop it + const float sq = metal::precise::sqrt(simd_sum(rq0 * rq0 + rq1 * rq1)); + const float sk = metal::precise::sqrt(simd_sum(rk0 * rk0 + rk1 * rk1)); + const float qn = isnan(sq) ? sq : max(sq, 1e-12f), kn = isnan(sk) ? sk : max(sk, 1e-12f); + const uint g = h * 64 + lane * 2; + const ulong to = (ulong(h) * p.rows + r) * 64 + lane * 2; + Q[to] = half(rq0 / qn * gq[g] * p.scale); + Q[to + 1] = half(rq1 / qn * gq[g + 1] * p.scale); + K[to] = half(rk0 / kn * gk[g] * p.scale); + K[to + 1] = half(rk1 / kn * gk[g + 1] * p.scale); + V[to] = qkv[from + 2048]; + V[to + 1] = qkv[from + 2049]; +} + +// x = fp16(x + fp16(g * y)) by column; g is a modulation gate, or ones for an ungated residual. +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_gate_add( + device half* x [[buffer(0)]], const device half* y [[buffer(1)]], const device half* g [[buffer(2)]], + constant uint& width [[buffer(3)]], uint2 at [[thread_position_in_grid]]) { + const ulong i = ulong(at.y) * width + at.x; + x[i] = half(float(x[i]) + id_h(float(g[at.x]) * float(y[i]))); +} + +// x = fp16(fp16(z w^T + b) + pe): the latent's input projection (16 inputs, fp32) and its fp16 position embedding. +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_embed( + const device float* z [[buffer(0)]], const device float* w [[buffer(1)]], const device float* b [[buffer(2)]], + const device half* pe [[buffer(3)]], device half* x [[buffer(4)]], uint2 at [[thread_position_in_grid]]) { + const uint c = at.x, r = at.y; + float s = 0.0f; + for (uint k = 0; k < 16; k++) s = fma(z[r * 16 + k], w[c * 16 + k], s); + const ulong i = ulong(r) * 1024 + c; + x[i] = half(float(half(s + b[c])) + float(pe[i])); +} + +// y = fp16(a + ba + c + bc) by column: the two condition projections' fp32 sums and biases (each torch Linear). +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_cond( + const device float* a [[buffer(0)]], const device float* ba [[buffer(1)]], const device float* c [[buffer(2)]], + const device float* bc [[buffer(3)]], device half* y [[buffer(4)]], constant uint& width [[buffer(5)]], + uint2 at [[thread_position_in_grid]]) { + const ulong i = ulong(at.y) * width + at.x; + y[i] = half((a[i] + ba[at.x]) + (c[i] + bc[at.x])); +} + +// y = x + b by column in fp32 (an fp32 Linear's bias), in place. +[[max_total_threads_per_threadgroup(256)]] [[kernel]] void id_bias32( + device float* y [[buffer(0)]], const device float* b [[buffer(1)]], constant uint& width [[buffer(2)]], + uint2 at [[thread_position_in_grid]]) { + y[ulong(at.y) * width + at.x] += b[at.x]; +} diff --git a/zig/kernels/metal/idol_attention.metal b/zig/kernels/metal/idol_attention.metal new file mode 100644 index 00000000000..8cc6919b338 --- /dev/null +++ b/zig/kernels/metal/idol_attention.metal @@ -0,0 +1,150 @@ +// Idol's attention: tfp::attention_nax's online softmax at head width 64, every query row to every key row. + +constant constexpr float kIdMasked = -3.402823466e+38f; +constant constexpr int kIdAnyCols = 1 << 30; + +// Fold one fragment's rows into r[2] (rows home.y, home.y + 8): pairs, then lanes 1 and 8 apart, then into r. +template +inline void id_fold(thread const tfp::frag& f, thread float (&r)[2]) { + TF_UNROLL + for (short h = 0; h < 2; h++) { + const short b = 4 * h; + float t = MAX ? max(max(f[b], f[b + 1]), max(f[b + 2], f[b + 3])) : (f[b] + f[b + 1]) + (f[b + 2] + f[b + 3]); + const float u = simd_shuffle_xor(t, ushort(1)); + t = MAX ? max(t, u) : t + u; + const float w = simd_shuffle_xor(t, ushort(8)); + t = MAX ? max(t, w) : t + w; + r[h] = MAX ? max(r[h], t) : r[h] + t; + } +} + +// One 64-query block of one head over 32-key blocks; P and F as Kernels.attention sets them (kernels.zig). +template +inline void id_attention(const device T* Q, const device T* K, const device T* V, device T* O, const device int* P, + const device float* F, uint3 tg, uint sg, uint lane) { + constexpr int BQ = 64, BK = 32, D = 64; + const int h = int(tg.y), lq = P[1], lk = P[2]; + Q += (long(h) * lq + long(tg.x) * BQ) * D; + K += long(h) * lk * D; + V += long(h) * lk * D; + const int os = P[0] * D; + O += long(tg.x) * BQ * os + h * D; + const float scale2 = F[0] * 1.44269504089f; + const short tm = 16 * short(sg); + Q += tm * D; + const short2 home = tfp::frag_home(ushort(lane)); + + tfp::frag acc[4]; + TF_UNROLL + for (short i = 0; i < 4; i++) acc[i] = tfp::frag(0); + float top[2] = {kIdMasked, kIdMasked}, total[2] = {0.0f, 0.0f}; + const bool last_q = int(tg.x) == P[4]; + const short q_rows = short(P[6] - tm), k_rows = short(P[7]); + + for (int kb = 0; kb < P[3]; kb++) { + const bool last_k = kb == P[5]; + tfp::frag s[2] = {tfp::frag(0), tfp::frag(0)}; + TF_UNROLL + for (short d = 0; d < 4; d++) { + tfp::frag q, k0, k1; + if (!AQ && last_q) { + tfp::frag_get_in(q, Q, D, 0, 16 * d, home, q_rows, kIdAnyCols); + } else { + tfp::frag_get(q, Q, D, 0, 16 * d, home); + } + if (!AK && last_k) { + tfp::frag_get_t_in(k0, K, D, 0, 16 * d, home, k_rows, kIdAnyCols); + tfp::frag_get_t_in(k1, K, D, 16, 16 * d, home, k_rows, kIdAnyCols); + } else { + tfp::frag_get_t(k0, K, D, 0, 16 * d, home); + tfp::frag_get_t(k1, K, D, 16, 16 * d, home); + } + tfp::mma_16x32(s[0], s[1], q, k0, k1); + } + TF_UNROLL + for (short f = 0; f < 2; f++) { + TF_UNROLL + for (short e = 0; e < 8; e++) s[f][e] *= scale2; + } + if (!AK && last_k) { + TF_UNROLL + for (short f = 0; f < 2; f++) { + TF_UNROLL + for (short e = 0; e < 8; e++) s[f][e] = (16 * f + home.x + TF_COL(e)) < k_rows ? s[f][e] : kIdMasked; + } + } + float top_new[2] = {top[0], top[1]}; + id_fold(s[0], top_new); + id_fold(s[1], top_new); + TF_UNROLL + for (short f = 0; f < 2; f++) { + TF_UNROLL + // the units take an fp32 P short: round it to fp16 here, so the denominator sums the values P V multiplies + for (short e = 0; e < 8; e++) s[f][e] = float(half(fast::exp2(s[f][e] - top_new[e >> 2]))); + } + float scale_old[2]; + TF_UNROLL + for (short r = 0; r < 2; r++) { + scale_old[r] = fast::exp2(top[r] - top_new[r]); + top[r] = top_new[r]; + total[r] = total[r] * scale_old[r]; + } + id_fold(s[0], total); + id_fold(s[1], total); + TF_UNROLL + for (short i = 0; i < 4; i++) { + TF_UNROLL + for (short e = 0; e < 8; e++) acc[i][e] = acc[i][e] * scale_old[e >> 2]; + } + simdgroup_barrier(mem_flags::mem_none); + TF_UNROLL + for (short d = 0; d < 4; d += 2) { + TF_UNROLL + for (short k = 0; k < 2; k++) { + tfp::frag v0, v1; + if (!AK && last_k) { + tfp::frag_get_in(v0, V, D, 16 * k, 16 * d, home, k_rows, kIdAnyCols); + tfp::frag_get_in(v1, V, D, 16 * k, 16 * d + 16, home, k_rows, kIdAnyCols); + } else { + tfp::frag_get(v0, V, D, 16 * k, 16 * d, home); + tfp::frag_get(v1, V, D, 16 * k, 16 * d + 16, home); + } + tfp::mma_16x32(acc[d], acc[d + 1], s[k], v0, v1); + } + } + K += BK * D; + V += BK * D; + } + + threadgroup_barrier(mem_flags::mem_none); + float inv[2]; + TF_UNROLL + for (short r = 0; r < 2; r++) inv[r] = 1.f / total[r]; + TF_UNROLL + for (short i = 0; i < 4; i++) { + TF_UNROLL + for (short e = 0; e < 8; e++) acc[i][e] = acc[i][e] * inv[e >> 2]; + } + O += tm * os; + if (!AQ && last_q) { + if (q_rows <= 0) return; + TF_UNROLL + for (short i = 0; i < 4; i++) tfp::frag_put_in(acc[i], O, os, 0, 16 * i, home, q_rows, kIdAnyCols); + } else { + TF_UNROLL + for (short i = 0; i < 4; i++) tfp::frag_put(acc[i], O, os, 0, 16 * i, home); + } +} + +#define ID_ATTENTION(NAME, T, AQ, AK) \ + [[max_total_threads_per_threadgroup(128)]] [[kernel]] void NAME( \ + const device T* Q [[buffer(0)]], const device T* K [[buffer(1)]], const device T* V [[buffer(2)]], \ + const device int32_t* P [[buffer(3)]], const device float* F [[buffer(4)]], device T* O [[buffer(5)]], \ + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], \ + uint3 tg [[threadgroup_position_in_grid]]) { \ + id_attention(Q, K, V, O, P, F, tg, sg, lane); \ + } +ID_ATTENTION(id_attention_00, half, false, false) +ID_ATTENTION(id_attention_01, half, false, true) +ID_ATTENTION(id_attention_10, half, true, false) +ID_ATTENTION(id_attention_11, half, true, true) diff --git a/zig/kernels/metal/ling/mla.metal b/zig/kernels/metal/ling/mla.metal new file mode 100644 index 00000000000..fcd813af9d5 --- /dev/null +++ b/zig/kernels/metal/ling/mla.metal @@ -0,0 +1,72 @@ +// Ling MLA extras around k3: RoPE (GPT-J pairs then halves) and per-head gate expand. + +// k3_mla_* kernels are unchanged. Layout matches ling_forward.py rot() and HF apply_rotary_pos_emb_interleave. + +// Pair (z[2i], z[2i+1]) rotates to (out[i], out[32+i]). +#include +using namespace metal; + +constant constexpr uint LAT = 512, ROPE = 64, KEY = LAT + ROPE, NOPE = 128, VD = 128, QD = NOPE + ROPE; + +struct MlaRow { + uint slot, pos; +}; + +struct MlaArgs { + device bfloat* cache; + uint slot_keys, heads, head0, rows, q_stride, kv_stride, gate_stride, out_stride; + float eps, scale; +}; + +// cs is (rows, 32, 2) f32: host f64 cos/sin of pos*inv, rounded to f32. Kernels apply only. +inline float2 ling_apply(float x0, float x1, const device float* cs, uint row, uint i) { + const uint at = (row * (ROPE / 2) + i) * 2; + const float c = cs[at], s = cs[at + 1]; + return float2(fma(x0, c, -(x1 * s)), fma(x1, c, x0 * s)); +} + +inline device bfloat* ling_keys(constant MlaArgs& a, MlaRow r) { + return a.cache + ulong(r.slot) * a.slot_keys * KEY; +} + +// In-place GPT-J rotate of the 64 rope columns k3_mla_cache just copied. + +// 32 threads, no early return: the threadgroup temp needs every lane at the barrier. + +// Cache address is rows[row].pos. +kernel void tf_ling_mla_rope_cache(device const MlaRow* rows [[buffer(0)]], constant MlaArgs& a [[buffer(1)]], + device const float* cs [[buffer(2)]], + uint row [[threadgroup_position_in_grid]], + uint t [[thread_index_in_threadgroup]]) { + threadgroup float tmp[ROPE]; + device bfloat* dst = ling_keys(a, rows[row]) + ulong(rows[row].pos) * KEY + LAT; + const float2 o = ling_apply(float(dst[2 * t]), float(dst[2 * t + 1]), cs, row, t); + tmp[t] = o.x; + tmp[t + ROPE / 2] = o.y; + threadgroup_barrier(mem_flags::mem_threadgroup); + dst[t] = bfloat(tmp[t]); + dst[t + ROPE / 2] = bfloat(tmp[t + ROPE / 2]); +} + +// Same rotate on q's rope region (offset NOPE in each head) in place. Angles from cs[row]. +kernel void tf_ling_mla_rope_q(device bfloat* q [[buffer(0)]], constant MlaArgs& a [[buffer(1)]], + device const float* cs [[buffer(2)]], + uint2 tg [[threadgroup_position_in_grid]], uint t [[thread_index_in_threadgroup]]) { + threadgroup float tmp[ROPE]; + const uint hl = tg.x, row = tg.y; + device bfloat* z = q + ulong(row) * a.q_stride + hl * QD + NOPE; + const float2 o = ling_apply(float(z[2 * t]), float(z[2 * t + 1]), cs, row, t); + tmp[t] = o.x; + tmp[t + ROPE / 2] = o.y; + threadgroup_barrier(mem_flags::mem_threadgroup); + z[t] = bfloat(tmp[t]); + z[t + ROPE / 2] = bfloat(tmp[t + ROPE / 2]); +} + +// Broadcast each per-head gate to 128 value columns so k3_mla_uv keeps Kimi's stride. +kernel void tf_ling_mla_gate_expand(device const bfloat* g [[buffer(0)]], device bfloat* g2 [[buffer(1)]], + constant MlaArgs& a [[buffer(2)]], uint2 gid [[thread_position_in_grid]]) { + const uint col = gid.x, row = gid.y; + if (row >= a.rows || col >= a.heads * VD) return; + g2[row * a.gate_stride + col] = g[row * a.heads + col / VD]; +} diff --git a/zig/kernels/metal/ling/sources.zig b/zig/kernels/metal/ling/sources.zig index 5fac014e986..6863a6cae5c 100644 --- a/zig/kernels/metal/ling/sources.zig +++ b/zig/kernels/metal/ling/sources.zig @@ -1,2 +1,3 @@ //! Ling Metal kernel sources. pub const route = @embedFile("route.metal"); +pub const mla = @embedFile("mla.metal"); diff --git a/zig/kernels/metal/sources.zig b/zig/kernels/metal/sources.zig index 5f178dd7400..0a4801ac6e5 100644 --- a/zig/kernels/metal/sources.zig +++ b/zig/kernels/metal/sources.zig @@ -142,12 +142,16 @@ pub const glm_rows = @embedFile("glm_rows.metal"); pub const glm_gather = @embedFile("glm_gather.metal"); /// GLM-5.3-Flash's latent attention for rows that read every key: 64 heads as one matrix on the tensor units. pub const glm_attn = @embedFile("glm_attn.metal"); +/// A window's rows' dense-attention softmaxes in one launch, appended to ops/softmax.metal (tf_softmax_row). +pub const glm_softmax_rows = @embedFile("glm_softmax_rows.metal"); /// GLM-5.3-Flash's image tower: the prefill GEMM template's projections and attention products, then its own steps. pub const glm_vision = vision_glue ++ @embedFile("glm_vision.metal"); /// The Qwen-VL image tower (core/qwen_vl): the prefill GEMM template's products, then its own steps. pub const core_qwen_vision = vision_glue ++ @embedFile("core/qwen_vision.metal"); /// Qwen-Image-2.1's transformer: the prefill attention template, then its own steps (projections: core_qwen_vision). pub const qwen_image = @embedFile("prefill/attention_nax.metal") ++ @embedFile("qwen_image.metal"); +/// Idol's denoiser: the prefill GEMM template, then its own steps and head-64 attention. +pub const idol = @embedFile("prefill/gemm_nax.metal") ++ @embedFile("idol.metal") ++ @embedFile("idol_attention.metal"); /// MOSS-Image: the prefill attention template, then its transformer's and encoder's steps (gemms: core_qwen_vision). pub const moss_image = @embedFile("prefill/attention_nax.metal") ++ @embedFile("moss_image.metal") ++ @embedFile("moss_image_encoder.metal"); /// Unlimited-OCR-2: its image encoder's and decoder's own steps (projections: core_qwen_vision). @@ -157,12 +161,22 @@ pub const uocr_decoder = @embedFile("uocr/decoder.metal"); pub const moss_image_decoder = @embedFile("moss_image_decoder.metal"); /// A prompt chunk's KDA layer in three passes, appended to the generated kda_rows source (its helpers). pub const glm_kda_prompt = @embedFile("glm_kda_prompt.metal"); +/// A decode window's fused KDA step, appended to kda_rows' source too: its arithmetic, rows' independent parts at once. +pub const glm_kda_window = @embedFile("glm_kda_window.metal"); +/// And on two threadgroups a head (their value columns), then each head's norm: kda_rows' values (Ultra-class GPUs). +pub const glm_kda_parts = @embedFile("glm_kda_parts.metal"); +/// Prompt chunks' expert gathers walked in column groups, appended to core/affine_mm.metal at 4 bits, groups of 64. +pub const glm_mm_groups = @embedFile("glm_mm_groups.metal"); +/// The router's logits for a one-row window, appended to core/moe_route.metal at GLM's two shapes. +pub const glm_route_one = @embedFile("glm_route_one.metal"); /// GLM-5.3-Flash speed-up mode's exchange kernels (families/glm/ep.zig). pub const glm_ep = @embedFile("glm_ep.metal"); /// A prompt chunk's sparse MLA attention on the tensor units (nax.h inlined at load). pub const glm_sparse_nax = @embedFile("glm_sparse_nax.metal"); /// A prompt chunk's index scores on the tensor units (nax.h inlined at load). pub const glm_index_nax = @embedFile("glm_index_nax.metal"); +/// Decode rows' key lists on many threadgroups: a sampled floor marks candidates, a merge selects among them. +pub const glm_select = @embedFile("glm_select.metal"); /// A prompt chunk's MLA absorb on the tensor units (nax.h inlined at load). pub const glm_absorb_nax = @embedFile("glm_absorb_nax.metal"); /// A MoE layer's route in two launches (core/moe_route.zig): router logits, then the top-k and the expert groups. diff --git a/zig/src/cli/cuda_main.zig b/zig/src/cli/cuda_main.zig index a646fdecb1c..4921afa79b9 100644 --- a/zig/src/cli/cuda_main.zig +++ b/zig/src/cli/cuda_main.zig @@ -51,6 +51,7 @@ const usage = \\ tensorfold rm REPO[@REVISION] [--yes] [--dry-run] \\ tensorfold lanes MODEL PROMPTS.json [--solo] [--max-tokens N] [--no-drafts] [sampling as run] [--report PATH] \\ (every prompt through the lane core at once, or one at a time with --solo) + \\ tensorfold config validate FILE \\ tensorfold cluster init|check|status \\ tensorfold serve [MODEL] --cluster FILE \\ tensorfold node --name NAME --cluster FILE @@ -71,6 +72,7 @@ pub fn main(init: std.process.Init) !u8 { } // Cluster commands must work without a model load. node joins over MCDMA, through the library each node names. if (args.len >= 2 and cluster.cli.wants(@ptrCast(args[1..]))) return cluster.cli.main(init, args[1..]); + if (args.len >= 2 and cluster.validate.wants(@ptrCast(args[1..]))) return cluster.validate.main(init, args[1..]); // The checkpoint commands must work without a model, driver or GPU too. if (args.len >= 2 and checkpoint_cli.wants(@ptrCast(args[1..]))) return checkpoint_cli.main(init, args[1..]); // A leading flag is not a command: the usage covers it, without touching the GPU. diff --git a/zig/src/cli/pull_http_test.zig b/zig/src/cli/pull_http_test.zig index 8d4c743d51c..de456b86f80 100644 --- a/zig/src/cli/pull_http_test.zig +++ b/zig/src/cli/pull_http_test.zig @@ -176,7 +176,10 @@ test "pull connect: a pending attempt observes real I/O cancellation and closes }; Pending.entered.store(false, .monotonic); Pending.closes.store(0, .monotonic); - const io = std.testing.io; + var client_io: @import("pull_test_client.zig").Client = undefined; + client_io.init(); + defer client_io.deinit(); + const io = client_io.io(); var future = try io.concurrent(Pending.run, .{io}); while (!Pending.entered.load(.acquire)) try Io.sleep(io, .fromMilliseconds(1), .awake); try std.testing.expectError(error.Canceled, future.cancel(io)); diff --git a/zig/src/cli/pull_test.zig b/zig/src/cli/pull_test.zig index a6ad3fb40fd..06a66d31d1d 100644 --- a/zig/src/cli/pull_test.zig +++ b/zig/src/cli/pull_test.zig @@ -5,9 +5,11 @@ const pull = @import("pull.zig"); const ranged = @import("pull_parts.zig"); const single = @import("pull_file.zig"); const exlr8_pull = @import("pull_exlr8.zig"); +const TestClient = @import("pull_test_client.zig").Client; /// A fake hub on 127.0.0.1: revision and tree APIs, ranged resolve endpoints, a body cut once, a repo ignoring ranges. const FakeHub = struct { + allocator: Allocator = std.heap.page_allocator, // the fake server owns its worker allocations server: std.Io.net.Server, io: std.Io, threaded: *std.Io.Threaded, @@ -37,9 +39,11 @@ const FakeHub = struct { const nested_body: []const u8 = &nested_body_storage; fn open() !FakeHub { - const threaded = try std.testing.allocator.create(std.Io.Threaded); - threaded.* = std.Io.Threaded.init(std.testing.allocator, .{}); - errdefer std.testing.allocator.destroy(threaded); + const a = std.heap.page_allocator; + const threaded = try a.create(std.Io.Threaded); + errdefer a.destroy(threaded); + threaded.* = std.Io.Threaded.init(a, .{}); + errdefer threaded.deinit(); const io = threaded.io(); const loopback: std.Io.net.IpAddress = .{ .ip4 = .loopback(0) }; var server = try loopback.listen(io, .{}); @@ -52,15 +56,20 @@ const FakeHub = struct { nested_hash.update(nested_body); var nested_digest: [32]u8 = undefined; nested_hash.final(&nested_digest); + const weights_sha_hex = try std.fmt.allocPrint(a, "{s}", .{std.fmt.bytesToHex(digest, .lower)}); + errdefer a.free(weights_sha_hex); + const nested_sha_hex = try std.fmt.allocPrint(a, "{s}", .{std.fmt.bytesToHex(nested_digest, .lower)}); + errdefer a.free(nested_sha_hex); return .{ + .allocator = a, .server = server, .io = io, .threaded = threaded, .weights = weights_body, .config = config_body, .nested = nested_body, - .weights_sha_hex = try std.fmt.allocPrint(std.testing.allocator, "{s}", .{std.fmt.bytesToHex(digest, .lower)}), - .nested_sha_hex = try std.fmt.allocPrint(std.testing.allocator, "{s}", .{std.fmt.bytesToHex(nested_digest, .lower)}), + .weights_sha_hex = weights_sha_hex, + .nested_sha_hex = nested_sha_hex, .config_git_hex = gitHex(config_body), .flaky_git_hex = gitHex(flaky_body), .port = server.socket.address.getPort(), @@ -94,7 +103,7 @@ const FakeHub = struct { continue; } fake.live_lock.lockUncancelable(fake.io); - fake.live.append(std.testing.allocator, conn) catch {}; + fake.live.append(fake.allocator, conn) catch {}; fake.live_lock.unlock(fake.io); conns[n] = std.Thread.spawn(.{}, handle, .{ fake, conn }) catch { fake.forget(conn); @@ -190,8 +199,8 @@ const FakeHub = struct { fake.respond(conn, config_body); } else if (std.mem.eql(u8, path, "/api/models/Org/Flash/tree/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1") or std.mem.eql(u8, path, "/api/models/Org/Whole/tree/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb2")) { // The hub's tree sends LFS oids as bare hex. - const tree = std.fmt.allocPrint(std.testing.allocator, "[{{\"type\": \"file\", \"oid\": \"{s}\", \"path\": \"config.json\", \"size\": {d}}}, {{\"type\": \"file\", \"oid\": \"1111111111111111111111111111111111111111\", \"path\": \"weights.safetensors\", \"size\": {d}, \"lfs\": {{\"oid\": \"{s}\", \"size\": {d}}}}}, {{\"type\": \"file\", \"oid\": \"{s}\", \"path\": \"flaky.json\", \"size\": {d}}}, {{\"type\": \"file\", \"oid\": \"3333333333333333333333333333333333333333\", \"path\": \"tensors/model-00001-of-00001.safetensors\", \"size\": {d}, \"lfs\": {{\"oid\": \"{s}\", \"size\": {d}}}}}]", .{ &fake.config_git_hex, fake.config.len, fake.weights.len, fake.weights_sha_hex, fake.weights.len, &fake.flaky_git_hex, flaky_body.len, fake.nested.len, fake.nested_sha_hex, fake.nested.len }) catch return false; - defer std.testing.allocator.free(tree); + const tree = std.fmt.allocPrint(fake.allocator, "[{{\"type\": \"file\", \"oid\": \"{s}\", \"path\": \"config.json\", \"size\": {d}}}, {{\"type\": \"file\", \"oid\": \"1111111111111111111111111111111111111111\", \"path\": \"weights.safetensors\", \"size\": {d}, \"lfs\": {{\"oid\": \"{s}\", \"size\": {d}}}}}, {{\"type\": \"file\", \"oid\": \"{s}\", \"path\": \"flaky.json\", \"size\": {d}}}, {{\"type\": \"file\", \"oid\": \"3333333333333333333333333333333333333333\", \"path\": \"tensors/model-00001-of-00001.safetensors\", \"size\": {d}, \"lfs\": {{\"oid\": \"{s}\", \"size\": {d}}}}}]", .{ &fake.config_git_hex, fake.config.len, fake.weights.len, fake.weights_sha_hex, fake.weights.len, &fake.flaky_git_hex, flaky_body.len, fake.nested.len, fake.nested_sha_hex, fake.nested.len }) catch return false; + defer fake.allocator.free(tree); fake.respond(conn, tree); } else if (std.mem.eql(u8, path, config_path) or std.mem.eql(u8, path, "/Org/Whole/resolve/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb2/config.json")) { fake.respond(conn, fake.config); @@ -283,11 +292,11 @@ const FakeHub = struct { if (fake.server.socket.address.connect(fake.io, .{ .mode = .stream }) catch null) |wake| wake.close(fake.io); if (fake.thread) |t| t.join(); fake.server.deinit(fake.io); - fake.live.deinit(std.testing.allocator); + fake.live.deinit(fake.allocator); fake.threaded.deinit(); - std.testing.allocator.destroy(fake.threaded); - std.testing.allocator.free(fake.weights_sha_hex); - std.testing.allocator.free(fake.nested_sha_hex); + fake.allocator.destroy(fake.threaded); + fake.allocator.free(fake.weights_sha_hex); + fake.allocator.free(fake.nested_sha_hex); } }; @@ -298,10 +307,13 @@ fn testEnv(a: Allocator, endpoint_url: []const u8) !std.process.Environ.Map { } test "pull downloads, verifies, retries a cut body, resumes and refuses a family Zig cannot serve" { - var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena_state = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena_state.deinit(); const a = arena_state.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake_hub = FakeHub.open() catch { return error.SkipZigTest; }; @@ -382,10 +394,13 @@ test "pull downloads, verifies, retries a cut body, resumes and refuses a family } test "large files come down as shared pieces, and whole files when the hub ignores ranges" { - var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena_state = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena_state.deinit(); const a = arena_state.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake_hub = FakeHub.open() catch return error.SkipZigTest; fake_hub.start(); defer fake_hub.stopServer(); @@ -414,10 +429,13 @@ test "large files come down as shared pieces, and whole files when the hub ignor } test "shared pieces fill every byte across files, restart only unmarked pieces and refuse a server without ranges" { - var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena_state = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena_state.deinit(); const a = arena_state.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake_hub = FakeHub.open() catch return error.SkipZigTest; fake_hub.start(); defer fake_hub.stopServer(); @@ -456,10 +474,13 @@ fn hexBytes(text: []const u8) ![32]u8 { } test "an EXLR8 node's whole files land in a relative directory, small files and LFS pieces alike" { - var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena_state = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena_state.deinit(); const a = arena_state.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake_hub = FakeHub.open() catch return error.SkipZigTest; fake_hub.start(); defer fake_hub.stopServer(); @@ -484,10 +505,13 @@ test "an EXLR8 node's whole files land in a relative directory, small files and } test "security: a hub response cannot write beyond the manifest file size" { - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena.deinit(); const a = arena.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake = try FakeHub.open(); fake.start(); defer fake.stopServer(); @@ -511,10 +535,13 @@ test "security: a hub response cannot write beyond the manifest file size" { } test "security: a shard in a folder inside the model folder lands inside the snapshot" { - var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena_state = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena_state.deinit(); const a = arena_state.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake_hub = FakeHub.open() catch return error.SkipZigTest; fake_hub.start(); defer fake_hub.stopServer(); @@ -533,10 +560,13 @@ test "security: a shard in a folder inside the model folder lands inside the sna } test "security: a hub tree path TensorFold reserves is refused, naming the path and why" { - var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena_state = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena_state.deinit(); const a = arena_state.allocator(); - const io = std.testing.io; + const io = client_io.io(); var fake_hub = FakeHub.open() catch return error.SkipZigTest; fake_hub.start(); defer fake_hub.stopServer(); @@ -557,10 +587,13 @@ test "security: a hub tree path TensorFold reserves is refused, naming the path } test "pull refuses cache mutation while rm holds the cache directory" { - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); + var client_io: TestClient = undefined; + client_io.init(); + defer client_io.deinit(); + var arena = std.heap.ArenaAllocator.init(client_io.allocator()); defer arena.deinit(); const a = arena.allocator(); - const io = std.testing.io; + const io = client_io.io(); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); const root = try tmp.dir.realPathFileAlloc(io, ".", a); diff --git a/zig/src/cli/pull_test_client.zig b/zig/src/cli/pull_test_client.zig new file mode 100644 index 00000000000..25dd35a5cec --- /dev/null +++ b/zig/src/cli/pull_test_client.zig @@ -0,0 +1,50 @@ +//! Pull tests own their client I/O and leak-checking allocator without stack unwinds on worker frees. +const std = @import("std"); + +pub const Client = struct { + heap: std.heap.SafeAllocator = undefined, + threaded: std.Io.Threaded = undefined, + + pub fn init(c: *Client) void { + c.heap = .init(std.heap.page_allocator, .{ .stack_trace_frames = 0 }); + c.threaded = .init(c.heap.allocator(), .{}); + } + + pub fn allocator(c: *Client) std.mem.Allocator { + return c.heap.allocator(); + } + + pub fn io(c: *Client) std.Io { + return c.threaded.io(); + } + + pub fn deinit(c: *Client) void { + c.threaded.deinit(); + const leaks = c.heap.deinit(); + if (leaks != 0) std.log.err("pull client test leaked {d} allocations", .{leaks}); + } +}; + +test "pull client I/O: cancelled futures and completed worker groups release their allocations" { + var client: Client = undefined; + client.init(); + defer client.deinit(); + const io = client.io(); + const Work = struct { + fn wait(i: std.Io, entered: *std.Io.Event, finish: *std.Io.Event) std.Io.Cancelable!void { + entered.set(i); + try finish.wait(i); + } + }; + var entered: std.Io.Event = .unset; + var finish: std.Io.Event = .unset; + var future = try io.concurrent(Work.wait, .{ io, &entered, &finish }); + entered.waitUncancelable(io); + try std.testing.expectError(error.Canceled, future.cancel(io)); + entered = .unset; + var group: std.Io.Group = .init; + try group.concurrent(io, Work.wait, .{ io, &entered, &finish }); + entered.waitUncancelable(io); + finish.set(io); + try group.await(io); +} diff --git a/zig/src/cluster/cli.zig b/zig/src/cluster/cli.zig index dc7a6e1f5f1..f300a4ed925 100644 --- a/zig/src/cluster/cli.zig +++ b/zig/src/cluster/cli.zig @@ -22,7 +22,8 @@ pub const Env = struct { }; pub const usage = - \\usage: tensorfold cluster init --node NAME=ADDRESS[@VIA]... [--cuda NAME]... [--ssh-user U] [--ssh-key FILE] [--name CLUSTER] [--probes DIR] + \\usage: tensorfold config validate FILE + \\ tensorfold cluster init --node NAME=ADDRESS[@VIA]... [--cuda NAME]... [--ssh-user U] [--ssh-key FILE] [--name CLUSTER] [--probes DIR] \\ tensorfold cluster check --cluster FILE [--model ID] [--model-config FILE [--model-files FILE]] [--probe | --probes DIR] \\ tensorfold cluster status --cluster FILE [--model ID] [--probe | --probes DIR] \\ tensorfold serve [MODEL] --cluster FILE [--leader NAME] [--dry-run] [--hold SECONDS] [--model-config FILE [--model-files FILE]] [--probe | --probes DIR] diff --git a/zig/src/cluster/cluster.zig b/zig/src/cluster/cluster.zig index 09a70313b94..4ae327fa6a6 100644 --- a/zig/src/cluster/cluster.zig +++ b/zig/src/cluster/cluster.zig @@ -32,6 +32,7 @@ pub const status = @import("status.zig"); pub const cli = @import("cli.zig"); pub const cli_model = @import("cli_model.zig"); pub const bringup = @import("bringup.zig"); +pub const validate = @import("validate.zig"); test { std.testing.refAllDecls(@This()); diff --git a/zig/src/cluster/main.zig b/zig/src/cluster/main.zig index 73e8d2a8c3b..3129ef3fcb2 100644 --- a/zig/src/cluster/main.zig +++ b/zig/src/cluster/main.zig @@ -4,5 +4,6 @@ const cluster = @import("cluster"); pub fn main(init: std.process.Init) !u8 { const argv = try init.minimal.args.toSlice(init.arena.allocator()); + if (cluster.validate.wants(@ptrCast(argv[1..]))) return cluster.validate.main(init, argv[1..]); return cluster.cli.main(init, argv[1..]); } diff --git a/zig/src/cluster/validate.zig b/zig/src/cluster/validate.zig new file mode 100644 index 00000000000..6fbef1ac434 --- /dev/null +++ b/zig/src/cluster/validate.zig @@ -0,0 +1,65 @@ +//! `tensorfold config validate FILE`: parse a cluster file, print every problem, no planning or probes. +const std = @import("std"); +const config = @import("config.zig"); + +const Allocator = std.mem.Allocator; +const W = std.Io.Writer; + +pub const Env = struct { + io: std.Io, + a: Allocator, + out: *W, + err: *W, +}; + +pub const usage = + \\usage: tensorfold config validate FILE + \\ +; + +/// True when argv starts with the config command. +pub fn wants(args: []const []const u8) bool { + return args.len > 0 and std.mem.eql(u8, args[0], "config"); +} + +/// Exit: 0 valid, 1 unreadable or invalid, 2 usage. +pub fn run(env: Env, args: []const []const u8) !u8 { + if (args.len != 3 or !std.mem.eql(u8, args[0], "config") or !std.mem.eql(u8, args[1], "validate")) return bad(env); + const path = args[2]; + if (std.mem.startsWith(u8, path, "-")) return bad(env); + const json = std.Io.Dir.cwd().readFileAlloc(env.io, path, env.a, .limited(16 << 20)) catch |err| { + try env.err.print("{s}: {s}\n", .{ path, @errorName(err) }); + return 1; + }; + var probs: config.Problems = .{ .a = env.a }; + const c = config.parse(env.a, json, &probs) catch { + for (probs.list.items) |p| try env.err.print("{s}\n", .{p}); + return 1; + }; + try env.out.print("{s}: {d} nodes, {d} models\n", .{ path, c.nodes.len, c.models.len }); + return 0; +} + +fn bad(env: Env) !u8 { + try env.err.writeAll(usage); + return 2; +} + +/// The entry both binaries share: argv after the program name, stdout and stderr. +pub fn main(init: std.process.Init, argv: []const [:0]const u8) !u8 { + const a = init.arena.allocator(); + var out_buf: [64 << 10]u8 = undefined; + var err_buf: [4 << 10]u8 = undefined; + var out = std.Io.File.stdout().writerStreaming(init.io, &out_buf); + var err = std.Io.File.stderr().writerStreaming(init.io, &err_buf); + const args = try a.alloc([]const u8, argv.len); + for (args, argv) |*x, y| x.* = y; + const code = try run(.{ .io = init.io, .a = a, .out = &out.interface, .err = &err.interface }, args); + try out.interface.flush(); + try err.interface.flush(); + return code; +} + +test { + _ = @import("validate_test.zig"); +} diff --git a/zig/src/cluster/validate_main.zig b/zig/src/cluster/validate_main.zig new file mode 100644 index 00000000000..fb473ed89c6 --- /dev/null +++ b/zig/src/cluster/validate_main.zig @@ -0,0 +1,8 @@ +//! Host-only `tensorfold config validate`: the same argv as the product CLI, no GPU, no CUDA, no probes. +const std = @import("std"); +const validate = @import("validate.zig"); + +pub fn main(init: std.process.Init) !u8 { + const argv = try init.minimal.args.toSlice(init.arena.allocator()); + return validate.main(init, argv[1..]); +} diff --git a/zig/src/cluster/validate_test.zig b/zig/src/cluster/validate_test.zig new file mode 100644 index 00000000000..8bad2fdf838 --- /dev/null +++ b/zig/src/cluster/validate_test.zig @@ -0,0 +1,125 @@ +//! `tensorfold config validate FILE` on the host: valid, invalid, missing, and usage, with no probes or planning. +const std = @import("std"); +const validate = @import("validate.zig"); +const config_test = @import("config_test.zig"); + +const io = std.testing.io; + +const Run = struct { out: []const u8, err: []const u8, code: u8 }; + +fn run(a: std.mem.Allocator, args: []const []const u8) !Run { + var out: std.Io.Writer.Allocating = .init(a); + var err: std.Io.Writer.Allocating = .init(a); + const code = try validate.run(.{ .io = io, .a = a, .out = &out.writer, .err = &err.writer }, args); + return .{ .out = out.written(), .err = err.written(), .code = code }; +} + +fn has(text: []const u8, needle: []const u8) bool { + if (std.mem.indexOf(u8, text, needle) != null) return true; + std.debug.print("missing \"{s}\" in:\n{s}\n", .{ needle, text }); + return false; +} + +fn writeCluster(a: std.mem.Allocator, tmp: std.testing.TmpDir, data: []const u8) ![]const u8 { + try tmp.dir.writeFile(io, .{ .sub_path = "cluster.json", .data = data }); + return std.fmt.allocPrint(a, ".zig-cache/tmp/{s}/cluster.json", .{tmp.sub_path}); +} + +test "config validate: only the config command belongs to this entry" { + try std.testing.expect(validate.wants(&.{"config"}) and validate.wants(&.{ "config", "validate", "c.json" })); + try std.testing.expect(!validate.wants(&.{ "cluster", "check" }) and !validate.wants(&.{"serve"}) and !validate.wants(&.{})); +} + +test "config validate: the worked example exits 0 and names the path and counts" { + var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const file = try writeCluster(a, tmp, config_test.example); + const got = try run(a, &.{ "config", "validate", file }); + try std.testing.expectEqual(@as(u8, 0), got.code); + try std.testing.expect(has(got.out, file)); + try std.testing.expect(has(got.out, "6 nodes")); + try std.testing.expect(has(got.out, "3 models")); + try std.testing.expectEqualStrings("", got.err); +} + +test "config validate: an unknown backend exits 1 and names it" { + var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const file = try writeCluster(a, tmp, "{\"schema\":\"tensorfold-cluster/1\",\"cluster\":\"x\",\"nodes\":[{\"name\":\"a\",\"address\":\"h\",\"backend\":\"rocm\"}]}"); + const got = try run(a, &.{ "config", "validate", file }); + try std.testing.expectEqual(@as(u8, 1), got.code); + try std.testing.expect(has(got.err, "backend")); + try std.testing.expectEqualStrings("", got.out); +} + +test "config validate: a wrong type exits 1 and names the field" { + var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const file = try writeCluster(a, tmp, "{\"schema\":\"tensorfold-cluster/1\",\"cluster\":\"x\",\"nodes\":\"nope\"}"); + const got = try run(a, &.{ "config", "validate", file }); + try std.testing.expectEqual(@as(u8, 1), got.code); + try std.testing.expect(has(got.err, "nodes: must be an array")); + try std.testing.expectEqualStrings("", got.out); +} + +test "config validate: a conflicting layout exits 1 and names the problem" { + var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const text = + \\{"schema":"tensorfold-cluster/1","cluster":"x", + \\"nodes":[{"name":"m1","address":"h","backend":"metal"},{"name":"m2","address":"h","backend":"metal"}, + \\{"name":"c1","address":"h","backend":"cuda"},{"name":"c2","address":"h","backend":"cuda"}], + \\"models":{"k":{"path":"/m","nodes":["m1","m2","c1","c2"],"parallel":{"tensor":3}}}} + ; + const file = try writeCluster(a, tmp, text); + const got = try run(a, &.{ "config", "validate", file }); + try std.testing.expectEqual(@as(u8, 1), got.code); + try std.testing.expect(has(got.err, "does not divide")); + try std.testing.expectEqualStrings("", got.out); +} + +test "config validate: a missing path exits 1 and includes the path tried" { + var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator); + defer arena.deinit(); + const a = arena.allocator(); + const path = "no-such-cluster-9f3a.json"; + const got = try run(a, &.{ "config", "validate", path }); + try std.testing.expectEqual(@as(u8, 1), got.code); + try std.testing.expect(has(got.err, path)); + try std.testing.expect(has(got.err, "FileNotFound")); + try std.testing.expectEqualStrings("", got.out); +} + +test "config validate: bad usage exits 2" { + var arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator); + defer arena.deinit(); + const a = arena.allocator(); + const Case = struct { args: []const []const u8 }; + const cases = [_]Case{ + .{ .args = &.{"config"} }, + .{ .args = &.{ "config", "validate" } }, + .{ .args = &.{ "config", "check", "c.json" } }, + .{ .args = &.{ "config", "validate", "a.json", "b.json" } }, + .{ .args = &.{ "config", "validate", "--cluster", "c.json" } }, + .{ .args = &.{ "config", "validate", "--help" } }, + }; + for (cases) |k| { + const got = try run(a, k.args); + if (got.code != 2) std.debug.print("usage: exit {d}\n{s}{s}", .{ got.code, got.out, got.err }); + try std.testing.expectEqual(@as(u8, 2), got.code); + try std.testing.expect(has(got.err, "usage: tensorfold config validate FILE")); + try std.testing.expectEqualStrings("", got.out); + } +} diff --git a/zig/src/core/checkpoint_cache.zig b/zig/src/core/checkpoint_cache.zig index 4c829a0b41e..d31f6d5d771 100644 --- a/zig/src/core/checkpoint_cache.zig +++ b/zig/src/core/checkpoint_cache.zig @@ -32,19 +32,15 @@ fn visit(io: Io, dir: []const u8, names: []const []const u8, comptime advise: an } /// Flash Next also closes shards while loading; its live PLE mappings must be excluded from the final sweep. -pub fn directory(io: Io, dir: []const u8, keep: anytype) void { +pub fn shards(io: Io, paths: []const [:0]u8, keep: anytype) void { if (@import("builtin").os.tag != .linux) return; - walk(io, dir, keep, drop); + walk(io, paths, keep, drop); } -fn walk(io: Io, dir: []const u8, keep: anytype, comptime advise: anytype) void { - var d = Io.Dir.cwd().openDir(io, dir, .{ .iterate = true }) catch return; - defer d.close(io); - var it = d.iterate(); - entries: while (it.next(io) catch null) |e| { - if (e.kind != .file and e.kind != .sym_link) continue; - if (!std.mem.endsWith(u8, e.name, ".safetensors")) continue; - const f = d.openFile(io, e.name, .{}) catch continue; +/// `paths` from the index (checkpoint.shardFiles), so shards nested under tensors/ are reached; held inodes skipped. +fn walk(io: Io, paths: []const [:0]u8, keep: anytype, comptime advise: anytype) void { + entries: for (paths) |path| { + const f = Io.Dir.cwd().openFile(io, path, .{}) catch continue; defer f.close(io); const stat = f.stat(io) catch continue; for (keep) |k| { @@ -89,30 +85,33 @@ test "checkpoint cache: last read precedes release and close on success and refu } } -test "checkpoint cache: final sweep excludes live PLE, subdirectories and unrelated files" { +test "checkpoint cache: final sweep reaches the index's nested shards and excludes live PLE and aliases" { var tmp = t.tmpDir(.{}); defer tmp.cleanup(); - for ([_][]const u8{ "model.safetensors", "mtp.safetensors", "ple.safetensors", "config.json" }) |name| + try tmp.dir.createDirPath(t.io, "tensors"); + for ([_][]const u8{ "tensors/model-1.safetensors", "tensors/model-2.safetensors", "tensors/ple.safetensors" }) |name| try tmp.dir.writeFile(t.io, .{ .sub_path = name, .data = name }); - try tmp.dir.createDirPath(t.io, "ssd.safetensors"); - try tmp.dir.writeFile(t.io, .{ .sub_path = "ssd.safetensors/expert.safetensors", .data = "runtime" }); - if (@import("builtin").os.tag != .windows) try tmp.dir.symLink(t.io, "ple.safetensors", "alias.safetensors", .{}); - const ple = try tmp.dir.openFile(t.io, "ple.safetensors", .{}); + if (@import("builtin").os.tag != .windows) try tmp.dir.symLink(t.io, "ple.safetensors", "tensors/alias.safetensors", .{}); + const ple = try tmp.dir.openFile(t.io, "tensors/ple.safetensors", .{}); defer ple.close(t.io); const keep = [_]struct { file: struct { file: Io.File } }{.{ .file = .{ .file = ple } }}; - const path = try tmp.dir.realPathFileAlloc(t.io, ".", t.allocator); - defer t.allocator.free(path); + const root = try tmp.dir.realPathFileAlloc(t.io, ".", t.allocator); + defer t.allocator.free(root); + var paths: [5][:0]u8 = undefined; + for (&paths, [_][]const u8{ "model-1", "model-2", "ple", "alias", "missing" }) |*p, name| + p.* = try std.fmt.allocPrintSentinel(t.allocator, "{s}/tensors/{s}.safetensors", .{ root, name }, 0); + defer for (paths) |p| t.allocator.free(p); const Spy = struct { var count: usize = 0; fn advise(f: Io.File) void { var buf: [64]u8 = undefined; const n = f.readPositionalAll(t.io, &buf, 0) catch unreachable; - std.debug.assert(std.mem.eql(u8, buf[0..n], "model.safetensors") or std.mem.eql(u8, buf[0..n], "mtp.safetensors")); + std.debug.assert(std.mem.startsWith(u8, buf[0..n], "tensors/model-")); count += 1; } }; Spy.count = 0; - walk(t.io, path, &keep, Spy.advise); + walk(t.io, &paths, &keep, Spy.advise); try t.expectEqual(@as(usize, 2), Spy.count); } diff --git a/zig/src/core/contract.zig b/zig/src/core/contract.zig index af4435ba6e5..1e7242532af 100644 --- a/zig/src/core/contract.zig +++ b/zig/src/core/contract.zig @@ -47,9 +47,11 @@ test { _ = @import("contract/row_wide_records.zig"); _ = @import("contract/nemotron_experts_records.zig"); _ = @import("contract/moss_image_records.zig"); + _ = @import("contract/idol_records.zig"); _ = @import("contract/metal_pair_records.zig"); _ = @import("contract/affine_gather_records.zig"); _ = @import("contract/flint_records.zig"); + _ = @import("contract/ling_mla_records.zig"); _ = spec; _ = gates; _ = rows; diff --git a/zig/src/core/contract/glm_launch_records.zig b/zig/src/core/contract/glm_launch_records.zig new file mode 100644 index 00000000000..5012795db21 --- /dev/null +++ b/zig/src/core/contract/glm_launch_records.zig @@ -0,0 +1,47 @@ +//! GLM-5.3-Flash's served Metal launches (tests/contract/metal_glm_launch.zig) at the threads forward.zig launches. +const std = @import("std"); +const M = @import("limits.zig").MetalLaunch; +pub const records = [_]M{ + .{ .name = "glm launch select glm_select_mark", .threads = 256, .tg_memory = 8240, .m1 = 832, .m2 = 832 }, + .{ .name = "glm launch select glm_select_merge", .threads = 512, .tg_memory = 26768, .m1 = 1024, .m2 = 1024 }, + // the sources reserve the threads they launch (max_total_threads_per_threadgroup) + .{ .name = "glm launch kda glm_kda_window", .threads = 1024, .tg_memory = 14464, .reserved = 1024 }, + .{ .name = "glm launch kda glm_kda_window_tp", .threads = 1024, .tg_memory = 14464, .reserved = 1024 }, + .{ .name = "glm launch kda glm_kda_parts", .threads = 512, .tg_memory = 9312, .reserved = 512 }, + .{ .name = "glm launch kda glm_kda_norm", .threads = 256, .tg_memory = 0, .m1 = 1024, .m2 = 1024 }, + // nax.h's fragments multiply through mpp before the M5 too: no M1/M2 build ahead of time, 32 threads a group + .{ .name = "glm launch attn glm_latent_scores_rows", .threads = 32, .tg_memory = 0, .offline = false }, + .{ .name = "glm launch attn glm_latent_values_rows", .threads = 32, .tg_memory = 0, .offline = false }, + .{ .name = "glm launch softmax glm_softmax_rows", .threads = 512, .tg_memory = 256, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch hc tf_hc_expand_mix", .threads = 256, .tg_memory = 800, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch hc tf_hc_first_mix", .threads = 256, .tg_memory = 800, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch hc tf_hc_expand_mix_parts", .threads = 256, .tg_memory = 160, .m1 = 928, .m2 = 928 }, + .{ .name = "glm launch hc tf_hc_first_mix_parts", .threads = 256, .tg_memory = 160, .m1 = 928, .m2 = 928 }, + .{ .name = "glm launch hc tf_hc_expand_inplace", .threads = 1024, .tg_memory = 0, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch hc tf_hc_expand_mix_moe", .threads = 256, .tg_memory = 800, .m1 = 832, .m2 = 832 }, + .{ .name = "glm launch hc tf_hc_expand_mix_parts_moe", .threads = 256, .tg_memory = 160, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch hc tf_hc_split", .threads = 1024, .tg_memory = 128, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch experts two glm_moe_gateup_0", .threads = 128, .tg_memory = 0, .m1 = 704, .m2 = 704 }, + .{ .name = "glm launch experts two glm_moe_down_0", .threads = 32, .tg_memory = 0, .m1 = 896, .m2 = 896 }, + .{ .name = "glm launch experts four glm_moe_gateup_0", .threads = 512, .tg_memory = 0, .m1 = 704, .m2 = 704 }, + .{ .name = "glm launch experts four glm_moe_down_0", .threads = 512, .tg_memory = 0, .m1 = 832, .m2 = 832 }, + .{ .name = "glm launch experts pick glm_moe_gateup_0", .threads = 32, .tg_memory = 0, .m1 = 704, .m2 = 704 }, + .{ .name = "glm launch experts pick glm_moe_down_0", .threads = 32, .tg_memory = 0, .m1 = 896, .m2 = 896 }, + .{ .name = "glm launch route router glm_route_logits_one", .threads = 256, .tg_memory = 128, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch route igate glm_route_logits_one", .threads = 256, .tg_memory = 128, .m1 = 1024, .m2 = 1024 }, + .{ .name = "glm launch picks glm tf_route_select", .threads = 512, .tg_memory = 5312, .m1 = 896, .m2 = 896 }, + .{ .name = "glm launch picks step5 tf_route_select", .threads = 512, .tg_memory = 6336, .m1 = 832, .m2 = 832 }, + .{ .name = "glm launch mla norms glm_mla_norms", .threads = 384, .tg_memory = 144, .m1 = 928, .m2 = 928 }, + // a prompt chunk's experts and dense products in column groups (nax.h: no M1/M2 build ahead of time) + .{ .name = "glm launch prompt experts glm_gather_glu_32", .threads = 128, .tg_memory = 9728, .offline = false }, + .{ .name = "glm launch prompt experts glm_gather_glu_64", .threads = 128, .tg_memory = 9728, .offline = false }, + .{ .name = "glm launch prompt experts glm_gather_scatter_32", .threads = 128, .tg_memory = 9728, .offline = false }, + .{ .name = "glm launch prompt experts glm_gather_scatter_64", .threads = 128, .tg_memory = 9728, .offline = false }, + .{ .name = "glm launch prompt dense glm_mm_grouped", .threads = 128, .tg_memory = 9728, .offline = false }, + // a prompt chunk's index scores in 128-row tiles (nax.h: no M1/M2 build ahead of time) + .{ .name = "glm launch index glm_index_scores_nax", .threads = 256, .tg_memory = 17408, .offline = false }, +}; + +test "the GLM launches fit every Apple family" { + try std.testing.expectEqual(@as(usize, 0), try @import("registry.zig").checkMetal(std.testing.allocator, &records, true)); +} diff --git a/zig/src/core/contract/hip_records_families.zig b/zig/src/core/contract/hip_records_families.zig index a944ff0c4d7..3e37edecb4b 100644 --- a/zig/src/core/contract/hip_records_families.zig +++ b/zig/src/core/contract/hip_records_families.zig @@ -7,6 +7,7 @@ pub const records = .{ @import("hip_records_joint.zig").records, @import("hip_records_lighton_ocr.zig").records, @import("hip_records_qwen_vision.zig").records, + @import("hip_records_relu2_widths.zig").records, }; /// Every family's records as one array. @@ -32,6 +33,7 @@ test "HIP record counts stay pinned in their owning files" { @import("hip_records_prompt.zig").records.len, @import("hip_records_qwen3.zig").records.len, @import("hip_records_qwen_vision.zig").records.len, + @import("hip_records_relu2_widths.zig").records.len, @import("hip_records_router.zig").records.len, @import("hip_records_score.zig").records.len, @import("hip_records_skew.zig").records.len, diff --git a/zig/src/core/contract/hip_records_relu2_widths.zig b/zig/src/core/contract/hip_records_relu2_widths.zig new file mode 100644 index 00000000000..c523d225bb5 --- /dev/null +++ b/zig/src/core/contract/hip_records_relu2_widths.zig @@ -0,0 +1,256 @@ +//! Gate 5's records of the relu^2 stream tile at the wider widths oQ checkpoints store (5, 6 and 8 bits). +const std = @import("std"); +const limits = @import("limits.zig"); +const Record = @import("hip_records.zig").Record; + +/// The relu^2 stream tile at `bits`, `rows` rows and `cb` columns a lane: DotF16 on RDNA2, else DotBF16. +fn relu2Tile(comptime bits: u32, comptime rows: u32, comptime cb: u32) limits.HipLaunch { + const fmt = "_ZN2tf4rocm24affine_dot2_stream_relu2INS0_{s}ELi{d}ELi{d}ELi{d}EEEvNS0_6AffineENS0_11StreamSidesEii"; + const half = std.fmt.comptimePrint(fmt, .{ "6DotF16", bits, rows, cb }); + const brain = std.fmt.comptimePrint(fmt, .{ "7DotBF16", bits, rows, cb }); + return .{ + .name = std.fmt.comptimePrint("relu2 stream tile {d}-bit {d}x{d}", .{ bits, rows, cb }), + .symbol = brain, + .image = "affine_tiles", + .threads = 128, + .symbols = .{ half, brain, brain, brain }, + }; +} + +pub const records = [24]Record{ + .{ + .launch = relu2Tile(5, 1, 2), + .usage = .{ + .{ .vgprs = 93, .sgprs = 49, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 92, .sgprs = 49, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 93, .sgprs = 49, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 93, .sgprs = 49, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 1, 4), + .usage = .{ + .{ .vgprs = 172, .sgprs = 51, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 173, .sgprs = 51, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 172, .sgprs = 51, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 172, .sgprs = 51, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 1, 8), + .usage = .{ + .{ .vgprs = 207, .sgprs = 54, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 256, .sgprs = 54, .lds = 0, .private = 144, .bound = 128, .wave = 32 }, + .{ .vgprs = 204, .sgprs = 54, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 204, .sgprs = 54, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 2, 2), + .usage = .{ + .{ .vgprs = 88, .sgprs = 56, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 87, .sgprs = 56, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 87, .sgprs = 56, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 87, .sgprs = 56, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 2, 4), + .usage = .{ + .{ .vgprs = 140, .sgprs = 58, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 139, .sgprs = 58, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 139, .sgprs = 58, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 139, .sgprs = 58, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 2, 8), + .usage = .{ + .{ .vgprs = 244, .sgprs = 62, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 240, .sgprs = 62, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 239, .sgprs = 62, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 239, .sgprs = 62, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 4, 2), + .usage = .{ + .{ .vgprs = 124, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 123, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 124, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 124, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(5, 4, 4), + .usage = .{ + .{ .vgprs = 180, .sgprs = 66, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 179, .sgprs = 66, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 179, .sgprs = 66, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 179, .sgprs = 66, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 1, 2), + .usage = .{ + .{ .vgprs = 113, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 96, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 112, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 112, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 1, 4), + .usage = .{ + .{ .vgprs = 181, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 182, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 181, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 181, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 1, 8), + .usage = .{ + .{ .vgprs = 221, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 256, .sgprs = 66, .lds = 0, .private = 204, .bound = 128, .wave = 32 }, + .{ .vgprs = 221, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 221, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 2, 2), + .usage = .{ + .{ .vgprs = 89, .sgprs = 62, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 88, .sgprs = 63, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 88, .sgprs = 63, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 88, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 2, 4), + .usage = .{ + .{ .vgprs = 141, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 140, .sgprs = 65, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 140, .sgprs = 65, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 140, .sgprs = 66, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 2, 8), + .usage = .{ + .{ .vgprs = 245, .sgprs = 68, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 242, .sgprs = 72, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 239, .sgprs = 69, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 239, .sgprs = 70, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 4, 2), + .usage = .{ + .{ .vgprs = 125, .sgprs = 70, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 124, .sgprs = 71, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 124, .sgprs = 71, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 124, .sgprs = 72, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(6, 4, 4), + .usage = .{ + .{ .vgprs = 181, .sgprs = 72, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 180, .sgprs = 73, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 180, .sgprs = 73, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 180, .sgprs = 74, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 1, 2), + .usage = .{ + .{ .vgprs = 111, .sgprs = 55, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 105, .sgprs = 55, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 115, .sgprs = 55, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 115, .sgprs = 57, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 1, 4), + .usage = .{ + .{ .vgprs = 211, .sgprs = 57, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 207, .sgprs = 57, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 196, .sgprs = 57, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 196, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 1, 8), + .usage = .{ + .{ .vgprs = 231, .sgprs = 60, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 256, .sgprs = 60, .lds = 0, .private = 180, .bound = 128, .wave = 32 }, + .{ .vgprs = 239, .sgprs = 60, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 239, .sgprs = 62, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 2, 2), + .usage = .{ + .{ .vgprs = 91, .sgprs = 58, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 90, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 90, .sgprs = 59, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 90, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 2, 4), + .usage = .{ + .{ .vgprs = 149, .sgprs = 60, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 140, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 139, .sgprs = 61, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 139, .sgprs = 63, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 2, 8), + .usage = .{ + .{ .vgprs = 189, .sgprs = 64, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 245, .sgprs = 65, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 244, .sgprs = 65, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 244, .sgprs = 67, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 4, 2), + .usage = .{ + .{ .vgprs = 127, .sgprs = 66, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 126, .sgprs = 67, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 129, .sgprs = 67, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 129, .sgprs = 69, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, + .{ + .launch = relu2Tile(8, 4, 4), + .usage = .{ + .{ .vgprs = 178, .sgprs = 68, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 178, .sgprs = 69, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 178, .sgprs = 69, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + .{ .vgprs = 178, .sgprs = 71, .lds = 0, .private = 0, .bound = 128, .wave = 32 }, + }, + }, +}; + +/// The known findings in these records: the 1x8 tile at 5, 6 and 8 bits spills to scratch on gfx1100. +pub const spills_on_gfx1100 = [_][]const u8{ + "relu2 stream tile 5-bit 1x8", + "relu2 stream tile 6-bit 1x8", + "relu2 stream tile 8-bit 1x8", +}; + +test "relu2 width records: scratch only where a known finding names it" { + const gfx1100 = for (limits.rdna, 0..) |t, i| { + if (std.mem.eql(u8, t.name, "gfx1100")) break i; + } else unreachable; + for (records) |r| { + const known = for (spills_on_gfx1100) |n| { + if (std.mem.eql(u8, n, r.launch.name)) break true; + } else false; + for (r.usage, 0..) |u, i| try std.testing.expectEqual(known and i == gfx1100, u.private != 0); + } +} diff --git a/zig/src/core/contract/idol_cuda_records.zig b/zig/src/core/contract/idol_cuda_records.zig new file mode 100644 index 00000000000..62029c96599 --- /dev/null +++ b/zig/src/core/contract/idol_cuda_records.zig @@ -0,0 +1,24 @@ +//! Idol's denoiser kernels on CUDA (idol.cu): every SM's compile records from nvcc 13.0, the release compiler. +const registry = @import("registry.zig"); + +/// nvcc 13.0's usage (cuobjdump -res-usage of the glue-flag image; sm_120's 1024 reserved shared bytes left out). +pub const cuda = [_]registry.CudaRecord{ + .{ .launch = .{ .name = "idol tf_idol_norm", .symbol = "tf_idol_norm", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 32, .static = 32, .bound = 256 }, .{ .regs = 40, .static = 32, .bound = 256 }, .{ .regs = 40, .static = 32, .bound = 256 }, .{ .regs = 33, .static = 32, .bound = 256 }, .{ .regs = 38, .static = 32, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_norm32", .symbol = "tf_idol_norm32", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 32, .static = 32, .bound = 256 }, .{ .regs = 38, .static = 32, .bound = 256 }, .{ .regs = 38, .static = 32, .bound = 256 }, .{ .regs = 36, .static = 32, .bound = 256 }, .{ .regs = 38, .static = 32, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_repo", .symbol = "tf_idol_repo", .image = "idol", .threads = 64, .min_sm = 80 }, .usage = .{ .{ .regs = 38, .static = 704, .bound = 64 }, .{ .regs = 66, .static = 704, .bound = 64 }, .{ .regs = 44, .static = 704, .bound = 64 }, .{ .regs = 37, .static = 704, .bound = 64 }, .{ .regs = 37, .static = 704, .bound = 64 } } }, + .{ .launch = .{ .name = "idol tf_idol_qk", .symbol = "tf_idol_qk", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 25, .static = 0, .bound = 256 }, .{ .regs = 25, .static = 0, .bound = 256 }, .{ .regs = 25, .static = 0, .bound = 256 }, .{ .regs = 27, .static = 0, .bound = 256 }, .{ .regs = 27, .static = 0, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_gate_add", .symbol = "tf_idol_gate_add", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 12, .static = 0, .bound = 256 }, .{ .regs = 12, .static = 0, .bound = 256 }, .{ .regs = 12, .static = 0, .bound = 256 }, .{ .regs = 12, .static = 0, .bound = 256 }, .{ .regs = 12, .static = 0, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_bias", .symbol = "tf_idol_bias", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 14, .static = 0, .bound = 256 }, .{ .regs = 15, .static = 0, .bound = 256 }, .{ .regs = 15, .static = 0, .bound = 256 }, .{ .regs = 14, .static = 0, .bound = 256 }, .{ .regs = 14, .static = 0, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_embed", .symbol = "tf_idol_embed", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 32, .static = 0, .bound = 256 }, .{ .regs = 40, .static = 0, .bound = 256 }, .{ .regs = 40, .static = 0, .bound = 256 }, .{ .regs = 40, .static = 0, .bound = 256 }, .{ .regs = 40, .static = 0, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_cond", .symbol = "tf_idol_cond", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 16, .static = 0, .bound = 256 }, .{ .regs = 16, .static = 0, .bound = 256 }, .{ .regs = 16, .static = 0, .bound = 256 }, .{ .regs = 18, .static = 0, .bound = 256 }, .{ .regs = 18, .static = 0, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_bias32", .symbol = "tf_idol_bias32", .image = "idol", .threads = 256, .min_sm = 80 }, .usage = .{ .{ .regs = 10, .static = 0, .bound = 256 }, .{ .regs = 10, .static = 0, .bound = 256 }, .{ .regs = 10, .static = 0, .bound = 256 }, .{ .regs = 12, .static = 0, .bound = 256 }, .{ .regs = 12, .static = 0, .bound = 256 } } }, + .{ .launch = .{ .name = "idol tf_idol_attention", .symbol = "tf_idol_attention", .image = "idol", .threads = 256, .dynamic = 36864, .min_sm = 80 }, .usage = .{ .{ .regs = 132, .static = 0, .bound = 256 }, .{ .regs = 132, .static = 0, .bound = 256 }, .{ .regs = 132, .static = 0, .bound = 256 }, .{ .regs = 120, .static = 0, .bound = 256 }, .{ .regs = 120, .static = 0, .bound = 256 } } }, +}; + +test "Idol CUDA: measured launches fit their physical resource limits" { + const t = @import("std").testing; + for (cuda) |r| { + for (r.usage) |u| try t.expect(u.regs > 0); + try t.expectEqual(@as(usize, 0), try registry.checkCuda(t.allocator, &.{r}, true)); + } +} diff --git a/zig/src/core/contract/idol_cuda_sets.zig b/zig/src/core/contract/idol_cuda_sets.zig new file mode 100644 index 00000000000..35104f2a939 --- /dev/null +++ b/zig/src/core/contract/idol_cuda_sets.zig @@ -0,0 +1,6 @@ +//! Every Idol component's CUDA records (nvcc 13.0, each SM), joined in the pipeline's order for registry.zig. +pub const cuda = @import("idol_cuda_records.zig").cuda; + +test { + _ = @import("idol_cuda_records.zig"); +} diff --git a/zig/src/core/contract/idol_records.zig b/zig/src/core/contract/idol_records.zig new file mode 100644 index 00000000000..ae395491641 --- /dev/null +++ b/zig/src/core/contract/idol_records.zig @@ -0,0 +1,34 @@ +//! Idol's denoiser launches (idol.metal and idol_attention.metal after gemm_nax.metal), each source-reserved. +const std = @import("std"); +const M = @import("limits.zig").MetalLaunch; +pub const records = [_]M{ + .{ .name = "idol id_linear_00", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_01", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_10", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_11", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_gelu_00", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_gelu_01", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_gelu_10", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_linear_gelu_11", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_split_0", .threads = 128, .tg_memory = 0, .reserved = 128 }, + .{ .name = "idol id_split_1", .threads = 128, .tg_memory = 0, .reserved = 128 }, + .{ .name = "idol id_gemm32", .threads = 128, .tg_memory = 19456, .reserved = 128 }, + .{ .name = "idol id_norm", .threads = 256, .tg_memory = 144, .reserved = 256 }, + .{ .name = "idol id_norm32", .threads = 256, .tg_memory = 144, .reserved = 256 }, + .{ .name = "idol id_norm_split", .threads = 256, .tg_memory = 144, .reserved = 256 }, + .{ .name = "idol id_repo", .threads = 64, .tg_memory = 704, .reserved = 64 }, + .{ .name = "idol id_qk", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_gate_add", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_embed", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_cond", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_bias32", .threads = 256, .tg_memory = 0, .reserved = 256 }, + .{ .name = "idol id_attention_00", .threads = 128, .tg_memory = 0, .reserved = 128 }, + .{ .name = "idol id_attention_01", .threads = 128, .tg_memory = 0, .reserved = 128 }, + .{ .name = "idol id_attention_10", .threads = 128, .tg_memory = 0, .reserved = 128 }, + .{ .name = "idol id_attention_11", .threads = 128, .tg_memory = 0, .reserved = 128 }, +}; + +test "the Idol launches fit every Apple family, one record a pipeline" { + try std.testing.expectEqual(@as(usize, 0), try @import("registry.zig").checkMetal(std.testing.allocator, &records, true)); + try std.testing.expectEqual(@as(usize, 24), records.len); +} diff --git a/zig/src/core/contract/ling_mla_records.zig b/zig/src/core/contract/ling_mla_records.zig new file mode 100644 index 00000000000..ef706fa8efd --- /dev/null +++ b/zig/src/core/contract/ling_mla_records.zig @@ -0,0 +1,12 @@ +//! Ling MLA extras (tf_ling_mla_rope_cache, tf_ling_mla_rope_q, tf_ling_mla_gate_expand). +const std = @import("std"); +const M = @import("limits.zig").MetalLaunch; +pub const records = [_]M{ + .{ .name = "metal ling mla tf_ling_mla_rope_cache", .threads = 32, .tg_memory = 256, .m1 = 1024, .m2 = 1024 }, + .{ .name = "metal ling mla tf_ling_mla_rope_q", .threads = 32, .tg_memory = 256, .m1 = 1024, .m2 = 1024 }, + .{ .name = "metal ling mla tf_ling_mla_gate_expand", .threads = 128, .tg_memory = 0, .m1 = 1024, .m2 = 1024 }, +}; + +test "the Ling MLA launches fit every Apple family" { + try std.testing.expectEqual(@as(usize, 0), try @import("registry.zig").checkMetal(std.testing.allocator, &records, true)); +} diff --git a/zig/src/core/contract/nvfp4_fact_records.zig b/zig/src/core/contract/nvfp4_fact_records.zig index 353e49ef4ee..642e4bf9b9f 100644 --- a/zig/src/core/contract/nvfp4_fact_records.zig +++ b/zig/src/core/contract/nvfp4_fact_records.zig @@ -1,27 +1,29 @@ -//! tf_nvfp4_fact_*, decode waves and 1-warp decode CTAs (nvfp4_experts.cu): nvcc 13.0.88 cubins, sm_80/86/89/120a/121a. +//! tf_nvfp4_fact_* and the decode CTAs (nvfp4_experts.cu): nvcc 13.0.88 cubins, sm_80/86/89/120a/121a. const CudaRecord = @import("registry.zig").CudaRecord; pub const cuda = [_]CudaRecord{ .{ .launch = .{ .name = "nvfp4_experts tf_nvfp4_fact_swiglu", .symbol = "tf_nvfp4_fact_swiglu", .image = "nvfp4_experts", .threads = 128, .dynamic = 34816 }, .usage = .{ .{ .regs = 249, .static = 0, .bound = 128 }, .{ .regs = 249, .static = 0, .bound = 128 }, .{ .regs = 255, .static = 0, .bound = 128 }, .{ .regs = 255, .static = 0, .bound = 128 }, .{ .regs = 255, .static = 0, .bound = 128 } } }, .{ .launch = .{ .name = "nvfp4_experts tf_nvfp4_fact_down_f32", .symbol = "tf_nvfp4_fact_down_f32", .image = "nvfp4_experts", .threads = 256, .dynamic = 34816 }, .usage = .{ .{ .regs = 185, .static = 0, .bound = 256 }, .{ .regs = 186, .static = 0, .bound = 256 }, .{ .regs = 178, .static = 0, .bound = 256 }, .{ .regs = 141, .static = 0, .bound = 256 }, .{ .regs = 141, .static = 0, .bound = 256 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode waves gate-up", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi2ELi2ELi4EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 128, .dynamic = 0 }, .usage = .{ .{ .regs = 117, .static = 0, .bound = 128 }, .{ .regs = 117, .static = 0, .bound = 128 }, .{ .regs = 121, .static = 0, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode waves down f32", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi1ELi0ELi4EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 128, .dynamic = 0 }, .usage = .{ .{ .regs = 80, .static = 0, .bound = 128 }, .{ .regs = 80, .static = 0, .bound = 128 }, .{ .regs = 89, .static = 0, .bound = 128 }, .{ .regs = 96, .static = 0, .bound = 128 }, .{ .regs = 96, .static = 0, .bound = 128 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode half gate-up", .symbol = "_ZN16tf_nvfp4_experts17nvfp4_expert_halfILi2ELi2ELi4EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 128, .dynamic = 0 }, .usage = .{ .{ .regs = 91, .static = 0, .bound = 128 }, .{ .regs = 91, .static = 0, .bound = 128 }, .{ .regs = 95, .static = 0, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode gate-up, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi2ELi2ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 118, .static = 0, .bound = 32 }, .{ .regs = 118, .static = 0, .bound = 32 }, .{ .regs = 122, .static = 0, .bound = 32 }, .{ .regs = 127, .static = 0, .bound = 32 }, .{ .regs = 127, .static = 0, .bound = 32 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode down f32, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi1ELi0ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 81, .static = 0, .bound = 32 }, .{ .regs = 83, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode down bf16, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi1ELi3ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 81, .static = 0, .bound = 32 }, .{ .regs = 83, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode up relu2, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi1ELi1ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 81, .static = 0, .bound = 32 }, .{ .regs = 83, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode waves gate-up, 1 warp", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi2ELi2ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 117, .static = 0, .bound = 32 }, .{ .regs = 117, .static = 0, .bound = 32 }, .{ .regs = 123, .static = 0, .bound = 32 }, .{ .regs = 124, .static = 0, .bound = 32 }, .{ .regs = 124, .static = 0, .bound = 32 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode waves down f32, 1 warp", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi1ELi0ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 85, .static = 0, .bound = 32 }, .{ .regs = 84, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 } } }, - .{ .launch = .{ .name = "nvfp4_experts decode half gate-up, 1 warp", .symbol = "_ZN16tf_nvfp4_experts17nvfp4_expert_halfILi2ELi2ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 91, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 94, .static = 0, .bound = 32 }, .{ .regs = 95, .static = 0, .bound = 32 }, .{ .regs = 95, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode waves gate-up", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi2ELi2ELi4EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 128, .dynamic = 0 }, .usage = .{ .{ .regs = 101, .static = 34816, .bound = 128 }, .{ .regs = 106, .static = 34816, .bound = 128 }, .{ .regs = 134, .static = 34816, .bound = 128 }, .{ .regs = 130, .static = 34816, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode waves down f32", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi1ELi0ELi4EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 128, .dynamic = 0 }, .usage = .{ .{ .regs = 79, .static = 25600, .bound = 128 }, .{ .regs = 82, .static = 25600, .bound = 128 }, .{ .regs = 101, .static = 25600, .bound = 128 }, .{ .regs = 108, .static = 25600, .bound = 128 }, .{ .regs = 96, .static = 0, .bound = 128 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode half gate-up", .symbol = "_ZN16tf_nvfp4_experts17nvfp4_expert_halfILi2ELi2ELi4EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 128, .dynamic = 0 }, .usage = .{ .{ .regs = 85, .static = 26624, .bound = 128 }, .{ .regs = 88, .static = 26624, .bound = 128 }, .{ .regs = 96, .static = 26624, .bound = 128 }, .{ .regs = 94, .static = 26624, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode gate-up, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi2ELi2ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 139, .static = 8704, .bound = 32 }, .{ .regs = 124, .static = 8704, .bound = 32 }, .{ .regs = 127, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode down f32, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi1ELi0ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 88, .static = 6400, .bound = 32 }, .{ .regs = 102, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode down bf16, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi1ELi3ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 88, .static = 6400, .bound = 32 }, .{ .regs = 102, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode up relu2, 1 warp", .symbol = "_ZN16tf_nvfp4_experts19nvfp4_expert_kernelILi1ELi1ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 88, .static = 6400, .bound = 32 }, .{ .regs = 102, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 80, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode waves gate-up, 1 warp", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi2ELi2ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 140, .static = 8704, .bound = 32 }, .{ .regs = 126, .static = 8704, .bound = 32 }, .{ .regs = 124, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode waves down f32, 1 warp", .symbol = "_ZN16tf_nvfp4_experts18nvfp4_expert_wavesILi1ELi0ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 90, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 } } }, + .{ .launch = .{ .name = "nvfp4_experts decode half gate-up, 1 warp", .symbol = "_ZN16tf_nvfp4_experts17nvfp4_expert_halfILi2ELi2ELi1EEEvPK13__nv_bfloat16iiPK5uint4PKfiiPKiSA_SA_Pvifi", .image = "nvfp4_experts", .threads = 32, .dynamic = 0 }, .usage = .{ .{ .regs = 85, .static = 6656, .bound = 32 }, .{ .regs = 87, .static = 6656, .bound = 32 }, .{ .regs = 93, .static = 6656, .bound = 32 }, .{ .regs = 90, .static = 6656, .bound = 32 }, .{ .regs = 95, .static = 0, .bound = 32 } } }, }; -/// What nvcc 13.2 compiles differently on sm_120 and sm_121: the 1-warp decode CTAs. +/// What nvcc 13.2.78 compiles differently on the decode CTAs; nvcc 13.3.73 compiles them as 13.2 does. pub const cuda_132 = [_]@import("registry.zig").Override{ - .{ .name = "nvfp4_experts decode gate-up, 1 warp", .usage = .{ .{ .regs = 118, .static = 0, .bound = 32 }, .{ .regs = 118, .static = 0, .bound = 32 }, .{ .regs = 122, .static = 0, .bound = 32 }, .{ .regs = 126, .static = 0, .bound = 32 }, .{ .regs = 126, .static = 0, .bound = 32 } } }, - .{ .name = "nvfp4_experts decode down f32, 1 warp", .usage = .{ .{ .regs = 81, .static = 0, .bound = 32 }, .{ .regs = 83, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 } } }, - .{ .name = "nvfp4_experts decode down bf16, 1 warp", .usage = .{ .{ .regs = 81, .static = 0, .bound = 32 }, .{ .regs = 83, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 } } }, - .{ .name = "nvfp4_experts decode up relu2, 1 warp", .usage = .{ .{ .regs = 81, .static = 0, .bound = 32 }, .{ .regs = 83, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 } } }, - .{ .name = "nvfp4_experts decode waves gate-up, 1 warp", .usage = .{ .{ .regs = 117, .static = 0, .bound = 32 }, .{ .regs = 117, .static = 0, .bound = 32 }, .{ .regs = 123, .static = 0, .bound = 32 }, .{ .regs = 126, .static = 0, .bound = 32 }, .{ .regs = 126, .static = 0, .bound = 32 } } }, - .{ .name = "nvfp4_experts decode waves down f32, 1 warp", .usage = .{ .{ .regs = 85, .static = 0, .bound = 32 }, .{ .regs = 84, .static = 0, .bound = 32 }, .{ .regs = 92, .static = 0, .bound = 32 }, .{ .regs = 95, .static = 0, .bound = 32 }, .{ .regs = 95, .static = 0, .bound = 32 } } }, + .{ .name = "nvfp4_experts decode waves gate-up", .usage = .{ .{ .regs = 101, .static = 34816, .bound = 128 }, .{ .regs = 106, .static = 34816, .bound = 128 }, .{ .regs = 134, .static = 34816, .bound = 128 }, .{ .regs = 129, .static = 34816, .bound = 128 }, .{ .regs = 126, .static = 0, .bound = 128 } } }, + .{ .name = "nvfp4_experts decode waves down f32", .usage = .{ .{ .regs = 79, .static = 25600, .bound = 128 }, .{ .regs = 82, .static = 25600, .bound = 128 }, .{ .regs = 101, .static = 25600, .bound = 128 }, .{ .regs = 107, .static = 25600, .bound = 128 }, .{ .regs = 96, .static = 0, .bound = 128 } } }, + .{ .name = "nvfp4_experts decode waves gate-up, 1 warp", .usage = .{ .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 140, .static = 8704, .bound = 32 }, .{ .regs = 124, .static = 8704, .bound = 32 }, .{ .regs = 126, .static = 0, .bound = 32 } } }, + .{ .name = "nvfp4_experts decode gate-up, 1 warp", .usage = .{ .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 103, .static = 8704, .bound = 32 }, .{ .regs = 139, .static = 8704, .bound = 32 }, .{ .regs = 124, .static = 8704, .bound = 32 }, .{ .regs = 126, .static = 0, .bound = 32 } } }, + .{ .name = "nvfp4_experts decode down f32, 1 warp", .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 88, .static = 6400, .bound = 32 }, .{ .regs = 102, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 } } }, + .{ .name = "nvfp4_experts decode down bf16, 1 warp", .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 88, .static = 6400, .bound = 32 }, .{ .regs = 102, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 } } }, + .{ .name = "nvfp4_experts decode up relu2, 1 warp", .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 88, .static = 6400, .bound = 32 }, .{ .regs = 102, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 79, .static = 0, .bound = 32 } } }, + .{ .name = "nvfp4_experts decode waves down f32, 1 warp", .usage = .{ .{ .regs = 80, .static = 6400, .bound = 32 }, .{ .regs = 90, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 103, .static = 6400, .bound = 32 }, .{ .regs = 95, .static = 0, .bound = 32 } } }, }; diff --git a/zig/src/core/contract/registry.zig b/zig/src/core/contract/registry.zig index e4386b2df30..632643aaa7e 100644 --- a/zig/src/core/contract/registry.zig +++ b/zig/src/core/contract/registry.zig @@ -213,111 +213,7 @@ pub const Override = struct { name: []const u8, usage: [limits.sms.len]U }; /// A later nvcc's records: the launches it compiles differently from the release before it. pub const CudaSet = struct { release: limits.Nvcc, usage: []const Override }; /// The later releases' sets, rising by release; a tree's images are checked against the newest at or below their own. -pub const cuda_sets = [_]CudaSet{ - .{ .release = .{ .major = 13, .minor = 2 }, .usage = &(@import("registry_shared_attention.zig").nvcc132(Override) ++ [_]Override{ - .{ .name = "window_pages tf_wrows_merge_512_pg", .usage = .{ .{ .regs = 56, .static = 128, .bound = 256 }, .{ .regs = 56, .static = 128, .bound = 256 }, .{ .regs = 56, .static = 128, .bound = 256 }, .{ .regs = 60, .static = 128, .bound = 256 }, .{ .regs = 60, .static = 128, .bound = 256 } } }, - .{ .name = "moe tf_moe_topk_sigmoid_score_warp", .usage = .{ .{ .regs = 219, .static = 0, .bound = 256 }, .{ .regs = 219, .static = 0, .bound = 256 }, .{ .regs = 219, .static = 0, .bound = 256 }, .{ .regs = 203, .static = 0, .bound = 256 }, .{ .regs = 203, .static = 0, .bound = 256 } } }, - .{ .name = "norms tf_rms_rows", .usage = .{ .{ .regs = 32, .static = 132, .bound = 1024 }, .{ .regs = 46, .static = 132, .bound = 1024 }, .{ .regs = 46, .static = 132, .bound = 1024 }, .{ .regs = 43, .static = 132, .bound = 1024 }, .{ .regs = 43, .static = 132, .bound = 1024 } } }, - .{ .name = "lane_gemv", .usage = .{ .{ .regs = 64, .static = 0, .bound = 128 }, .{ .regs = 58, .static = 0, .bound = 128 }, .{ .regs = 58, .static = 0, .bound = 128 }, .{ .regs = 66, .static = 0, .bound = 128 }, .{ .regs = 66, .static = 0, .bound = 128 } } }, - .{ .name = "lane_gemv split-K", .usage = .{ .{ .regs = 62, .static = 128, .bound = 128 }, .{ .regs = 56, .static = 128, .bound = 128 }, .{ .regs = 56, .static = 128, .bound = 128 }, .{ .regs = 72, .static = 128, .bound = 128 }, .{ .regs = 72, .static = 128, .bound = 128 } } }, - .{ .name = "prompt16 FP8", .usage = .{ .{ .regs = 243, .static = 0, .bound = 128 }, .{ .regs = 243, .static = 0, .bound = 128 }, .{ .regs = 243, .static = 0, .bound = 128 }, .{ .regs = 212, .static = 0, .bound = 128 }, .{ .regs = 212, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf FP4 fp32 out 32-row tile, cluster of 8", .usage = .{ .{ .regs = 64, .static = 0, .bound = 128 }, .{ .regs = 64, .static = 0, .bound = 128 }, .{ .regs = 80, .static = 0, .bound = 128 }, .{ .regs = 61, .static = 0, .bound = 128 }, .{ .regs = 61, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf MXFP8 64-row tile, fused slices", .usage = .{ .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf FP8 fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 179, .static = 0, .bound = 128 }, .{ .regs = 179, .static = 0, .bound = 128 }, .{ .regs = 179, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf MXFP8 fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf FP8G fp32 out 32-row tile, cluster of 8", .usage = .{ .{ .regs = 72, .static = 0, .bound = 128 }, .{ .regs = 72, .static = 0, .bound = 128 }, .{ .regs = 72, .static = 0, .bound = 128 }, .{ .regs = 57, .static = 0, .bound = 128 }, .{ .regs = 57, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf FP8G fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 196, .static = 0, .bound = 128 }, .{ .regs = 196, .static = 0, .bound = 128 }, .{ .regs = 196, .static = 0, .bound = 128 }, .{ .regs = 155, .static = 0, .bound = 128 }, .{ .regs = 155, .static = 0, .bound = 128 } } }, - .{ .name = "qmmf BF16 fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 180, .static = 0, .bound = 128 }, .{ .regs = 180, .static = 0, .bound = 128 }, .{ .regs = 180, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 } } }, - .{ .name = "flashnext_gdn flashnext_gdn_chain", .usage = .{ .{ .regs = 51, .static = 2060, .bound = 1024 }, .{ .regs = 56, .static = 2060, .bound = 1024 }, .{ .regs = 56, .static = 2060, .bound = 1024 }, .{ .regs = 64, .static = 2060, .bound = 1024 }, .{ .regs = 64, .static = 2060, .bound = 1024 } } }, - .{ .name = "flashnext_attn fn_attn_chunks", .usage = .{ .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 } } }, - .{ .name = "flashnext_attn fn_attn_chunks_ahead", .usage = .{ .{ .regs = 70, .static = 768, .bound = 128 }, .{ .regs = 70, .static = 768, .bound = 128 }, .{ .regs = 70, .static = 768, .bound = 128 }, .{ .regs = 72, .static = 768, .bound = 128 }, .{ .regs = 72, .static = 768, .bound = 128 } } }, - .{ .name = "flashnext_attn fn_attn_merge", .usage = .{ .{ .regs = 26, .static = 0, .bound = 256 }, .{ .regs = 28, .static = 0, .bound = 256 }, .{ .regs = 28, .static = 0, .bound = 256 }, .{ .regs = 23, .static = 0, .bound = 256 }, .{ .regs = 23, .static = 0, .bound = 256 } } }, - .{ .name = "flashnext_batch fn_gdn_front", .usage = .{ .{ .regs = 26, .static = 1024, .bound = 256 }, .{ .regs = 26, .static = 1024, .bound = 256 }, .{ .regs = 26, .static = 1024, .bound = 256 }, .{ .regs = 30, .static = 1024, .bound = 256 }, .{ .regs = 30, .static = 1024, .bound = 256 } } }, - .{ .name = "flashnext_hc fn_hc_down", .usage = .{ .{ .regs = 56, .static = 64, .bound = 128 }, .{ .regs = 54, .static = 64, .bound = 128 }, .{ .regs = 54, .static = 64, .bound = 128 }, .{ .regs = 64, .static = 64, .bound = 128 }, .{ .regs = 64, .static = 64, .bound = 128 } } }, - .{ .name = "flashnext_hc fn_hc_normalize", .usage = .{ .{ .regs = 32, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 } } }, - .{ .name = "flashnext_hc fn_hc_reduce_act", .usage = .{ .{ .regs = 32, .static = 4096, .bound = 1024 }, .{ .regs = 63, .static = 4096, .bound = 1024 }, .{ .regs = 63, .static = 4096, .bound = 1024 }, .{ .regs = 60, .static = 4096, .bound = 1024 }, .{ .regs = 60, .static = 4096, .bound = 1024 } } }, - .{ .name = "flashnext_hc fn_hc_upmix", .usage = .{ .{ .regs = 69, .static = 2048, .bound = 256 }, .{ .regs = 64, .static = 2048, .bound = 256 }, .{ .regs = 64, .static = 2048, .bound = 256 }, .{ .regs = 62, .static = 2048, .bound = 256 }, .{ .regs = 62, .static = 2048, .bound = 256 } } }, - .{ .name = "flashnext_hc fn_hc_writeback0", .usage = .{ .{ .regs = 30, .static = 256, .bound = 256 }, .{ .regs = 30, .static = 256, .bound = 256 }, .{ .regs = 30, .static = 256, .bound = 256 }, .{ .regs = 37, .static = 256, .bound = 256 }, .{ .regs = 37, .static = 256, .bound = 256 } } }, - .{ .name = "flashnext_hc fn_hc_writeback_moe", .usage = .{ .{ .regs = 32, .static = 256, .bound = 256 }, .{ .regs = 40, .static = 256, .bound = 256 }, .{ .regs = 40, .static = 256, .bound = 256 }, .{ .regs = 47, .static = 256, .bound = 256 }, .{ .regs = 47, .static = 256, .bound = 256 } } }, - .{ .name = "flashnext_hc fn_ple_conv", .usage = .{ .{ .regs = 23, .static = 0, .bound = 512 }, .{ .regs = 35, .static = 0, .bound = 512 }, .{ .regs = 35, .static = 0, .bound = 512 }, .{ .regs = 36, .static = 0, .bound = 512 }, .{ .regs = 36, .static = 0, .bound = 512 } } }, - .{ .name = "flashnext_hc fn_ple_gate", .usage = .{ .{ .regs = 32, .static = 128, .bound = 512 }, .{ .regs = 34, .static = 128, .bound = 512 }, .{ .regs = 34, .static = 128, .bound = 512 }, .{ .regs = 33, .static = 128, .bound = 512 }, .{ .regs = 33, .static = 128, .bound = 512 } } }, - .{ .name = "flashnext_attn fn_qsa_pool", .usage = .{ .{ .regs = 32, .static = 1152, .bound = 128 }, .{ .regs = 40, .static = 1152, .bound = 128 }, .{ .regs = 40, .static = 1152, .bound = 128 }, .{ .regs = 39, .static = 1152, .bound = 128 }, .{ .regs = 39, .static = 1152, .bound = 128 } } }, - .{ .name = "flashnext_batch fn_qsa_select", .usage = .{ .{ .regs = 32, .static = 1168, .bound = 1024 }, .{ .regs = 50, .static = 1168, .bound = 1024 }, .{ .regs = 50, .static = 1168, .bound = 1024 }, .{ .regs = 42, .static = 1168, .bound = 1024 }, .{ .regs = 42, .static = 1168, .bound = 1024 } } }, - .{ .name = "route_rows tf_route_logits", .usage = .{ .{ .regs = 32, .static = 0, .bound = 128 }, .{ .regs = 39, .static = 0, .bound = 128 }, .{ .regs = 39, .static = 0, .bound = 128 }, .{ .regs = 35, .static = 0, .bound = 128 }, .{ .regs = 35, .static = 0, .bound = 128 } } }, - .{ .name = "route_rows tf_route_logits_few", .usage = .{ .{ .regs = 31, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 }, .{ .regs = 34, .static = 0, .bound = 128 }, .{ .regs = 34, .static = 0, .bound = 128 } } }, - .{ .name = "qwen_vision tf_qv_qkv_rope", .usage = .{ .{ .regs = 32, .static = 0, .bound = 128 }, .{ .regs = 37, .static = 0, .bound = 128 }, .{ .regs = 37, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 } } }, - .{ .name = "qwen_vision tf_qv_attention64", .usage = .{ .{ .regs = 164, .static = 32768, .bound = 64 }, .{ .regs = 164, .static = 32768, .bound = 64 }, .{ .regs = 164, .static = 32768, .bound = 64 }, .{ .regs = 162, .static = 32768, .bound = 64 }, .{ .regs = 162, .static = 32768, .bound = 64 } } }, - .{ .name = "exl3_linear tf_exl3_linear_2_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_4_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_6_2_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 159, .static = 16, .bound = 128 }, .{ .regs = 159, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_8_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_3_2_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_5_2_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 157, .static = 16, .bound = 128 }, .{ .regs = 157, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_13_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_2_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_4_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_6_1_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_8_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_14_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_2_0_4", .usage = .{ .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_4_0_4", .usage = .{ .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_6_0_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_8_0_4", .usage = .{ .{ .regs = 254, .static = 16, .bound = 128 }, .{ .regs = 254, .static = 16, .bound = 128 }, .{ .regs = 254, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_14_0_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_16_0_4", .usage = .{ .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 125, .static = 16, .bound = 128 }, .{ .regs = 125, .static = 16, .bound = 128 } } }, - .{ .name = "exl3_linear tf_exl3_linear_2_2_8", .usage = .{ .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_4_2_8", .usage = .{ .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_8_2_8", .usage = .{ .{ .regs = 199, .static = 16, .bound = 256 }, .{ .regs = 199, .static = 16, .bound = 256 }, .{ .regs = 199, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_10_2_8", .usage = .{ .{ .regs = 178, .static = 16, .bound = 256 }, .{ .regs = 178, .static = 16, .bound = 256 }, .{ .regs = 178, .static = 16, .bound = 256 }, .{ .regs = 228, .static = 16, .bound = 256 }, .{ .regs = 228, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_12_2_8", .usage = .{ .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_14_2_8", .usage = .{ .{ .regs = 225, .static = 16, .bound = 256 }, .{ .regs = 225, .static = 16, .bound = 256 }, .{ .regs = 225, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_16_2_8", .usage = .{ .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_7_2_8", .usage = .{ .{ .regs = 179, .static = 16, .bound = 256 }, .{ .regs = 179, .static = 16, .bound = 256 }, .{ .regs = 179, .static = 16, .bound = 256 }, .{ .regs = 236, .static = 16, .bound = 256 }, .{ .regs = 236, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_9_2_8", .usage = .{ .{ .regs = 176, .static = 16, .bound = 256 }, .{ .regs = 177, .static = 16, .bound = 256 }, .{ .regs = 177, .static = 16, .bound = 256 }, .{ .regs = 224, .static = 16, .bound = 256 }, .{ .regs = 224, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_11_2_8", .usage = .{ .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_13_2_8", .usage = .{ .{ .regs = 216, .static = 16, .bound = 256 }, .{ .regs = 216, .static = 16, .bound = 256 }, .{ .regs = 216, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_2_1_8", .usage = .{ .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_4_1_8", .usage = .{ .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_8_1_8", .usage = .{ .{ .regs = 233, .static = 16, .bound = 256 }, .{ .regs = 233, .static = 16, .bound = 256 }, .{ .regs = 233, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_10_1_8", .usage = .{ .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 241, .static = 16, .bound = 256 }, .{ .regs = 241, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_12_1_8", .usage = .{ .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 240, .static = 16, .bound = 256 }, .{ .regs = 240, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_16_1_8", .usage = .{ .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_2_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_4_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_6_0_8", .usage = .{ .{ .regs = 174, .static = 16, .bound = 256 }, .{ .regs = 174, .static = 16, .bound = 256 }, .{ .regs = 174, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_8_0_8", .usage = .{ .{ .regs = 255, .static = 16, .bound = 256 }, .{ .regs = 255, .static = 16, .bound = 256 }, .{ .regs = 255, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_10_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_12_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_14_0_8", .usage = .{ .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "exl3_linear tf_exl3_linear_16_0_8", .usage = .{ .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 222, .static = 16, .bound = 256 }, .{ .regs = 222, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, - .{ .name = "experts3 decode down", .usage = .{ .{ .regs = 198, .static = 0, .bound = 128 }, .{ .regs = 199, .static = 0, .bound = 128 }, .{ .regs = 199, .static = 0, .bound = 128 }, .{ .regs = 194, .static = 0, .bound = 128 }, .{ .regs = 194, .static = 0, .bound = 128 } } }, - .{ .name = "experts3_prefill pair", .usage = .{ .{ .regs = 179, .static = 0, .bound = 256 }, .{ .regs = 179, .static = 0, .bound = 256 }, .{ .regs = 179, .static = 0, .bound = 256 }, .{ .regs = 150, .static = 0, .bound = 256 }, .{ .regs = 150, .static = 0, .bound = 256 } } }, - .{ .name = "experts3 tf_experts3_widen", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 34, .static = 0, .bound = 0 }, .{ .regs = 34, .static = 0, .bound = 0 }, .{ .regs = 36, .static = 0, .bound = 0 }, .{ .regs = 36, .static = 0, .bound = 0 } } }, - .{ .name = "exl3_experts tf_exl3_down_combine", .usage = .{ .{ .regs = 32, .static = 16384, .bound = 0 }, .{ .regs = 40, .static = 16384, .bound = 0 }, .{ .regs = 40, .static = 16384, .bound = 0 }, .{ .regs = 42, .static = 16384, .bound = 0 }, .{ .regs = 42, .static = 16384, .bound = 0 } } }, - .{ .name = "exl3_experts tf_exl3_plan_rotate", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 33, .static = 0, .bound = 0 }, .{ .regs = 33, .static = 0, .bound = 0 }, .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 32, .static = 0, .bound = 0 } } }, - .{ .name = "exl3_candidate tf_exl3_tc_1", .usage = .{ .{ .regs = 128, .static = 8196, .bound = 256 }, .{ .regs = 127, .static = 8196, .bound = 256 }, .{ .regs = 127, .static = 8196, .bound = 256 }, .{ .regs = 128, .static = 8196, .bound = 256 }, .{ .regs = 128, .static = 8196, .bound = 256 } } }, - .{ .name = "exl3_candidate tf_exl3_prompt_1", .usage = .{ .{ .regs = 80, .static = 32768, .bound = 256 }, .{ .regs = 80, .static = 32768, .bound = 256 }, .{ .regs = 80, .static = 32768, .bound = 256 }, .{ .regs = 77, .static = 32768, .bound = 256 }, .{ .regs = 77, .static = 32768, .bound = 256 } } }, - .{ .name = "exl3_candidate tf_exl3_rotate_f", .usage = .{ .{ .regs = 28, .static = 0, .bound = 32 }, .{ .regs = 28, .static = 0, .bound = 32 }, .{ .regs = 28, .static = 0, .bound = 32 }, .{ .regs = 20, .static = 0, .bound = 32 }, .{ .regs = 20, .static = 0, .bound = 32 } } }, - .{ .name = "h3 h3_attention", .usage = .{ .{ .regs = 168, .static = 0, .bound = 128 }, .{ .regs = 168, .static = 0, .bound = 128 }, .{ .regs = 168, .static = 0, .bound = 128 }, .{ .regs = 208, .static = 0, .bound = 128 }, .{ .regs = 208, .static = 0, .bound = 128 } } }, - .{ .name = "h3 h3_topk", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 40, .static = 0, .bound = 0 }, .{ .regs = 40, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 } } }, - .{ .name = "drama3 d3_gemv", .usage = .{ .{ .regs = 54, .static = 0, .bound = 256 }, .{ .regs = 54, .static = 0, .bound = 256 }, .{ .regs = 54, .static = 0, .bound = 256 }, .{ .regs = 64, .static = 0, .bound = 256 }, .{ .regs = 64, .static = 0, .bound = 256 } } }, - .{ .name = "drama3 d3_conv_silu", .usage = .{ .{ .regs = 35, .static = 0, .bound = 0 }, .{ .regs = 35, .static = 0, .bound = 0 }, .{ .regs = 35, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 } } }, - .{ .name = "drama3 d3_qk_rope", .usage = .{ .{ .regs = 28, .static = 1168, .bound = 0 }, .{ .regs = 28, .static = 1168, .bound = 0 }, .{ .regs = 28, .static = 1168, .bound = 0 }, .{ .regs = 26, .static = 1168, .bound = 0 }, .{ .regs = 26, .static = 1168, .bound = 0 } } }, - .{ .name = "drama3 d3_sample_main", .usage = .{ .{ .regs = 31, .static = 400, .bound = 1024 }, .{ .regs = 37, .static = 400, .bound = 1024 }, .{ .regs = 37, .static = 400, .bound = 1024 }, .{ .regs = 47, .static = 400, .bound = 1024 }, .{ .regs = 47, .static = 400, .bound = 1024 } } }, - .{ .name = "drama3 d3_sample_code_fast", .usage = .{ .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 } } }, - .{ .name = "drama3_codec c_vq_encode", .usage = .{ .{ .regs = 31, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 } } }, - .{ .name = "drama3_codec c_attn", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 30, .static = 0, .bound = 0 }, .{ .regs = 30, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 } } }, - .{ .name = "drama3_codec c_snake", .usage = .{ .{ .regs = 21, .static = 0, .bound = 0 }, .{ .regs = 21, .static = 0, .bound = 0 }, .{ .regs = 21, .static = 0, .bound = 0 }, .{ .regs = 26, .static = 0, .bound = 0 }, .{ .regs = 26, .static = 0, .bound = 0 } } }, - .{ .name = "drama3_fp8 decode gate-up", .usage = .{ .{ .regs = 157, .static = 0, .bound = 128 }, .{ .regs = 157, .static = 0, .bound = 128 }, .{ .regs = 157, .static = 0, .bound = 128 }, .{ .regs = 163, .static = 0, .bound = 128 }, .{ .regs = 163, .static = 0, .bound = 128 } } }, - .{ .name = "drama3_fp8 prompt gate-up", .usage = .{ .{ .regs = 199, .static = 32768, .bound = 128 }, .{ .regs = 199, .static = 32768, .bound = 128 }, .{ .regs = 199, .static = 32768, .bound = 128 }, .{ .regs = 214, .static = 32768, .bound = 128 }, .{ .regs = 214, .static = 32768, .bound = 128 } } }, - .{ .name = "latent tf_super_topk_few", .usage = .{ .{ .regs = 32, .static = 4352, .bound = 1024 }, .{ .regs = 38, .static = 4352, .bound = 1024 }, .{ .regs = 38, .static = 4352, .bound = 1024 }, .{ .regs = 32, .static = 4352, .bound = 1024 }, .{ .regs = 32, .static = 4352, .bound = 1024 } } }, - .{ .name = "ck tf_ck4_up_relu2_few", .usage = .{ .{ .regs = 19, .static = 0, .bound = 128 }, .{ .regs = 19, .static = 0, .bound = 128 }, .{ .regs = 19, .static = 0, .bound = 128 }, .{ .regs = 124, .static = 0, .bound = 128 }, .{ .regs = 124, .static = 0, .bound = 128 } } }, - .{ .name = "mamba tf_nemo_scan", .usage = .{ .{ .regs = 138, .static = 41088, .bound = 128 }, .{ .regs = 144, .static = 41088, .bound = 128 }, .{ .regs = 144, .static = 41088, .bound = 128 }, .{ .regs = 118, .static = 41088, .bound = 128 }, .{ .regs = 118, .static = 41088, .bound = 128 } } }, - } ++ joins.nvcc_132_after) }, - .{ .release = .{ .major = 13, .minor = 3 }, .usage = &([_]Override{ - .{ .name = "flashnext_batch fn_qsa_select", .usage = .{ .{ .regs = 32, .static = 1168, .bound = 1024 }, .{ .regs = 52, .static = 1168, .bound = 1024 }, .{ .regs = 52, .static = 1168, .bound = 1024 }, .{ .regs = 63, .static = 1168, .bound = 1024 }, .{ .regs = 63, .static = 1168, .bound = 1024 } } }, - } ++ joins.nvcc_133_after) }, -}; +pub const cuda_sets = @import("registry_cuda_sets.zig").cuda_sets; pub fn newer(x: limits.Nvcc, y: limits.Nvcc) bool { return x.major > y.major or (x.major == y.major and x.minor > y.minor); } @@ -579,15 +475,14 @@ pub const gradient_pending = learning.gradient_pending; pub const qwen_learning_pending = learning.qwen_learning_pending; pub const glm_pending = @import("glm_sampling_pending.zig"); pub const landed_cuda = joins.landed_cuda; -test { - _ = learning; -} pub const all_cuda = joins.all_cuda; pub const dsv41_pending = joins.dsv41_pending; test { + _ = learning; _ = @import("qwen4_cuda_receipts_test.zig"); _ = @import("moss_image_cuda_records.zig"); _ = @import("glm_kv_pending.zig"); + _ = @import("glm_launch_records.zig"); _ = @import("minimax_cuda_records.zig"); _ = @import("glm_f32w_pending.zig"); _ = @import("glm_l2pf_pending.zig"); diff --git a/zig/src/core/contract/registry_cuda_sets.zig b/zig/src/core/contract/registry_cuda_sets.zig new file mode 100644 index 00000000000..fcfc5d1ac1b --- /dev/null +++ b/zig/src/core/contract/registry_cuda_sets.zig @@ -0,0 +1,112 @@ +//! The later nvcc releases' usage records for the CUDA launches, by release (registry.zig's `cuda_sets`). +const registry = @import("registry.zig"); +const joins = @import("registry_joins.zig"); +const Override = registry.Override; +const CudaSet = registry.CudaSet; + +/// The later releases' sets, rising by release; a tree's images are checked against the newest at or below their own. +pub const cuda_sets = [_]CudaSet{ + .{ .release = .{ .major = 13, .minor = 2 }, .usage = &(@import("registry_shared_attention.zig").nvcc132(Override) ++ [_]Override{ + .{ .name = "window_pages tf_wrows_merge_512_pg", .usage = .{ .{ .regs = 56, .static = 128, .bound = 256 }, .{ .regs = 56, .static = 128, .bound = 256 }, .{ .regs = 56, .static = 128, .bound = 256 }, .{ .regs = 60, .static = 128, .bound = 256 }, .{ .regs = 60, .static = 128, .bound = 256 } } }, + .{ .name = "moe tf_moe_topk_sigmoid_score_warp", .usage = .{ .{ .regs = 219, .static = 0, .bound = 256 }, .{ .regs = 219, .static = 0, .bound = 256 }, .{ .regs = 219, .static = 0, .bound = 256 }, .{ .regs = 203, .static = 0, .bound = 256 }, .{ .regs = 203, .static = 0, .bound = 256 } } }, + .{ .name = "norms tf_rms_rows", .usage = .{ .{ .regs = 32, .static = 132, .bound = 1024 }, .{ .regs = 46, .static = 132, .bound = 1024 }, .{ .regs = 46, .static = 132, .bound = 1024 }, .{ .regs = 43, .static = 132, .bound = 1024 }, .{ .regs = 43, .static = 132, .bound = 1024 } } }, + .{ .name = "lane_gemv", .usage = .{ .{ .regs = 64, .static = 0, .bound = 128 }, .{ .regs = 58, .static = 0, .bound = 128 }, .{ .regs = 58, .static = 0, .bound = 128 }, .{ .regs = 66, .static = 0, .bound = 128 }, .{ .regs = 66, .static = 0, .bound = 128 } } }, + .{ .name = "lane_gemv split-K", .usage = .{ .{ .regs = 62, .static = 128, .bound = 128 }, .{ .regs = 56, .static = 128, .bound = 128 }, .{ .regs = 56, .static = 128, .bound = 128 }, .{ .regs = 72, .static = 128, .bound = 128 }, .{ .regs = 72, .static = 128, .bound = 128 } } }, + .{ .name = "prompt16 FP8", .usage = .{ .{ .regs = 243, .static = 0, .bound = 128 }, .{ .regs = 243, .static = 0, .bound = 128 }, .{ .regs = 243, .static = 0, .bound = 128 }, .{ .regs = 212, .static = 0, .bound = 128 }, .{ .regs = 212, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf FP4 fp32 out 32-row tile, cluster of 8", .usage = .{ .{ .regs = 64, .static = 0, .bound = 128 }, .{ .regs = 64, .static = 0, .bound = 128 }, .{ .regs = 80, .static = 0, .bound = 128 }, .{ .regs = 61, .static = 0, .bound = 128 }, .{ .regs = 61, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf MXFP8 64-row tile, fused slices", .usage = .{ .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf FP8 fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 179, .static = 0, .bound = 128 }, .{ .regs = 179, .static = 0, .bound = 128 }, .{ .regs = 179, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf MXFP8 fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 229, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 }, .{ .regs = 158, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf FP8G fp32 out 32-row tile, cluster of 8", .usage = .{ .{ .regs = 72, .static = 0, .bound = 128 }, .{ .regs = 72, .static = 0, .bound = 128 }, .{ .regs = 72, .static = 0, .bound = 128 }, .{ .regs = 57, .static = 0, .bound = 128 }, .{ .regs = 57, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf FP8G fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 196, .static = 0, .bound = 128 }, .{ .regs = 196, .static = 0, .bound = 128 }, .{ .regs = 196, .static = 0, .bound = 128 }, .{ .regs = 155, .static = 0, .bound = 128 }, .{ .regs = 155, .static = 0, .bound = 128 } } }, + .{ .name = "qmmf BF16 fp32 out 64-row tile, fused slices", .usage = .{ .{ .regs = 180, .static = 0, .bound = 128 }, .{ .regs = 180, .static = 0, .bound = 128 }, .{ .regs = 180, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 }, .{ .regs = 140, .static = 0, .bound = 128 } } }, + .{ .name = "flashnext_gdn flashnext_gdn_chain", .usage = .{ .{ .regs = 51, .static = 2060, .bound = 1024 }, .{ .regs = 56, .static = 2060, .bound = 1024 }, .{ .regs = 56, .static = 2060, .bound = 1024 }, .{ .regs = 64, .static = 2060, .bound = 1024 }, .{ .regs = 64, .static = 2060, .bound = 1024 } } }, + .{ .name = "flashnext_attn fn_attn_chunks", .usage = .{ .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 }, .{ .regs = 72, .static = 640, .bound = 128 } } }, + .{ .name = "flashnext_attn fn_attn_chunks_ahead", .usage = .{ .{ .regs = 70, .static = 768, .bound = 128 }, .{ .regs = 70, .static = 768, .bound = 128 }, .{ .regs = 70, .static = 768, .bound = 128 }, .{ .regs = 72, .static = 768, .bound = 128 }, .{ .regs = 72, .static = 768, .bound = 128 } } }, + .{ .name = "flashnext_attn fn_attn_merge", .usage = .{ .{ .regs = 26, .static = 0, .bound = 256 }, .{ .regs = 28, .static = 0, .bound = 256 }, .{ .regs = 28, .static = 0, .bound = 256 }, .{ .regs = 23, .static = 0, .bound = 256 }, .{ .regs = 23, .static = 0, .bound = 256 } } }, + .{ .name = "flashnext_batch fn_gdn_front", .usage = .{ .{ .regs = 26, .static = 1024, .bound = 256 }, .{ .regs = 26, .static = 1024, .bound = 256 }, .{ .regs = 26, .static = 1024, .bound = 256 }, .{ .regs = 30, .static = 1024, .bound = 256 }, .{ .regs = 30, .static = 1024, .bound = 256 } } }, + .{ .name = "flashnext_hc fn_hc_down", .usage = .{ .{ .regs = 56, .static = 64, .bound = 128 }, .{ .regs = 54, .static = 64, .bound = 128 }, .{ .regs = 54, .static = 64, .bound = 128 }, .{ .regs = 64, .static = 64, .bound = 128 }, .{ .regs = 64, .static = 64, .bound = 128 } } }, + .{ .name = "flashnext_hc fn_hc_normalize", .usage = .{ .{ .regs = 32, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 }, .{ .regs = 40, .static = 16, .bound = 0 } } }, + .{ .name = "flashnext_hc fn_hc_reduce_act", .usage = .{ .{ .regs = 32, .static = 4096, .bound = 1024 }, .{ .regs = 63, .static = 4096, .bound = 1024 }, .{ .regs = 63, .static = 4096, .bound = 1024 }, .{ .regs = 60, .static = 4096, .bound = 1024 }, .{ .regs = 60, .static = 4096, .bound = 1024 } } }, + .{ .name = "flashnext_hc fn_hc_upmix", .usage = .{ .{ .regs = 69, .static = 2048, .bound = 256 }, .{ .regs = 64, .static = 2048, .bound = 256 }, .{ .regs = 64, .static = 2048, .bound = 256 }, .{ .regs = 62, .static = 2048, .bound = 256 }, .{ .regs = 62, .static = 2048, .bound = 256 } } }, + .{ .name = "flashnext_hc fn_hc_writeback0", .usage = .{ .{ .regs = 30, .static = 256, .bound = 256 }, .{ .regs = 30, .static = 256, .bound = 256 }, .{ .regs = 30, .static = 256, .bound = 256 }, .{ .regs = 37, .static = 256, .bound = 256 }, .{ .regs = 37, .static = 256, .bound = 256 } } }, + .{ .name = "flashnext_hc fn_hc_writeback_moe", .usage = .{ .{ .regs = 32, .static = 256, .bound = 256 }, .{ .regs = 40, .static = 256, .bound = 256 }, .{ .regs = 40, .static = 256, .bound = 256 }, .{ .regs = 47, .static = 256, .bound = 256 }, .{ .regs = 47, .static = 256, .bound = 256 } } }, + .{ .name = "flashnext_hc fn_ple_conv", .usage = .{ .{ .regs = 23, .static = 0, .bound = 512 }, .{ .regs = 35, .static = 0, .bound = 512 }, .{ .regs = 35, .static = 0, .bound = 512 }, .{ .regs = 36, .static = 0, .bound = 512 }, .{ .regs = 36, .static = 0, .bound = 512 } } }, + .{ .name = "flashnext_hc fn_ple_gate", .usage = .{ .{ .regs = 32, .static = 128, .bound = 512 }, .{ .regs = 34, .static = 128, .bound = 512 }, .{ .regs = 34, .static = 128, .bound = 512 }, .{ .regs = 33, .static = 128, .bound = 512 }, .{ .regs = 33, .static = 128, .bound = 512 } } }, + .{ .name = "flashnext_attn fn_qsa_pool", .usage = .{ .{ .regs = 32, .static = 1152, .bound = 128 }, .{ .regs = 40, .static = 1152, .bound = 128 }, .{ .regs = 40, .static = 1152, .bound = 128 }, .{ .regs = 39, .static = 1152, .bound = 128 }, .{ .regs = 39, .static = 1152, .bound = 128 } } }, + .{ .name = "flashnext_batch fn_qsa_select", .usage = .{ .{ .regs = 32, .static = 1168, .bound = 1024 }, .{ .regs = 50, .static = 1168, .bound = 1024 }, .{ .regs = 50, .static = 1168, .bound = 1024 }, .{ .regs = 42, .static = 1168, .bound = 1024 }, .{ .regs = 42, .static = 1168, .bound = 1024 } } }, + .{ .name = "route_rows tf_route_logits", .usage = .{ .{ .regs = 32, .static = 0, .bound = 128 }, .{ .regs = 39, .static = 0, .bound = 128 }, .{ .regs = 39, .static = 0, .bound = 128 }, .{ .regs = 35, .static = 0, .bound = 128 }, .{ .regs = 35, .static = 0, .bound = 128 } } }, + .{ .name = "route_rows tf_route_logits_few", .usage = .{ .{ .regs = 31, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 }, .{ .regs = 34, .static = 0, .bound = 128 }, .{ .regs = 34, .static = 0, .bound = 128 } } }, + .{ .name = "qwen_vision tf_qv_qkv_rope", .usage = .{ .{ .regs = 32, .static = 0, .bound = 128 }, .{ .regs = 37, .static = 0, .bound = 128 }, .{ .regs = 37, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 }, .{ .regs = 40, .static = 0, .bound = 128 } } }, + .{ .name = "qwen_vision tf_qv_attention64", .usage = .{ .{ .regs = 164, .static = 32768, .bound = 64 }, .{ .regs = 164, .static = 32768, .bound = 64 }, .{ .regs = 164, .static = 32768, .bound = 64 }, .{ .regs = 162, .static = 32768, .bound = 64 }, .{ .regs = 162, .static = 32768, .bound = 64 } } }, + .{ .name = "exl3_linear tf_exl3_linear_2_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_4_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 }, .{ .regs = 154, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_6_2_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 159, .static = 16, .bound = 128 }, .{ .regs = 159, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_8_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_3_2_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_5_2_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 157, .static = 16, .bound = 128 }, .{ .regs = 157, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_13_2_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_2_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_4_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 }, .{ .regs = 158, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_6_1_4", .usage = .{ .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 164, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_8_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_14_1_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_2_0_4", .usage = .{ .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_4_0_4", .usage = .{ .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 255, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_6_0_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 }, .{ .regs = 160, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_8_0_4", .usage = .{ .{ .regs = 254, .static = 16, .bound = 128 }, .{ .regs = 254, .static = 16, .bound = 128 }, .{ .regs = 254, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 }, .{ .regs = 162, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_14_0_4", .usage = .{ .{ .regs = 168, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 167, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 128, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_16_0_4", .usage = .{ .{ .regs = 128, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 156, .static = 16, .bound = 128 }, .{ .regs = 125, .static = 16, .bound = 128 }, .{ .regs = 125, .static = 16, .bound = 128 } } }, + .{ .name = "exl3_linear tf_exl3_linear_2_2_8", .usage = .{ .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_4_2_8", .usage = .{ .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 192, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_8_2_8", .usage = .{ .{ .regs = 199, .static = 16, .bound = 256 }, .{ .regs = 199, .static = 16, .bound = 256 }, .{ .regs = 199, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_10_2_8", .usage = .{ .{ .regs = 178, .static = 16, .bound = 256 }, .{ .regs = 178, .static = 16, .bound = 256 }, .{ .regs = 178, .static = 16, .bound = 256 }, .{ .regs = 228, .static = 16, .bound = 256 }, .{ .regs = 228, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_12_2_8", .usage = .{ .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_14_2_8", .usage = .{ .{ .regs = 225, .static = 16, .bound = 256 }, .{ .regs = 225, .static = 16, .bound = 256 }, .{ .regs = 225, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_16_2_8", .usage = .{ .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_7_2_8", .usage = .{ .{ .regs = 179, .static = 16, .bound = 256 }, .{ .regs = 179, .static = 16, .bound = 256 }, .{ .regs = 179, .static = 16, .bound = 256 }, .{ .regs = 236, .static = 16, .bound = 256 }, .{ .regs = 236, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_9_2_8", .usage = .{ .{ .regs = 176, .static = 16, .bound = 256 }, .{ .regs = 177, .static = 16, .bound = 256 }, .{ .regs = 177, .static = 16, .bound = 256 }, .{ .regs = 224, .static = 16, .bound = 256 }, .{ .regs = 224, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_11_2_8", .usage = .{ .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 181, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 }, .{ .regs = 226, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_13_2_8", .usage = .{ .{ .regs = 216, .static = 16, .bound = 256 }, .{ .regs = 216, .static = 16, .bound = 256 }, .{ .regs = 216, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_2_1_8", .usage = .{ .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_4_1_8", .usage = .{ .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_8_1_8", .usage = .{ .{ .regs = 233, .static = 16, .bound = 256 }, .{ .regs = 233, .static = 16, .bound = 256 }, .{ .regs = 233, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_10_1_8", .usage = .{ .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 241, .static = 16, .bound = 256 }, .{ .regs = 241, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_12_1_8", .usage = .{ .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 214, .static = 16, .bound = 256 }, .{ .regs = 240, .static = 16, .bound = 256 }, .{ .regs = 240, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_16_1_8", .usage = .{ .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_2_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_4_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_6_0_8", .usage = .{ .{ .regs = 174, .static = 16, .bound = 256 }, .{ .regs = 174, .static = 16, .bound = 256 }, .{ .regs = 174, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_8_0_8", .usage = .{ .{ .regs = 255, .static = 16, .bound = 256 }, .{ .regs = 255, .static = 16, .bound = 256 }, .{ .regs = 255, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_10_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_12_0_8", .usage = .{ .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 254, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_14_0_8", .usage = .{ .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 231, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "exl3_linear tf_exl3_linear_16_0_8", .usage = .{ .{ .regs = 220, .static = 16, .bound = 256 }, .{ .regs = 222, .static = 16, .bound = 256 }, .{ .regs = 222, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 }, .{ .regs = 128, .static = 16, .bound = 256 } } }, + .{ .name = "experts3 decode down", .usage = .{ .{ .regs = 198, .static = 0, .bound = 128 }, .{ .regs = 199, .static = 0, .bound = 128 }, .{ .regs = 199, .static = 0, .bound = 128 }, .{ .regs = 194, .static = 0, .bound = 128 }, .{ .regs = 194, .static = 0, .bound = 128 } } }, + .{ .name = "experts3_prefill pair", .usage = .{ .{ .regs = 179, .static = 0, .bound = 256 }, .{ .regs = 179, .static = 0, .bound = 256 }, .{ .regs = 179, .static = 0, .bound = 256 }, .{ .regs = 150, .static = 0, .bound = 256 }, .{ .regs = 150, .static = 0, .bound = 256 } } }, + .{ .name = "experts3 tf_experts3_widen", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 34, .static = 0, .bound = 0 }, .{ .regs = 34, .static = 0, .bound = 0 }, .{ .regs = 36, .static = 0, .bound = 0 }, .{ .regs = 36, .static = 0, .bound = 0 } } }, + .{ .name = "exl3_experts tf_exl3_down_combine", .usage = .{ .{ .regs = 32, .static = 16384, .bound = 0 }, .{ .regs = 40, .static = 16384, .bound = 0 }, .{ .regs = 40, .static = 16384, .bound = 0 }, .{ .regs = 42, .static = 16384, .bound = 0 }, .{ .regs = 42, .static = 16384, .bound = 0 } } }, + .{ .name = "exl3_experts tf_exl3_plan_rotate", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 33, .static = 0, .bound = 0 }, .{ .regs = 33, .static = 0, .bound = 0 }, .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 32, .static = 0, .bound = 0 } } }, + .{ .name = "exl3_candidate tf_exl3_tc_1", .usage = .{ .{ .regs = 128, .static = 8196, .bound = 256 }, .{ .regs = 127, .static = 8196, .bound = 256 }, .{ .regs = 127, .static = 8196, .bound = 256 }, .{ .regs = 128, .static = 8196, .bound = 256 }, .{ .regs = 128, .static = 8196, .bound = 256 } } }, + .{ .name = "exl3_candidate tf_exl3_prompt_1", .usage = .{ .{ .regs = 80, .static = 32768, .bound = 256 }, .{ .regs = 80, .static = 32768, .bound = 256 }, .{ .regs = 80, .static = 32768, .bound = 256 }, .{ .regs = 77, .static = 32768, .bound = 256 }, .{ .regs = 77, .static = 32768, .bound = 256 } } }, + .{ .name = "exl3_candidate tf_exl3_rotate_f", .usage = .{ .{ .regs = 28, .static = 0, .bound = 32 }, .{ .regs = 28, .static = 0, .bound = 32 }, .{ .regs = 28, .static = 0, .bound = 32 }, .{ .regs = 20, .static = 0, .bound = 32 }, .{ .regs = 20, .static = 0, .bound = 32 } } }, + .{ .name = "h3 h3_attention", .usage = .{ .{ .regs = 168, .static = 0, .bound = 128 }, .{ .regs = 168, .static = 0, .bound = 128 }, .{ .regs = 168, .static = 0, .bound = 128 }, .{ .regs = 208, .static = 0, .bound = 128 }, .{ .regs = 208, .static = 0, .bound = 128 } } }, + .{ .name = "h3 h3_topk", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 40, .static = 0, .bound = 0 }, .{ .regs = 40, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 } } }, + .{ .name = "drama3 d3_gemv", .usage = .{ .{ .regs = 54, .static = 0, .bound = 256 }, .{ .regs = 54, .static = 0, .bound = 256 }, .{ .regs = 54, .static = 0, .bound = 256 }, .{ .regs = 64, .static = 0, .bound = 256 }, .{ .regs = 64, .static = 0, .bound = 256 } } }, + .{ .name = "drama3 d3_conv_silu", .usage = .{ .{ .regs = 35, .static = 0, .bound = 0 }, .{ .regs = 35, .static = 0, .bound = 0 }, .{ .regs = 35, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 } } }, + .{ .name = "drama3 d3_qk_rope", .usage = .{ .{ .regs = 28, .static = 1168, .bound = 0 }, .{ .regs = 28, .static = 1168, .bound = 0 }, .{ .regs = 28, .static = 1168, .bound = 0 }, .{ .regs = 26, .static = 1168, .bound = 0 }, .{ .regs = 26, .static = 1168, .bound = 0 } } }, + .{ .name = "drama3 d3_sample_main", .usage = .{ .{ .regs = 31, .static = 400, .bound = 1024 }, .{ .regs = 37, .static = 400, .bound = 1024 }, .{ .regs = 37, .static = 400, .bound = 1024 }, .{ .regs = 47, .static = 400, .bound = 1024 }, .{ .regs = 47, .static = 400, .bound = 1024 } } }, + .{ .name = "drama3 d3_sample_code_fast", .usage = .{ .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 }, .{ .regs = 25, .static = 3616, .bound = 1024 } } }, + .{ .name = "drama3_codec c_vq_encode", .usage = .{ .{ .regs = 31, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 }, .{ .regs = 39, .static = 424, .bound = 0 } } }, + .{ .name = "drama3_codec c_attn", .usage = .{ .{ .regs = 32, .static = 0, .bound = 0 }, .{ .regs = 30, .static = 0, .bound = 0 }, .{ .regs = 30, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 }, .{ .regs = 38, .static = 0, .bound = 0 } } }, + .{ .name = "drama3_codec c_snake", .usage = .{ .{ .regs = 21, .static = 0, .bound = 0 }, .{ .regs = 21, .static = 0, .bound = 0 }, .{ .regs = 21, .static = 0, .bound = 0 }, .{ .regs = 26, .static = 0, .bound = 0 }, .{ .regs = 26, .static = 0, .bound = 0 } } }, + .{ .name = "drama3_fp8 decode gate-up", .usage = .{ .{ .regs = 157, .static = 0, .bound = 128 }, .{ .regs = 157, .static = 0, .bound = 128 }, .{ .regs = 157, .static = 0, .bound = 128 }, .{ .regs = 163, .static = 0, .bound = 128 }, .{ .regs = 163, .static = 0, .bound = 128 } } }, + .{ .name = "drama3_fp8 prompt gate-up", .usage = .{ .{ .regs = 199, .static = 32768, .bound = 128 }, .{ .regs = 199, .static = 32768, .bound = 128 }, .{ .regs = 199, .static = 32768, .bound = 128 }, .{ .regs = 214, .static = 32768, .bound = 128 }, .{ .regs = 214, .static = 32768, .bound = 128 } } }, + .{ .name = "latent tf_super_topk_few", .usage = .{ .{ .regs = 32, .static = 4352, .bound = 1024 }, .{ .regs = 38, .static = 4352, .bound = 1024 }, .{ .regs = 38, .static = 4352, .bound = 1024 }, .{ .regs = 32, .static = 4352, .bound = 1024 }, .{ .regs = 32, .static = 4352, .bound = 1024 } } }, + .{ .name = "ck tf_ck4_up_relu2_few", .usage = .{ .{ .regs = 19, .static = 0, .bound = 128 }, .{ .regs = 19, .static = 0, .bound = 128 }, .{ .regs = 19, .static = 0, .bound = 128 }, .{ .regs = 124, .static = 0, .bound = 128 }, .{ .regs = 124, .static = 0, .bound = 128 } } }, + .{ .name = "mamba tf_nemo_scan", .usage = .{ .{ .regs = 138, .static = 41088, .bound = 128 }, .{ .regs = 144, .static = 41088, .bound = 128 }, .{ .regs = 144, .static = 41088, .bound = 128 }, .{ .regs = 118, .static = 41088, .bound = 128 }, .{ .regs = 118, .static = 41088, .bound = 128 } } }, + } ++ joins.nvcc_132_after) }, + .{ .release = .{ .major = 13, .minor = 3 }, .usage = &([_]Override{ + .{ .name = "flashnext_batch fn_qsa_select", .usage = .{ .{ .regs = 32, .static = 1168, .bound = 1024 }, .{ .regs = 52, .static = 1168, .bound = 1024 }, .{ .regs = 52, .static = 1168, .bound = 1024 }, .{ .regs = 63, .static = 1168, .bound = 1024 }, .{ .regs = 63, .static = 1168, .bound = 1024 } } }, + } ++ joins.nvcc_133_after) }, +}; diff --git a/zig/src/core/contract/registry_joins.zig b/zig/src/core/contract/registry_joins.zig index 028217dff1f..603150b8e42 100644 --- a/zig/src/core/contract/registry_joins.zig +++ b/zig/src/core/contract/registry_joins.zig @@ -19,6 +19,7 @@ pub const cuda_after = @import("registry_media.zig").cuda ++ @import("minimax_cuda_records.zig").cuda ++ @import("moss_image_cuda_records.zig").cuda ++ @import("nemo_audio_cuda_records.zig").cuda ++ + @import("idol_cuda_sets.zig").cuda ++ @import("exl3_dense_records.zig").cuda ++ @import("exl3_finish_records.zig").cuda ++ @import("lfm2_moe_cuda_records.zig").cuda ++ @@ -64,6 +65,7 @@ pub const all_metal = @import("lane_q8_records.zig").records ++ @import("simd_half_records.zig").records ++ @import("metal_pair_records.zig").records ++ @import("glm_rows_records.zig").records ++ + @import("glm_launch_records.zig").records ++ @import("row_wide_records.zig").records ++ @import("weight_only_records.zig").metal ++ @import("grouped_records.zig").metal ++ @@ -81,9 +83,11 @@ pub const all_metal = @import("lane_q8_records.zig").records ++ @import("gemma_attention_records.zig").records ++ @import("moss_image_records.zig").records ++ @import("h3_image_records.zig").records ++ + @import("idol_records.zig").records ++ @import("dsv41_metal_records.zig").records ++ @import("minimax_records.zig").records ++ @import("ling_route_records.zig").records ++ + @import("ling_mla_records.zig").records ++ @import("qwen27_moe_records.zig").records ++ @import("affine_gather_records.zig").records ++ @import("flint_records.zig").records ++ diff --git a/zig/src/core/engine_api.zig b/zig/src/core/engine_api.zig index 8ef306dcead..53d8085ac71 100644 --- a/zig/src/core/engine_api.zig +++ b/zig/src/core/engine_api.zig @@ -125,6 +125,7 @@ pub const SpeechRequest = @import("speech_api.zig").SpeechRequest; pub const SpeechResult = @import("speech_api.zig").SpeechResult; pub const SpeechInfo = @import("speech_api.zig").SpeechInfo; pub const SpeechSubmitError = error{ Closed, Busy, InvalidRequest, Unsupported }; +pub const EncodeVoiceError = error{ BadWav, Closed, Failed, OutOfMemory }; pub const ImageRequest = @import("image_api.zig").ImageRequest; pub const ImageResult = @import("image_api.zig").ImageResult; pub const ImageInfo = @import("image_api.zig").ImageInfo; @@ -446,6 +447,8 @@ pub const Engine = struct { load: ?*const fn (ctx: *anyopaque, producer: ?load_ledger.Producer) void = null, /// Asked once per whole request: the returned message is the refusal, up to `refusal_bytes`; null: accepted. refusal: ?*const fn (ctx: *anyopaque, request: *const Request, out: []u8) ?[]const u8 = null, + /// A reference WAV file's codec rows in `gpa`, on the speech engine's own thread; null: it encodes no voices. + encode_voice: ?*const fn (ctx: *anyopaque, gpa: Allocator, wav: []const u8) EncodeVoiceError![][10]i32 = null, }; pub fn info(e: Engine) Info { @@ -563,7 +566,6 @@ pub const LaneHost = @import("lane_host.zig").LaneHost; pub const prefill_env = @import("lane_host_env.zig"); /// An opt-in family round planner for the lane host, in place of its `prefill_step` chunks (lane_rounds.zig). pub const Rounds = @import("lane_host.zig").Rounds; - /// Exact prompt reuse between requests, for any family (prompt_cache.zig). pub const prompt_cache = @import("prompt_cache.zig"); /// The same for a paged cache over the backend's own KV pages (prompt_radix.zig). @@ -574,7 +576,6 @@ pub const cache_modes = @import("cache_modes.zig"); /// Learned prompt-cache states on disk (prompt_imprint.zig), and when a shared cut goes there (prompt_learn.zig). pub const prompt_imprint = @import("prompt_imprint.zig"); pub const prompt_learn = @import("prompt_learn.zig"); - /// A question about a conversation's kept states, in RAM and on disk (rows_ask.zig). pub const ImprintAsk = @import("rows_ask.zig").Ask; pub const ImprintOp = @import("rows_ask.zig").Op; @@ -582,7 +583,6 @@ pub const ImprintDisk = @import("rows_ask.zig").Disk; /// Recall's record of the ids earlier requests read and wrote, for drafts (not the prompt cache's learned states). pub const recall_store = lanes.recall_store; - /// The idle keepalive's ticker and target contract. pub const keepalive = @import("keepalive.zig"); diff --git a/zig/src/core/fixtures/gptq_synth/config.json b/zig/src/core/fixtures/gptq_synth/config.json new file mode 100644 index 00000000000..d5d067ace73 --- /dev/null +++ b/zig/src/core/fixtures/gptq_synth/config.json @@ -0,0 +1,28 @@ +{ + "architectures": ["Qwen3_5ForConditionalGeneration"], + "model_type": "qwen3_5", + "num_experts": 512, + "num_experts_per_tok": 5, + "shared_expert_intermediate_size": 1280, + "quantization_config": { + "quant_method": "gptq", + "bits": 4, + "group_size": 128, + "sym": true, + "desc_act": false, + "lm_head": true, + "dynamic": { + "+:.*lm_head$": {"bits": 4}, + "-:.*linear_attn.*": {"bits": 4}, + "-:.*self_attn.*": {"bits": 4}, + "-:.*hyper_connection.*": {"bits": 4}, + "-:.*visual.*": {"bits": 4}, + "-:.*shared_expert.*": {"bits": 4}, + "-:.*\\.ple\\..*": {"bits": 4}, + "-:.*embed.*": {"bits": 4}, + "-:.*fc_hidden.*": {"bits": 4}, + "-:.*layers\\.48\\..*": {"bits": 4}, + "-:.*\\.gate$": {"bits": 4} + } + } +} diff --git a/zig/src/core/hc.zig b/zig/src/core/hc.zig index ee7fef99606..c3566c03629 100644 --- a/zig/src/core/hc.zig +++ b/zig/src/core/hc.zig @@ -3,8 +3,8 @@ const std = @import("std"); const mtl = @import("metal"); const ks = @import("kernel_sources"); -/// The boundary's shape: stream width (4 streams, a multiple of 1024), Sinkhorn iterations, the split's eps in 1e-9. -pub const Shape = struct { width: u32, sinkhorn: u32, eps_e9: u32 }; +/// The boundary's shape: width (4 streams, 1024s), Sinkhorn iterations, split eps in 1e-9, the MoE's picks. +pub const Shape = struct { width: u32, sinkhorn: u32, eps_e9: u32, topk: u32 = 8 }; /// The partial sums a row: 24 mixes and the squares, for each 1024-column slice of the 4 streams. pub fn partBytes(s: Shape) usize { @@ -13,10 +13,14 @@ pub fn partBytes(s: Shape) usize { pub fn source(a: std.mem.Allocator, s: Shape) ![]u8 { if (s.width % 1024 != 0) return error.UnsupportedHcShape; - return std.fmt.allocPrint(a, "#define TF_D {d}\n#define TF_ITERS {d}\n#define TF_HC_EPS_INT {d}\n{s}", .{ s.width, s.sinkhorn, s.eps_e9, ks.core_hc_boundary }); + return std.fmt.allocPrint(a, "#define TF_D {d}\n#define TF_ITERS {d}\n#define TF_HC_EPS_INT {d}\n#define TF_HC_TOPK {d}\n{s}", .{ s.width, s.sinkhorn, s.eps_e9, s.topk, ks.core_hc_boundary }); } -pub const names = [4][:0]const u8{ "tf_hc_expand_mix", "tf_hc_first_mix", "tf_hc_split", "tf_hc_expand_inplace" }; +pub const names = [8][:0]const u8{ "tf_hc_expand_mix", "tf_hc_first_mix", "tf_hc_split", "tf_hc_expand_inplace", "tf_hc_expand_mix_parts", "tf_hc_first_mix_parts", "tf_hc_expand_mix_moe", "tf_hc_expand_mix_parts_moe" }; +pub const Pipes = [names.len]mtl.Pipeline; + +/// Windows of up to 4 rows: the expand's parts on six groups a slice (same sums; M5 Ultra 1.1-1.35 us a boundary less). +pub const parts_rows = 4; fn bind(e: mtl.ComputeEncoder, i: usize, r: anytype) void { e.setBuffer(r.buf, r.off, i); @@ -27,13 +31,28 @@ pub fn inPlace(x_old: anytype, x_new: anytype) bool { return x_old.buf.id == x_new.buf.id and x_old.off == x_new.off; } -/// `x_old` expanded to `x_new` (one buffer: in place then a first boundary read, same sums), mix sums to `part`, split. -pub fn boundary(e: mtl.ComputeEncoder, pipes: [4]mtl.Pipeline, s: Shape, expand: bool, rows: u32, eps: f32, b: anytype) void { +/// `x_old` expanded to `x_new`, mix sums to `part`, split; with `b.wts`, the expand combines a MoE's rows `branch`. +pub fn boundary(e: mtl.ComputeEncoder, pipes: Pipes, s: Shape, expand: bool, rows: u32, eps: f32, b: anytype) void { + boundaryWith(e, pipes, s, expand, rows, eps, b, rows <= @as(u32, if (moeWts(b) != null) moe_parts_rows else parts_rows)); +} + +/// Windows of up to 2 rows take the combining expand on six groups a slice (its reads a group grow with the combine). +pub const moe_parts_rows = 2; + +fn moeWts(b: anytype) ?@TypeOf(b.x_old) { + return if (comptime @hasField(@TypeOf(b), "wts")) b.wts else null; +} + +/// `boundary` with the expand's parts on six threadgroups a slice or on one (the same bits either way). +pub fn boundaryWith(e: mtl.ComputeEncoder, pipes: Pipes, s: Shape, expand: bool, rows: u32, eps: f32, b: anytype, parts: bool) void { const one = expand and inPlace(b.x_old, b.x_new); + const wts = moeWts(b); + std.debug.assert(wts == null or (expand and !one)); if (one) expandInPlace(e, pipes, s, rows, b.x_old, b.branch, b.post, b.comb); - e.setPipeline(pipes[if (expand and !one) 0 else 1]); + e.setPipeline(pipes[if (wts != null) @as(usize, if (parts) 7 else 6) else @as(usize, if (expand and !one) 0 else 1) + @as(usize, if (parts) 4 else 0)]); inline for (.{ b.x_old, b.branch, b.post, b.comb, b.fn_packed, b.x_new, b.part }, 0..) |r, i| bind(e, i, r); - e.dispatchGroups(mtl.Size.of(4 * s.width / 1024, rows, 1), mtl.Size.of(256, 1, 1)); + if (wts) |w| bind(e, 7, w); + e.dispatchGroups(mtl.Size.of(4 * s.width / 1024, rows, if (parts) 6 else 1), mtl.Size.of(256, 1, 1)); e.setPipeline(pipes[2]); inline for (.{ if (expand) b.x_new else b.x_old, b.part }, 0..) |r, i| bind(e, i, r); bind(e, 2, b.scale); @@ -41,11 +60,14 @@ pub fn boundary(e: mtl.ComputeEncoder, pipes: [4]mtl.Pipeline, s: Shape, expand: bind(e, 4, b.norm); e.setValue(eps, 5); inline for (.{ b.normed, b.post, b.comb }, 6..) |r, i| bind(e, i, r); - e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(1024, 1, 1)); + e.dispatchGroups(mtl.Size.of(rows, split_groups, 1), mtl.Size.of(1024, 1, 1)); } +/// The split's threadgroups a row: the collapse and norm, and post with the Sinkhorn comb beside it (the same bits). +pub const split_groups = 2; + /// A pending `branch` into the streams `x` in place (width / 4 threads a row, so width <= 4096). -pub fn expandInPlace(e: mtl.ComputeEncoder, pipes: [4]mtl.Pipeline, s: Shape, rows: u32, x: anytype, branch: anytype, post: anytype, comb: anytype) void { +pub fn expandInPlace(e: mtl.ComputeEncoder, pipes: Pipes, s: Shape, rows: u32, x: anytype, branch: anytype, post: anytype, comb: anytype) void { std.debug.assert(s.width <= 4096); e.setPipeline(pipes[3]); inline for (.{ x, branch, post, comb }, 0..) |r, i| bind(e, i, r); @@ -56,7 +78,7 @@ test "the boundary's shape is checked" { var arena = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena.deinit(); const src = try source(arena.allocator(), .{ .width = 4096, .sinkhorn = 20, .eps_e9 = 1000 }); - try std.testing.expect(std.mem.startsWith(u8, src, "#define TF_D 4096\n#define TF_ITERS 20\n#define TF_HC_EPS_INT 1000\n")); + try std.testing.expect(std.mem.startsWith(u8, src, "#define TF_D 4096\n#define TF_ITERS 20\n#define TF_HC_EPS_INT 1000\n#define TF_HC_TOPK 8\n")); try std.testing.expectError(error.UnsupportedHcShape, source(arena.allocator(), .{ .width = 4000, .sinkhorn = 20, .eps_e9 = 1000 })); try std.testing.expectEqual(@as(usize, 1600), partBytes(.{ .width = 4096, .sinkhorn = 20, .eps_e9 = 1000 })); } diff --git a/zig/src/core/modelopt.zig b/zig/src/core/modelopt.zig index a0269f164d0..8a3951df906 100644 --- a/zig/src/core/modelopt.zig +++ b/zig/src/core/modelopt.zig @@ -198,17 +198,17 @@ fn block(root: std.json.Value) ?std.json.ObjectMap { return null; } -fn object(v: ?std.json.Value) ?std.json.ObjectMap { +pub fn object(v: ?std.json.Value) ?std.json.ObjectMap { const x = v orelse return null; return if (x == .object) x.object else null; } -fn text(v: ?std.json.Value) ?[]const u8 { +pub fn text(v: ?std.json.Value) ?[]const u8 { const x = v orelse return null; return if (x == .string) x.string else null; } -fn int(v: ?std.json.Value) ?i64 { +pub fn int(v: ?std.json.Value) ?i64 { const x = v orelse return null; return if (x == .integer) x.integer else null; } diff --git a/zig/src/core/picture/jpeg.zig b/zig/src/core/picture/jpeg.zig index d4771030605..f277f37c153 100644 --- a/zig/src/core/picture/jpeg.zig +++ b/zig/src/core/picture/jpeg.zig @@ -61,7 +61,7 @@ fn load(io: std.Io, a: Allocator) error{ NoJpegLibrary, JpegLibraryVersion }!Fns } fn find(io: std.Io, a: Allocator) Loaded { - if (platform.c.getenv(env)) |named| return open(io, a, std.mem.span(named)) orelse .missing; + if ((platform.environment.Process{}).get(env)) |named| return open(io, a, named) orelse .missing; var seen_wrong = false; if (std.process.executableDirPathAlloc(io, a)) |exe| { defer a.free(exe); diff --git a/zig/src/core/picture/webp.zig b/zig/src/core/picture/webp.zig index 5073e5ed667..059f87c8325 100644 --- a/zig/src/core/picture/webp.zig +++ b/zig/src/core/picture/webp.zig @@ -42,7 +42,7 @@ fn load(io: std.Io, a: Allocator) error{ NoWebpLibrary, WebpLibraryVersion }!Fns } fn find(io: std.Io, a: Allocator) Loaded { - if (std.c.getenv(env)) |named| return open(std.mem.span(named)) orelse .missing; + if ((@import("sys").environment.Process{}).get(env)) |named| return open(named) orelse .missing; var seen_wrong = false; if (std.process.executableDirPathAlloc(io, a)) |exe| { defer a.free(exe); diff --git a/zig/src/core/quant/gptq.zig b/zig/src/core/quant/gptq.zig new file mode 100644 index 00000000000..6529b6f0cbd --- /dev/null +++ b/zig/src/core/quant/gptq.zig @@ -0,0 +1,349 @@ +//! AutoGPTQ v1 weights (4-bit symmetric groups of 128, no act order): the rules, the stored tensors, an fp64 reference. +const std = @import("std"); +const ckpt = @import("../checkpoint.zig"); +const modelopt = @import("../modelopt.zig"); +const Why = modelopt.Why; +const object = modelopt.object; +const text = modelopt.text; +const int = modelopt.int; + +const Allocator = std.mem.Allocator; +const Checkpoint = ckpt.Checkpoint; +const Tensor = ckpt.Tensor; + +/// The width and the group a config declares: anything else is refused by its field. +pub const bits = 4; +pub const group = 128; +/// The zero point of symmetric weights as qzeros stores it: 8 - 1, so a code reads as (nibble - 8). +pub const zero_nibble = 7; + +/// What a `dynamic` rule does to the module its pattern matches. +pub const Kind = enum { quantize, skip }; + +/// One `dynamic` rule: the pattern after its `+:` or `-:`, which Python's re.match anchors at the start. +pub const Rule = struct { pattern: []const u8, kind: Kind }; + +/// A GPTQ quantization_config after admission, prepared to say which modules it stores quantized. +pub const Config = struct { + arena: std.heap.ArenaAllocator, + rules: []const Rule = &.{}, + + /// The modules it quantizes: the last rule matching `module` decides, `default` where no rule does. + pub fn quantizedDefault(self: *const Config, module: []const u8, default: bool) bool { + var q = default; + for (self.rules) |r| { + if (regexMatch(r.pattern, module)) q = r.kind == .quantize; + } + return q; + } + + /// The modules it quantizes, a module no rule names included. + pub fn quantized(self: *const Config, module: []const u8) bool { + return self.quantizedDefault(module, true); + } + + pub fn deinit(self: *Config) void { + self.arena.deinit(); + } +}; + +/// The GPTQ block of `config_json` admitted, else null when no `quantization_config` declares `quant_method` gptq. +pub fn admit(gpa: Allocator, config_json: []const u8, why: *Why) !?Config { + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const parsed = try std.json.parseFromSliceLeaky(std.json.Value, arena.allocator(), config_json, .{}); + if (parsed != .object) return null; + return config(gpa, parsed.object, why); +} + +/// `admit` over an already parsed config.json: the file's top-level object, whose text tower is read too. +pub fn config(gpa: Allocator, root: std.json.ObjectMap, why: *Why) !?Config { + for ([_]?std.json.ObjectMap{ root, object(root.get("text_config")) }) |source| { + const q = object((source orelse continue).get("quantization_config")) orelse continue; + const method = text(q.get("quant_method")) orelse continue; + if (!std.ascii.eqlIgnoreCase(method, "gptq")) continue; + return try dialect(gpa, q, why); + } + return null; +} + +/// The fields and the rules this reader reads; a value outside them is refused by its field or rule name. +fn dialect(gpa: Allocator, q: std.json.ObjectMap, why: *Why) !Config { + const width = int(q.get("bits")); + if (width != bits) { + why.set("quantization_config.bits: {?d}, expected 4", .{width}); + return error.UnsupportedQuantization; + } + const size = int(q.get("group_size")); + if (size != group) { + why.set("quantization_config.group_size: {?d}, expected 128", .{size}); + return error.UnsupportedQuantization; + } + if (!holds(q.get("sym"), true)) { + why.set("quantization_config.sym: {?}, expected true", .{flag(q.get("sym"))}); + return error.UnsupportedQuantization; + } + if (q.get("desc_act")) |v| switch (v) { + .bool => |act| if (act) { + why.set("quantization_config.desc_act: true, this reader reads no act order", .{}); + return error.UnsupportedQuantization; + }, + else => { + why.set("quantization_config.desc_act: {s}, expected a bool", .{kindOf(v)}); + return error.UnsupportedQuantization; + }, + }; + if (q.get("checkpoint_format")) |v| { + const format = text(v) orelse { + why.set("quantization_config.checkpoint_format: {s}, expected gptq", .{kindOf(v)}); + return error.UnsupportedQuantization; + }; + if (!std.mem.eql(u8, format, "gptq")) { + why.set("quantization_config.checkpoint_format: {s}, expected gptq", .{format}); + return error.UnsupportedQuantization; + } + } + const dyn = object(q.get("dynamic")) orelse { + const found = if (q.get("dynamic") == null) "absent" else "not an object"; + why.set("quantization_config.dynamic: {s}, this reader reads its rules", .{found}); + return error.UnsupportedQuantization; + }; + var c: Config = .{ .arena = .init(gpa) }; + errdefer c.deinit(); + const a = c.arena.allocator(); + const rules = try a.alloc(Rule, dyn.count()); + var it = dyn.iterator(); + var i: usize = 0; + while (it.next()) |kv| : (i += 1) { + const key = kv.key_ptr.*; + const kind: Kind = if (std.mem.startsWith(u8, key, "+:")) .quantize else if (std.mem.startsWith(u8, key, "-:")) .skip else { + why.set("quantization_config.dynamic {s}: no +: or -: prefix", .{key}); + return error.UnsupportedQuantization; + }; + if (!supported(key[2..])) { + why.set("quantization_config.dynamic {s}: outside this reader's matcher", .{key}); + return error.UnsupportedQuantization; + } + try ruleMath(kv.value_ptr.*, key, why); + rules[i] = .{ .pattern = try a.dupe(u8, key[2..]), .kind = kind }; + } + c.rules = rules; + if (!c.quantizedDefault("lm_head", holds(q.get("lm_head"), true))) { + why.set("quantization_config.lm_head: {?}, the rules do not store the head int4", .{flag(q.get("lm_head"))}); + return error.UnsupportedQuantization; + } + return c; +} + +/// A rule's own value: a width or a group other than the admitted one is mixed precision this reader does not read. +fn ruleMath(v: std.json.Value, key: []const u8, why: *Why) !void { + if (v == .null) return; + const o = object(v) orelse { + why.set("quantization_config.dynamic {s}: not an object of bits", .{key}); + return error.UnsupportedQuantization; + }; + if (int(o.get("bits"))) |b| if (b != bits) { + why.set("quantization_config.dynamic {s}: bits {d}, expected 4", .{ key, b }); + return error.UnsupportedQuantization; + }; + if (int(o.get("group_size"))) |g| if (g != group) { + why.set("quantization_config.dynamic {s}: group_size {d}, expected 128", .{ key, g }); + return error.UnsupportedQuantization; + }; +} + +/// Whether a pattern uses only what `regexMatch` reads, so a rule outside the subset is refused rather than misread. +fn supported(pattern: []const u8) bool { + if (pattern.len == 0) return false; + var i: usize = 0; + var atom = false; + while (i < pattern.len) : (i += 1) { + switch (pattern[i]) { + '\\' => { + // an escaped alphanumeric is a class or an anchor in Python's re, never that character + if (i + 1 >= pattern.len or std.ascii.isAlphanumeric(pattern[i + 1])) return false; + i += 1; + atom = true; + }, + '.' => atom = true, + '*', '+' => { + if (!atom) return false; + atom = false; + }, + '$' => return i + 1 == pattern.len, + '?', '[', ']', '(', ')', '{', '}', '|', '^' => return false, + else => atom = true, + } + } + return true; +} + +/// Python's re.match for the subset the rules use: literals, '.', '\x' escapes, '*' and '+' after an atom, a final '$'. +pub fn regexMatch(pattern: []const u8, module: []const u8) bool { + return reAt(pattern, 0, module, 0); +} + +const Atom = struct { len: usize, lit: ?u8 }; + +fn reAtom(pattern: []const u8, p: usize) Atom { + if (pattern[p] == '\\' and p + 1 < pattern.len) return .{ .len = 2, .lit = pattern[p + 1] }; + if (pattern[p] == '.') return .{ .len = 1, .lit = null }; + return .{ .len = 1, .lit = pattern[p] }; +} + +fn reOne(lit: ?u8, c: u8) bool { + return if (lit) |l| l == c else true; +} + +fn reAt(pattern: []const u8, p: usize, module: []const u8, t: usize) bool { + if (p == pattern.len) return true; + if (pattern[p] == '$' and p + 1 == pattern.len) return t == module.len; + const atom = reAtom(pattern, p); + const next = p + atom.len; + if (next < pattern.len and (pattern[next] == '*' or pattern[next] == '+')) { + const least: usize = if (pattern[next] == '+') 1 else 0; + var n: usize = 0; + while (t + n < module.len and reOne(atom.lit, module[t + n])) n += 1; + var k: usize = n + 1; + while (k > least) { + k -= 1; + if (reAt(pattern, next + 1, module, t + k)) return true; + } + return false; + } + if (t < module.len and reOne(atom.lit, module[t])) return reAt(pattern, next, module, t + 1); + return false; +} + +/// One module as stored: qweight int32 [k / 8, n], scales f16 [k / 128, n], qzeros int32 [k / 128, n / 8]. +pub const Host = struct { qweight: Tensor, scales: Tensor, qzeros: Tensor, n: usize, k: usize }; + +/// `module`'s tensors from `ck`, each refusal logged; the byte views live as long as the checkpoint's map. +pub fn read(ck: *Checkpoint, module: []const u8, n: usize, k: usize) !Host { + var why: Why = .{}; + return readWhy(ck, module, n, k, &why) catch |e| { + if (why.len > 0) std.log.err("{s}", .{why.text()}); + return e; + }; +} + +/// `read`, the refusal kept in `why` instead of the log (tests read it). +pub fn readWhy(ck: *Checkpoint, module: []const u8, n: usize, k: usize, why: *Why) !Host { + if (n == 0 or k == 0 or n % 8 != 0 or k % group != 0) { + why.set("{s}: [n, k] of [{d}, {d}] is not 4-bit groups of 128 in words of 8 codes", .{ module, n, k }); + return error.UnexpectedTensor; + } + const qweight = try fetch(ck, module, "qweight", .i32, &.{ k / 8, n }, why); + const scales = try fetch(ck, module, "scales", .f16, &.{ k / group, n }, why); + const qzeros = try fetch(ck, module, "qzeros", .i32, &.{ k / group, n / 8 }, why); + if (zerosOff(qzeros.bytes)) |at| { + why.set("{s}.qzeros: byte {d} is 0x{x:0>2}, a symmetric weight's every nibble is 7", .{ module, at, qzeros.bytes[at] }); + return error.UnsupportedQuantization; + } + var buf: [320]u8 = undefined; + const gidx = try std.fmt.bufPrint(&buf, "{s}.g_idx", .{module}); + if (ck.has(gidx)) { + const g = try ck.get(gidx); + if (g.numel() != 0) { + why.set("{s}.g_idx: {t} {any}, act order is not read", .{ module, g.dtype, g.shape[0..g.rank] }); + return error.UnexpectedTensor; + } + } + return .{ .qweight = qweight, .scales = scales, .qzeros = qzeros, .n = n, .k = k }; +} + +/// `{module}.{tail}` of `dtype` and `shape`, its bytes whole; a missing tensor refused by name. +fn fetch(ck: *Checkpoint, module: []const u8, tail: []const u8, dtype: ckpt.DType, shape: []const usize, why: *Why) !Tensor { + var buf: [320]u8 = undefined; + const name = try std.fmt.bufPrint(&buf, "{s}.{s}", .{ module, tail }); + if (!ck.has(name)) { + why.set("{s}: no {s}, a GPTQ weight stores it", .{ module, tail }); + return error.MissingTensor; + } + const t = try ck.get(name); + var need: usize = 1; + for (shape) |d| need = std.math.mul(usize, need, d) catch return error.UnexpectedTensor; + if (t.is(dtype, shape)) { + if (need * dtype.size() == t.bytes.len) return t; + why.set("{s}: {d} bytes, {t} {any} needs {d}", .{ name, t.bytes.len, dtype, shape, need * dtype.size() }); + return error.UnexpectedTensor; + } + why.set("{s}: {t} {any}, expected {t} {any}", .{ name, t.dtype, t.shape[0..t.rank], dtype, shape }); + return error.UnexpectedTensor; +} + +/// Weights of a module: its columns by its inputs. +pub fn elements(h: Host) usize { + return h.n * h.k; +} + +/// The dequantized weight of input `k` in column `n`: (code - 8) * scale, exact in binary64. +pub fn weight(h: Host, n: usize, k: usize) f64 { + return @as(f64, @floatFromInt(@as(i32, code(h, n, k)) - 8)) * scale(h, n, k); +} + +/// The code of input `k` in column `n`: nibble `k % 8` of the word at [k / 8, n] (0..15). +pub fn code(h: Host, n: usize, k: usize) u8 { + std.debug.assert(n < h.n and k < h.k); + const at = ((k / 8) * h.n + n) * 4; + const w = std.mem.readInt(u32, h.qweight.bytes[at..][0..4], .little); + return @intCast((w >> @intCast(4 * (k % 8))) & 0xF); +} + +/// The fp16 scale of the group holding input `k` in column `n`, widened exactly. +pub fn scale(h: Host, n: usize, k: usize) f64 { + std.debug.assert(n < h.n and k < h.k); + const at = ((k / group) * h.n + n) * 2; + const half: f16 = @bitCast(std.mem.readInt(u16, h.scales.bytes[at..][0..2], .little)); + return @floatCast(half); +} + +/// Every weight, row-major [n, k], into `out`. +pub fn reference(h: Host, out: []f64) error{UnexpectedTensor}!void { + if (!sized(h) or out.len != elements(h)) return error.UnexpectedTensor; + for (0..h.n) |n| for (0..h.k) |k| { + out[n * h.k + k] = weight(h, n, k); + }; +} + +/// The stored tensors hold exactly what `Host`'s [n, k] says they do. +fn sized(h: Host) bool { + if (h.n == 0 or h.k == 0 or h.n % 8 != 0 or h.k % group != 0) return false; + const words = h.k / 8 * h.n; + if (!h.qweight.is(.i32, &.{ h.k / 8, h.n }) or h.qweight.bytes.len != words * 4) return false; + const scales = h.k / group * h.n; + if (!h.scales.is(.f16, &.{ h.k / group, h.n }) or h.scales.bytes.len != scales * 2) return false; + return h.qzeros.is(.i32, &.{ h.k / group, h.n / 8 }) and h.qzeros.bytes.len == scales / 8 * 4; +} + +/// The first qzeros byte whose two nibbles are not both `zero_nibble`, else null. +pub fn zerosOff(qzeros: []const u8) ?usize { + const all: u8 = zero_nibble << 4 | zero_nibble; + for (qzeros, 0..) |b, i| if (b != all) return i; + return null; +} + +fn flag(v: ?std.json.Value) ?bool { + const x = v orelse return null; + return if (x == .bool) x.bool else null; +} + +/// The JSON kind of `v`, so a refusal of a field that is not the type it must be says what it found. +fn kindOf(v: std.json.Value) []const u8 { + return switch (v) { + .null => "null", + .bool => "a bool", + .integer, .float, .number_string => "a number", + .string => "a string", + .array => "an array", + .object => "an object", + }; +} + +fn holds(v: ?std.json.Value, want: bool) bool { + return (flag(v) orelse false) == want; +} + +test { + _ = @import("gptq_test.zig"); +} diff --git a/zig/src/core/quant/gptq_test.zig b/zig/src/core/quant/gptq_test.zig new file mode 100644 index 00000000000..c2ed4d97afa --- /dev/null +++ b/zig/src/core/quant/gptq_test.zig @@ -0,0 +1,570 @@ +//! gptq: the shared AutoGPTQ v1 reader (core/quant/gptq.zig) on a synthetic checkpoint, against binary64. +const std = @import("std"); +const gptq = @import("gptq.zig"); +const ckpt = @import("../checkpoint.zig"); +const fixture = @import("../checkpoint_fixture.zig"); +const Why = @import("../modelopt.zig").Why; + +const testing = std.testing; +const a = testing.allocator; +const io = testing.io; + +const config_json = @embedFile("../fixtures/gptq_synth/config.json"); + +/// The two modules the synthetic checkpoint holds, and the [n, k] each one stores. +const expert = "model.language_model.layers.0.mlp.experts.0.gate_proj"; +const head = "language_model.lm_head"; + +/// The fp16 bit patterns the fixture stores: awkward mantissas, a subnormal, a negative and a negative zero. +const scale_bits = [2][8]u16{ + .{ 0x3C00, 0x3555, 0xB800, 0x0011, 0x4900, 0x7BFF, 0x8000, 0x3E00 }, + .{ 0x4200, 0xBC00, 0x5000, 0x3400, 0x0001, 0x3800, 0xC000, 0x3900 }, +}; + +/// The code of input `k` in column `c` the fixture writes: a full 0..15 cycle per column, a third of a turn apart. +fn codeOf(c: usize, k: usize) u8 { + return @intCast((k + 3 * c) % 16); +} + +/// What those codes and scale bits mean by the format's definition, in binary64. +fn want(c: usize, k: usize) f64 { + const half: f16 = @bitCast(scale_bits[k / gptq.group][c]); + return @as(f64, @floatFromInt(@as(i32, codeOf(c, k)) - 8)) * @as(f64, @floatCast(half)); +} + +/// AutoGPTQ v1's qweight packing, written from the format: word [k / 8][n], nibble j is input 8w + j, low first. +fn pack(k: usize, n: usize) ![]u8 { + const out = try a.alloc(u8, (k / 8) * n * 4); + @memset(out, 0); + for (0..k / 8) |w| for (0..n) |c| for (0..8) |j| { + const q = codeOf(c, w * 8 + j); + out[(w * n + c) * 4 + j / 2] |= if (j % 2 == 0) q else q << 4; + }; + return out; +} + +/// The scales [k / 128][n] as fp16 bit patterns, little-endian. +fn scales(k: usize, n: usize) ![]u8 { + const out = try a.alloc(u8, (k / gptq.group) * n * 2); + for (0..k / gptq.group) |g| for (0..n) |c| { + std.mem.writeInt(u16, out[(g * n + c) * 2 ..][0..2], scale_bits[g][c], .little); + }; + return out; +} + +/// qzeros [k / 128][n / 8] int32 whose every nibble is 7, so every zero point the format reads is 8. +fn zeros(k: usize, n: usize) ![]u8 { + const out = try a.alloc(u8, (k / gptq.group) * (n / 8) * 4); + @memset(out, 0x77); + return out; +} + +/// The synthetic checkpoint's six tensors, packed to the format; `entries` is what the safetensors image holds. +const Synth = struct { + const modules = [2][]const u8{ expert, head }; + const ns = [2]usize{ 8, 8 }; + const ks = [2]usize{ 256, 128 }; + const tails = [3][]const u8{ "qweight", "scales", "qzeros" }; + const dtypes = [3][]const u8{ "I32", "F16", "I32" }; + + bytes: [6][]u8 = undefined, + shapes: [6][2]usize = undefined, + names: [6][160]u8 = undefined, + entries: [6]fixture.Entry = undefined, + + fn init(s: *Synth) !void { + for (0..2) |m| for (0..3) |t| { + const i = m * 3 + t; + const n = ns[m]; + const k = ks[m]; + s.bytes[i] = switch (t) { + 0 => try pack(k, n), + 1 => try scales(k, n), + else => try zeros(k, n), + }; + s.shapes[i] = switch (t) { + 0 => .{ k / 8, n }, + 1 => .{ k / gptq.group, n }, + else => .{ k / gptq.group, n / 8 }, + }; + const name = try std.fmt.bufPrint(&s.names[i], "{s}.{s}", .{ modules[m], tails[t] }); + s.entries[i] = .{ .name = name, .dtype = dtypes[t], .shape = &s.shapes[i], .bytes = s.bytes[i] }; + }; + } + + fn deinit(s: *Synth) void { + for (s.bytes) |b| a.free(b); + } +}; + +/// A checkpoint folder: `config.json` and one `model.safetensors`. +const Folder = struct { + tmp: testing.TmpDir, + path: [160]u8 = undefined, + len: usize = 0, + ck: ckpt.Checkpoint = undefined, + + fn open(f: *Folder, entries: []const fixture.Entry) !void { + f.tmp = testing.tmpDir(.{}); + errdefer f.tmp.cleanup(); + try f.tmp.dir.writeFile(io, .{ .sub_path = "config.json", .data = config_json }); + try fixture.write(a, io, f.tmp.dir, "model.safetensors", entries); + const sub = try std.fmt.bufPrint(&f.path, ".zig-cache/tmp/{s}", .{f.tmp.sub_path}); + f.len = sub.len; + f.ck = try ckpt.Checkpoint.openModel(a, io, sub); + } + + /// The folder as the checkpoint opened it. + fn dir(f: *const Folder) []const u8 { + return f.path[0..f.len]; + } + + fn close(f: *Folder) void { + f.ck.close(); + f.tmp.cleanup(); + } + + /// The folder's own config.json, as the checkpoint's file. + fn configText(f: *Folder) ![]u8 { + var buf: [192]u8 = undefined; + const path = try std.fmt.bufPrint(&buf, "{s}/config.json", .{f.dir()}); + return std.Io.Dir.cwd().readFileAlloc(io, path, a, .limited(1 << 16)); + } +}; + +test "gptq: the synthetic checkpoint's config is admitted and names the modules it stores quantized" { + var s: Synth = .{}; + try s.init(); + defer s.deinit(); + var f: Folder = .{ .tmp = undefined }; + try f.open(&s.entries); + defer f.close(); + const json = try f.configText(); + defer a.free(json); + var why: Why = .{}; + var cfg = (try gptq.admit(a, json, &why)).?; + defer cfg.deinit(); + try testing.expectEqual(@as(usize, 11), cfg.rules.len); + try testing.expectEqual(@as(usize, 0), why.len); + for ([_][]const u8{ + expert, + "model.language_model.layers.47.mlp.experts.511.down_proj", + "model.language_model.layers.3.mlp.experts.0.up_proj", + "language_model.lm_head", + }) |m| try testing.expect(cfg.quantized(m)); + for ([_][]const u8{ + "model.language_model.layers.0.linear_attn.in_proj_qkv", + "model.language_model.layers.3.self_attn.q_proj", + "model.language_model.layers.0.attn_hyper_connection.input_mix_weight_up", + "model.visual.blocks.0.attn.qkv", + "model.language_model.layers.0.mlp.shared_expert.gate_proj", + "model.language_model.layers.0.ple.embedding", + "model.language_model.embed_tokens", + "model.language_model.layers.0.mlp.fc_hidden", + "model.language_model.layers.48.mlp.down_proj", + "model.language_model.layers.0.mlp.gate", + }) |m| try testing.expect(!cfg.quantized(m)); +} + +test "gptq: the stored tensors dequantize to the binary64 fixture" { + var s: Synth = .{}; + try s.init(); + defer s.deinit(); + var f: Folder = .{ .tmp = undefined }; + try f.open(&s.entries); + defer f.close(); + const h = try gptq.read(&f.ck, expert, 8, 256); + try testing.expectEqual(@as(usize, 8 * 256), gptq.elements(h)); + var got: [8 * 256]f64 = undefined; + try gptq.reference(h, &got); + for (0..8) |c| for (0..256) |k| { + const bits: u64 = @bitCast(got[c * 256 + k]); + if (bits != @as(u64, @bitCast(want(c, k)))) { + std.debug.print("column {d} input {d}: 0x{x:0>16}, expected 0x{x:0>16}\n", .{ c, k, bits, @as(u64, @bitCast(want(c, k))) }); + return error.TestUnexpectedResult; + } + }; + // the binary64 fixture: every code, both groups, a negative, a subnormal and a negative zero + const spot = [_]struct { c: usize, k: usize, want: f64 }{ + .{ .c = 0, .k = 0, .want = -8.0 }, // q -8 x 1 + .{ .c = 0, .k = 1, .want = -7.0 }, // q -7 x 1 + .{ .c = 0, .k = 2, .want = -6.0 }, + .{ .c = 0, .k = 3, .want = -5.0 }, + .{ .c = 0, .k = 4, .want = -4.0 }, + .{ .c = 0, .k = 5, .want = -3.0 }, + .{ .c = 0, .k = 6, .want = -2.0 }, + .{ .c = 0, .k = 7, .want = -1.0 }, + .{ .c = 0, .k = 8, .want = 0.0 }, // q 0, the zero point itself + .{ .c = 0, .k = 9, .want = 1.0 }, + .{ .c = 0, .k = 10, .want = 2.0 }, + .{ .c = 0, .k = 11, .want = 3.0 }, + .{ .c = 0, .k = 12, .want = 4.0 }, + .{ .c = 0, .k = 13, .want = 5.0 }, + .{ .c = 0, .k = 14, .want = 6.0 }, + .{ .c = 0, .k = 15, .want = 7.0 }, + .{ .c = 1, .k = 0, .want = -1.666259765625 }, // q -5 x 0.333251953125 + .{ .c = 1, .k = 1, .want = -1.3330078125 }, + .{ .c = 1, .k = 2, .want = -0.999755859375 }, + .{ .c = 1, .k = 3, .want = -0.66650390625 }, + .{ .c = 1, .k = 4, .want = -0.333251953125 }, + .{ .c = 1, .k = 5, .want = 0.0 }, + .{ .c = 1, .k = 6, .want = 0.333251953125 }, + .{ .c = 1, .k = 7, .want = 0.66650390625 }, + .{ .c = 2, .k = 0, .want = 1.0 }, // q -2 x -0.5 + .{ .c = 2, .k = 1, .want = 0.5 }, + .{ .c = 2, .k = 2, .want = -0.0 }, // a zero code under a negative scale keeps the product's sign + .{ .c = 2, .k = 3, .want = -0.5 }, + .{ .c = 3, .k = 0, .want = 1.0132789611816406e-06 }, // a subnormal scale, q 1 + .{ .c = 3, .k = 1, .want = 2.0265579223632812e-06 }, + .{ .c = 0, .k = 128, .want = -24.0 }, // the second group's own scale, q -8 x 3 + .{ .c = 0, .k = 129, .want = -21.0 }, + .{ .c = 0, .k = 130, .want = -18.0 }, + .{ .c = 0, .k = 131, .want = -15.0 }, + .{ .c = 0, .k = 132, .want = -12.0 }, + .{ .c = 0, .k = 133, .want = -9.0 }, + .{ .c = 0, .k = 134, .want = -6.0 }, + .{ .c = 0, .k = 135, .want = -3.0 }, + .{ .c = 7, .k = 128, .want = -1.875 }, // q -3 x 0.625 + .{ .c = 7, .k = 129, .want = -1.25 }, + .{ .c = 7, .k = 130, .want = -0.625 }, + .{ .c = 7, .k = 131, .want = 0.0 }, + .{ .c = 4, .k = 128, .want = 2.384185791015625e-07 }, // the smallest subnormal, q 4 + .{ .c = 4, .k = 129, .want = 2.980232238769531e-07 }, + .{ .c = 6, .k = 0, .want = 0.0 }, // a negative-zero scale turns a negative code positive + .{ .c = 6, .k = 1, .want = 0.0 }, + }; + for (spot) |p| try testing.expectEqual(@as(u64, @bitCast(p.want)), @as(u64, @bitCast(got[p.c * 256 + p.k]))); + try testing.expectEqual(@as(u8, 15), gptq.code(h, 0, 15)); + try testing.expectEqual(@as(u8, 8), gptq.code(h, 2, 2)); // the zero point itself + try testing.expectEqual(@as(f64, 0.333251953125), gptq.scale(h, 1, 100)); + try testing.expectEqual(@as(f64, 3), gptq.scale(h, 0, 128)); + try testing.expectEqual(@as(u64, @bitCast(@as(f64, 2.0))), @as(u64, @bitCast(gptq.weight(h, 0, 10)))); + const hd = try gptq.read(&f.ck, head, 8, 128); + var one: [8 * 128]f64 = undefined; + try gptq.reference(hd, &one); + try testing.expectEqual(@as(u64, @bitCast(@as(f64, -8.0))), @as(u64, @bitCast(one[0]))); + try testing.expectEqual(@as(u64, @bitCast(@as(f64, -24.0))), @as(u64, @bitCast(got[128]))); +} + +test "gptq: the matcher reads the rule subset and anchors as Python's re.match does" { + const cases = [_]struct { pattern: []const u8, hit: []const u8, miss: []const u8 }{ + .{ .pattern = ".*lm_head$", .hit = "language_model.lm_head", .miss = "language_model.lm_head.weight" }, + .{ .pattern = ".*\\.gate$", .hit = "model.language_model.layers.0.mlp.gate", .miss = "model.language_model.layers.0.mlp.gate_proj" }, + .{ .pattern = ".*linear_attn.*", .hit = "model.language_model.layers.0.linear_attn.in_proj_qkv", .miss = "model.language_model.layers.0.self_attn.q_proj" }, + .{ .pattern = ".*self_attn.*", .hit = "model.language_model.layers.3.self_attn.q_proj", .miss = "model.language_model.layers.3.mlp.experts.0.gate_proj" }, + .{ .pattern = ".*hyper_connection.*", .hit = "model.language_model.layers.0.attn_hyper_connection.input_mix_weight_up", .miss = "model.language_model.layers.0.mlp.experts.0.gate_proj" }, + .{ .pattern = ".*visual.*", .hit = "model.visual.blocks.0.attn.qkv", .miss = "model.language_model.embed_tokens" }, + .{ .pattern = ".*shared_expert.*", .hit = "model.language_model.layers.0.mlp.shared_expert.gate_proj", .miss = "model.language_model.layers.0.mlp.experts.0.gate_proj" }, + .{ .pattern = ".*\\.ple\\..*", .hit = "model.language_model.layers.0.ple.embedding", .miss = "model.language_model.layers.0.pleb" }, + .{ .pattern = ".*embed.*", .hit = "model.language_model.embed_tokens", .miss = "model.language_model.layers.0.mlp.down_proj" }, + .{ .pattern = ".*fc_hidden.*", .hit = "model.language_model.layers.0.mlp.fc_hidden.weight", .miss = "model.language_model.layers.0.mlp.experts.0.gate_proj" }, + .{ .pattern = ".*layers\\.48\\..*", .hit = "model.language_model.layers.48.mlp.down_proj", .miss = "model.language_model.layers.4.mlp.down_proj" }, + }; + for (cases) |c| { + try testing.expect(gptq.regexMatch(c.pattern, c.hit)); + try testing.expect(!gptq.regexMatch(c.pattern, c.miss)); + } + try testing.expect(gptq.regexMatch("abc", "abcdef")); // re.match anchors at the start, not the end + try testing.expect(!gptq.regexMatch("abc", "xabc")); + try testing.expect(gptq.regexMatch("a.c", "abc")); + try testing.expect(!gptq.regexMatch("a.c", "ac")); + try testing.expect(gptq.regexMatch("a\\.c", "a.c")); + try testing.expect(!gptq.regexMatch("a\\.c", "abc")); + try testing.expect(gptq.regexMatch("a*b", "aaab")); // '*' and '+' backtrack + try testing.expect(gptq.regexMatch("a*b", "b")); + try testing.expect(!gptq.regexMatch("a*b", "aaac")); + try testing.expect(gptq.regexMatch("a+b", "aaab")); + try testing.expect(!gptq.regexMatch("a+b", "b")); + try testing.expect(gptq.regexMatch("$", "")); + try testing.expect(!gptq.regexMatch("$", "x")); + try testing.expect(gptq.regexMatch(".*\\.48\\..*", "layers.48.x")); + try testing.expect(!gptq.regexMatch(".*\\.48\\..*", "layers.480.x")); +} + +test "gptq: an escape of an alphanumeric character is refused, as Python's re reads it as a class or an anchor" { + // Python's re matches model.layers.12.mlp.x here; read as a literal d it matches layers.d.mlp instead + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": false, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:.*layers\\.\\d+\\.mlp.*": {"bits": 4}} + , "quantization_config.dynamic -:.*layers\\.\\d+\\.mlp.*: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": false, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:.*\\w+.*": {"bits": 4}} + , "quantization_config.dynamic -:.*\\w+.*: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": false, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:.*\\s+\\b.*": {"bits": 4}} + , "quantization_config.dynamic -:.*\\s+\\b.*: outside this reader's matcher"); + // an escape of a non-alphanumeric character is the character itself, in Python's re and in this matcher + try testing.expect(gptq.regexMatch("a\\+b", "a+b")); + try testing.expect(!gptq.regexMatch("a\\+b", "aab")); + try testing.expect(gptq.regexMatch("a\\$", "a$")); + try testing.expect(gptq.regexMatch("a\\\\b", "a\\b")); + var why: Why = .{}; + var plus = (try gptq.admit(a, jsonOf( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": false, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:a\\+b.*": {"bits": 4}} + ), &why)).?; + defer plus.deinit(); + try testing.expect(!plus.quantized("a+bzzz")); + try testing.expect(plus.quantized("aab")); +} + +/// `fields` as a config.json's quantization_config, so one field can be changed per case. +fn jsonOf(comptime fields: []const u8) []const u8 { + return "{\"quantization_config\": {" ++ fields ++ "}}"; +} + +/// `jsonOf(fields)` is refused as unsupported, its reason exactly `text`. +fn refuses(comptime fields: []const u8, text: []const u8) !void { + var why: Why = .{}; + try testing.expectError(error.UnsupportedQuantization, gptq.admit(a, jsonOf(fields), &why)); + try testing.expectEqualStrings(text, why.text()); +} + +/// The admitted fields: the fixture's shape, with the head rule alone in `dynamic`. +const ok = + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": false, "checkpoint_format": "gptq", + \\"lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} +; + +test "gptq: a config outside the dialect is refused by its field or rule name" { + var why: Why = .{}; + var cfg = (try gptq.admit(a, jsonOf(ok), &why)).?; + cfg.deinit(); + try refuses( + \\"quant_method": "gptq", "bits": 8, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.bits: 8, expected 4"); + try refuses( + \\"quant_method": "gptq", "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.bits: null, expected 4"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 64, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.group_size: 64, expected 128"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.group_size: null, expected 128"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": false, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.sym: false, expected true"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.sym: null, expected true"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.desc_act: true, this reader reads no act order"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": "false", "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.desc_act: a string, expected a bool"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": null, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.desc_act: null, expected a bool"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "checkpoint_format": "marlin", "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.checkpoint_format: marlin, expected gptq"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "checkpoint_format": "GPTQ", "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.checkpoint_format: GPTQ, expected gptq"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "checkpoint_format": 1, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + , "quantization_config.checkpoint_format: a number, expected gptq"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "desc_act": false, "lm_head": false, "dynamic": {"-:.*linear_attn.*": {"bits": 4}} + , "quantization_config.lm_head: false, the rules do not store the head int4"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"-:.*lm_head$": {"bits": 4}} + , "quantization_config.lm_head: true, the rules do not store the head int4"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "dynamic": {"-:.*linear_attn.*": {"bits": 4}} + , "quantization_config.lm_head: null, the rules do not store the head int4"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true + , "quantization_config.dynamic: absent, this reader reads its rules"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": ["+:.*lm_head$"] + , "quantization_config.dynamic: not an object, this reader reads its rules"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"lm_head": {"bits": 4}} + , "quantization_config.dynamic lm_head: no +: or -: prefix"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:.*linear_attn(.*": {"bits": 4}} + , "quantization_config.dynamic -:.*linear_attn(.*: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:^model.*": {"bits": 4}} + , "quantization_config.dynamic -:^model.*: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:a**": {"bits": 4}} + , "quantization_config.dynamic -:a**: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:a$b": {"bits": 4}} + , "quantization_config.dynamic -:a$b: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}, "-:": {"bits": 4}} + , "quantization_config.dynamic -:: outside this reader's matcher"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 8}} + , "quantization_config.dynamic +:.*lm_head$: bits 8, expected 4"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4, "group_size": 64}} + , "quantization_config.dynamic +:.*lm_head$: group_size 64, expected 128"); + try refuses( + \\"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": 4} + , "quantization_config.dynamic +:.*lm_head$: not an object of bits"); +} + +test "gptq: a config that declares no gptq block is not this reader's, and the head rule may stand alone" { + var why: Why = .{}; + for ([_][]const u8{ + \\{} + , + \\{"quantization": {"group_size": 32, "bits": 4}} + , + \\{"quantization_config": {"quant_method": "modelopt", "quant_algo": "NVFP4"}} + , + \\{"quantization_config": {"quant_method": "exl3"}} + , + \\[1] + }) |json| { + const declared = try gptq.admit(a, json, &why); + try testing.expect(declared == null); + } + // the head is quantized by its rule alone, as the export may leave lm_head out of the config + var forced = (try gptq.admit(a, + \\{"quantization_config": {"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": false, + \\ "dynamic": {"+:.*lm_head$": null}}} + , &why)).?; + defer forced.deinit(); + try testing.expect(forced.quantized("language_model.lm_head")); + // a rule set with no exclusions quantizes whatever it is asked about + var all = (try gptq.admit(a, + \\{"text_config": {"quantization_config": {"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, + \\ "lm_head": true, "dynamic": {}}}} + , &why)).?; + defer all.deinit(); + try testing.expectEqual(@as(usize, 0), all.rules.len); + try testing.expect(all.quantized("model.language_model.layers.0.linear_attn.in_proj_qkv")); + // GPTQ spelled in another case is the same method + var upper = (try gptq.admit(a, jsonOf( + \\"quant_method": "GPTQ", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, "dynamic": {"+:.*lm_head$": {"bits": 4}} + ), &why)).?; + upper.deinit(); +} + +test "gptq: the last rule matching a module decides, and no rule leaves it quantized" { + var why: Why = .{}; + var cfg = (try gptq.admit(a, + \\{"quantization_config": {"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, + \\ "dynamic": {"-:.*experts.*": {"bits": 4}, "+:.*gate_proj$": {"bits": 4}}}} + , &why)).?; + defer cfg.deinit(); + try testing.expect(!cfg.quantized("m.experts.0.down_proj")); + try testing.expect(cfg.quantized("m.experts.0.gate_proj")); + var other = (try gptq.admit(a, + \\{"quantization_config": {"quant_method": "gptq", "bits": 4, "group_size": 128, "sym": true, "lm_head": true, + \\ "dynamic": {"+:.*gate_proj$": {"bits": 4}, "-:.*experts.*": {"bits": 4}}}} + , &why)).?; + defer other.deinit(); + try testing.expect(!other.quantized("m.experts.0.gate_proj")); + try testing.expect(!other.quantized("m.experts.0.up_proj")); + try testing.expect(other.quantized("m.layers.0.mlp.gate_proj")); +} + +/// `entries` read as `module` [n, k] fail with `err`, the refusal saying exactly `text`. +fn refusedTensor(entries: []const fixture.Entry, module: []const u8, n: usize, k: usize, err: anyerror, text: []const u8) !void { + var f: Folder = .{ .tmp = undefined }; + try f.open(entries); + defer f.close(); + var why: Why = .{}; + try testing.expectError(err, gptq.readWhy(&f.ck, module, n, k, &why)); + try testing.expectEqualStrings(text, why.text()); +} + +const one_shape = [_]usize{1}; +const one_byte = [_]u8{0}; + +/// `entries` in `buf` with tensor `i` replaced by `e`, or by an unrelated tensor when `e` is null. +fn edited(buf: *[7]fixture.Entry, entries: [6]fixture.Entry, i: usize, e: ?fixture.Entry) []const fixture.Entry { + @memcpy(buf[0..6], &entries); + buf[6] = .{ .name = "x.unrelated", .dtype = "U8", .shape = &one_shape, .bytes = &one_byte }; + buf[i] = e orelse buf[6]; + return buf[0..6]; +} + +test "gptq: every tensor it refuses is named, the zero point and act order included" { + var s: Synth = .{}; + try s.init(); + defer s.deinit(); + var f: Folder = .{ .tmp = undefined }; + try f.open(&s.entries); + defer f.close(); + _ = try gptq.read(&f.ck, expert, 8, 256); + _ = try gptq.read(&f.ck, head, 8, 128); + var buf: [7]fixture.Entry = undefined; + const E = error.UnexpectedTensor; + const Q = error.UnsupportedQuantization; + try refusedTensor(&s.entries, expert, 5, 256, E, expert ++ ": [n, k] of [5, 256] is not 4-bit groups of 128 in words of 8 codes"); + try refusedTensor(&s.entries, expert, 8, 192, E, expert ++ ": [n, k] of [8, 192] is not 4-bit groups of 128 in words of 8 codes"); + try refusedTensor(&s.entries, expert, 8, 128, E, expert ++ ".qweight: i32 { 32, 8 }, expected i32 { 16, 8 }"); + var wide = [_]usize{ 16, 16 }; + const qw_wide: fixture.Entry = .{ .name = s.entries[0].name, .dtype = "I32", .shape = &wide, .bytes = s.bytes[0] }; + try refusedTensor(edited(&buf, s.entries, 0, qw_wide), expert, 8, 256, E, expert ++ ".qweight: i32 { 16, 16 }, expected i32 { 32, 8 }"); + const qw_u8: fixture.Entry = .{ .name = s.entries[0].name, .dtype = "U8", .shape = &s.shapes[0], .bytes = s.bytes[0][0..256] }; + try refusedTensor(edited(&buf, s.entries, 0, qw_u8), expert, 8, 256, E, expert ++ ".qweight: u8 { 32, 8 }, expected i32 { 32, 8 }"); + var f32_scales: [64]u8 = @splat(0); + const sc_f32: fixture.Entry = .{ .name = s.entries[1].name, .dtype = "F32", .shape = &s.shapes[1], .bytes = &f32_scales }; + try refusedTensor(edited(&buf, s.entries, 1, sc_f32), expert, 8, 256, E, expert ++ ".scales: f32 { 2, 8 }, expected f16 { 2, 8 }"); + const sc_bf16: fixture.Entry = .{ .name = s.entries[1].name, .dtype = "BF16", .shape = &s.shapes[1], .bytes = s.bytes[1] }; + try refusedTensor(edited(&buf, s.entries, 1, sc_bf16), expert, 8, 256, E, expert ++ ".scales: bf16 { 2, 8 }, expected f16 { 2, 8 }"); + var flipped = [_]usize{ 8, 2 }; + const sc_flipped: fixture.Entry = .{ .name = s.entries[1].name, .dtype = "F16", .shape = &flipped, .bytes = s.bytes[1] }; + try refusedTensor(edited(&buf, s.entries, 1, sc_flipped), expert, 8, 256, E, expert ++ ".scales: f16 { 8, 2 }, expected f16 { 2, 8 }"); + var half = [_]usize{ 2, 2 }; + var wide_zeroes: [16]u8 = @splat(0); + const qz_wide: fixture.Entry = .{ .name = s.entries[2].name, .dtype = "I32", .shape = &half, .bytes = &wide_zeroes }; + try refusedTensor(edited(&buf, s.entries, 2, qz_wide), expert, 8, 256, E, expert ++ ".qzeros: i32 { 2, 2 }, expected i32 { 2, 1 }"); + const bad = try a.dupe(u8, s.bytes[5]); + defer a.free(bad); + bad[3] = 0x87; + const qz_bad: fixture.Entry = .{ .name = s.entries[5].name, .dtype = "I32", .shape = &s.shapes[5], .bytes = bad }; + try refusedTensor(edited(&buf, s.entries, 5, qz_bad), head, 8, 128, Q, head ++ ".qzeros: byte 3 is 0x87, a symmetric weight's every nibble is 7"); + bad[3] = 0x78; + try refusedTensor(edited(&buf, s.entries, 5, qz_bad), head, 8, 128, Q, head ++ ".qzeros: byte 3 is 0x78, a symmetric weight's every nibble is 7"); + bad[3] = 0x77; + bad[0] = 0x00; + try refusedTensor(edited(&buf, s.entries, 5, qz_bad), head, 8, 128, Q, head ++ ".qzeros: byte 0 is 0x00, a symmetric weight's every nibble is 7"); + // a store that hands back fewer bytes than its header declares (checkpoint_direct's copies) is refused by name + var copies: std.StringHashMapUnmanaged([]const u8) = .empty; + defer copies.deinit(a); + try copies.put(a, s.entries[0].name, s.bytes[0][0..1020]); + var short: Folder = .{ .tmp = undefined }; + try short.open(&s.entries); + defer short.close(); + short.ck.copies = &copies; + var why: Why = .{}; + try testing.expectError(E, gptq.readWhy(&short.ck, expert, 8, 256, &why)); + try testing.expectEqualStrings(expert ++ ".qweight: 1020 bytes, i32 { 32, 8 } needs 1024", why.text()); + try refusedTensor(edited(&buf, s.entries, 2, null), expert, 8, 256, error.MissingTensor, expert ++ ": no qzeros, a GPTQ weight stores it"); + try refusedTensor(edited(&buf, s.entries, 3, null), head, 8, 128, error.MissingTensor, head ++ ": no qweight, a GPTQ weight stores it"); + var order = [_]usize{128}; + var gbytes: [128 * 4]u8 = @splat(0); + var with_g: [7]fixture.Entry = undefined; + @memcpy(with_g[0..6], &s.entries); + with_g[6] = .{ .name = head ++ ".g_idx", .dtype = "I32", .shape = &order, .bytes = &gbytes }; + try refusedTensor(&with_g, head, 8, 128, E, head ++ ".g_idx: i32 { 128 }, act order is not read"); + // an empty g_idx is what a desc_act false export leaves behind: it is read and kept out of the way + var none = [_]usize{0}; + with_g[6] = .{ .name = head ++ ".g_idx", .dtype = "I32", .shape = &none, .bytes = &.{} }; + var g: Folder = .{ .tmp = undefined }; + try g.open(&with_g); + defer g.close(); + const hd = try gptq.read(&g.ck, head, 8, 128); + _ = try gptq.read(&g.ck, expert, 8, 256); + try testing.expectEqual(@as(u64, @bitCast(@as(f64, -8.0))), @as(u64, @bitCast(gptq.weight(hd, 0, 0)))); + try testing.expectEqual(@as(usize, 0), g.ck.unused()); +} + +test "gptq: the zero point check reads both nibbles of every word" { + try testing.expectEqual(@as(?usize, null), gptq.zerosOff(&.{ 0x77, 0x77, 0x77, 0x77 })); + try testing.expectEqual(@as(?usize, null), gptq.zerosOff(&.{})); + try testing.expectEqual(@as(?usize, null), gptq.zerosOff(&.{ 0x77, 0x77 })); + try testing.expectEqual(@as(?usize, 0), gptq.zerosOff(&.{ 0x78, 0x77 })); + try testing.expectEqual(@as(?usize, 1), gptq.zerosOff(&.{ 0x77, 0x87 })); + try testing.expectEqual(@as(?usize, 2), gptq.zerosOff(&.{ 0x77, 0x77, 0x00 })); + try testing.expectEqual(@as(?usize, 1), gptq.zerosOff(&.{ 0x77, 0x7F })); +} diff --git a/zig/src/core/quant/quant.zig b/zig/src/core/quant/quant.zig index 3c03930cf01..1a6b47234b3 100644 --- a/zig/src/core/quant/quant.zig +++ b/zig/src/core/quant/quant.zig @@ -15,6 +15,8 @@ pub const experts = @import("experts.zig"); /// FP8 and NVFP4 values and fp64 references; host only (no Format: their kernels' layouts are each backend's). pub const fp8 = @import("fp8.zig"); pub const nvfp4 = @import("nvfp4.zig"); +/// AutoGPTQ v1 weights (4-bit symmetric groups of 128) and their fp64 reference; host only, as `fp8`. +pub const gptq = @import("gptq.zig"); pub const widen = @import("widen.zig"); const Allocator = std.mem.Allocator; diff --git a/zig/src/core/root.zig b/zig/src/core/root.zig index a34a9aa8437..caac0deebd9 100644 --- a/zig/src/core/root.zig +++ b/zig/src/core/root.zig @@ -87,6 +87,7 @@ test { _ = shard_edit; _ = lora_merge; _ = quant; + _ = quant.gptq; _ = nvfp4_rows; _ = route_ref; _ = nvfp4_csf; diff --git a/zig/src/core/row_projection.zig b/zig/src/core/row_projection.zig index 9c8162532f9..c80f71a72fa 100644 --- a/zig/src/core/row_projection.zig +++ b/zig/src/core/row_projection.zig @@ -204,12 +204,20 @@ test "a strided call writes rows at least a matrix wide" { try std.testing.expectEqual([6]i32{ 128, 64, 64, 2, 192, 1 }, c.dims); } +// Fake pipelines carry a distinct id in both the real Metal struct and the recording stub's u32. +fn testPipeline(id: usize) mtl.Pipeline { + return if (comptime @typeInfo(mtl.Pipeline) == .@"struct") .{ .id = @ptrFromInt(id) } else @intCast(id); +} +fn testPipelineId(p: mtl.Pipeline) usize { + return if (comptime @typeInfo(mtl.Pipeline) == .@"struct") @intFromPtr(p.id) else @intCast(p); +} + test "row dispatch selects wide contiguous and strided pipelines from four rows" { if (comptime @import("builtin").os.tag != .macos) return error.SkipZigTest; // Metal pipelines exist only on macOS var p: Pipelines = undefined; p.wide = true; inline for (.{ "plain", "relu2", "strided", "wide_plain", "wide_relu2", "wide_strided" }, 1..) |field, tag| { - for (&@field(p, field), 0..) |*pipeline, i| pipeline.* = .{ .id = @ptrFromInt(0x1000 + tag * 0x100 + i) }; + for (&@field(p, field), 0..) |*pipeline, i| pipeline.* = testPipeline(0x1000 + tag * 0x100 + i); } for (bit_widths) |bits| for ([_]Sum{ .f32, .bf16 }) |sum| { const w = Weights{ .w = undefined, .scales = undefined, .biases = undefined, .n = 64, .k = 128, .bits = bits, .sum = sum }; @@ -217,10 +225,10 @@ test "row dispatch selects wide contiguous and strided pipelines from four rows" for (1..33) |rows| { for ([_]bool{ false, true }) |relu2| { const expected = if (rows >= 4) (if (relu2) p.wide_relu2[i] else p.wide_plain[i]) else if (relu2) p.relu2[i] else p.plain[i]; - try std.testing.expectEqual(expected.id, (try call(&p, w, rows, relu2)).pipeline.id); + try std.testing.expectEqual(testPipelineId(expected), testPipelineId((try call(&p, w, rows, relu2)).pipeline)); } const expected = if (rows >= 4) p.wide_strided[i] else p.strided[i]; - try std.testing.expectEqual(expected.id, (try callStrided(&p, w, rows, 128)).pipeline.id); + try std.testing.expectEqual(testPipelineId(expected), testPipelineId((try callStrided(&p, w, rows, 128)).pipeline)); } }; } @@ -230,7 +238,7 @@ test "row dispatch without tensor units keeps main's pipelines at every row coun var p: Pipelines = undefined; p.wide = false; inline for (.{ "plain", "relu2", "strided", "wide_plain", "wide_relu2", "wide_strided" }, 1..) |field, tag| { - for (&@field(p, field), 0..) |*pipeline, i| pipeline.* = .{ .id = @ptrFromInt(0x1000 + tag * 0x100 + i) }; + for (&@field(p, field), 0..) |*pipeline, i| pipeline.* = testPipeline(0x1000 + tag * 0x100 + i); } for (bit_widths) |bits| for ([_]Sum{ .f32, .bf16 }) |sum| { const w = Weights{ .w = undefined, .scales = undefined, .biases = undefined, .n = 64, .k = 128, .bits = bits, .sum = sum }; @@ -238,9 +246,9 @@ test "row dispatch without tensor units keeps main's pipelines at every row coun for (1..33) |rows| { for ([_]bool{ false, true }) |relu2| { const expected = if (relu2) p.relu2[i] else p.plain[i]; - try std.testing.expectEqual(expected.id, (try call(&p, w, rows, relu2)).pipeline.id); + try std.testing.expectEqual(testPipelineId(expected), testPipelineId((try call(&p, w, rows, relu2)).pipeline)); } - try std.testing.expectEqual(p.strided[i].id, (try callStrided(&p, w, rows, 128)).pipeline.id); + try std.testing.expectEqual(testPipelineId(p.strided[i]), testPipelineId((try callStrided(&p, w, rows, 128)).pipeline)); } }; } diff --git a/zig/src/core/rows_all_test.zig b/zig/src/core/rows_all_test.zig index a8912ea3714..916b32fa871 100644 --- a/zig/src/core/rows_all_test.zig +++ b/zig/src/core/rows_all_test.zig @@ -7,6 +7,7 @@ test { _ = @import("rows_write.zig").io; _ = @import("rows_test.zig"); _ = @import("rows_spill_test.zig"); + _ = @import("rows_isolation_test.zig"); _ = @import("rows_async_test.zig"); _ = @import("rows_close_test.zig"); _ = @import("rows_stage_test.zig"); diff --git a/zig/src/core/rows_isolation_test.zig b/zig/src/core/rows_isolation_test.zig new file mode 100644 index 00000000000..4bcea0e2e91 --- /dev/null +++ b/zig/src/core/rows_isolation_test.zig @@ -0,0 +1,151 @@ +//! KV isolation across sessions: a spilled and dropped state, a retired page, and a disjoint session admitted between. +const std = @import("std"); +const platform = @import("sys"); +const pc = @import("prompt_cache.zig"); +const rows = @import("rows_store.zig"); +const Fake = @import("rows_fake.zig").Fake; +const fresh = @import("rows_fake.zig").fresh; +const Pooled = @import("prompt_cache_fake.zig").Fake; +const pooledFresh = @import("prompt_cache_test.zig").fresh; +const rmTree = @import("prompt_imprint_test.zig").rmTree; +const Allocator = std.mem.Allocator; + +const rules: pc.Rules = .{ .lookahead = 1, .min_prompt = 0, .min_gap = 1 }; + +fn root(buf: []u8, tag: []const u8) []const u8 { + return std.fmt.bufPrint(buf, "/tmp/tf-isolation-{s}-{d}", .{ tag, platform.c.getpid() }) catch unreachable; +} + +/// Session `c`'s prompt of `n` tokens: no token is shared with another session's, and every length is the same. +fn session(a: Allocator, c: u32, n: u32) ![]u32 { + const out = try a.alloc(u32, n); + for (out, 0..) |*t, i| t.* = @intCast(50_000 + c * 10_000 + i); + return out; +} + +/// The session's next turn: its first 601 tokens, then two new ones. +fn next(a: Allocator, p: []const u32) ![]u32 { + return std.mem.concat(a, u32, &.{ p[0..601], &[_]u32{ 1, 2 } }); +} + +/// One request: its plan, then a pass from it (`f.restored_ok` holds whether every restore equalled a fresh pass). +fn request(a: Allocator, s: *pc.Store, f: *Fake, p: []const u32, history: u32) !struct { from: u32, sum: u64 } { + f.prompt = p; + const plan = try s.begin(a, p, history, &.{}, f.starts, null, f.spans); + return .{ .from = plan.from, .sum = f.pass(s, plan) }; +} + +/// A RAM budget that holds one state of `at` tokens, not two. +fn one(f: *Fake, at: u32) u64 { + return Fake.snapshots(f).vtable.bytes(f, at) + 1000; +} + +fn blockFiles(dir: [:0]const u8) usize { + const d = platform.c.opendir(dir) orelse return 0; + defer _ = platform.c.closedir(d); + var n: usize = 0; + while (platform.c.readdir(d)) |ent| n += @intFromBool(std.mem.endsWith(u8, std.mem.sliceTo(&ent.name, 0), ".blk")); + return n; +} + +test "rows isolation: B admitted after A is spilled and dropped never resumes A's rows; A resumes exactly its own" { + const gpa = std.testing.allocator; + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const a = arena.allocator(); + var buf: [128]u8 = undefined; + const dir = root(&buf, "spill"); + defer rmTree(dir); + var f: Fake = .{ .gpa = gpa }; + var s = pc.Store.init(gpa, f.snapshots(), rules, one(&f, 600)); + const r = try rows.attach(gpa, &s, .{ .sync_writes = true, .root = dir, .identity = 7, .cap = 1 << 34, .floor = 0, .daily = 1 << 40, .lookahead = 1, .spill = .evicted }); + defer r.deinit(); + defer s.deinit(); + // A and B share no token, and keep states at the same positions + const sa = try session(a, 1, 700); + const sb = try session(a, 2, 700); + _ = try request(a, &s, &f, sa, 600); + const b1 = try request(a, &s, &f, sb, 600); // A leaves RAM for disk + try std.testing.expectEqual(@as(usize, 1), r.states.items.len); + try std.testing.expectEqual(@as(usize, 1), s.entries.items.len); + try std.testing.expectEqualSlices(u32, sb[0..600], s.entries.items[0].tokens[0..600]); + // (1) B's first turn and its next resume nothing of A's: B prefills, then resumes its own RAM state + try std.testing.expectEqual(@as(u32, 0), b1.from); + try std.testing.expectEqual(fresh(sb), b1.sum); + const b_next = try next(a, sb); + const b2 = try request(a, &s, &f, b_next, 602); + try std.testing.expectEqual(@as(u32, 600), b2.from); + try std.testing.expect(f.restored_ok); + try std.testing.expectEqual(fresh(b_next), b2.sum); + try std.testing.expectEqual(@as(u64, 0), r.counts.reads); // A's spilled file was not read for B + // (2) A's next turn resumes A's spilled state, equal to a fresh pass of A's own tokens + const a_next = try next(a, sa); + const a2 = try request(a, &s, &f, a_next, 602); + try std.testing.expectEqual(@as(u32, 600), a2.from); + try std.testing.expect(f.restored_ok); + try std.testing.expectEqual(fresh(a_next), a2.sum); + try std.testing.expectEqual(@as(u64, 1), r.counts.reads); +} + +test "rows isolation: after A's spilled state and blocks are retired and B's are written, A's lookup takes nothing" { + const gpa = std.testing.allocator; + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const a = arena.allocator(); + var buf: [128]u8 = undefined; + const dir = root(&buf, "retire"); + defer rmTree(dir); + var f: Fake = .{ .gpa = gpa }; + var s = pc.Store.init(gpa, f.snapshots(), rules, one(&f, 600)); + const r = try rows.attach(gpa, &s, .{ .sync_writes = true, .root = dir, .identity = 7, .cap = 1 << 34, .floor = 0, .daily = 1 << 40, .lookahead = 1, .spill = .evicted }); + defer r.deinit(); + defer s.deinit(); + const sa = try session(a, 1, 700); + const sb = try session(a, 2, 700); + _ = try request(a, &s, &f, sa, 600); + _ = try request(a, &s, &f, sb, 600); // A on disk + try std.testing.expectEqual(@as(usize, 1), r.states.items.len); + try std.testing.expect(blockFiles(r.dir) > 0); + r.remove(0); // A's state retired: its file and blocks go + try std.testing.expectEqual(@as(usize, 0), r.states.items.len); + try std.testing.expectEqual(@as(usize, 0), blockFiles(r.dir)); + _ = try request(a, &s, &f, try session(a, 3, 700), 600); // B's state takes the disk A's left + try std.testing.expectEqual(@as(usize, 1), r.states.items.len); + try std.testing.expect(blockFiles(r.dir) > 0); + // (3) A's prefix matches no state's tokens: nothing is read or restored, and A prefills its own tokens + const a_next = try next(a, sa); + try std.testing.expectEqual(@as(?usize, null), r.best(a_next, &.{}, &.{}, 0)); + const reads = r.counts.reads; + const got = try request(a, &s, &f, a_next, 602); + try std.testing.expectEqual(@as(u32, 0), got.from); + try std.testing.expectEqual(reads, r.counts.reads); + try std.testing.expect(f.restored_ok); + try std.testing.expectEqual(fresh(a_next), got.sum); +} + +test "rows isolation: storage A's dropped state left spare and B's save reused is never resumed for A's prefix" { + const gpa = std.testing.allocator; + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const a = arena.allocator(); + var f: Pooled = .{ .gpa = gpa }; + var s = pc.Store.init(gpa, f.pooled(), .{ .min_prompt = 0 }, 1 << 20); + defer s.deinit(); + const sa = [_]u32{ 11, 12, 13, 14, 15, 16, 17, 18 }; + const sb = [_]u32{ 21, 22, 23, 24, 25, 26, 27, 28 }; + f.at, f.sum = .{ 4, pooledFresh(sa[0..4]) }; + try std.testing.expect(s.keep(&sa, 4, null, &.{}, &.{})); + s.remove(0); // A's page retired: its storage stays spare + try std.testing.expectEqual(@as(u64, 94), s.spare()); + f.at, f.sum = .{ 4, pooledFresh(sb[0..4]) }; + try std.testing.expect(s.keep(&sb, 4, null, &.{}, &.{})); // B's state reuses that page + try std.testing.expectEqual(@as(u64, 0), s.spare()); + // (3) the lookup for A's prefix compares tokens first: B's entry at the same position is not restored + const l = try s.lookup(a, &sa, 4, &.{}, &.{}, &.{}); + try std.testing.expect(l.entry == null); + f.at, f.sum = .{ 999, 0 }; // a restore would overwrite these + const plan = try s.begin(a, &sa, 4, &.{}, &.{}, null, &.{}); + try std.testing.expectEqual(@as(u32, 0), plan.from); + try std.testing.expectEqual(@as(u32, 999), f.at); + try std.testing.expectEqual(pooledFresh(&sa), f.pass(&s, &sa, plan)); +} diff --git a/zig/src/cuda/cublaslt.zig b/zig/src/cuda/cublaslt.zig index 95050eba0c7..8a7efd2d0e4 100644 --- a/zig/src/cuda/cublaslt.zig +++ b/zig/src/cuda/cublaslt.zig @@ -122,7 +122,7 @@ pub const Library = struct { } }; -/// One row-major bf16 product D[m,n] = X[m,k] . W[n,k]^T (a torch Linear), fp32 accumulate, bf16 or fp32 out. +/// One row-major product D[m,n] = X[m,k] . W[n,k]^T (a torch Linear), fp32 accumulate; bf16 inputs unless typed. pub const Linear = struct { lt: *const Library, handle: Handle, @@ -142,6 +142,11 @@ pub const Linear = struct { /// `init`'s plan, its algorithm also running `epilogue` when it supports it (`epilogue` says if); see `runBias`. pub fn initEpilogue(lt: *const Library, m: u64, n: u64, k: u64, out: DataType, workspace_limit: usize, epilogue: Epilogue) Error!Linear { + return initTyped(lt, m, n, k, .bf16, out, workspace_limit, epilogue); + } + + /// `initEpilogue` with X and W of type `in` (bf16, fp16, or fp32 for true fp32 products), fp32 compute. + pub fn initTyped(lt: *const Library, m: u64, n: u64, k: u64, in: DataType, out: DataType, workspace_limit: usize, epilogue: Epilogue) Error!Linear { var self: Linear = undefined; self.lt = lt; try lt.check(lt.api.cublasLtCreate(&self.handle), "cublasLtCreate"); @@ -153,9 +158,9 @@ pub const Linear = struct { try lt.check(lt.api.cublasLtMatmulDescSetAttribute(self.desc, desc_transa, &ta, @sizeOf(c_int)), "set transa"); try lt.check(lt.api.cublasLtMatmulDescSetAttribute(self.desc, desc_transb, &tb, @sizeOf(c_int)), "set transb"); // column-major view: D^T[n,m] = W[n,k] (stored k x n, transposed) . X^T[k,m] - try lt.check(lt.api.cublasLtMatrixLayoutCreate(&self.a, .bf16, k, n, @intCast(k)), "layout W"); + try lt.check(lt.api.cublasLtMatrixLayoutCreate(&self.a, in, k, n, @intCast(k)), "layout W"); errdefer _ = lt.api.cublasLtMatrixLayoutDestroy(self.a); - try lt.check(lt.api.cublasLtMatrixLayoutCreate(&self.b, .bf16, k, m, @intCast(k)), "layout X"); + try lt.check(lt.api.cublasLtMatrixLayoutCreate(&self.b, in, k, m, @intCast(k)), "layout X"); errdefer _ = lt.api.cublasLtMatrixLayoutDestroy(self.b); try lt.check(lt.api.cublasLtMatrixLayoutCreate(&self.c, out, n, m, @intCast(n)), "layout D"); errdefer _ = lt.api.cublasLtMatrixLayoutDestroy(self.c); diff --git a/zig/src/cuda/kernels.zig b/zig/src/cuda/kernels.zig index caff055d30e..858f9deda06 100644 --- a/zig/src/cuda/kernels.zig +++ b/zig/src/cuda/kernels.zig @@ -99,6 +99,7 @@ pub const glm_ops: []const u8 = if (available) &Blob("fatbin_glm_ops").bytes els pub const glm_index: []const u8 = if (available) &Blob("fatbin_glm_index").bytes else &.{}; pub const minimax_m3: []const u8 = if (available) &Blob("fatbin_minimax_m3").bytes else &.{}; pub const minimax_m3_attn: []const u8 = if (available) &Blob("fatbin_minimax_m3_attn").bytes else &.{}; +pub const idol: []const u8 = if (available) &Blob("fatbin_idol").bytes else &.{}; pub const glm_quant: []const u8 = if (available) &Blob("fatbin_glm_quant").bytes else &.{}; pub const glm_vision: []const u8 = if (available) &Blob("fatbin_glm_vision").bytes else &.{}; pub const glm_mm: []const u8 = if (available) &Blob("fatbin_glm_mm").bytes else &.{}; diff --git a/zig/src/fabric/tp/gpu_main.zig b/zig/src/fabric/tp/gpu_main.zig index 56a6ccaed45..76934d10313 100644 --- a/zig/src/fabric/tp/gpu_main.zig +++ b/zig/src/fabric/tp/gpu_main.zig @@ -166,7 +166,7 @@ const DeviceRun = struct { /// The failed-transport check's host-only forms (fail-fast off, a hold): TF_TP_ALLOW_HOST_ONLY=1 and no RDMA wire. fn hostOnlyAllowed(cfg: tp.Config) bool { - const flag = std.mem.eql(u8, std.mem.span(std.c.getenv("TF_TP_ALLOW_HOST_ONLY") orelse ""), "1"); + const flag = std.mem.eql(u8, (@import("sys").environment.Process{}).get("TF_TP_ALLOW_HOST_ONLY") orelse "", "1"); return flag and (cfg.backend != .roce or cfg.roce_wire == .shm); } diff --git a/zig/src/families/dory/cuda_native.zig b/zig/src/families/dory/cuda_native.zig index 28dcdd00ab4..032c30d5b2e 100644 --- a/zig/src/families/dory/cuda_native.zig +++ b/zig/src/families/dory/cuda_native.zig @@ -155,9 +155,9 @@ pub fn open(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: [ }; } -fn envOff(name: [*:0]const u8) bool { - const v = std.c.getenv(name) orelse return false; - return std.mem.eql(u8, std.mem.span(v), "0"); +fn envOff(name: [:0]const u8) bool { + const v = (@import("sys").environment.Process{}).get(name) orelse return false; + return std.mem.eql(u8, v, "0"); } fn gib(b: u64) f64 { diff --git a/zig/src/families/dory/names.zig b/zig/src/families/dory/names.zig index 17364e7cd0e..4aa7046b071 100644 --- a/zig/src/families/dory/names.zig +++ b/zig/src/families/dory/names.zig @@ -223,8 +223,8 @@ test "every tensor of a tiny NVFP4, MXFP8 and bf16 checkpoint maps" { } /// The checkpoint at the `env` directory: 72 sublayers, an mlp last, its end tokens. -fn pinnedMaps(env: [*:0]const u8) !void { - const dir = @import("sys").getenv(env) orelse return error.SkipZigTest; +fn pinnedMaps(env: [:0]const u8) !void { + const dir = (@import("sys").environment.Process{}).get(env) orelse return error.SkipZigTest; const c = try Config.read(testing.allocator, io, dir); var ck = try Checkpoint.openModel(testing.allocator, io, dir); defer ck.close(); diff --git a/zig/src/families/drama3/model.zig b/zig/src/families/drama3/model.zig index 7543a6a3571..5ee5ba123f4 100644 --- a/zig/src/families/drama3/model.zig +++ b/zig/src/families/drama3/model.zig @@ -7,6 +7,7 @@ pub const max_reference_samples = 30 * 44100; pub fn reference(samples: []const f32, rate: u32) !void { if (rate == 0 or rate > 192000 or samples.len == 0 or samples.len > @as(usize, rate) * 30) return error.BadReference; + if (rate / std.math.gcd(rate, @as(u32, 44100)) > 640) return error.BadReference; for (samples) |s| if (!std.math.isFinite(s)) return error.BadReference; } @@ -53,3 +54,10 @@ test "typed reference rows are bounded and agree with their semantic code" { try std.testing.expectError(error.BadCode, validate(&rows, ids, 16, 8)); try std.testing.expectError(error.BadPromptSize, validate(&rows, ids, 2, 1)); } + +test "voice reference: reduced resample width accepts standard rates and refuses pathological rates" { + for ([_]u32{ 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000 }) |rate| + try reference(&.{0}, rate); + for ([_]u32{ 44101, 44113, 191999 }) |rate| + try std.testing.expectError(error.BadReference, reference(&.{0}, rate)); +} diff --git a/zig/src/families/drama3/wav.zig b/zig/src/families/drama3/wav.zig index 494e5faea41..21c75ee2818 100644 --- a/zig/src/families/drama3/wav.zig +++ b/zig/src/families/drama3/wav.zig @@ -34,7 +34,7 @@ pub fn parse(gpa: std.mem.Allocator, bytes: []const u8) !Audio { } else if (std.mem.eql(u8, id, "data")) { data = body; } - at += 8 + len + (len & 1); + at += 8 + @as(usize, len) + (len & 1); } const d = data orelse return error.BadWav; if (channels == 0 or rate == 0) return error.BadWav; @@ -163,3 +163,21 @@ test "resampling keeps torchaudio's output length and a constant signal's level" try std.testing.expectEqual(@as(usize, 4410), y.len); for (y[200 .. y.len - 200]) |v| try std.testing.expectApproxEqAbs(@as(f32, 0.25), v, 2e-3); } + +test "voice WAV: a huge trailing chunk cannot overflow the RIFF advance" { + var bytes: [44]u8 = undefined; + header(&bytes, 44100, 0); + @memcpy(bytes[36..40], "JUNK"); + std.mem.writeInt(u32, bytes[40..44], 0xFFFFFFF8, .little); + try std.testing.expectError(error.BadWav, parse(std.testing.allocator, &bytes)); +} + +test "voice WAV: a truncated maximal data chunk is bounded by the available bytes" { + var bytes: [46]u8 = @splat(0); + header(bytes[0..44], 44100, 1); + std.mem.writeInt(u32, bytes[40..44], 0xFFFFFFFF, .little); + const audio = try parse(std.testing.allocator, &bytes); + defer audio.deinit(std.testing.allocator); + try std.testing.expectEqual(@as(usize, 1), audio.samples.len); + try std.testing.expectEqual(@as(f32, 0), audio.samples[0]); +} diff --git a/zig/src/families/flashnext/cuda_lanes_load.zig b/zig/src/families/flashnext/cuda_lanes_load.zig index 1e53ebfafb3..3ebc849aeb8 100644 --- a/zig/src/families/flashnext/cuda_lanes_load.zig +++ b/zig/src/families/flashnext/cuda_lanes_load.zig @@ -91,7 +91,7 @@ pub fn open(comptime F: type, gpa: std.mem.Allocator, io: std.Io, ctx: *const cu own.confidence = try @import("sys").environment.read(f64, "TF_FLASHNEXT_CONFIDENCE", mtp.default_confidence); } errdefer if (own.head) |h| h.deinit(); - @import("cuda_prompt_wt.zig").dropPageCache(io, dir, e.ngram.files.items); + @import("cuda_prompt_wt.zig").dropPageCache(gpa, io, dir, e.ngram.files.items); const window = @min(o.context + mtp.max_rows, prompt.max_tokens); // and an attention block's block scores at the window (64 MiB at 262,144 tokens) _ = try own.engine.reserveScores(window, @min(o.context, own.engine.chunk)); diff --git a/zig/src/families/flashnext/cuda_prompt_wt.zig b/zig/src/families/flashnext/cuda_prompt_wt.zig index 423194ba607..1c7ed4b5124 100644 --- a/zig/src/families/flashnext/cuda_prompt_wt.zig +++ b/zig/src/families/flashnext/cuda_prompt_wt.zig @@ -79,24 +79,32 @@ const Shard = struct { } fn close(self: *Shard) void { - // A shard may mix loaded tensors with the n-gram table still read at runtime. - if (!runtimePages(self.f.names.keys())) self.f.release(std.heap.page_allocator); // no keep list: scratch unused + self.drop(std.heap.page_allocator); self.f.close(self.io); } + /// The shard's pages out of the page cache, except the n-gram table's: a shard may mix both (embed, HC, MTP). + fn drop(self: *const Shard, scratch: std.mem.Allocator) void { + var keep: std.ArrayList([]const u8) = .empty; + defer keep.deinit(scratch); + for (self.f.names.keys()) |name| if (runtimePage(name)) keep.append(scratch, self.f.get(name).?.bytes) catch return; + self.f.releaseExcept(keep.items, scratch); + } + fn get(self: *const Shard, name: []const u8) ?Tensor { return self.f.get(name); } }; -fn runtimePages(names: []const []const u8) bool { - for (names) |name| if (std.mem.indexOf(u8, name, ".ple_embedding.ngram_embedding.") != null) return true; - return false; +fn runtimePage(name: []const u8) bool { + return std.mem.indexOf(u8, name, ".ple_embedding.ngram_embedding.") != null; } -/// The final load-only sweep excludes the n-gram table's live mappings. -pub fn dropPageCache(io: std.Io, dir: []const u8, keep: anytype) void { - core.checkpoint.cache.directory(io, dir, keep); +/// The final load-only sweep over the index's shards excludes the n-gram table's live mappings. +pub fn dropPageCache(gpa: std.mem.Allocator, io: std.Io, dir: []const u8, keep: anytype) void { + const paths = core.checkpoint.shardFiles(gpa, io, dir) catch return; + defer core.checkpoint.freeShardFiles(gpa, paths); + core.checkpoint.cache.shards(io, paths, keep); } pub const Store = struct { @@ -188,8 +196,8 @@ pub const Store = struct { /// Borrowers expire here; their shards stay open, pages dropped, until the load ends (or close if not kept). pub fn release(self: *Store) void { for (self.held.items) |h| { - // the borrowers' pages leave this process (their bytes are copied), except the n-gram table's (Shard.close) - if (!runtimePages(h.file.f.names.keys())) h.file.f.release(self.gpa); + // the borrowers' pages leave this process (their bytes are copied), except the n-gram table's + h.file.drop(self.gpa); self.released.append(self.gpa, h) catch { var kept = h.file; kept.close(); @@ -295,7 +303,7 @@ pub const Store = struct { } else try self.openShard(file); if (self.file) |*f| { // its pages dropped as close drops them: the n-gram table's stay - if (!runtimePages(f.f.names.keys())) f.f.release(self.gpa); + f.drop(self.gpa); self.released.appendAssumeCapacity(.{ .rel = self.rel, .file = f.* }); } self.rel = next.rel; @@ -579,6 +587,7 @@ test { } test "Flash Next load cache: a mixed PLE shard keeps its runtime pages" { - try std.testing.expect(runtimePages(&.{ "language_model.model.norm.weight", "language_model.model.layers.1.ple.ple_embedding.ngram_embedding.shards.0.weight" })); - try std.testing.expect(!runtimePages(&.{ "language_model.model.norm.weight", "language_model.mtp.norm.weight" })); + try std.testing.expect(runtimePage("language_model.model.layers.1.ple.ple_embedding.ngram_embedding.shards.0.weight")); + try std.testing.expect(!runtimePage("language_model.model.norm.weight")); + try std.testing.expect(!runtimePage("language_model.mtp.norm.weight")); } diff --git a/zig/src/families/glm/checks.zig b/zig/src/families/glm/checks.zig index 98fa944e277..c2a5799a2c0 100644 --- a/zig/src/families/glm/checks.zig +++ b/zig/src/families/glm/checks.zig @@ -6,6 +6,7 @@ const st = @import("state.zig"); const fwd = @import("forward.zig"); const mtp = @import("mtp.zig"); const prompt_mod = @import("prompt.zig"); +const tape_mod = @import("prompt_tape.zig"); const affine_mm = @import("../../core/affine_mm.zig"); const Engine = @import("engine.zig").Engine; @@ -104,11 +105,15 @@ pub fn forced(e: *Engine, prompt: []const u32, reply: []const u32) !struct { sam /// Knock-out profile: a `depth`-draft round replayed `reps` times, each launch class left out in turn; median GPU time. pub fn profile(e: *Engine, depth: u32, reps: usize, only: bool, parts: bool) !void { + const d: u32 = if (e.w.mtp == null) 0 else @min(depth, st.max_rows - 1); + if (d > 0) return profileRows(e, d, d + 1, reps, only, parts); + var it = std.mem.tokenizeScalar(u8, if (platform.c.getenv("GLM_PROFILE_ROWS")) |v| std.mem.span(v) else "1", ','); // copy windows' rows, without the MTP head + while (it.next()) |v| try profileRows(e, 0, std.math.clamp(std.fmt.parseInt(u32, v, 10) catch 1, 1, st.max_rows), reps, only, parts); +} + +fn profileRows(e: *Engine, d: u32, R: u32, reps: usize, only: bool, parts: bool) !void { const c = &e.c; const D = c.hidden; - const d: u32 = if (e.w.mtp == null) 0 else @min(depth, st.max_rows - 1); - const wide = if (platform.c.getenv("GLM_PROFILE_ROWS")) |v| std.fmt.parseInt(u32, std.mem.span(v), 10) catch 1 else 1; // a copy window's rows, without the MTP head - const R = if (d == 0) std.math.clamp(wide, 1, st.max_rows) else d + 1; const pool = mtl.objc.Pool.push(); defer pool.pop(); if (e.s.pos + R + 1 > e.s.cap) return error.ContextFull; @@ -144,6 +149,7 @@ pub fn profile(e: *Engine, depth: u32, reps: usize, only: bool, parts: bool) !vo std.mem.sort(f64, times, {}, std.sort.asc(f64)); const med = times[reps / 2]; if (mi == 0) full = med; + if (mi == 0) std.debug.print("profile {d} rows: the last MoE layer's unique experts {d}\n", .{ R, if (R == 1) 8 else Engine.u32s(e.sc.ucount, 1)[0] }); // one row: its picks (no groups) const name = if (mask == 0) (if (mi == 0) "full" else "full again") else if (mask == 0xffff_ffff) "none" else if (parts) fwd.Part.names[@ctz(mask)] else fwd.Class.names[@ctz(mask)]; std.debug.print("profile {d} rows{s}: {s:<10} {d:7.3} ms (min {d:.3}, max {d:.3}){s}", .{ R, if (only) " only" else "", name, med, times[0], times[reps - 1], if (mask == 0 or only or mask == 0xffff_ffff) "\n" else "" }); if (mask != 0 and !only and mask != 0xffff_ffff) std.debug.print(" class {d:6.3} ms {d:5.1}%\n", .{ full - med, 100 * (full - med) / full }); @@ -187,22 +193,38 @@ pub fn checkMatmul(e: *Engine, prompt: []const u32) !void { std.debug.print("matmul check (layer 0 KDA in-projection, {d} rows x {d}): {d} of {d} bf16 outputs differ ({d:.3}%), at most {d} steps\n", .{ rows, N, differ, @as(usize, rows) * N, 100 * @as(f64, @floatFromInt(differ)) / @as(f64, @floatFromInt(@as(usize, rows) * N)), worst }); } -/// Prompt chunk GPU time, median of `reps`: whole, then each class left out (alone with `only`); pairs run it together. +/// Prompt chunk GPU time, median of `reps`: whole, then each class left out (alone with `only`); GLM_PROFILE_AT=N. pub fn profilePrompt(e: *Engine, prompt: []const u32, reps: usize, only: bool, parts: bool) !void { const pr = &(e.pr orelse return error.NoPromptPath); const C = fwd.Class; - const rows: u32 = @intCast(@min(prompt.len, pr.rows)); - if (rows + 1 > e.s.cap) return error.ContextFull; + // GLM_PROFILE_AT=N: the chunk at position N, the prompt's rows before it run first (the caches a long prompt has) + const at: u32 = if (platform.c.getenv("GLM_PROFILE_AT")) |v| @intCast(@min(try std.fmt.parseInt(usize, std.mem.span(v), 10), prompt.len - 1)) else 0; + const rows: u32 = @intCast(@min(prompt.len - at, pr.rows)); + if (at + rows + 1 > e.s.cap) return error.ContextFull; const pool = mtl.objc.Pool.push(); defer pool.pop(); e.sync(); - @memcpy(Engine.u32s(e.prompt_ids, rows), prompt[0..rows]); + @memcpy(Engine.u32s(e.prompt_ids, at + rows), prompt[0 .. at + rows]); + if (at > 0) e.s.reset(); + var done: u32 = 0; + while (done < at) { // the rows before the chunk, in chunks, as a prompt pass runs them + const n = @min(pr.rows, at - done); + var x = e.ctx(); + x.sc = &pr.streams; + const b = e.begin(); + prompt_mod.backbone(pr, &x, b.enc, e.prompt_ids.at(@as(usize, done) * 4), n, done); + try e.finish(b.cb, b.enc); + fwd.flipKda(&x); + done += n; + } + const times = try e.gpa.alloc(f64, reps); + defer e.gpa.free(times); + const run: Run = .{ .e = e, .pr = pr, .rows = rows, .at = at, .times = times }; + if (parts and platform.c.getenv("GLM_PROFILE_TAPE") != null) return profileTaped(run); // routes and lists played const P = fwd.Part; - const classes = if (parts) [_]u32{ P.bit("mla_proj"), P.bit("mla_cache"), P.bit("mla_absorb"), P.bit("mla_select"), P.bit("mla_attn"), P.bit("mla_unabs"), P.bit("mla_out"), P.bit("kda_in"), P.bit("kda_pre"), P.bit("kda_scan"), P.bit("kda_post"), P.bit("kda_out") } else [_]u32{ C.hc, C.kda, C.mla, C.dense, C.route, C.routed, C.shared, C.exchange, C.combine, C.ends, 0, 0 }; + const classes = if (parts) [_]u32{ P.bit("mla_proj"), P.bit("mla_cache"), P.bit("mla_absorb"), P.bit("mla_select"), P.bit("mla_attn"), P.bit("mla_unabs"), P.bit("mla_out"), P.bit("kda_in"), P.bit("kda_pre"), P.bit("kda_scan"), P.bit("kda_post"), P.bit("kda_out"), P.bit("hc_mix"), P.bit("r_router"), P.bit("r_topk"), P.bit("e_gateup"), P.bit("e_down"), P.bit("s_gateup"), P.bit("s_down"), P.bit("combine") } else [_]u32{ C.hc, C.kda, C.mla, C.dense, C.route, C.routed, C.shared, C.exchange, C.combine, C.ends, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var all: u32 = 0; for (classes) |m| all |= m; - const times = try e.gpa.alloc(f64, reps); - defer e.gpa.free(times); var full: f64 = 0; for (0..classes.len + 3) |mi| { const mask: u32 = if (mi == 0 or mi == classes.len + 2) 0 else if (mi == classes.len + 1) all else classes[mi - 1]; @@ -211,22 +233,87 @@ pub fn profilePrompt(e: *Engine, prompt: []const u32, reps: usize, only: bool, p x.sc = &pr.streams; const m = if (mask == all) all else if (only and mask != 0) all & ~mask else mask; if (parts) x.pskip = m else x.skip = m; - for (0..reps + 1) |rep| { - e.s.reset(); - const b = e.begin(); - prompt_mod.backbone(pr, &x, b.enc, e.prompt_ids, rows, 0); - try e.finish(b.cb, b.enc); - if (rep > 0) times[rep - 1] = (e.gpu[1] - e.gpu[0]) * 1e3; - } - std.mem.sort(f64, times, {}, std.sort.asc(f64)); - const med = times[reps / 2]; + const med = try run.median(&x); if (mi == 0) full = med; const name = if (mask == 0) (if (mi == 0) "full" else "full again") else if (mask == all) "none" else if (parts) fwd.Part.names[@ctz(mask)] else fwd.Class.names[@ctz(mask)]; - std.debug.print("prompt profile {d} rows{s}: {s:<10} {d:9.2} ms (min {d:.2}, max {d:.2}){s}", .{ rows, if (only) " only" else "", name, med, times[0], times[reps - 1], if (mask == 0 or only or mask == all) "\n" else "" }); + std.debug.print("prompt profile {d} rows at {d}{s}: {s:<10} {d:9.2} ms (min {d:.2}, max {d:.2}){s}", .{ rows, at, if (only) " only" else "", name, med, times[0], times[reps - 1], if (mask == 0 or only or mask == all) "\n" else "" }); if (mask != 0 and !only and mask != all) std.debug.print(" class {d:8.2} ms {d:5.1}%\n", .{ full - med, 100 * (full - med) / full }); } } +/// One profiled chunk: the median GPU time of a pass over it. +const Run = struct { + e: *Engine, + pr: *const prompt_mod.Prompt, + rows: u32, + at: u32, + times: []f64, + + fn median(r: Run, x: *fwd.Ctx) !f64 { + for (0..r.times.len + 1) |rep| { + if (r.at == 0) r.e.s.reset(); // later chunks keep the caches (each rep reads and writes the same rows) + const b = r.e.begin(); + prompt_mod.backbone(r.pr, x, b.enc, r.e.prompt_ids.at(@as(usize, r.at) * 4), r.rows, r.at); + try r.e.finish(b.cb, b.enc); + if (rep > 0) r.times[rep - 1] = (r.e.gpu[1] - r.e.gpu[0]) * 1e3; + } + std.mem.sort(f64, r.times, {}, std.sort.asc(f64)); + return r.times[r.times.len / 2]; + } +}; + +/// GLM_PROFILE_TAPE: parts against a pass whose routes and key lists play back from a recorded whole pass. +fn profileTaped(r: Run) !void { + const e = r.e; + const c = &e.c; + var moes: u32 = 0; + for (e.w.layers[0..c.run]) |*l| moes += @intFromBool(l.mlp == .moe); + var t = try tape_mod.Tape.init(&e.arena, moes, c.countKind(.mla), r.rows, c.topk, c.experts, c.keyWidth()); + const pr: *prompt_mod.Prompt = @constCast(r.pr); + pr.tape = &t; + defer pr.tape = null; + const P = fwd.Part; + const parts = [_]u32{ P.bit("mla_proj"), P.bit("mla_cache"), P.bit("mla_absorb"), P.bit("mla_select"), P.bit("mla_attn"), P.bit("mla_unabs"), P.bit("mla_out"), P.bit("kda_in"), P.bit("kda_pre"), P.bit("kda_scan"), P.bit("kda_post"), P.bit("kda_out"), P.bit("hc_mix"), P.bit("r_router"), P.bit("r_topk"), P.bit("e_gateup"), P.bit("e_down"), P.bit("s_gateup"), P.bit("s_down"), P.bit("combine") }; + var all: u32 = 0; + for (parts) |m| all |= m; + const M = tape_mod.Mode; + const Step = struct { name: []const u8, skip: u32 = 0, route: M = .play, keys: M = .play }; + var steps: [parts.len + 6]Step = undefined; + steps[0] = .{ .name = "full", .route = .off, .keys = .off }; + steps[1] = .{ .name = "taped" }; + steps[2] = .{ .name = "route", .route = .off }; + steps[3] = .{ .name = "select", .keys = .off }; + for (parts, 0..) |m, i| steps[4 + i] = .{ .name = P.names[@ctz(m)], .skip = m }; + steps[parts.len + 4] = .{ .name = "none", .skip = all }; + steps[parts.len + 5] = .{ .name = "full again", .route = .off, .keys = .off }; + { // the tape: one whole pass recorded + var x = e.ctx(); + x.sc = &pr.streams; + t.route_mode = .record; + t.keys_mode = .record; + if (r.at == 0) e.s.reset(); + const b = e.begin(); + prompt_mod.backbone(pr, &x, b.enc, e.prompt_ids.at(@as(usize, r.at) * 4), r.rows, r.at); + try e.finish(b.cb, b.enc); + } + var base: f64 = 0; + var full: f64 = 0; + for (steps, 0..) |st_, i| { + var x = e.ctx(); + x.sc = &pr.streams; + x.pskip = st_.skip; + t.route_mode = st_.route; + t.keys_mode = st_.keys; + const med = try r.median(&x); + if (i == 0) full = med; + if (i == 1) base = med; + std.debug.print("prompt profile {d} rows at {d} taped: {s:<10} {d:9.2} ms (min {d:.2}, max {d:.2})", .{ r.rows, r.at, st_.name, med, r.times[0], r.times[r.times.len - 1] }); + const d = if (i == 2 or i == 3) med - base else base - med; // live parts add, knock-outs take away + if (i >= 2 and i < steps.len - 2) std.debug.print(" part {d:8.2} ms {d:5.1}%", .{ d, 100 * d / full }); + std.debug.print("\n", .{}); + } +} + /// Per-token loss via the prompt path in `rows`-row chunks: the head over every row, -log p(ids[i + 1]) into out[i]. pub fn promptNll(e: *Engine, ids: []const u32, rows: u32, out: []f32) !void { const c = &e.c; diff --git a/zig/src/families/glm/cuda_engine_prof.zig b/zig/src/families/glm/cuda_engine_prof.zig index 925aade490c..8b3bbe479fd 100644 --- a/zig/src/families/glm/cuda_engine_prof.zig +++ b/zig/src/families/glm/cuda_engine_prof.zig @@ -13,8 +13,7 @@ pub fn freeProfs(e: *Engine) void { } pub fn heatRoot() []const u8 { - const p = std.c.getenv("TF_HEAT_ROOT") orelse return @import("heat").default_root; - const s = std.mem.span(p); + const s = (@import("sys").environment.Process{}).get("TF_HEAT_ROOT") orelse return @import("heat").default_root; return if (s.len == 0) @import("heat").default_root else s; } diff --git a/zig/src/families/glm/cuda_env_test.zig b/zig/src/families/glm/cuda_env_test.zig index a74685852f0..4d601ab113e 100644 --- a/zig/src/families/glm/cuda_env_test.zig +++ b/zig/src/families/glm/cuda_env_test.zig @@ -22,6 +22,7 @@ const reals = [_][:0]const u8{"TF_GLM_DRAFT_CONFIDENCE"}; /// The window GLM may serve past config.json's: GLM's raisedCeiling reads it at the open, after these rows' check. const windows = [_][:0]const u8{"TF_GLM_CONTEXT_CEILING"}; const words = [_][:0]const u8{"TF_GLM_EXPERT_FORM"}; +const added = [_][:0]const u8{ "TF_GLM_INDEX_CUDA", "TF_GLM_KV_HOST_GIB", "TF_GLM_RANK", "TF_GLM_WORLD" }; /// The row by name without `rule`, so a missing row fails an assertion instead of panicking. fn row(name: []const u8) !e.Rule { @@ -60,12 +61,13 @@ test "GLM strict env: every GLM reader's name is a glm row, and the glm scope ho for (reals) |name| try t.expectEqual(e.Kind.real, (try row(name)).kind); for (windows) |name| try t.expectEqual(e.Kind.u64, (try row(name)).kind); for (words) |name| try t.expectEqual(e.Kind.word, (try row(name)).kind); + for (added) |name| try t.expect((try row(name)).kind != .flag); var n: usize = 0; for (e.rules) |r| if (r.scope == .glm) { try t.expect(std.mem.startsWith(u8, r.name, "TF_GLM_")); n += 1; }; - try t.expectEqual(switches.len + counts.len + reals.len + windows.len + words.len, n); + try t.expectEqual(switches.len + counts.len + reals.len + windows.len + words.len + added.len, n); } test "GLM strict env: the expert form takes classic or factored, leaves blank to the race, and refuses the rest by name" { diff --git a/zig/src/families/glm/cuda_index.zig b/zig/src/families/glm/cuda_index.zig index 4dd75d770f3..542822b9f67 100644 --- a/zig/src/families/glm/cuda_index.zig +++ b/zig/src/families/glm/cuda_index.zig @@ -23,16 +23,17 @@ pub const Mode = enum { scores, pub fn parse(text: ?[]const u8) !Mode { - const t = text orelse return .both; - if (std.mem.trim(u8, t, " \t\r\n").len == 0 or std.mem.eql(u8, t, "1")) return .both; - if (std.mem.eql(u8, t, "0")) return .off; - if (std.mem.eql(u8, t, "scores")) return .scores; - return error.BadIndexMode; + const n = try @import("sys").environment.value(u32, "TF_GLM_INDEX_CUDA", text, 0); + return switch (n) { + 0 => .both, + 1 => .off, + 2 => .scores, + else => unreachable, + }; } pub fn read() !Mode { - const v = std.c.getenv("TF_GLM_INDEX_CUDA") orelse return .both; - return parse(std.mem.span(v)); + return parse((@import("sys").environment.Process{}).get("TF_GLM_INDEX_CUDA")); } }; @@ -103,8 +104,8 @@ test "GLM index: TF_GLM_INDEX_CUDA is on unless 0, scores bisects, and a typo is try std.testing.expectEqual(Mode.both, try Mode.parse("1")); try std.testing.expectEqual(Mode.off, try Mode.parse("0")); try std.testing.expectEqual(Mode.scores, try Mode.parse("scores")); - try std.testing.expectError(error.BadIndexMode, Mode.parse("on")); - try std.testing.expectError(error.BadIndexMode, Mode.parse("off")); + try std.testing.expectError(error.InvalidEnvironment, Mode.parse("on")); + try std.testing.expectError(error.InvalidEnvironment, Mode.parse("off")); } test "GLM index: the scores grid covers 8 rows a CTA and 16 pool blocks a CTA" { diff --git a/zig/src/families/glm/cuda_kv_host.zig b/zig/src/families/glm/cuda_kv_host.zig index 852db4dab75..6866d0d78cb 100644 --- a/zig/src/families/glm/cuda_kv_host.zig +++ b/zig/src/families/glm/cuda_kv_host.zig @@ -26,8 +26,8 @@ fn pagesOf(gib: ?f64, page: u64, capacity: usize) usize { /// TF_GLM_KV_HOST_GIB's host pages, else one full window's. pub fn hostPages(page: u64, capacity: usize) usize { - const v = std.c.getenv("TF_GLM_KV_HOST_GIB") orelse return pagesOf(null, page, capacity); - return pagesOf(std.fmt.parseFloat(f64, std.mem.span(v)) catch null, page, capacity); + const gib = @import("sys").environment.read(?f64, "TF_GLM_KV_HOST_GIB", null) catch null; + return pagesOf(gib, page, capacity); } /// The plan's `pages` (counted by their device keys alone), held to the host pages when the pages are in host memory. diff --git a/zig/src/families/glm/cuda_l2pf.zig b/zig/src/families/glm/cuda_l2pf.zig index c5fefb0216b..9cdfda0e0f3 100644 --- a/zig/src/families/glm/cuda_l2pf.zig +++ b/zig/src/families/glm/cuda_l2pf.zig @@ -100,7 +100,10 @@ fn sources(l: weights.Layer, site: Site) Sources { }, }, .f => switch (l.ffn) { - .moe => |m| s.add(m.router), + .moe => |m| { + s.add(m.router); + s.proj(m.shared_gu); // read after the routed experts, which no table holds (the router picks them) + }, .dense => |m| switch (m.w) { .nvfp4 => |x| { s.lane(x.gate); @@ -310,10 +313,11 @@ test "the table: each site's sources in its matmuls' order, site n from the next d.mixer.mla.q_b = .{ .bf16 = 0x7000_0000 }; d.ffn = .{ .dense = undefined }; d.ffn.dense.w = .{ .bf16 = .{ .gu = 0x9000_0000, .down = 0xa000_0000 } }; - var e: weights.Layer = undefined; // layer 1: KDA on the lane and MoE + var e: weights.Layer = undefined; // layer 1: KDA on the lane and MoE, its shared expert block FP8 on the lane e.mixer = .{ .kda = k }; e.ffn = .{ .moe = undefined }; e.ffn.moe.router = 0x5000_0000; + e.ffn.moe.shared_gu = .{ .fp8g = .{ .mode = .fp8g, .codes = 0xb000_0000, .scales = 0x8000_0000, .n = 64, .k = 64, .npad = 64 } }; const MiB = 1 << 20; var bufs = [_]cuda.DeviceBuffer{ .{ .d = undefined, .ptr = 0x1000_0000, .len = 1 * MiB }, @@ -324,6 +328,8 @@ test "the table: each site's sources in its matmuls' order, site n from the next .{ .d = undefined, .ptr = 0x6000_0000, .len = 16 * MiB }, .{ .d = undefined, .ptr = 0x7000_0000, .len = 17 * MiB }, .{ .d = undefined, .ptr = 0x9000_0000, .len = 34 * MiB }, + .{ .d = undefined, .ptr = 0x8000_0000, .len = 1 * MiB }, + .{ .d = undefined, .ptr = 0xb000_0000, .len = 16 * MiB }, }; var rows: std.ArrayList([2]i64) = .empty; defer rows.deinit(t.allocator); @@ -333,8 +339,10 @@ test "the table: each site's sources in its matmuls' order, site n from the next .{ 0x1000_0000, 1 * MiB }, // layer 0's n: layer 1's qkv scales whole, then its codes' head .{ 0x2000_0000, 11 * MiB }, .{ 0x9000_0000, 12 * MiB }, // layer 0's f: its gate and up's head - .{ 0x5000_0000, 2 * MiB }, // layer 1's f: its router; its n would be the head's, its o is KDA's o - .{ 0x4000_0000, 12 * MiB }, + .{ 0x5000_0000, 2 * MiB }, // layer 1's f: its router, then its shared gate-up's scales and its codes' head + .{ 0x8000_0000, 1 * MiB }, + .{ 0xb000_0000, 9 * MiB }, + .{ 0x4000_0000, 12 * MiB }, // layer 1's o, KDA's o; its n would be the head's }; try t.expectEqualSlices([2]i64, &want, rows.items); try t.expectEqualSlices(Span, &.{ @@ -342,8 +350,8 @@ test "the table: each site's sources in its matmuls' order, site n from the next .{ .at = 2, .rows = 1, .bytes = 12 * MiB }, .{ .at = 3 }, // DSA: no site o .{ .at = 3 }, - .{ .at = 3, .rows = 1, .bytes = 2 * MiB }, - .{ .at = 4, .rows = 1, .bytes = 12 * MiB }, + .{ .at = 3, .rows = 3, .bytes = 12 * MiB }, + .{ .at = 6, .rows = 1, .bytes = 12 * MiB }, }, &spans); rows.clearRetainingCapacity(); try t.expect(!try table(t.allocator, bufs[1..], &.{ d, e }, 12 * MiB, &rows, &spans)); diff --git a/zig/src/families/glm/cuda_native.zig b/zig/src/families/glm/cuda_native.zig index 0aef928c1d5..e933c6b4c81 100644 --- a/zig/src/families/glm/cuda_native.zig +++ b/zig/src/families/glm/cuda_native.zig @@ -134,10 +134,10 @@ pub fn kvPool(p: *anyopaque) ?kv.Source { pub const Place = struct { rank: usize, world: usize }; pub fn place() !Place { - const r = std.c.getenv("TF_GLM_RANK") orelse return error.NoRank; - const w = std.c.getenv("TF_GLM_WORLD") orelse return error.NoRank; - const p: Place = .{ .rank = std.fmt.parseInt(usize, std.mem.span(r), 10) catch return error.NoRank, .world = std.fmt.parseInt(usize, std.mem.span(w), 10) catch return error.NoRank }; - return checked(p); + const settings = @import("sys").environment; + const r = (try settings.read(?u64, "TF_GLM_RANK", null)) orelse return error.NoRank; + const w = (try settings.read(?u64, "TF_GLM_WORLD", null)) orelse return error.NoRank; + return checked(.{ .rank = @intCast(r), .world = @intCast(w) }); } /// A place the family serves: a rank inside its world, and at most `ranks.max_world` ranks. @@ -199,7 +199,7 @@ pub fn open(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: [ try @import("cuda_env.zig").startup(); try @import("cuda_env.zig").requestStartsAlone(o.learn_conversations); // before any rank opens const p = try place(); - const roce_bytes = try roceBytes(if (std.c.getenv("TF_ROCE_MAX_KB")) |v| std.mem.span(v) else null); + const roce_bytes = try roceBytes((@import("sys").environment.Process{}).get("TF_ROCE_MAX_KB")); if (p.world > 1 and std.c.getenv("NCCL_COMM_ID") == null) return error.NoCommId; var problem: []const u8 = ""; var set = ranks.Settings.read(&ranks.environment, &problem) catch |err| { @@ -208,7 +208,7 @@ pub fn open(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: [ }; try @import("cuda_roce_multi.zig").validate(p.world, p.rank, set.roce_multi); set.kv8 = o.kv8; - if (share_mod.moved(if (std.c.getenv("TF_GLM_KV_SHARE")) |v| std.mem.span(v) else "")) return error.GlmKvShareMoved; // before any rank opens + if (share_mod.moved((@import("sys").environment.Process{}).get("TF_GLM_KV_SHARE") orelse "")) return error.GlmKvShareMoved; // before any rank opens const share_snaps = try kp.sharing(); if (share_mod.tooMany(share_snaps)) { std.log.err("TF_KV_SHARE={d} asks more kept states than the {d} it keeps: set {d} or fewer", .{ share_snaps, kv.most_snaps, kv.most_snaps }); diff --git a/zig/src/families/glm/cuda_roce_multi.zig b/zig/src/families/glm/cuda_roce_multi.zig index eb116a5c2db..d5d6a7122d9 100644 --- a/zig/src/families/glm/cuda_roce_multi.zig +++ b/zig/src/families/glm/cuda_roce_multi.zig @@ -32,7 +32,7 @@ fn fallsBack(err: anyerror, entered: bool) bool { /// fabric/tp's bootstrap, ports, wire and kernel, and a probe against the group's NCCL: each step every rank's or none. fn borrow(gpa: std.mem.Allocator, io: std.Io, d: *const cuda.Driver, g: *const Group, cfg: tp.Config, entered: *bool) !*Wire { - const path = std.mem.span(std.c.getenv("TF_TP_KERNEL_IMAGE") orelse return error.NoKernelImage); + const path = (@import("sys").environment.Process{}).get("TF_TP_KERNEL_IMAGE") orelse return error.NoKernelImage; const image = try std.Io.Dir.cwd().readFileAllocOptions(io, path, gpa, .limited(1 << 26), .@"16", null); defer gpa.free(image); // the module copies it at load var b = try tp.Bootstrap.open(cfg); diff --git a/zig/src/families/glm/dense_attn.zig b/zig/src/families/glm/dense_attn.zig new file mode 100644 index 00000000000..3ba08046c0c --- /dev/null +++ b/zig/src/families/glm/dense_attn.zig @@ -0,0 +1,54 @@ +//! GLM-5.3-Flash's latent attention for rows whose keys all fit index_topk: every key, the 64 heads as one matrix. +const std = @import("std"); +const mtl = @import("metal"); +const fwd = @import("forward.zig"); +const Ref = @import("weights.zig").Ref; +const Ctx = fwd.Ctx; +const bind = fwd.bind; +const shape = fwd.shape; +const size = fwd.size; + +/// One row's 64 heads over keys [0, n) as one 64-row matrix against the latent keys: scores, a precise softmax, values. +pub fn attendDense(x: *const Ctx, e: mtl.ComputeEncoder, keys: Ref, q: Ref, scores: Ref, probs: Ref, out: Ref, n: u32) void { + const k = x.k; + const H = x.c.mla_heads; + e.setPipeline(k.latent_scores); + bind(e, 0, .{ q, keys, scores }); + e.setValue([2]i32{ @intCast(n), @intFromBool(n < 256) }, 3); // fewer than 256 keys: the 512 dims in two halves + e.dispatchGroups(size((n + 31) / 32, 1, 1), size(2 * H, 1, 1)); // a simdgroup each 16 heads + e.setPipeline(k.softmax); + bind(e, 0, .{scores}); + shape(e, 1, .{n}); + bind(e, 2, .{probs}); + e.dispatchGroups(size(H, 1, 1), size(((n + 3) / 4 + 31) / 32 * 32, 1, 1)); + e.setPipeline(k.latent_values); + bind(e, 0, .{ probs, keys, out }); + e.setValue([2]i32{ @intCast(n), if (n > 1024) 1024 else 0 }, 3); // past 1,024 keys: the first 1,024 apart + e.dispatchGroups(size(x.c.kv_lora / 32, 1, 1), size(2 * H, 1, 1)); +} + +/// glm_attn.metal's GlmAttnRows: the first row's keys, the rows' strides, the queries' scale (the scores kernel's). +const RowArgs = extern struct { n0: i32, q_stride: i32, s_stride: i32, o_stride: i32, q_scale: f32 }; + +/// `rows` rows (keys n0, n0 + 1, ..) as attendDense leaves them on `q` times `q_scale` (a power of two), 3 launches. +pub fn attendRows(x: *const Ctx, e: mtl.ComputeEncoder, keys: Ref, q: Ref, q_scale: f32, scores: Ref, probs: Ref, out: Ref, n0: u32, rows: u32) void { + const k = x.k; + const H = x.c.mla_heads; + const lat: i32 = @intCast(H * x.c.kv_lora); // a row's latent queries and outputs + const plane: i32 = @intCast(H * x.c.i_topk); // and its scores + const n_max = n0 + rows - 1; + const args = RowArgs{ .n0 = @intCast(n0), .q_stride = lat, .s_stride = plane, .o_stride = lat, .q_scale = q_scale }; + e.setPipeline(k.latent_scores_rows); + bind(e, 0, .{ q, keys, scores }); + e.setBytes(std.mem.asBytes(&args), 3); + e.dispatchGroups(size((n_max + 31) / 32, H / 16, rows), size(32, 1, 1)); // a simdgroup each 16 heads + e.setPipeline(k.softmax_rows); + bind(e, 0, .{scores}); + e.setValue([2]i32{ @intCast(n0), plane }, 1); + bind(e, 2, .{probs}); + e.dispatchGroups(size(H, rows, 1), size(((n_max + 3) / 4 + 31) / 32 * 32, 1, 1)); + e.setPipeline(k.latent_values_rows); + bind(e, 0, .{ probs, keys, out }); + e.setBytes(std.mem.asBytes(&args), 3); + e.dispatchGroups(size(x.c.kv_lora / 32, H / 16, rows), size(32, 1, 1)); +} diff --git a/zig/src/families/glm/forward.zig b/zig/src/families/glm/forward.zig index 82c5db3158b..834ae3c3696 100644 --- a/zig/src/families/glm/forward.zig +++ b/zig/src/families/glm/forward.zig @@ -13,6 +13,7 @@ const wide = @import("wide.zig"); const Ref = wts.Ref; /// The MoE block (moe.zig). pub const moe = @import("moe.zig").moe; +const moeBlock = @import("moe.zig").block; pub const Ctx = struct { k: *const Kernels, @@ -33,10 +34,11 @@ pub const Ctx = struct { segs: []const Seg = &.{}, // a shared window's streams in row order (empty: every row is `s`'s) inject: ?*const Inject = null, // a prompt pass's image rows over its placeholder embeddings draws: ?*const Draws = null, // the rows' draw rules in row order (null: every row draws greedily) + moe_branch: bool = false, // the pending branch is the last MoE block's ye and wts: the next expand combines them + q_normed: bool = false, // mlaKeys normed the rows' queries into qr (with the cache writes): mlaAttend's projection next }; -/// An image prompt's tower output: prompt rows [at, at + n) of each span embed as rows [row, row + n) of `rows`. -pub const Inject = struct { rows: Ref, spans: []const Span }; +pub const Inject = struct { rows: Ref, spans: []const Span }; // tower rows: [at,at+n) -> [row,row+n) pub const Span = struct { at: u32, n: u32, row: u32 }; /// The image rows among `rows` embedding rows (positions pos..) written over `out`; nothing without an injection. @@ -127,6 +129,10 @@ pub fn snap(x: *Ctx, e: mtl.ComputeEncoder, src: Ref, plane: usize) void { } pub const Rows = extern struct { rows: i32, width: i32, x_stride: i32, y_stride: i32, eps: f32 }; +/// glm_mla_norms' arguments: an x_proj row's offsets and widths of the three parts, their eps and the weights' scale. +const MlaNorms = extern struct { x_stride: u32, kv_at: u32, ik_at: u32, iw_at: u32, kv_width: u32, ik_width: u32, iw_width: u32, q_width: u32, kv_eps: f32, ik_eps: f32, iw_scale: f32, q_eps: f32 }; +/// The indexer weights' scale (exact: a power of two). +const index_weight_scale: f32 = 1.0 / 64.0; const ScoreArgs = extern struct { p0: u32, q_stride: u32, w_stride: u32, s_stride: u32, rows: u32 }; const SelectArgs = extern struct { p0: u32, top: u32, width: u32, s_stride: u32, i_stride: u32 }; @@ -198,6 +204,9 @@ pub fn embedRows(x: *const Ctx, e: mtl.ComputeEncoder, ids: Ref, out: Ref, rows: pub fn boundary(x: *Ctx, e: mtl.ComputeEncoder, rows: u32, pending: bool, hc: ?wts.Hc, norm: ?Ref) void { const sc = x.sc; const k = x.k; + const moe_branch = x.moe_branch; // the MoE block's combine in the expand (glm's combine kernel's bits) + x.moe_branch = false; + std.debug.assert(!moe_branch or (pending and hc != null and !hc_core.inPlace(sc.x[0], sc.x[1]))); const h = hc orelse { // the last boundary: the pending branch written into the streams alone if (pending and on(x, "hc_expand") and hc_core.inPlace(sc.x[0], sc.x[1])) { hc_core.expandInPlace(e, k.hc_core, hc_shape, rows, sc.x[0], sc.branch, sc.post, sc.comb); @@ -211,7 +220,7 @@ pub fn boundary(x: *Ctx, e: mtl.ComputeEncoder, rows: u32, pending: bool, hc: ?w if (pending) x.xi = 1 - x.xi; return; }; - if (on(x, "hc_mix")) hc_core.boundary(e, k.hc_core, hc_shape, pending, rows, x.c.eps, .{ .x_old = sc.x[x.xi], .branch = sc.branch, .post = sc.post, .comb = sc.comb, .fn_packed = h.fnp, .x_new = sc.x[1 - x.xi], .part = sc.mixes, .scale = h.scale, .base = h.base, .norm = norm.?, .normed = sc.normed }); + if (on(x, "hc_mix")) hc_core.boundary(e, k.hc_core, hc_shape, pending, rows, x.c.eps, .{ .x_old = sc.x[x.xi], .branch = if (moe_branch) sc.ye else sc.branch, .post = sc.post, .comb = sc.comb, .fn_packed = h.fnp, .x_new = sc.x[1 - x.xi], .part = sc.mixes, .scale = h.scale, .base = h.base, .norm = norm.?, .normed = sc.normed, .wts = if (moe_branch) sc.wts else null }); if (pending) x.xi = 1 - x.xi; } @@ -252,17 +261,25 @@ pub fn kdaStep(x: *const Ctx, e: mtl.ComputeEncoder, ki: usize, w: *const wts.Kd fb = .{ f, f, f }; gb = .{ g, g, g }; } + // An Ultra's GPU, 2+ rows: each head on two threadgroups (raw outputs, gates in gu), then each row's head normed + const parts = gate == .generated and x.k.kda_split and c.tp == 1 and rows > 1; e.setPipeline(switch (gate) { - .generated => if (c.tp > 1) x.k.kda_rows_tp else x.k.kda_rows, + .generated => if (parts) x.k.kda_parts else if (rows > 1) (if (c.tp > 1) x.k.kda_window_tp else x.k.kda_window) else if (c.tp > 1) x.k.kda_rows_tp else x.k.kda_rows, .pre, .fused => |p| p, }); bind(e, 0, .{proj}); shape(e, 1, .{ rows, c.kdaProj() }); - bind(e, 2, .{ L.cs[cur], w.conv_w, fb[0], fb[1], fb[2], gb[0], gb[1], gb[2], w.a, w.dt_bias, L.st[cur], w.o_norm }); + bind(e, 2, .{ L.cs[cur], w.conv_w, fb[0], fb[1], fb[2], gb[0], gb[1], gb[2], w.a, w.dt_bias, L.st[cur], if (parts) x.sc.gu else w.o_norm }); e.setValue(c.lower_bound, 14); e.setValue(c.eps, 15); bind(e, 16, .{ y, L.st[1 - cur], L.cs[1 - cur] }); - e.dispatchThreads(size(32, 32, c.kda_heads), size(32, 32, 1)); + e.dispatchThreads(size(32, 32, c.kda_heads), size(32, if (parts) 16 else 32, 1)); + if (!parts) return; + std.debug.assert(c.kda_heads == 64); + e.setPipeline(x.k.kda_norm); + bind(e, 0, .{ y, x.sc.gu, w.o_norm }); + e.setValue(c.eps, 3); + e.dispatchGroups(size(c.kda_heads / 8, rows, 1), size(256, 1, 1)); } /// MLA layer `mi` (its index among MLA caches) for rows at positions pos.. on `x_in`, into `branch`. @@ -277,9 +294,11 @@ pub fn mlaKeys(x: *Ctx, e: mtl.ComputeEncoder, mi: usize, w: *const wts.Mla, x_i const sc = x.sc; var one: [1]Seg = undefined; if (on(x, "mla_proj")) qmv(x, e, x.k.qmv_x, x_in, w.x_proj, sc.xp, rows); + x.q_normed = on(x, "mla_proj") and on(x, "mla_cache"); // the queries' norm in the cache writes' launch if (on(x, "mla_cache")) for (segments(x, rows, pos, &one)) |g| { const y = withState(x, g); - mlaCache(&y, e, mi, w, x_in.at(@as(usize, g.row0) * c.hidden * 2), sc.xp.at(@as(usize, g.row0) * c.xProj() * 2), c.xProj(), sc.iw.at(@as(usize, g.row0) * c.i_heads * 2), g.rows, g.pos); + const qr = if (x.q_normed) sc.qr.at(@as(usize, g.row0) * c.q_lora * 2) else null; + mlaCache(&y, e, mi, w, x_in.at(@as(usize, g.row0) * c.hidden * 2), sc.xp.at(@as(usize, g.row0) * c.xProj() * 2), c.xProj(), sc.iw.at(@as(usize, g.row0) * c.i_heads * 2), qr, g.rows, g.pos); }; } @@ -290,9 +309,10 @@ pub fn mlaAttend(x: *Ctx, e: mtl.ComputeEncoder, mi: usize, w: *const wts.Mla, r const sc = x.sc; var one: [1]Seg = undefined; if (on(x, "mla_proj")) { - rms(x, e, sc.xp, w.q_norm, sc.qr, rows, c.q_lora, c.xProj(), c.q_lora, c.eps); + if (!x.q_normed) rms(x, e, sc.xp, w.q_norm, sc.qr, rows, c.q_lora, c.xProj(), c.q_lora, c.eps); qmv(x, e, if (c.tp > 1) k.qmv_qr_tp else k.qmv_qr, sc.qr, w.qr_proj, sc.qp, rows); } + x.q_normed = false; if (on(x, "mla_absorb")) absorb(x, e, w, sc.qp, sc.ql, rows); for (segments(x, rows, pos, &one)) |g| attend(&withState(x, g), e, mi, g); if (on(x, "mla_unabs")) unabsorb(x, e, w, sc.att, sc.vals, rows); @@ -305,7 +325,7 @@ pub fn mlaAttend(x: *Ctx, e: mtl.ComputeEncoder, mi: usize, w: *const wts.Mla, r /// Rows' indexer weights from their x_proj outputs (a row `xp_stride` apart), into `iw`. pub fn indexWeights(x: *const Ctx, e: mtl.ComputeEncoder, xp: Ref, xp_stride: u32, iw: Ref, rows: u32) void { const c = x.c; - scale(x, e, xp.at((c.q_lora + c.kv_lora + c.i_dim) * 2), iw, rows, c.i_heads, xp_stride, c.i_heads, 1.0 / 64.0); + scale(x, e, xp.at((c.q_lora + c.kv_lora + c.i_dim) * 2), iw, rows, c.i_heads, xp_stride, c.i_heads, index_weight_scale); } /// One stream's rows over its own cache: rows whose keys all fit index_topk attend every key (MLX's unfused attention). @@ -317,29 +337,22 @@ fn attend(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, g: Seg) void { const lat = @as(usize, H) * RANK * 2; // a row's latent queries var dense: u32 = 0; while (dense < g.rows and g.pos + dense + 1 <= c.i_topk) dense += 1; - if (on(x, "mla_absorb") and dense > 0) scale(x, e, sc.ql.at(g.row0 * lat), sc.qls.at(g.row0 * lat), dense * H, RANK, RANK, RANK, 1.0 / 16.0); if (!on(x, "mla_attn")) return; const plane = @as(usize, H) * c.i_topk * 2; - for (0..dense) |ri| { - const r: usize = g.row0 + ri; - attendDense(x, e, x.s.mla[mi].keys, sc.qls.at(r * lat), sc.scores.at(r * plane), sc.probs.at(r * plane), sc.att.at(r * lat), g.pos + @as(u32, @intCast(ri)) + 1); - } + const r: usize = g.row0; + if (dense > 0) attendRows(x, e, x.s.mla[mi].keys, sc.ql.at(r * lat), 1.0 / 16.0, sc.scores.at(r * plane), sc.probs.at(r * plane), sc.att.at(r * lat), g.pos + 1, dense); if (dense < g.rows) attendSparse(x, e, mi, g, dense); } -/// Rows' latent keys, indexer keys, gates to cache `mi` at pos..; indexer weights to `iw`; the blocks they complete. -pub fn mlaCache(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, w: *const wts.Mla, x_in: Ref, xp: Ref, xp_stride: u32, iw: Ref, rows: u32, pos: u32) void { +/// Rows' latent keys and indexer keys and gates to cache `mi` at pos.., weights to `iw` (`qr`: queries), the pools. +pub fn mlaCache(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, w: *const wts.Mla, x_in: Ref, xp: Ref, xp_stride: u32, iw: Ref, qr: ?Ref, rows: u32, pos: u32) void { const c = x.c; const k = x.k; const C = &x.s.mla[mi]; const RANK = c.kv_lora; - rms(x, e, xp.at(c.q_lora * 2), w.kv_norm, C.keys.at(@as(usize, pos) * RANK * 2), rows, RANK, xp_stride, RANK, c.eps); - e.setPipeline(k.layer_norm); - bind(e, 0, .{ xp.at((c.q_lora + RANK) * 2), w.k_norm_w, w.k_norm_b, C.ik.at(@as(usize, pos) * c.i_dim * 2) }); - e.setValue(Rows{ .rows = @intCast(rows), .width = @intCast(c.i_dim), .x_stride = @intCast(xp_stride), .y_stride = @intCast(c.i_dim), .eps = 1e-6 }, 4); - e.dispatchGroups(size(rows, 1, 1), size(32, 1, 1)); - moe_route.logits(e, k.igate_logits, @import("kernels.zig").igate_shape, x_in, w.igate, C.ig.at(@as(usize, pos) * c.i_dim * 2), rows); // MLX's gemv_t sums, more threadgroups - indexWeights(x, e, xp, xp_stride, iw, rows); + mlaNorms(k, c, e, w, xp, xp_stride, C.keys.at(@as(usize, pos) * RANK * 2), C.ik.at(@as(usize, pos) * c.i_dim * 2), iw, qr, rows); + const ig = if (rows == 1) k.igate_logits_one else k.igate_logits; // MLX's gemv_t sums, more threadgroups + moe_route.logits(e, ig, @import("kernels.zig").igate_shape, x_in, w.igate, C.ig.at(@as(usize, pos) * c.i_dim * 2), rows); const first = pos / c.kpool; const last = (pos + rows) / c.kpool; if (last > first) { @@ -350,6 +363,17 @@ pub fn mlaCache(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, w: *const wts.M } } +/// Rows' kv norm, key norm, index weights (and `qr`: query norm) from x_proj in one launch (glm_mla_norms), same bits. +pub fn mlaNorms(k: *const Kernels, c: *const cfg.Config, e: mtl.ComputeEncoder, w: *const wts.Mla, xp: Ref, xp_stride: u32, keys: Ref, ik: Ref, iw: Ref, qr: ?Ref, rows: u32) void { + const R = c.kv_lora; + e.setPipeline(k.mla_norms); + bind(e, 0, .{ xp, w.kv_norm, keys, w.k_norm_w, w.k_norm_b, ik, iw }); + e.setValue(MlaNorms{ .x_stride = xp_stride, .kv_at = c.q_lora, .ik_at = c.q_lora + R, .iw_at = c.q_lora + R + c.i_dim, .kv_width = R, .ik_width = c.i_dim, .iw_width = c.i_heads, .q_width = c.q_lora, .kv_eps = c.eps, .ik_eps = 1e-6, .iw_scale = index_weight_scale, .q_eps = c.eps }, 7); + if (qr) |q| bind(e, 8, .{ w.q_norm, q }); + const widest = if (qr != null) @max(R, c.q_lora) else R; // rms' threads for the widest row (all parts fit) + e.dispatchGroups(size(rows, if (qr != null) 4 else 3, 1), size(((widest + 3) / 4 + 31) / 32 * 32, 1, 1)); +} + /// Every row's 64 heads of q_nope (`qp`, rows qrProj apart) into the latent: qvm on kv_b's key half, or embed_q's qmv. pub fn absorb(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Mla, qp: Ref, ql: Ref, rows: u32) void { const c = x.c; @@ -371,24 +395,9 @@ pub fn unabsorb(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Mla, att: Re e.dispatchGroups(size(1, c.v_dim / 4, rows * c.mla_heads), size(32, 1, 1)); } -/// One row's 64 heads over keys [0, n) as one 64-row matrix against the latent keys: scores, a precise softmax, values. -pub fn attendDense(x: *const Ctx, e: mtl.ComputeEncoder, keys: Ref, q: Ref, scores: Ref, probs: Ref, out: Ref, n: u32) void { - const k = x.k; - const H = x.c.mla_heads; - e.setPipeline(k.latent_scores); - bind(e, 0, .{ q, keys, scores }); - e.setValue([2]i32{ @intCast(n), @intFromBool(n < 256) }, 3); // fewer than 256 keys: the 512 dims in two halves - e.dispatchGroups(size((n + 31) / 32, 1, 1), size(2 * H, 1, 1)); // a simdgroup each 16 heads - e.setPipeline(k.softmax); - bind(e, 0, .{scores}); - shape(e, 1, .{n}); - bind(e, 2, .{probs}); - e.dispatchGroups(size(H, 1, 1), size(((n + 3) / 4 + 31) / 32 * 32, 1, 1)); - e.setPipeline(k.latent_values); - bind(e, 0, .{ probs, keys, out }); - e.setValue([2]i32{ @intCast(n), if (n > 1024) 1024 else 0 }, 3); // past 1,024 keys: the first 1,024 apart - e.dispatchGroups(size(x.c.kv_lora / 32, 1, 1), size(2 * H, 1, 1)); -} +/// Dense latent attention (dense_attn.zig): one row's launches, and a window's rows in three launches. +pub const attendDense = @import("dense_attn.zig").attendDense; +pub const attendRows = @import("dense_attn.zig").attendRows; /// A stream's rows [first, rows) past index_topk keys: fp32 block scores, top blocks in order, the tail, sparse kernel. fn attendSparse(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, g: Seg, first: u32) void { @@ -396,7 +405,7 @@ fn attendSparse(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, g: Seg, first: const sc = x.sc; const n = g.rows - first; const r: usize = g.row0 + first; // the first sparse row's place in the window - selectKeys(x, e, mi, sc.qp.at((r * c.qrProj() + c.mla_heads * c.nope) * 2), c.qrProj(), sc.iw.at(r * c.i_heads * 2), sc.sscore, sc.indices, n, g.pos + first); + if (on(x, "mla_select")) selectKeys(x, e, mi, sc.qp.at((r * c.qrProj() + c.mla_heads * c.nope) * 2), c.qrProj(), sc.iw.at(r * c.i_heads * 2), sc.sscore, sc.indices, n, g.pos + first); const ql = sc.ql.at(r * c.mla_heads * c.kv_lora * 2); const att = sc.att.at(r * c.mla_heads * c.kv_lora * 2); if (c.tp > 1) return attendIndexed(x, e, mi, ql, sc.indices, att, n, g.pos + g.rows); @@ -434,12 +443,35 @@ pub fn selectKeys(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, iq: Ref, q_st bind(e, 0, .{ iq, iw, x.s.mla[mi].pool, scores }); e.setValue(ScoreArgs{ .p0 = p0, .q_stride = q_stride, .w_stride = c.i_heads, .s_stride = s_stride, .rows = n }, 4); e.dispatchGroups(size((most + 127) / 128, n, 1), size(128, 1, 1)); - e.setPipeline(k.index_select); + const sel = SelectArgs{ .p0 = p0, .top = c.i_topk / c.kpool, .width = c.keyWidth(), .s_stride = s_stride, .i_stride = c.keyWidth() }; + if (most > select_cap and most <= select_marks) { // between them glm_index_select's one group a row is quicker + e.setPipeline(k.index_select); + bind(e, 0, .{ scores, indices }); + e.setValue(sel, 2); + return e.dispatchGroups(size(n, 1, 1), size(1024, 1, 1)); + } + const words = st.selectWords(x.s.cap, c.kpool); + if (most > select_cap) { // past `select_marks` blocks: each span's blocks at or above the row's sampled floor + e.setPipeline(k.select_mark); + bind(e, 0, .{ scores, x.sc.bits }); + e.setValue(sel, 2); + e.setValue(words, 3); + e.dispatchGroups(size((most + select_span - 1) / select_span, n, 1), size(256, 1, 1)); + } + e.setPipeline(k.select_merge); // the selection among them, glm_index_select's bytes bind(e, 0, .{ scores, indices }); - e.setValue(SelectArgs{ .p0 = p0, .top = c.i_topk / c.kpool, .width = c.keyWidth(), .s_stride = s_stride, .i_stride = c.keyWidth() }, 2); - e.dispatchGroups(size(n, 1, 1), size(1024, 1, 1)); + e.setValue(sel, 2); + e.setValue(words, 3); + bind(e, 4, .{x.sc.bits}); + e.dispatchGroups(size(n, 1, 1), size(select_threads, 1, 1)); } +/// glm_select.metal's CAP (the merge's candidates; shorter rows select whole) and SPAN (a mark group's blocks). +const select_cap = 3072; +const select_marks = 8192; // blocks (32,768 tokens) past which marking and merging beat one group a row (M5 Ultra) +const select_span = 4096; +const select_threads = 512; // a merge group's threads (T2) + /// The sparse kernel for `n` rows' 64 heads over their listed keys (`key_length` keys written so far). pub fn attendIndexed(x: *const Ctx, e: mtl.ComputeEncoder, mi: usize, ql: Ref, indices: Ref, out: Ref, n: u32, key_length: u32) void { const c = x.c; @@ -496,7 +528,7 @@ pub fn backbone(x: *Ctx, e: mtl.ComputeEncoder, ids: Ref, rows: u32, pos: u32) v snap(x, e, sc.normed, plane); switch (L.mlp) { .dense => |*d| if (k & Class.dense == 0) denseMlp(x, e, d, sc.normed, rows), - .moe => |*m| moe(x, e, m, sc.normed, rows), + .moe => |*m| x.moe_branch = moeBlock(x, e, m, sc.normed, rows, x.dump == null and li + 1 < c.run and k & Class.hc == 0 and on(x, "hc_mix")), } snap(x, e, sc.branch, plane); pending = true; @@ -530,7 +562,8 @@ pub fn headWith(x: *const Ctx, e: mtl.ComputeEncoder, hw: wts.Affine, in: Ref, l if (n > 0) { var q = hw; q.n = n; - qmv(x, e, if (x.c.tp > 1) x.k.qmv_head_tp else x.k.qmv_head, in, q, logits, rows); + if (on(x, "head_qmv")) qmv(x, e, if (x.c.tp > 1) x.k.qmv_head_tp else x.k.qmv_head, in, q, logits, rows); + if (!on(x, "head_argmax")) return; const payload = @import("draw_rule.zig").Payload.init(if (greedy) null else x.draws, rows, vocab); // draw_dispatch splits the rows into runs of one mode: sampled tf_sample_full, else argmax. @import("draw_dispatch.zig").encode(e, x.k.sample, x.k.argmax, logits.buf, logits.off, picks.buf, picks.off, &payload, n); diff --git a/zig/src/families/glm/glm.zig b/zig/src/families/glm/glm.zig index 40fbbe9176c..86628016f2e 100644 --- a/zig/src/families/glm/glm.zig +++ b/zig/src/families/glm/glm.zig @@ -2,6 +2,7 @@ pub const config = @import("config.zig"); pub const weights = @import("weights.zig"); pub const kernels = @import("kernels.zig"); +pub const hc = @import("../../core/hc.zig"); pub const state = @import("state.zig"); pub const forward = @import("forward.zig"); pub const mtp = @import("mtp.zig"); @@ -17,6 +18,7 @@ pub const mirror = @import("mirror.zig"); pub const timing = @import("timing.zig"); pub const affine = @import("affine.zig"); pub const wide = @import("wide.zig"); +pub const mm_groups = @import("mm_groups.zig"); pub const vision = @import("vision.zig"); pub const image = @import("image.zig"); pub const video = @import("video.zig"); diff --git a/zig/src/families/glm/kernels.zig b/zig/src/families/glm/kernels.zig index 5adf7c38643..5497de4d8f0 100644 --- a/zig/src/families/glm/kernels.zig +++ b/zig/src/families/glm/kernels.zig @@ -5,6 +5,7 @@ const sources = @import("kernel_sources"); const frags = @import("../../core/frags.zig"); const moe_route = @import("../../core/moe_route.zig"); const affine_mm = @import("../../core/affine_mm.zig"); +const mm_groups = @import("mm_groups.zig"); const hc = @import("../../core/hc.zig"); const wide = @import("wide.zig"); @@ -14,7 +15,7 @@ pub const route_shape: moe_route.Shape = .{ .hidden = 4096, .experts = 288, .top pub const igate_shape: moe_route.Shape = .{ .hidden = 4096, .experts = 128, .topk = 8, .out_bf16 = true }; /// The hyper-connection boundary's shape (config.zig refuses other checkpoints). -pub const hc_shape: hc.Shape = .{ .width = 4096, .sinkhorn = 20, .eps_e9 = 1000 }; +pub const hc_shape: hc.Shape = .{ .width = 4096, .sinkhorn = 20, .eps_e9 = 1000, .topk = route_shape.topk }; pub const max_rows = 16; @@ -42,9 +43,14 @@ pub const Kernels = struct { gemv_scores_le32: mtl.Pipeline, gemv_scores: mtl.Pipeline, hc_expand_10: mtl.Pipeline, - hc_core: [4]mtl.Pipeline, // core/hc.zig: the expand (or the first boundary's read) with partial sums, the split, the expand in place + hc_core: hc.Pipes, // core/hc.zig's names: the expand (or first read) with partial sums, split, in place, parts apart, MoE kda_rows: mtl.Pipeline, kda_rows_tp: mtl.Pipeline, // TP2: the fused step over one Mac's 32 heads + kda_window: mtl.Pipeline, // windows of 2+ rows: kda_rows' values, the rows' gates, convolutions and norms at once + kda_window_tp: mtl.Pipeline, + kda_parts: mtl.Pipeline, // all 64 heads on two threadgroups each (their value columns), raw outputs and gates + kda_norm: mtl.Pipeline, // then each row's head normed and gated: kda_rows' values + kda_split: bool = false, // 2+ row steps take kda_parts and kda_norm (an Ultra's GPU idles at 64 groups) router: [max_rows]mtl.Pipeline, // by window rows (RR = 1 .. 16) moe_route: mtl.Pipeline, shared_gateup: mtl.Pipeline, // the shared expert's kernels at one output a simdgroup: four times the threadgroups, the same sums @@ -53,6 +59,8 @@ pub const Kernels = struct { moe_down_0: mtl.Pipeline, moe_gateup_0_one: mtl.Pipeline, // the same at two outputs a simdgroup, for one-row rounds (more weight reads in flight) moe_down_0_one: mtl.Pipeline, + moe_gateup_pick: mtl.Pipeline, // one row: each routed group replays the route select's picks, no select launch + moe_down_pick: mtl.Pipeline, // and the down projections of the picks in pick order combine_0: mtl.Pipeline, // their combine: the shared expert's row read from the last slot moe_gateup_2: mtl.Pipeline, moe_down_2: mtl.Pipeline, @@ -66,6 +74,7 @@ pub const Kernels = struct { absorb: mtl.Pipeline, unabsorb: mtl.Pipeline, scale: mtl.Pipeline, + mla_norms: mtl.Pipeline, // an MLA layer's latent key norm, indexer key norm and indexer weights in one launch pool: mtl.Pipeline, stream_mean: mtl.Pipeline, add: mtl.Pipeline, @@ -75,6 +84,8 @@ pub const Kernels = struct { index_select: mtl.Pipeline, index_scores_nax: mtl.Pipeline, // a prompt chunk's index scores on the tensor units (glm_index_nax.metal) index_decode: mtl.Pipeline, // and decode rows' (a row's heads as the op's rows) + select_mark: mtl.Pipeline, // decode rows' key lists past CAP blocks: the blocks at or above a sampled floor (glm_select.metal) + select_merge: mtl.Pipeline, // and the selection among them, glm_index_select's bytes exp_f32: mtl.Pipeline, streams: mtl.Pipeline, copy_u32: mtl.Pipeline, @@ -85,9 +96,14 @@ pub const Kernels = struct { embed: mtl.Pipeline, latent_scores: mtl.Pipeline, latent_values: mtl.Pipeline, + latent_scores_rows: mtl.Pipeline, // a window's dense rows at once: each row the one-row kernels' bits + latent_values_rows: mtl.Pipeline, + softmax_rows: mtl.Pipeline, route_logits: mtl.Pipeline, route_select: mtl.Pipeline, igate_logits: mtl.Pipeline, + route_logits_one: mtl.Pipeline, // both for a one-row window: row 0's sums alone (glm_route_one.metal) + igate_logits_one: mtl.Pipeline, kda_prep: mtl.Pipeline, // a prompt chunk's KDA layer (glm_kda_prompt.metal): conv, norms, decay and beta kda_scan: mtl.Pipeline, // the recurrence alone kda_post: mtl.Pipeline, // the output norm and gate @@ -101,6 +117,7 @@ pub const Kernels = struct { sparse_nax_tp: mtl.Pipeline, // TP2: both over one Mac's 32 heads absorb_nax_tp: mtl.Pipeline, mm_bf16: affine_mm.Pipes, // prompt chunks' 4-bit g64 matmuls on the tensor units (core/affine_mm.zig): dense, gathers + mm_groups: mm_groups.Pipes, // the routed gathers walked in column groups (mm_groups.zig): mm_bf16's bits mm_f32: affine_mm.Pipes, // and with fp32 out: expert parallel by rows' down partials wide: ?wide.Pipes = null, // the products at other widths (wide.zig), for a checkpoint that has one @@ -109,7 +126,7 @@ pub const Kernels = struct { inline for (info.field_names, info.field_types) |name, T| { if (T == mtl.Pipeline) @field(k, name).deinit() else if (T == ?wide.Pipes) { if (k.wide) |*w| w.deinit(); - } else if (T != u64) for (&@field(k, name)) |*p| p.deinit(); + } else if (T != u64 and T != bool) for (&@field(k, name)) |*p| p.deinit(); } } @@ -167,6 +184,7 @@ const glue = [_]struct { name: [:0]const u8, field: []const u8 }{ .{ .name = "glm_exp_f32", .field = "exp_f32" }, .{ .name = "glm_streams", .field = "streams" }, .{ .name = "glm_copy_u32", .field = "copy_u32" }, .{ .name = "glm_route_rows", .field = "route_rows" }, .{ .name = "glm_act2", .field = "act2" }, .{ .name = "glm_dense_indices", .field = "dense_indices" }, + .{ .name = "glm_mla_norms", .field = "mla_norms" }, }; const Job = struct { @@ -215,6 +233,36 @@ fn kernelOf(comptime key: []const u8) sources.glm.Kernel { @compileError("no generated GLM kernel " ++ key); } +/// The KDA step's 64 heads on two threadgroups each for 2+ rows on an Ultra's GPU (faster there), not on a Max's. +pub fn splitKda(gpu: []const u8) bool { + return std.mem.indexOf(u8, gpu, "Ultra") != null; +} + +/// `src` with `old` replaced by `new` once: error.KernelCompile when the generated text no longer has it. +fn edit(gpa: std.mem.Allocator, src: []const u8, old: []const u8, new: []const u8) ![]u8 { + if (std.mem.count(u8, src, old) != 1) return error.KernelCompile; + return std.mem.replaceOwned(u8, gpa, src, old, new); +} + +/// One row's experts with no select launch: gate/up groups replay the select's picks, slot u takes pick u (same slots). +fn pickSources(gpa: std.mem.Allocator, route_core: []const u8, gu: []const u8, down: []const u8) ![2][]u8 { + const member = " if (!shared && u >= UCOUNT[0]) return;\n const int pick = shared ? (m < R ? m * TOPK : -1) : UMEM[u * MAXR + m];"; + const by_pick = " const int pick = shared ? (m < R ? m * TOPK : -1) : u;"; + const g1 = try edit(gpa, gu, member, by_pick); + defer gpa.free(g1); + const g2 = try edit(gpa, g1, " const size_t e = shared ? 0 : size_t(UIDS[u]);", " const size_t e = shared ? 0 : size_t(tf_route_pick_at(RLOGITS, RBIAS, u, lane, u == TOPK - 1 && threadgroup_position_in_grid.y == 0, RPICK, RWTS, RSCALE));"); + defer gpa.free(g2); + const g3 = try edit(gpa, g2, " const device int32_t* UIDS [[buffer(11)]],\n const device int32_t* UMEM [[buffer(12)]],\n const device int32_t* UCOUNT [[buffer(13)]],", " const device float* RLOGITS [[buffer(11)]],\n const device float* RBIAS [[buffer(12)]],\n device int32_t* RPICK [[buffer(13)]],"); + defer gpa.free(g3); + const g4 = try edit(gpa, g3, " device bfloat16_t* ACT [[buffer(15)]],", " device bfloat16_t* ACT [[buffer(15)]],\n device float* RWTS [[buffer(16)]],\n constant float& RSCALE [[buffer(17)]],"); + defer gpa.free(g4); + const gate_up = try std.mem.concat(gpa, u8, &.{ route_core, g4 }); + errdefer gpa.free(gate_up); + return .{ gate_up, try edit(gpa, down, member, by_pick) }; +} + +const m16_names = affine_mm.names ++ mm_groups.names; + /// Compile every library on worker threads. pub fn load(gpa: std.mem.Allocator, device: mtl.Device) !*Kernels { const k = try gpa.create(Kernels); @@ -231,7 +279,7 @@ pub fn visitSources(gpa: std.mem.Allocator, device: mtl.Device, visitor: anytype fn assemble(gpa: std.mem.Allocator, device: mtl.Device, k: *Kernels, visitor: anytype) !void { k.wide = null; - var jobs: [generated.len + 23]Job = undefined; + var jobs: [generated.len + 27]Job = undefined; inline for (generated, 0..) |g, i| { const src = comptime kernelOf(g.key); const FT = @FieldType(Kernels, g.field); @@ -253,26 +301,31 @@ fn assemble(gpa: std.mem.Allocator, device: mtl.Device, k: *Kernels, visitor: an jobs[generated.len + 3] = .{ .device = device, .source = sources.ops_embed_norm, .names = &.{"tf_embed_b4_g64"}, .out = @as(*[1]mtl.Pipeline, &k.embed) }; const attn_src = try frags.source(device, gpa, sources.glm_attn); defer gpa.free(attn_src); - var attn_out: [2]mtl.Pipeline = undefined; - jobs[generated.len + 4] = .{ .device = device, .source = attn_src, .names = &.{ "glm_latent_scores", "glm_latent_values" }, .out = &attn_out }; - const route_src = try moe_route.source(gpa, route_shape); + var attn_out: [4]mtl.Pipeline = undefined; + jobs[generated.len + 4] = .{ .device = device, .source = attn_src, .names = &.{ "glm_latent_scores", "glm_latent_values", "glm_latent_scores_rows", "glm_latent_values_rows" }, .out = &attn_out }; + const route_core = try moe_route.source(gpa, route_shape); + defer gpa.free(route_core); + const route_src = try std.mem.concat(gpa, u8, &.{ route_core, sources.glm_route_one }); defer gpa.free(route_src); - var route_out: [2]mtl.Pipeline = undefined; - jobs[generated.len + 5] = .{ .device = device, .source = route_src, .names = &moe_route.names, .out = &route_out }; - const igate_src = try moe_route.source(gpa, igate_shape); + var route_out: [3]mtl.Pipeline = undefined; + jobs[generated.len + 5] = .{ .device = device, .source = route_src, .names = &.{ moe_route.names[0], moe_route.names[1], "glm_route_logits_one" }, .out = &route_out }; + const igate_core = try moe_route.source(gpa, igate_shape); + defer gpa.free(igate_core); + const igate_src = try std.mem.concat(gpa, u8, &.{ igate_core, sources.glm_route_one }); defer gpa.free(igate_src); - var igate_out: [1]mtl.Pipeline = undefined; - jobs[generated.len + 6] = .{ .device = device, .source = igate_src, .names = &.{moe_route.names[0]}, .out = &igate_out }; - const m16_src = try affine_mm.source(device, gpa, .{}); + var igate_out: [2]mtl.Pipeline = undefined; + jobs[generated.len + 6] = .{ .device = device, .source = igate_src, .names = &.{ moe_route.names[0], "glm_route_logits_one" }, .out = &igate_out }; + const m16_src = try mm_groups.source(device, gpa); // affine_mm.names, then the column-group gathers defer gpa.free(m16_src); const m32_src = try affine_mm.source(device, gpa, .{ .out_f32 = true }); defer gpa.free(m32_src); - jobs[generated.len + 7] = .{ .device = device, .source = m16_src, .names = &affine_mm.names, .out = &k.mm_bf16 }; + var m16_out: [m16_names.len]mtl.Pipeline = undefined; + jobs[generated.len + 7] = .{ .device = device, .source = m16_src, .names = &m16_names, .out = &m16_out }; jobs[generated.len + 8] = .{ .device = device, .source = m32_src, .names = &affine_mm.names, .out = &k.mm_f32 }; - const kda_src = try std.mem.concat(gpa, u8, &.{ comptime kernelOf("kda_rows").source, sources.glm_kda_prompt }); + const kda_src = try std.mem.concat(gpa, u8, &.{ comptime kernelOf("kda_rows").source, sources.glm_kda_prompt, sources.glm_kda_window, sources.glm_kda_parts }); defer gpa.free(kda_src); - var kda_out: [6]mtl.Pipeline = undefined; - jobs[generated.len + 9] = .{ .device = device, .source = kda_src, .names = &.{ "glm_kda_prep", "glm_kda_scan", "glm_kda_post", "glm_kda_prep_tp", "glm_kda_scan_tp", "glm_kda_post_tp" }, .out = &kda_out }; + var kda_out: [10]mtl.Pipeline = undefined; + jobs[generated.len + 9] = .{ .device = device, .source = kda_src, .names = &.{ "glm_kda_prep", "glm_kda_scan", "glm_kda_post", "glm_kda_prep_tp", "glm_kda_scan_tp", "glm_kda_post_tp", "glm_kda_window", "glm_kda_window_tp", "glm_kda_parts", "glm_kda_norm" }, .out = &kda_out }; const sparse_src = try frags.source(device, gpa, sources.glm_sparse_nax); defer gpa.free(sparse_src); var sparse_out: [3]mtl.Pipeline = undefined; @@ -317,6 +370,11 @@ fn assemble(gpa: std.mem.Allocator, device: mtl.Device, k: *Kernels, visitor: an if (std.mem.eql(u8, gu0_one, gu0_src) or std.mem.eql(u8, down0_one, down0_src)) return error.KernelCompile; jobs[generated.len + 20] = .{ .device = device, .source = gu0_one, .names = &.{"glm_moe_gateup_0"}, .out = @as(*[1]mtl.Pipeline, &k.moe_gateup_0_one) }; jobs[generated.len + 21] = .{ .device = device, .source = down0_one, .names = &.{"glm_moe_down_0"}, .out = @as(*[1]mtl.Pipeline, &k.moe_down_0_one) }; + const picks = try pickSources(gpa, route_core, gu0_one, down0_one); + defer gpa.free(picks[0]); + defer gpa.free(picks[1]); + jobs[generated.len + 25] = .{ .device = device, .source = picks[0], .names = &.{"glm_moe_gateup_0"}, .out = @as(*[1]mtl.Pipeline, &k.moe_gateup_pick) }; + jobs[generated.len + 26] = .{ .device = device, .source = picks[1], .names = &.{"glm_moe_down_0"}, .out = @as(*[1]mtl.Pipeline, &k.moe_down_pick) }; const comb = comptime kernelOf("moe_combine"); const comb_a = try std.mem.replaceOwned(u8, gpa, comb.source, "const device bfloat* y = Y + size_t(r) * TOPK * D + d;", "const device bfloat* y = Y + size_t(r) * (TOPK + 1) * D + d;"); defer gpa.free(comb_a); @@ -324,6 +382,10 @@ fn assemble(gpa: std.mem.Allocator, device: mtl.Device, k: *Kernels, visitor: an defer gpa.free(comb_src); if (std.mem.eql(u8, comb_src, comb.source)) return error.KernelCompile; // the generated combine changed: its edit no longer applies jobs[generated.len + 22] = .{ .device = device, .source = comb_src, .names = comb.functions, .out = @as(*[1]mtl.Pipeline, &k.combine_0) }; + var select_out: [2]mtl.Pipeline = undefined; + jobs[generated.len + 23] = .{ .device = device, .source = sources.glm_select, .names = &.{ "glm_select_mark", "glm_select_merge" }, .out = &select_out }; + const softmax_rows_src = comptime sources.ops_softmax ++ sources.glm_softmax_rows; + jobs[generated.len + 24] = .{ .device = device, .source = softmax_rows_src, .names = &.{"glm_softmax_rows"}, .out = @as(*[1]mtl.Pipeline, &k.softmax_rows) }; if (comptime @TypeOf(visitor) != void) { for (jobs) |j| try visitor.raw("glm", j.names[0], j.source); @@ -351,18 +413,31 @@ fn assemble(gpa: std.mem.Allocator, device: mtl.Device, k: *Kernels, visitor: an k.sample = sample_out[0]; // the shared sampler's own library: glm_glue's table never named it k.latent_scores = attn_out[0]; k.latent_values = attn_out[1]; + k.latent_scores_rows = attn_out[2]; + k.latent_values_rows = attn_out[3]; + k.mm_bf16 = m16_out[0..affine_mm.names.len].*; + k.mm_groups = m16_out[affine_mm.names.len..].*; k.route_logits = route_out[0]; k.route_select = route_out[1]; + k.route_logits_one = route_out[2]; k.igate_logits = igate_out[0]; + k.igate_logits_one = igate_out[1]; k.kda_prep = kda_out[0]; k.kda_scan = kda_out[1]; k.kda_post = kda_out[2]; k.kda_prep_tp = kda_out[3]; k.kda_scan_tp = kda_out[4]; k.kda_post_tp = kda_out[5]; + k.kda_window = kda_out[6]; + k.kda_window_tp = kda_out[7]; + k.kda_parts = kda_out[8]; + k.kda_norm = kda_out[9]; + k.kda_split = splitKda(std.mem.span(device.name())); k.sparse_nax = sparse_out[0]; k.sparse_split = sparse_out[1]; k.sparse_combine = sparse_out[2]; k.index_scores_nax = index_out[0]; k.index_decode = index_out[1]; + k.select_mark = select_out[0]; + k.select_merge = select_out[1]; } diff --git a/zig/src/families/glm/mm_groups.zig b/zig/src/families/glm/mm_groups.zig new file mode 100644 index 00000000000..b89defef2e7 --- /dev/null +++ b/zig/src/families/glm/mm_groups.zig @@ -0,0 +1,94 @@ +//! Prompt experts and dense products in column groups (glm_mm_groups.metal): core/affine_mm.zig's bits, faster. +const std = @import("std"); +const mtl = @import("metal"); +const sources = @import("kernel_sources"); +const affine_mm = @import("../../core/affine_mm.zig"); + +pub const names = [5][:0]const u8{ "glm_gather_glu_32", "glm_gather_glu_64", "glm_gather_scatter_32", "glm_gather_scatter_64", "glm_mm_grouped" }; + +/// The column-group products in `names` order (bf16 out). +pub const Pipes = [5]mtl.Pipeline; + +/// Column tiles a group (glm_mm_groups.metal's GT_GROUP): a launch's column tiles must be a multiple. +pub const group = 32; + +/// Dense products' depth from which they take column groups (shallower ones were as fast or slower on an M5 Ultra). +pub const dense_from = 4096; + +/// Experts' mean rows below which a launch takes 32-row tiles (gate/up, down); M5 Ultra, GLM's shapes. +pub const glu_32_below = 96; +pub const down_32_below = 64; + +/// core/affine_mm.metal at 4/64, bf16 out, the column-group kernels after it: affine_mm.names, then ours. +pub fn source(device: mtl.Device, a: std.mem.Allocator) ![]u8 { + const core = try affine_mm.source(device, a, .{}); + defer a.free(core); + return std.mem.concat(a, u8, &.{ core, sources.glm_mm_groups }); +} + +fn bind(e: mtl.ComputeEncoder, i: usize, r: anytype) void { + e.setBuffer(r.buf, r.off, i); +} + +/// The one-launch gathers' tile count: each expert's last tile may be partial. +fn tiles(rows: u32, experts: u32, bm: u32) u32 { + return @min(rows, (rows + bm - 1) / bm + experts - 1); +} + +/// affine_mm.gatherGlu's activations (expert-sorted pairs, pair i: x row order[i] / topk) in column groups. +pub fn gatherGlu(e: mtl.ComputeEncoder, p: Pipes, x: anytype, sums: anytype, gate: anytype, up: anytype, offsets: anytype, order: anytype, act: anytype, rows: u32, experts: u32, topk: u32, limit: f32) void { + std.debug.assert(gate.n % (32 * group) == 0 and gate.k % 64 == 0 and gate.n == up.n and gate.k == up.k); + const bm: u32 = if (rows / experts < glu_32_below) 32 else 64; + e.setPipeline(p[if (bm == 64) 1 else 0]); + bind(e, 0, x); + bind(e, 1, gate.w); + bind(e, 2, gate.s); + bind(e, 3, gate.b); + bind(e, 4, sums); + e.setValue(affine_mm.Args{ .rows = @intCast(rows), .n = @intCast(gate.n), .k = @intCast(gate.k), .experts = @intCast(experts) }, 5); + bind(e, 6, act); + bind(e, 7, offsets); + bind(e, 8, order); + bind(e, 9, up.w); + bind(e, 10, up.s); + bind(e, 11, up.b); + e.setValue([2]f32{ @floatFromInt(topk), limit }, 12); + e.dispatchGroups(mtl.Size.of(tiles(rows, experts, bm) * (gate.n / 32), 1, 1), mtl.Size.of(128, 1, 1)); +} + +/// affine_mm.gatherTo (sorted row i's outputs to row dst[i] of y) in column groups. +pub fn gatherTo(e: mtl.ComputeEncoder, p: Pipes, x: anytype, sums: anytype, q: anytype, offsets: anytype, y: anytype, dst: anytype, rows: u32, experts: u32) void { + std.debug.assert(q.n % (64 * group) == 0 and q.k % 64 == 0); + const bm: u32 = if (rows / experts < down_32_below) 32 else 64; + e.setPipeline(p[if (bm == 64) 3 else 2]); + bind(e, 0, x); + bind(e, 1, q.w); + bind(e, 2, q.s); + bind(e, 3, q.b); + bind(e, 4, sums); + e.setValue(affine_mm.Args{ .rows = @intCast(rows), .n = @intCast(q.n), .k = @intCast(q.k), .experts = @intCast(experts) }, 5); + bind(e, 6, y); + bind(e, 7, offsets); + bind(e, 8, dst); + e.dispatchGroups(mtl.Size.of(tiles(rows, experts, bm) * (q.n / 64), 1, 1), mtl.Size.of(128, 1, 1)); +} + +/// affine_mm.denseBatch at one batch (y = x W^T, pitches `s`) in column groups. +pub fn dense(e: mtl.ComputeEncoder, p: Pipes, x: anytype, sums: anytype, q: anytype, y: anytype, rows: u32, s: affine_mm.Strides) void { + const n = std.mem.alignForward(u32, q.n, 64); + e.setPipeline(p[4]); + bind(e, 0, x); + bind(e, 1, q.w); + bind(e, 2, q.s); + bind(e, 3, q.b); + bind(e, 4, sums); + e.setValue(affine_mm.Args{ .rows = @intCast(rows), .n = @intCast(n), .k = @intCast(q.k), .experts = 0 }, 5); + bind(e, 6, y); + e.setValue(s, 7); + e.dispatchGroups(mtl.Size.of(((rows + 63) / 64) * (n / 64), 1, 1), mtl.Size.of(128, 1, 1)); +} + +/// Whether a routed layer's matrices fit the column groups (4-bit/64 gate/up of 1024s of rows, down of 2048s). +pub fn fits(gate: anytype, down: anytype) bool { + return gate.n % (32 * group) == 0 and down.n % (64 * group) == 0; +} diff --git a/zig/src/families/glm/moe.zig b/zig/src/families/glm/moe.zig index 43af19a28fd..1914b6d4454 100644 --- a/zig/src/families/glm/moe.zig +++ b/zig/src/families/glm/moe.zig @@ -21,6 +21,11 @@ comptime { /// MoE block (shared expert, route, routed experts, combine); expert parallel: our experts, sent, the peer's received. pub fn moe(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, rows: u32) void { + _ = block(x, e, w, x_in, rows, false); +} + +/// The block; `leave`: on the generated kernels' path the next boundary's expand takes the combine (true if it did). +pub fn block(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, rows: u32, leave: bool) bool { std.debug.assert(rows <= st.max_rows); const c = x.c; const k = x.k; @@ -34,7 +39,7 @@ pub fn moe(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, r if (s & Class.exchange == 0 and on(x, "x_locpost")) ep.sendRows(e, sc.yp, sc.wts, rows); // with its begin if (s & Class.shared == 0) experts(x, e, w, x_in, rows, 1, .{ sc.none, sc.none, sc.none }); if (s & Class.combine == 0) ep.receiveRows(e, sc.ys, sc.branch, rows); - return; + return false; }; if (x.ep) |ep| { if (s & Class.exchange == 0 and on(x, "x_locpost")) ep.begin(); @@ -44,16 +49,19 @@ pub fn moe(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, r if (s & Class.exchange == 0) ep.send(e, sc.ye, rows, on(x, "x_pack") and on(x, "x_locpost"), on(x, "x_locpost")); if (s & Class.shared == 0) experts(x, e, w, x_in, rows, 1, .{ sc.none, sc.none, sc.none }); if (s & Class.exchange == 0 and on(x, "x_unpack")) ep.receive(e, sc.ye, rows); - } else if (native(w, .both) and s & (Class.shared | Class.routed) == 0 and on(x, "e_gateup") and on(x, "e_down") and on(x, "s_gateup") and on(x, "s_down")) { - if (s & Class.route == 0) route(x, e, w, x_in, rows); - both(x, e, w, x_in, rows); // the shared expert as the gathers' last slot: two launches fewer - if (s & Class.combine != 0 or !on(x, "combine")) return; + } else if (native(w, .both) and s & (Class.shared | Class.routed) == 0) { + const one = rows == 1 and x.fused_route; // the gate/up groups replay the select: the logits alone + if (s & Class.route == 0 and one and on(x, "r_router")) logits(x, e, w, x_in, rows); + if (s & Class.route == 0 and !one) route(x, e, w, x_in, rows); + both(x, e, w, x_in, rows, one); // the shared expert as the gathers' last slot: two launches fewer + if (s & Class.combine != 0 or !on(x, "combine")) return false; + if (leave) return true; e.setPipeline(k.combine_0); bind(e, 0, .{ sc.ye, sc.ye, sc.wts }); shape(e, 3, .{ rows, top }); bind(e, 4, .{sc.branch}); e.dispatchThreads(size(rows * c.hidden, 1, 1), size(256, 1, 1)); - return; + return false; } else if (x.k.wide != null and wide.moeOne(parts(w)) and s & (Class.shared | Class.routed) == 0 and on(x, "e_gateup") and on(x, "e_down") and on(x, "s_gateup") and on(x, "s_down")) { @@ -74,25 +82,31 @@ pub fn moe(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, r if (s & Class.route == 0) route(x, e, w, x_in, rows); if (s & Class.routed == 0) experts(x, e, w, x_in, rows, 2, .{ sc.uids, sc.umem, sc.ucount }); } - if (s & Class.combine != 0 or !on(x, "combine")) return; + if (s & Class.combine != 0 or !on(x, "combine")) return false; e.setPipeline(k.moe_combine); bind(e, 0, .{ sc.ys, sc.ye, sc.wts }); shape(e, 3, .{ rows, top }); bind(e, 4, .{sc.branch}); e.dispatchThreads(size(rows * c.hidden, 1, 1), size(256, 1, 1)); + return false; } fn parts(w: *const wts.Moe) wide.Moe { return .{ .gate = w.gate, .up = w.up, .down = w.down, .sh_gate_up = w.sh_gate_up, .sh_down = w.sh_down }; } +/// The router's fp32 logits (the core route's first launch). +fn logits(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, rows: u32) void { + moe_route.logits(e, if (rows == 1) x.k.route_logits_one else x.k.route_logits, route_shape, x_in, w.router, x.sc.logits_r, rows); +} + /// The router's fp32 logits and the route: picks, weights and the window's unique experts with their members. fn route(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, rows: u32) void { const c = x.c; const k = x.k; const sc = x.sc; if (x.fused_route) { - if (on(x, "r_router")) moe_route.logits(e, k.route_logits, route_shape, x_in, w.router, sc.logits_r, rows); + if (on(x, "r_router")) logits(x, e, w, x_in, rows); if (!on(x, "r_topk")) return; if (x.ep) |ep| if (!c.byRows()) return moe_route.select(e, k.route_select, sc.logits_r, w.bias, c.routed_scale, rows, c.own, ep.outputs(sc.pick, sc.wts)); const rl = sc.rl; @@ -152,27 +166,38 @@ fn experts(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, r e.dispatchThreads(size(32 * rows, if (part == 1) D else D / 4, zs), size(32 * rows, 1, 1)); // the shared expert: an output a simdgroup } -/// Routed experts and the shared one (slot topk: grid z past the routed ids, the kernels' last) into `act` and `ye`. -fn both(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, rows: u32) void { +/// Routed and shared experts into `act` and `ye` (shared: slot topk); `one`: one row whose groups replay the select. +fn both(x: *const Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, rows: u32, one: bool) void { const c = x.c; const k = x.k; const sc = x.sc; const D = c.hidden; const N = c.moe_inter; const zs: u32 = rows * c.topk + 1; // the routed ids' slots, then the shared expert's - const rps: u32 = if (rows == 1) 2 else 4; // one row: two outputs a simdgroup, more reads in flight (the same sums) - e.setPipeline(if (rows == 1) k.moe_gateup_0_one else k.moe_gateup_0); - bind(e, 0, .{x_in}); - shape(e, 1, .{ rows, D }); - bind(e, 2, .{ w.gate.w, w.gate.s, w.gate.b, w.up.w, w.up.s, w.up.b, w.sh_gate_up.w, w.sh_gate_up.s, w.sh_gate_up.b, sc.uids, sc.umem, sc.ucount }); - e.setValue(c.swiglu_limit, 14); - bind(e, 15, .{sc.act}); - e.dispatchThreads(size(32 * rows, N / rps, zs), size(32 * rows, 1, 1)); - e.setPipeline(if (rows == 1) k.moe_down_0_one else k.moe_down_0); + // Two outputs a simdgroup (more reads in flight, the same sums): gate/up to 4 rows, down at one (M5 Ultra). + const gu_two = rows <= 4; + const rps: u32 = if (gu_two) 2 else 4; + if (on(x, "e_gateup")) { // a profile's knock-outs leave out one launch of this path, never the path + e.setPipeline(if (one) k.moe_gateup_pick else if (gu_two) k.moe_gateup_0_one else k.moe_gateup_0); + bind(e, 0, .{x_in}); + shape(e, 1, .{ rows, D }); + bind(e, 2, .{ w.gate.w, w.gate.s, w.gate.b, w.up.w, w.up.s, w.up.b, w.sh_gate_up.w, w.sh_gate_up.s, w.sh_gate_up.b }); + bind(e, 11, if (one) .{ sc.logits_r, w.bias, sc.pick } else .{ sc.uids, sc.umem, sc.ucount }); + e.setValue(c.swiglu_limit, 14); + bind(e, 15, .{sc.act}); + if (one) bind(e, 16, .{sc.wts}); + if (one) e.setValue(c.routed_scale, 17); + e.dispatchThreads(size(32 * rows, N / rps, zs), size(32 * rows, 1, 1)); + } + if (!on(x, "e_down")) return; + const down_rps: u32 = if (rows == 1) 2 else 4; + e.setPipeline(if (one) k.moe_down_pick else if (rows == 1) k.moe_down_0_one else k.moe_down_0); bind(e, 0, .{sc.act}); shape(e, 1, .{ rows, c.topk + 1, N }); - bind(e, 2, .{ w.down.w, w.down.s, w.down.b, w.sh_down.w, w.sh_down.s, w.sh_down.b, sc.uids, sc.umem, sc.ucount, sc.ye }); - e.dispatchThreads(size(32 * rows, D / rps, zs), size(32 * rows, 1, 1)); + bind(e, 2, .{ w.down.w, w.down.s, w.down.b, w.sh_down.w, w.sh_down.s, w.sh_down.b }); + bind(e, 8, if (one) .{ sc.pick, sc.none, sc.none } else .{ sc.uids, sc.umem, sc.ucount }); + bind(e, 11, .{sc.ye}); + e.dispatchThreads(size(32 * rows, D / down_rps, zs), size(32 * rows, 1, 1)); } /// By rows: every routed pick's half (this Mac's intermediate rows), down's fp32 partials into `yp`. diff --git a/zig/src/families/glm/mtp.zig b/zig/src/families/glm/mtp.zig index 53c35fda955..fa50574d888 100644 --- a/zig/src/families/glm/mtp.zig +++ b/zig/src/families/glm/mtp.zig @@ -55,6 +55,7 @@ pub fn finish(x: *fwd.Ctx, e: mtl.ComputeEncoder, res: Ref, normed: Ref, rows: u if (gathered) { // the rows' queries and indexer weights, as the absorb computed them where the rows were fwd.qmv(x, e, x.k.qmv_x, normed, L.attn.mla.x_proj, sc.xp, rows); fwd.indexWeights(x, e, sc.xp, c.xProj(), sc.iw, rows); + x.q_normed = false; // the queries from this x_proj: mlaAttend norms them } fwd.mlaAttend(x, e, mi, &L.attn.mla, rows, pos); add(x, e, res, sc.branch, sc.m_out, rows * D); diff --git a/zig/src/families/glm/prompt.zig b/zig/src/families/glm/prompt.zig index d2f8e748395..a8fa3df9931 100644 --- a/zig/src/families/glm/prompt.zig +++ b/zig/src/families/glm/prompt.zig @@ -9,11 +9,13 @@ const fwd = @import("forward.zig"); const pk = @import("../nemotron/prefill_kernels.zig"); const ep_mod = @import("ep.zig"); const affine_mm = @import("../../core/affine_mm.zig"); +const mm_groups = @import("mm_groups.zig"); const hc = @import("../../core/hc.zig"); const kernels = @import("kernels.zig"); const wide = @import("wide.zig"); const Kernels = kernels.Kernels; const moe_route = @import("../../core/moe_route.zig"); +const tape = @import("prompt_tape.zig"); const Ref = wts.Ref; const bind = fwd.bind; const size = fwd.size; @@ -64,6 +66,7 @@ pub const Prompt = struct { m_out: Ref, sums: Ref, // fp32 group sums of a matmul's rows (affine_mm's bias operand) sparse_nax: bool, // the sparse MLA attention on the tensor units (GLM_SPARSE_NAX=0: the row kernel) + tape: ?*tape.Tape, // a profile's routes and key lists, played back in place of computing them rows: u32, // a chunk's rows at most (the buffers' height) kda_rows: u32, // the rows a KDA block's planes hold (half a chunk) @@ -106,6 +109,7 @@ fn buffers(p: *Prompt, arena: *st.Arena, c: *const cfg.Config, decode: *const st } }.to; p.rows = rows; + p.tape = null; p.kda_rows = @max(rows / 2, 1); p.sparse_nax = sparseNax(); p.streams = decode.*; @@ -191,7 +195,13 @@ fn run(e: mtl.ComputeEncoder, grid: [3]usize, group: [3]usize) void { fn qmm(p: *const Prompt, e: mtl.ComputeEncoder, x: Ref, q: wts.Affine, y: Ref, M: u32) void { if (!wide.native(q)) return qmmAt(p, e, x, q.k, q, y, M); affine_mm.rowSums(e, p.mm.mm_bf16, 64, x, p.sums, M, q.k); - affine_mm.dense(e, p.mm.mm_bf16, x, p.sums, q, y, M); + denseOf(p, e, x, q, y, M, .{ .x_row = @intCast(q.k), .y_row = @intCast(std.mem.alignForward(u32, q.n, 64)) }); +} + +/// affine_mm's dense product at one batch: deep ones in column groups (mm_groups.zig, the same bits). +fn denseOf(p: *const Prompt, e: mtl.ComputeEncoder, x: Ref, q: wts.Affine, y: Ref, M: u32, s: affine_mm.Strides) void { + if (q.k >= mm_groups.dense_from) return mm_groups.dense(e, p.mm.mm_groups, x, p.sums, q, y, M, s); + affine_mm.denseBatch(e, p.mm.mm_bf16, x, p.sums, q, y, M, 1, s); } /// `qmm` over x's rows `ld` elements apart (a slice of a wider row). @@ -204,9 +214,8 @@ fn qmmAt(p: *const Prompt, e: mtl.ComputeEncoder, x: Ref, ld: u32, q: wts.Affine .{ .in = x, .ldx = ld, .out = y, .ldo = pitch, .rows = M }, p.sums, ); - const mm = p.mm.mm_bf16; - affine_mm.rowSumsAt(e, mm, 64, x, p.sums, M, q.k, ld); - affine_mm.denseBatch(e, mm, x, p.sums, q, y, M, 1, .{ .x_row = @intCast(ld), .y_row = @intCast(pitch) }); + affine_mm.rowSumsAt(e, p.mm.mm_bf16, 64, x, p.sums, M, q.k, ld); + denseOf(p, e, x, q, y, M, .{ .x_row = @intCast(ld), .y_row = @intCast(pitch) }); } /// `qmm` with fp32 out (TP2: one Mac's partial of a row-split projection). @@ -215,10 +224,12 @@ fn qmmF32(p: *const Prompt, e: mtl.ComputeEncoder, x: Ref, q: wts.Affine, y: Ref affine_mm.dense(e, p.mm.mm_f32, x, p.sums, q, y, M); } -/// Routed experts' gate, up and SwiGLU on the M rows of `x_in` its pairs read (expert order) into `act` ([n, gate.n]). -fn gateUp(p: *const Prompt, mm: affine_mm.Pipes, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, M: u32, n: u32) void { +/// Routed experts' gate, up and SwiGLU into `act` ([n, gate.n]); `groups`: 4/64 in column groups (the same bits). +fn gateUp(p: *const Prompt, mm: affine_mm.Pipes, groups: bool, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, M: u32, n: u32) void { affine_mm.rowSums(e, mm, 64, x_in, p.sums, M, w.gate.k); - affine_mm.gatherGlu(e, mm, x_in, p.sums, w.gate, w.up, p.offsets, p.order, p.act, n, x.c.experts, x.c.topk, x.c.swiglu_limit); + if (groups) { + mm_groups.gatherGlu(e, p.mm.mm_groups, x_in, p.sums, w.gate, w.up, p.offsets, p.order, p.act, n, x.c.experts, x.c.topk, x.c.swiglu_limit); + } else affine_mm.gatherGlu(e, mm, x_in, p.sums, w.gate, w.up, p.offsets, p.order, p.act, n, x.c.experts, x.c.topk, x.c.swiglu_limit); affine_mm.rowSums(e, mm, 64, p.act, p.sums, n, w.down.k); } @@ -238,9 +249,11 @@ fn add(x: *const fwd.Ctx, e: mtl.ComputeEncoder, a: Ref, b: Ref, out: Ref, n: u3 /// The shared expert on M rows into `ys`. fn shared(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *const wts.Moe, x_in: Ref, M: u32) void { - qmm(p, e, x_in, w.sh_gate_up, p.sgu, M); - swiglu(x, e, p.sgu, p.sact, M, x.c.moe_inter); - qmm(p, e, p.sact, w.sh_down, p.ys, M); + if (fwd.on(x, "s_gateup")) { + qmm(p, e, x_in, w.sh_gate_up, p.sgu, M); + swiglu(x, e, p.sgu, p.sact, M, x.c.moe_inter); + } + if (fwd.on(x, "s_down")) qmm(p, e, p.sact, w.sh_down, p.ys, M); } /// Shared expert, route, experts gathered by expert; by rows, this Mac's halves summed in slot order and swapped. @@ -256,10 +269,13 @@ fn moe(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *const wts if (ep) |t| { if (s & Class.exchange == 0) t.begin(); } else if (s & Class.shared == 0) shared(p, x, e, w, x_in, M); - if (s & Class.route == 0) route(p, x, e, w, x_in, M); + if (!tape.playRoute(p.tape, x, e, p.wts, p.order, p.offsets, M)) { + if (s & Class.route == 0) route(p, x, e, w, x_in, M); + tape.keepRoute(p.tape, x, e, p.wts, p.order, p.offsets, M); + } if (ep) |t| { if (s & Class.routed == 0) { // down's fp32 partials put back in (row, slot) order for the decode's combine - gateUp(p, p.mm.mm_bf16, x, e, w, x_in, M, n); + gateUp(p, p.mm.mm_bf16, false, x, e, w, x_in, M, n); affine_mm.gatherTo(e, p.mm.mm_f32, p.act, p.sums, w.down, p.offsets, p.yf, p.order, n, E); } if (s & Class.exchange == 0) t.sendRows(e, p.yf, p.wts, M); @@ -297,10 +313,13 @@ fn moe(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *const wts g.encode(e, p.mm.wide.?.gather[1], w.down, null, .{ .x = p.act, .offsets = p.offsets, .order = p.order, .out = p.yp }, n, E, 1, D, 0); } else if (s & Class.routed == 0) { // down's rows put back in (row, slot) order for the combine const mm = if (path == .mm4) p.mm.mm_bf16 else p.mm.wide.?.mm2; - gateUp(p, mm, x, e, w, x_in, M, n); - affine_mm.gatherTo(e, mm, p.act, p.sums, w.down, p.offsets, p.yp, p.order, n, E); + const groups = path == .mm4 and mm_groups.fits(w.gate, w.down); + if (fwd.on(x, "e_gateup")) gateUp(p, mm, groups, x, e, w, x_in, M, n); + if (fwd.on(x, "e_down") and groups) { + mm_groups.gatherTo(e, p.mm.mm_groups, p.act, p.sums, w.down, p.offsets, p.yp, p.order, n, E); + } else if (fwd.on(x, "e_down")) affine_mm.gatherTo(e, mm, p.act, p.sums, w.down, p.offsets, p.yp, p.order, n, E); } - if (s & Class.combine != 0) return; + if (s & Class.combine != 0 or !fwd.on(x, "combine")) return; e.setPipeline(k.moe_combine); bind(e, 0, .{ p.ys, p.yp, p.wts }); fwd.shape(e, 3, .{ M, c.topk }); @@ -314,7 +333,8 @@ fn route(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *const w const k = x.k; const E = c.experts; const n = M * c.topk; - moe_route.logits(e, k.route_logits, kernels.route_shape, x_in, w.router, p.logits_r, M); // the decode's bits, any rows + if (fwd.on(x, "r_router")) moe_route.logits(e, k.route_logits, kernels.route_shape, x_in, w.router, p.logits_r, M); // the decode's bits, any rows + if (!fwd.on(x, "r_topk")) return; e.setPipeline(k.route_rows); bind(e, 0, .{ p.logits_r, w.bias }); e.setValue(c.routed_scale, 2); @@ -414,6 +434,11 @@ fn unabsorb(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: *cons affine_mm.denseBatch(e, p.mm.mm_bf16, p.att, p.sums, q, p.vals, M, H, .{ .x_row = @intCast(H * K), .y_row = @intCast(H * c.v_dim), .sums_row = @intCast(H), .x_batch = @intCast(K), .y_batch = @intCast(c.v_dim), .sums_batch = 1, .w_batch = @intCast(per) }); } +/// The index scores' tile rows: 128 (a row's queries read once for 64 blocks), 64 where that leaves the GPU half idle. +pub fn scoreRows(most: u32, n: u32) u32 { + return if (((most + 63) / 64) * ((n + 127) / 128) >= 128) 128 else 64; +} + /// `n` rows' key lists from index scores over every pooled block they read (positions p0..), scores on tensor units. fn selectKeys(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, mi: usize, iq: Ref, iw: Ref, indices: Ref, n: u32, p0: u32) void { const c = x.c; @@ -422,7 +447,8 @@ fn selectKeys(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, mi: us e.setPipeline(x.k.index_scores_nax); bind(e, 0, .{ iq, iw, x.s.mla[mi].pool, p.sscore }); e.setValue([5]u32{ p0, c.qrProj(), c.i_heads, s_stride, n }, 4); - e.dispatchGroups(size((most + 63) / 64, (n + 63) / 64, 1), size(128, 1, 1)); + const rows = scoreRows(most, n); + e.dispatchGroups(size((most + 63) / 64, (n + rows - 1) / rows, 1), size(2 * rows, 1, 1)); e.setPipeline(x.k.index_select); bind(e, 0, .{ p.sscore, indices }); e.setValue([5]u32{ p0, c.i_topk / c.kpool, c.keyWidth(), s_stride, c.keyWidth() }, 2); @@ -439,7 +465,7 @@ fn mla(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, mi: usize, w: fwd.rms(x, e, p.xp, w.q_norm, p.qr, M, c.q_lora, XP, c.q_lora, c.eps); qmm(p, e, p.qr, w.qr_proj, p.qp, M); } - if (fwd.on(x, "mla_cache")) fwd.mlaCache(x, e, mi, w, x_in, p.xp, XP, p.iw, M, pos); + if (fwd.on(x, "mla_cache")) fwd.mlaCache(x, e, mi, w, x_in, p.xp, XP, p.iw, null, M, pos); if (fwd.on(x, "mla_absorb") and w.absorbed != null) { wide.headsBatch( &p.mm.wide.?, @@ -458,7 +484,8 @@ fn mla(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, mi: usize, w: } var dense: u32 = 0; while (dense < M and pos + dense + 1 <= c.i_topk) dense += 1; - if (fwd.on(x, "mla_select")) { + const taped = tape.playKeys(p.tape, x, e, p.indices, M); + if (!taped and fwd.on(x, "mla_select")) { if (dense > 0) { e.setPipeline(x.k.dense_indices); bind(e, 0, .{p.indices}); @@ -471,6 +498,7 @@ fn mla(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, mi: usize, w: selectKeys(p, x, e, mi, p.qp.at((@as(usize, r0) * c.qrProj() + c.mla_heads * c.nope) * 2), p.iw.at(@as(usize, r0) * c.i_heads * 2), p.indices.at(@as(usize, r0) * width * 4), sb, pos + r0); } } + if (!taped) tape.keepKeys(p.tape, x, e, p.indices, M); if (fwd.on(x, "mla_attn")) { if (p.sparse_nax) { e.setPipeline(if (c.tp > 1) x.k.sparse_nax_tp else x.k.sparse_nax); @@ -495,6 +523,7 @@ pub fn backbone(p: *const Prompt, x: *fwd.Ctx, e: mtl.ComputeEncoder, ids: Ref, std.debug.assert(x.sc == ss and M <= p.rows); const s = x.skip; // classes a profile leaves out const Class = fwd.Class; + if (p.tape) |t| t.rewind(); if (s & Class.ends == 0) fwd.embed(x, e, ids, M, pos); const plane = @as(usize, M) * c.hidden * 2; // a trace's capture points: the decode backbone's fwd.snap(x, e, ss.h, plane); @@ -566,5 +595,5 @@ pub fn mtp(p: *const Prompt, x: *const fwd.Ctx, e: mtl.ComputeEncoder, h: Ref, n } else qmm(p, e, p.m_eh, m.eh_proj, p.m_x, M); fwd.rms(x, e, p.m_x, L.in_norm, p.m_xn, M, D, D, D, c.eps); qmm(p, e, p.m_xn, L.attn.mla.x_proj, p.xp, M); - fwd.mlaCache(x, e, c.countKind(.mla), &L.attn.mla, p.m_xn, p.xp, @intCast(std.mem.alignForward(usize, c.xProj(), 64)), p.iw, M, pos); + fwd.mlaCache(x, e, c.countKind(.mla), &L.attn.mla, p.m_xn, p.xp, @intCast(std.mem.alignForward(usize, c.xProj(), 64)), p.iw, null, M, pos); } diff --git a/zig/src/families/glm/prompt_tape.zig b/zig/src/families/glm/prompt_tape.zig new file mode 100644 index 00000000000..163442c015e --- /dev/null +++ b/zig/src/families/glm/prompt_tape.zig @@ -0,0 +1,92 @@ +//! A profile's tape: a chunk's routes and key lists played back, so knock-outs leave later layers' loads as served. +const std = @import("std"); +const mtl = @import("metal"); +const wts = @import("weights.zig"); +const fwd = @import("forward.zig"); +const Ref = wts.Ref; + +pub const Mode = enum { off, record, play }; + +pub const Tape = struct { + route: Ref, // a MoE layer's routes: weights and order (pairs), then the experts' first pairs + keys: Ref, // an MLA layer's key lists: [rows, width] i32 + route_mode: Mode = .off, + keys_mode: Mode = .off, + moe_at: usize = 0, // the pass's next MoE layer + mla_at: usize = 0, // and MLA layer + rows: u32, + + /// Every MoE layer's routes and every MLA layer's key lists of `rows`-row chunks. + pub fn init(arena: anytype, moe_layers: u32, mla_layers: u32, rows: u32, topk: u32, experts: u32, width: u32) !Tape { + return .{ + .route = try arena.buffer(@as(usize, moe_layers) * routeWords(rows, topk, experts) * 4), + .keys = try arena.buffer(@as(usize, mla_layers) * rows * width * 4), + .rows = rows, + }; + } + + /// A pass starts at the first layers. + pub fn rewind(t: *Tape) void { + t.moe_at = 0; + t.mla_at = 0; + } +}; + +fn routeWords(rows: u32, topk: u32, experts: u32) usize { + return 2 * @as(usize, rows) * topk + experts; +} + +fn copy(x: *const fwd.Ctx, e: mtl.ComputeEncoder, src: Ref, dst: Ref, words: usize) void { + e.setPipeline(x.k.copy_u32); + fwd.bind(e, 0, .{ src, dst }); + e.setValue(@as(u32, @intCast(words)), 2); + e.dispatchThreads(fwd.size(words, 1, 1), fwd.size(256, 1, 1)); +} + +/// A MoE layer's routes: false to compute them (then `keepRoute`), true when the tape played them into place. +pub fn playRoute(tape: ?*Tape, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: Ref, order: Ref, offsets: Ref, M: u32) bool { + const t = tape orelse return false; + if (t.route_mode != .play) return false; + routeCopies(t, x, e, w, order, offsets, M, true); + return true; +} + +pub fn keepRoute(tape: ?*Tape, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: Ref, order: Ref, offsets: Ref, M: u32) void { + const t = tape orelse return; + if (t.route_mode == .record) routeCopies(t, x, e, w, order, offsets, M, false) else t.moe_at += 1; +} + +fn routeCopies(t: *Tape, x: *const fwd.Ctx, e: mtl.ComputeEncoder, w: Ref, order: Ref, offsets: Ref, M: u32, play: bool) void { + std.debug.assert(M <= t.rows); + const n = @as(usize, M) * x.c.topk; + const at = t.route.at(t.moe_at * routeWords(t.rows, x.c.topk, x.c.experts) * 4); + const parts = [3]Ref{ w, order, offsets }; + const offs = [3]usize{ 0, n, 2 * n }; + const lens = [3]usize{ n, n, x.c.experts }; + for (parts, offs, lens) |live, o, len| { + if (play) copy(x, e, at.at(o * 4), live, len) else copy(x, e, live, at.at(o * 4), len); + } + t.moe_at += 1; +} + +/// An MLA layer's key lists: false to select them (then `keepKeys`), true when the tape played them into place. +pub fn playKeys(tape: ?*Tape, x: *const fwd.Ctx, e: mtl.ComputeEncoder, indices: Ref, M: u32) bool { + const t = tape orelse return false; + if (t.keys_mode != .play) return false; + keyCopies(t, x, e, indices, M, true); + return true; +} + +pub fn keepKeys(tape: ?*Tape, x: *const fwd.Ctx, e: mtl.ComputeEncoder, indices: Ref, M: u32) void { + const t = tape orelse return; + if (t.keys_mode == .record) keyCopies(t, x, e, indices, M, false) else t.mla_at += 1; +} + +fn keyCopies(t: *Tape, x: *const fwd.Ctx, e: mtl.ComputeEncoder, indices: Ref, M: u32, play: bool) void { + std.debug.assert(M <= t.rows); + const width = x.c.keyWidth(); + const at = t.keys.at(t.mla_at * @as(usize, t.rows) * width * 4); + const words = @as(usize, M) * width; + if (play) copy(x, e, at, indices, words) else copy(x, e, indices, at, words); + t.mla_at += 1; +} diff --git a/zig/src/families/glm/state.zig b/zig/src/families/glm/state.zig index 591a27e6274..ed168eaf5cf 100644 --- a/zig/src/families/glm/state.zig +++ b/zig/src/families/glm/state.zig @@ -98,8 +98,7 @@ pub const Scratch = struct { xp: Ref, qr: Ref, qp: Ref, - ql: Ref, // [rows * heads, rank] - qls: Ref, + ql: Ref, // [rows * heads, rank]: dense rows' scores kernel scales them as it loads scores: Ref, // bf16 [rows, heads, 2048] probs: Ref, att: Ref, // [rows * heads, rank] @@ -107,7 +106,7 @@ pub const Scratch = struct { iw: Ref, sscore: Ref, // fp32 [rows, cap / 4] indices: Ref, // i32 [rows, key width] - sel: Ref, // GlmSelectArgs [rows] + bits: Ref, // u32 [rows, selectWords]: the decode select's marked blocks (glm_select.metal) xf: Ref, logits_r: Ref, // router fp32 [rows, experts] pick: Ref, @@ -140,6 +139,11 @@ pub const Scratch = struct { apart: Ref, // fp32 decode attention blocks: values [rows, blocks, heads, rank], then maxes and sums [rows, blocks, heads] }; +/// The decode select's bitmap words a row: a bit for each of `cap` tokens' pooled blocks. +pub fn selectWords(cap: u32, kpool: u32) u32 { + return (cap / kpool + 1 + 31) / 32; +} + /// The bytes `initState` takes for `cap` tokens (`shared`: with another state's projections). pub fn stateBytes(c: *const cfg.Config, cap: u32, shared: bool) usize { const st_bytes: usize = @as(usize, c.kda_heads) * c.kda_dim * c.kda_dim * 4; @@ -185,17 +189,17 @@ pub fn init(arena: *Arena, c: *const cfg.Config, cap: u32) !struct { state: Stat const H: usize = c.mla_heads; const V: usize = c.vocab; const sizes = [_]usize{ - R * 4, R * 4, R * 4 * D * 2, R * 4 * D * 2, R * D * 2, - R * D * 2, R * D * 2, R * 4 * 4, R * 16 * 4, R * 4, - R * hc.partBytes(.{ .width = @intCast(D), .sinkhorn = 0, .eps_e9 = 0 }), 64, R * c.kdaWidth() * 2, R * c.xProj() * 2, R * c.q_lora * 2, - R * c.qrProj() * 2, R * H * c.kv_lora * 2, R * H * c.kv_lora * 2, R * H * c.i_topk * 2, R * H * c.i_topk * 2, - R * H * c.kv_lora * 2, R * H * c.v_dim * 2, R * c.i_heads * 2, R * (cap / c.kpool + 1) * 4, R * c.keyWidth() * 4, - R * 6 * 4, R * D * 4, R * c.experts * 4, R * c.topk * 4, R * c.topk * 4, - R * c.topk * 4 + 64, R * c.topk * R * 4, 64, 64, R * c.moe_inter * 2, - R * D * 2, R * (c.topk + 1) * c.moe_inter * 2, R * (c.topk + 1) * D * 2, R * 2 * c.dense_inter * 2, R * c.dense_inter * 2, - R * D * 2, R * D * 2, R * V * 2, R * 4, R * D * 2, - R * 2 * D * 2, R * D * 2, R * D * 2, R * D * 2, R * D * 2, - R * V * 2, R * 4, R * c.topk * 4 * 2 + 256, R * c.topk * D * 4, R * c.attnBlocks() * H * (c.kv_lora + 2) * 4, + R * 4, R * 4, R * 4 * D * 2, R * 4 * D * 2, R * D * 2, + R * D * 2, R * D * 2, R * 4 * 4, R * 16 * 4, R * 4, + R * hc.partBytes(.{ .width = @intCast(D), .sinkhorn = 0, .eps_e9 = 0 }), 64, R * c.kdaWidth() * 2, R * c.xProj() * 2, R * c.q_lora * 2, + R * c.qrProj() * 2, R * H * c.kv_lora * 2, R * H * c.i_topk * 2, R * H * c.i_topk * 2, R * H * c.kv_lora * 2, + R * H * c.v_dim * 2, R * c.i_heads * 2, R * (cap / c.kpool + 1) * 4, R * c.keyWidth() * 4, R * selectWords(cap, c.kpool) * 4, + R * D * 4, R * c.experts * 4, R * c.topk * 4, R * c.topk * 4, R * c.topk * 4 + 64, + R * c.topk * R * 4, 64, 64, R * c.moe_inter * 2, R * D * 2, + R * (c.topk + 1) * c.moe_inter * 2, R * (c.topk + 1) * D * 2, R * 2 * c.dense_inter * 2, R * c.dense_inter * 2, R * D * 2, + R * D * 2, R * V * 2, R * 4, R * D * 2, R * 2 * D * 2, + R * D * 2, R * D * 2, R * D * 2, R * D * 2, R * V * 2, + R * 4, R * c.topk * 4 * 2 + 256, R * c.topk * D * 4, R * c.attnBlocks() * H * (c.kv_lora + 2) * 4, }; var total: usize = 0; for (sizes) |n| total += std.mem.alignForward(usize, n, 256); @@ -221,5 +225,5 @@ fn flat(comptime i: usize) usize { test "the scratch sizes line up with its fields" { const n = @typeInfo(Scratch).@"struct".field_names.len; - try std.testing.expectEqual(@as(usize, 54), n); + try std.testing.expectEqual(@as(usize, 53), n); } diff --git a/zig/src/families/idol/config.zig b/zig/src/families/idol/config.zig new file mode 100644 index 00000000000..d399755886a --- /dev/null +++ b/zig/src/families/idol/config.zig @@ -0,0 +1,71 @@ +//! Idol's denoiser geometry, and the check that a snapshot's config.json names that denoiser. +const std = @import("std"); + +pub const hidden = 1024; +pub const heads = 16; +pub const head_dim = hidden / heads; +pub const ffn = 4 * hidden; +pub const layers = 24; +/// The noise and condition refiners' blocks, each. +pub const refiners = 2; +pub const latent_rows = 8192; +pub const latent_channels = 16; +pub const camera_channels = 5; +/// DINOv3 ViT-H+/16 rows at 1024 x 1024: 64 x 64 patches, the class token and four registers. +pub const cond_rows = 4101; +pub const cond_channels = 1280; +pub const cond2_channels = 128; +/// Latent, condition and camera rows through the joint blocks. +pub const joint_rows = latent_rows + cond_rows + 1; +/// RePo's hidden width (model_channels / 8) and its frequencies per head: 10, 10 and 12 for x, y and z. +pub const repo_hidden = hidden / 8; +pub const repo_pairs = head_dim / 2; +pub const time_dim = 256; +/// Every transformer block's LayerNorm32, fixed in idol-sdk's layers.py, not a config setting. +pub const block_eps: f32 = 1e-6; +/// RePo's LayerNorm32 and the output's F.layer_norm take torch's default. +pub const default_eps: f32 = 1e-5; +/// Modulated blocks: the noise refiner's, then the joint blocks. +pub const modulated = refiners + layers; + +/// Accepts the snapshot config whose denoiser this family runs (LatentSeqMMFlowModel at its released size). +pub fn check(gpa: std.mem.Allocator, text: []const u8) !void { + const doc = try std.json.parseFromSlice(std.json.Value, gpa, text, .{}); + defer doc.deinit(); + if (doc.value != .object) return error.BadConfig; + const den = doc.value.object.get("denoiser") orelse return error.BadConfig; + if (den != .object) return error.BadConfig; + const name = den.object.get("name") orelse return error.BadConfig; + if (name != .string or !std.mem.eql(u8, name.string, "LatentSeqMMFlowModel")) return error.NotIdol; + const args = den.object.get("args") orelse return error.BadConfig; + if (args != .object) return error.BadConfig; + const want = .{ .{ "q_token_length", latent_rows }, .{ "in_channels", latent_channels }, .{ "cam_channels", camera_channels }, .{ "model_channels", hidden }, .{ "cond_channels", cond_channels }, .{ "cond2_channels", cond2_channels }, .{ "num_blocks", layers }, .{ "num_refiner_blocks", refiners }, .{ "num_heads", heads }, .{ "mlp_ratio", 4 } }; + inline for (want) |kv| { + const v = args.object.get(kv[0]) orelse return error.BadConfig; + if (v != .integer or v.integer != kv[1]) { + std.log.warn("idol: denoiser {s} is not {d}; this family runs the released geometry only", .{ kv[0], kv[1] }); + return error.UnsupportedGeometry; + } + } +} + +const sample = + \\{"denoiser": {"name": "LatentSeqMMFlowModel", "args": {"q_token_length": 8192, "in_channels": 16, + \\ "cam_channels": 5, "model_channels": 1024, "cond_channels": 1280, "cond2_channels": 128, "num_blocks": 24, + \\ "num_refiner_blocks": 2, "num_heads": 16, "mlp_ratio": 4}}, "image_size": 1024, "max_voxel_level": 8} +; + +test "the released denoiser config passes; another depth, width or class does not" { + const a = std.testing.allocator; + try check(a, sample); + const deeper = try std.mem.replaceOwned(u8, a, sample, "\"num_blocks\": 24", "\"num_blocks\": 12"); + defer a.free(deeper); + try std.testing.expectError(error.UnsupportedGeometry, check(a, deeper)); + const missing = try std.mem.replaceOwned(u8, a, sample, "\"mlp_ratio\": 4", "\"mlp\": 4"); + defer a.free(missing); + try std.testing.expectError(error.BadConfig, check(a, missing)); + const other = try std.mem.replaceOwned(u8, a, sample, "LatentSeqMMFlowModel", "LatentFlowModel"); + defer a.free(other); + try std.testing.expectError(error.NotIdol, check(a, other)); + try std.testing.expectError(error.BadConfig, check(a, "{\"decoder\": {}}")); +} diff --git a/zig/src/families/idol/cuda.zig b/zig/src/families/idol/cuda.zig new file mode 100644 index 00000000000..ea600075b4e --- /dev/null +++ b/zig/src/families/idol/cuda.zig @@ -0,0 +1,20 @@ +//! Idol's denoiser on CUDA: driven by tf-idol-cuda beside the lane engine, as the Metal family is by tf-idol. +pub const config = @import("config.zig"); +pub const host = @import("host.zig"); +pub const reference = @import("reference.zig"); +pub const kernels = @import("cuda_kernels.zig"); +pub const Model = @import("cuda_model.zig").Model; +pub const Condition = @import("cuda_model.zig").Condition; +pub const Timing = @import("cuda_model.zig").Timing; +pub const seconds = @import("cuda_model.zig").seconds; +pub const admitted = @import("cuda_model.zig").admitted; + +test { + _ = @import("cuda_kernels.zig"); + _ = @import("cuda_gemm.zig"); + _ = @import("cuda_model.zig"); + _ = @import("cuda_weights.zig"); + _ = config; + _ = host; + _ = reference; +} diff --git a/zig/src/families/idol/cuda_gemm.zig b/zig/src/families/idol/cuda_gemm.zig new file mode 100644 index 00000000000..a39a36f3476 --- /dev/null +++ b/zig/src/families/idol/cuda_gemm.zig @@ -0,0 +1,58 @@ +//! Idol's products on cuBLASLt: fp16 block linears into fp32 sums, and true fp32 products (no TF32), a plan a shape. +const std = @import("std"); +const cuda = @import("cuda"); +const lt_ = cuda.cublaslt; + +pub const workspace_bytes = 32 << 20; + +/// The operands' type: fp16 for the blocks' linears, fp32 for RePo's maps and the condition and output projections. +pub const In = enum { f16, f32 }; + +pub const Gemms = struct { + gpa: std.mem.Allocator, + lt: lt_.Library, + workspace: cuda.DeviceBuffer, + plans: std.AutoHashMapUnmanaged([4]u64, lt_.Linear) = .empty, + + pub fn init(gpa: std.mem.Allocator, d: *const cuda.Driver) !Gemms { + var lt = try lt_.Library.open(); + errdefer lt.close(); + return .{ .gpa = gpa, .lt = lt, .workspace = try cuda.DeviceBuffer.alloc(d, workspace_bytes) }; + } + + pub fn deinit(g: *Gemms) void { + var it = g.plans.valueIterator(); + while (it.next()) |l| l.deinit(); + g.plans.deinit(g.gpa); + g.workspace.free(); + g.lt.close(); + } + + /// y fp32 [rows, n] (rows `n` apart) = x [rows, k] . w [n, k]^T with fp32 compute and sums, on `stream`. + pub fn run(g: *Gemms, s: cuda.Stream, in: In, x: u64, w: u64, y: u64, rows: usize, n: usize, k: usize) !void { + if (rows == 0) return; + const p = try g.plan(in, rows, n, k); + try p.run(x, w, y, g.workspace.ptr, workspace_bytes, s.handle); + } + + fn plan(g: *Gemms, in: In, rows: usize, n: usize, k: usize) !*const lt_.Linear { + const got = try g.plans.getOrPut(g.gpa, .{ @backingInt(in), rows, n, k }); + if (got.found_existing) return got.value_ptr; + const t: lt_.DataType = switch (in) { + .f16 => .f16, + .f32 => .f32, + }; + got.value_ptr.* = lt_.Linear.initTyped(&g.lt, rows, n, k, t, .f32, workspace_bytes, .none) catch |e| { + g.plans.removeByPtr(got.key_ptr); + return e; + }; + return got.value_ptr; + } +}; + +test "cuBLASLt's fp32 compute type is CUBLAS_COMPUTE_32F, not a TF32 or fast mode" { + // cublasComputeType_t: 68 is CUBLAS_COMPUTE_32F; 74 and 77 are its FAST_TF32 and FAST_16F forms + try std.testing.expectEqual(@as(c_int, 68), lt_.compute_32f); + try std.testing.expectEqual(@as(c_int, 2), @backingInt(lt_.DataType.f16)); + try std.testing.expectEqual(@as(c_int, 0), @backingInt(lt_.DataType.f32)); +} diff --git a/zig/src/families/idol/cuda_kernels.zig b/zig/src/families/idol/cuda_kernels.zig new file mode 100644 index 00000000000..02aa16fc79b --- /dev/null +++ b/zig/src/families/idol/cuda_kernels.zig @@ -0,0 +1,153 @@ +//! Idol's own CUDA kernels (idol.cu): LayerNorms, RePo's angles, q/k turned and normed, epilogues, head-64 attention. +const std = @import("std"); +const cuda = @import("cuda"); +const cfg = @import("config.zig"); + +fn int(x: usize) c_int { + return @intCast(x); +} + +fn ceil(n: usize, d: usize) u32 { + return @intCast((n + d - 1) / d); +} + +/// The LayerNorm's form: plain, affine (fp32 weight and bias), or modulated (after the fp16 rounding). +pub const Norm = enum(c_int) { plain = 0, affine = 1, modulated = 2 }; + +/// The attention's tile: 8 warps of 16 query rows a block, two buffers of 64 K and V rows padded to 9 chunks of 16 B. +pub const attention_warps = 8; +pub const attention_smem: u32 = 2 * 2 * 64 * (cfg.head_dim / 8 + 1) * 16; + +pub const Kernels = struct { + mod: cuda.Module, + norm: cuda.Function, + norm32: cuda.Function, + repo: cuda.Function, + qk: cuda.Function, + gate_add: cuda.Function, + bias: cuda.Function, + embed: cuda.Function, + cond: cuda.Function, + bias32: cuda.Function, + attention: cuda.Function, + + pub fn load(d: *const cuda.Driver) !Kernels { + if (!cuda.kernels.available) return error.BuiltWithoutKernels; + var mod = try cuda.Module.load(d, cuda.kernels.idol); + errdefer mod.unload(); + var k: Kernels = undefined; + k.mod = mod; + inline for (.{ "norm", "norm32", "repo", "qk", "gate_add", "bias", "embed", "cond", "bias32", "attention" }) |n| + @field(k, n) = try mod.function("tf_idol_" ++ n); + return k; + } + + pub fn unload(k: *Kernels) void { + k.mod.unload(); + } +}; + +fn go(f: cuda.Function, s: cuda.Stream, grid: cuda.Dim3, threads: u32, a: *cuda.Args) !void { + try cuda.launch.launch(f, .{ .grid = grid, .block = .{ .x = threads } }, s, a); +} + +fn addAll(a: *cuda.Args, ptrs: []const u64) void { + for (ptrs) |p| a.add(p); +} + +/// y fp16 = the LayerNorm32 of x's `rows` rows, rounded to fp16: plain, affine (w, b fp32) or modulated (s1, sh fp16). +pub fn norm(k: *const Kernels, s: cuda.Stream, x: u64, w: u64, b: u64, s1: u64, sh: u64, y: u64, rows: usize, eps: f32, mode: Norm) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ x, w, b, s1, sh, y }); + a.add(int(cfg.hidden)); + a.add(eps); + a.add(@backingInt(mode)); + try go(k.norm, s, .{ .x = @intCast(rows) }, 256, &a); +} + +/// y fp32 = the LayerNorm of x's rows times w plus b (affine), or times (1 + w) plus b (modulated). +pub fn norm32(k: *const Kernels, s: cuda.Stream, x: u64, w: u64, b: u64, y: u64, rows: usize, eps: f32, mode: Norm) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ x, w, b, y }); + a.add(int(cfg.hidden)); + a.add(eps); + a.add(@backingInt(mode)); + try go(k.norm32, s, .{ .x = @intCast(rows) }, 256, &a); +} + +/// cos, sin [rows, 16, 32] fp32 of RePo from its gate | content sums [rows, 256] fp32, final map and frequencies. +pub fn repo(k: *const Kernels, s: cuda.Stream, gc: u64, final: u64, freqs: u64, cos: u64, sin: u64, rows: usize) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ gc, final, freqs, cos, sin }); + a.add(int(rows)); + try go(k.repo, s, .{ .x = @intCast(rows) }, 64, &a); +} + +/// Attention's packed rows [rows, q | k | v] from qkv rows: q, k turned by cos, sin, normed by gq, gk times 8. +pub fn qk(k: *const Kernels, s: cuda.Stream, qkv: u64, gq: u64, gk: u64, cos: u64, sin: u64, out: u64, rows: usize) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ qkv, gq, gk, cos, sin, out }); + a.add(int(rows)); + a.add(@as(f32, @sqrt(@as(f32, cfg.head_dim)))); + try go(k.qk, s, .{ .x = @intCast(rows), .y = ceil(cfg.heads, 8) }, 256, &a); +} + +/// x [rows, width] += y gated by the fp16 vector g, in place. +pub fn gateAdd(k: *const Kernels, s: cuda.Stream, x: u64, y: u64, g: u64, rows: usize, width: usize) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ x, y, g }); + for ([_]usize{ width, rows }) |v| a.add(int(v)); + try go(k.gate_add, s, .{ .x = @intCast(rows), .y = ceil(width, 256) }, 256, &a); +} + +/// y fp16 = fp16(acc + b) from fp32 sums, then fp16(GELU) when `gelu`. +pub fn bias(k: *const Kernels, s: cuda.Stream, acc: u64, b: u64, y: u64, rows: usize, width: usize, gelu: bool) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ acc, b, y }); + for ([_]usize{ width, rows }) |v| a.add(int(v)); + a.add(@as(c_int, @intFromBool(gelu))); + try go(k.bias, s, .{ .x = @intCast(rows), .y = ceil(width, 256) }, 256, &a); +} + +/// x [rows, 1024] = fp16(fp16(z w^T + b) + pe), z [rows, 16] fp32. +pub fn embed(k: *const Kernels, s: cuda.Stream, z: u64, w: u64, b: u64, pe: u64, x: u64, rows: usize) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ z, w, b, pe, x }); + a.add(int(rows)); + try go(k.embed, s, .{ .x = @intCast(rows), .y = ceil(cfg.hidden, 256) }, 256, &a); +} + +/// y [rows, width] = fp16((a + ba) + (c + bc)). +pub fn cond(k: *const Kernels, s: cuda.Stream, a_: u64, ba: u64, c: u64, bc: u64, y: u64, rows: usize, width: usize) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ a_, ba, c, bc, y }); + for ([_]usize{ width, rows }) |v| a.add(int(v)); + try go(k.cond, s, .{ .x = @intCast(rows), .y = ceil(width, 256) }, 256, &a); +} + +/// y [rows, width] += b by column, fp32. +pub fn bias32(k: *const Kernels, s: cuda.Stream, y: u64, b: u64, rows: usize, width: usize) !void { + var a: cuda.Args = .{}; + addAll(&a, &.{ y, b }); + for ([_]usize{ width, rows }) |v| a.add(int(v)); + try go(k.bias32, s, .{ .x = @intCast(rows), .y = ceil(width, 256) }, 256, &a); +} + +/// out [rows, heads 64] = softmax(q k^T scale) v of packed rows [rows, q | k | v heads 64], fp16, every key. +pub fn attention(k: *const Kernels, s: cuda.Stream, qkv: u64, out: u64, rows: usize, heads: usize, scale: f32) !void { + if (rows == 0) return; + var a: cuda.Args = .{}; + addAll(&a, &.{ qkv, out }); + for ([_]usize{ rows, heads }) |v| a.add(int(v)); + a.add(scale); + const grid: cuda.Dim3 = .{ .x = ceil(rows, 16 * attention_warps), .y = @intCast(heads) }; + try cuda.launch.launch(k.attention, .{ .grid = grid, .block = .{ .x = 32 * attention_warps }, .shared = attention_smem }, s, &a); +} + +test "launch geometry: rows on grid x, 256-column strips on y, attention's tile under 48 KiB" { + try std.testing.expectEqual(@as(u32, 4), ceil(cfg.hidden, 256)); + try std.testing.expectEqual(@as(u32, 2), ceil(cfg.heads, 8)); + try std.testing.expectEqual(@as(u32, 97), ceil(cfg.joint_rows, 16 * attention_warps)); + try std.testing.expectEqual(@as(u32, 36864), attention_smem); + try std.testing.expect(attention_smem <= 48 * 1024); +} diff --git a/zig/src/families/idol/cuda_model.zig b/zig/src/families/idol/cuda_model.zig new file mode 100644 index 00000000000..b4dd9792f77 --- /dev/null +++ b/zig/src/families/idol/cuda_model.zig @@ -0,0 +1,288 @@ +//! Idol's denoiser on CUDA: the image condition refined once, then latent, condition and camera rows each step. +const std = @import("std"); +const cuda = @import("cuda"); +const cfg = @import("config.zig"); +const host = @import("host.zig"); +const wts = @import("cuda_weights.zig"); +const ks = @import("cuda_kernels.zig"); +const gm = @import("cuda_gemm.zig"); + +const H = cfg.hidden; +const F = cfg.ffn; +const L = cfg.joint_rows; +const R = cfg.latent_rows; +const C = cfg.cond_rows; + +pub const Timing = struct { wall: f64, gpu: f64, host: f64 }; + +pub fn seconds() f64 { + const c = @import("sys").c; + var ts: c.timespec = undefined; + _ = c.clock_gettime(c.CLOCK.MONOTONIC, &ts); + return @as(f64, @floatFromInt(ts.sec)) + @as(f64, @floatFromInt(ts.nsec)) * 1e-9; +} + +/// The GPUs this family admits: GB10 (sm_121) and the RTX 50 / PRO Blackwell cards (sm_120), refused others by name. +pub fn admitted(sm: u32) bool { + return sm == 120 or sm == 121; +} + +/// A refined image condition: the condition refiner's rows [4101, 1024] fp16 on the device. +pub const Condition = struct { + rows: cuda.DeviceBuffer, + + pub fn deinit(c: *Condition) void { + c.rows.free(); + } +}; + +/// The scratch buffer's parts in bytes, in the order of Model's views. +const parts = [_]usize{ + L * H * 2, L * H * 2, L * 3 * H * 2, L * 3 * H * 2, L * H * 2, + L * H * 2, L * F * 2, L * F * 4, L * H * 4, L * 2 * cfg.repo_hidden * 4, + L * cfg.heads * 32 * 4, L * cfg.heads * 32 * 4, R * cfg.latent_channels * 4, R * cfg.latent_channels * 4, cfg.modulated * host.vectors * H * 2, + 2 * H * 4, C * cfg.cond_channels * 4, C * cfg.cond2_channels * 4, H * 2, R * H * 2, +}; + +pub fn scratchBytes() usize { + var total: usize = 0; + for (parts) |n| total += std.mem.alignForward(usize, n, 256); + return total; +} + +pub const Model = struct { + gpa: std.mem.Allocator, + d: *const cuda.Driver, + stream: cuda.Stream, + k: ks.Kernels, + gemms: gm.Gemms, + w: *wts.Weights, + scratch: cuda.DeviceBuffer, + /// A pass's start and end on the stream, for its GPU time. + marks: [2]cuda.Event, + // fp16 rows: the stream, a norm's output, a qkv projection, attention's packed heads, its output, a projection's + x: u64 = 0, + xn: u64 = 0, + qkv: u64 = 0, + qkh: u64 = 0, + att: u64 = 0, + y: u64 = 0, + /// the MLP's GELU rows, and a block linear's fp32 sums before its bias + u: u64 = 0, + acc: u64 = 0, + /// fp32 rows: RePo's norm (and the condition's two projections), its gate | content sums, cos and sin + ln: u64 = 0, + gc: u64 = 0, + cos: u64 = 0, + sin: u64 = 0, + lat: u64 = 0, + vel: u64 = 0, + mods: u64 = 0, + head: u64 = 0, + f1: u64 = 0, + f2: u64 = 0, + ones: u64 = 0, + pe: u64 = 0, + /// The model time `mods` and `head` hold, if any, and their host copies. + time: ?f32 = null, + mods_host: host.Mods = undefined, + head_host: [2][H]f32 = undefined, + /// The stream's rows downloaded for `stream`, and the camera row each forward reads back. + rows_host: []f16 = &.{}, + + /// The denoiser of snapshot folder `dir` on `ctx`'s GPU, if it is one this family admits. + pub fn load(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: []const u8) !*Model { + const sm = try ctx.capability(); + if (!admitted(sm)) { + var buf: [256]u8 = undefined; + const name = ctx.name(&buf) catch "this GPU"; + std.log.err("idol: {s} (sm_{d}) is not a GPU this family admits; it runs on sm_120 and sm_121 alone", .{ name, sm }); + return error.UncheckedGpu; + } + const d = ctx.d; + const t = try gpa.create(Model); + errdefer gpa.destroy(t); + t.* = .{ .gpa = gpa, .d = d, .stream = undefined, .k = undefined, .gemms = undefined, .w = undefined, .scratch = undefined, .marks = undefined }; + t.rows_host = try gpa.alloc(f16, L * H); + errdefer gpa.free(t.rows_host); + t.stream = try cuda.Stream.init(d, false); + errdefer t.stream.deinit(); + t.k = try ks.Kernels.load(d); + errdefer t.k.unload(); + t.gemms = try gm.Gemms.init(gpa, d); + errdefer t.gemms.deinit(); + t.w = try wts.load(gpa, io, d, dir); + errdefer { + t.w.deinit(); + gpa.destroy(t.w); + } + t.scratch = try cuda.DeviceBuffer.alloc(d, scratchBytes()); + errdefer t.scratch.free(); + t.marks[0] = try cuda.Event.init(d, true); + errdefer t.marks[0].deinit(); + t.marks[1] = try cuda.Event.init(d, true); + errdefer t.marks[1].deinit(); + var at: usize = t.scratch.ptr; + const views = [_]*u64{ &t.x, &t.xn, &t.qkv, &t.qkh, &t.att, &t.y, &t.u, &t.acc, &t.ln, &t.gc, &t.cos, &t.sin, &t.lat, &t.vel, &t.mods, &t.head, &t.f1, &t.f2, &t.ones, &t.pe }; + for (views, parts) |view, n| { + view.* = at; + at += std.mem.alignForward(usize, n, 256); + } + const ones = try gpa.alloc(f16, H); + defer gpa.free(ones); + @memset(ones, 1.0); + try t.upload(t.ones, std.mem.sliceAsBytes(ones)); + const pe = try gpa.alloc(f16, R * H); + defer gpa.free(pe); + host.positions(t.w.host.pos, pe); + try t.upload(t.pe, std.mem.sliceAsBytes(pe)); + return t; + } + + pub fn deinit(t: *Model) void { + for (&t.marks) |*m| m.deinit(); + t.scratch.free(); + t.w.deinit(); + t.gpa.destroy(t.w); + t.gemms.deinit(); + t.k.unload(); + t.stream.deinit(); + t.gpa.free(t.rows_host); + t.gpa.destroy(t); + } + + fn upload(t: *const Model, at: u64, bytes: []const u8) !void { + try t.d.check(t.d.api.cuMemcpyHtoDAsync_v2(at, bytes.ptr, bytes.len, t.stream.handle), "cuMemcpyHtoDAsync"); + try t.stream.synchronize(); + } + + fn download(t: *const Model, out: []u8, at: u64) !void { + try t.d.check(t.d.api.cuMemcpyDtoHAsync_v2(out.ptr, at, out.len, t.stream.handle), "cuMemcpyDtoHAsync"); + try t.stream.synchronize(); + } + + fn copy(t: *const Model, to: u64, from: u64, n: usize) !void { + try t.d.check(t.d.api.cuMemcpyDtoDAsync_v2(to, from, n, t.stream.handle), "cuMemcpyDtoDAsync"); + } + + /// The modulated block `i`'s vector `part` (0 shift, 1 one plus scale, 2 gate; 3 to 5 the MLP's). + fn vec(t: *const Model, i: usize, part: usize) u64 { + return t.mods + ((i * host.vectors) + part) * H * 2; + } + + /// Every modulated block's vectors and the output's at model time `time`, unless they are already there. + fn modulate(t: *Model, time: f32) !void { + if (t.time == time) return; + t.time = null; + host.modulation(t.w.host, time, &t.mods_host, &t.head_host); + try t.upload(t.mods, std.mem.sliceAsBytes(&t.mods_host)); + try t.upload(t.head, std.mem.sliceAsBytes(&t.head_host)); + t.time = time; + } + + /// The image condition: DINOv3 rows [4101, 1280] and FLUX.2 VAE rows [4101, 128] (zeros: the negative branch). + pub fn condition(t: *Model, feature1: []const f32, feature2: []const f32) !Condition { + if (feature1.len != C * cfg.cond_channels or feature2.len != C * cfg.cond2_channels) return error.ConditionRows; + var c: Condition = .{ .rows = try cuda.DeviceBuffer.alloc(t.d, C * H * 2) }; + errdefer c.rows.free(); + try t.upload(t.f1, std.mem.sliceAsBytes(feature1)); + try t.upload(t.f2, std.mem.sliceAsBytes(feature2)); + const a = t.ln; + const b = t.ln + C * H * 4; + try t.gemms.run(t.stream, .f32, t.f1, t.w.cond, a, C, H, cfg.cond_channels); + try t.gemms.run(t.stream, .f32, t.f2, t.w.cond2, b, C, H, cfg.cond2_channels); + try ks.cond(&t.k, t.stream, a, t.w.cond_b, b, t.w.cond2_b, t.x, C, H); + for (t.w.context, t.w.context_repo) |blk, r| try t.block(blk, r, C, null); + try t.copy(c.rows.ptr, t.x, C * H * 2); + try t.stream.synchronize(); + return c; + } + + /// The velocity of latent [8192, 16] and camera [5] at model time `time` (1000 times t) under condition `c`. + pub fn forward(t: *Model, c: *const Condition, latent: []const f32, camera: *const [cfg.camera_channels]f32, time: f32, velocity: []f32, camera_velocity: *[cfg.camera_channels]f32) !Timing { + if (latent.len != R * cfg.latent_channels or velocity.len != latent.len) return error.LatentRows; + const started = seconds(); + try t.modulate(time); + try t.upload(t.lat, std.mem.sliceAsBytes(latent)); + const camera_row = t.rows_host[0..H]; + host.cameraToken(t.w.host, camera, camera_row); + try t.upload(t.x + (L - 1) * H * 2, std.mem.sliceAsBytes(camera_row)); + const spent = seconds() - started; + try t.marks[0].record(t.stream); + try t.copy(t.x + R * H * 2, c.rows.ptr, C * H * 2); + try ks.embed(&t.k, t.stream, t.lat, t.w.input, t.w.input_b, t.pe, t.x, R); + for (t.w.noise, t.w.noise_repo, 0..) |blk, r, i| try t.block(blk, r, R, i); + for (t.w.blocks, t.w.repo, 0..) |blk, r, i| try t.block(blk, r, L, cfg.refiners + i); + try ks.norm32(&t.k, t.stream, t.x, t.head + H * 4, t.head, t.ln, R, cfg.default_eps, .modulated); + try t.gemms.run(t.stream, .f32, t.ln, t.w.out, t.vel, R, cfg.latent_channels, H); + try ks.bias32(&t.k, t.stream, t.vel, t.w.out_b, R, cfg.latent_channels); + try t.marks[1].record(t.stream); + try t.download(std.mem.sliceAsBytes(velocity), t.vel); + try t.download(std.mem.sliceAsBytes(camera_row), t.x + (L - 1) * H * 2); + host.cameraVelocity(t.w.host, camera_row, &t.head_host, camera_velocity); + const gpu = @as(f64, try cuda.Event.elapsedMs(t.marks[0], t.marks[1])) / 1000; + return .{ .wall = seconds() - started, .gpu = gpu, .host = spent }; + } + + /// Modulated block `index` alone at model time `time` on `rows` (the noise refiner's 8192, else 12294) given rows. + pub fn blockAt(t: *Model, index: usize, rows: []const f16, time: f32) !void { + const n: usize = if (index < cfg.refiners) R else L; + if (index >= cfg.modulated or rows.len != n * H) return error.BlockRows; + try t.modulate(time); + try t.upload(t.x, std.mem.sliceAsBytes(rows)); + if (index < cfg.refiners) { + try t.block(t.w.noise[index], t.w.noise_repo[index], n, index); + } else try t.block(t.w.blocks[index - cfg.refiners], t.w.repo[index - cfg.refiners], n, index); + try t.stream.synchronize(); + } + + /// The residual stream's first `rows` rows as the last pass left them, fp16 (valid until the next call). + pub fn residual(t: *Model, rows: usize) ![]const f16 { + const out = t.rows_host[0 .. rows * H]; + try t.download(std.mem.sliceAsBytes(out), t.x); + return out; + } + + /// y fp16 [rows, n] = fp16(x w^T + b) from fp32 sums, then fp16(GELU) when `gelu`. + fn linear(t: *Model, x: u64, w: u64, b: u64, y: u64, rows: usize, n: usize, k: usize, gelu: bool) !void { + try t.gemms.run(t.stream, .f16, x, w, t.acc, rows, n, k); + try ks.bias(&t.k, t.stream, t.acc, b, y, rows, n, gelu); + } + + /// One block over the stream's first `rows` rows: modulated block `mod`, or the condition refiner's (null). + fn block(t: *Model, b: wts.Block, r: wts.Repo, rows: usize, mod: ?usize) !void { + const k = &t.k; + const s = t.stream; + // RePo: angles from the block's input rows, its projections in fp32 + try ks.norm32(k, s, t.x, r.norm, r.norm_b, t.ln, rows, cfg.default_eps, .affine); + try t.gemms.run(s, .f32, t.ln, r.maps, t.gc, rows, 2 * cfg.repo_hidden, H); + try ks.repo(k, s, t.gc, r.final, r.freqs, t.cos, t.sin, rows); + if (mod) |m| { + try ks.norm(k, s, t.x, 0, 0, t.vec(m, 1), t.vec(m, 0), t.xn, rows, cfg.block_eps, .modulated); + } else try ks.norm(k, s, t.x, b.norm1, b.norm1_b, t.ones, t.ones, t.xn, rows, cfg.block_eps, .affine); + try t.linear(t.xn, b.qkv, b.qkv_b, t.qkv, rows, 3 * H, H, false); + try ks.qk(k, s, t.qkv, b.q_norm, b.k_norm, t.cos, t.sin, t.qkh, rows); + try ks.attention(k, s, t.qkh, t.att, rows, cfg.heads, 1.0 / @sqrt(@as(f32, cfg.head_dim))); + try t.linear(t.att, b.out, b.out_b, t.y, rows, H, H, false); + try ks.gateAdd(k, s, t.x, t.y, if (mod) |m| t.vec(m, 2) else t.ones, rows, H); + if (mod) |m| { + try ks.norm(k, s, t.x, 0, 0, t.vec(m, 4), t.vec(m, 3), t.xn, rows, cfg.block_eps, .modulated); + } else try ks.norm(k, s, t.x, b.norm2, b.norm2_b, t.ones, t.ones, t.xn, rows, cfg.block_eps, .affine); + try t.linear(t.xn, b.up, b.up_b, t.u, rows, F, H, true); + try t.linear(t.u, b.down, b.down_b, t.y, rows, H, F, false); + try ks.gateAdd(k, s, t.x, t.y, if (mod) |m| t.vec(m, 5) else t.ones, rows, H); + } +}; + +test "scratch for the joint rows: every part 256-aligned, the condition's two projections fit RePo's norm rows" { + try std.testing.expectEqual(@as(usize, 12294), L); + try std.testing.expect(2 * C * H * 4 <= parts[8]); + try std.testing.expect(scratchBytes() < 1 << 30); + // the kernels index rows and offsets as c_int + try std.testing.expect(L * F < std.math.maxInt(c_int)); +} + +test "admission: sm_120 and sm_121 alone" { + try std.testing.expect(admitted(121) and admitted(120)); + for ([_]u32{ 80, 86, 89, 90, 100, 103, 122 }) |sm| try std.testing.expect(!admitted(sm)); +} diff --git a/zig/src/families/idol/cuda_weights.zig b/zig/src/families/idol/cuda_weights.zig new file mode 100644 index 00000000000..82fb1e97da8 --- /dev/null +++ b/zig/src/families/idol/cuda_weights.zig @@ -0,0 +1,191 @@ +//! Idol's denoiser tensors on CUDA: blocks' linears and biases to fp16 as idol-sdk does, the rest fp32. +const std = @import("std"); +const cuda = @import("cuda"); +const core = @import("core"); +const cfg = @import("config.zig"); +const host = @import("host.zig"); + +const H = cfg.hidden; + +/// A block's device addresses: fp16 linears and biases, fp32 head RMSNorm gammas; fp32 norms in the refiner alone. +pub const Block = struct { qkv: u64, qkv_b: u64, out: u64, out_b: u64, up: u64, up_b: u64, down: u64, down_b: u64, q_norm: u64, k_norm: u64, norm1: u64 = 0, norm1_b: u64 = 0, norm2: u64 = 0, norm2_b: u64 = 0 }; + +/// A RePo layer: fp32 norm, gate | content maps [256, 1024], final map [48, 128] and its 32 frequencies. +pub const Repo = struct { norm: u64, norm_b: u64, maps: u64, final: u64, freqs: u64 }; + +pub const Weights = struct { + gpa: std.mem.Allocator, + ck: core.Checkpoint, + buffers: std.ArrayList(cuda.DeviceBuffer) = .empty, + noise: [cfg.refiners]Block = undefined, + context: [cfg.refiners]Block = undefined, + blocks: [cfg.layers]Block = undefined, + noise_repo: [cfg.refiners]Repo = undefined, + context_repo: [cfg.refiners]Repo = undefined, + repo: [cfg.layers]Repo = undefined, + input: u64 = 0, + input_b: u64 = 0, + cond: u64 = 0, + cond_b: u64 = 0, + cond2: u64 = 0, + cond2_b: u64 = 0, + out: u64 = 0, + out_b: u64 = 0, + /// The host's tensors, mapped from the checkpoint (host.modulation, cameraToken, cameraVelocity, positions). + host: host.Host = undefined, + bytes: u64 = 0, + + pub fn deinit(w: *Weights) void { + for (w.buffers.items) |*b| b.free(); + w.buffers.deinit(w.gpa); + w.ck.close(); + } + + fn typed(w: *Weights, name: []const u8, shape: []const usize) !core.checkpoint.Tensor { + const t = try w.ck.get(name); + if (t.dtype != .f32 or t.rank != shape.len or !std.mem.eql(usize, t.shape[0..t.rank], shape)) { + std.log.err("idol: {s} is {t} {any}; the denoiser reads f32 {any}", .{ name, t.dtype, t.shape[0..t.rank], shape }); + return error.UnexpectedTensor; + } + if (@intFromPtr(t.bytes.ptr) % 4 != 0) return error.UnalignedTensor; + return t; + } + + /// The fp32 tensor `name` of `shape`, its values on the host (mapped from the checkpoint). + fn floats(w: *Weights, name: []const u8, shape: []const usize) ![]const f32 { + const t = try w.typed(name, shape); + return @alignCast(std.mem.bytesAsSlice(f32, t.bytes)); + } + + fn upload(w: *Weights, d: *const cuda.Driver, bytes: []const u8) !u64 { + var b = try cuda.DeviceBuffer.fromHost(d, bytes); + errdefer b.free(); + try w.buffers.append(w.gpa, b); + w.bytes += b.len; + return b.ptr; + } + + /// The fp32 tensor `name` of `shape` on the device as stored. + fn take(w: *Weights, d: *const cuda.Driver, name: []const u8, shape: []const usize) !u64 { + return w.upload(d, std.mem.sliceAsBytes(try w.floats(name, shape))); + } + + /// The fp32 tensor `name` of `shape` on the device rounded to fp16 (`stage` holds the halves). + fn half(w: *Weights, d: *const cuda.Driver, stage: []f16, name: []const u8, shape: []const usize) !u64 { + const src = try w.floats(name, shape); + for (stage[0..src.len], src) |*o, v| o.* = @floatCast(v); + return w.upload(d, std.mem.sliceAsBytes(stage[0..src.len])); + } +}; + +fn block(w: *Weights, d: *const cuda.Driver, stage: []f16, prefix: []const u8, i: usize, affine: bool) !Block { + var name: [96]u8 = undefined; + const N = struct { + fn n(buf: []u8, p: []const u8, j: usize, s: []const u8) ![]const u8 { + return std.fmt.bufPrint(buf, "{s}.{d}.{s}", .{ p, j, s }); + } + }; + var b: Block = undefined; + b.qkv = try w.half(d, stage, try N.n(&name, prefix, i, "attn.qkv.weight"), &.{ 3 * H, H }); + b.qkv_b = try w.half(d, stage, try N.n(&name, prefix, i, "attn.qkv.bias"), &.{3 * H}); + b.out = try w.half(d, stage, try N.n(&name, prefix, i, "attn.out.weight"), &.{ H, H }); + b.out_b = try w.half(d, stage, try N.n(&name, prefix, i, "attn.out.bias"), &.{H}); + b.up = try w.half(d, stage, try N.n(&name, prefix, i, "mlp.mlp.0.weight"), &.{ cfg.ffn, H }); + b.up_b = try w.half(d, stage, try N.n(&name, prefix, i, "mlp.mlp.0.bias"), &.{cfg.ffn}); + b.down = try w.half(d, stage, try N.n(&name, prefix, i, "mlp.mlp.2.weight"), &.{ H, cfg.ffn }); + b.down_b = try w.half(d, stage, try N.n(&name, prefix, i, "mlp.mlp.2.bias"), &.{H}); + b.q_norm = try w.take(d, try N.n(&name, prefix, i, "attn.q_norm.gamma"), &.{ cfg.heads, cfg.head_dim }); + b.k_norm = try w.take(d, try N.n(&name, prefix, i, "attn.k_norm.gamma"), &.{ cfg.heads, cfg.head_dim }); + b.norm1 = 0; + b.norm1_b = 0; + b.norm2 = 0; + b.norm2_b = 0; + if (affine) { + b.norm1 = try w.take(d, try N.n(&name, prefix, i, "norm1.weight"), &.{H}); + b.norm1_b = try w.take(d, try N.n(&name, prefix, i, "norm1.bias"), &.{H}); + b.norm2 = try w.take(d, try N.n(&name, prefix, i, "norm2.weight"), &.{H}); + b.norm2_b = try w.take(d, try N.n(&name, prefix, i, "norm2.bias"), &.{H}); + } + return b; +} + +/// A RePo layer: its gate and content maps stacked [256, 1024] fp32, its three frequency vectors as 32 values. +fn repo(w: *Weights, d: *const cuda.Driver, stage: []f32, prefix: []const u8, i: usize) !Repo { + var name: [96]u8 = undefined; + var r: Repo = undefined; + r.norm = try w.take(d, try std.fmt.bufPrint(&name, "{s}.{d}.norm.weight", .{ prefix, i }), &.{H}); + r.norm_b = try w.take(d, try std.fmt.bufPrint(&name, "{s}.{d}.norm.bias", .{ prefix, i }), &.{H}); + const n = cfg.repo_hidden * H; + @memcpy(stage[0..n], try w.floats(try std.fmt.bufPrint(&name, "{s}.{d}.gate_map.weight", .{ prefix, i }), &.{ cfg.repo_hidden, H })); + @memcpy(stage[n .. 2 * n], try w.floats(try std.fmt.bufPrint(&name, "{s}.{d}.content_map.weight", .{ prefix, i }), &.{ cfg.repo_hidden, H })); + r.maps = try w.upload(d, std.mem.sliceAsBytes(stage[0 .. 2 * n])); + r.final = try w.take(d, try std.fmt.bufPrint(&name, "{s}.{d}.final_map.weight", .{ prefix, i }), &.{ 3 * cfg.heads, cfg.repo_hidden }); + var freqs: [cfg.repo_pairs]f32 = undefined; + var at: usize = 0; + inline for (.{ .{ "freqs_0", 10 }, .{ "freqs_1", 10 }, .{ "freqs_2", 12 } }) |f| { + @memcpy(freqs[at..][0..f[1]], try w.floats(try std.fmt.bufPrint(&name, "{s}.{d}.{s}", .{ prefix, i, f[0] }), &.{f[1]})); + at += f[1]; + } + r.freqs = try w.upload(d, std.mem.sliceAsBytes(&freqs)); + return r; +} + +/// The snapshot folder `dir`: config.json checked, then denoiser.safetensors's every tensor, none left unread. +pub fn load(gpa: std.mem.Allocator, io: std.Io, d: *const cuda.Driver, dir: []const u8) !*Weights { + var arena_state = std.heap.ArenaAllocator.init(gpa); + defer arena_state.deinit(); + const arena = arena_state.allocator(); + const config = try std.Io.Dir.cwd().readFileAlloc(io, try std.fs.path.join(arena, &.{ dir, "config.json" }), arena, .limited(1 << 20)); + try cfg.check(gpa, config); + const w = try gpa.create(Weights); + errdefer gpa.destroy(w); + w.* = .{ .gpa = gpa, .ck = .{ .gpa = gpa, .io = io } }; + errdefer w.deinit(); + try w.ck.add(dir, "denoiser.safetensors"); + const halves = try arena.alloc(f16, cfg.ffn * H); + const stage = try arena.alloc(f32, 2 * cfg.repo_hidden * H); + for (&w.noise, &w.context, &w.noise_repo, &w.context_repo, 0..) |*n, *x, *nr, *xr, i| { + n.* = try block(w, d, halves, "noise_refiner", i, false); + x.* = try block(w, d, halves, "context_refiner", i, true); + nr.* = try repo(w, d, stage, "noise_repo_layers", i); + xr.* = try repo(w, d, stage, "context_repo_layers", i); + } + for (&w.blocks, &w.repo, 0..) |*b, *r, i| { + b.* = try block(w, d, halves, "blocks", i, false); + r.* = try repo(w, d, stage, "repo_layers", i); + } + w.input = try w.take(d, "input_layer.weight", &.{ H, cfg.latent_channels }); + w.input_b = try w.take(d, "input_layer.bias", &.{H}); + w.cond = try w.take(d, "cond_embedder.weight", &.{ H, cfg.cond_channels }); + w.cond_b = try w.take(d, "cond_embedder.bias", &.{H}); + w.cond2 = try w.take(d, "cond_embedder2.weight", &.{ H, cfg.cond2_channels }); + w.cond2_b = try w.take(d, "cond_embedder2.bias", &.{H}); + w.out = try w.take(d, "out_layer.weight", &.{ cfg.latent_channels, H }); + w.out_b = try w.take(d, "out_layer.bias", &.{cfg.latent_channels}); + var hw: host.Host = undefined; + hw.t1 = try w.floats("t_embedder.mlp.0.weight", &.{ H, cfg.time_dim }); + hw.t1_b = try w.floats("t_embedder.mlp.0.bias", &.{H}); + hw.t2 = try w.floats("t_embedder.mlp.2.weight", &.{ H, H }); + hw.t2_b = try w.floats("t_embedder.mlp.2.bias", &.{H}); + hw.ada = try w.floats("adaLN_modulation.1.weight", &.{ 6 * H, H }); + hw.ada_b = try w.floats("adaLN_modulation.1.bias", &.{6 * H}); + hw.cam1 = try w.floats("cam_refiner.mlp.0.weight", &.{ H, cfg.camera_channels }); + hw.cam1_b = try w.floats("cam_refiner.mlp.0.bias", &.{H}); + hw.cam2 = try w.floats("cam_refiner.mlp.2.weight", &.{ H, H }); + hw.cam2_b = try w.floats("cam_refiner.mlp.2.bias", &.{H}); + hw.cam_out = try w.floats("cam_out_layer.weight", &.{ cfg.camera_channels, H }); + hw.cam_out_b = try w.floats("cam_out_layer.bias", &.{cfg.camera_channels}); + var name: [64]u8 = undefined; + for (&hw.shifts, 0..) |*s, i| { + const n = if (i < cfg.refiners) try std.fmt.bufPrint(&name, "noise_refiner.{d}.shift_table", .{i}) else try std.fmt.bufPrint(&name, "blocks.{d}.shift_table", .{i - cfg.refiners}); + s.* = try w.floats(n, &.{ 1, 6 * H }); + } + hw.head = try w.floats("shift_table", &.{ 1, 2, H }); + hw.pos = try w.floats("pos_pe", &.{ 1, cfg.latent_rows, 3 }); + w.host = hw; + if (w.ck.unused() != 0) { + std.log.err("idol: denoiser.safetensors has {d} tensors this family does not read", .{w.ck.unused()}); + return error.UnexpectedTensors; + } + return w; +} diff --git a/zig/src/families/idol/host.zig b/zig/src/families/idol/host.zig new file mode 100644 index 00000000000..a6d7de560bb --- /dev/null +++ b/zig/src/families/idol/host.zig @@ -0,0 +1,167 @@ +//! The host's part of an Idol denoiser pass: the schedule, the time modulation, the camera token and its velocity. +const std = @import("std"); +const cfg = @import("config.zig"); + +const H = cfg.hidden; + +/// The fp32 vectors and small matrices the host reads each timestep. +pub const Host = struct { + t1: []const f32, + t1_b: []const f32, + t2: []const f32, + t2_b: []const f32, + ada: []const f32, + ada_b: []const f32, + cam1: []const f32, + cam1_b: []const f32, + cam2: []const f32, + cam2_b: []const f32, + cam_out: []const f32, + cam_out_b: []const f32, + /// Each modulated block's own shift table [6144]: the noise refiner's, then the joint blocks'. + shifts: [cfg.modulated][]const f32, + /// The output's shift table [2, 1024]. + head: []const f32, + pos: []const f32, +}; + +pub fn half(x: f32) f32 { + return @as(f16, @floatCast(x)); +} + +/// y[o] = sum over k of x[k] w[o, k] + b[o] in fp32, w stored (outputs, inputs). +pub fn project(w: []const f32, b: []const f32, x: []const f32, y: []f32) void { + std.debug.assert(w.len == x.len * y.len and b.len == y.len); + const V = @Vector(8, f32); + for (y, 0..) |*o, row| { + const ws = w[row * x.len ..][0..x.len]; + var acc: V = @splat(0); + var k: usize = 0; + while (k + 8 <= x.len) : (k += 8) acc += @as(V, ws[k..][0..8].*) * @as(V, x[k..][0..8].*); + var sum = @reduce(.Add, acc); + while (k < x.len) : (k += 1) sum += ws[k] * x[k]; + o.* = sum + b[row]; + } +} + +fn silu(x: f32) f32 { + return x / (1.0 + @exp(-x)); +} + +fn gelu(x: f32) f32 { + return 0.5 * x * (1.0 + std.math.tanh(0.7978845608028654 * (x + 0.044715 * x * x * x))); +} + +/// The sampler's times: t = s u / (1 + (s - 1) u) for u from 1 to 0 in `steps` (steps + 1 values), in float64. +pub fn schedule(out: []f64, rescale: f64) void { + const steps = out.len - 1; + for (out, 0..) |*t, i| { + const u = 1.0 - @as(f64, @floatFromInt(i)) / @as(f64, @floatFromInt(steps)); + t.* = rescale * u / (1.0 + (rescale - 1.0) * u); + } +} + +/// The modulated blocks' six fp16 vectors each (shift, 1 + scale, gate for attention, then for the MLP). +pub const vectors = 6; +pub const Mods = [cfg.modulated][vectors][H]f16; + +/// t_embedder's output [1024] at model time `t` (1000 times the flow time), in fp32. +pub fn timeEmbedding(w: Host, t: f32, out: *[H]f32) void { + const halfdim = cfg.time_dim / 2; + var freq: [cfg.time_dim]f32 = undefined; + const lg: f32 = @floatCast(-@log(@as(f64, 10000))); + for (0..halfdim) |i| { + const a = t * @exp(lg * @as(f32, @floatFromInt(i)) / @as(f32, halfdim)); + freq[i] = @cos(a); + freq[halfdim + i] = @sin(a); + } + var mid: [H]f32 = undefined; + project(w.t1, w.t1_b, &freq, &mid); + for (&mid) |*v| v.* = silu(v.*); + project(w.t2, w.t2_b, &mid, out); +} + +/// Every modulated block's vectors and the output's fp32 shift and scale at model time `t`. +pub fn modulation(w: Host, t: f32, mods: *Mods, head: *[2][H]f32) void { + var emb: [H]f32 = undefined; + timeEmbedding(w, t, &emb); + var act: [H]f32 = undefined; + for (&act, emb) |*o, v| o.* = silu(v); + var tmod: [6 * H]f32 = undefined; + project(w.ada, w.ada_b, &act, &tmod); + for (&tmod) |*v| v.* = half(v.*); + for (mods, w.shifts) |*m, shift| { + for (0..6 * H) |i| { + const v = half(tmod[i] + half(shift[i])); + const part = i / H; + // the scales (parts 1 and 4) enter as fp16(1 + scale) + m[part][i % H] = @floatCast(if (part == 1 or part == 4) half(1.0 + v) else v); + } + } + for (0..2) |p| for (0..H) |i| { + head[p][i] = w.head[p * H + i] + emb[i]; + }; +} + +/// The camera token: cam_refiner's MLP of the five camera values, in fp32, then fp16. +pub fn cameraToken(w: Host, camera: *const [cfg.camera_channels]f32, out: []f16) void { + var mid: [H]f32 = undefined; + project(w.cam1, w.cam1_b, camera, &mid); + for (&mid) |*v| v.* = gelu(v.*); + var tok: [H]f32 = undefined; + project(w.cam2, w.cam2_b, &mid, &tok); + for (out, tok) |*o, v| o.* = @floatCast(v); +} + +/// The camera velocity from the last joint row: F.layer_norm (eps 1e-5), modulated by `head`, then cam_out_layer. +pub fn cameraVelocity(w: Host, row: []const f16, head: *const [2][H]f32, out: *[cfg.camera_channels]f32) void { + var x: [H]f32 = undefined; + var mean: f32 = 0; + for (&x, row) |*o, v| { + o.* = v; + mean += o.*; + } + mean /= H; + var q: f32 = 0; + for (x) |v| q += (v - mean) * (v - mean); + const inv = 1.0 / @sqrt(q / H + cfg.default_eps); + // shift is the table's first half, scale its second + for (&x, 0..) |*v, i| v.* = ((v.* - mean) * inv) * (1.0 + head[1][i]) + head[0][i]; + project(w.cam_out, w.cam_out_b, &x, out); +} + +/// The latents' fixed position embedding [8192, 1024] in fp16: sin then cos of each axis at 2^k frequencies. +pub fn positions(pos: []const f32, out: []f16) void { + std.debug.assert(pos.len == cfg.latent_rows * 3 and out.len == cfg.latent_rows * H); + const fd = H / 3 / 2; + const max_res = 16; + var freqs: [fd]f32 = undefined; + const rest = fd - max_res; + for (&freqs, 0..) |*f, i| { + const e: f32 = if (i < max_res) @floatFromInt(i) else @as(f32, @floatFromInt(i - max_res)) / @as(f32, rest) * max_res; + f.* = std.math.pow(f32, 2, e); + } + for (0..cfg.latent_rows) |r| { + const o = out[r * H ..][0..H]; + // outer(x.reshape(-1), freqs) then cat(sin, cos) per value: each axis's fd sines, then its fd cosines + for (0..3) |a| for (0..fd) |j| { + const ang = pos[r * 3 + a] * freqs[j] * 2 * std.math.pi; + o[a * 2 * fd + j] = @floatCast(@sin(ang)); + o[a * 2 * fd + fd + j] = @floatCast(@cos(ang)); + }; + for (o[6 * fd ..]) |*v| v.* = 0; + } +} + +test "the schedule runs from 1 to 0, denser at high noise for rescale 3" { + var t: [51]f64 = undefined; + schedule(&t, 3.0); + try std.testing.expectEqual(@as(f64, 1), t[0]); + try std.testing.expectEqual(@as(f64, 0), t[50]); + try std.testing.expectApproxEqAbs(@as(f64, 0.75), t[25], 1e-12); +} + +test "fp16 rounding is to nearest, ties to even" { + try std.testing.expectEqual(@as(f32, 1.0), half(1.0 + 1.0 / 4096.0)); + try std.testing.expectEqual(@as(f32, 1.0 + 1.0 / 512.0), half(1.0 + 3.0 / 2048.0)); +} diff --git a/zig/src/families/idol/idol.zig b/zig/src/families/idol/idol.zig new file mode 100644 index 00000000000..a2aff609445 --- /dev/null +++ b/zig/src/families/idol/idol.zig @@ -0,0 +1,19 @@ +//! Idol image to 3D: its denoiser on Metal (a denoiser beside the lane engine, not a token family). +pub const config = @import("config.zig"); +pub const host = @import("host.zig"); +pub const weights = @import("weights.zig"); +pub const kernels = @import("kernels.zig"); +pub const model = @import("model.zig"); +pub const reference = @import("reference.zig"); +pub const Model = model.Model; +pub const Condition = model.Condition; +pub const Timing = model.Timing; + +test { + _ = config; + _ = host; + _ = weights; + _ = kernels; + _ = model; + _ = reference; +} diff --git a/zig/src/families/idol/kernels.zig b/zig/src/families/idol/kernels.zig new file mode 100644 index 00000000000..2efe840cdc2 --- /dev/null +++ b/zig/src/families/idol/kernels.zig @@ -0,0 +1,209 @@ +//! Idol's Metal pipelines: its fp16 projections and steps, fp32 projections and head-64 attention. +const std = @import("std"); +const mtl = @import("metal"); +const sources = @import("kernel_sources"); +const frags = @import("../../core/frags.zig"); +const cfg = @import("config.zig"); +pub const Ref = @import("../../core/qwen_vl/weights.zig").Ref; + +/// Each pipeline by its function. +pub const names = [_][]const u8{ + "id_linear_00", + "id_linear_01", + "id_linear_10", + "id_linear_11", + "id_linear_gelu_00", + "id_linear_gelu_01", + "id_linear_gelu_10", + "id_linear_gelu_11", + "id_norm", + "id_norm32", + "id_repo", + "id_qk", + "id_gate_add", + "id_embed", + "id_cond", + "id_bias32", + "id_gemm32", + "id_split_0", + "id_split_1", + "id_norm_split", + "id_attention_00", + "id_attention_01", + "id_attention_10", + "id_attention_11", +}; +const linear_first = 0; +const attention_first = blk: { + for (names, 0..) |n, i| if (std.mem.eql(u8, n, "id_attention_00")) break :blk i; + unreachable; +}; + +pub const Norm = enum(u32) { plain = 0, affine = 1, modulated = 2 }; + +pub const Kernels = struct { + own: mtl.Library, + p: [names.len]mtl.Pipeline, + + pub fn load(gpa: std.mem.Allocator, device: mtl.Device) !Kernels { + var k: Kernels = undefined; + const own = try frags.source(device, gpa, sources.idol); + defer gpa.free(own); + k.own = try mtl.Library.fromSource(device, own, mtl.CompileOptions.mlx()); + errdefer k.own.deinit(); + var made: usize = 0; + errdefer for (k.p[0..made]) |p| p.deinit(); + for (names, 0..) |name, i| { + k.p[i] = try mtl.Pipeline.init(device, k.own, name, false); + made += 1; + } + return k; + } + + pub fn deinit(k: *Kernels) void { + for (k.p) |p| p.deinit(); + k.own.deinit(); + } + + pub fn get(k: *const Kernels, comptime name: []const u8) mtl.Pipeline { + inline for (names, 0..) |n, i| if (comptime std.mem.eql(u8, n, name)) return k.p[i]; + @compileError("no pipeline " ++ name); + } + + /// y [M, N] (rows `ldd` apart) = x [M, K] w^T in fp32 FMA, w as stored [N, K]; K % 32, N % 64 (or N < 64, % 8) = 0. + pub fn linear32(k: *const Kernels, e: mtl.ComputeEncoder, x: Ref, w: Ref, y: Ref, M: usize, N: usize, K: usize, ldd: usize) void { + std.debug.assert(K % 32 == 0 and (N % 64 == 0 or (N < 64 and N % 8 == 0))); + const params = [4]u32{ @intCast(M), @intCast(N), @intCast(K), @intCast(ldd) }; + bind(e, k.get("id_gemm32"), &.{ x, w, y }, params); + e.dispatchGroups(mtl.Size.of((N + 63) / 64, (M + 63) / 64, 1), mtl.Size.of(128, 1, 1)); + } + + /// c [M, 256] fp32 = x3 [M, 3072] w3^T over fp16: a split LayerNorm's rows and a RePo layer's split maps. + pub fn split(k: *const Kernels, e: mtl.ComputeEncoder, x3: Ref, w3: Ref, c: Ref, M: usize) void { + const N = 2 * cfg.repo_hidden; + const K = 3 * cfg.hidden; + const tn: usize = N / 64; + const tm = (M + 63) / 64; + const swz: u6 = if (tm <= 3) 0 else 1; + e.setPipeline(if (M % 64 == 0) k.get("id_split_1") else k.get("id_split_0")); + e.setBuffer(x3.buf, x3.off, 0); + e.setBuffer(w3.buf, w3.off, 1); + var p: [16]i32 = @splat(0); + const vals = [_]usize{ M, N, K, K, K, N, tn, tm, 1, M * N, K, swz, 0, 0 }; + for (vals, 0..) |v, i| p[i] = @intCast(v); + e.setBytes(std.mem.asBytes(&p), 2); + e.setBuffer(c.buf, c.off, 3); + const tiles = (tn << swz) * ((tm + (@as(usize, 1) << swz) - 1) >> swz); + e.dispatchThreads(mtl.Size.of(tiles * 32, 2, 2), mtl.Size.of(32, 2, 2)); + } + + /// x3 rows [hi | hi | lo] of the affine LayerNorm32 of x's rows, for `split`. + pub fn normSplit(k: *const Kernels, e: mtl.ComputeEncoder, x: Ref, w: Ref, b: Ref, x3: Ref, rows: usize, eps: f32) void { + const params = extern struct { width: u32, eps: f32, mode: u32 }{ .width = cfg.hidden, .eps = eps, .mode = 1 }; + bind(e, k.get("id_norm_split"), &.{ x, w, b, x3 }, params); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(256, 1, 1)); + } + + /// y [M, N] = fp16(x w^T + b) in fp16 with fp32 sums, then GELU (rounded again) when `gelu`. + pub fn linear(k: *const Kernels, e: mtl.ComputeEncoder, x: Ref, w: Ref, b: Ref, y: Ref, M: usize, N: usize, K: usize, gelu: bool) void { + const tn = (N + 127) / 128; + const tm = (M + 63) / 64; + const form = @as(usize, @intFromBool(M % 64 == 0)) * 2 + @intFromBool(N % 128 == 0); + e.setPipeline(k.p[linear_first + @as(usize, @intFromBool(gelu)) * 4 + form]); + e.setBuffer(x.buf, x.off, 0); + e.setBuffer(w.buf, w.off, 1); + var p: [16]i32 = @splat(0); + const vals = [_]usize{ M, N, K, K, K, N, tn, tm, 0, K / 256 }; + for (vals, 0..) |v, i| p[i] = @intCast(v); + e.setBytes(std.mem.asBytes(&p), 2); + e.setBuffer(y.buf, y.off, 3); + e.setBuffer(b.buf, b.off, 4); + e.dispatchGroups(mtl.Size.of(tn, tm, 1), mtl.Size.of(256, 1, 1)); + } + + /// o rows [Lq, heads * 64] = softmax(q k^T / 8) v for q [heads, Lq, 64] and k, v [heads, Lk, 64]. + pub fn attention(k: *const Kernels, e: mtl.ComputeEncoder, q: Ref, kb: Ref, vb: Ref, o: Ref, lq: usize, lk: usize) void { + const form = @as(usize, @intFromBool(lq % 64 == 0)) * 2 + @intFromBool(lk % 32 == 0); + const nq = (lq + 63) / 64; + const nk = (lk + 31) / 32; + e.setPipeline(k.p[attention_first + form]); + for ([_]Ref{ q, kb, vb }, 0..) |r, i| e.setBuffer(r.buf, r.off, i); + // heads, q rows, k rows, k blocks, last q block, last k block, rows in the last q block and in the last k block + var params: [8]i32 = .{ cfg.heads, @intCast(lq), @intCast(lk), @intCast(nk), @intCast(nq - 1), @intCast(nk - 1), @intCast(lq - (nq - 1) * 64), @intCast(lk - (nk - 1) * 32) }; + e.setBytes(std.mem.asBytes(¶ms), 3); + var f: [4]f32 = .{ 1.0 / @sqrt(@as(f32, cfg.head_dim)), 0, 0, 0 }; + e.setBytes(std.mem.asBytes(&f), 4); + e.setBuffer(o.buf, o.off, 5); + e.dispatchGroups(mtl.Size.of(nq, cfg.heads, 1), mtl.Size.of(32, 4, 1)); + } + + /// y = LayerNorm32 of x's rows in fp32 rounded to fp16, then affine (w, b fp32) or modulated (s1, sh fp16). + pub fn norm(k: *const Kernels, e: mtl.ComputeEncoder, x: Ref, w: Ref, b: Ref, s1: Ref, sh: Ref, y: Ref, rows: usize, eps: f32, mode: Norm) void { + const params = extern struct { width: u32, eps: f32, mode: u32 }{ .width = cfg.hidden, .eps = eps, .mode = @backingInt(mode) }; + bind(e, k.get("id_norm"), &.{ x, w, b, s1, sh, y }, params); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(256, 1, 1)); + } + + /// y fp32 = LayerNorm of x's rows times w plus b (affine), or times (1 + w) plus b (modulated). + pub fn norm32(k: *const Kernels, e: mtl.ComputeEncoder, x: Ref, w: Ref, b: Ref, y: Ref, rows: usize, eps: f32, mode: Norm) void { + const params = extern struct { width: u32, eps: f32, mode: u32 }{ .width = cfg.hidden, .eps = eps, .mode = @backingInt(mode) }; + bind(e, k.get("id_norm32"), &.{ x, w, b, y }, params); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(256, 1, 1)); + } + + /// cos, sin [rows, 16, 32] of RePo from its gate and content sums (fp32 rows of 256) and final map. + pub fn repo(k: *const Kernels, e: mtl.ComputeEncoder, gc: Ref, inv: f32, final: Ref, freqs: Ref, cos: Ref, sin: Ref, rows: usize) void { + const params = extern struct { rows: u32, stride: u32, inv: f32 }{ .rows = @intCast(rows), .stride = 2 * cfg.repo_hidden, .inv = inv }; + bind(e, k.get("id_repo"), &.{ gc, final, freqs, cos, sin }, params); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(64, 1, 1)); + } + + /// q, k, v heads [16, rows, 64] from packed qkv rows: rotated by cos, sin, then normed by gq, gk. + pub fn heads(k: *const Kernels, e: mtl.ComputeEncoder, qkv: Ref, gq: Ref, gk: Ref, cos: Ref, sin: Ref, q: Ref, kk: Ref, v: Ref, rows: usize) void { + const params = extern struct { rows: u32, scale: f32 }{ .rows = @intCast(rows), .scale = @sqrt(@as(f32, cfg.head_dim)) }; + bind(e, k.get("id_qk"), &.{ qkv, gq, gk, cos, sin, q, kk, v }, params); + e.dispatchGroups(mtl.Size.of(rows, 2, 1), mtl.Size.of(256, 1, 1)); + } + + /// x [rows, 1024] += y gated by the fp16 vector g, in place. + pub fn gateAdd(k: *const Kernels, e: mtl.ComputeEncoder, x: Ref, y: Ref, g: Ref, rows: usize) void { + bind(e, k.get("id_gate_add"), &.{ x, y, g }, @as(u32, cfg.hidden)); + e.dispatchThreads(mtl.Size.of(cfg.hidden, rows, 1), mtl.Size.of(256, 1, 1)); + } + + /// x [8192, 1024] = fp16(fp16(z w^T + b) + pe). + pub fn embed(k: *const Kernels, e: mtl.ComputeEncoder, z: Ref, w: Ref, b: Ref, pe: Ref, x: Ref) void { + e.setPipeline(k.get("id_embed")); + for ([_]Ref{ z, w, b, pe, x }, 0..) |r, i| e.setBuffer(r.buf, r.off, i); + e.dispatchThreads(mtl.Size.of(cfg.hidden, cfg.latent_rows, 1), mtl.Size.of(256, 1, 1)); + } + + /// y [rows, 1024] = fp16((a + ba) + (c + bc)). + pub fn cond(k: *const Kernels, e: mtl.ComputeEncoder, a: Ref, ba: Ref, c: Ref, bc: Ref, y: Ref, rows: usize) void { + bind(e, k.get("id_cond"), &.{ a, ba, c, bc, y }, @as(u32, cfg.hidden)); + e.dispatchThreads(mtl.Size.of(cfg.hidden, rows, 1), mtl.Size.of(256, 1, 1)); + } + + /// y [rows, width] += b by column, fp32. + pub fn bias32(k: *const Kernels, e: mtl.ComputeEncoder, y: Ref, b: Ref, rows: usize, width: usize) void { + bind(e, k.get("id_bias32"), &.{ y, b }, @as(u32, @intCast(width))); + e.dispatchThreads(mtl.Size.of(width, rows, 1), mtl.Size.of(@min(width, 256), 1, 1)); + } +}; + +/// One kernel's buffers in order, then its parameters at the next index. +pub fn bind(e: mtl.ComputeEncoder, p: mtl.Pipeline, refs: []const Ref, params: anytype) void { + e.setPipeline(p); + for (refs, 0..) |r, i| e.setBuffer(r.buf, r.off, i); + e.setValue(params, refs.len); +} + +test "every Idol pipeline compiles and loads on this GPU" { + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = mtl.Device.init() catch return error.SkipZigTest; + defer device.deinit(); + if (!device.tensorUnits()) return error.SkipZigTest; + var k = try Kernels.load(std.testing.allocator, device); + k.deinit(); +} diff --git a/zig/src/families/idol/model.zig b/zig/src/families/idol/model.zig new file mode 100644 index 00000000000..27c6e12a134 --- /dev/null +++ b/zig/src/families/idol/model.zig @@ -0,0 +1,244 @@ +//! Idol's denoiser on Metal: the image condition refined once, then latent, condition and camera rows each step. +const std = @import("std"); +const mtl = @import("metal"); +const cfg = @import("config.zig"); +const host = @import("host.zig"); +const wts = @import("weights.zig"); +const ks = @import("kernels.zig"); +const Ref = ks.Ref; + +const H = cfg.hidden; +const F = cfg.ffn; +const L = cfg.joint_rows; +const R = cfg.latent_rows; +const C = cfg.cond_rows; + +pub const Timing = struct { wall: f64, gpu: f64, host: f64 }; + +/// A refined image condition: the condition refiner's rows [4101, 1024] fp16. +pub const Condition = struct { + rows: mtl.Buffer, + + pub fn deinit(c: *Condition) void { + c.rows.deinit(); + } +}; + +/// The scratch buffer's parts in bytes, in the order of Model's views. +const parts = [_]usize{ + L * H * 2, L * H * 2, L * 3 * H * 2, L * H * 2, L * H * 2, L * H * 2, L * H * 2, L * H * 2, + L * F * 2, L * H * 4, L * 2 * cfg.repo_hidden * 4, L * cfg.heads * cfg.repo_pairs * 4, L * cfg.heads * cfg.repo_pairs * 4, R * cfg.latent_channels * 4, R * cfg.latent_channels * 4, cfg.modulated * host.vectors * H * 2, + 2 * H * 4, C * cfg.cond_channels * 4, C * cfg.cond2_channels * 4, H * 2, R * H * 2, +}; + +pub fn scratchBytes() usize { + var total: usize = 0; + for (parts) |n| total += std.mem.alignForward(usize, n, 256); + return total; +} + +pub const Model = struct { + gpa: std.mem.Allocator, + device: mtl.Device, + queue: mtl.Queue, + k: ks.Kernels, + w: wts.Weights, + scratch: mtl.Buffer, + // fp16 rows: the stream, a norm's output, packed qkv, heads [16, rows, 64], attention rows, a projection's output + x: Ref, + xn: Ref, + qkv: Ref, + q: Ref, + k_: Ref, + v: Ref, + att: Ref, + y: Ref, + /// the MLP's GELU rows + u: Ref, + /// fp32 rows: RePo's norm (and the condition's two projections), its gate | content sums, cos and sin + ln: Ref, + gc: Ref, + cos: Ref, + sin: Ref, + lat: Ref, + vel: Ref, + mods: Ref, + head: Ref, + f1: Ref, + f2: Ref, + ones: Ref, + pe: Ref, + /// The model time `mods` and `head` hold, if any. + time: ?f32 = null, + + /// The denoiser of snapshot folder `dir`. + pub fn load(gpa: std.mem.Allocator, io: std.Io, device: mtl.Device, dir: []const u8) !*Model { + // qualified on the M5's tensor units alone: the projections and attention take another path before them + if (!device.tensorUnits()) { + std.log.err("idol: {s} has no tensor units; this family runs on the M5's alone, the only chip it was checked on", .{device.name()}); + return error.TensorUnitsRequired; + } + const t = try gpa.create(Model); + errdefer gpa.destroy(t); + t.* = undefined; + t.gpa = gpa; + t.device = device; + t.time = null; + t.queue = try device.queue(); + errdefer t.queue.deinit(); + t.k = try ks.Kernels.load(gpa, device); + errdefer t.k.deinit(); + t.w = try wts.load(gpa, io, device, dir); + errdefer t.w.deinit(); + t.scratch = try device.buffer(scratchBytes(), mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked); + var at: usize = 0; + const views = [_]*Ref{ &t.x, &t.xn, &t.qkv, &t.q, &t.k_, &t.v, &t.att, &t.y, &t.u, &t.ln, &t.gc, &t.cos, &t.sin, &t.lat, &t.vel, &t.mods, &t.head, &t.f1, &t.f2, &t.ones, &t.pe }; + for (views, parts) |view, n| { + view.* = .{ .buf = t.scratch, .off = at }; + at += std.mem.alignForward(usize, n, 256); + } + @memset(halves(t.ones, H), 1.0); + host.positions(t.w.host.pos, halves(t.pe, R * H)); + return t; + } + + pub fn deinit(t: *Model) void { + t.scratch.deinit(); + t.w.deinit(); + t.k.deinit(); + t.queue.deinit(); + t.gpa.destroy(t); + } + + fn floats(r: Ref, n: usize) []f32 { + return @as([*]f32, @ptrCast(@alignCast(r.addr())))[0..n]; + } + + fn halves(r: Ref, n: usize) []f16 { + return @as([*]f16, @ptrCast(@alignCast(r.addr())))[0..n]; + } + + /// The modulated block `i`'s vector `part` (0 shift, 1 one plus scale, 2 gate; 3 to 5 the MLP's). + fn vec(t: *const Model, i: usize, part: usize) Ref { + return t.mods.at(((i * host.vectors) + part) * H * 2); + } + + /// The image condition: DINOv3 rows [4101, 1280] and FLUX.2 VAE rows [4101, 128] (zeros: the negative branch). + pub fn condition(t: *Model, feature1: []const f32, feature2: []const f32) !Condition { + if (feature1.len != C * cfg.cond_channels or feature2.len != C * cfg.cond2_channels) return error.ConditionRows; + var c: Condition = .{ .rows = try t.device.buffer(C * H * 2, mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked) }; + errdefer c.rows.deinit(); + @memcpy(floats(t.f1, feature1.len), feature1); + @memcpy(floats(t.f2, feature2.len), feature2); + const started = mtl.clock.seconds(); + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const cb = t.queue.commandBuffer(); + const e = cb.compute(.serial); + const a = t.ln; + const b = t.ln.at(C * H * 4); + t.k.linear32(e, t.f1, t.w.cond, a, C, H, cfg.cond_channels, H); + t.k.linear32(e, t.f2, t.w.cond2, b, C, H, cfg.cond2_channels, H); + t.k.cond(e, a, t.w.cond_b, b, t.w.cond2_b, t.x, C); + for (t.w.context, t.w.context_repo) |blk, r| t.block(e, blk, r, C, null); + _ = try finish(cb, e, started, 0); + @memcpy(halves(.{ .buf = c.rows }, C * H), halves(t.x, C * H)); + return c; + } + + /// The velocity of latent [8192, 16] and camera [5] at model time `time` (1000 times t) under condition `c`. + pub fn forward(t: *Model, c: *const Condition, latent: []const f32, camera: *const [cfg.camera_channels]f32, time: f32, velocity: []f32, camera_velocity: *[cfg.camera_channels]f32) !Timing { + if (latent.len != R * cfg.latent_channels or velocity.len != latent.len) return error.LatentRows; + const started = mtl.clock.seconds(); + if (t.time != time) { + t.time = null; + host.modulation(t.w.host, time, @ptrCast(@alignCast(t.mods.addr())), @ptrCast(@alignCast(t.head.addr()))); + t.time = time; + } + @memcpy(floats(t.lat, latent.len), latent); + @memcpy(halves(t.x.at(R * H * 2), C * H), halves(.{ .buf = c.rows }, C * H)); + host.cameraToken(t.w.host, camera, halves(t.x.at((L - 1) * H * 2), H)); + const spent = mtl.clock.seconds() - started; + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const cb = t.queue.commandBuffer(); + const e = cb.compute(.serial); + t.k.embed(e, t.lat, t.w.input, t.w.input_b, t.pe, t.x); + for (t.w.noise, t.w.noise_repo, 0..) |blk, r, i| t.block(e, blk, r, R, i); + for (t.w.blocks, t.w.repo, 0..) |blk, r, i| t.block(e, blk, r, L, cfg.refiners + i); + const head: Ref = t.head; + t.k.norm32(e, t.x, head.at(H * 4), head, t.ln, R, cfg.default_eps, .modulated); + t.k.linear32(e, t.ln, t.w.out, t.vel, R, cfg.latent_channels, H, cfg.latent_channels); + t.k.bias32(e, t.vel, t.w.out_b, R, cfg.latent_channels); + const timing = try finish(cb, e, started, spent); + @memcpy(velocity, floats(t.vel, velocity.len)); + host.cameraVelocity(t.w.host, halves(t.x.at((L - 1) * H * 2), H), @ptrCast(@alignCast(t.head.addr())), camera_velocity); + return timing; + } + + /// Modulated block `index` alone at model time `time` on `rows` (the noise refiner's 8192, else 12294) given rows. + pub fn blockAt(t: *Model, index: usize, rows: []const f16, time: f32) !void { + const n: usize = if (index < cfg.refiners) R else L; + if (index >= cfg.modulated or rows.len != n * H) return error.BlockRows; + if (t.time != time) { + t.time = null; + host.modulation(t.w.host, time, @ptrCast(@alignCast(t.mods.addr())), @ptrCast(@alignCast(t.head.addr()))); + t.time = time; + } + @memcpy(halves(t.x, rows.len), rows); + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const cb = t.queue.commandBuffer(); + const e = cb.compute(.serial); + if (index < cfg.refiners) t.block(e, t.w.noise[index], t.w.noise_repo[index], n, index) else t.block(e, t.w.blocks[index - cfg.refiners], t.w.repo[index - cfg.refiners], n, index); + _ = try finish(cb, e, mtl.clock.seconds(), 0); + } + + /// The stream's first `rows` rows as the last pass left them, fp16. + pub fn stream(t: *const Model, rows: usize) []const f16 { + return halves(t.x, rows * H); + } + + fn finish(cb: mtl.CommandBuffer, e: mtl.ComputeEncoder, started: f64, spent: f64) !Timing { + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.log.err("idol: a pass failed on the GPU: {s}", .{msg}); + return error.GpuFailure; + } + return .{ .wall = mtl.clock.seconds() - started, .gpu = cb.gpuSeconds(), .host = spent }; + } + + /// One block over the stream's first `rows` rows: modulated block `mod`, or the condition refiner's (null). + fn block(t: *const Model, e: mtl.ComputeEncoder, b: wts.Block, r: wts.Repo, rows: usize, mod: ?usize) void { + const k = &t.k; + // RePo: angles from the block's input rows + k.normSplit(e, t.x, r.norm, r.norm_b, t.qkv, rows, cfg.default_eps); + k.split(e, t.qkv, r.maps, t.gc, rows); + k.repo(e, t.gc, r.inv, r.final, r.freqs, t.cos, t.sin, rows); + if (mod) |m| { + k.norm(e, t.x, t.ln, t.ln, t.vec(m, 1), t.vec(m, 0), t.xn, rows, cfg.block_eps, .modulated); + } else { + k.norm(e, t.x, b.norm1, b.norm1_b, t.ones, t.ones, t.xn, rows, cfg.block_eps, .affine); + } + k.linear(e, t.xn, b.qkv, b.qkv_b, t.qkv, rows, 3 * H, H, false); + k.heads(e, t.qkv, b.q_norm, b.k_norm, t.cos, t.sin, t.q, t.k_, t.v, rows); + k.attention(e, t.q, t.k_, t.v, t.att, rows, rows); + k.linear(e, t.att, b.out, b.out_b, t.y, rows, H, H, false); + k.gateAdd(e, t.x, t.y, if (mod) |m| t.vec(m, 2) else t.ones, rows); + if (mod) |m| { + k.norm(e, t.x, t.ln, t.ln, t.vec(m, 4), t.vec(m, 3), t.xn, rows, cfg.block_eps, .modulated); + } else { + k.norm(e, t.x, b.norm2, b.norm2_b, t.ones, t.ones, t.xn, rows, cfg.block_eps, .affine); + } + k.linear(e, t.xn, b.up, b.up_b, t.u, rows, F, H, true); + k.linear(e, t.u, b.down, b.down_b, t.y, rows, H, F, false); + k.gateAdd(e, t.x, t.y, if (mod) |m| t.vec(m, 5) else t.ones, rows); + } +}; + +test "scratch for the joint rows fits a GPU buffer, each part 256-aligned" { + try std.testing.expect(scratchBytes() < 1 << 31); + try std.testing.expectEqual(@as(usize, 12294), L); +} diff --git a/zig/src/families/idol/reference.zig b/zig/src/families/idol/reference.zig new file mode 100644 index 00000000000..549b92fa99c --- /dev/null +++ b/zig/src/families/idol/reference.zig @@ -0,0 +1,79 @@ +//! Comparing a velocity with idol-sdk's: cosine, largest difference and worst row, and the gate against fp32. +const std = @import("std"); + +pub const Match = struct { max_abs: f64, cosine: f64, worst_row: f64 }; + +/// Largest absolute difference, cosine, and the largest relative L2 error of one row of `width`. +pub fn match(ours: []const f32, theirs: []const f32, width: usize) Match { + std.debug.assert(ours.len == theirs.len and ours.len % width == 0); + var dot: f64 = 0; + var aa: f64 = 0; + var bb: f64 = 0; + var most: f64 = 0; + var worst: f64 = 0; + var row: usize = 0; + while (row < ours.len) : (row += width) { + var rd: f64 = 0; + var rb: f64 = 0; + for (ours[row..][0..width], theirs[row..][0..width]) |a, b| { + const d = @as(f64, a) - b; + dot += @as(f64, a) * b; + aa += @as(f64, a) * a; + bb += @as(f64, b) * b; + rd += d * d; + rb += @as(f64, b) * b; + most = @max(most, @abs(d)); + } + worst = @max(worst, @sqrt(rd / @max(rb, 1e-30))); + } + return .{ .max_abs = most, .cosine = dot / @sqrt(@max(aa * bb, 1e-300)), .worst_row = worst }; +} + +/// How far ours may sit from the fp32 ruler: this many times the torch fp16 reference's own distance. +pub const factor = 2.0; + +/// Against the fp32 ruler: worst row and 1 - cosine within `factor` times the fp16 reference's own; non-finite fails. +pub fn within(ours: Match, reference: Match) bool { + if (!std.math.isFinite(ours.cosine) or !std.math.isFinite(ours.worst_row)) return false; + return ours.worst_row <= factor * reference.worst_row and (1 - ours.cosine) <= factor * (1 - reference.cosine); +} + +/// The cosine half of `within`: for a velocity, whose worst row the gate takes over the whole run instead. +pub fn withinCosine(ours: Match, reference: Match) bool { + return std.math.isFinite(ours.cosine) and (1 - ours.cosine) <= factor * (1 - reference.cosine); +} + +test "a velocity matches itself exactly" { + const v = [_]f32{ 1, -2, 3, 0.5, 0.25, -1 }; + const m = match(&v, &v, 3); + try std.testing.expectEqual(@as(f64, 0), m.max_abs); + try std.testing.expectEqual(@as(f64, 0), m.worst_row); + try std.testing.expectApproxEqAbs(@as(f64, 1), m.cosine, 1e-15); +} + +test "a planted 5% error in one row fails the gate though everything else repeats exactly" { + const a = std.testing.allocator; + const n = 64 * 16; + const ruler = try a.alloc(f32, n); + defer a.free(ruler); + const fp16 = try a.alloc(f32, n); + defer a.free(fp16); + const ours = try a.alloc(f32, n); + defer a.free(ours); + var rng = std.Random.DefaultPrng.init(7); + for (ruler, fp16, ours) |*r, *f, *o| { + r.* = rng.random().floatNorm(f32); + f.* = r.* * (1 + 1e-3 * rng.random().floatNorm(f32)); + o.* = r.* * (1 + 1e-3 * rng.random().floatNorm(f32)); + } + const reference = match(fp16, ruler, 16); + try std.testing.expect(within(match(ours, ruler, 16), reference)); + for (ours[5 * 16 ..][0..16]) |*o| o.* *= 1.05; + try std.testing.expect(!within(match(ours, ruler, 16), reference)); +} + +test "non-finite values fail the gate" { + const ruler = [_]f32{ 1, 2, 3, 4 }; + const bad = [_]f32{ 1, std.math.nan(f32), 3, 4 }; + try std.testing.expect(!within(match(&bad, &ruler, 2), match(&ruler, &ruler, 2))); +} diff --git a/zig/src/families/idol/weights.zig b/zig/src/families/idol/weights.zig new file mode 100644 index 00000000000..4dcee77a129 --- /dev/null +++ b/zig/src/families/idol/weights.zig @@ -0,0 +1,292 @@ +//! Idol's denoiser tensors (fp32 as stored): the blocks' linears to fp16 at load as idol-sdk does, the rest fp32. +const std = @import("std"); +const mtl = @import("metal"); +const ck = @import("../../core/checkpoint_metal.zig"); +const cfg = @import("config.zig"); +const Ref = @import("../../core/qwen_vl/weights.zig").Ref; + +const H = cfg.hidden; + +/// A transformer block: fp16 linears and biases, fp32 head RMSNorm gammas [16, 64]; norms only in the refiner. +pub const Block = struct { qkv: Ref, qkv_b: Ref, out: Ref, out_b: Ref, up: Ref, up_b: Ref, down: Ref, down_b: Ref, q_norm: Ref, k_norm: Ref, norm1: Ref = undefined, norm1_b: Ref = undefined, norm2: Ref = undefined, norm2_b: Ref = undefined }; + +/// A RePo layer: fp32 norm; gate | content maps over `inv` (a power of two) as fp16 [hi | lo | hi]; final map, freqs. +pub const Repo = struct { norm: Ref, norm_b: Ref, maps: Ref, inv: f32, final: Ref, freqs: Ref }; + +const repos = 2 * cfg.refiners + cfg.layers; +const map_bytes = 2 * cfg.repo_hidden * 3 * H * 2; + +/// The power of two that puts a map's largest magnitude in [2^13, 2^14), so its fp16 halves keep their bits. +fn mapScale(gate: []const f32, content: []const f32) f32 { + var most: f32 = 0; + for (gate) |v| most = @max(most, @abs(v)); + for (content) |v| most = @max(most, @abs(v)); + if (most == 0 or !std.math.isFinite(most)) return 1; + return std.math.ldexp(@as(f32, 1), 13 - std.math.ilogb(most)); +} + +/// Row `n` of a map as [hi | lo | hi] fp16 of `scale` times its values. +fn split(src: []const f32, scale: f32, dst: []f16) void { + for (src, 0..) |v, i| { + const x = v * scale; + const hi: f16 = @floatCast(x); + dst[i] = hi; + dst[H + i] = @floatCast(x - @as(f32, hi)); + dst[2 * H + i] = hi; + } +} + +/// The fp32 vectors and small matrices the host reads each timestep (host.zig, shared with CUDA). +pub const Host = @import("host.zig").Host; + +pub const Weights = struct { + ck: ck.Checkpoint, + noise: [cfg.refiners]Block, + context: [cfg.refiners]Block, + blocks: [cfg.layers]Block, + noise_repo: [cfg.refiners]Repo, + context_repo: [cfg.refiners]Repo, + repo: [cfg.layers]Repo, + input: Ref, + input_b: Ref, + cond: Ref, + cond_b: Ref, + cond2: Ref, + cond2_b: Ref, + out: Ref, + out_b: Ref, + host: Host, + + pub fn deinit(w: *Weights) void { + w.ck.deinit(); + } +}; + +const linears = [_][]const u8{ "attn.qkv", "attn.out", "mlp.mlp.0", "mlp.mlp.2" }; + +/// The blocks' linear weights stay in the file: load reads each once into its fp16 copy. +fn later(name: []const u8, rank: usize) bool { + if (rank != 2) return false; + const owned = std.mem.startsWith(u8, name, "blocks.") or std.mem.startsWith(u8, name, "noise_refiner.") or std.mem.startsWith(u8, name, "context_refiner."); + return owned and std.mem.endsWith(u8, name, ".weight"); +} + +fn check(t: ck.Tensor, name: []const u8, shape: []const usize) !void { + if (t.dtype != .f32 or t.rank != shape.len or !std.mem.eql(usize, t.shape[0..t.rank], shape)) { + std.log.err("idol: {s} is {t} {any}; the denoiser reads f32 {any}", .{ name, t.dtype, t.shape[0..t.rank], shape }); + return error.UnexpectedTensor; + } +} + +fn take(c: *const ck.Checkpoint, name: []const u8, shape: []const usize) !Ref { + const t = try c.get(name); + try check(t, name, shape); + if (t.offset % 16 != 0) return error.UnalignedTensor; + return .{ .buf = t.buffer, .off = t.offset }; +} + +fn floats(c: *const ck.Checkpoint, name: []const u8, shape: []const usize) ![]const f32 { + const t = try c.get(name); + try check(t, name, shape); + return t.host(f32); +} + +/// fp16 values written into an owned buffer, bump-allocated 256-aligned. +const Halves = struct { + buf: mtl.Buffer, + at: usize = 0, + stage: []f32, + + fn put(h: *Halves, src: []const f32) Ref { + const dst = @as([*]f16, @ptrCast(@alignCast(h.buf.contents() + h.at)))[0..src.len]; + for (dst, src) |*o, v| o.* = @floatCast(v); + const r: Ref = .{ .buf = h.buf, .off = h.at }; + h.at += std.mem.alignForward(usize, src.len * 2, ck.alignment); + return r; + } + + /// A deferred fp32 weight read in staged pieces, rounded to fp16. + fn read(h: *Halves, c: *const ck.Checkpoint, name: []const u8, shape: [2]usize) !Ref { + const d = c.deferred.get(name) orelse return error.MissingTensor; + if (d.dtype != .f32 or d.rank != 2 or d.shape[0] != shape[0] or d.shape[1] != shape[1]) { + std.log.err("idol: {s} is {t} {any}; the denoiser reads f32 {any}", .{ name, d.dtype, d.shape[0..d.rank], shape }); + return error.UnexpectedTensor; + } + const n = shape[0] * shape[1]; + const r: Ref = .{ .buf = h.buf, .off = h.at }; + const dst = @as([*]f16, @ptrCast(@alignCast(h.buf.contents() + h.at)))[0..n]; + var done: usize = 0; + while (done < n) { + const part = @min(h.stage.len, n - done); + try c.read(name, done * 4, std.mem.sliceAsBytes(h.stage[0..part])); + for (dst[done..][0..part], h.stage[0..part]) |*o, v| o.* = @floatCast(v); + done += part; + } + h.at += std.mem.alignForward(usize, n * 2, ck.alignment); + return r; + } +}; + +const per_block = blk: { + var n: usize = 0; + for ([_]usize{ 3 * H * H, 3 * H, H * H, H, cfg.ffn * H, cfg.ffn, H * cfg.ffn, H }) |v| n += std.mem.alignForward(usize, v * 2, ck.alignment); + break :blk n; +}; + +fn block(c: *const ck.Checkpoint, h: *Halves, prefix: []const u8, i: usize, affine: bool) !Block { + var name: [96]u8 = undefined; + const P = struct { + fn n(buf: []u8, p: []const u8, j: usize, s: []const u8) ![]const u8 { + return std.fmt.bufPrint(buf, "{s}.{d}.{s}", .{ p, j, s }); + } + }; + var b: Block = undefined; + b.qkv = try h.read(c, try P.n(&name, prefix, i, "attn.qkv.weight"), .{ 3 * H, H }); + b.qkv_b = h.put(try floats(c, try P.n(&name, prefix, i, "attn.qkv.bias"), &.{3 * H})); + b.out = try h.read(c, try P.n(&name, prefix, i, "attn.out.weight"), .{ H, H }); + b.out_b = h.put(try floats(c, try P.n(&name, prefix, i, "attn.out.bias"), &.{H})); + b.up = try h.read(c, try P.n(&name, prefix, i, "mlp.mlp.0.weight"), .{ cfg.ffn, H }); + b.up_b = h.put(try floats(c, try P.n(&name, prefix, i, "mlp.mlp.0.bias"), &.{cfg.ffn})); + b.down = try h.read(c, try P.n(&name, prefix, i, "mlp.mlp.2.weight"), .{ H, cfg.ffn }); + b.down_b = h.put(try floats(c, try P.n(&name, prefix, i, "mlp.mlp.2.bias"), &.{H})); + b.q_norm = try take(c, try P.n(&name, prefix, i, "attn.q_norm.gamma"), &.{ cfg.heads, cfg.head_dim }); + b.k_norm = try take(c, try P.n(&name, prefix, i, "attn.k_norm.gamma"), &.{ cfg.heads, cfg.head_dim }); + if (affine) { + b.norm1 = try take(c, try P.n(&name, prefix, i, "norm1.weight"), &.{H}); + b.norm1_b = try take(c, try P.n(&name, prefix, i, "norm1.bias"), &.{H}); + b.norm2 = try take(c, try P.n(&name, prefix, i, "norm2.weight"), &.{H}); + b.norm2_b = try take(c, try P.n(&name, prefix, i, "norm2.bias"), &.{H}); + } + return b; +} + +/// A RePo layer; its two maps into `pack` at `slot`, and its three frequency vectors as 32 values after every map. +fn repo(c: *const ck.Checkpoint, pack: mtl.Buffer, slot: usize, prefix: []const u8, i: usize) !Repo { + var name: [96]u8 = undefined; + var r: Repo = undefined; + r.norm = try take(c, try std.fmt.bufPrint(&name, "{s}.{d}.norm.weight", .{ prefix, i }), &.{H}); + r.norm_b = try take(c, try std.fmt.bufPrint(&name, "{s}.{d}.norm.bias", .{ prefix, i }), &.{H}); + const gate = try floats(c, try std.fmt.bufPrint(&name, "{s}.{d}.gate_map.weight", .{ prefix, i }), &.{ cfg.repo_hidden, H }); + const content = try floats(c, try std.fmt.bufPrint(&name, "{s}.{d}.content_map.weight", .{ prefix, i }), &.{ cfg.repo_hidden, H }); + const scale = mapScale(gate, content); + const maps = @as([*]f16, @ptrCast(@alignCast(pack.contents() + slot * map_bytes)))[0 .. 2 * cfg.repo_hidden * 3 * H]; + for (0..2 * cfg.repo_hidden) |n| { + const src = if (n < cfg.repo_hidden) gate[n * H ..][0..H] else content[(n - cfg.repo_hidden) * H ..][0..H]; + split(src, scale, maps[n * 3 * H ..][0 .. 3 * H]); + } + r.maps = .{ .buf = pack, .off = slot * map_bytes }; + r.inv = 1 / scale; + r.final = try take(c, try std.fmt.bufPrint(&name, "{s}.{d}.final_map.weight", .{ prefix, i }), &.{ 3 * cfg.heads, cfg.repo_hidden }); + const freqs = repos * map_bytes; + const dst = @as([*]f32, @ptrCast(@alignCast(pack.contents() + freqs)))[slot * cfg.repo_pairs ..][0..cfg.repo_pairs]; + var at: usize = 0; + inline for (.{ .{ "freqs_0", 10 }, .{ "freqs_1", 10 }, .{ "freqs_2", 12 } }) |f| { + const src = try floats(c, try std.fmt.bufPrint(&name, "{s}.{d}.{s}", .{ prefix, i, f[0] }), &.{f[1]}); + @memcpy(dst[at..][0..f[1]], src); + at += f[1]; + } + r.freqs = .{ .buf = pack, .off = freqs + slot * cfg.repo_pairs * 4 }; + return r; +} + +/// The snapshot folder `dir`: config.json checked, then denoiser.safetensors's every tensor, each read once. +pub fn load(gpa: std.mem.Allocator, io: std.Io, device: mtl.Device, dir: []const u8) !Weights { + var arena_state = std.heap.ArenaAllocator.init(gpa); + defer arena_state.deinit(); + const arena = arena_state.allocator(); + const config = try std.Io.Dir.cwd().readFileAlloc(io, try std.fs.path.join(arena, &.{ dir, "config.json" }), arena, .limited(1 << 20)); + try cfg.check(gpa, config); + var w: Weights = undefined; + w.ck = ck.Checkpoint.init(gpa); + errdefer w.ck.deinit(); + const path = try std.fmt.allocPrintSentinel(arena, "{s}/denoiser.safetensors", .{dir}, 0); + try w.ck.addFileSplit(device, path, "", null, later); + const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked; + const blocks = 2 * cfg.refiners + cfg.layers; + const fp16 = try device.buffer(blocks * per_block, opts); + w.ck.own(fp16, blocks * per_block) catch |err| { + fp16.deinit(); + return err; + }; + const pack_bytes = repos * (map_bytes + cfg.repo_pairs * 4); + const pack = try device.buffer(pack_bytes, opts); + w.ck.own(pack, pack_bytes) catch |err| { + pack.deinit(); + return err; + }; + var h: Halves = .{ .buf = fp16, .stage = try arena.alloc(f32, 4 << 20) }; + for (&w.noise, &w.context, &w.noise_repo, &w.context_repo, 0..) |*n, *x, *nr, *xr, i| { + n.* = try block(&w.ck, &h, "noise_refiner", i, false); + x.* = try block(&w.ck, &h, "context_refiner", i, true); + nr.* = try repo(&w.ck, pack, i, "noise_repo_layers", i); + xr.* = try repo(&w.ck, pack, cfg.refiners + i, "context_repo_layers", i); + } + for (&w.blocks, &w.repo, 0..) |*b, *r, i| { + b.* = try block(&w.ck, &h, "blocks", i, false); + r.* = try repo(&w.ck, pack, 2 * cfg.refiners + i, "repo_layers", i); + } + w.ck.closeFiles(); + w.input = try take(&w.ck, "input_layer.weight", &.{ H, cfg.latent_channels }); + w.input_b = try take(&w.ck, "input_layer.bias", &.{H}); + w.cond = try take(&w.ck, "cond_embedder.weight", &.{ H, cfg.cond_channels }); + w.cond_b = try take(&w.ck, "cond_embedder.bias", &.{H}); + w.cond2 = try take(&w.ck, "cond_embedder2.weight", &.{ H, cfg.cond2_channels }); + w.cond2_b = try take(&w.ck, "cond_embedder2.bias", &.{H}); + w.out = try take(&w.ck, "out_layer.weight", &.{ cfg.latent_channels, H }); + w.out_b = try take(&w.ck, "out_layer.bias", &.{cfg.latent_channels}); + var hw: Host = undefined; + hw.t1 = try floats(&w.ck, "t_embedder.mlp.0.weight", &.{ H, cfg.time_dim }); + hw.t1_b = try floats(&w.ck, "t_embedder.mlp.0.bias", &.{H}); + hw.t2 = try floats(&w.ck, "t_embedder.mlp.2.weight", &.{ H, H }); + hw.t2_b = try floats(&w.ck, "t_embedder.mlp.2.bias", &.{H}); + hw.ada = try floats(&w.ck, "adaLN_modulation.1.weight", &.{ 6 * H, H }); + hw.ada_b = try floats(&w.ck, "adaLN_modulation.1.bias", &.{6 * H}); + hw.cam1 = try floats(&w.ck, "cam_refiner.mlp.0.weight", &.{ H, cfg.camera_channels }); + hw.cam1_b = try floats(&w.ck, "cam_refiner.mlp.0.bias", &.{H}); + hw.cam2 = try floats(&w.ck, "cam_refiner.mlp.2.weight", &.{ H, H }); + hw.cam2_b = try floats(&w.ck, "cam_refiner.mlp.2.bias", &.{H}); + hw.cam_out = try floats(&w.ck, "cam_out_layer.weight", &.{ cfg.camera_channels, H }); + hw.cam_out_b = try floats(&w.ck, "cam_out_layer.bias", &.{cfg.camera_channels}); + var name: [64]u8 = undefined; + for (&hw.shifts, 0..) |*s, i| { + const n = if (i < cfg.refiners) try std.fmt.bufPrint(&name, "noise_refiner.{d}.shift_table", .{i}) else try std.fmt.bufPrint(&name, "blocks.{d}.shift_table", .{i - cfg.refiners}); + s.* = try floats(&w.ck, n, &.{ 1, 6 * H }); + } + hw.head = try floats(&w.ck, "shift_table", &.{ 1, 2, H }); + hw.pos = try floats(&w.ck, "pos_pe", &.{ 1, cfg.latent_rows, 3 }); + w.host = hw; + // a block's 4 linears, 4 biases and 2 gammas, the context refiner's 4 norms, the shift tables; 8 a RePo layer + const all = 2 * cfg.refiners + cfg.layers; + const read = 10 * all + 4 * cfg.refiners + cfg.modulated + 8 * all + 8 + 12 + 2; + const total = w.ck.tensors.count() + w.ck.deferred.count(); + if (total != read) { + std.log.err("idol: denoiser.safetensors has {d} tensors; this family reads {d}", .{ total, read }); + return error.UnexpectedTensors; + } + return w; +} + +test "a map's split halves sum back to its scaled values within fp32's rounding" { + var src: [H]f32 = undefined; + var rng = std.Random.DefaultPrng.init(3); + for (&src) |*v| v.* = 0.05 * rng.random().floatNorm(f32); + const scale = mapScale(&src, &src); + try std.testing.expect(scale >= 1); + var dst: [3 * H]f16 = undefined; + split(&src, scale, &dst); + for (src, 0..) |v, i| { + const back = (@as(f32, dst[i]) + @as(f32, dst[H + i])) / scale; + try std.testing.expect(@abs(back - v) <= @abs(v) * 1e-6 + 1e-12); + try std.testing.expectEqual(dst[i], dst[2 * H + i]); + } +} + +test "the blocks' linear weights, and only they, stay in the file for their fp16 copies" { + try std.testing.expect(later("blocks.3.attn.qkv.weight", 2)); + try std.testing.expect(later("context_refiner.1.mlp.mlp.2.weight", 2)); + try std.testing.expect(!later("blocks.3.attn.qkv.bias", 1)); + try std.testing.expect(!later("blocks.3.attn.q_norm.gamma", 2)); + try std.testing.expect(!later("context_refiner.0.norm1.weight", 1)); + try std.testing.expect(!later("repo_layers.0.gate_map.weight", 2)); + try std.testing.expect(!later("cond_embedder.weight", 2)); +} diff --git a/zig/src/families/ling/host_test.zig b/zig/src/families/ling/host_test.zig index e339b37f0c2..516726dd005 100644 --- a/zig/src/families/ling/host_test.zig +++ b/zig/src/families/ling/host_test.zig @@ -10,9 +10,29 @@ test { _ = @import("synth.zig"); _ = @import("route.zig"); _ = @import("kda.zig"); + _ = @import("mla.zig"); + _ = @import("mla_rope_test.zig"); } test "the float64 oracle handles tiny's null SwiGLU lists" { const src = @embedFile("oracle/ling_forward.py"); try std.testing.expect(std.mem.indexOf(u8, src, "null (Ling-3.0-tiny)") != null); } + +test "the float64 oracle's mla takes a pos0 so a chunk is not always arange(T) from 0" { + const src = @embedFile("oracle/ling_forward.py"); + try std.testing.expect(std.mem.indexOf(u8, src, "def mla(self, x, p, pos0=0)") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "def one_mla(") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "pos0 + torch.arange(T, dtype=torch.float64)") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "attends only over the rows it is given") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "kv_a_proj_with_mqa") != null); +} + +test "mla dump runs ling_forward.py --mla-layer for TFLINGA1" { + const src = @embedFile("oracle/mla_dump.py"); + try std.testing.expect(std.mem.indexOf(u8, src, "ling_forward.py") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "--mla-layer") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "TFLINGA1") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "Random values in Ling-3.0-tiny tensor shapes") != null); + try std.testing.expect(std.mem.indexOf(u8, src, "sys.argv") != null); +} diff --git a/zig/src/families/ling/mla.zig b/zig/src/families/ling/mla.zig new file mode 100644 index 00000000000..75b7ea3388a --- /dev/null +++ b/zig/src/families/ling/mla.zig @@ -0,0 +1,276 @@ +//! Ling MLA mixer after the linears: unabsorbed python-style (ling_forward.py mla), plus RoPE helpers. +const std = @import("std"); +const config = @import("config.zig"); +const bf16_round = @import("bf16_round"); + +pub const lat: u32 = 512; +pub const rope_dim: u32 = 64; +pub const nope: u32 = 128; +pub const vd: u32 = 128; +pub const key: u32 = lat + rope_dim; +pub const qd: u32 = nope + rope_dim; +pub const nfreq: u32 = rope_dim / 2; +pub const theta_tiny: f64 = 6_000_000; +pub const eps_tiny: f32 = 1e-6; + +pub const Shape = struct { + heads: u32, + eps: f32, + theta: f64, + + pub fn of(c: *const config.Config) Shape { + return .{ .heads = c.mla_heads, .eps = c.eps, .theta = c.rope_theta }; + } + + pub fn scale(s: Shape) f64 { + _ = s; + return 1.0 / @sqrt(@as(f64, @floatFromInt(qd))); + } + + pub fn outWidth(s: Shape) u32 { + return s.heads * vd; + } +}; + +/// 1 / theta ** (arange(0, rope, 2) / rope): frequency i is 2i / 64. +pub fn invFreq(theta: f64, i: usize) f64 { + return 1.0 / std.math.pow(f64, theta, @as(f64, @floatFromInt(2 * i)) / @as(f64, @floatFromInt(rope_dim))); +} + +/// One 64-vector at absolute pos: even/odd pairs, then cat(a*c-b*s, b*c+a*s). out and z are rope_dim long. +pub fn rotate(out: []f64, z: []const f64, pos: u32, theta: f64) void { + std.debug.assert(out.len == rope_dim and z.len == rope_dim); + for (0..nfreq) |i| { + const ang = @as(f64, @floatFromInt(pos)) * invFreq(theta, i); + const c = @cos(ang); + const s = @sin(ang); + const a = z[2 * i]; + const b = z[2 * i + 1]; + out[i] = a * c - b * s; + out[nfreq + i] = b * c + a * s; + } +} + +/// T rows of 64 at pos0 + t, the chunk/resume case. out and z are T * rope_dim. +pub fn rotateRows(out: []f64, z: []const f64, rows: u32, pos0: u32, theta: f64) void { + std.debug.assert(out.len == rows * rope_dim and z.len == rows * rope_dim); + for (0..rows) |t| { + rotate(out[t * rope_dim ..][0..rope_dim], z[t * rope_dim ..][0..rope_dim], pos0 + @as(u32, @intCast(t)), theta); + } +} + +/// (T, H) to (T, H*128): each head gate repeated across the value columns. +pub fn expandGate(out: []u16, g: []const u16, rows: u32, heads: u32) void { + std.debug.assert(g.len == rows * heads and out.len == rows * heads * vd); + for (0..rows) |t| { + for (0..heads) |h| { + const v = g[t * heads + h]; + const lo = (t * heads + h) * vd; + for (0..vd) |d| out[lo + d] = v; + } + } +} + +fn r64(comptime round: bool, v: f64) f64 { + if (!round) return v; + return bf16_round.bf16(v); +} + +fn sig(x: f64) f64 { + if (x >= 0) { + const e = @exp(-x); + return 1.0 / (1.0 + e); + } + const e = @exp(x); + return e / (1.0 + e); +} + +fn mixAs( + comptime round: bool, + alloc: std.mem.Allocator, + y: []f64, + q: []const f32, + kv: []const f32, + w_rms: []const f32, + kvb: []const f32, + g: []const f32, + s: Shape, + rows: u32, + pos0: u32, +) !void { + const H = s.heads; + const T = rows; + std.debug.assert(y.len == T * H * vd); + std.debug.assert(q.len == T * H * qd); + std.debug.assert(kv.len == T * key); + std.debug.assert(w_rms.len == lat); + std.debug.assert(kvb.len == H * (nope + vd) * lat); + std.debug.assert(g.len == T * H); + + const lat_t = try alloc.alloc(f64, T * lat); + defer alloc.free(lat_t); + const krope = try alloc.alloc(f64, T * rope_dim); + defer alloc.free(krope); + const qrope = try alloc.alloc(f64, T * H * rope_dim); + defer alloc.free(qrope); + const k_nope = try alloc.alloc(f64, T * H * nope); + defer alloc.free(k_nope); + const v = try alloc.alloc(f64, T * H * vd); + defer alloc.free(v); + + const eps: f64 = s.eps; + for (0..T) |t| { + var ss: f64 = 0; + for (0..lat) |i| { + const x: f64 = kv[t * key + i]; + ss += x * x; + } + const rstd = 1.0 / @sqrt(ss / @as(f64, lat) + eps); + for (0..lat) |i| { + const yn = @as(f64, kv[t * key + i]) * rstd; + lat_t[t * lat + i] = r64(round, r64(round, yn) * w_rms[i]); + } + var z: [rope_dim]f64 = undefined; + var out: [rope_dim]f64 = undefined; + for (0..rope_dim) |i| z[i] = kv[t * key + lat + i]; + rotate(&out, &z, pos0 + @as(u32, @intCast(t)), s.theta); + for (0..rope_dim) |i| krope[t * rope_dim + i] = r64(round, out[i]); + for (0..H) |h| { + for (0..rope_dim) |i| z[i] = q[(t * H + h) * qd + nope + i]; + rotate(&out, &z, pos0 + @as(u32, @intCast(t)), s.theta); + for (0..rope_dim) |i| qrope[(t * H + h) * rope_dim + i] = r64(round, out[i]); + } + } + + for (0..H) |h| { + for (0..T) |t| { + for (0..nope) |d| { + var acc: f64 = 0; + const w0 = ((h * (nope + vd) + d) * lat); + for (0..lat) |c| acc += lat_t[t * lat + c] * kvb[w0 + c]; + k_nope[(t * H + h) * nope + d] = r64(round, acc); + } + for (0..vd) |d| { + var acc: f64 = 0; + const w0 = ((h * (nope + vd) + nope + d) * lat); + for (0..lat) |c| acc += lat_t[t * lat + c] * kvb[w0 + c]; + v[(t * H + h) * vd + d] = r64(round, acc); + } + } + } + + const sc = s.scale(); + const scores = try alloc.alloc(f64, H * T * T); + defer alloc.free(scores); + for (0..H) |h| { + for (0..T) |t| { + for (0..T) |k| { + if (k > t) { + scores[(h * T + t) * T + k] = -std.math.inf(f64); + continue; + } + var p: f64 = 0; + const qb = (t * H + h) * qd; + const kb = (k * H + h) * nope; + for (0..nope) |d| p += @as(f64, q[qb + d]) * k_nope[kb + d]; + const qr = (t * H + h) * rope_dim; + for (0..rope_dim) |d| p += qrope[qr + d] * krope[k * rope_dim + d]; + scores[(h * T + t) * T + k] = p * sc; + } + } + } + + for (0..H) |h| { + for (0..T) |t| { + var m: f64 = -std.math.inf(f64); + const row = scores[(h * T + t) * T ..][0..T]; + for (0..t + 1) |k| m = @max(m, row[k]); + var den: f64 = 0; + for (0..t + 1) |k| { + row[k] = @exp(row[k] - m); + den += row[k]; + } + for (0..t + 1) |k| row[k] /= den; + var o: [vd]f64 = @splat(0); + for (0..t + 1) |k| { + const a = row[k]; + const vb = (k * H + h) * vd; + for (0..vd) |d| o[d] += a * v[vb + d]; + } + const gate = r64(round, sig(g[t * H + h])); + for (0..vd) |d| y[(t * H + h) * vd + d] = r64(round, r64(round, o[d]) * gate); + } + } +} + +/// Unabsorbed MLA in float64, r = identity. Causal over the given rows; pos0 is RoPE only. +pub fn mixF64( + alloc: std.mem.Allocator, + y: []f64, + q: []const f32, + kv: []const f32, + w_rms: []const f32, + kvb: []const f32, + g: []const f32, + s: Shape, + rows: u32, + pos0: u32, +) !void { + try mixAs(false, alloc, y, q, kv, w_rms, kvb, g, s, rows, pos0); +} + +/// Same mixer with r = bf16 at ling_forward.py's points (RMS, kv_b, rot, attn@v, gate). +pub fn mixBf16( + alloc: std.mem.Allocator, + y: []f64, + q: []const f32, + kv: []const f32, + w_rms: []const f32, + kvb: []const f32, + g: []const f32, + s: Shape, + rows: u32, + pos0: u32, +) !void { + try mixAs(true, alloc, y, q, kv, w_rms, kvb, g, s, rows, pos0); +} + +test "tiny MLA geometry is 16 heads, 512 latent, 64 rope, 128 nope/v, softmax 1/sqrt(192)" { + const tiny = @embedFile("fixtures/tiny_config.json"); + var why: config.Why = .{}; + const c = try config.parse(std.testing.allocator, tiny, &why); + const s = Shape.of(&c); + try std.testing.expectEqual(@as(u32, 16), s.heads); + try std.testing.expectEqual(@as(u32, 512), lat); + try std.testing.expectEqual(@as(u32, 64), c.rope_dim); + try std.testing.expectEqual(@as(u32, 128), c.nope); + try std.testing.expectEqual(@as(u32, 128), c.v_dim); + try std.testing.expectEqual(config.RopeStyle.gptj, c.rope_style); + try std.testing.expectEqual(@as(f64, 6000000), s.theta); + try std.testing.expectEqual(@as(f32, @floatCast(s.scale())), c.smScale()); +} + +test "expandGate repeats each head value across 128 columns" { + const g = [_]u16{ 0x3f80, 0x4000, 0x4040, 0xc000 }; + var out: [2 * 2 * vd]u16 = undefined; + expandGate(&out, &g, 2, 2); + for (0..vd) |d| { + try std.testing.expectEqual(@as(u16, 0x3f80), out[d]); + try std.testing.expectEqual(@as(u16, 0x4000), out[vd + d]); + try std.testing.expectEqual(@as(u16, 0x4040), out[2 * vd + d]); + try std.testing.expectEqual(@as(u16, 0xc000), out[3 * vd + d]); + } +} + +test "mixF64 of zeros is zeros" { + const a = std.testing.allocator; + const s = Shape{ .heads = 1, .eps = eps_tiny, .theta = theta_tiny }; + var y: [vd]f64 = undefined; + const q: [qd]f32 = @splat(0); + const kv: [key]f32 = @splat(0); + const w: [lat]f32 = @splat(1); + const kvb: [1 * (nope + vd) * lat]f32 = @splat(0); + const g = [_]f32{0}; + try mixF64(a, &y, &q, &kv, &w, &kvb, &g, s, 1, 0); + for (y) |v| try std.testing.expectEqual(@as(f64, 0), v); +} diff --git a/zig/src/families/ling/mla_rope_test.zig b/zig/src/families/ling/mla_rope_test.zig new file mode 100644 index 00000000000..fd808e28aa2 --- /dev/null +++ b/zig/src/families/ling/mla_rope_test.zig @@ -0,0 +1,84 @@ +//! Ling MLA RoPE: GPT-J pairs then halves, matching ling_forward.py rot() and HF apply_rotary_pos_emb_interleave. +const std = @import("std"); +const config = @import("config.zig"); +const bf16_round = @import("bf16_round"); +const mla = @import("mla.zig"); + +pub const rope_dim: u32 = mla.rope_dim; +pub const nfreq: u32 = mla.nfreq; +pub const invFreq = mla.invFreq; +pub const rotate = mla.rotate; +pub const rotateRows = mla.rotateRows; + +fn tinyTheta() !f64 { + var why: config.Why = .{}; + const c = try config.parse(std.testing.allocator, @embedFile("fixtures/tiny_config.json"), &why); + try std.testing.expectEqual(@as(u32, 64), c.rope_dim); + try std.testing.expectEqual(config.RopeStyle.gptj, c.rope_style); + try std.testing.expectEqual(@as(f64, 6000000), c.rope_theta); + try std.testing.expectEqual(@as(u32, 192), c.qkDim()); + try std.testing.expectEqual(@as(f32, @floatCast(1.0 / @sqrt(@as(f64, 192.0)))), c.smScale()); + return c.rope_theta; +} + +test "tiny MLA rope is 64 GPT-J columns, theta 6e6, softmax 1/sqrt(192)" { + _ = try tinyTheta(); +} + +test "pos 0 writes GPT-J pairs as halves: the identity rotation" { + const theta = try tinyTheta(); + var z: [rope_dim]f64 = undefined; + for (&z, 0..) |*v, i| v.* = @as(f64, @floatFromInt(i)) + 0.25; + var out: [rope_dim]f64 = undefined; + rotate(&out, &z, 0, theta); + for (0..nfreq) |i| { + try std.testing.expectEqual(z[2 * i], out[i]); + try std.testing.expectEqual(z[2 * i + 1], out[nfreq + i]); + } +} + +test "pos 1, 8 and 1024 rotate the first pair by pos radians (frequency 0 is theta^0 = 1)" { + const theta = try tinyTheta(); + try std.testing.expectEqual(@as(f64, 1), invFreq(theta, 0)); + var z: [rope_dim]f64 = @splat(0); + z[0] = 1; + z[1] = 0; + for ([_]u32{ 1, 8, 1024 }) |pos| { + var out: [rope_dim]f64 = undefined; + rotate(&out, &z, pos, theta); + const p: f64 = @floatFromInt(pos); + try std.testing.expectApproxEqAbs(@cos(p), out[0], 1e-12); + try std.testing.expectApproxEqAbs(@sin(p), out[nfreq], 1e-12); + for (1..nfreq) |i| { + try std.testing.expectEqual(@as(f64, 0), out[i]); + try std.testing.expectEqual(@as(f64, 0), out[nfreq + i]); + } + } +} + +test "a pos0 offset of 8 on four rows equals rotating each row at its absolute index" { + const theta = try tinyTheta(); + const rows: u32 = 4; + const pos0: u32 = 8; + var z: [rows * rope_dim]f64 = undefined; + for (&z, 0..) |*v, i| v.* = @as(f64, @floatFromInt(i % 17)) * 0.125 - 1.0; + var chunk: [rows * rope_dim]f64 = undefined; + rotateRows(&chunk, &z, rows, pos0, theta); + var fresh: [rows * rope_dim]f64 = undefined; + for (0..rows) |t| { + rotate(fresh[t * rope_dim ..][0..rope_dim], z[t * rope_dim ..][0..rope_dim], pos0 + @as(u32, @intCast(t)), theta); + } + for (&chunk, fresh) |a, b| try std.testing.expectEqual(a, b); +} + +test "round32 keeps signalling NaN 0x7f800001 and all-ones 0x7fffffff as NaN" { + const cases = [_]u32{ 0x7f800001, 0x7fffffff }; + for (cases) |u| { + const v: f32 = @bitCast(u); + try std.testing.expect(std.math.isNan(v)); + const h = bf16_round.bits(v); + try std.testing.expectEqual(@as(u16, @truncate((u >> 16) | 0x40)), h); + try std.testing.expect(std.math.isNan(bf16_round.value(h))); + try std.testing.expect(std.math.isNan(bf16_round.round32(v))); + } +} diff --git a/zig/src/families/ling/oracle/ling_forward.py b/zig/src/families/ling/oracle/ling_forward.py index 5f51f6b576e..aab4c520286 100644 --- a/zig/src/families/ling/oracle/ling_forward.py +++ b/zig/src/families/ling/oracle/ling_forward.py @@ -99,7 +99,8 @@ def kda(self, x, p): y = out / torch.sqrt((out * out).mean(-1, keepdim=True) + self.eps) * w * torch.sigmoid(gate) return self.lin(r(y).reshape(T, H * dk), p + "o_proj") - def mla(self, x, p): + def mla(self, x, p, pos0=0): + """One MLA layer. x is the pre-normed residual [T, hidden]; attends only over the rows it is given.""" c, r, ck = self.c, self.r, self.ck T, H = x.shape[0], c["num_attention_heads"] nope, rope, dv, lw = c["qk_nope_head_dim"], c["qk_rope_head_dim"], c["v_head_dim"], c["kv_lora_rank"] @@ -108,7 +109,7 @@ def mla(self, x, p): lat = self.norm(kv[:, :lw], ck.t(p + "kv_a_layernorm.weight")) kvb = self.lin(lat, p + "kv_b_proj").view(T, H, nope + dv) inv = 1.0 / c["rope_theta"] ** (torch.arange(0, rope, 2, dtype=torch.float64) / rope) - ang = torch.arange(T, dtype=torch.float64)[:, None] * inv + ang = (pos0 + torch.arange(T, dtype=torch.float64))[:, None] * inv cos, sin = torch.cos(ang), torch.sin(ang) def rot(z): # GPT-J pairs (rope_interleave), out in halves as HF's interleave helper writes them @@ -181,6 +182,11 @@ def mtp_logits(self, ids): return self.norm(x, ck.t(p + "final_layernorm.weight")) @ ck.lin("lm_head").T +def one_mla(ck, c, x, layer, r, pos0=0): + """One MLA layer's output [T, hidden] from its pre-normed input x. Same Model.mla, not a second copy.""" + return Model(ck, c, r).mla(x, f"model.layers.{layer}.attention.", pos0) + + def main(): a = argparse.ArgumentParser(description=__doc__) a.add_argument("ckpt", help="a ling-synth directory (config.json, model.safetensors) or a sharded checkpoint's") @@ -189,11 +195,35 @@ def main(): a.add_argument("--picks", help="route on these picks (i32 [MoE layers][tokens][top_k], the graph's) instead") a.add_argument("--mtp", help="also the MTP layer's logits (float64, bf16 points) and its own picks, to this file") a.add_argument("--ids", help="these tokens (i32, ling-lanes' OUT.ids) instead of the fixed walk; --tokens follows") + a.add_argument("--mla-layer", type=int, metavar="I", help="write one MLA layer's output from --acts instead of full-decoder logits") + a.add_argument("--pos0", type=int, default=0, help="RoPE origin of row 0 of --acts; attention is still only over these rows") + a.add_argument("--acts", help="float64 [T, hidden] pre-normed input for --mla-layer") o = a.parse_args() c = json.load(open(os.path.join(o.ckpt, "config.json"))) one = os.path.join(o.ckpt, "model.safetensors") ck = Ckpt(one if os.path.exists(one) else o.ckpt) V = c["vocab_size"] + if o.mla_layer is not None: + if not o.acts: + a.error("--mla-layer needs --acts") + i = o.mla_layer + stem = f"model.layers.{i}.attention.kv_a_proj_with_mqa" + if not any(k == stem or k.startswith(stem + ".") for k in ck.keys): + a.error(f"layer {i} has no {stem} in the checkpoint: not an MLA layer, or the index is not in this file") + hidden = c["hidden_size"] + raw = torch.frombuffer(bytearray(open(o.acts, "rb").read()), dtype=torch.float64) + if raw.numel() % hidden != 0: + a.error(f"--acts length {raw.numel()} is not a multiple of hidden {hidden}") + x = raw.view(-1, hidden) + T = x.shape[0] + with torch.no_grad(): + y64 = one_mla(ck, c, x, i, lambda z: z, o.pos0) + ybf = one_mla(ck, c, x, i, bf16, o.pos0) + with open(o.out, "wb") as f: + f.write(b"TFLINGA1" + struct.pack("<4I", T, hidden, i, o.pos0)) + f.write(y64.contiguous().numpy().tobytes() + ybf.contiguous().numpy().tobytes()) + print("mla layer", i, "tokens", T, "pos0", o.pos0, "rms", y64.pow(2).mean().sqrt().item()) + return if o.ids: ids = torch.frombuffer(bytearray(open(o.ids, "rb").read()), dtype=torch.int32).long() else: diff --git a/zig/src/families/ling/oracle/mla_dump.py b/zig/src/families/ling/oracle/mla_dump.py new file mode 100644 index 00000000000..80f05157b2b --- /dev/null +++ b/zig/src/families/ling/oracle/mla_dump.py @@ -0,0 +1,216 @@ +"""Tiny-shape MLA dump (TFLINGA1). Random values in Ling-3.0-tiny tensor shapes, not checkpoint weights.""" +from __future__ import annotations + +import importlib.util +import json +import os +import struct +import subprocess +import sys +import tempfile +from pathlib import Path + +import torch +from safetensors.torch import save_file + +HERE = Path(__file__).resolve().parent +FIXTURES = HERE.parent / "fixtures" +TINY_CONFIG = FIXTURES / "tiny_config.json" +LAYER = 3 +MAGIC_M1 = b"TFLINGM1" + + +def load(name, path): + spec = importlib.util.spec_from_file_location(name, path) + mod = importlib.util.module_from_spec(spec) + sys.modules[name] = mod + spec.loader.exec_module(mod) + return mod + + +lf = load("ling_forward", HERE / "ling_forward.py") + + +class FakeCkpt: + def __init__(self, tensors): + self.tensors = tensors + self.keys = set(tensors) + + def t(self, name): + return self.tensors[name] + + def lin(self, module): + return self.t(module + ".weight").double() + + +class CaptureModel(lf.Model): + def lin(self, x, module): + y = super().lin(x, module) + self.captured[module] = y.detach().clone() + if module.endswith("dense"): + self.y_pre_dense = x.detach().clone() + return y + + +def f32_bytes(t): + return t.detach().cpu().contiguous().to(torch.float32).numpy().tobytes() + + +def f64_bytes(t): + return t.detach().cpu().contiguous().to(torch.float64).numpy().tobytes() + + +def make_weights(cfg, g): + H = cfg["num_attention_heads"] + hidden = cfg["hidden_size"] + qa = cfg["q_lora_rank"] + lw = cfg["kv_lora_rank"] + nope, rope, dv = cfg["qk_nope_head_dim"], cfg["qk_rope_head_dim"], cfg["v_head_dim"] + p = f"model.layers.{LAYER}.attention." + scale = cfg.get("initializer_range", 0.02) + + def rand(*shape): + return torch.randn(*shape, generator=g, dtype=torch.float64) * scale + + def rand1(*shape): + return 0.5 + 0.5 * torch.randn(*shape, generator=g, dtype=torch.float64) + + return { + p + "q_a_proj.weight": rand(qa, hidden), + p + "q_a_layernorm.weight": rand1(qa), + p + "q_b_proj.weight": rand(H * (nope + rope), qa), + p + "kv_a_proj_with_mqa.weight": rand(lw + rope, hidden), + p + "kv_a_layernorm.weight": rand1(lw), + p + "kv_b_proj.weight": rand(H * (nope + dv), lw), + p + "g_proj.weight": rand(H, hidden), + p + "dense.weight": rand(hidden, H * dv), + } + + +def capture(cfg, tensors_f64, x, pos0): + p = f"model.layers.{LAYER}.attention." + model = CaptureModel(FakeCkpt(tensors_f64), cfg, lambda z: z) + model.captured = {} + model.y_pre_dense = None + with torch.no_grad(): + out = model.mla(x, p, pos0) + H = cfg["num_attention_heads"] + q = model.captured[p + "q_b_proj"].view(x.shape[0], H, -1) + kv = model.captured[p + "kv_a_proj_with_mqa"] + g = model.captured[p + "g_proj"] + return { + "q": q, + "kv": kv, + "g": g, + "y_pre": model.y_pre_dense, + "y": out, + "w_rms": tensors_f64[p + "kv_a_layernorm.weight"], + "kvb": tensors_f64[p + "kv_b_proj.weight"], + "Wo": tensors_f64[p + "dense.weight"], + } + + +def run_cli(ckpt_dir, acts_path, out_path, pos0): + subprocess.check_call( + [ + sys.executable, + str(HERE / "ling_forward.py"), + str(ckpt_dir), + str(out_path), + "--mla-layer", + str(LAYER), + "--acts", + str(acts_path), + "--pos0", + str(pos0), + ] + ) + + +def write_case_files(tmp, cfg, tensors_f32, x, pos0, a1_path): + ckpt_dir = Path(tmp) / "ckpt" + ckpt_dir.mkdir(exist_ok=True) + with open(ckpt_dir / "config.json", "w") as f: + json.dump(cfg, f, indent=2) + save_file(tensors_f32, ckpt_dir / "model.safetensors") + acts_path = Path(tmp) / f"acts_p{pos0}.bin" + acts_path.write_bytes(f64_bytes(x)) + run_cli(ckpt_dir, acts_path, a1_path, pos0) + raw = a1_path.read_bytes() + assert raw[:8] == b"TFLINGA1", raw[:8] + T, hidden, layer, p0 = struct.unpack_from("<4I", raw, 8) + assert T == x.shape[0] and hidden == cfg["hidden_size"] and layer == LAYER and p0 == pos0 + n = T * hidden + y64 = torch.frombuffer(bytearray(raw[24 : 24 + n * 8]), dtype=torch.float64).clone().view(T, hidden) + ybf = torch.frombuffer(bytearray(raw[24 + n * 8 : 24 + 2 * n * 8]), dtype=torch.float64).clone().view(T, hidden) + return y64, ybf + + +def pack_mixer(cfg, tensors_f64, cases, path): + H = cfg["num_attention_heads"] + hidden = cfg["hidden_size"] + w_rms = tensors_f64[f"model.layers.{LAYER}.attention.kv_a_layernorm.weight"] + kvb = tensors_f64[f"model.layers.{LAYER}.attention.kv_b_proj.weight"] + Wo = tensors_f64[f"model.layers.{LAYER}.attention.dense.weight"] + with open(path, "wb") as f: + f.write(MAGIC_M1) + f.write(struct.pack("<4I", hidden, LAYER, H, len(cases))) + f.write(f32_bytes(w_rms)) + f.write(f32_bytes(kvb)) + f.write(f32_bytes(Wo)) + for case in cases: + T = case["q"].shape[0] + f.write(struct.pack("<2I", T, case["pos0"])) + f.write(f32_bytes(case["q"].reshape(T, -1))) + f.write(f32_bytes(case["kv"])) + f.write(f32_bytes(case["g"])) + f.write(f64_bytes(case["y_pre"])) + f.write(f64_bytes(case["y64"])) + f.write(f64_bytes(case["ybf"])) + + +def main(): + out = Path(sys.argv[1] if len(sys.argv) > 1 else "/tmp/ling-mla-dumps") + out.mkdir(parents=True, exist_ok=True) + cfg = json.loads(TINY_CONFIG.read_text()) + g = torch.Generator().manual_seed(0x74696E79) + tensors_f64 = make_weights(cfg, g) + tensors_f32 = {k: v.float().contiguous() for k, v in tensors_f64.items()} + tensors_cli = {k: v.double() for k, v in tensors_f32.items()} + specs = ( + (4, 0, 0x6D6C61, "mla_tiny_t4_pos0.bin"), + (2, 30000, 0x6D6C62, "mla_tiny_t2_pos30000.bin"), + ) + packed = [] + with tempfile.TemporaryDirectory() as tmp: + for T, pos0, seed, a1_name in specs: + gx = torch.Generator().manual_seed(seed) + x = torch.randn(T, cfg["hidden_size"], generator=gx, dtype=torch.float64) + a1_path = out / a1_name + y64, ybf = write_case_files(tmp, cfg, tensors_f32, x, pos0, a1_path) + cap = capture(cfg, tensors_cli, x, pos0) + worst = (cap["y"] - y64).abs().max().item() + print(f"CaptureModel vs TFLINGA1 T={T} pos0={pos0} worst abs {worst:.6e}") + if worst > 1e-12: + raise SystemExit(f"CLI y64 does not match CaptureModel: {worst}") + packed.append( + { + "pos0": pos0, + "q": cap["q"], + "kv": cap["kv"], + "g": cap["g"], + "y_pre": cap["y_pre"], + "y64": y64, + "ybf": ybf, + } + ) + mixer_path = out / "mla_tiny_mixer.bin" + pack_mixer(cfg, tensors_cli, packed, mixer_path) + print("wrote", mixer_path, "bytes", mixer_path.stat().st_size) + for _, _, _, name in specs: + p = out / name + print("wrote", p, "bytes", p.stat().st_size) + + +if __name__ == "__main__": + main() diff --git a/zig/src/families/minimax_m3/cuda_native.zig b/zig/src/families/minimax_m3/cuda_native.zig index e8ae18b47c9..cc2fd4acc23 100644 --- a/zig/src/families/minimax_m3/cuda_native.zig +++ b/zig/src/families/minimax_m3/cuda_native.zig @@ -61,11 +61,12 @@ pub fn visionBytes(a: std.mem.Allocator, io: std.Io, dir: []const u8) !u64 { pub const Place = struct { rank: usize, world: usize }; pub fn place() !Place { - const r = std.c.getenv("TF_MINIMAX_RANK"); - const w = std.c.getenv("TF_MINIMAX_WORLD"); + const env = @import("sys").environment; + const r = try env.read(?u64, "TF_MINIMAX_RANK", null); + const w = try env.read(?u64, "TF_MINIMAX_WORLD", null); if (r == null and w == null) return .{ .rank = 0, .world = 1 }; if (r == null or w == null) return error.NoRank; - const p: Place = .{ .rank = std.fmt.parseInt(usize, std.mem.span(r.?), 10) catch return error.NoRank, .world = std.fmt.parseInt(usize, std.mem.span(w.?), 10) catch return error.NoRank }; + const p: Place = .{ .rank = @intCast(r.?), .world = @intCast(w.?) }; if (p.world < 1 or p.rank >= p.world) return error.NoRank; return p; } @@ -138,6 +139,7 @@ const Owned = struct { pub fn open(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: []const u8, kernels: ?[]const u8, o: Options) !Loaded { _ = kernels; + try @import("sys").environment.checkScope(.minimax_m3, @import("sys").environment.Process{}); const p = try place(); try admit(@intCast(try ctx.attribute(.compute_capability_major) * 10 + try ctx.attribute(.compute_capability_minor)), p.world); if (p.world > 1 and std.c.getenv("NCCL_COMM_ID") == null) return error.NoCommId; @@ -192,7 +194,7 @@ fn openRank(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: [ if (p.world > 1) { // small gathers by RoCE writes on two ranks, both or neither (TF_ROCE=0: NCCL; TF_ROCE_MAX_KB: the cap) own.group = .{ .lib = own.lib.?, .comm = own.comm, .rank = p.rank, .world = p.world }; - if (p.world == 2) try own.group.?.openRoce(gpa, io, ctx.d, own.e.stream, try roceBytes(if (std.c.getenv("TF_ROCE_MAX_KB")) |v| std.mem.span(v) else null)); + if (p.world == 2) try own.group.?.openRoce(gpa, io, ctx.d, own.e.stream, try roceBytes((@import("sys").environment.Process{}).get("TF_ROCE_MAX_KB"))); own.e.exchange = .{ .nccl = .{ .lib = &own.lib.?, .comm = own.comm, .group = &own.group.? } }; } errdefer if (own.group) |*g| if (g.fast) |f| f.deinit(); diff --git a/zig/src/families/nemotron/backend.zig b/zig/src/families/nemotron/backend.zig index 208b412032b..969216e648f 100644 --- a/zig/src/families/nemotron/backend.zig +++ b/zig/src/families/nemotron/backend.zig @@ -100,7 +100,7 @@ pub const Metal = struct { .tokens = try m.device.buffer(ring * 4, opts), .prompt = try m.device.buffer(@max(o.capacity, 16) * 4, opts), .fence = try Fence.init(m.device), - .trace = platform.c.getenv("TF_SLIDE_TRACE") != null, + .trace = (@import("sys").environment.Process{}).get("TF_SLIDE_TRACE") != null, .coop_split = fwd.splitOn(), }; if (o.chunk > fused_rows) b.wide = try prefill.Prefill.init(m, @min(o.chunk, o.capacity)); diff --git a/zig/src/families/nemotron/choice.zig b/zig/src/families/nemotron/choice.zig deleted file mode 100644 index 5f0bea0e6d2..00000000000 --- a/zig/src/families/nemotron/choice.zig +++ /dev/null @@ -1,67 +0,0 @@ -//! A lesson's block per layer: directions its fact's rows outweigh the steady rows along, the first rank its router's. -const std = @import("std"); -const subspace = @import("subspace.zig"); -const adapters = @import("learn_shape.zig"); - -const n = adapters.candidates; -const block = adapters.block; - -/// What each layer has seen of the steady rows and the fact's answer rows, along its candidate directions. -pub const Choice = struct { - gpa: std.mem.Allocator, - steady: []f64, // [layers, n, n]: the steady rows' second moment - facts: []f64, // [layers, n, n]: the fact's answer rows' second moment - coef: []f32, // [layers, block, n]: each layer's new directions in the candidates' terms - - pub fn init(gpa: std.mem.Allocator, layers: usize) !Choice { - return .{ - .gpa = gpa, - .steady = try gpa.alloc(f64, layers * n * n), - .facts = try gpa.alloc(f64, layers * n * n), - .coef = try gpa.alloc(f32, layers * block * n), - }; - } - - pub fn deinit(c: *Choice) void { - inline for (.{ "steady", "facts", "coef" }) |f| c.gpa.free(@field(c, f)); - } - - pub fn reset(c: *Choice) void { - @memset(c.steady, 0); - @memset(c.facts, 0); - } - - /// Layer l's unit rows [rows, n], steady or the fact's; row `first` (how an answer opens) weighs as all after it. - pub fn add(c: *Choice, l: usize, rows: []const f32, fact: bool, first: usize) void { - const m = (if (fact) c.facts else c.steady)[l * n * n ..][0 .. n * n]; - const count = rows.len / n; - for (0..count) |r| { - const p = rows[r * n ..][0..n]; - const w: f64 = if (r == first) @floatFromInt(@max(count - first - 1, 1)) else 1; - for (0..n) |i| for (0..n) |j| { - m[i * n + j] += w * p[i] * p[j]; - }; - } - } - - /// Every layer's directions. - pub fn choose(c: *Choice) !void { - var threads: [16]?std.Thread = @splat(null); - var failed: [16]?anyerror = @splat(null); - const layers = c.coef.len / (block * n); - const k = @min(threads.len, layers); - for (threads[0..k], 0..) |*t, i| t.* = std.Thread.spawn(.{}, share, .{ c, i, k, &failed[i] }) catch null; - for (threads[0..k], 0..) |t, i| if (t) |th| th.join() else share(c, i, k, &failed[i]); - for (failed[0..k]) |f| if (f) |e| return e; - } - - fn share(c: *Choice, from: usize, step: usize, failed: *?anyerror) void { - var l = from; - while (l < c.coef.len / (block * n)) : (l += step) { - const coef = c.coef[l * block * n ..][0 .. block * n]; - subspace.outweigh(c.gpa, c.facts[l * n * n ..][0 .. n * n], c.steady[l * n * n ..][0 .. n * n], n, block, coef) catch |e| { - failed.* = e; - }; - } - } -}; diff --git a/zig/src/families/nemotron/config.zig b/zig/src/families/nemotron/config.zig index 6ed9775a1b0..dc2a28cf207 100644 --- a/zig/src/families/nemotron/config.zig +++ b/zig/src/families/nemotron/config.zig @@ -12,22 +12,7 @@ pub const latent_max_experts = 1024; /// Conditional MTP acceptance by depth until a stream has its own estimates, from model.py draft_prior. pub const draft_prior = [_]f64{ 0.8, 0.72, 0.68, 0.62, 0.58, 0.55, 0.5, 0.5 }; -/// Why a check refused the checkpoint, kept for the caller's log line (tests read it instead). -pub const Why = struct { - buf: [320]u8 = undefined, - len: usize = 0, - - /// Keep the reason, cut short if it is long. - pub fn set(self: *Why, comptime fmt: []const u8, args: anytype) void { - var w: std.Io.Writer = .fixed(&self.buf); - w.print(fmt, args) catch {}; - self.len = w.end; - } - - pub fn text(self: *const Why) []const u8 { - return self.buf[0..self.len]; - } -}; +pub const Why = @import("config_types.zig").Why; /// config.json's count of learned neurons at the end of every shared expert (other loaders read them as the expert's). pub const pocket_key = "tensorfold_learned_neurons"; @@ -38,21 +23,7 @@ pub const Format = enum { mlx, modelopt }; /// --precision: a ModelOpt checkpoint's own math (e4m3 and NVFP4 rows), or bf16 rows throughout (full). pub const Precision = enum { checkpoint, full }; -/// One matrix's MLX affine width: `bits` per weight, a scale and a bias for each `group` of them. -pub const Width = struct { - bits: u8 = 4, - group: u16 = 64, - - /// The width the 4-bit kernels read (lane tiles, the expert kernels, the embedding); others take the row kernels. - pub fn four(w: Width) bool { - return w.bits == 4 and w.group == 64; - } - - /// A width the core's affine kernels unpack: 2 to 8 bits but 7, in groups of 32, 64 or 128. - pub fn readable(w: Width) bool { - return w.bits >= 2 and w.bits <= 8 and w.bits != 7 and (w.group == 32 or w.group == 64 or w.group == 128); - } -}; +pub const Width = @import("config_types.zig").Width; /// A matrix by its module name, at its width. pub const Named = struct { name: []const u8, width: Width }; @@ -109,6 +80,7 @@ pub const Config = struct { ck: bool = false, // --precision checkpoint: e4m3 rows into the FP8 layers, NVFP4 rows into the experts widths: [max_layers][4]Width = @splat(@splat(.{})), // each layer's matrices (members(kind) order) at their widths embed_width: Width = .{}, + embed_bf16: bool = false, // the token table is stored bf16 (config.json's `false` for it), read by HIP only head_width: Width = .{}, /// MoE layer `i`'s routed experts and width. @@ -219,12 +191,17 @@ pub const Config = struct { /// `dir`/config.json. pub fn read(gpa: std.mem.Allocator, io: std.Io, dir: []const u8) !Config { + return readWith(gpa, io, dir, .{}); + } + + /// `dir`/config.json, also reading what `allow` names. + pub fn readWith(gpa: std.mem.Allocator, io: std.Io, dir: []const u8, allow: Allow) !Config { const path = try std.fs.path.join(gpa, &.{ dir, "config.json" }); defer gpa.free(path); const text = try std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(1 << 25)); // ModelOpt names each module defer gpa.free(text); var why: Why = .{}; - return parse(gpa, text, &why) catch |e| { + return parseWith(gpa, text, &why, allow) catch |e| { if (why.len > 0) std.log.err("{s}: {s}", .{ path, why.text() }); return e; }; @@ -303,7 +280,7 @@ fn width(o: std.json.ObjectMap, key: []const u8, default: usize) usize { } /// The checkpoint's width and each per-module entry's (oQ quants); a width no kernel reads is refused by its module. -fn quantization(c: *Config, o: std.json.ObjectMap, why: *Why) !void { +fn quantization(c: *Config, o: std.json.ObjectMap, why: *Why, allow: Allow) !void { const q = quantBlock(o) orelse { why.set("config.json declares no quantization; the native Nemotron kernels read MLX affine checkpoints", .{}); return error.UnsupportedQuantization; @@ -334,7 +311,7 @@ fn quantization(c: *Config, o: std.json.ObjectMap, why: *Why) !void { c.head_width = global; c.widths = @splat(@splat(global)); var it = q.iterator(); - while (it.next()) |e| if (!blockField(e.key_ptr.*)) try module(c, global, e.key_ptr.*, e.value_ptr.*, why); + while (it.next()) |e| if (!blockField(e.key_ptr.*)) try module(c, global, e.key_ptr.*, e.value_ptr.*, why, allow); } /// What the native Nemotron kernels read, for the refusals that name a width. @@ -347,7 +324,11 @@ fn readable(bits: usize, group: usize) ?Width { } /// A per-module entry as nn.quantize reads it: true, a dict at a readable width, or false for a lesson's matrix. -fn module(c: *Config, global: Width, path: []const u8, v: std.json.Value, why: *Why) !void { +fn module(c: *Config, global: Width, path: []const u8, v: std.json.Value, why: *Why, allow: Allow) !void { + if (allow.bf16_embed and v == .bool and !v.bool and isEmbed(path)) { + c.embed_bf16 = true; + return; + } const slot = target(c, path) orelse return; // a module the engine does not read as a quantized matrix slot.* = switch (v) { .bool => |on| if (on) global else if (learned(path)) Width{} else return unquantized(path, why), // split to 4/64 @@ -366,6 +347,15 @@ fn module(c: *Config, global: Width, path: []const u8, v: std.json.Value, why: * }; } +/// What a backend's loader reads beyond MLX affine matrices (`bf16_embed`: unquantized token table). +pub const Allow = struct { bf16_embed: bool = false }; + +/// Whether `path` names the token embedding (with or without "language_model."). +fn isEmbed(path: []const u8) bool { + const bare = if (std.mem.startsWith(u8, path, "language_model.")) path["language_model.".len..] else path; + return std.mem.eql(u8, bare, "backbone.embeddings"); +} + fn unquantized(path: []const u8, why: *Why) error{UnsupportedQuantization} { why.set("config.json leaves {s} unquantized; the native Nemotron kernels read it only as an MLX affine matrix", .{path}); return error.UnsupportedQuantization; @@ -396,6 +386,11 @@ fn learned(path: []const u8) bool { /// config.json's text; a refusal's reason goes to `why`. pub fn parse(allocator: std.mem.Allocator, text: []const u8, why: *Why) !Config { + return parseWith(allocator, text, why, .{}); +} + +/// `parse`, also reading what `allow` names. +pub fn parseWith(allocator: std.mem.Allocator, text: []const u8, why: *Why, allow: Allow) !Config { var parsed = try std.json.parseFromSlice(std.json.Value, allocator, text, .{}); defer parsed.deinit(); const root = parsed.value.object; @@ -465,7 +460,7 @@ pub fn parse(allocator: std.mem.Allocator, text: []const u8, why: *Why) !Config }; c.salm = salm; // the published bf16 weights, read per tensor as the ModelOpt loader reads a bf16 projection - if (salm) c.format = .modelopt else try quantization(&c, root, why); + if (salm) c.format = .modelopt else try quantization(&c, root, why, allow); return c; } @@ -592,8 +587,5 @@ pub const lightning = test { _ = @import("config_test.zig"); -} - -test { _ = @import("config_bolt_test.zig"); } diff --git a/zig/src/families/nemotron/config_test.zig b/zig/src/families/nemotron/config_test.zig index 6186f81734a..c4b6e8a7d0d 100644 --- a/zig/src/families/nemotron/config_test.zig +++ b/zig/src/families/nemotron/config_test.zig @@ -175,3 +175,19 @@ test "CUDA and the Intel GPU engine refuse any width but 4/64 by name; other con try cfg.fourOnlyText(a, modelopt, "CUDA"); try cfg.fourOnlyText(a, "{\"model_type\": \"llama\"}", "CUDA"); } + +test "a bf16 token table (false) is read only where a backend allows it, by its own name" { + const block = "\"quantization\": {\"group_size\": 64, \"bits\": 6, \"backbone.embeddings\": false}"; + try expectRefused(block, error.UnsupportedQuantization, &.{ "backbone.embeddings", "unquantized" }); + const text = try withQuantization(block); + defer std.testing.allocator.free(text); + var why: Why = .{}; + const c = try cfg.parseWith(std.testing.allocator, text, &why, .{ .bf16_embed = true }); + try std.testing.expect(c.embed_bf16); + try std.testing.expectEqual(Width{ .bits = 6 }, c.widthOf(0, "in_proj")); + // only the token table: a head or a projection stored bf16 is refused with the same allowance + const head = try withQuantization("\"quantization\": {\"group_size\": 64, \"bits\": 4, \"lm_head\": false}"); + defer std.testing.allocator.free(head); + try std.testing.expectError(error.UnsupportedQuantization, cfg.parseWith(std.testing.allocator, head, &why, .{ .bf16_embed = true })); + try std.testing.expect(std.mem.indexOf(u8, why.text(), "lm_head") != null); +} diff --git a/zig/src/families/nemotron/config_types.zig b/zig/src/families/nemotron/config_types.zig new file mode 100644 index 00000000000..80d7ae18131 --- /dev/null +++ b/zig/src/families/nemotron/config_types.zig @@ -0,0 +1,35 @@ +//! Config refusal text and affine matrix widths shared by the Nemotron backends. +const std = @import("std"); + +/// Why a check refused the checkpoint, kept for the caller's log line (tests read it instead). +pub const Why = struct { + buf: [320]u8 = undefined, + len: usize = 0, + + /// Keep the reason, cut short if it is long. + pub fn set(self: *Why, comptime fmt: []const u8, args: anytype) void { + var w: std.Io.Writer = .fixed(&self.buf); + w.print(fmt, args) catch {}; + self.len = w.end; + } + + pub fn text(self: *const Why) []const u8 { + return self.buf[0..self.len]; + } +}; + +/// One matrix's MLX affine width: `bits` per weight, a scale and a bias for each `group` of them. +pub const Width = struct { + bits: u8 = 4, + group: u16 = 64, + + /// The width the 4-bit kernels read (lane tiles, the expert kernels, the embedding); others take the row kernels. + pub fn four(w: Width) bool { + return w.bits == 4 and w.group == 64; + } + + /// A width the core's affine kernels unpack: 2 to 8 bits but 7, in groups of 32, 64 or 128. + pub fn readable(w: Width) bool { + return w.bits >= 2 and w.bits <= 8 and w.bits != 7 and (w.group == 32 or w.group == 64 or w.group == 128); + } +}; diff --git a/zig/src/families/nemotron/cuda_engine.zig b/zig/src/families/nemotron/cuda_engine.zig index 3aa6c32a334..32f21bf2706 100644 --- a/zig/src/families/nemotron/cuda_engine.zig +++ b/zig/src/families/nemotron/cuda_engine.zig @@ -136,7 +136,7 @@ pub const Engine = struct { const e = try gpa.create(Engine); errdefer if (!keep_owner) gpa.destroy(e); e.* = .{ .gpa = gpa, .io = io, .ctx = ctx, .stream = undefined, .k = undefined, .w = undefined, .b = undefined, .c = undefined, .max_len = 0, .pinned = undefined, .history = undefined }; - e.trace = platform.c.getenv("TF_SLIDE_TRACE") != null; + e.trace = (@import("sys").environment.Process{}).get("TF_SLIDE_TRACE") != null; e.c = try Config.read(gpa, io, model_dir); try latent.place(&e.c); var load_cache = @import("core").checkpoint.cache.Load.begin(io, e.c.world > 1); diff --git a/zig/src/families/nemotron/cuda_latent.zig b/zig/src/families/nemotron/cuda_latent.zig index a119d6cbf5b..5bfeef06e43 100644 --- a/zig/src/families/nemotron/cuda_latent.zig +++ b/zig/src/families/nemotron/cuda_latent.zig @@ -87,12 +87,13 @@ pub fn partFloats(c: Config, rows: usize) usize { /// TF_NEMOTRON_RANK of TF_NEMOTRON_WORLD into `c`: both or neither; a world must hold whole shares. pub fn place(c: *Config) !void { - const r = std.c.getenv("TF_NEMOTRON_RANK"); - const w = std.c.getenv("TF_NEMOTRON_WORLD"); + const env = @import("sys").environment; + const r = try env.read(?u64, "TF_NEMOTRON_RANK", null); + const w = try env.read(?u64, "TF_NEMOTRON_WORLD", null); if (r == null and w == null) return; if (r == null or w == null) return error.NoRank; - c.rank = std.fmt.parseInt(usize, std.mem.span(r.?), 10) catch return error.NoRank; - c.world = std.fmt.parseInt(usize, std.mem.span(w.?), 10) catch return error.NoRank; + c.rank = @intCast(r.?); + c.world = @intCast(w.?); if (c.world < 1 or c.rank >= c.world) return error.NoRank; if (c.world == 1) return; if (c.latent == 0) { diff --git a/zig/src/families/nemotron/cuda_native.zig b/zig/src/families/nemotron/cuda_native.zig index 2b885e87403..78fbcefbe8a 100644 --- a/zig/src/families/nemotron/cuda_native.zig +++ b/zig/src/families/nemotron/cuda_native.zig @@ -110,14 +110,16 @@ const Owned = struct { gpa: std.mem.Allocator, e: *engine.Engine, head: ?*Head, /// Own-sequence graphs support both draw modes; drafting also captures the head. pub fn open(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, dir: []const u8, kernels: ?[]const u8, o: Options) !Loaded { - if (std.c.getenv("TF_NEMOTRON_RANK")) |r| if (!std.mem.eql(u8, std.mem.span(r), "0")) { // expert ranks never serve + try @import("sys").environment.checkScope(.nemotron, @import("sys").environment.Process{}); + const rank = try @import("sys").environment.read(?u64, "TF_NEMOTRON_RANK", null); + if (rank != null and rank.? != 0) { @import("cuda_worker.zig").serve(gpa, io, ctx, dir, o.precision) catch |err| { cuda.tp_watch.fail(@errorName(err)); // rank 0 stops with this rank's error std.log.err("expert rank stopped: {s}", .{@errorName(err)}); std.c._exit(1); // a stream may still wait on rank 0: a normal exit would join it }; std.process.exit(0); - }; + } const carve = try openCarveout(gpa, ctx); errdefer if (carve) |c| closeCarveout(gpa, c); const e = try engine.Engine.init(gpa, io, ctx, dir, kernels, .{ .context = o.context, .mtp = o.drafts, .graphs = true, .sampling = null, .segments = o.segments, .carveout = carve, .slide = o.slide, .vision = o.vision, .precision = o.precision }); @@ -206,7 +208,9 @@ fn release(p: *anyopaque) void { /// TF_CUDA_CARVEOUT=1: the display carveout KV planes go to first (cuda/carveout.zig); null when it is off. fn openCarveout(gpa: std.mem.Allocator, ctx: *const cuda.Context) !?*cuda.Carveout { const bytes = (try cuda.carveout.requested(false, env("TF_CUDA_CARVEOUT"), env("TF_CUDA_CARVEOUT_MIB"))) orelse return null; - const card: [*:0]const u8 = platform.c.getenv("TF_DRM_CARD") orelse cuda.carveout.default_card; + const raw_card = (@import("sys").environment.Process{}).get("TF_DRM_CARD") orelse cuda.carveout.default_card; + const card = try gpa.dupeSentinel(u8, raw_card, 0); + defer gpa.free(card); const c = try gpa.create(cuda.Carveout); errdefer gpa.destroy(c); c.* = cuda.Carveout.open(ctx.d, card, bytes) catch |err| { @@ -255,7 +259,7 @@ test "Nemotron paging: registered lookup preserves the native reader's live envi } fn env(name: [:0]const u8) ?[]const u8 { - return std.mem.span(platform.c.getenv(name) orelse return null); + return (@import("sys").environment.Process{}).get(name); } /// The tensors this family loads; the early check uses the same vision switch as open(). diff --git a/zig/src/families/nemotron/cuda_pages.zig b/zig/src/families/nemotron/cuda_pages.zig index 0950e8720df..0931d54b6fc 100644 --- a/zig/src/families/nemotron/cuda_pages.zig +++ b/zig/src/families/nemotron/cuda_pages.zig @@ -6,7 +6,7 @@ const Engine = @import("cuda_engine.zig").Engine; const state = @import("cuda_state.zig"); const reuse = @import("cuda_reuse.zig"); const mtp = @import("cuda_mtp.zig"); -const lesson_route = @import("lesson_route.zig"); +const lesson_route = @import("living").lesson_route; /// One paged sequence, made at load, and the lease of the stream that holds it. const Lane = struct { seq: *state.Seq, lease: kv.Lease = .{}, used: bool = false }; diff --git a/zig/src/families/nemotron/cuda_seq_graphs.zig b/zig/src/families/nemotron/cuda_seq_graphs.zig index 6486a6fc1b4..275bbfc400a 100644 --- a/zig/src/families/nemotron/cuda_seq_graphs.zig +++ b/zig/src/families/nemotron/cuda_seq_graphs.zig @@ -30,8 +30,8 @@ pub const Stats = struct { /// Whether TF_GRAPH_LOG=1 asks for a line a request: its captures, their time, its replays and eager windows. pub fn logFromEnv() bool { - const v = platform.c.getenv("TF_GRAPH_LOG") orelse return false; - return std.mem.eql(u8, std.mem.span(v), "1"); + const v = (@import("sys").environment.Process{}).get("TF_GRAPH_LOG") orelse return false; + return std.mem.eql(u8, v, "1"); } /// One graph of `body` on the bound sequence's buffers, instantiated and uploaded. diff --git a/zig/src/families/nemotron/editor.zig b/zig/src/families/nemotron/editor.zig deleted file mode 100644 index 7723596fc68..00000000000 --- a/zig/src/families/nemotron/editor.zig +++ /dev/null @@ -1,433 +0,0 @@ -//! A fact written at its subject: rank-one changes to a few shared-expert down projections, other keys' outputs kept. -const std = @import("std"); -const adapters = @import("learn_shape.zig"); -const lesson_route = @import("lesson_route.zig"); -const subspace = @import("subspace.zig"); - -const examples = @import("lesson_examples.zig"); -const Example = examples.Example; -const pick = examples.pick; - -/// The MoE layers a fact's change is spread over, first to last; its target is the residual after the last. -pub const layers = [_]usize{ 13, 15, 17 }; -const target_layer = layers[layers.len - 1]; - -const hold: f32 = 1e2; // the kept keys' mean second moment against a fact's own key, when a change is solved -const history_weight: f32 = 1e3; // an earlier fact's key against one kept row: it must keep its output exactly -const target_steps = 30; // Adam steps on the nudge that makes the fact's answers come out -const reach: f32 = 0.1; // each nudge step's size against the residual's -const decay: f32 = 0.5; // the nudge's squared size against the residual's, added to its loss -const furthest: f32 = 4; // the nudge's size at most, against the residual's -const enough: f32 = 0.05; // a mean answer loss low enough that the nudge stops early - -const Phase = enum { kept, facts, target, edits, done }; - -/// The lesson's acting lessons and flags for a step: every lesson kept so far and, once written, this one. -pub const Acting = lesson_route.Acting; - -/// An editor over trainer T (Metal's: its key, residual and nudge). -pub fn Editor(comptime T: type) type { - return struct { - const Self = @This(); - gpa: std.mem.Allocator, - kept: [layers.len]std.ArrayList(f32) = @splat(.empty), // each layer's kept keys [rows, W], this lesson's - history: [layers.len]std.ArrayList(f32) = @splat(.empty), // each layer's keys of every fact written so far - facts: std.ArrayList(Example) = .empty, // the fact's examples that have a subject row, those with answers first - answered: usize = 0, // facts[0..answered] have answers: the nudge is found on those, the key read on all - stay: []const []const Example = &.{}, // the examples whose outputs the change must keep - keys: std.ArrayList(f32) = .empty, // [facts, layers, W]: each example's key at each layer, as last read - base: std.ArrayList(f32) = .empty, // [facts, D]: the residual after the target layer at the subject row, unchanged - now: std.ArrayList(f32) = .empty, // [facts, D]: the same as last read - delta: std.ArrayList(f32) = .empty, // [4, D]: the nudge, its Adam moments, and a round's gradient - phase: Phase = .done, - at: usize = 0, - round: usize = 0, - loss: f32 = 0, - first_loss: f32 = 0, - last_loss: f32 = 0, - size: f32 = 0, // the subject rows' mean residual length after the target layer - - pub fn init(gpa: std.mem.Allocator) Self { - return .{ .gpa = gpa }; - } - - pub fn deinit(e: *Self) void { - for (&e.kept) |*s| s.deinit(e.gpa); - for (&e.history) |*s| s.deinit(e.gpa); - inline for (.{ "facts", "keys", "base", "now", "delta" }) |f| @field(e, f).deinit(e.gpa); - } - - /// Examples naming a subject (`answered` set the nudge, `asked` add keys) and ones to keep; false if too few. - pub fn begin(e: *Self, answered: []const []const Example, asked: []const []const Example, stay: []const []const Example) !bool { - e.facts.clearRetainingCapacity(); - for (answered) |xs| for (xs) |ex| if (ex.subject > 0 and ex.subject < ex.start) try e.facts.append(e.gpa, ex); - e.answered = e.facts.items.len; - if (e.answered < 2) return false; - for (asked) |xs| for (xs) |ex| if (ex.subject > 0 and ex.subject < ex.start) try e.facts.append(e.gpa, ex); - for (&e.kept) |*s| s.clearRetainingCapacity(); - e.stay = stay; - e.next(.kept); - return true; - } - - /// One unit (keys, a nudge step or a layer's change) run with `acting`; true once every layer has its change. - pub fn step(e: *Self, t: *T, acting: Acting) !bool { - return switch (e.phase) { - .kept => e.keptOnce(t, acting), - .facts => e.factsOnce(t, acting), - .target => e.targetOnce(t, acting), - .edits => e.editsOnce(t, acting), - .done => true, - }; - } - - /// The fact's keys joined to every layer's history, once its lesson stays: later facts keep its outputs. - pub fn settle(e: *Self) !void { - const w = keyWidth(e); - if (w == 0) return; - for (0..e.facts.items.len) |i| for (0..layers.len) |j| { - try e.history[j].appendSlice(e.gpa, e.keys.items[(i * layers.len + j) * w ..][0..w]); - }; - } - - /// The kept edit rounded into each layer's codes, all before any write (`host`: codes, addRounded, commit). - pub fn fold(e: *Self, t: *T, host: anytype) !void { - const c = t.b.m.config; - const w = c.shared_width; - const d = c.hidden; - const h = try e.gpa.alloc(f32, w * w); - defer e.gpa.free(h); - const delta = try e.gpa.alloc(f32, d * w); - defer e.gpa.free(delta); - var fresh: [layers.len][]u32 = @splat(&.{}); - defer for (fresh) |f| e.gpa.free(f); - const first = t.sites.first(); - const ranks = t.sites.cap * adapters.block; - for (layers, 0..) |l, j| { - const site = &t.sites.list[l]; - const a = site.a.slice(f32, ranks * site.in)[first * site.in ..][0..site.in]; - const b = site.b.slice(f32, ranks * site.out)[first * site.out ..][0..site.out]; - for (0..d) |o| for (delta[o * w ..][0..w], a) |*x, ai| { - x.* = adapters.scale * b[o] * ai; - }; - const add = secondMoment(e.kept[j].items, e.history[j].items, w, h); - const codes = try host.codes(l); - fresh[j] = try e.gpa.dupe(u32, codes.words); - const changed = try host.addRounded(fresh[j], codes.scales, codes.biases, d, w, delta, h, add); - std.log.info("slide: layer {d}'s down projection takes the change in {d} of its {d} codes", .{ l, changed, d * w }); - } - for (layers, fresh) |l, f| { - @memcpy((try host.codes(l)).words, f); - try host.commit(l); - } - } - - fn keyWidth(e: *const Self) usize { - return if (e.facts.items.len == 0) 0 else e.keys.items.len / (e.facts.items.len * layers.len); - } - - fn turn(ex: Example, acting: Acting) lesson_route.Turn { - return .{ .decide = ex.decide, .bits = acting, .whole = true }; - } - - fn keptOnce(e: *Self, t: *T, acting: Acting) !bool { - var n: usize = 0; - for (e.stay) |xs| n += xs.len; - if (e.at == n) { - e.next(.facts); - return false; - } - const ex = pick(e.stay, e.at); - e.at += 1; - _ = try t.step(ex.ids, ex.start, .keys, turn(ex, acting)); - for (layers, &e.kept) |l, *rows| for (0..ex.ids.len - 1) |r| try widen(e.gpa, rows, t.key(l, r)); - return false; - } - - fn factsOnce(e: *Self, t: *T, acting: Acting) !bool { - const c = t.b.m.config; - if (e.at == 0) { - e.keys.clearRetainingCapacity(); - e.base.clearRetainingCapacity(); - try e.keys.appendNTimes(e.gpa, 0, e.facts.items.len * layers.len * c.shared_width); - try e.base.appendNTimes(e.gpa, 0, e.facts.items.len * c.hidden); - } - if (e.at == e.facts.items.len) { - e.now.clearRetainingCapacity(); - try e.now.appendSlice(e.gpa, e.base.items); - e.size = 0; - for (0..e.answered) |i| e.size += @sqrt(subspace.dot(row(e.base.items, i, c.hidden), row(e.base.items, i, c.hidden))); - e.size /= @floatFromInt(e.answered); - e.delta.clearRetainingCapacity(); - try e.delta.appendNTimes(e.gpa, 0, 4 * c.hidden); - e.next(.target); - return false; - } - const i = e.at; - e.at += 1; - try e.read(t, i, null, acting, true); - return false; - } - - /// Example i's key at every layer (or only layer `only`) and its residual after the target layer, as now. - fn read(e: *Self, t: *T, i: usize, only: ?usize, acting: Acting, unchanged: bool) !void { - const c = t.b.m.config; - const ex = e.facts.items[i]; - _ = try t.step(ex.ids, ex.start, .keys, turn(ex, acting)); - for (layers, 0..) |l, j| { - if (only) |o| if (o != j) continue; - for (e.keys.items[(i * layers.len + j) * c.shared_width ..][0..c.shared_width], t.key(l, ex.subject)) |*o, b| o.* = f32of(b); - } - const into = if (unchanged) e.base.items else e.now.items; - for (row(into, i, c.hidden), t.residual(target_layer + 1, ex.subject)) |*o, b| o.* = f32of(b); - } - - fn targetOnce(e: *Self, t: *T, acting: Acting) !bool { - const d = t.b.m.config.hidden; - const delta = e.delta.items[0..d]; - const grad = e.delta.items[3 * d ..][0..d]; - if (e.at == 0) @memset(grad, 0); - if (e.at < e.answered) { - const ex = e.facts.items[e.at]; - e.at += 1; - t.nudge = .{ .layers = .{ @as(u64, 1) << target_layer, 0, 0 }, .rows = .{ ex.subject, 0, 0 } }; - @memcpy(t.delta.slice(f32, t.b.m.config.layers * d)[target_layer * d ..][0..d], delta); - const got = try t.step(ex.ids, ex.start, .target, turn(ex, acting)); - e.loss += got.loss; - for (grad, t.push.slice(f32, t.b.m.config.layers * d)[target_layer * d ..][0..d]) |*g, p| g.* += p; - return false; - } - const n: f32 = @floatFromInt(e.answered); - const mean = e.loss / n; - if (e.round == 0) e.first_loss = mean; - e.loss = 0; - e.at = 0; - e.round += 1; - if (mean < enough or e.round > target_steps) { - e.last_loss = mean; - std.log.info("slide: the subject's target found in {d} steps, the answers' loss {d:.3} to {d:.3}, its nudge {d:.2} of the residual", .{ e.round - 1, e.first_loss, mean, @sqrt(subspace.dot(delta, delta)) / e.size }); - e.next(.edits); - return false; - } - const m = e.delta.items[d..][0..d]; - const v = e.delta.items[2 * d ..][0..d]; - const lr = reach * e.size / @sqrt(@as(f32, @floatFromInt(d))); - const t1: f32 = @floatFromInt(e.round); - for (delta, m, v, grad) |*x, *mm, *vv, g0| { - const g = g0 / n + 2 * decay * x.* / (e.size * e.size); - mm.* = 0.9 * mm.* + 0.1 * g; - vv.* = 0.999 * vv.* + 0.001 * g * g; - const mh = mm.* / (1 - std.math.pow(f32, 0.9, t1)); - const vh = vv.* / (1 - std.math.pow(f32, 0.999, t1)); - x.* -= lr * mh / (@sqrt(vh) + 1e-8); - } - const len = @sqrt(subspace.dot(delta, delta)); - if (len > furthest * e.size) for (delta) |*x| { - x.* *= furthest * e.size / len; - }; - return false; - } - - fn editsOnce(e: *Self, t: *T, acting: Acting) !bool { - if (e.round == layers.len) { - e.next(.done); - return true; - } - if (e.at < e.facts.items.len) { - const i = e.at; - e.at += 1; - try e.read(t, i, e.round, acting, false); - return false; - } - try e.edit(t, e.round, acting); - e.at = 0; - e.round += 1; - return false; - } - - /// Layer j's rank-one change: the mean key sent to its share of the nudge left, kept and earlier keys held. - fn edit(e: *Self, t: *T, j: usize, acting: Acting) !void { - const c = t.b.m.config; - const w = c.shared_width; - const d = c.hidden; - const n: f32 = @floatFromInt(e.facts.items.len); - const na: f32 = @floatFromInt(e.answered); - const work = try e.gpa.alloc(f32, w + w + d); - defer e.gpa.free(work); - const key = work[0..w]; - const u = work[w..][0..w]; - const left = work[2 * w ..][0..d]; - @memset(work, 0); - for (0..e.facts.items.len) |i| subspace.axpy(key, 1 / n, e.keys.items[(i * layers.len + j) * w ..][0..w]); - for (0..e.answered) |i| for (left, row(e.base.items, i, d), row(e.now.items, i, d), e.delta.items[0..d]) |*o, b, now, dl| { - o.* += (b + dl - now) / na; - }; - for (left) |*o| o.* /= @floatFromInt(layers.len - j); - try solve(e.gpa, e.kept[j].items, e.history[j].items, w, key, u); - const s = subspace.dot(key, u); - const site = &t.sites.list[layers[j]]; - const first = t.sites.first(); - const ranks = t.sites.cap * adapters.block; - const a = site.a.slice(f32, ranks * site.in)[first * site.in ..][0..site.in]; - const b = site.b.slice(f32, ranks * site.out)[first * site.out ..][0..site.out]; - for (a, u) |*o, x| o.* = x / (1 + s); - for (b, left) |*o, x| o.* = x / adapters.scale; - t.sites.attach(&t.b.m.weights, true); - var loss: f32 = 0; - for (e.facts.items[0..e.answered]) |ex| loss += (try t.step(ex.ids, ex.start, .loss, turn(ex, acting))).loss; - std.log.info("slide: change at layer {d}: the key's reach over the kept rows {d:.1}, its change {d:.2} of the residual; the answers' loss with it {d:.3} (the nudge's {d:.3})", .{ layers[j], s, @sqrt(subspace.dot(left, left)) / e.size, loss / na, e.last_loss }); - } - - fn next(e: *Self, phase: Phase) void { - e.phase = phase; - e.at = 0; - e.round = 0; - e.loss = 0; - } - }; -} - -/// A bf16's value. -fn f32of(b: u16) f32 { - return @bitCast(@as(u32, b) << 16); -} - -fn row(xs: []f32, i: usize, n: usize) []f32 { - return xs[i * n ..][0..n]; -} - -/// A bf16 row appended as f32. -fn widen(gpa: std.mem.Allocator, rows: *std.ArrayList(f32), from: []const u16) !void { - try rows.ensureUnusedCapacity(gpa, from.len); - for (from) |b| rows.appendAssumeCapacity(f32of(b)); -} - -/// h = hold X^T X / rows + history_weight H^T H; returns the fold's diagonal add: a hundredth of the kept part's mean. -fn secondMoment(x: []const f32, hist: []const f32, w: usize, h: []f32) f32 { - const rows = x.len / w; - const scale = hold / @as(f32, @floatFromInt(@max(rows, 1))); - @memset(h[0 .. w * w], 0); - const Share = struct { - fn run(xs: []const f32, width: usize, coef: f32, out: []f32, from: usize, to: usize) void { - const n = xs.len / width; - for (0..n) |r| { - const v = xs[r * width ..][0..width]; - for (from..to) |i| { - const f = coef * v[i]; - if (f != 0) subspace.axpy(out[i * width ..][0..width], f, v); - } - } - } - }; - const threads = @min(std.Thread.getCpuCount() catch 1, 32); - var spawned: [32]?std.Thread = @splat(null); - for (0..threads) |k| spawned[k] = std.Thread.spawn(.{}, Share.run, .{ x, w, scale, h, w * k / threads, w * (k + 1) / threads }) catch null; - for (0..threads) |k| if (spawned[k]) |th| th.join() else Share.run(x, w, scale, h, w * k / threads, w * (k + 1) / threads); - var mean: f32 = 0; - for (0..w) |i| mean += h[i * w + i]; - Share.run(hist, w, history_weight, h, 0, w); - if (mean == 0) for (0..w) |i| { // nothing kept: the facts' keys set it after all - mean += h[i * w + i]; - }; - return 1e-2 * mean / @as(f32, @floatFromInt(w)) + 1e-12; -} - -/// u = C^-1 k, C = hold X^T X / rows + history_weight H^T H + mu I (X kept keys, H facts'), by preconditioned CG. -fn solve(gpa: std.mem.Allocator, x: []const f32, h: []const f32, w: usize, k: []const f32, u: []f32) !void { - const rows = x.len / w; - const hist = h.len / w; - const work = try gpa.alloc(f32, 5 * w); - defer gpa.free(work); - const diag = work[0..w]; - const r = work[w..][0..w]; - const z = work[2 * w ..][0..w]; - const p = work[3 * w ..][0..w]; - const ap = work[4 * w ..][0..w]; - const scale = hold / @as(f32, @floatFromInt(@max(rows, 1))); - @memset(diag, 0); - for (0..rows) |i| for (diag, x[i * w ..][0..w]) |*dg, v| { - dg.* += scale * v * v; - }; - for (0..hist) |i| for (diag, h[i * w ..][0..w]) |*dg, v| { - dg.* += history_weight * v * v; - }; - var mean: f32 = 0; - for (diag) |dg| mean += dg; - const mu = 1e-2 * mean / @as(f32, @floatFromInt(w)) + 1e-12; - for (diag) |*dg| dg.* += mu; - @memset(u, 0); - @memcpy(r, k); - for (z, r, diag) |*zi, ri, dg| zi.* = ri / dg; - @memcpy(p, z); - var rz = subspace.dot(r, z); - const stop = 1e-4 * @sqrt(subspace.dot(k, k)); - for (0..400) |_| { - try apply(gpa, x, scale, h, w, mu, p, ap); - const pap = subspace.dot(p, ap); - if (!(pap > 0)) break; - const alpha = rz / pap; - if (!std.math.isFinite(alpha)) break; - subspace.axpy(u, alpha, p); - subspace.axpy(r, -alpha, ap); - if (@sqrt(subspace.dot(r, r)) < stop) break; - for (z, r, diag) |*zi, ri, dg| zi.* = ri / dg; - const rz2 = subspace.dot(r, z); - for (p, z) |*pi, zi| pi.* = zi + rz2 / rz * pi.*; - rz = rz2; - } - for (u) |*v| if (!std.math.isFinite(v.*)) { - v.* = 0; - }; -} - -/// ap = C p, with C as `solve` holds it, the rows' products spread over threads. -fn apply(gpa: std.mem.Allocator, x: []const f32, scale: f32, h: []const f32, w: usize, mu: f32, p: []const f32, ap: []f32) !void { - const threads = @min(std.Thread.getCpuCount() catch 1, 16); - const parts = try gpa.alloc(f32, threads * w); - defer gpa.free(parts); - @memset(parts, 0); - const Share = struct { - fn run(xs: []const f32, hs: []const f32, width: usize, sc: f32, pp: []const f32, out: []f32, from: usize, step: usize) void { - const n = xs.len / width; - var i = from; - while (i < n + hs.len / width) : (i += step) { - const v = if (i < n) xs[i * width ..][0..width] else hs[(i - n) * width ..][0..width]; - const cf = (if (i < n) sc else history_weight) * subspace.dot(v, pp); - subspace.axpy(out, cf, v); - } - } - }; - var spawned: [16]?std.Thread = @splat(null); - for (0..threads) |i| spawned[i] = std.Thread.spawn(.{}, Share.run, .{ x, h, w, scale, p, parts[i * w ..][0..w], i, threads }) catch null; - for (0..threads) |i| if (spawned[i]) |th| th.join() else Share.run(x, h, w, scale, p, parts[i * w ..][0..w], i, threads); - for (ap, p) |*o, v| o.* = mu * v; - for (0..threads) |i| for (ap, parts[i * w ..][0..w]) |*o, v| { - o.* += v; - }; -} - -test "the solve inverts the kept rows' held second moment, earlier facts' keys among them" { - const gpa = std.testing.allocator; - const w = 16; - var x: [40 * w]f32 = undefined; - var h: [3 * w]f32 = undefined; - var prng = std.Random.DefaultPrng.init(3); - for (&x) |*v| v.* = prng.random().float(f32) - 0.5; - for (&h) |*v| v.* = prng.random().float(f32) - 0.5; - var k: [w]f32 = undefined; - for (&k, 0..) |*v, i| v.* = @floatFromInt(i % 3); - var u: [w]f32 = undefined; - try solve(gpa, &x, &h, w, &k, &u); - var diag_mean: f32 = 0; - for (0..w) |i| { - for (0..40) |r| diag_mean += hold / 40 * x[r * w + i] * x[r * w + i]; - for (0..3) |r| diag_mean += history_weight * h[r * w + i] * h[r * w + i]; - } - const mu = 1e-2 * diag_mean / w + 1e-12; - for (0..w) |i| { - var s: f32 = mu * u[i]; - for (0..40) |r| s += hold / 40 * x[r * w + i] * subspace.dot(x[r * w ..][0..w], &u); - for (0..3) |r| s += history_weight * h[r * w + i] * subspace.dot(h[r * w ..][0..w], &u); - try std.testing.expectApproxEqAbs(k[i], s, 2e-2 * (1 + @abs(k[i]))); - } -} diff --git a/zig/src/families/nemotron/gpu_round.zig b/zig/src/families/nemotron/gpu_round.zig index 33dfd4d7991..ab21d8c6304 100644 --- a/zig/src/families/nemotron/gpu_round.zig +++ b/zig/src/families/nemotron/gpu_round.zig @@ -352,7 +352,7 @@ pub fn run(gpa: std.mem.Allocator, b: *Metal, s: *lanes.Stream, o: Options, hook var mtp_known: usize = mtp0 + 1; var queued: u64 = 0; // rounds submitted var read: u64 = 0; // rounds whose records the host took - const log = platform.c.getenv("TF_ROUND_LOG") != null; + const log = (@import("sys").environment.Process{}).get("TF_ROUND_LOG") != null; var widths: [32]usize = undefined; var window_ms: [32]f64 = undefined; for (b.costs.window[0..b.costs.windows], 0..) |w, i| { diff --git a/zig/src/families/nemotron/hip.zig b/zig/src/families/nemotron/hip.zig index a0bbcebb369..46ee4298c98 100644 --- a/zig/src/families/nemotron/hip.zig +++ b/zig/src/families/nemotron/hip.zig @@ -3,8 +3,10 @@ pub const config = @import("config.zig"); pub const Config = config.Config; pub const tensors = @import("hip/tensors.zig"); pub const plan = @import("hip/plan.zig"); +pub const widths = @import("hip/widths.zig"); pub const admit = @import("hip/admit.zig"); pub const model = @import("hip/model.zig"); +pub const embedding = @import("hip/embedding.zig"); pub const load = @import("hip/load.zig"); pub const pages = @import("hip/pages.zig"); /// The Mamba-2 mixer's and the MoE layer's interfaces, which their kernels fill. @@ -28,6 +30,8 @@ test { _ = config; _ = tensors; _ = plan; + _ = widths; + _ = embedding; _ = admit; _ = model; _ = pages; diff --git a/zig/src/families/nemotron/hip/admit.zig b/zig/src/families/nemotron/hip/admit.zig index c0d740bfcec..4128a784b87 100644 --- a/zig/src/families/nemotron/hip/admit.zig +++ b/zig/src/families/nemotron/hip/admit.zig @@ -3,11 +3,12 @@ const std = @import("std"); const config = @import("../config.zig"); const tensors = @import("tensors.zig"); const plan = @import("plan.zig"); +const widths = @import("widths.zig"); const Config = config.Config; -/// The MLX affine checkpoints the HIP engine reads: 4-bit codes in groups of 64. -pub const formats: []const []const u8 = &.{"mlx-q4g64"}; +/// The MLX affine checkpoints the HIP engine reads: 4-, 5-, 6- or 8-bit codes in groups of 64, a width a matrix. +pub const formats = widths.formats; /// Device bytes a rank keeps for the forward's scratch until the engine counts its own. pub const scratch_bytes: u64 = 2 << 30; /// Rows of the vocabulary head the MTP head drafts among (draft_ids.txt). @@ -106,8 +107,8 @@ fn missingWhy( if (have.contains(words)) return refuse( a, problem, - "{s} is stored unquantized (a projection Living Weights taught): Nemotron on HIP reads MLX " ++ - "4-bit projections alone for now", + "{s} is stored unquantized (a projection Living Weights taught): Nemotron on HIP reads " ++ + widths.served_text ++ " alone for now", .{stem}, ); } @@ -129,6 +130,13 @@ fn names( if (check.missing) |m| return missingWhy(a, have, m, where, problem); if (check.found != have.count()) { const name = (extra(a, have, c, mtp) catch return error.Refused) orelse "?"; + if (!mtp and std.mem.startsWith(u8, name, "mtp.")) return refuse( + a, + problem, + "{s} holds the MTP head ({s}) inside the model's shards: Nemotron on HIP reads the head from {s} " ++ + "beside them", + .{ where, name, tensors.mtp_file }, + ); return refuse(a, problem, "{s} holds {s}, which Nemotron-H on HIP does not read", .{ where, name }); } } @@ -147,7 +155,7 @@ fn indexNames(a: std.mem.Allocator, text: []const u8) !std.StringHashMapUnmanage /// The checkpoint's format and what it holds, refused unless the HIP engine reads all of it. pub fn checkpoint(a: std.mem.Allocator, f: Facts, problem: *[]const u8) Refused!Config { var why: config.Why = .{}; - const c = config.parse(a, f.config, &why) catch |err| { + var c = config.parseWith(a, f.config, &why, .{ .bf16_embed = true }) catch |err| { if (why.len > 0) return refuse(a, problem, "{s}", .{why.text()}); return refuse(a, problem, "config.json is not a Nemotron-H config the HIP engine reads ({t})", .{err}); }; @@ -155,14 +163,15 @@ pub fn checkpoint(a: std.mem.Allocator, f: Facts, problem: *[]const u8) Refused! a, problem, "this is a ModelOpt (FP8 and NVFP4) checkpoint: the CUDA engine serves it; Nemotron on HIP reads " ++ - "MLX affine 4-bit checkpoints", + "MLX affine checkpoints", .{}, ); - if (c.bits != 4 or c.group_size != 64) return refuse( + var name: [96]u8 = undefined; + if (widths.unserved(&c, &name)) |m| return refuse( a, problem, - "Nemotron on HIP reads MLX affine 4-bit groups of 64; this checkpoint is {d}-bit in groups of {d}", - .{ c.bits, c.group_size }, + "{s} is {d}-bit in groups of {d}: Nemotron on HIP reads " ++ widths.served_text, + .{ m.name, m.width.bits, m.width.group }, ); if (c.pocket > 0) return refuse( a, @@ -183,11 +192,20 @@ pub fn checkpoint(a: std.mem.Allocator, f: Facts, problem: *[]const u8) Refused! "model.safetensors.index.json is unreadable ({t})", .{err}, ); + // as MLX loads it, a table without scales is not quantized, whatever config.json lists for it + if (tensors.hasBf16Embed(have.contains(tensors.embed ++ ".weight"), have.contains(tensors.embed ++ ".scales"))) c.embed_bf16 = true; try names(a, &have, &c, false, "the checkpoint's index", problem); if (f.mtp) |list| { var head: std.StringHashMapUnmanaged(void) = .empty; for (list) |n| head.put(a, n, {}) catch return error.Refused; try names(a, &head, &c, true, tensors.mtp_file, problem); + if (c.bits != 4 or c.group_size != 64) return refuse( + a, + problem, + "{s} sits beside a model stored {d}-bit in groups of {d}: Nemotron on HIP reads the MTP head beside " ++ + "a model stored 4-bit in groups of 64 only; move {s} out of the folder to serve it without drafts", + .{ tensors.mtp_file, c.bits, c.group_size, tensors.mtp_file }, + ); } return c; } @@ -196,7 +214,9 @@ pub fn checkpoint(a: std.mem.Allocator, f: Facts, problem: *[]const u8) Refused! pub fn admit(a: std.mem.Allocator, f: Facts, ask: Ask, problem: *[]const u8) Refused!Verdict { const c = try checkpoint(a, f, problem); const mtp = f.mtp != null; - const w = plan.weights(&c, ask.world, .device, .{ .mtp = mtp, .drafts = if (mtp) draft_rows else 0 }) catch + const head: config.Width = .{ .bits = @intCast(c.bits), .group = @intCast(c.group_size) }; + const want: plan.Head = .{ .mtp = mtp, .drafts = if (mtp) draft_rows else 0, .width = head }; + const w = plan.weights(&c, ask.world, .device, want) catch return refuse( a, problem, @@ -234,7 +254,7 @@ pub fn tooBig(a: std.mem.Allocator, v: Verdict, ask: Ask, problem: *[]const u8) return refuse( a, problem, - "Nemotron 4-bit on {d} rank(s) holds {d:.2} GiB of weights a rank and {d:.1} GiB of scratch, of the " ++ + "Nemotron on {d} rank(s) holds {d:.2} GiB of weights a rank and {d:.1} GiB of scratch, of the " ++ "{d:.2} GiB this card grants: a {d}-token window does not fit (at most {d}); lower --context or " ++ "add ranks (--tp)", .{ ask.world, gibs(v.weights), gibs(scratch_bytes), gibs(ask.room), ask.window, v.most }, @@ -260,6 +280,16 @@ fn edit(a: std.mem.Allocator, text: []const u8, from: []const u8, to: []const u8 return std.mem.replaceOwned(u8, a, text, from, to); } +/// The stock config with module `name` at `bits` in groups of `group`. +fn module(a: std.mem.Allocator, name: []const u8, bits: u8, group: u16) ![]const u8 { + const entry = try std.fmt.allocPrint(a, "\"group_size\": 64, \"{s}\": {{\"bits\": {d}, \"group_size\": {d}}},", .{ + name, + bits, + group, + }); + return edit(a, stock_config, "\"group_size\": 64,", entry); +} + /// admit() must refuse with a reason naming each of `words`. fn expectRefused(a: std.mem.Allocator, f: Facts, ask: Ask, words: []const []const u8) !void { var problem: []const u8 = ""; @@ -294,6 +324,50 @@ test "the stock checkpoint and its MTP head are admitted; on one V620 a stream t try testing.expect(std.mem.indexOf(u8, problem, "16.00 GiB this card grants") != null); } +test "uniform 8-bit and mixed 4/5/6/8-bit checkpoints in groups of 64 are admitted, their bytes at their widths" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var problem: []const u8 = ""; + const ask: Ask = .{ .window = 4096, .room = 60 * gib }; + const four = try admit(a, .{ .config = stock_config, .index = stock_index }, ask, &problem); + const eight_text = try edit(a, stock_config, "\"bits\": 4", "\"bits\": 8"); + const eight = try admit(a, .{ .config = eight_text, .index = stock_index }, ask, &problem); + try testing.expect(eight.fits and eight.weights > four.weights + four.weights / 2); + var text: []const u8 = stock_config; + for ([_][]const u8{ "backbone.embeddings", "lm_head", "backbone.layers.1.mixer.shared_experts.up_proj" }) |n| { + const entry = try std.fmt.allocPrint(a, "\"group_size\": 64, \"{s}\": {{\"bits\": 8}},", .{n}); + text = try edit(a, text, "\"group_size\": 64,", entry); + } + text = try edit(a, text, "\"group_size\": 64,", "\"group_size\": 64, " ++ + "\"backbone.layers.0.mixer.in_proj\": {\"bits\": 5}, " ++ + "\"backbone.layers.0.mixer.out_proj\": {\"bits\": 6},"); + const mixed = try admit(a, .{ .config = text, .index = stock_index }, ask, &problem); + try testing.expect(mixed.fits and mixed.weights > four.weights and mixed.weights < eight.weights); + try testing.expectEqual(@as(u8, 5), mixed.config.widths[0][0].bits); +} + +test "the MTP head file is refused by name beside a model not stored 4-bit in groups of 64" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var problem: []const u8 = ""; + const ask: Ask = .{ .window = 4096, .room = 60 * gib }; + const mtp = try stockMtp(a); + for ([_][]const u8{ "\"bits\": 6", "\"bits\": 8" }, [_][]const u8{ "6-bit", "8-bit" }) |bits, said| { + const text = try edit(a, stock_config, "\"bits\": 4", bits); + _ = try admit(a, .{ .config = text, .index = stock_index }, ask, &problem); + try expectRefused(a, .{ .config = text, .index = stock_index, .mtp = mtp }, ask, &.{ + tensors.mtp_file, + said, + "without drafts", + }); + } + const mixed = try module(a, "lm_head", 8, 64); + const v = try admit(a, .{ .config = mixed, .index = stock_index, .mtp = mtp }, ask, &problem); + try testing.expect(v.mtp and v.fits); +} + test "altered checkpoints are refused with a reason" { var arena: std.heap.ArenaAllocator = .init(testing.allocator); defer arena.deinit(); @@ -328,15 +402,42 @@ test "altered checkpoints are refused with a reason" { ); try expectRefused( a, - .{ .config = try edit(a, stock_config, "\"bits\": 4", "\"bits\": 8"), .index = stock_index }, + .{ .config = try edit(a, stock_config, "\"group_size\": 64", "\"group_size\": 32"), .index = stock_index }, ask, - &.{"8-bit in groups of 64"}, + &.{ "backbone.embeddings is 4-bit in groups of 32", "groups of 64" }, ); + const three = try module(a, "backbone.layers.4.mixer.in_proj", 3, 64); + try expectRefused(a, .{ .config = three, .index = stock_index }, ask, &.{ + "backbone.layers.4.mixer.in_proj is 3-bit in groups of 64", + }); + try expectRefused(a, .{ .config = try module(a, "lm_head", 8, 128), .index = stock_index }, ask, &.{ + "lm_head is 8-bit in groups of 128", + }); try expectRefused( a, - .{ .config = try edit(a, stock_config, "\"group_size\": 64", "\"group_size\": 32"), .index = stock_index }, + .{ .config = try module(a, "backbone.layers.1.mixer.switch_mlp.fc1", 2, 64), .index = stock_index }, ask, - &.{"groups of 32"}, + &.{"backbone.layers.1.mixer.switch_mlp.fc1 is 2-bit"}, + ); + try expectRefused( + a, + .{ + .config = try edit(a, stock_config, "\"group_size\": 64,", "\"group_size\": 64, " ++ + "\"backbone.layers.5.mixer.q_proj\": false,"), + .index = stock_index, + }, + ask, + &.{ "backbone.layers.5.mixer.q_proj", "unquantized" }, + ); + try expectRefused( + a, + .{ + .config = stock_config, + .index = try edit(a, stock_index, "\"lm_head.weight\"", "\"lm_head.weight\": \"a\", " ++ + "\"mtp.layers.0.eh_proj.weight\""), + }, + ask, + &.{ "mtp.layers.0.eh_proj.weight", "inside the model's shards", tensors.mtp_file }, ); try expectRefused( a, @@ -381,3 +482,84 @@ test "altered checkpoints are refused with a reason" { &.{"--tp 3"}, ); } + +/// The stock config with the raw quantization entries `raw` added to its block. +fn entries(a: std.mem.Allocator, raw: []const u8) ![]const u8 { + return edit(a, stock_config, "\"group_size\": 64,", try std.fmt.allocPrint(a, "\"group_size\": 64, {s},", .{raw})); +} + +/// The stock index without the embedding's scales and biases: a bf16 token table's tensors. +fn bf16Index(a: std.mem.Allocator) ![]const u8 { + const biases = "\"backbone.embeddings.biases\": \"model-00001-of-00004.safetensors\","; + const scales = "\"backbone.embeddings.scales\": \"model-00001-of-00004.safetensors\","; + return edit(a, try edit(a, stock_index, biases, ""), scales, ""); +} + +test "a bf16 token table beside quantized projections is admitted, its bytes counted as stored" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var problem: []const u8 = ""; + const ask: Ask = .{ .window = 4096, .room = 60 * gib }; + const text = try entries(a, "\"backbone.embeddings\": false"); + const mtp = try stockMtp(a); + const stock = try admit(a, .{ .config = stock_config, .index = stock_index, .mtp = mtp }, ask, &problem); + const v = try admit(a, .{ .config = text, .index = try bf16Index(a), .mtp = mtp }, ask, &problem); + try testing.expect(v.fits and v.mtp and v.config.embed_bf16); + const quantized = plan.affine(.{}, v.config.vocab, v.config.hidden); + try testing.expectEqual(stock.weights - quantized + v.config.vocab * v.config.hidden * 2, v.weights); + // as MLX loads it, no scales in the files is enough: config.json need not list the table + const unlisted = try admit(a, .{ .config = stock_config, .index = try bf16Index(a), .mtp = mtp }, ask, &problem); + try testing.expect(unlisted.config.embed_bf16); + try testing.expectEqual(v.weights, unlisted.weights); + // the same text still refuses where the token table is not the engine's to read bare + var why: config.Why = .{}; + try testing.expectError(error.UnsupportedQuantization, config.parse(a, text, &why)); + try testing.expect(std.mem.indexOf(u8, why.text(), "backbone.embeddings") != null); +} + +test "with a bf16 token table, every other unquantized or unread tensor is still refused by name" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const ask: Ask = .{ .window = 4096, .room = 60 * gib }; + const bare = "\"backbone.embeddings\": false"; + const index = try bf16Index(a); + // the table's own mismatches: scales left in the index, or none behind a quantized config + try expectRefused(a, .{ .config = try entries(a, bare), .index = stock_index }, ask, &.{ + "backbone.embeddings.scales", + "does not read", + }); + try expectRefused(a, .{ .config = stock_config, .index = try edit(a, index, "\"backbone.embeddings.weight\"", "\"x\"") }, ask, &.{ + "backbone.embeddings.weight", + }); + try expectRefused(a, .{ .config = try entries(a, "\"backbone.embeddings\": {}"), .index = index }, ask, &.{ + "backbone.embeddings", + "unquantized", + }); + // a bf16 head, projection or attention matrix is not the table + for ([_][]const u8{ "lm_head", "backbone.layers.1.mixer.shared_experts.up_proj", "backbone.layers.5.mixer.q_proj" }) |n| { + const text = try entries(a, try std.fmt.allocPrint(a, "{s}, \"{s}\": false", .{ bare, n })); + try expectRefused(a, .{ .config = text, .index = index }, ask, &.{ n, "unquantized" }); + } + const o_proj = "backbone.layers.12.mixer.o_proj.scales"; + try expectRefused(a, .{ + .config = try entries(a, bare), + .index = try edit(a, index, "\"" ++ o_proj ++ "\"", "\"x\""), + }, ask, &.{ "backbone.layers.12.mixer.o_proj", "Living Weights" }); + // other widths and group sizes + const three = try entries(a, bare ++ ", \"backbone.layers.4.mixer.in_proj\": {\"bits\": 3}"); + try expectRefused(a, .{ .config = three, .index = index }, ask, &.{"backbone.layers.4.mixer.in_proj is 3-bit in groups of 64"}); + const wide = try entries(a, bare ++ ", \"lm_head\": {\"bits\": 8, \"group_size\": 128}"); + try expectRefused(a, .{ .config = wide, .index = index }, ask, &.{"lm_head is 8-bit in groups of 128"}); + const grouped = try edit(a, try entries(a, bare), "\"group_size\": 64,", "\"group_size\": 32,"); + try expectRefused(a, .{ .config = grouped, .index = index }, ask, &.{"groups of 32"}); + // the MTP head inside the shards, and its file beside a model not stored 4-bit + const inside = try edit(a, index, "\"lm_head.weight\"", "\"lm_head.weight\": \"a\", \"mtp.layers.0.eh_proj.weight\""); + try expectRefused(a, .{ .config = try entries(a, bare), .index = inside }, ask, &.{ + "mtp.layers.0.eh_proj.weight", + "inside the model's shards", + }); + const eight = try edit(a, try entries(a, bare), "\"bits\": 4", "\"bits\": 8"); + try expectRefused(a, .{ .config = eight, .index = index, .mtp = try stockMtp(a) }, ask, &.{ tensors.mtp_file, "8-bit" }); +} diff --git a/zig/src/families/nemotron/hip/embedding.zig b/zig/src/families/nemotron/hip/embedding.zig new file mode 100644 index 00000000000..a294374b2a7 --- /dev/null +++ b/zig/src/families/nemotron/hip/embedding.zig @@ -0,0 +1,124 @@ +//! Nemotron-H's token table stored bf16: its rows kept as the file holds them, gathered with no arithmetic. +const std = @import("std"); +const core = @import("core"); +const config = @import("../config.zig"); +const tensors = @import("tensors.zig"); + +const quant = core.quant; +const Tensor = core.checkpoint.Tensor; + +/// The bf16 table `t` holds, its file bytes shared and not widened: [vocab, hidden], else UnexpectedTensor. +pub fn read(a: std.mem.Allocator, t: anytype, c: *const config.Config) !quant.Host { + const h = try quant.readStored(a, t, tensors.embed); + if (h != .dense) return error.UnexpectedTensor; + const w: Tensor = h.dense.weight; + if (w.dtype != .bf16 or w.rank != 2 or w.shape[0] != c.vocab or w.shape[1] != c.hidden) return error.UnexpectedTensor; + return h; +} + +const testing = std.testing; +const round = @import("round.zig"); + +const rows = 5; +const hidden = 8; + +/// A small table of every kind of bf16 pattern: signed zeros, a subnormal, infinities, NaNs and a mixed hash. +fn pattern(out: []u16) void { + const special = [_]u16{ 0x0000, 0x8000, 0x0001, 0x7F80, 0xFF80, 0x7FC1, 0xFFFF, 0x3F80 }; + for (out, 0..) |*v, i| v.* = if (i < special.len) special[i] else @truncate((i + 1) *% 0x9E37 ^ (i >> 3) *% 0x7F4B); +} + +/// The Lightning config cut down to a `rows` x `hidden` table. +fn small() !config.Config { + var why: config.Why = .{}; + var c = try config.parse(testing.allocator, @embedFile("../fixtures/config.json"), &why); + c.vocab = rows; + c.hidden = hidden; + c.embed_bf16 = true; + return c; +} + +/// `model.safetensors` in `dir` holding the entry `name` with `dtype`, `shape` and `bytes`. +fn write(dir: std.Io.Dir, name: []const u8, dtype: []const u8, shape: []const usize, bytes: []const u8) !void { + const entry: core.checkpoint_fixture.Entry = .{ .name = name, .dtype = dtype, .shape = shape, .bytes = bytes }; + try core.checkpoint_fixture.write(testing.allocator, testing.io, dir, "model.safetensors", &.{entry}); +} + +/// The checkpoint as the loader's table reads it: tensors by name, no width of its own. +const Table = struct { + ck: *core.checkpoint.Checkpoint, + + pub fn has(t: *const Table, key: []const u8) bool { + return t.ck.has(key); + } + + pub fn get(t: *const Table, key: []const u8) !Tensor { + return t.ck.get(key); + } + + pub fn width(_: *const Table, _: []const u8) !quant.mlx.Width { + return error.UnsupportedQuantization; + } +}; + +fn opened(dir: std.Io.Dir) !core.checkpoint.Checkpoint { + const path = try dir.realPathFileAlloc(testing.io, ".", testing.allocator); + defer testing.allocator.free(path); + var ck: core.checkpoint.Checkpoint = .{ .gpa = testing.allocator, .io = testing.io }; + errdefer ck.close(); + try ck.add(path, "model.safetensors"); + return ck; +} + +test "the gathered rows are the file's bytes, first row and last, widened exactly; an id past the table is refused" { + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + var values: [rows * hidden]u16 = undefined; + pattern(&values); + const file = std.mem.sliceAsBytes(&values); + try write(tmp.dir, tensors.embed ++ ".weight", "BF16", &.{ rows, hidden }, file); + var ck = try opened(tmp.dir); + defer ck.close(); + const c = try small(); + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const h = try read(arena.allocator(), &Table{ .ck = &ck }, &c); + const table = h.dense.weight; + try testing.expectEqual(core.checkpoint.DType.bf16, table.dtype); + try testing.expectEqual(@as(usize, rows), h.rows()); + // the row the gather launch reads for `id`: `hidden` values at id * hidden, as stored + for ([_]usize{ 0, 1, rows - 2, rows - 1 }) |id| { + const row = table.bytes[id * hidden * 2 ..][0 .. hidden * 2]; + try testing.expectEqualSlices(u8, file[id * hidden * 2 ..][0 .. hidden * 2], row); + for (0..hidden) |col| { + const stored = std.mem.readInt(u16, row[col * 2 ..][0..2], .little); + const widened = try quant.convert.float32(arena.allocator(), table); + const bits = std.mem.readInt(u32, widened.bytes[(id * hidden + col) * 4 ..][0..4], .little); + try testing.expectEqual(@as(u32, stored) << 16, bits); + } + } + // no kernel bounds an id: a round refuses one at the table's row count before its plan is written + var p: round.Plan = .{ .host = undefined, .dev = undefined, .rows = 4, .slots = 1, .pool = 0, .pages = 0, .vocab = h.rows() }; + const last: round.Window = .{ .s = undefined, .pos = 0, .tokens = &.{rows} }; + try testing.expectError(error.TokenOutsideVocabulary, p.send(&.{last}, 4096, undefined)); +} + +test "a table that is not bf16 [vocab, hidden] is refused" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const c = try small(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + const wide: [rows * hidden]f32 = @splat(0); + try write(tmp.dir, tensors.embed ++ ".weight", "F32", &.{ rows, hidden }, std.mem.sliceAsBytes(&wide)); + var ck = try opened(tmp.dir); + defer ck.close(); + try testing.expectError(error.UnexpectedTensor, read(a, &Table{ .ck = &ck }, &c)); + var short: [(rows - 1) * hidden]u16 = undefined; + pattern(&short); + try write(tmp.dir, tensors.embed ++ ".weight", "BF16", &.{ rows - 1, hidden }, std.mem.sliceAsBytes(&short)); + var again = try opened(tmp.dir); + defer again.close(); + try testing.expectError(error.UnexpectedTensor, read(a, &Table{ .ck = &again }, &c)); +} diff --git a/zig/src/families/nemotron/hip/engine.zig b/zig/src/families/nemotron/hip/engine.zig index 9ff4b361cc9..25b53c2500a 100644 --- a/zig/src/families/nemotron/hip/engine.zig +++ b/zig/src/families/nemotron/hip/engine.zig @@ -36,6 +36,8 @@ pub const Options = struct { mtp: bool = true, /// The KV pool is made at `open` from `streams` and `extra_pages`; false leaves it to `sizePool` (after agreeing). pool: bool = true, + /// Admitted config when `admit` already checked the checkpoint; null reads `config.json` with HIP allowances. + cfg: ?config.Config = null, }; pub const Engine = struct { @@ -125,14 +127,15 @@ pub const Engine = struct { if (o.world > 1) e.comm = try (o.group orelse return error.NoGroup).open(); errdefer if (e.comm) |c| c.close(); _ = try steps.done(.{ 0, 0 }, .first); - e.cfg = try config.Config.read(gpa, io, dir); + e.cfg = o.cfg orelse try config.Config.readWith(gpa, io, dir, .{ .bf16_embed = true }); const mtp = o.mtp and o.rank == 0 and hasFile(gpa, dir, tensors.mtp_file); - e.weights = try loader.load( + e.weights = try loader.loadInto( gpa, io, &e.driver, dir, &e.cfg, + o.cfg != null, .{ .world = o.world, .rank = o.rank, .mtp = mtp, .act = e.act }, ); errdefer e.weights.deinit(); diff --git a/zig/src/families/nemotron/hip/load.zig b/zig/src/families/nemotron/hip/load.zig index 28aa0550af7..eedd5a8137d 100644 --- a/zig/src/families/nemotron/hip/load.zig +++ b/zig/src/families/nemotron/hip/load.zig @@ -5,6 +5,8 @@ const core = @import("core"); const config = @import("../config.zig"); const draft_ids = @import("../draft_ids.zig"); const tensors = @import("tensors.zig"); +const widths = @import("widths.zig"); +const embedding = @import("embedding.zig"); const model = @import("model.zig"); const quant = core.quant; @@ -14,9 +16,11 @@ const Host = quant.Host; const Span = quant.Span; const Allocator = std.mem.Allocator; -/// The table core/quant reads projections through: one width for every matrix, as admission checked. +/// The table core/quant reads projections through: each matrix at config.json's width for it, as admission checked. const Tables = struct { ck: *Checkpoint, + /// The model's config, naming each matrix's width; null reads every matrix at `w` (the MTP head's file). + c: ?*const config.Config = null, w: quant.mlx.Width, pub fn has(t: *const Tables, key: []const u8) bool { @@ -27,8 +31,10 @@ const Tables = struct { return t.ck.get(key); } - pub fn width(t: *const Tables, _: []const u8) !quant.mlx.Width { - return t.w; + pub fn width(t: *const Tables, key: []const u8) !quant.mlx.Width { + const c = t.c orelse return t.w; + const w = widths.of(c, key) orelse return error.UnsupportedQuantization; + return .{ .bits = w.bits, .group = w.group }; } }; @@ -178,8 +184,9 @@ const Loader = struct { }; } - /// A routed stack (experts, n, k) as stored, this rank's run of experts when cut. + /// A routed stack (experts, n, k) as stored at its own width, this rank's run of experts when cut. fn stack(l: *const Loader, k: []const u8, cut: ?Span) !model.Projection { + const w = try l.t.width(k); var parts: [3]Tensor = undefined; for (&parts, tensors.parts) |*p, s| { p.* = try l.t.get(try l.key("{s}.{s}", .{ k, s })); @@ -188,13 +195,17 @@ const Loader = struct { } if (parts[0].dtype != .u32) return error.UnsupportedQuantization; parts[0].dtype = .i32; + _ = quant.mlx.geometry.shape(parts[0], parts[1], parts[2], w.bits, w.group, true) catch { + std.log.err("{s}: the stack is not {d}-bit in groups of {d}, as config.json says", .{ k, w.bits, w.group }); + return error.UnexpectedTensor; + }; const pair = try quant.mlx.tables(l.a, parts[1], parts[2]); const h: Host = .{ .mlx = .{ .words = parts[0], .scales = pair[0], .biases = pair[1], - .bits = l.t.w.bits, - .group = l.t.w.group, + .bits = w.bits, + .group = w.group, } }; return quant.view(try quant.upload(l.up.uploader(), h), true); } @@ -274,10 +285,16 @@ fn loadMtp(gpa: Allocator, io: std.Io, l: *Loader, dir: []const u8, c: *const co return out; } +/// The token table as BF16 when decided (`c.embed_bf16`), else as a quantized projection. +fn readEmbed(a: Allocator, t: *const Tables, c: *const config.Config) !Host { + if (c.embed_bf16) return embedding.read(a, t, c); + return quant.read(a, t, tensors.embed); +} + /// What a load takes: the rank, and whether rank 0 reads the MTP head. pub const Options = struct { world: usize = 1, rank: usize = 0, mtp: bool = true, act: model.Kind = .bf16 }; -/// One rank's weights from the model folder `dir` (admitted before): blocks by kind, the head, the MTP head on rank 0. +/// One rank's weights from `dir` using an already-admitted config `c`. pub fn load( gpa: Allocator, io: std.Io, @@ -285,12 +302,31 @@ pub fn load( dir: []const u8, c: *const config.Config, o: Options, +) !Weights { + var cfg = c.*; + return loadInto(gpa, io, r, dir, &cfg, true, o); +} + +/// One rank's weights from `dir`, checking unlisted BF16 embeddings when `admitted` is false. +pub fn loadInto( + gpa: Allocator, + io: std.Io, + r: *const hip.Runtime, + dir: []const u8, + c: *config.Config, + admitted: bool, + o: Options, ) !Weights { var w: Weights = .{ .gpa = gpa }; errdefer w.deinit(); var ck = try Checkpoint.openModel(gpa, io, dir); defer ck.close(); - const tables: Tables = .{ .ck = &ck, .w = .{ .bits = @intCast(c.bits), .group = @intCast(c.group_size) } }; + if (!admitted and !c.embed_bf16 and + tensors.hasBf16Embed(ck.has(tensors.embed ++ ".weight"), ck.has(tensors.embed ++ ".scales"))) + { + c.embed_bf16 = true; + } + const tables: Tables = .{ .ck = &ck, .c = c, .w = .{ .bits = @intCast(c.bits), .group = @intCast(c.group_size) } }; var arena: std.heap.ArenaAllocator = .init(gpa); defer arena.deinit(); const dims = try model.Dims.of(c, o.world, o.rank); @@ -316,7 +352,7 @@ pub fn load( } _ = arena.reset(.retain_capacity); const head = try l.proj(tensors.lm_head); - const embed = try l.proj(tensors.embed); + const embed = try readEmbed(l.a, l.t, c); if (embed.rows() != c.vocab) return error.UnexpectedTensor; // an id below the vocabulary must name a row w.model = .{ .dims = dims, @@ -338,3 +374,58 @@ test "draft ids become runs of the head's rows in their order" { try std.testing.expectEqual(Span{ .from = 4, .to = 7 }, spans[0]); try std.testing.expectEqual(Span{ .from = 2, .to = 4 }, spans[2]); } + +test "the loader's table reads each matrix at config.json's width for it, the head's file at one width" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const stock = @embedFile("../fixtures/config.json"); + const text = try std.mem.replaceOwned(u8, a, stock, "\"group_size\": 64,", "\"group_size\": 64, " ++ + "\"lm_head\": {\"bits\": 8}, \"backbone.layers.0.mixer.in_proj\": {\"bits\": 5}, " ++ + "\"backbone.layers.1.mixer.switch_mlp.fc2\": {\"bits\": 6},"); + var why: config.Why = .{}; + const c = try config.parse(a, text, &why); + const W = quant.mlx.Width; + const four: W = .{ .bits = 4, .group = 64 }; + const t: Tables = .{ .ck = undefined, .c = &c, .w = four }; + try std.testing.expectEqual(W{ .bits = 8, .group = 64 }, try t.width("lm_head")); + try std.testing.expectEqual(W{ .bits = 5, .group = 64 }, try t.width("backbone.layers.0.mixer.in_proj")); + try std.testing.expectEqual(W{ .bits = 6, .group = 64 }, try t.width("backbone.layers.1.mixer.switch_mlp.fc2")); + try std.testing.expectEqual(four, try t.width("backbone.layers.1.mixer.switch_mlp.fc1")); + try std.testing.expectError(error.UnsupportedQuantization, t.width("backbone.layers.1.mixer.gate")); + const head: Tables = .{ .ck = undefined, .w = four }; + try std.testing.expectEqual(four, try head.width("layers.1.mixer.switch_mlp.fc1")); +} + +test "Config.readWith admits backbone.embeddings false on disk while Config.read and parseWith reject invalid heads; readEmbed reads bf16 once decided" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const stock = @embedFile("../fixtures/config.json"); + const bf16_text = try std.mem.replaceOwned(u8, a, stock, "\"group_size\": 64,", "\"group_size\": 64, \"backbone.embeddings\": false,"); + const bad_head = try std.mem.replaceOwned(u8, a, stock, "\"group_size\": 64,", "\"group_size\": 64, \"lm_head\": false,"); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "config.json", .data = bf16_text }); + const dir_path = try tmp.dir.realPathFileAlloc(std.testing.io, ".", a); + var why: config.Why = .{}; + try std.testing.expectError(error.UnsupportedQuantization, config.parse(a, bf16_text, &why)); + const ok = try config.Config.readWith(a, std.testing.io, dir_path, .{ .bf16_embed = true }); + try std.testing.expect(ok.embed_bf16); + try std.testing.expectError(error.UnsupportedQuantization, config.parseWith(a, bad_head, &why, .{ .bf16_embed = true })); + + var cfg_unlisted = try config.parse(a, stock, &why); + cfg_unlisted.vocab = 4; + cfg_unlisted.hidden = 8; + const raw_bf16: [4 * 8]u16 = @splat(0x3F80); + const entry: core.checkpoint_fixture.Entry = .{ .name = tensors.embed ++ ".weight", .dtype = "BF16", .shape = &.{ 4, 8 }, .bytes = std.mem.sliceAsBytes(&raw_bf16) }; + try core.checkpoint_fixture.write(a, std.testing.io, tmp.dir, "model.safetensors", &.{entry}); + var ck: Checkpoint = .{ .gpa = a, .io = std.testing.io }; + defer ck.close(); + try ck.add(dir_path, "model.safetensors"); + cfg_unlisted.embed_bf16 = tensors.hasBf16Embed(ck.has(tensors.embed ++ ".weight"), ck.has(tensors.embed ++ ".scales")); + try std.testing.expect(cfg_unlisted.embed_bf16); + const tables: Tables = .{ .ck = &ck, .c = &cfg_unlisted, .w = .{ .bits = 4, .group = 64 } }; + const embed = try readEmbed(a, &tables, &cfg_unlisted); + try std.testing.expectEqual(core.checkpoint.DType.bf16, embed.dense.weight.dtype); +} diff --git a/zig/src/families/nemotron/hip/native.zig b/zig/src/families/nemotron/hip/native.zig index 8e2487f3813..5b737c02832 100644 --- a/zig/src/families/nemotron/hip/native.zig +++ b/zig/src/families/nemotron/hip/native.zig @@ -12,6 +12,7 @@ const pages = @import("pages.zig"); const hip_lanes = @import("lanes.zig"); const worker = @import("worker.zig"); const costs = @import("costs.zig"); +const widths = @import("widths.zig"); pub const model_type = "nemotron_h"; pub const formats = admit.formats; @@ -187,6 +188,7 @@ fn prepare( .policy = dev.policy, .mtp = dev.policy.mtp.drafts > 0, .pool = false, + .cfg = v.config, }) catch |err| return switch (err) { error.PeerRefused, error.LinkFailed => steps.stoppedBy(a, problem), else => steps.refuseAll(a, problem, "the native HIP engine cannot load {s} ({t})", .{ dir, err }), @@ -236,14 +238,16 @@ fn prepare( cache = .{ .pages = @intCast(fit[0]), .snaps = @intCast(fit[1]) }; e.sizePool(capacity, streams, cache.pages) catch |err| return steps.refuseAll(a, problem, "the native HIP engine cannot allocate its pages ({t})", .{err}); + var label: [64]u8 = undefined; const startup = try std.fmt.allocPrint(gpa, "HIP {s} device {d}, rank {d} of {d}: Nemotron-H model " ++ - "{d:.2} GiB, MTP head {s}; {d} stream{s} at once, {d:.2} GiB each at a {d}-token window, of {d:.2} " ++ + "{s} {d:.2} GiB, MTP head {s}; {d} stream{s} at once, {d:.2} GiB each at a {d}-token window, of {d:.2} " ++ "GiB left after the model and {d:.1} GiB of scratch; prompt cache {d:.2} GiB ({d} pages, {d} " ++ "snapshots); prompts in {d}-row chunks; windows of {d} rows", .{ hip.kernels.arch, dev.index, o.rank, o.world, + widths.label(c, &label), admit.gibs(v.weights), if (e.model_().mtp != null) "loaded" else "off", streams, @@ -347,4 +351,5 @@ pub fn follow( test "the registry entry names the family and its format" { try std.testing.expectEqualStrings("nemotron_h", model_type); try std.testing.expectEqualStrings("mlx-q4g64", formats[0]); + try std.testing.expectEqualStrings("mlx-q8g64", formats[formats.len - 1]); } diff --git a/zig/src/families/nemotron/hip/plan.zig b/zig/src/families/nemotron/hip/plan.zig index 80cb653b772..3704ee644cc 100644 --- a/zig/src/families/nemotron/hip/plan.zig +++ b/zig/src/families/nemotron/hip/plan.zig @@ -3,12 +3,13 @@ const std = @import("std"); const config = @import("../config.zig"); const Config = config.Config; +const Width = config.Width; /// Stored: the checkpoint's bytes. Device: as the loader places them, its bf16 vectors widened to fp32. pub const Mode = enum { stored, device }; -/// The MTP head a rank 0 holds: none, the head alone, or the head and `drafts` rows of the vocabulary head. -pub const Head = struct { mtp: bool = false, drafts: usize = 0 }; +/// The MTP head rank 0 holds: none, the head alone at its file's `width`, or with `drafts` rows of the vocabulary head. +pub const Head = struct { mtp: bool = false, drafts: usize = 0, width: Width = .{} }; /// Where a checkpoint's weights live on a rank of `world`. pub const Weights = struct { @@ -30,9 +31,15 @@ pub const Weights = struct { } }; -/// Bytes of an MLX affine 4-bit group-64 matrix: packed codes, then a bf16 scale and bias a group. -pub fn affine(c: *const Config, n: u64, k: u64) u64 { - return n * k * c.bits / 8 + 4 * n * (k / c.group_size); +/// Bytes of an MLX affine matrix at width `w`: packed codes, then a bf16 scale and bias a group. +pub fn affine(w: Width, n: u64, k: u64) u64 { + return n * k * w.bits / 8 + 4 * n * (k / w.group); +} + +/// The token table's bytes: bf16 as stored when config.json says so, else an affine matrix at its width. +pub fn embedBytes(c: *const Config) u64 { + const d: u64 = c.hidden; + return if (c.embed_bf16) c.vocab * d * 2 else affine(c.embed_width, c.vocab, d); } fn even(n: u64, world: u32) !u64 { @@ -54,34 +61,31 @@ fn float(mode: Mode, n: u64) u64 { return n * @as(u64, if (mode == .device) 4 else 2); } -/// A mixer's bytes into `w`; `whole` keeps it uncut (the MTP head's, on rank 0). -fn mixer(c: *const Config, kind: config.Kind, world: u32, mode: Mode, whole: bool, w: *Weights) !void { +/// A mixer's bytes into `w`, its matrices at `ws` (members(kind) order); `whole` keeps it uncut (the MTP head's). +fn mixer(c: *const Config, kind: config.Kind, ws: [4]Width, world: u32, mode: Mode, whole: bool, w: *Weights) !void { const d: u64 = c.hidden; - const ws: u32 = if (whole) 1 else world; + const cuts: u32 = if (whole) 1 else world; var cut: u64 = 0; var mine: u64 = 0; switch (kind) { .mamba => { - const heads = try even(c.mamba_heads, ws); + const heads = try even(c.mamba_heads, cuts); const inner = heads * c.mamba_head_dim; - const groups = try even(c.groups, ws); + const groups = try even(c.groups, cuts); const conv = inner + 2 * groups * c.state; - cut += affine(c, inner + conv + heads, d) + affine(c, d, inner); + cut += affine(ws[0], inner + conv + heads, d) + affine(ws[1], d, inner); cut += float(mode, conv * c.conv_kernel + conv + 3 * heads + inner); }, .attention => { - const heads = try even(c.heads, ws); + const heads = try even(c.heads, cuts); const kv = if (whole) c.kv_heads else try kvHeads(c, world); - cut += affine( - c, - heads * c.head_dim, - d, - ) + 2 * affine(c, kv * c.head_dim, d) + affine(c, d, heads * c.head_dim); + cut += affine(ws[0], heads * c.head_dim, d) + affine(ws[1], kv * c.head_dim, d) + + affine(ws[2], kv * c.head_dim, d) + affine(ws[3], d, heads * c.head_dim); }, .moe => { mine += float(mode, c.experts * d) + c.experts * 4; - cut += try even(c.experts, ws) * (affine(c, c.expert_width, d) + affine(c, d, c.expert_width)); - const shared = affine(c, c.shared_width, d) + affine(c, d, c.shared_width); + cut += try even(c.experts, cuts) * (affine(ws[0], c.expert_width, d) + affine(ws[1], d, c.expert_width)); + const shared = affine(ws[2], c.shared_width, d) + affine(ws[3], d, c.shared_width); if (whole) cut += shared else w.shared += shared; }, } @@ -95,17 +99,19 @@ fn mixer(c: *const Config, kind: config.Kind, world: u32, mode: Mode, whole: boo pub fn weights(c: *const Config, world: u32, mode: Mode, head: Head) !Weights { var w: Weights = .{}; const d: u64 = c.hidden; - w.replicated += affine(c, c.vocab, d) + float(mode, d); - w.split += affine(c, try even(c.vocab, world), d); - for (c.kinds[0..c.layers]) |kind| { + w.replicated += embedBytes(c) + float(mode, d); + w.split += affine(c.head_width, try even(c.vocab, world), d); + for (c.kinds[0..c.layers], c.widths[0..c.layers]) |kind, ws| { w.replicated += float(mode, d); - try mixer(c, kind, world, mode, false, &w); + try mixer(c, kind, ws, world, mode, false, &w); } if (head.mtp) { - w.head += affine(c, d, 2 * d) + float(mode, 5 * d); - try mixer(c, .attention, world, mode, true, &w); - try mixer(c, .moe, world, mode, true, &w); - if (mode == .device and head.drafts > 0) w.head += affine(c, head.drafts, d) + head.drafts * 4; + const hw: [4]Width = @splat(head.width); + w.head += affine(head.width, d, 2 * d) + float(mode, 5 * d); + try mixer(c, .attention, hw, world, mode, true, &w); + try mixer(c, .moe, hw, world, mode, true, &w); + // the draft rows are the vocabulary head's own, at its width + if (mode == .device and head.drafts > 0) w.head += affine(c.head_width, head.drafts, d) + head.drafts * 4; } return w; } @@ -163,7 +169,7 @@ test "the plan counts every byte of the stock checkpoint and its MTP head, and s // every cut part sums back; only the replicated parts and the kv heads past two ranks add try std.testing.expectEqual( one.split, - w.split * world - if (world > 2) (world - 2) * 6 * 2 * affine(&c, 128, 2688) else 0, + w.split * world - if (world > 2) (world - 2) * 6 * 2 * affine(.{}, 128, 2688) else 0, ); try std.testing.expectEqual(one.shared, w.shared); try std.testing.expectEqual(one.replicated, w.replicated); @@ -172,6 +178,39 @@ test "the plan counts every byte of the stock checkpoint and its MTP head, and s try std.testing.expectError(error.UnevenSplit, weights(&c, 16, .stored, .{})); } +/// The stock config at `bits`, with `eights` (modules) and every MoE layer's shared expert at 8-bit, oQ's layout. +fn oq(a: std.mem.Allocator, bits: u8, eights: []const []const u8) !Config { + const stock = @embedFile("../fixtures/config.json"); + var entries: std.ArrayList(u8) = .empty; + try entries.print(a, "\"bits\": {d}", .{bits}); + const c = try lightning(); + for (eights) |m| try entries.print(a, ", \"{s}\": {{\"bits\": 8}}", .{m}); + for (c.kinds[0..c.layers], 0..) |kind, i| if (kind == .moe) for ([_][]const u8{ "up", "down" }) |p| { + try entries.print(a, ", \"backbone.layers.{d}.mixer.shared_experts.{s}_proj\": {{\"bits\": 8}}", .{ i, p }); + }; + const text = try std.mem.replaceOwned(u8, a, stock, "\"bits\": 4", entries.items); + var why: config.Why = .{}; + return config.parse(a, text, &why); +} + +test "the plan counts every byte of oQ6 and oQ8 checkpoints at each matrix's own width" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + // the tensors of TensorFold's oQ6 (embedding, head, layer 42's attention and shared experts at 8-bit) and oQ8 + const six = try oq(a, 6, &.{ + "backbone.embeddings", "lm_head", + "backbone.layers.42.mixer.q_proj", "backbone.layers.42.mixer.k_proj", + "backbone.layers.42.mixer.v_proj", "backbone.layers.42.mixer.o_proj", + }); + try std.testing.expectEqual(@as(u64, 25964363648), (try weights(&six, 1, .stored, .{})).total(1)); + const eight = try oq(a, 8, &.{}); + try std.testing.expectEqual(@as(u64, 33559877504), (try weights(&eight, 1, .stored, .{})).total(1)); + // the head file at its own width beside an 8-bit model: the stock head's bytes, the draft rows at the head's width + const head = try weights(&eight, 1, .stored, .{ .mtp = true }); + try std.testing.expectEqual(@as(u64, 33559877504 + 751635200), head.total(1)); +} + test "device bytes: the bf16 vectors widened, the draft rows of the head on rank 0" { const c = try lightning(); const stored = try weights(&c, 1, .stored, .{ .mtp = true }); @@ -200,3 +239,39 @@ test "a token's keys and values, a stream's Mamba state, and the window a V620 l try std.testing.expect(most >= 262144); try std.testing.expectEqual(@as(u64, 0), window(16 * gib, w, 2 * gib, 7168, 1 << 20)); } + +/// The bytes a safetensors header gives its one tensor: the end of its `data_offsets`. +fn headerBytes(a: std.mem.Allocator, image: []const u8) !u64 { + const len = std.mem.readInt(u64, image[0..8], .little); + const doc = try std.json.parseFromSliceLeaky(std.json.Value, a, image[8..][0..len], .{}); + const offsets = doc.object.get("backbone.embeddings.weight").?.object.get("data_offsets").?.array.items; + return @intCast(offsets[1].integer - offsets[0].integer); +} + +test "the plan counts a bf16 token table at the bytes its header gives, in both modes and on every rank" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var c = try lightning(); + c.vocab = 1032; + const table = try a.alloc(u8, c.vocab * c.hidden * 2); + @memset(table, 0x3f); + const image = try @import("core").checkpoint_fixture.image(a, &.{.{ + .name = "backbone.embeddings.weight", + .dtype = "BF16", + .shape = &.{ c.vocab, c.hidden }, + .bytes = table, + }}); + const stored = try headerBytes(a, image); + try std.testing.expectEqual(@as(u64, 1032 * 2688 * 2), stored); + var bf = c; + bf.embed_bf16 = true; + try std.testing.expectEqual(stored, embedBytes(&bf)); + try std.testing.expectEqual(affine(.{}, 1032, 2688), embedBytes(&c)); + for ([_]Mode{ .stored, .device }) |mode| for ([_]u32{ 1, 2 }) |world| { + const with = try weights(&bf, world, mode, .{}); + const without = try weights(&c, world, mode, .{}); + try std.testing.expectEqual(stored - affine(.{}, 1032, 2688), with.device(1 % world) - without.device(1 % world)); + try std.testing.expectEqual(with.total(world) - without.total(world), world * (stored - affine(.{}, 1032, 2688))); + }; +} diff --git a/zig/src/families/nemotron/hip/tensors.zig b/zig/src/families/nemotron/hip/tensors.zig index 096346ca303..adbd5632875 100644 --- a/zig/src/families/nemotron/hip/tensors.zig +++ b/zig/src/families/nemotron/hip/tensors.zig @@ -11,6 +11,11 @@ pub const lm_head = "lm_head"; /// The MTP head's file beside the shards; its names have no `backbone.` prefix. pub const mtp_file = "mtp-4bit.safetensors"; +/// Whether a checkpoint's token table is stored unquantized (weight tensor with no scales). +pub fn hasBf16Embed(has_weight: bool, has_scales: bool) bool { + return has_weight and !has_scales; +} + /// Block `i`'s stem: its norm is `{stem}.norm.weight`, its mixer's tensors `{stem}.mixer.*`. pub fn layer(buf: []u8, i: usize) ![]const u8 { return std.fmt.bufPrint(buf, "backbone.layers.{d}", .{i}); @@ -80,7 +85,8 @@ pub fn mixerNames(kind: Kind) struct { projections: []const []const u8, vectors: pub fn eachText(c: *const Config, ctx: anytype, comptime f: fn (@TypeOf(ctx), []const u8) anyerror!void) !void { var buf: [192]u8 = undefined; for (parts) |p| { - try f(ctx, try std.fmt.bufPrint(&buf, "{s}.{s}", .{ embed, p })); + // a bf16 token table is its weight alone + if (!c.embed_bf16 or std.mem.eql(u8, p, "weight")) try f(ctx, try std.fmt.bufPrint(&buf, "{s}.{s}", .{ embed, p })); try f(ctx, try std.fmt.bufPrint(&buf, "{s}.{s}", .{ lm_head, p })); } try f(ctx, norm_f); diff --git a/zig/src/families/nemotron/hip/widths.zig b/zig/src/families/nemotron/hip/widths.zig new file mode 100644 index 00000000000..c893236a0a1 --- /dev/null +++ b/zig/src/families/nemotron/hip/widths.zig @@ -0,0 +1,134 @@ +//! The width each Nemotron-H matrix is read at on HIP: config.json's per-module entries, and the widths admitted. +const std = @import("std"); +const config = @import("../config.zig"); +const tensors = @import("tensors.zig"); + +const Config = config.Config; +const Width = config.Width; + +/// The MLX affine widths the HIP launches read for Nemotron-H, as the registry names them. +pub const formats: []const []const u8 = &.{ "mlx-q4g64", "mlx-q5g64", "mlx-q6g64", "mlx-q8g64" }; +/// What the refusals say Nemotron on HIP reads. +pub const served_text = "MLX affine 4-, 5-, 6- or 8-bit matrices in groups of 64"; + +/// A width the HIP launches read for Nemotron-H: 4, 5, 6 or 8 bits in groups of 64. +pub fn served(w: Width) bool { + return w.group == 64 and (w.bits == 4 or w.bits == 5 or w.bits == 6 or w.bits == 8); +} + +/// The width of the matrix `key` (a projection's name before `.weight`), or null for a name no entry covers. +pub fn of(c: *const Config, key: []const u8) ?Width { + if (std.mem.eql(u8, key, tensors.embed)) return if (c.embed_bf16) null else c.embed_width; + if (std.mem.eql(u8, key, tensors.lm_head)) return c.head_width; + const stem = "backbone.layers."; + if (!std.mem.startsWith(u8, key, stem)) return null; + const rest = key[stem.len..]; + const dot = std.mem.indexOfScalar(u8, rest, '.') orelse return null; + const i = std.fmt.parseInt(usize, rest[0..dot], 10) catch return null; + const mixer = ".mixer."; + if (i >= c.layers or !std.mem.startsWith(u8, rest[dot..], mixer)) return null; + const leaf = rest[dot + mixer.len ..]; + for (config.members(c.kinds[i]), 0..) |m, j| if (std.mem.eql(u8, m, leaf)) return c.widths[i][j]; + return null; +} + +/// The first matrix at a width the launches do not read (its name written into `buf`), else null. +pub fn unserved(c: *const Config, buf: []u8) ?config.Named { + if (!c.embed_bf16 and !served(c.embed_width)) return .{ .name = tensors.embed, .width = c.embed_width }; + for (0..c.layers) |i| for (config.members(c.kinds[i]), 0..) |m, j| if (!served(c.widths[i][j])) { + const name = std.fmt.bufPrint(buf, "backbone.layers.{d}.mixer.{s}", .{ i, m }) catch m; + return .{ .name = name, .width = c.widths[i][j] }; + }; + if (!served(c.head_width)) return .{ .name = tensors.lm_head, .width = c.head_width }; + return null; +} + +/// A short label of the widths held, as `mlx-q4g64`, `mlx-q4g64+q5g64+q8g64` for a mix, `+bf16-embed` for a bf16 table. +pub fn label(c: *const Config, buf: []u8) []const u8 { + var seen: [9]bool = @splat(false); + if (!c.embed_bf16) seen[@min(c.embed_width.bits, 8)] = true; + seen[@min(c.head_width.bits, 8)] = true; + for (0..c.layers) |i| for (0..config.members(c.kinds[i]).len) |j| { + seen[@min(c.widths[i][j].bits, 8)] = true; + }; + var w: std.Io.Writer = .fixed(buf); + var first = true; + for (seen, 0..) |on, bits| if (on) { + w.print("{s}q{d}g64", .{ if (first) "mlx-" else "+", bits }) catch break; + first = false; + }; + if (c.embed_bf16) w.writeAll("+bf16-embed") catch {}; + return w.buffered(); +} + +const testing = std.testing; + +fn parsed(a: std.mem.Allocator, text: []const u8) !Config { + var why: config.Why = .{}; + return config.parse(a, text, &why); +} + +test "a mixed-width table resolves each matrix to its own entry, the rest to the checkpoint's width" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const stock = @embedFile("../fixtures/config.json"); + const mixed = try std.mem.replaceOwned(u8, a, stock, "\"group_size\": 64,", "\"group_size\": 64, " ++ + "\"backbone.embeddings\": {\"bits\": 8, \"group_size\": 64}, " ++ + "\"lm_head\": {\"bits\": 8, \"group_size\": 64}, " ++ + "\"backbone.layers.0.mixer.in_proj\": {\"bits\": 5, \"group_size\": 64}, " ++ + "\"backbone.layers.0.mixer.out_proj\": {\"bits\": 6, \"group_size\": 64}, " ++ + "\"backbone.layers.1.mixer.shared_experts.up_proj\": {\"bits\": 8, \"group_size\": 64},"); + try testing.expect(!std.mem.eql(u8, mixed, stock)); + const c = try parsed(a, mixed); + try testing.expectEqual(Width{ .bits = 8 }, of(&c, "backbone.embeddings").?); + try testing.expectEqual(Width{ .bits = 8 }, of(&c, "lm_head").?); + try testing.expectEqual(Width{ .bits = 5 }, of(&c, "backbone.layers.0.mixer.in_proj").?); + try testing.expectEqual(Width{ .bits = 6 }, of(&c, "backbone.layers.0.mixer.out_proj").?); + try testing.expectEqual(Width{ .bits = 8 }, of(&c, "backbone.layers.1.mixer.shared_experts.up_proj").?); + try testing.expectEqual(Width{ .bits = 4 }, of(&c, "backbone.layers.1.mixer.shared_experts.down_proj").?); + try testing.expectEqual(Width{ .bits = 4 }, of(&c, "backbone.layers.1.mixer.switch_mlp.fc1").?); + try testing.expectEqual(Width{ .bits = 4 }, of(&c, "backbone.layers.2.mixer.in_proj").?); + try testing.expectEqual(@as(?Width, null), of(&c, "backbone.layers.1.mixer.gate")); + try testing.expectEqual(@as(?Width, null), of(&c, "backbone.layers.0.mixer.q_proj")); + try testing.expectEqual(@as(?Width, null), of(&c, "backbone.layers.99.mixer.in_proj")); + var buf: [96]u8 = undefined; + try testing.expectEqual(@as(?config.Named, null), unserved(&c, &buf)); + try testing.expectEqualStrings("mlx-q4g64+q5g64+q6g64+q8g64", label(&c, &buf)); +} + +test "the stock 4-bit checkpoint reads every matrix at 4-bit in groups of 64, as before" { + const c = try parsed(testing.allocator, @embedFile("../fixtures/config.json")); + var buf: [96]u8 = undefined; + try testing.expectEqualStrings("mlx-q4g64", label(&c, &buf)); + try testing.expectEqual(Width{}, of(&c, "lm_head").?); + try testing.expectEqual(Width{}, of(&c, "backbone.embeddings").?); + for (0..c.layers) |i| for (config.members(c.kinds[i])) |m| { + const key = try std.fmt.bufPrint(&buf, "backbone.layers.{d}.mixer.{s}", .{ i, m }); + try testing.expectEqual(Width{ .bits = 4, .group = 64 }, of(&c, key).?); + }; +} + +test "a width the launches do not read is named, the first one found" { + var arena: std.heap.ArenaAllocator = .init(testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const stock = @embedFile("../fixtures/config.json"); + const three = try std.mem.replaceOwned(u8, a, stock, "\"group_size\": 64,", "\"group_size\": 64, " ++ + "\"backbone.layers.5.mixer.q_proj\": {\"bits\": 3, \"group_size\": 64},"); + var buf: [96]u8 = undefined; + const c = try parsed(a, three); + const n = unserved(&c, &buf).?; + try testing.expectEqualStrings("backbone.layers.5.mixer.q_proj", n.name); + try testing.expectEqual(@as(u8, 3), n.width.bits); +} + +test "a bf16 token table has no width: its matrix is unnamed, never unserved, and its label says so" { + var c = try parsed(testing.allocator, @embedFile("../fixtures/config.json")); + c.embed_bf16 = true; + c.embed_width = .{ .bits = 3 }; + var buf: [96]u8 = undefined; + try testing.expectEqual(@as(?Width, null), of(&c, "backbone.embeddings")); + try testing.expectEqual(@as(?config.Named, null), unserved(&c, &buf)); + try testing.expectEqualStrings("mlx-q4g64+bf16-embed", label(&c, &buf)); +} diff --git a/zig/src/families/nemotron/lesson_route.zig b/zig/src/families/nemotron/lesson_route.zig deleted file mode 100644 index f806c76abcb..00000000000 --- a/zig/src/families/nemotron/lesson_route.zig +++ /dev/null @@ -1,121 +0,0 @@ -//! How rows meet lessons in both gate kernels: the decision row scores each router, later rows carry those that clear. -const std = @import("std"); - -pub const max_slots = 64; // latch slots: a stream's replay id (a sequence's on CUDA), the trainer's the last -pub const max_blocks = @import("learn_shape.zig").max_blocks; -pub const trainer_slot = max_slots - 1; -pub const max_segments = 8; - -/// A stream without a decision row: none of its rows carry a lesson. -pub const none: i64 = std.math.maxInt(i32); - -/// No segments: no row carries a lesson. -pub const off: Route = .{}; - -/// Which lessons act on a reply, a bit a block. -pub const Acting = std.bit_set.Integer(max_blocks); - -/// A training example's decision row and the lessons acting after it (`whole`: on every row, as weight edits do). -pub const Turn = struct { decide: u32, bits: Acting = .empty, whole: bool = false }; - -/// A slot's latch flags (`latch`: u32 [max_slots, max_blocks]) set to `bits`, as a training pass reads them. -pub fn flag(latch: []u32, slot: u32, bits: Acting) void { - for (latch[slot * max_blocks ..][0..max_blocks], 0..) |*f, b| f.* = @intFromBool(bits.isSet(b)); -} - -/// A training pass over one example's `rows` rows: its latch is set before the pass (the trainer's slot). -pub fn trained(rows: usize, turn: Turn) Route { - var r: Route = .{ .known = 1, .whole = @intFromBool(turn.whole) }; - r.add(0, rows, 0, turn.decide, trainer_slot); - return r; -} - -pub const Route = extern struct { - count: u32 = 0, - known: u32 = 0, // 1: every latch was set before the pass, so rows after a decision row in it may act (training) - whole: u32 = 0, // 1: lessons edit the weights and act on every row (a training pass's flagged ones, else all) - pad: u32 = 0, - seg: [max_segments][4]i32 = std.mem.zeroes([max_segments][4]i32), - - /// The pass's rows `first`..`first + rows`, a stream's rows from position `pos`, its decision row at `decide`. - pub fn add(r: *Route, first: usize, rows: usize, pos: usize, decide: i64, slot: u32) void { - std.debug.assert(r.count < max_segments); - const at: i64 = if (decide == none) none else @as(i64, @intCast(first)) + decide - @as(i64, @intCast(pos)); - r.seg[r.count] = .{ @intCast(first), @intCast(rows), @intCast(std.math.clamp(at, -1, none)), @intCast(slot) }; - r.count += 1; - } - - /// The pass's rows `first`..`first + rows`, a stream past its decision row: its latch alone decides. - pub fn later(r: *Route, first: usize, rows: usize, slot: u32) void { - r.add(first, rows, 1, 0, slot); - } - - /// Segment s's decision row, when it lies in this pass (then the stream's latch is set after it). - pub fn decision(r: *const Route, s: usize) ?usize { - const g = r.seg[s]; - return if (g[2] >= g[0] and g[2] < g[0] + g[1]) @intCast(g[2]) else null; - } -}; - -test "a stream's rows carry a lesson only after its decision row" { - var r: Route = .{}; - r.add(0, 10, 100, 104, 3); // decision at position 104: pass row 4 - r.add(10, 2, 200, 150, 5); // decided in an earlier pass - r.add(12, 3, 7, none, 6); - try std.testing.expectEqual(@as(?usize, 4), r.decision(0)); - try std.testing.expectEqual(@as(?usize, null), r.decision(1)); - try std.testing.expect(r.seg[1][2] < r.seg[1][0]); - try std.testing.expect(r.seg[2][2] >= r.seg[2][0] + r.seg[2][1]); -} - -/// A pass's rows the pocket acts on, segment by segment in pass order: runs of rows between untaught streams' rows. -pub const Runs = struct { - first: usize = 0, // the open run's first row - rows: usize = 0, // and its rows so far - - /// The run a segment of `rows` rows closes, if any: an untaught segment ends the open run and is left out. - pub fn next(r: *Runs, rows: usize, untaught: bool) ?[2]usize { - if (!untaught) { - r.rows += rows; - return null; - } - const closed = r.last(); - r.* = .{ .first = r.first + r.rows + rows }; - return closed; - } - - /// The open run, once every segment is in. - pub fn last(r: *const Runs) ?[2]usize { - return if (r.rows > 0) .{ r.first, r.rows } else null; - } -}; - -test "the pocket's runs leave out the rows of streams that read the model as shipped" { - var r: Runs = .{}; - try std.testing.expectEqual(@as(?[2]usize, null), r.next(3, false)); - try std.testing.expectEqual(@as(?[2]usize, .{ 0, 3 }), r.next(2, true)); - try std.testing.expectEqual(@as(?[2]usize, null), r.next(4, true)); - try std.testing.expectEqual(@as(?[2]usize, null), r.next(1, false)); - try std.testing.expectEqual(@as(?[2]usize, null), r.next(2, false)); - try std.testing.expectEqual(@as(?[2]usize, .{ 9, 3 }), r.last()); - var all: Runs = .{}; - try std.testing.expectEqual(@as(?[2]usize, null), all.next(5, true)); - try std.testing.expectEqual(@as(?[2]usize, null), all.last()); -} - -/// The kept lessons (blocks below `blocks`) whose router scores reach what they need. -pub fn latched(score: []const f32, need: []const f32, blocks: usize) Acting { - var bits: Acting = .empty; - for (0..blocks) |b| if (need[b] > 0 and score[b] >= need[b]) bits.set(b); - return bits; -} - -test "a kept lesson acts on a reply only once its router score reaches what it needs" { - var score: [max_blocks]f32 = @splat(0); - var need: [max_blocks]f32 = @splat(0); - score[0..4].* = .{ 2.5, 1.2, 0, 3 }; - need[0..2].* = .{ 2, 1.5 }; - const four = latched(&score, &need, 4); - try std.testing.expect(four.isSet(0) and four.count() == 1); - try std.testing.expectEqual(@as(usize, 0), latched(&score, &need, 0).count()); -} diff --git a/zig/src/families/nemotron/pocket_clock.zig b/zig/src/families/nemotron/pocket_clock.zig deleted file mode 100644 index f4b539472b0..00000000000 --- a/zig/src/families/nemotron/pocket_clock.zig +++ /dev/null @@ -1,37 +0,0 @@ -//! Where a pocket lesson's round spends its time: wall seconds, trainer passes and rows of each phase, logged a round. -const std = @import("std"); - -/// A round's phases: examples read, inputs fitted, outputs fitted, the held-out loss read between steps, judging. -pub const Part = enum { read, fit, values, judge, check }; -const parts = std.enums.values(Part).len; - -/// Passes a trainer ran and the rows they held, counted as it steps. -pub const Count = struct { passes: usize = 0, rows: usize = 0 }; - -pub const Clock = struct { - seconds: [parts]f64 = @splat(0), - passes: [parts]usize = @splat(0), - rows: [parts]usize = @splat(0), - round: usize = 1, - - pub fn add(c: *Clock, part: Part, seconds: f64, before: Count, after: Count) void { - const i = @backingInt(part); - c.seconds[i] += seconds; - c.passes[i] += after.passes - before.passes; - c.rows[i] += after.rows - before.rows; - } - - /// The round's line, then the counts cleared for the next round. - pub fn end(c: *Clock) void { - const s = c.seconds; - var total: f64 = 0; - for (s) |x| total += x; - std.log.info("slide pocket: round {d} took {d:.1} s: read {d:.1} s ({d} passes, {d} rows), fit {d:.1} s, values {d:.1} s ({d} passes, {d} rows), judge {d:.1} s ({d} passes), check {d:.1} s ({d} passes)", .{ c.round, total, s[0], c.passes[0], c.rows[0], s[1], s[2], c.passes[2], c.rows[2], s[3], c.passes[3], s[4], c.passes[4] }); - c.* = .{ .round = c.round + 1 }; - } -}; - -/// Seconds on the awake clock. -pub fn now(io: std.Io) f64 { - return @as(f64, @floatFromInt(std.Io.Clock.awake.now(io).toNanoseconds())) / 1e9; -} diff --git a/zig/src/families/nemotron/pocket_dump.zig b/zig/src/families/nemotron/pocket_dump.zig deleted file mode 100644 index b1f5d152a6a..00000000000 --- a/zig/src/families/nemotron/pocket_dump.zig +++ /dev/null @@ -1,40 +0,0 @@ -//! A lesson's read rows written out for offline study (TF_SLIDE_POCKET_DUMP=dir): inputs, labels and examples. -const std = @import("std"); -const platform = @import("sys"); - -/// `bytes` written to `path`. -fn put(path: [:0]const u8, bytes: []const u8) !void { - const f = platform.c.fopen(path, "wb") orelse return error.DumpOpen; - defer _ = platform.c.fclose(f); - if (platform.c.fwrite(bytes.ptr, 1, bytes.len, f) != bytes.len) return error.DumpWrite; -} - -/// Pocket `p`'s read rows under `dir` for `tag`: bf16 [read, slots, D], then their labels and examples as text. -pub fn write(p: anytype, dir: []const u8, tag: usize, d: usize) !void { - const a = p.gpa; - var path: [1024]u8 = undefined; - try put(try std.mem.printSentinel(&path, "{s}/fact-{d}-rows.bf16", .{ dir, tag }, 0), std.mem.sliceAsBytes(p.rows.items)); - var text: std.ArrayList(u8) = .empty; - defer text.deinit(a); - try text.print(a, "{d} {d}", .{ p.moe.items.len, d }); - for (p.moe.items) |l| try text.print(a, " {d}", .{l}); - try text.append(a, '\n'); - var exs: usize = 0; - for (p.labels.items) |l| { - const ex = p.pickRead(l.ex).?.ex; - const key: i32 = if (l.key) |k| @backingInt(k) else -1; - try text.print(a, "{d} {d} {d} {d} {d} {d}\n", .{ @backingInt(l.kind), key, l.ex, l.row, ex.ids[l.row], if (l.row > 0) ex.ids[l.row - 1] else 0 }); - exs = @max(exs, l.ex + 1); - } - try put(try std.mem.printSentinel(&path, "{s}/fact-{d}-labels.txt", .{ dir, tag }, 0), text.items); - text.clearRetainingCapacity(); - for (0..exs) |i| { - const got = p.pickRead(i).?; - const ex = got.ex; - try text.print(a, "{d} {d} {d} {d} {d} {d}", .{ i, @backingInt(got.kind), ex.start, ex.decide, ex.subject, ex.value }); - for (ex.ids) |id| try text.print(a, " {d}", .{id}); - try text.append(a, '\n'); - } - try put(try std.mem.printSentinel(&path, "{s}/fact-{d}-examples.txt", .{ dir, tag }, 0), text.items); - std.log.info("slide pocket: the lesson's {d} read rows written to {s} for study", .{ p.labels.items.len, dir }); -} diff --git a/zig/src/families/nemotron/pocket_fit.zig b/zig/src/families/nemotron/pocket_fit.zig deleted file mode 100644 index 02c9d994934..00000000000 --- a/zig/src/families/nemotron/pocket_fit.zig +++ /dev/null @@ -1,286 +0,0 @@ -//! A pocket neuron's input weights by Adam on squared hinges: at least 1 on its fact's rows, below zero elsewhere. -const std = @import("std"); -const subspace = @import("subspace.zig"); - -pub const margin: f32 = 0.25; // how far below zero a fact's neuron sits on rows it stays silent on -pub const fit_steps = 500; // Adam steps fitting a neuron's input weights -pub const fit_rate: f32 = 0.01; // their step, the inputs scaled to unit length - -/// A read row to the open fact: a key row of a learned, held-out or other prompt, any other row, or left free. -pub const Kind = enum(u8) { fact, held, steady, other, none }; - -/// One MoE layer's fit: how its neuron's input product sits on each kind of row. -pub const Fit = struct { - fact_least: f32 = 0, // the lowest over the fact's own questions - fact_on: f32 = 0, // the share of them at 0.5 or more - held_mean: f32 = 0, - held_on: f32 = 0, - steady_most: f32 = 0, // the highest over other prompts' first reply rows - other_most: f32 = 0, // the highest over every other row read - fires: usize = 0, // rows it must stay silent on where it is above zero -}; - -/// Slot j's neuron fitted on its read rows, copied side by side first (a failure: zero, its slot last in line). -pub fn fitLayer(gpa: std.mem.Allocator, rows: []const u16, kinds: []const Kind, slots: usize, j: usize, d: usize, u: []f32, out: *Fit) void { - const own = gpa.alloc(u16, kinds.len * d) catch { - out.* = .{ .fires = std.math.maxInt(usize) }; - return; - }; - defer gpa.free(own); - const xs = gpa.alloc([]const u16, kinds.len) catch { - out.* = .{ .fires = std.math.maxInt(usize) }; - return; - }; - defer gpa.free(xs); - for (xs, 0..) |*x, i| { - @memcpy(own[i * d ..][0..d], rows[(i * slots + j) * d ..][0..d]); - x.* = own[i * d ..][0..d]; - } - out.* = fit(gpa, xs, kinds, d, u, false, fit_steps, 0) catch blk: { - @memset(u, 0); - break :blk .{ .fires = std.math.maxInt(usize) }; - }; -} - -/// Fits `u` on `xs` (from `u` if `warm`): at least 1 on fact rows, at most -margin elsewhere; first `fixed` rows kept. -pub fn fit(gpa: std.mem.Allocator, xs: []const []const u16, kinds: []const Kind, d: usize, u: []f32, warm: bool, steps: usize, fixed: usize) !Fit { - const n = kinds.len; - var scale: f32 = 0; - for (xs) |x| scale += @sqrt(squares(x)); - scale /= @floatFromInt(@max(n, 1)); - const inv = 1 / scale; - var counts: [5]f32 = @splat(0); - for (kinds) |k| counts[@backingInt(k)] += 1; - const w = try gpa.alloc(f32, 8 * d); - defer gpa.free(w); - @memset(w, 0); - const mean_fact = w[0..d]; - const mean_rest = w[d..][0..d]; - const m = w[2 * d ..][0..d]; - const v = w[3 * d ..][0..d]; - const g = w[4 * d ..][0..d]; - const parts = w[5 * d ..][0 .. 3 * d]; // each kind's rows on the wrong side, their hinges' sum: fact, steady, other - if (warm) { - for (u) |*o| o.* *= scale; - } else { - // a start: the fact's mean less the mean of the rows it stays silent on, sized so the fact's mean is 1 - for (kinds, xs) |k, x| switch (k) { - .fact => axpyRow(mean_fact, inv / @max(counts[0], 1), x), - .steady, .other => axpyRow(mean_rest, inv / @max(counts[2] + counts[3], 1), x), - .held, .none => {}, - }; - for (u, mean_fact, mean_rest) |*o, a, b| o.* = a - b; - const at_fact = subspace.dot(u, mean_fact); - if (at_fact > 0) for (u) |*o| { - o.* /= at_fact; - }; - } - const basis = try gpa.alloc(f32, 2 * fixed * d); - defer gpa.free(basis); - const own = basis[fixed * d ..]; - for (0..fixed) |i| for (own[i * d ..][0..d], xs[i]) |*o, b| { - o.* = bf(b) * inv; - }; - const rank = orthonormal(basis[0 .. fixed * d], own, d); - for (1..steps + 1) |s| { - // each kind weighed by its rows on the wrong side only: a few rows that still slip are pushed as hard as many - @memset(parts, 0); - var wrong: [3]f32 = @splat(0); - for (kinds, xs) |k, x| { - const z = dotRow(u, x) * inv; - switch (k) { - .fact => if (z < 1) { - wrong[0] += 1; - axpyRow(parts[0..d], -2 * (1 - z), x); - }, - .steady, .other => if (z > -margin) { - const at: usize = if (k == .steady) 1 else 2; - wrong[at] += 1; - axpyRow(parts[at * d ..][0..d], 2 * (z + margin), x); - }, - .held, .none => {}, - } - } - @memset(g, 0); - for (0..3) |at| subspace.axpy(g, inv / @max(wrong[at], 1), parts[at * d ..][0..d]); - const tt: f32 = @floatFromInt(s); - for (u, m, v, g) |ui, *mi, *vi, *gi| { - const gg = gi.* + 2e-4 * ui; - mi.* = 0.9 * mi.* + 0.1 * gg; - vi.* = 0.999 * vi.* + 0.001 * gg * gg; - gi.* = fit_rate * (mi.* / (1 - std.math.pow(f32, 0.9, tt))) / (@sqrt(vi.* / (1 - std.math.pow(f32, 0.999, tt))) + 1e-8); - } - // the step, less its part along the fixed rows' span - for (0..rank) |j| { - const b = basis[j * d ..][0..d]; - subspace.axpy(g, -subspace.dot(g, b), b); - } - for (u, g) |*ui, st| ui.* -= st; - } - var f: Fit = .{ .fact_least = std.math.inf(f32), .steady_most = -std.math.inf(f32), .other_most = -std.math.inf(f32) }; - for (kinds, xs) |k, x| { - const zi = dotRow(u, x) * inv; - switch (k) { - .fact => { - f.fact_least = @min(f.fact_least, zi); - f.fact_on += @floatFromInt(@intFromBool(zi >= 0.5)); - }, - .held => { - f.held_mean += if (zi > 0) zi * zi else 0; - f.held_on += @floatFromInt(@intFromBool(zi >= 0.5)); - }, - .steady => { - f.steady_most = @max(f.steady_most, zi); - f.fires += @intFromBool(zi > 0); - }, - .other => { - f.other_most = @max(f.other_most, zi); - f.fires += @intFromBool(zi > 0); - }, - .none => {}, - } - } - f.fact_on /= @max(counts[0], 1); - f.held_on /= @max(counts[1], 1); - f.held_mean /= @max(counts[1], 1); - for (u) |*o| o.* /= scale; - return f; -} - -const V = @Vector(8, f32); - -/// Eight bf16 values widened to f32, exactly. -inline fn widen8(b: []const u16) V { - const raw: @Vector(8, u32) = @as(@Vector(8, u16), b[0..8].*); - return @bitCast(raw << @splat(16)); -} - -fn bf(b: u16) f32 { - return @bitCast(@as(u32, b) << 16); -} - -/// a . b for f32 `a` and bf16 `b`: four sums of eight lanes, so no add waits on the one before it. -fn dotRow(a: []const f32, b: []const u16) f32 { - var acc: [4]V = @splat(@splat(0)); - var i: usize = 0; - while (i + 32 <= a.len) : (i += 32) { - inline for (&acc, 0..) |*x, k| x.* += @as(V, a[i + 8 * k ..][0..8].*) * widen8(b[i + 8 * k ..]); - } - while (i + 8 <= a.len) : (i += 8) acc[0] += @as(V, a[i..][0..8].*) * widen8(b[i..]); - var s = @reduce(.Add, (acc[0] + acc[1]) + (acc[2] + acc[3])); - while (i < a.len) : (i += 1) s += a[i] * bf(b[i]); - return s; -} - -/// y += c b for bf16 `b`. -fn axpyRow(y: []f32, c: f32, b: []const u16) void { - const cv: V = @splat(c); - var i: usize = 0; - while (i + 8 <= y.len) : (i += 8) y[i..][0..8].* = @as(V, y[i..][0..8].*) + cv * widen8(b[i..]); - while (i < y.len) : (i += 1) y[i] += c * bf(b[i]); -} - -/// b . b for bf16 `b`. -fn squares(b: []const u16) f32 { - var acc: V = @splat(0); - var i: usize = 0; - while (i + 8 <= b.len) : (i += 8) { - const x = widen8(b[i..]); - acc += x * x; - } - var s = @reduce(.Add, acc); - while (i < b.len) : (i += 1) s += bf(b[i]) * bf(b[i]); - return s; -} - -/// An orthonormal basis of `rows` ([k, d]) into `basis` by Gram-Schmidt run twice, rows in the span left out; its rank. -fn orthonormal(basis: []f32, rows: []const f32, d: usize) usize { - var rank: usize = 0; - for (0..rows.len / d) |i| { - const q = basis[rank * d ..][0..d]; - @memcpy(q, rows[i * d ..][0..d]); - const before = @sqrt(subspace.dot(q, q)); - for (0..2) |_| for (0..rank) |j| { - const b = basis[j * d ..][0..d]; - subspace.axpy(q, -subspace.dot(q, b), b); - }; - const len = @sqrt(subspace.dot(q, q)); - if (len <= 1e-3 * before) continue; - for (q) |*e| e.* /= len; - rank += 1; - } - return rank; -} - -pub fn dotBf16(a: []const f32, b: []const u16) f32 { - var s: f32 = 0; - for (a, b) |x, y| s += x * @as(f32, @bitCast(@as(u32, y) << 16)); - return s; -} - -pub fn normBf16(b: []const u16) f32 { - var s: f32 = 0; - for (b) |y| { - const f: f32 = @bitCast(@as(u32, y) << 16); - s += f * f; - } - return @sqrt(s); -} - -test "a neuron fires on its fact's rows and stays at zero on the rest; fitted again, it goes quiet on a new fact's" { - const gpa = std.testing.allocator; - const d = 64; - var prng = std.Random.DefaultPrng.init(9); - const r = prng.random(); - // a shared offset every row has (as hidden states do), and a direction each fact's rows lean along - var common: [d]f32 = undefined; - var fact_dir: [d]f32 = undefined; - var new_dir: [d]f32 = undefined; - for (&common, &fact_dir, &new_dir) |*c, *f, *g| { - c.* = 1 + r.floatNorm(f32) * 0.1; - f.* = r.floatNorm(f32); - g.* = r.floatNorm(f32); - } - const n_fact = 12; - const n_rest = 200; - const n_new = 12; - const rows = try gpa.alloc(u16, (n_fact + n_rest + n_new) * d); - defer gpa.free(rows); - for (0..n_fact + n_rest + n_new) |i| { - const lean: ?*const [d]f32 = if (i < n_fact) &fact_dir else if (i >= n_fact + n_rest) &new_dir else null; - for (0..d) |k| { - var v = common[k] + r.floatNorm(f32) * 0.5; - if (lean) |dir| v += 1.5 * dir[k]; - rows[i * d + k] = @truncate(@as(u32, @bitCast(v)) >> 16); - } - } - const xs = try gpa.alloc([]const u16, n_fact + n_rest); - defer gpa.free(xs); - const kinds = try gpa.alloc(Kind, n_fact + n_rest); - defer gpa.free(kinds); - for (xs, kinds, 0..) |*x, *k, i| { - x.* = rows[i * d ..][0..d]; - k.* = if (i < n_fact) .fact else .other; - } - var u: [d]f32 = undefined; - const first = try fit(gpa, xs, kinds, d, &u, false, fit_steps, 0); - try std.testing.expectEqual(@as(f32, 1), first.fact_on); - try std.testing.expectEqual(@as(usize, 0), first.fires); - // the new fact's rows, which nothing told it about, are where it is fitted again to stay quiet - const all = try gpa.alloc([]const u16, n_fact + n_rest + n_new); - defer gpa.free(all); - const kinds2 = try gpa.alloc(Kind, n_fact + n_rest + n_new); - defer gpa.free(kinds2); - for (all, kinds2, 0..) |*x, *k, i| { - x.* = rows[i * d ..][0..d]; - k.* = if (i < n_fact) .fact else if (i < n_fact + n_rest) .other else .steady; - } - const before = try gpa.dupe(f32, &u); - defer gpa.free(before); - const again = try fit(gpa, all, kinds2, d, &u, true, fit_steps / 2, n_fact); - try std.testing.expectEqual(@as(f32, 1), again.fact_on); - try std.testing.expectEqual(@as(usize, 0), again.fires); - try std.testing.expect(again.steady_most <= 0); - // its own rows were held fixed: each reads as it did before the refit - for (all[0..n_fact]) |x| try std.testing.expectApproxEqAbs(dotBf16(before, x), dotBf16(&u, x), 1e-3); -} diff --git a/zig/src/families/nemotron/pocket_forget.zig b/zig/src/families/nemotron/pocket_forget.zig deleted file mode 100644 index 014a0b571ae..00000000000 --- a/zig/src/families/nemotron/pocket_forget.zig +++ /dev/null @@ -1,158 +0,0 @@ -//! A fact deleted on request: its neurons' inputs zeroed, their layers rounded as a save writes them, kept to put back. -const std = @import("std"); -const pocket = @import("pocket.zig"); - -/// What the last delete changed, bit for bit as it was: whole layers' neurons and counts, every neuron's record. -pub const Kept = struct { - held: bool = false, // a delete not yet written by a save nor put back - stale: bool = false, // put back in memory, but a layer's upload failed: kept until the device takes them all - slots: std.ArrayList(usize) = .empty, // the pocket slots it changed - up: std.ArrayList(f32) = .empty, // [slots, neurons, D]: their input weights before - down: std.ArrayList(f32) = .empty, // [slots, neurons, D]: their outputs before - used: std.ArrayList(usize) = .empty, // [slots]: their counts before - learned: std.ArrayList(pocket.Learned) = .empty, // the session's neuron records before - learned_before: usize = 0, - marks: usize = 0, // retired lessons before - - pub fn deinit(k: *Kept, gpa: std.mem.Allocator) void { - inline for (.{ "slots", "up", "down", "used", "learned" }) |f| @field(k, f).deinit(gpa); - } - - fn clear(k: *Kept) void { - inline for (.{ "slots", "up", "down", "used", "learned" }) |f| @field(k, f).clearRetainingCapacity(); - k.held = false; - k.stale = false; - } -}; - -/// Whether a delete waits to be written: a save then writes the pocket even when nothing is left in it. -pub fn pending(p: anytype) bool { - return p.forgot.held; -} - -/// Whether a put-back is in memory but not yet on the device: replies are refused until `unforget` lands it. -pub fn stale(p: anytype) bool { - return p.forgot.stale; -} - -/// The last delete written into the shards: nothing is left to put back. -pub fn settle(p: anytype) void { - p.forgot.clear(); -} - -/// Neurons `gone` names that hold anything silenced, their layers rounded, freed at the top; how many held anything. -pub fn forget(p: anytype, t: anytype, host: anytype, gone: []const [2]u16) !usize { - try p.load(t, host); - const d = t.config().hidden; - const n = pocket.neurons * d; - const k = &p.forgot; - // a put-back the device has not taken yet is never dropped for a new delete - if (k.stale) return error.PutBackNotOnDevice; - k.clear(); - var held: usize = 0; - for (gone) |g| { - const slot = std.mem.indexOfScalar(usize, p.moe.items, g[0]) orelse continue; - if (g[1] >= p.used.items[slot] or std.mem.allEqual(f32, p.neuron(p.up.items, slot, g[1], d), 0)) continue; - held += 1; - if (std.mem.indexOfScalar(usize, k.slots.items, slot) == null) try k.slots.append(p.gpa, slot); - } - // a replaced fact's neurons are zero already: nothing changes, nothing is kept - if (held == 0) return 0; - for (k.slots.items) |slot| { - try k.up.appendSlice(p.gpa, p.up.items[slot * n ..][0..n]); - try k.down.appendSlice(p.gpa, p.down.items[slot * n ..][0..n]); - try k.used.append(p.gpa, p.used.items[slot]); - } - try k.learned.appendSlice(p.gpa, p.learned.items); - // everything that can fail before the pocket moves is done here; anything that fails after puts it all back - try p.retired_lessons.ensureUnusedCapacity(p.gpa, p.learned.items.len); // a lesson at most for each record - k.learned_before = p.learned_before; - k.marks = p.retired_lessons.items.len; - k.held = true; - cut(p, t, host, gone) catch |e| { - // put back whole; if the device cannot take it, that is the failure to report, the snapshot kept - _ = unforget(p, t, host) catch |back| { - std.log.warn("slide pocket: a delete failed ({t}), and its put-back did not reach the device ({t})", .{ e, back }); - return back; - }; - return e; - }; - std.log.info("slide pocket: {d} neurons of a deleted fact zeroed in {d} layers", .{ held, k.slots.items.len }); - return held; -} - -/// The cut itself, after the snapshot: input weights zeroed, records out, layers rounded, freed and uploaded. -fn cut(p: anytype, t: anytype, host: anytype, gone: []const [2]u16) !void { - const d = t.config().hidden; - const n = pocket.neurons * d; - const k = &p.forgot; - for (gone) |g| { - const slot = std.mem.indexOfScalar(usize, p.moe.items, g[0]) orelse continue; - if (g[1] >= p.used.items[slot]) continue; - // its input weights zeroed, so it never fires; its output stays, so the 4-bit groups it shares keep every bit - @memset(p.neuron(p.up.items, slot, g[1], d), 0); - // its record goes, so no later fact on the neuron is refitted as this one; its lesson's answers retire - var i: usize = 0; - while (i < p.learned.items.len) { - const e = p.learned.items[i]; - if (e.slot != slot or e.neuron != g[1]) { - i += 1; - continue; - } - if (std.mem.indexOfScalar(u32, p.retired_lessons.items, e.lesson) == null) p.retired_lessons.appendAssumeCapacity(e.lesson); - _ = p.learned.orderedRemove(i); - if (i < p.learned_before) p.learned_before -= 1; - } - } - for (k.slots.items) |slot| { - // the layer as its next save writes it, so the checks after this read what the shards will hold - try host.pocketRound(p.up.items[slot * n ..][0..n], p.down.items[slot * n ..][0..n]); - try settled(p.gpa, host, p.up.items[slot * n ..][0..n], p.down.items[slot * n ..][0..n]); - // neurons at the top whose input weights are zero are free; one below a kept neuron stays taken - while (p.used.items[slot] > 0 and std.mem.allEqual(f32, p.neuron(p.up.items, slot, p.used.items[slot] - 1, d), 0)) p.used.items[slot] -= 1; - try p.upload(t, host, slot); - } -} - -/// A rounded layer that a save would round to the same bits, else error.LayerRoundsAgain, so the delete is put back. -fn settled(gpa: std.mem.Allocator, host: anytype, up: []const f32, down: []const f32) !void { - const again = try gpa.alloc(f32, up.len + down.len); - defer gpa.free(again); - @memcpy(again[0..up.len], up); - @memcpy(again[up.len..], down); - try host.pocketRound(again[0..up.len], again[up.len..]); - const same = std.mem.eql(u8, std.mem.sliceAsBytes(again[0..up.len]), std.mem.sliceAsBytes(up)) and std.mem.eql(u8, std.mem.sliceAsBytes(again[up.len..]), std.mem.sliceAsBytes(down)); - if (!same) return error.LayerRoundsAgain; -} - -/// The last delete undone bit for bit; a layer the device does not take keeps the snapshot, and a call again retries. -pub fn unforget(p: anytype, t: anytype, host: anytype) !usize { - const k = &p.forgot; - if (!k.held) return 0; - try p.load(t, host); - try p.learned.ensureTotalCapacity(p.gpa, k.learned.items.len); - // the pocket whole as it was before any layer goes to the forward, so a failed upload leaves no layer half put back - const n = pocket.neurons * t.config().hidden; - for (k.slots.items, 0..) |slot, j| { - @memcpy(p.up.items[slot * n ..][0..n], k.up.items[j * n ..][0..n]); - @memcpy(p.down.items[slot * n ..][0..n], k.down.items[j * n ..][0..n]); - p.used.items[slot] = k.used.items[j]; - } - p.learned.clearRetainingCapacity(); - p.learned.appendSliceAssumeCapacity(k.learned.items); - p.learned_before = k.learned_before; - p.retired_lessons.shrinkRetainingCapacity(k.marks); - const back = k.slots.items.len; - var failed: ?anyerror = null; - for (k.slots.items) |slot| p.upload(t, host, slot) catch |e| { - failed = failed orelse e; - }; - if (failed) |e| { - k.stale = true; - std.log.warn("slide pocket: a deleted fact's {d} layers are put back in memory, but not all on the device ({t}): replies are refused until they are", .{ back, e }); - return error.PutBackNotOnDevice; - } - k.clear(); - std.log.info("slide pocket: a deleted fact's {d} layers put back as they were", .{back}); - return back; -} diff --git a/zig/src/families/nemotron/pocket_forget_test.zig b/zig/src/families/nemotron/pocket_forget_test.zig deleted file mode 100644 index 5500a6ef658..00000000000 --- a/zig/src/families/nemotron/pocket_forget_test.zig +++ /dev/null @@ -1,464 +0,0 @@ -//! A delete on a pocket of three facts: their neurons zeroed and rounded, freed at the top, put back bit for bit. -const std = @import("std"); -const cfg = @import("config.zig"); -const pocket = @import("pocket.zig"); -const forgetting = @import("pocket_forget.zig"); -const whole = @import("whole.zig"); -const examples = @import("lesson_examples.zig"); -const Shards = @import("pocket_shards.zig").Io(struct { - pub const shard_edit = @import("../../core/shard_edit.zig"); - pub const safetensors = @import("../../core/safetensors.zig"); - pub const affine4_host = @import("../../core/affine4_host.zig"); -}); - -const d = 64; -const layers = 4; // every MoE layer but the last holds a pocket: slots 0, 1 and 2 -const width = pocket.neurons * d; - -/// The trainer as the pocket reads it: only the model's shape. -const Trainer = struct { - c: cfg.Config, - - pub fn config(t: *const Trainer) cfg.Config { - return t.c; - } -}; - -const P = pocket.Pocket(Trainer); - -/// The backend: the pocket as the shards loaded it, and each layer's live copy as the forward reads it. -const Device = struct { - loaded_up: [layers][width]f32 = @splat(@splat(0)), - loaded_down: [layers][width]f32 = @splat(@splat(0)), - loaded_used: [layers]usize = @splat(0), - up: [layers][width]f32 = @splat(@splat(0)), - down: [layers][width]f32 = @splat(@splat(0)), - used: [layers]usize = @splat(0), - uploads: usize = 0, - saves: usize = 0, - gpa: std.mem.Allocator = std.testing.allocator, // what rounding allocates from - fail_at: usize = 0, // the upload, counted from one, that fails once (0: none) - fail_from: usize = 0, // the upload, counted from one, from which every upload fails (0: none) - failing: bool = false, // every upload fails - - pub fn pocketRead(h: *Device, l: usize, up: []f32, down: []f32) usize { - @memcpy(up, &h.loaded_up[l]); - @memcpy(down, &h.loaded_down[l]); - h.up[l] = h.loaded_up[l]; - h.down[l] = h.loaded_down[l]; - h.used[l] = h.loaded_used[l]; - return h.loaded_used[l]; - } - - pub fn pocket(h: *Device, l: usize, up: []const f32, down: []const f32, used: usize) !void { - if (h.failing or h.uploads + 1 == h.fail_at or (h.fail_from > 0 and h.uploads + 1 >= h.fail_from)) { - h.uploads += 1; - return error.UploadFailed; - } - @memcpy(&h.up[l], up); - @memcpy(&h.down[l], down); - h.used[l] = used; - h.uploads += 1; - } - - pub fn pocketRound(h: *Device, up: []f32, down: []f32) !void { - return Shards.round(h.gpa, d, up, down); - } -}; - -/// The learner's host as a save reaches it: `Device` above, and a write into the shards that counts itself. -const SaveHost = struct { - pub const Ctx = *Device; - - pub fn seconds(_: std.Io) f64 { - return 0; - } - - pub fn pocket(h: Ctx, l: usize, up: []const f32, down: []const f32, used: usize) !void { - return h.pocket(l, up, down, used); - } - - pub fn pocketRead(h: Ctx, l: usize, up: []f32, down: []f32) usize { - return h.pocketRead(l, up, down); - } - - pub fn pocketSave(h: Ctx, _: std.mem.Allocator, _: std.Io, _: []const usize, _: usize, _: []f32, _: []f32) !usize { - h.saves += 1; - return 0; - } -}; - -/// The learner as `whole.save` reads it: a pocket lesson kept, and its pocket. -const Learner = struct { - pub const Host = SaveHost; - method: whole.Method = .pocket, - pocketed: bool = false, - kept_rounds: u32 = 1, - pockets: P = .{ .gpa = std.testing.allocator, .mode = .auto }, - trainer: ?*Trainer, - b: *Device, - gpa: std.mem.Allocator = std.testing.allocator, - io: std.Io = std.testing.io, - owned: examples.Lesson = .{}, - - pub fn recalls(_: *Learner, _: []const examples.Example, _: bool) !bool { - return true; - } -}; - -/// Three facts as saved: A at (0, 0) and (1, 0); B at (0, 1) and (2, 0); C at (0, 2) and (1, 1), lessons 0, 1, 2. -fn three(h: *Device, p: *P, t: *Trainer) !void { - var prng = std.Random.DefaultPrng.init(11); - const r = prng.random(); - const held = [_][3]usize{ .{ 0, 0, 0 }, .{ 1, 0, 0 }, .{ 0, 1, 1 }, .{ 2, 0, 1 }, .{ 0, 2, 2 }, .{ 1, 1, 2 } }; - for (held) |x| { - for (h.loaded_up[x[0]][x[1] * d ..][0..d], h.loaded_down[x[0]][x[1] * d ..][0..d]) |*u, *v| { - u.* = r.floatNorm(f32) * 0.05; - v.* = r.floatNorm(f32) * 0.2; - } - h.loaded_used[x[0]] = @max(h.loaded_used[x[0]], x[1] + 1); - } - // the shards hold 4-bit values: the pocket as a save left it - for (0..layers) |l| try Shards.round(std.testing.allocator, d, &h.loaded_up[l], &h.loaded_down[l]); - try p.load(t, h); - for (held, 0..) |x, i| try p.learned.append(p.gpa, .{ .slot = x[0], .neuron = x[1], .key = .reply, .start = i, .count = 1, .subject = 0, .lesson = @intCast(x[2]) }); - p.learned_before = 4; // C, the last lesson, found A's and B's -} - -fn trainer() Trainer { - var c: cfg.Config = .{ .hidden = d, .vocab = 16, .layers = layers, .mamba_heads = 1, .mamba_head_dim = 1, .groups = 1, .state = 1, .conv_kernel = 4, .heads = 1, .kv_heads = 1, .head_dim = 1, .experts = 1, .top_k = 1, .expert_width = 64, .shared_width = 64, .routed_scaling = 1, .eps = 1e-5 }; - for (0..layers) |l| c.kinds[l] = .moe; - return .{ .c = c }; -} - -const b_neurons = [_][2]u16{ .{ 0, 1 }, .{ 2, 0 } }; - -test "a deleted fact's input weights go to zero, every output bit stays, its layers rounded as a save writes them" { - var t = trainer(); - var h: Device = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(&h, &p, &t); - // a lesson since the last save moved C's outputs in layer 0 off the 4-bit grid - for (p.neuron(p.down.items, 0, 2, d)) |*v| v.* *= 1.001; - const before_up = try std.testing.allocator.dupe(f32, p.up.items); - defer std.testing.allocator.free(before_up); - // what layer 0 is to hold: B's input weights zeroed, then the layer rounded on its own - var want_up: [width]f32 = p.up.items[0..width].*; - var want_down: [width]f32 = p.down.items[0..width].*; - @memset(want_up[1 * d ..][0..d], 0); - try Shards.round(std.testing.allocator, d, &want_up, &want_down); - try std.testing.expectEqual(@as(usize, 2), try forgetting.forget(&p, &t, &h, &b_neurons)); - try std.testing.expect(forgetting.pending(&p)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&want_up), std.mem.sliceAsBytes(p.up.items[0..width])); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&want_down), std.mem.sliceAsBytes(p.down.items[0..width])); - try std.testing.expect(std.mem.allEqual(f32, p.neuron(p.up.items, 2, 0, d), 0)); - // layer 2 as saved: B's input weights zero, every output bit as it was, B's own too, so no 4-bit group moves - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&h.loaded_down[2]), std.mem.sliceAsBytes(p.down.items[2 * width ..][0..width])); - // A's and C's input weights keep every bit; layer 1 was not touched at all - for ([_][2]usize{ .{ 0, 0 }, .{ 0, 2 }, .{ 1, 0 }, .{ 1, 1 } }) |x| try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(before_up[(x[0] * pocket.neurons + x[1]) * d ..][0..d]), std.mem.sliceAsBytes(p.neuron(p.up.items, x[0], x[1], d))); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&h.loaded_down[1]), std.mem.sliceAsBytes(p.down.items[width..][0..width])); - // layer 0's neuron 1 sits below C's, so it stays taken; layer 2 is empty again - try std.testing.expectEqualSlices(usize, &.{ 3, 2, 0 }, p.used.items); - // the forward reads exactly the pocket, and only the two layers changed were sent - try std.testing.expectEqual(@as(usize, 2), h.uploads); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(p.down.items[0..width]), std.mem.sliceAsBytes(&h.down[0])); - try std.testing.expectEqual(@as(usize, 0), h.used[2]); - // B's records are gone, so no later fact on its freed neuron is refitted as B; its lesson's answers retire - try std.testing.expectEqual(@as(usize, 4), p.learned.items.len); - for (p.learned.items) |e| try std.testing.expect(e.lesson != 1); - try std.testing.expectEqual(@as(usize, 2), p.learned_before); - try std.testing.expectEqualSlices(u32, &.{1}, p.retired_lessons.items); - forgetting.settle(&p); - try std.testing.expect(!forgetting.pending(&p)); -} - -test "a delete put back restores every bit it changed, in the pocket and in the forward" { - var t = trainer(); - var h: Device = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(&h, &p, &t); - // C's outputs off the grid, as a lesson not yet saved leaves them: the delete's rounding moves them - for (p.neuron(p.down.items, 0, 2, d)) |*v| v.* *= 1.001; - try p.upload(&t, &h, 0); - const gpa = std.testing.allocator; - const up = try gpa.dupe(f32, p.up.items); - defer gpa.free(up); - const down = try gpa.dupe(f32, p.down.items); - defer gpa.free(down); - const used = try gpa.dupe(usize, p.used.items); - defer gpa.free(used); - const learned = try gpa.dupe(pocket.Learned, p.learned.items); - defer gpa.free(learned); - const live = h; - try std.testing.expectEqual(@as(usize, 2), try forgetting.forget(&p, &t, &h, &b_neurons)); - try std.testing.expectEqual(@as(usize, 2), try forgetting.unforget(&p, &t, &h)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(up), std.mem.sliceAsBytes(p.up.items)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(down), std.mem.sliceAsBytes(p.down.items)); - try std.testing.expectEqualSlices(usize, used, p.used.items); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(learned), std.mem.sliceAsBytes(p.learned.items)); - try std.testing.expectEqual(@as(usize, 4), p.learned_before); - try std.testing.expectEqual(@as(usize, 0), p.retired_lessons.items.len); - for (0..layers - 1) |l| { - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&live.up[l]), std.mem.sliceAsBytes(&h.up[l])); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&live.down[l]), std.mem.sliceAsBytes(&h.down[l])); - try std.testing.expectEqual(live.used[l], h.used[l]); - } - try std.testing.expect(!forgetting.pending(&p)); - // with nothing to put back, a second put-back changes nothing - const sent = h.uploads; - try std.testing.expectEqual(@as(usize, 0), try forgetting.unforget(&p, &t, &h)); - try std.testing.expectEqual(sent, h.uploads); - try std.testing.expectEqual(@as(usize, 6), p.learned.items.len); -} - -test "a replaced fact's neurons are zero already: nothing to delete, nothing changed or kept" { - var t = trainer(); - var h: Device = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(&h, &p, &t); - // a newer fact replaced A: its neurons zeroed where they sit, their places taken - try p.retire(&t, &h, &.{ .{ 0, 0 }, .{ 1, 0 } }); - const gpa = std.testing.allocator; - const up = try gpa.dupe(f32, p.up.items); - defer gpa.free(up); - const down = try gpa.dupe(f32, p.down.items); - defer gpa.free(down); - const sent = h.uploads; - try std.testing.expectEqual(@as(usize, 0), try forgetting.forget(&p, &t, &h, &.{ .{ 0, 0 }, .{ 1, 0 } })); - try std.testing.expect(!forgetting.pending(&p)); - try std.testing.expectEqual(sent, h.uploads); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(up), std.mem.sliceAsBytes(p.up.items)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(down), std.mem.sliceAsBytes(p.down.items)); - try std.testing.expectEqual(@as(usize, 6), p.learned.items.len); -} - -test "deleting every fact empties the pocket, and the delete still waits for a save to write it" { - var t = trainer(); - var h: Device = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(&h, &p, &t); - try std.testing.expectEqual(@as(usize, 6), try forgetting.forget(&p, &t, &h, &.{ .{ 0, 0 }, .{ 1, 0 }, .{ 0, 1 }, .{ 2, 0 }, .{ 0, 2 }, .{ 1, 1 } })); - try std.testing.expect(p.empty()); - try std.testing.expect(forgetting.pending(&p)); - for (0..layers - 1) |l| try std.testing.expect(std.mem.allEqual(f32, &h.up[l], 0)); - try std.testing.expectEqualSlices(u32, &.{ 0, 1, 2 }, p.retired_lessons.items); - try std.testing.expectEqual(@as(usize, 0), p.learned_before); -} - -test "a save after the last fact is deleted writes the emptied pocket; an untaught one stays unwritten" { - var t = trainer(); - var h: Device = .{}; - // a model never taught: nothing in the pocket, nothing written - var untaught: Learner = .{ .trainer = &t, .b = &h }; - defer untaught.pockets.deinit(); - try untaught.pockets.load(&t, &h); - try std.testing.expect(try whole.save(&untaught)); - try std.testing.expectEqual(@as(usize, 0), h.saves); - var l: Learner = .{ .trainer = &t, .b = &h }; - defer l.pockets.deinit(); - try three(&h, &l.pockets, &t); - _ = try forgetting.forget(&l.pockets, &t, &h, &.{ .{ 0, 0 }, .{ 1, 0 }, .{ 0, 1 }, .{ 2, 0 }, .{ 0, 2 }, .{ 1, 1 } }); - try std.testing.expect(try whole.save(&l)); - try std.testing.expectEqual(@as(usize, 1), h.saves); - try std.testing.expect(!forgetting.pending(&l.pockets)); -} - -/// The pocket's state a delete may change, copied: its weights, counts, records and retired lessons. -const Copy = struct { - up: []f32, - down: []f32, - used: []usize, - learned: []pocket.Learned, - learned_before: usize, - retired: []u32, - - fn of(p: *const P) !Copy { - const a = std.testing.allocator; - return .{ .up = try a.dupe(f32, p.up.items), .down = try a.dupe(f32, p.down.items), .used = try a.dupe(usize, p.used.items), .learned = try a.dupe(pocket.Learned, p.learned.items), .learned_before = p.learned_before, .retired = try a.dupe(u32, p.retired_lessons.items) }; - } - - fn expectSame(c: Copy, p: *const P) !void { - try c.expectFields(p); - try std.testing.expect(!forgetting.pending(p)); - } - - /// The pocket in memory as copied, its snapshot kept or not. - fn expectFields(c: Copy, p: *const P) !void { - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(c.up), std.mem.sliceAsBytes(p.up.items)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(c.down), std.mem.sliceAsBytes(p.down.items)); - try std.testing.expectEqualSlices(usize, c.used, p.used.items); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(c.learned), std.mem.sliceAsBytes(p.learned.items)); - try std.testing.expectEqual(c.learned_before, p.learned_before); - try std.testing.expectEqualSlices(u32, c.retired, p.retired_lessons.items); - } - - fn free(c: Copy) void { - const a = std.testing.allocator; - a.free(c.up); - a.free(c.down); - a.free(c.used); - a.free(c.learned); - a.free(c.retired); - } -}; - -/// The forward's layers as the device holds them, for the pocket's slots. -fn expectLive(before: *const Device, now: *const Device) !void { - for (0..layers - 1) |l| { - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&before.up[l]), std.mem.sliceAsBytes(&now.up[l])); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&before.down[l]), std.mem.sliceAsBytes(&now.down[l])); - try std.testing.expectEqual(before.used[l], now.used[l]); - } -} - -test "an allocation or an upload that fails anywhere in a delete leaves the pocket and the forward as they were" { - var t = trainer(); - // each allocation of the delete in turn fails (the pocket's and the rounding's), until it goes through - var failures: usize = 0; - while (true) : (failures += 1) { - var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{}); - const h = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(h); - h.* = .{ .gpa = failing.allocator() }; - var p: P = .{ .gpa = failing.allocator(), .mode = .auto }; - defer p.deinit(); - try three(h, &p, &t); - const before = try Copy.of(&p); - defer before.free(); - const live = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(live); - live.* = h.*; - failing.fail_index = failing.alloc_index + failures; - if (forgetting.forget(&p, &t, h, &b_neurons)) |n| { - try std.testing.expectEqual(@as(usize, 2), n); - break; - } else |e| try std.testing.expectEqual(error.OutOfMemory, e); - try before.expectSame(&p); - try expectLive(live, h); - } - try std.testing.expect(failures >= 5); - // an upload that fails once, at either changed layer: the pocket and the forward put back - for ([_]usize{ 1, 2 }) |at| { - const h = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(h); - h.* = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(h, &p, &t); - const before = try Copy.of(&p); - defer before.free(); - const live = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(live); - live.* = h.*; - h.fail_at = h.uploads + at; - try std.testing.expectError(error.UploadFailed, forgetting.forget(&p, &t, h, &b_neurons)); - try before.expectSame(&p); - try expectLive(live, h); - // and a retry goes through - try std.testing.expectEqual(@as(usize, 2), try forgetting.forget(&p, &t, h, &b_neurons)); - } - // a device that takes no upload: put back in memory, the snapshot kept and the pocket stale until one lands - const h = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(h); - h.* = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(h, &p, &t); - const before = try Copy.of(&p); - defer before.free(); - const live = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(live); - live.* = h.*; - h.failing = true; - try std.testing.expectError(error.PutBackNotOnDevice, forgetting.forget(&p, &t, h, &b_neurons)); - try before.expectFields(&p); - try std.testing.expect(forgetting.stale(&p) and forgetting.pending(&p)); - h.failing = false; - try std.testing.expectEqual(@as(usize, 2), try forgetting.unforget(&p, &t, h)); - try before.expectSame(&p); - try expectLive(live, h); -} - -test "a put-back the device stops taking after one layer is cut keeps its snapshot, refuses, and lands once it can" { - var t = trainer(); - const h = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(h); - h.* = .{}; - var l: Learner = .{ .trainer = &t, .b = h }; - defer l.pockets.deinit(); - try three(h, &l.pockets, &t); - const before = try Copy.of(&l.pockets); - defer before.free(); - const live = try std.testing.allocator.create(Device); - defer std.testing.allocator.destroy(live); - live.* = h.*; - // the first changed layer (0) takes its cut; from the second upload on, the device takes nothing, put-back too - h.fail_from = h.uploads + 2; - try std.testing.expectError(error.PutBackNotOnDevice, forgetting.forget(&l.pockets, &t, h, &b_neurons)); - // memory is as it was and the snapshot is kept, while the device still holds layer 0 cut and layer 2 as it was - try before.expectFields(&l.pockets); - try std.testing.expect(whole.stale(&l) and forgetting.pending(&l.pockets)); - try std.testing.expect(std.mem.allEqual(f32, h.up[0][1 * d ..][0..d], 0)); - try std.testing.expect(!std.mem.allEqual(f32, live.up[0][1 * d ..][0..d], 0)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&live.up[2]), std.mem.sliceAsBytes(&h.up[2])); - // until it lands, another delete is refused and a retry fails the same way, the snapshot kept - try std.testing.expectError(error.PutBackNotOnDevice, forgetting.forget(&l.pockets, &t, h, &b_neurons)); - try std.testing.expectError(error.PutBackNotOnDevice, whole.heal(&l)); - try std.testing.expect(whole.stale(&l)); - try before.expectFields(&l.pockets); - // the device takes uploads again: the retry lands every layer, and nothing is left to put back - h.fail_from = 0; - try whole.heal(&l); - try std.testing.expect(!whole.stale(&l)); - try before.expectSame(&l.pockets); - try expectLive(live, h); -} - -test "a delete whose cut layer would round to other values when saved is put back whole, nothing changed" { - var t = trainer(); - var h: Device = .{}; - var p: P = .{ .gpa = std.testing.allocator, .mode = .auto }; - defer p.deinit(); - try three(&h, &p, &t); - var prng = std.Random.DefaultPrng.init(3); - const r = prng.random(); - // slot 0's neurons far from zero next to their spread, until its cut layer would move when a save rounds it again - var cut_up: [width]f32 = undefined; - var cut_down: [width]f32 = undefined; - var moves = false; - for (0..20) |_| { - const spread = std.math.pow(f32, 10, -4 + 6 * r.float(f32)); - const offset = spread * 256 * r.float(f32) * @as(f32, if (r.boolean()) 1 else -1); - for (p.up.items[0..width], p.down.items[0..width]) |*u, *v| { - u.* = offset + spread * r.floatNorm(f32); - v.* = -offset + spread * r.floatNorm(f32); - } - @memcpy(&cut_up, p.up.items[0..width]); - @memcpy(&cut_down, p.down.items[0..width]); - @memset(cut_up[1 * d ..][0..d], 0); // B's neuron at slot 0 - try Shards.round(std.testing.allocator, d, &cut_up, &cut_down); - const once_up = cut_up; - const once_down = cut_down; - try Shards.round(std.testing.allocator, d, &cut_up, &cut_down); - moves = !std.mem.eql(u8, std.mem.sliceAsBytes(&once_up), std.mem.sliceAsBytes(&cut_up)) or !std.mem.eql(u8, std.mem.sliceAsBytes(&once_down), std.mem.sliceAsBytes(&cut_down)); - if (moves) break; - } - try std.testing.expect(moves); - try p.upload(&t, &h, 0); - const gpa = std.testing.allocator; - const up = try gpa.dupe(f32, p.up.items); - defer gpa.free(up); - const down = try gpa.dupe(f32, p.down.items); - defer gpa.free(down); - const live = h; - try std.testing.expectError(error.LayerRoundsAgain, forgetting.forget(&p, &t, &h, &b_neurons)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(up), std.mem.sliceAsBytes(p.up.items)); - try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(down), std.mem.sliceAsBytes(p.down.items)); - for (0..layers - 1) |l| try std.testing.expectEqualSlices(u8, std.mem.sliceAsBytes(&live.up[l]), std.mem.sliceAsBytes(&h.up[l])); - try std.testing.expect(!forgetting.pending(&p)); - try std.testing.expectEqual(@as(usize, 6), p.learned.items.len); -} diff --git a/zig/src/families/nemotron/pocket_joint.zig b/zig/src/families/nemotron/pocket_joint.zig deleted file mode 100644 index 6bbe409f9c2..00000000000 --- a/zig/src/families/nemotron/pocket_joint.zig +++ /dev/null @@ -1,46 +0,0 @@ -//! Earlier facts on the open fact's subject fitted with it: MEMIT-Merge's one value a subject, a fact at a time. -const std = @import("std"); - -/// The earlier subject neurons the open fact shares its subject with, their replayed answers, their outputs as now. -pub fn find(p: anytype, d: usize) !void { - p.joint.clearRetainingCapacity(); - p.joint_down.clearRetainingCapacity(); - p.joint_answers.clearRetainingCapacity(); - if (!p.joining or p.split[1] == 0 or p.subjects.items.len == 0) return; - var group: std.ArrayList(u32) = .empty; - defer group.deinit(p.gpa); - for (p.learned.items[0..p.learned_before]) |e| { - if (e.key != .subject or std.mem.indexOfScalar(u32, p.subjects.items, e.subject) == null) continue; - if (std.mem.indexOfScalar(u32, p.retired_lessons.items, e.lesson) != null) continue; - if (std.mem.indexOfScalar(u32, group.items, e.lesson) == null) try group.append(p.gpa, e.lesson); - } - const replay: []const @TypeOf(p.answered[0]) = if (p.steady.len > 2) p.steady[2] else &.{}; - for (replay, 0..) |ex, i| { - if (i >= p.replay_lessons.len or std.mem.indexOfScalar(u32, group.items, p.replay_lessons[i]) == null) continue; - if (p.keyRow(ex, .subject) != null) try p.joint_answers.append(p.gpa, ex); - } - // without their answers to hold them, earlier outputs would only bend to the new fact - if (p.joint_answers.items.len == 0) return; - for (p.learned.items[0..p.learned_before]) |e| if (e.key == .subject and std.mem.indexOfScalar(u32, group.items, e.lesson) != null) { - try p.joint.append(p.gpa, .{ .slot = e.slot, .neuron = e.neuron, .key = .subject }); - try p.joint_down.appendSlice(p.gpa, p.neuron(p.down.items, e.slot, e.neuron, d)); - }; - std.log.info("slide pocket: {d} neurons of {d} earlier facts on its subject fitted with it, on {d} of their answers", .{ p.joint.items.len, group.items.len, p.joint_answers.items.len }); -} - -/// Their outputs as the fit starts, after the open fact's (which start at zero). -pub fn seed(p: anytype, d: usize) void { - const k = p.taken.items.len; - @memcpy(p.v.adam.items[k * d ..][0 .. p.joint.items.len * d], p.joint_down.items); -} - -/// The earlier neurons as they were before the open fact fitted them (its lesson undone). -pub fn putBack(p: anytype, t: anytype, host: anytype, d: usize) !void { - for (p.joint.items, 0..) |x, j| { - @memcpy(p.neuron(p.down.items, x.slot, x.neuron, d), p.joint_down.items[j * d ..][0..d]); - try p.upload(t, host, x.slot); - } - p.joint.clearRetainingCapacity(); - p.joint_down.clearRetainingCapacity(); - p.joint_answers.clearRetainingCapacity(); -} diff --git a/zig/src/families/nemotron/pocket_pack.zig b/zig/src/families/nemotron/pocket_pack.zig deleted file mode 100644 index ebed647bb02..00000000000 --- a/zig/src/families/nemotron/pocket_pack.zig +++ /dev/null @@ -1,42 +0,0 @@ -//! The pocket's passes with their sequences side by side: as many as one pass of the trainer holds, run together. -const std = @import("std"); -const train_mode = @import("train_mode.zig"); -const lesson_route = @import("lesson_route.zig"); -const Example = @import("lesson_examples.zig").Example; - -pub const Seq = train_mode.Seq; -pub const Result = train_mode.Result; -const Mode = train_mode.Mode; - -/// How many of `seqs`, from the first, one pass of trainer t holds: as many as fit, at least one. -pub fn fits(t: anytype, seqs: []const Seq) usize { - if (!t.packs()) return @min(seqs.len, 1); - var rows: usize = 0; - var n: usize = 0; - while (n < seqs.len and n < t.spans.len) : (n += 1) { - rows += seqs[n].ids.len - 1 - seqs[n].skip; - if (rows > t.pack and n > 0) break; - } - return n; -} - -/// The sequence an example makes, its pocket unscaled and nothing nudged. -pub fn seq(ex: Example) Seq { - return .{ .ids = ex.ids, .start = ex.start, .decide = ex.decide }; -} - -/// The turn every pocket pass takes: lessons of the model itself, no router deciding. -pub const turn: lesson_route.Turn = .{ .decide = 0, .bits = lesson_route.Acting.empty, .whole = true }; - -/// Each of `xs` read in `mode` in as few passes as hold them, each one's result into `out`. -pub fn read(gpa: std.mem.Allocator, t: anytype, xs: []const Example, mode: Mode, out: []Result) !void { - const seqs = try gpa.alloc(Seq, xs.len); - defer gpa.free(seqs); - for (seqs, xs) |*s, ex| s.* = seq(ex); - var at: usize = 0; - while (at < seqs.len) { - const n = fits(t, seqs[at..]); - try t.pass(seqs[at..][0..n], mode, turn, out[at..][0..n]); - at += n; - } -} diff --git a/zig/src/families/nemotron/pocket_prefix.zig b/zig/src/families/nemotron/pocket_prefix.zig deleted file mode 100644 index ca854f38eee..00000000000 --- a/zig/src/families/nemotron/pocket_prefix.zig +++ /dev/null @@ -1,100 +0,0 @@ -//! A pocket fact's answers' prompts run once: their rows before any of its neurons fires never change while it learns. -const std = @import("std"); -const pack = @import("pocket_pack.zig"); -const train_mode = @import("train_mode.zig"); -const dotBf16 = @import("pocket_fit.zig").dotBf16; - -const Seq = train_mode.Seq; -const Span = train_mode.Span; - -const least = 16; // rows a prefix must hold to be worth a slot - -/// An answer's prefix: its rows before any open neuron fires (once a whole pass shows them), and its slot once drawn. -const Kept = struct { seen: bool = false, skip: usize = 0, slot: ?u32 = null }; - -/// The open fact's answers' prefixes (its own answers first, then those that are to stay). -pub const Prefixes = struct { - list: std.ArrayList(Kept) = .empty, - slots: u32 = 0, - skipped: usize = 0, // rows its steps did not run again - inputs: u64 = 0, // the pocket's input weights the prefixes were found under - - pub fn deinit(s: *Prefixes, gpa: std.mem.Allocator) void { - s.list.deinit(gpa); - } - - /// A fact's `n` answers begun, no prefix known. - pub fn begin(s: *Prefixes, gpa: std.mem.Allocator, n: usize) !void { - s.list.clearRetainingCapacity(); - try s.list.appendNTimes(gpa, .{}, n); - s.slots = 0; - s.skipped = 0; - s.inputs = 0; - } -}; - -/// A round of outputs begun: the prefixes found kept while the pocket's input weights are as they were found under. -pub fn round(p: anytype, s: *Prefixes) void { - var h = std.hash.Wyhash.init(0); - h.update(std.mem.sliceAsBytes(p.up.items)); - h.update(std.mem.sliceAsBytes(p.used.items)); - const now = h.final(); - if (now == s.inputs) return; - for (s.list.items) |*k| k.* = .{}; - s.slots = 0; - s.inputs = now; -} - -/// The slots freed with their states (a further round runs its answers' prefixes again from their next draw). -pub fn release(t: anytype, s: *Prefixes) !void { - try t.prefixSlots(0); - for (s.list.items) |*k| k.slot = null; - s.slots = 0; -} - -/// The drawn answers (`which`: their indexes) set to skip prefixes in slots; those shown but not yet kept primed first. -pub fn use(t: anytype, s: *Prefixes, seqs: []Seq, which: []const usize) !void { - if (!t.packs()) return; - var fresh: [32]Seq = undefined; - if (seqs.len > fresh.len) return error.BadPass; - var n: usize = 0; - for (seqs, which) |*q, w| { - const k = &s.list.items[w]; - if (k.slot == null and k.seen and k.skip >= least and s.slots < @TypeOf(t.prefixes).most) { - k.slot = s.slots; - s.slots += 1; - fresh[n] = .{ .ids = q.ids[0 .. k.skip + 1], .start = k.skip, .decide = k.skip - 1, .slot = k.slot.? }; - n += 1; - } - if (k.slot) |slot| { - q.skip = k.skip; - q.slot = slot; - s.skipped += k.skip; - } - } - if (n == 0) return; - try t.prefixSlots(s.slots); - var got: [32]train_mode.Result = undefined; - var at: usize = 0; - while (at < n) { - const m = pack.fits(t, fresh[at..n]); - try t.pass(fresh[at..][0..m], .prime, pack.turn, got[0..m]); - at += m; - } -} - -/// Answer `which` (`sq` at `sp`, run whole): its rows before an open neuron fires, its decision, answer and nudges. -pub fn learn(p: anytype, t: anytype, s: *Prefixes, sq: Seq, sp: Span, which: usize) void { - const k = &s.list.items[which]; - if (k.seen or sq.skip > 0) return; - k.seen = true; - const d = t.config().hidden; - var limit = @min(sq.decide, sq.start - 1); - for (sq.nudge.layers, sq.nudge.rows) |mask, row| if (mask != 0) { - limit = @min(limit, row); - }; - k.skip = rows: for (0..limit) |r| { - for (p.taken.items) |x| if (dotBf16(p.neuron(p.up.items, x.slot, x.neuron, d), t.normed(p.moe.items[x.slot], sp.row(r))) > 0) break :rows r; - for (p.joint.items) |x| if (dotBf16(p.neuron(p.up.items, x.slot, x.neuron, d), t.normed(p.moe.items[x.slot], sp.row(r))) > 0) break :rows r; - } else limit; -} diff --git a/zig/src/families/nemotron/probe.zig b/zig/src/families/nemotron/probe.zig deleted file mode 100644 index 1175275c7a6..00000000000 --- a/zig/src/families/nemotron/probe.zig +++ /dev/null @@ -1,186 +0,0 @@ -//! A measure, not a lesson: how far vectors fitted at one row of a few layers bring a fact's held-out answers back. -const std = @import("std"); -const examples = @import("lesson_examples.zig"); -const lesson_route = @import("lesson_route.zig"); -const subspace = @import("subspace.zig"); - -const Example = examples.Example; -const Acting = lesson_route.Acting; - -/// The row a setup's vectors go on: the reply's first (the assistant header) or the question's subject. -pub const Row = enum { decide, subject }; - -const steps = 30; // Adam steps a setup is fitted for -const reach: f32 = 0.05; // each step's size against the residual's -const decay: f32 = 0.05; // the vectors' squared size against the residual's, added to the loss -const furthest: f32 = 3; // a vector's size at most, against the residual's - -/// A probe over trainer T (Metal's: its residual and nudges). -pub fn Probe(comptime T: type) type { - return struct { - const Self = @This(); - const Setup = struct { row: Row, layers: u64 }; - - gpa: std.mem.Allocator, - answered: []const Example = &.{}, - held: []const Example = &.{}, - setups: std.ArrayList(Setup) = .empty, - setup: usize = 0, - round: usize = 0, - at: usize = 0, - judging: bool = false, - loss: f32 = 0, - first: f32 = 0, - final: f32 = 0, // the answers' loss at the last fitting round - back: usize = 0, // held-out answers that came back token for token - size: std.ArrayList(f32) = .empty, // [layers]: the row's mean residual length after each layer - state: std.ArrayList(f32) = .empty, // [4, layers, D]: the vectors, their Adam moments, a round's gradient - - pub fn init(gpa: std.mem.Allocator) Self { - return .{ .gpa = gpa }; - } - - pub fn deinit(p: *Self) void { - p.setups.deinit(p.gpa); - p.size.deinit(p.gpa); - p.state.deinit(p.gpa); - } - - /// A lesson's setups: the subject's row at MoE layers 13 to 25, then in windows of three MoE layers, two apart. - pub fn begin(p: *Self, t: *T, answered: []const Example, held: []const Example) !void { - const c = t.config(); - p.answered = answered; - p.held = held; - p.setups.clearRetainingCapacity(); - var moe: [64]usize = undefined; - var count_moe: usize = 0; - var mid: u64 = 0; - for (0..c.layers - 1) |l| if (c.kinds[l] == .moe) { - moe[count_moe] = l; - count_moe += 1; - if (l >= 13 and l <= 25) mid |= @as(u64, 1) << @intCast(l); - }; - try p.setups.append(p.gpa, .{ .row = .subject, .layers = mid }); - var w: usize = 0; - while (w + 3 <= count_moe) : (w += 2) { - var mask: u64 = 0; - for (moe[w..][0..3]) |l| mask |= @as(u64, 1) << @intCast(l); - try p.setups.append(p.gpa, .{ .row = .subject, .layers = mask }); - } - p.setup = 0; - try p.start(t); - } - - fn start(p: *Self, t: *T) !void { - const c = t.config(); - p.round = 0; - p.at = 0; - p.loss = 0; - p.judging = false; - p.back = 0; - p.size.clearRetainingCapacity(); - try p.size.appendNTimes(p.gpa, 0, c.layers); - p.state.clearRetainingCapacity(); - try p.state.appendNTimes(p.gpa, 0, 4 * c.layers * c.hidden); - } - - fn row(s: Setup, ex: Example) ?usize { - return switch (s.row) { - .decide => ex.decide, - .subject => if (ex.subject > 0 and ex.subject < ex.start) ex.subject else null, - }; - } - - /// One pass; true once every setup has been fitted and judged. - pub fn step(p: *Self, t: *T, acting: Acting) !bool { - if (p.setup == p.setups.items.len) return true; - const c = t.config(); - const d = c.hidden; - const n = c.layers * d; - const s = p.setups.items[p.setup]; - const vecs = p.state.items[0..n]; - const grad = p.state.items[3 * n ..][0..n]; - const list = if (p.judging) p.held else p.answered; - while (p.at < list.len) { - const ex = list[p.at]; - p.at += 1; - const r = row(s, ex) orelse continue; - t.nudge = .{ .layers = .{ s.layers, 0, 0 }, .rows = .{ r, 0, 0 } }; - @memcpy(t.delta.slice(f32, n), vecs); - const got = try t.step(ex.ids, ex.start, .target, .{ .decide = ex.decide, .bits = acting, .whole = true }); - p.loss += got.loss; - if (p.judging) { - p.back += @intFromBool(got.recalled); - return false; - } - for (0..c.layers) |l| if (s.layers >> @intCast(l) & 1 != 0) { - for (grad[l * d ..][0..d], t.push.slice(f32, n)[l * d ..][0..d]) |*g, x| g.* += x; - if (p.round == 0) p.size.items[l] += norm(t.residual(l + 1, r)); - }; - return false; - } - const used = count(s, list); - const mean = p.loss / @as(f32, @floatFromInt(@max(used, 1))); - p.loss = 0; - p.at = 0; - if (p.judging) { - var len: f32 = 0; - var layers: usize = 0; - for (0..c.layers) |l| if (s.layers >> @intCast(l) & 1 != 0) { - len += @sqrt(subspace.dot(vecs[l * d ..][0..d], vecs[l * d ..][0..d])) / p.size.items[l]; - layers += 1; - }; - const last = 63 - @clz(s.layers); - std.log.info("slide probe: the {t}'s row, {d} MoE layers from {d} to {d}: the answers' loss {d:.3} to {d:.3} in {d} steps, vectors {d:.2} of the residual each; held-out {d} of {d} come back, their loss {d:.3}", .{ s.row, layers, @ctz(s.layers), last, p.first, p.final, steps, len / @as(f32, @floatFromInt(@max(layers, 1))), p.back, used, mean }); - p.setup += 1; - if (p.setup < p.setups.items.len) try p.start(t); - return false; - } - if (p.round == 0) { - p.first = mean; - for (p.size.items) |*x| x.* /= @floatFromInt(@max(used, 1)); - } - p.round += 1; - p.final = mean; - if (p.round > steps) { - p.judging = true; - return false; - } - const m = p.state.items[n..][0..n]; - const v = p.state.items[2 * n ..][0..n]; - const tt: f32 = @floatFromInt(p.round); - for (0..c.layers) |l| if (s.layers >> @intCast(l) & 1 != 0) { - const size = p.size.items[l]; - const lr = reach * size / @sqrt(@as(f32, @floatFromInt(d))); - const x = vecs[l * d ..][0..d]; - for (x, m[l * d ..][0..d], v[l * d ..][0..d], grad[l * d ..][0..d]) |*xi, *mi, *vi, gi| { - const g = gi / @as(f32, @floatFromInt(@max(used, 1))) + 2 * decay * xi.* / (size * size); - mi.* = 0.9 * mi.* + 0.1 * g; - vi.* = 0.999 * vi.* + 0.001 * g * g; - xi.* -= lr * (mi.* / (1 - std.math.pow(f32, 0.9, tt))) / (@sqrt(vi.* / (1 - std.math.pow(f32, 0.999, tt))) + 1e-8); - } - const len = @sqrt(subspace.dot(x, x)); - if (len > furthest * size) for (x) |*xi| { - xi.* *= furthest * size / len; - }; - }; - @memset(grad, 0); - return false; - } - - fn count(s: Setup, list: []const Example) usize { - var k: usize = 0; - for (list) |ex| k += @intFromBool(row(s, ex) != null); - return k; - } - }; -} - -fn norm(b: []const u16) f32 { - var s: f32 = 0; - for (b) |x| { - const f: f32 = @bitCast(@as(u32, x) << 16); - s += f * f; - } - return @sqrt(s); -} diff --git a/zig/src/families/nemotron/router.zig b/zig/src/families/nemotron/router.zig deleted file mode 100644 index e221c50c6c1..00000000000 --- a/zig/src/families/nemotron/router.zig +++ /dev/null @@ -1,260 +0,0 @@ -//! A lesson's router: Fisher scores per layer, the best averaged; it acts past a bar read off left-out questions. -const std = @import("std"); -const shape = @import("learn_shape.zig"); -const subspace = @import("subspace.zig"); - -const n = shape.candidates; - -const ridge = 0.1; // of the scatter's mean diagonal: questions are few against 64 directions -const most_reads = 12; // layers a router averages: past the best dozen, weaker layers blur the fact's questions back in -const odd_share = 4; // one fact question in this many may word itself apart from the rest and go untaken - -pub const Fit = struct { - dir: []f32, // [layers, n]: each layer's direction, unit, in its candidates' terms - weight: []f32, // [layers]: each layer's share of the average over the other prompts' spread there (0: unread) - mean: []f32, // [layers]: the other prompts' mean score there - need: f32, // the average a reply's decision row must reach for the lesson to act on it - reads: u32, // layers with a share - fact_low: f32, // the average most fact questions left out of the fit reached (all but the oddest quarter) - fact_least: f32, // the lowest any of them reached - steady_high: f32, // the highest a steady prompt left out of the fit reached - - pub fn deinit(f: *Fit, gpa: std.mem.Allocator) void { - gpa.free(f.dir); - gpa.free(f.weight); - gpa.free(f.mean); - } - - /// Whether a fact question the fit never saw still scores above every steady prompt it never saw. - pub fn apart(f: *const Fit) bool { - return f.fact_low > f.steady_high; - } - - /// Router row `i` of `rows` (rows[l]: layer l's decision rows along its candidates) as the lesson scores it. - pub fn score(f: *const Fit, rows: []const []const f32, i: usize) f32 { - var s: f32 = 0; - for (rows, 0..) |r, l| { - if (f.weight[l] == 0) continue; - s += f.weight[l] * (subspace.dot(f.dir[l * n ..][0..n], r[i * n ..][0..n]) - f.mean[l]); - } - return s; - } -}; - -/// Sums over a set of rows, from which a mean and scatter come with any one row left out. -const Stats = struct { - count: f64 = 0, - sum: [n]f64 = @splat(0), - sq: [n * n]f64 = @splat(0), - - fn of(rows: []const f32) Stats { - var s: Stats = .{}; - for (0..rows.len / n) |r| s.add(rows[r * n ..][0..n], 1); - return s; - } - - fn add(s: *Stats, p: []const f32, w: f64) void { - s.count += w; - for (0..n) |i| { - s.sum[i] += w * p[i]; - for (0..n) |j| s.sq[i * n + j] += w * p[i] * p[j]; - } - } -}; - -/// Fisher's direction (unit) between two sets: (scatter + ridge)^-1 (mean difference). -fn fisher(pos: *const Stats, neg: *const Stats, out: []f32) !void { - var mean: [2][n]f64 = undefined; - const sets = [2]*const Stats{ pos, neg }; - var a: [n * n]f64 = @splat(0); - for (sets, 0..) |s, k| { - for (0..n) |i| mean[k][i] = s.sum[i] / s.count; - for (0..n) |i| for (0..n) |j| { - a[i * n + j] += s.sq[i * n + j] / s.count - mean[k][i] * mean[k][j]; - }; - } - var trace: f64 = 0; - for (0..n) |i| trace += a[i * n + i]; - for (0..n) |i| a[i * n + i] += ridge * trace / n + 1e-12; - var d: [n]f64 = undefined; - for (&d, mean[0], mean[1]) |*x, p, q| x.* = p - q; - try subspace.solve(&a, n, &d); - var size: f64 = 0; - for (d) |x| size += x * x; - for (out, d) |*o, x| o.* = @floatCast(x / @sqrt(@max(size, 1e-30))); -} - -/// One layer's direction from every row, and each row's score along the direction fitted without it. -fn layer(facts: []const f32, steady: []const f32, dir: []f32, fact_s: []f32, steady_s: []f32) !void { - const pos = Stats.of(facts); - const neg = Stats.of(steady); - try fisher(&pos, &neg, dir); - var d: [n]f32 = undefined; - for (fact_s, 0..) |*s, i| { - const p = facts[i * n ..][0..n]; - var less = pos; - less.add(p, -1); - try fisher(&less, &neg, &d); - s.* = subspace.dot(&d, p); - } - for (steady_s, 0..) |*s, j| { - const p = steady[j * n ..][0..n]; - var less = neg; - less.add(p, -1); - try fisher(&pos, &less, &d); - s.* = subspace.dot(&d, p); - } -} - -/// The steady rows' mean and spread of `s`, with row `skip` left out. -fn spread(s: []const f32, skip: ?usize) [2]f32 { - var sum: f64 = 0; - var sq: f64 = 0; - var count: f64 = 0; - for (s, 0..) |x, j| if (j != skip) { - sum += x; - sq += x * x; - count += 1; - }; - const m = sum / count; - return .{ @floatCast(m), @floatCast(@sqrt(@max(sq / count - m * m, 0)) + 1e-9) }; -} - -/// Each layer's share from fact scores `z` [layers, facts] less `skip`: top layers by median, above the steady mean. -fn shares(gpa: std.mem.Allocator, z: []const f32, layers: usize, nf: usize, skip: ?usize, out: []f32) !void { - const col = try gpa.alloc(f32, nf); - defer gpa.free(col); - const sep = try gpa.alloc(f32, layers); - defer gpa.free(sep); - for (0..layers) |l| { - var m: usize = 0; - for (0..nf) |i| if (i != skip) { - col[m] = z[l * nf + i]; - m += 1; - }; - std.mem.sort(f32, col[0..m], {}, std.sort.asc(f32)); - sep[l] = col[m / 2]; - } - const sorted = try gpa.dupe(f32, sep); - defer gpa.free(sorted); - std.mem.sort(f32, sorted, {}, std.sort.desc(f32)); - const bar = sorted[@min(most_reads, layers) - 1]; - var total: f32 = 0; - for (out, sep) |*w, x| { - w.* = if (x >= bar and x > 0) x else 0; - total += w.*; - } - for (out) |*w| w.* = if (total > 0) w.* / total else 0; -} - -/// The router from each layer's decision rows: facts[l] and steady[l] the same questions at every layer, [count, n]. -pub fn fit(gpa: std.mem.Allocator, facts: []const []const f32, steady: []const []const f32) !Fit { - const layers = facts.len; - const nf = facts[0].len / n; - const ns = steady[0].len / n; - if (nf < 2 or ns < 3) return error.TooFewQuestions; - const dir = try gpa.alloc(f32, layers * n); - errdefer gpa.free(dir); - const weight = try gpa.alloc(f32, layers); - errdefer gpa.free(weight); - const mean = try gpa.alloc(f32, layers); - errdefer gpa.free(mean); - const fact_s = try gpa.alloc(f32, layers * nf); - defer gpa.free(fact_s); - const steady_s = try gpa.alloc(f32, layers * ns); - defer gpa.free(steady_s); - const Share = struct { - fn run(from: usize, step: usize, ctx: anytype, out: *?anyerror) void { - var l = from; - while (l < ctx.layers) : (l += step) layer(ctx.facts[l], ctx.steady[l], ctx.dir[l * n ..][0..n], ctx.fact_s[l * ctx.nf ..][0..ctx.nf], ctx.steady_s[l * ctx.ns ..][0..ctx.ns]) catch |e| { - out.* = e; - }; - } - }; - const ctx = .{ .layers = layers, .facts = facts, .steady = steady, .dir = dir, .fact_s = fact_s, .steady_s = steady_s, .nf = nf, .ns = ns }; - var threads: [16]?std.Thread = @splat(null); - var errs: [16]?anyerror = @splat(null); - const k = @min(threads.len, layers); - for (threads[0..k], 0..) |*t, i| t.* = std.Thread.spawn(.{}, Share.run, .{ i, k, ctx, &errs[i] }) catch null; - for (threads[0..k], 0..) |t, i| if (t) |th| th.join() else Share.run(i, k, ctx, &errs[i]); - for (errs[0..k]) |e| if (e) |x| return x; - // every score standardised by the steady prompts' at its layer: a steady prompt's without its own - const z_fact = try gpa.alloc(f32, layers * nf); - defer gpa.free(z_fact); - const z_steady = try gpa.alloc(f32, layers * ns); - defer gpa.free(z_steady); - const spread_all = try gpa.alloc([2]f32, layers); - defer gpa.free(spread_all); - for (0..layers) |l| { - const s = steady_s[l * ns ..][0..ns]; - spread_all[l] = spread(s, null); - for (0..nf) |i| z_fact[l * nf + i] = (fact_s[l * nf + i] - spread_all[l][0]) / spread_all[l][1]; - for (0..ns) |j| { - const own = spread(s, j); - z_steady[l * ns + j] = (s[j] - own[0]) / own[1]; - } - } - // each left-out question's average over the layers chosen without it - const w = try gpa.alloc(f32, layers); - defer gpa.free(w); - const fact_avg = try gpa.alloc(f32, nf); - defer gpa.free(fact_avg); - for (fact_avg, 0..) |*avg, i| { - try shares(gpa, z_fact, layers, nf, i, w); - avg.* = 0; - for (0..layers) |l| avg.* += w[l] * z_fact[l * nf + i]; - } - try shares(gpa, z_fact, layers, nf, null, w); - var high: f32 = -std.math.inf(f32); - for (0..ns) |j| { - var avg: f32 = 0; - for (0..layers) |l| avg += w[l] * z_steady[l * ns + j]; - high = @max(high, avg); - } - std.mem.sort(f32, fact_avg, {}, std.sort.asc(f32)); - const low = fact_avg[nf / odd_share]; - var reads: u32 = 0; - for (0..layers) |l| { - weight[l] = w[l] / spread_all[l][1]; - mean[l] = spread_all[l][0]; - reads += @intFromBool(w[l] > 0); - } - // half way across the gap between left-out facts and steady prompts; on overlap, what most facts reach - const need = if (low > high) (low + high) / 2 else low; - return .{ .dir = dir, .weight = weight, .mean = mean, .need = need, .reads = reads, .fact_low = low, .fact_least = fact_avg[0], .steady_high = high }; -} - -test "a router clears questions it never saw about its fact, and steady prompts it never saw stay below it" { - const gpa = std.testing.allocator; - var prng = std.Random.DefaultPrng.init(11); - const r = prng.random(); - const layers = 6; - const nf = 8; - const ns = 60; - var facts: [layers][]f32 = undefined; - var steady: [layers][]f32 = undefined; - // facts share a direction the steady rows lack; every row then made unit - for (0..layers) |l| { - facts[l] = try gpa.alloc(f32, nf * n); - steady[l] = try gpa.alloc(f32, ns * n); - for (facts[l], 0..) |*x, i| x.* = r.floatNorm(f32) * 0.3 + @as(f32, if (i % n == l) 3 else 0); - for (steady[l]) |*x| x.* = r.floatNorm(f32) * 0.3; - for ([_][]f32{ facts[l], steady[l] }) |rows| for (0..rows.len / n) |q| { - const row = rows[q * n ..][0..n]; - const size = @sqrt(subspace.dot(row, row)); - for (row) |*x| x.* /= size; - }; - } - defer for (0..layers) |l| { - gpa.free(facts[l]); - gpa.free(steady[l]); - }; - var f = try fit(gpa, &facts, &steady); - defer f.deinit(gpa); - try std.testing.expect(f.apart()); - try std.testing.expect(f.need > f.steady_high and f.need < f.fact_low); - try std.testing.expectEqual(@as(u32, layers), f.reads); - // the fit's own rows: every fact above the bar, every steady prompt below it - for (0..nf) |i| try std.testing.expect(f.score(&facts, i) >= f.need); - for (0..ns) |j| try std.testing.expect(f.score(&steady, j) < f.need); -} diff --git a/zig/src/families/nemotron/subspace.zig b/zig/src/families/nemotron/subspace.zig deleted file mode 100644 index 4fe16eb109e..00000000000 --- a/zig/src/families/nemotron/subspace.zig +++ /dev/null @@ -1,216 +0,0 @@ -//! Small dense linear algebra for a lesson's directions: orthonormal rows, and where one set of rows outweighs another. -const std = @import("std"); - -const V = @Vector(8, f32); - -pub fn dot(x: []const f32, y: []const f32) f32 { - var acc: V = @splat(0); - var i: usize = 0; - while (i + 8 <= x.len) : (i += 8) acc += @as(V, x[i..][0..8].*) * @as(V, y[i..][0..8].*); - var s = @reduce(.Add, acc); - while (i < x.len) : (i += 1) s += x[i] * y[i]; - return s; -} - -/// y += c x. -pub fn axpy(y: []f32, c: f32, x: []const f32) void { - const cv: V = @splat(c); - var i: usize = 0; - while (i + 8 <= y.len) : (i += 8) y[i..][0..8].* = @as(V, y[i..][0..8].*) + cv * @as(V, x[i..][0..8].*); - while (i < y.len) : (i += 1) y[i] += c * x[i]; -} - -/// Rows of `m` made orthonormal in place, each against those before it twice over; a row that vanishes becomes zero. -pub fn orthonormal(m: []f32, rows: usize, len: usize) void { - for (0..rows) |j| { - const row = m[j * len ..][0..len]; - const size = @sqrt(dot(row, row)); - for (0..2) |_| for (0..j) |i| { - const prev = m[i * len ..][0..len]; - axpy(row, -dot(row, prev), prev); - }; - const left = @sqrt(dot(row, row)); - if (!(left > 1e-4 * size)) { - @memset(row, 0); - continue; - } - for (row) |*v| v.* /= left; - } -} - -/// Each row of `m` (rows x len) with its parts along the orthonormal rows of `basis` taken out, twice over. -pub fn remove(m: []f32, rows: usize, basis: []const f32, count: usize, len: usize) void { - for (0..rows) |q| { - const row = m[q * len ..][0..len]; - for (0..2) |_| for (0..count) |u| { - const dir = basis[u * len ..][0..len]; - axpy(row, -dot(row, dir), dir); - }; - } -} - -/// The k orthonormal directions (rows of out) where `more` (n x n) outweighs `less`: more v = mu (less + lambda) v. -pub fn outweigh(gpa: std.mem.Allocator, more: []const f64, less: []const f64, n: usize, k: usize, out: []f32) !void { - const l = try gpa.dupe(f64, less); - defer gpa.free(l); - var trace: f64 = 0; - for (0..n) |i| trace += l[i * n + i]; - const lambda = 1e-3 * trace / @as(f64, @floatFromInt(n)) + 1e-12; - for (0..n) |i| l[i * n + i] += lambda; - try cholesky(l, n); - const s = try gpa.alloc(f64, n * n); - defer gpa.free(s); - const t = try gpa.alloc(f64, n * n); - defer gpa.free(t); - @memcpy(t, more); - for (0..n) |col| lower(l, n, t, col); - for (0..n) |i| for (0..n) |j| { - s[i * n + j] = t[j * n + i]; - }; - for (0..n) |col| lower(l, n, s, col); - const vecs = try gpa.alloc(f64, n * n); - defer gpa.free(vecs); - jacobi(s, n, vecs); - const vals = try gpa.alloc(f64, n); - defer gpa.free(vals); - for (vals, 0..) |*v, i| v.* = s[i * n + i]; - const order = try gpa.alloc(usize, n); - defer gpa.free(order); - for (order, 0..) |*o, i| o.* = i; - std.mem.sort(usize, order, vals, struct { - fn bigger(v: []const f64, a: usize, b: usize) bool { - return v[a] > v[b]; - } - }.bigger); - const w = try gpa.alloc(f64, n); - defer gpa.free(w); - for (0..k) |q| { - for (w, 0..) |*x, i| x.* = vecs[i * n + order[q]]; - upper(l, n, w); - for (out[q * n ..][0..n], w) |*o, x| o.* = @floatCast(x); - } - orthonormal(out, k, n); -} - -/// x = a^-1 b for a symmetric positive definite a (n x n, overwritten by its Cholesky factor). -pub fn solve(a: []f64, n: usize, b: []f64) !void { - try cholesky(a, n); - solveFactored(a, n, b); -} - -/// x = a^-1 b given a's Cholesky factor (as `factor` leaves it). -pub fn solveFactored(l: []const f64, n: usize, b: []f64) void { - for (0..n) |i| { - var v = b[i]; - for (0..i) |k| v -= l[i * n + k] * b[k]; - b[i] = v / l[i * n + i]; - } - upper(l, n, b); -} - -/// a = L L^T in place, for solveFactored. -pub fn factor(a: []f64, n: usize) !void { - try cholesky(a, n); -} - -/// a = L L^T in place (L in the lower triangle, the upper zeroed); a must be symmetric positive definite. -fn cholesky(a: []f64, n: usize) !void { - for (0..n) |j| { - var d = a[j * n + j]; - for (0..j) |k| d -= a[j * n + k] * a[j * n + k]; - if (!(d > 0)) return error.NotPositiveDefinite; - const root = @sqrt(d); - a[j * n + j] = root; - for (j + 1..n) |i| { - var v = a[i * n + j]; - for (0..j) |k| v -= a[i * n + k] * a[j * n + k]; - a[i * n + j] = v / root; - } - for (j + 1..n) |k| a[j * n + k] = 0; - } -} - -/// Column `col` of m (n x n) replaced by L^-1 times it. -fn lower(l: []const f64, n: usize, m: []f64, col: usize) void { - for (0..n) |i| { - var v = m[i * n + col]; - for (0..i) |k| v -= l[i * n + k] * m[k * n + col]; - m[i * n + col] = v / l[i * n + i]; - } -} - -/// w replaced by L^-T w. -fn upper(l: []const f64, n: usize, w: []f64) void { - var i = n; - while (i > 0) { - i -= 1; - var v = w[i]; - for (i + 1..n) |k| v -= l[k * n + i] * w[k]; - w[i] = v / l[i * n + i]; - } -} - -/// A symmetric a (n x n) brought to its eigenvalues on the diagonal by Jacobi rotations; vecs' columns: eigenvectors. -fn jacobi(a: []f64, n: usize, vecs: []f64) void { - @memset(vecs, 0); - for (0..n) |i| vecs[i * n + i] = 1; - for (0..60) |_| { - var off: f64 = 0; - var all: f64 = 0; - for (0..n) |i| for (0..n) |j| { - all += a[i * n + j] * a[i * n + j]; - if (i != j) off += a[i * n + j] * a[i * n + j]; - }; - if (off <= 1e-24 * all) return; - for (0..n) |p| for (p + 1..n) |q| { - const apq = a[p * n + q]; - if (apq == 0) continue; - const theta = (a[q * n + q] - a[p * n + p]) / (2 * apq); - const t = std.math.sign(theta) / (@abs(theta) + @sqrt(theta * theta + 1)) + @as(f64, if (theta == 0) 1 else 0); - const c = 1 / @sqrt(t * t + 1); - const s = t * c; - for (0..n) |k| { - const akp = a[k * n + p]; - const akq = a[k * n + q]; - a[k * n + p] = c * akp - s * akq; - a[k * n + q] = s * akp + c * akq; - } - for (0..n) |k| { - const apk = a[p * n + k]; - const aqk = a[q * n + k]; - a[p * n + k] = c * apk - s * aqk; - a[q * n + k] = s * apk + c * aqk; - } - for (0..n) |k| { - const vkp = vecs[k * n + p]; - const vkq = vecs[k * n + q]; - vecs[k * n + p] = c * vkp - s * vkq; - vecs[k * n + q] = s * vkp + c * vkq; - } - }; - } -} - -test "orthonormal rows, and the direction one set of rows outweighs another along" { - const len = 64; - var avoid: [3 * len]f32 = undefined; - var seek: [2 * len]f32 = undefined; - var prng = std.Random.DefaultPrng.init(7); - for (&avoid) |*v| v.* = prng.random().float(f32) - 0.5; - for (&seek) |*v| v.* = prng.random().float(f32) - 0.5; - orthonormal(&avoid, 3, len); - remove(&seek, 2, &avoid, 3, len); - orthonormal(&seek, 2, len); - for (0..2) |q| { - const row = seek[q * len ..][0..len]; - try std.testing.expectApproxEqAbs(@as(f32, 1), dot(row, row), 1e-4); - for (0..3) |u| try std.testing.expectApproxEqAbs(@as(f32, 0), dot(row, avoid[u * len ..][0..len]), 1e-4); - } - // more is large on axis 0 and 1, less is large on axis 1: the best single direction is axis 0 - var more = [_]f64{ 4, 0, 0, 0, 4, 0, 0, 0, 1 }; - var less = [_]f64{ 1, 0, 0, 0, 9, 0, 0, 0, 1 }; - var out: [3]f32 = undefined; - try outweigh(std.testing.allocator, &more, &less, 3, 1, &out); - try std.testing.expectApproxEqAbs(@as(f32, 1), @abs(out[0]), 1e-4); - try std.testing.expectApproxEqAbs(@as(f32, 0), out[1], 1e-4); -} diff --git a/zig/src/families/nemotron/train_mode.zig b/zig/src/families/nemotron/train_mode.zig deleted file mode 100644 index d6b4a69dfc5..00000000000 --- a/zig/src/families/nemotron/train_mode.zig +++ /dev/null @@ -1,47 +0,0 @@ -//! What a training step does, for both backends' trainers. - -/// A step's loss, its gradient (and Adam: `learn`), inputs only (`reads`), or the gradient at a nudged row (`target`). -pub const Mode = enum { loss, grad, learn, avoid, seek, project, keys, target, prime }; - -/// Whether a step only reads the site inputs (sketches, projections or keys), with no loss. -pub fn reads(mode: Mode) bool { - return switch (mode) { - .avoid, .seek, .project, .keys, .prime => true, - else => false, - }; -} - -/// Where a `target` step nudges and reads the gradient: three rows, each after its mask's layers, row i's in third i. -pub const Nudge = struct { layers: [3]u64 = @splat(0), rows: [3]usize = @splat(0) }; - -/// The answer's mean loss, and whether each of its tokens was the likeliest at its row. -pub const Result = struct { loss: f32, recalled: bool }; - -/// A pass's sequence: tokens, answer start, decision row, pocket scale, nudges, and `skip` rows from prefix `slot`. -pub const Seq = struct { ids: []const u32, start: usize, decide: usize, scale: f32 = 1, nudge: Nudge = .{}, skip: usize = 0, slot: u32 = 0 }; - -/// Where each sequence of a pass sits: its first row, its rows (ids less the last and the skipped), its prefix. -pub const Span = struct { - at: usize, - rows: usize, - skip: usize = 0, - slot: u32 = 0, - - /// The pass's row holding the sequence's row r (r at least `skip`). - pub fn row(sp: Span, r: usize) usize { - return sp.at + r - sp.skip; - } -}; - -/// A sequence's rows that predict its answer: the first in the pass, where they sit among the head's rows, how many. -pub const Answer = struct { first: usize, at: usize, rows: usize }; - -/// Each sequence's answer rows, packed for the head (no other row's loss or gradient there is anything but zero). -pub fn answers(seqs: []const Seq, spans: []const Span, out: []Answer) usize { - var at: usize = 0; - for (seqs, spans, out) |sq, sp, *a| { - a.* = .{ .first = sp.row(sq.start - 1), .at = at, .rows = sq.ids.len - sq.start }; - at += a.rows; - } - return at; -} diff --git a/zig/src/families/qwen27/model.zig b/zig/src/families/qwen27/model.zig index 8db542a18e6..30ec2fd225b 100644 --- a/zig/src/families/qwen27/model.zig +++ b/zig/src/families/qwen27/model.zig @@ -80,7 +80,7 @@ pub const Model = struct { share_fits: ?*const fn (u64) bool, later: bool, ) !*Model { - if (platform.getenv("TF_PROMPT_ROWS")) |raw| { + if ((platform.environment.Process{}).get("TF_PROMPT_ROWS")) |raw| { const n = std.fmt.parseInt(u32, raw, 10) catch 0; if (n < 16 or n > 2048 or n % 16 != 0) { try platform.environment.check("TF_PROMPT_ROWS", raw); @@ -174,7 +174,7 @@ pub const Model = struct { m.share_pending = false; defer m.checkpoint.closeFiles(); const c = m.config; - const columns = try ane_policy.columns(if (platform.c.getenv("TF_ANE_COLUMNS")) |v| std.mem.span(v) else null); + const columns = try ane_policy.columns((platform.environment.Process{}).get("TF_ANE_COLUMNS")); // The share is a whole MLP's columns: a rank holds half of them, so tensor parallel keeps prompts on the GPU. const share = m.shard.ranks == 1 and ane_policy.requestedOnChip(columns, m.device.tensorUnits()) and !c.moe() and mtl.ane.available() and m.weights.uniformMlp(); if (m.shard.ranks != 1) std.log.info("qwen27: tensor parallel rank {d}/{d} runs prompts on the GPU alone", .{ m.shard.rank, m.shard.ranks }); @@ -226,7 +226,7 @@ pub const Model = struct { /// A prompt pass's requested rows, before the runner's frame and attention limits. pub fn promptRows(c: cfg.Config, generation: u32) u32 { - const value = if (std.c.getenv("TF_PROMPT_ROWS")) |v| std.mem.span(v) else null; + const value = (platform.environment.Process{}).get("TF_PROMPT_ROWS"); return @import("prompt_rows.zig").requested(generation, c.moe(), value); } diff --git a/zig/src/families/qwen3_5/backend.zig b/zig/src/families/qwen3_5/backend.zig index 1236bebc1ce..6ffe0fedd3c 100644 --- a/zig/src/families/qwen3_5/backend.zig +++ b/zig/src/families/qwen3_5/backend.zig @@ -253,4 +253,5 @@ pub const draw = draws.draw; test { _ = draws; + _ = @import("model.zig"); } diff --git a/zig/src/families/qwen3_5/model.zig b/zig/src/families/qwen3_5/model.zig index 4dee28f796a..2062429e32c 100644 --- a/zig/src/families/qwen3_5/model.zig +++ b/zig/src/families/qwen3_5/model.zig @@ -7,6 +7,11 @@ const shards = @import("../../core/checkpoint.zig"); const weights = @import("weights.zig"); const kernels = @import("kernels.zig"); +/// The language model's tensors pack into their own buffer, not the file span between them that holds the vision tower. +fn never(_: []const u8, _: usize) bool { + return false; +} + pub const Model = struct { gpa: std.mem.Allocator, device: mtl.Device, @@ -30,7 +35,7 @@ pub const Model = struct { errdefer m.checkpoint.deinit(); const files = try shards.shardFiles(gpa, io, dir); defer shards.freeShardFiles(gpa, files); - for (files) |path| try m.checkpoint.addFileSelected(m.device, path, "", "language_model."); + for (files) |path| try m.checkpoint.addFileSplit(m.device, path, "", "language_model.", never); m.weights = try weights.load(&m.checkpoint, config.tied); m.kernels = try kernels.load(m.device); return m; @@ -44,3 +49,36 @@ pub const Model = struct { m.gpa.destroy(m); } }; + +test "the language model's tensors are held without the vision tower stored between them" { + if (comptime !@hasDecl(mtl.Device, "init")) return error.SkipZigTest; + const device = mtl.Device.init() catch return error.SkipZigTest; + defer device.deinit(); + const gpa = std.testing.allocator; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + // the order a Qwen3.5 checkpoint stores: a language-model tensor, the vision tower, then the next one + const header = + \\{"language_model.a":{"dtype":"BF16","shape":[2],"data_offsets":[0,4]}, + \\ "vision_tower.x":{"dtype":"U8","shape":[4096],"data_offsets":[4,4100]}, + \\ "language_model.b":{"dtype":"BF16","shape":[3],"data_offsets":[4100,4106]}} + ; + var data: [8 + header.len + 4106]u8 = undefined; + std.mem.writeInt(u64, data[0..8], header.len, .little); + @memcpy(data[8..][0..header.len], header); + for (data[8 + header.len ..], 0..) |*b, i| b.* = @truncate(i); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "model.safetensors", .data = &data }); + const path = try std.fmt.allocPrintSentinel(gpa, ".zig-cache/tmp/{s}/model.safetensors", .{tmp.sub_path}, 0); + defer gpa.free(path); + var span = ckpt.Checkpoint.init(gpa); + defer span.deinit(); + try span.addFileSelected(device, path, "", "language_model."); + try std.testing.expectEqual(@as(usize, 4106), span.residentBytes()); + var packed_ = ckpt.Checkpoint.init(gpa); + defer packed_.deinit(); + try packed_.addFileSplit(device, path, "", "language_model.", never); + try std.testing.expectEqual(@as(usize, ckpt.alignment + 6), packed_.residentBytes()); + try std.testing.expect(!packed_.has("vision_tower.x")); + inline for (.{ "language_model.a", "language_model.b" }) |name| + try std.testing.expectEqualSlices(u16, (try span.get(name)).host(u16), (try packed_.get(name)).host(u16)); +} diff --git a/zig/src/main.zig b/zig/src/main.zig index c02baa6f216..8f81487374c 100644 --- a/zig/src/main.zig +++ b/zig/src/main.zig @@ -276,6 +276,7 @@ pub fn main(init: std.process.Init) !void { const arena = init.arena.allocator(); const argv = try init.minimal.args.toSlice(arena); if (cluster.cli.wants(@ptrCast(argv[1..]))) std.process.exit(try cluster.cli.main(init, argv[1..])); + if (cluster.validate.wants(@ptrCast(argv[1..]))) std.process.exit(try cluster.validate.main(init, argv[1..])); if (checkpoint_cli.wants(@ptrCast(argv[1..]))) std.process.exit(try checkpoint_cli.main(init, argv[1..])); const o = try parseArgs(arena, argv); cli_chunks = o.chunks; diff --git a/zig/src/native/cache_fit.zig b/zig/src/native/cache_fit.zig index ab80fd15f84..f4facf4a4e9 100644 --- a/zig/src/native/cache_fit.zig +++ b/zig/src/native/cache_fit.zig @@ -255,7 +255,8 @@ test "the OS readings: RAM and this process's footprint" { if (builtin.os.tag != .macos) return error.SkipZigTest; const r = ram() orelse return error.SkipZigTest; const p = footprint() orelse return error.SkipZigTest; - try std.testing.expect(r >= 8 * GiB and p > 0 and p < r); + // hw.memsize is bytes on every Mac; the 8 GiB floor held on the large hosts but not the arm64 runner. + try std.testing.expect(r >= GiB and p > 0 and p < r); } test "a host's memory counts keep the footprint, its measured peak and the limit apart" { diff --git a/zig/src/native/drama_host.zig b/zig/src/native/drama_host.zig index c290d17b55a..adf59bbc478 100644 --- a/zig/src/native/drama_host.zig +++ b/zig/src/native/drama_host.zig @@ -13,6 +13,7 @@ const Limit = if (is_cuda) @import("drama_limit.zig").Limit else struct { fn deinit(_: *@This()) void {} }; const Warm = if (is_cuda) struct {} else d3.residency.Warm; +const Voice = @import("drama_host_voice.zig").For(Host); const Session = struct { e: *d3.Engine, t: *d3.tts.Tts, @@ -67,6 +68,7 @@ const Host = struct { closing: bool = false, failed: completion.State = .{}, refs: Refs = .{}, + voices: @import("drama_host_voice.zig").Queue = .{}, const vtable: api.Engine.VTable = .{ .info = info, .submit = submitText, @@ -76,6 +78,7 @@ const Host = struct { .memory = memory, .keepalive = if (is_cuda) null else keepalive, .drain = drain, + .encode_voice = Voice.encode, }; fn self(p: *anyopaque) *Host { return @ptrCast(@alignCast(p)); @@ -164,6 +167,7 @@ const Host = struct { if (is_cuda) h.sessions[0].e.ctx.makeCurrent() catch { h.lock(); h.closing = true; + Voice.refuse(h); h.unlock(); while (true) { h.lock(); @@ -175,6 +179,7 @@ const Host = struct { }; while (true) { h.lock(); + if (Voice.step(h)) continue; const work = h.queue.next() orelse { if (h.closing or h.failed.closed) { h.unlock(); @@ -317,14 +322,7 @@ pub fn open(gpa: std.mem.Allocator, io: std.Io, dir: []const u8, _: []const u8, try o.silence.validate(); const h = try gpa.create(Host); errdefer gpa.destroy(h); - h.* = .{ - .gpa = gpa, - .io = io, - .limit = undefined, - .queue = try rounds.Queue.init(o.lanes), - .info_ = .{}, - .silence = o.silence, - }; + h.* = .{ .gpa = gpa, .io = io, .limit = undefined, .queue = try rounds.Queue.init(o.lanes), .info_ = .{}, .silence = o.silence }; if (is_cuda) h.refs = .{ .gpa = gpa, .capacity = o.reference_entries }; try h.limit.init(gpa, io, o.device); errdefer h.limit.deinit(); diff --git a/zig/src/native/drama_host_voice.zig b/zig/src/native/drama_host_voice.zig new file mode 100644 index 00000000000..dc6aaf49a54 --- /dev/null +++ b/zig/src/native/drama_host_voice.zig @@ -0,0 +1,87 @@ +//! A reference WAV file's codes for POST /v1/voices, encoded on the speech host's own thread by an idle lane's codec. +const std = @import("std"); +const api = @import("engine_api"); + +/// One waiting encode; the asking thread sleeps on `done` under the host's mutex. +const Ask = struct { + gpa: std.mem.Allocator, + wav: []const u8, + codes: [][10]i32 = &.{}, + err: ?api.EncodeVoiceError = null, + done: bool = false, + cond: std.Io.Condition = .init, +}; + +/// Asks waiting for the host thread: one at a time, in arrival order. +pub const Queue = struct { turn: std.Io.Mutex = .init, ask: ?*Ask = null }; + +/// Errors of the file itself: the request's to fix, so the engine stays open. +fn input(err: anyerror) bool { + for ([_]anyerror{ error.NotWav, error.BadWav, error.UnsupportedWav, error.BadReference, error.EmptyAudio }) |e| if (err == e) return true; + return false; +} + +pub fn For(comptime Host: type) type { + return struct { + /// The engine's encode_voice: hands the file to the host thread and waits for its codes. + pub fn encode(p: *anyopaque, gpa: std.mem.Allocator, wav: []const u8) api.EncodeVoiceError![][10]i32 { + const h: *Host = @ptrCast(@alignCast(p)); + h.voices.turn.lockUncancelable(h.io); + defer h.voices.turn.unlock(h.io); + var ask: Ask = .{ .gpa = gpa, .wav = wav }; + h.mutex.lockUncancelable(h.io); + defer h.mutex.unlock(h.io); + if (h.closing or h.failed.closed) return error.Closed; + h.voices.ask = &ask; + h.wake.signal(h.io); + while (!ask.done) ask.cond.waitUncancelable(h.io, &h.mutex); + return ask.err orelse ask.codes; + } + + /// On the host thread with its mutex held: runs a waiting encode on an idle lane; true: done, mutex released. + pub fn step(h: *Host) bool { + const ask = h.voices.ask orelse return false; + if (h.closing or h.failed.closed) { + refuse(h); + h.mutex.unlock(h.io); + return true; + } + const lane = for (h.jobs[0..h.queue.lanes], 0..) |job, i| { + if (job == null) break i; + } else return false; // every lane busy: the ask waits for one to finish + h.voices.ask = null; + h.mutex.unlock(h.io); + const t = h.sessions[lane].t; + const outcome: ?api.EncodeVoiceError = if (t.encodeWav(ask.wav)) |codes| copy: { + defer t.c.gpa.free(codes); + ask.codes = ask.gpa.dupe([10]i32, codes) catch break :copy error.OutOfMemory; + break :copy null; + } else |err| if (err == error.OutOfMemory) error.OutOfMemory else if (input(err)) error.BadWav else fail: { + std.log.warn("drama3: reference encode failed, closing the speech engine: {s}", .{@errorName(err)}); + break :fail error.Failed; + }; + h.mutex.lockUncancelable(h.io); + if (outcome) |e| if (e == error.Failed) { + h.failed.closed = true; // a device error: as in advance, the engine stops serving + }; + ask.err = outcome; + ask.done = true; + ask.cond.signal(h.io); + h.mutex.unlock(h.io); + return true; + } + + /// With the host's mutex held and the engine closing: a waiting encode gets Closed. + pub fn refuse(h: *Host) void { + const ask = h.voices.ask orelse return; + h.voices.ask = null; + ask.err = error.Closed; + ask.done = true; + ask.cond.signal(h.io); + } + }; +} + +test { + _ = @import("drama_host_voice_test.zig"); +} diff --git a/zig/src/native/drama_host_voice_test.zig b/zig/src/native/drama_host_voice_test.zig new file mode 100644 index 00000000000..2c6b3e6a1e0 --- /dev/null +++ b/zig/src/native/drama_host_voice_test.zig @@ -0,0 +1,109 @@ +//! The speech host's encode hand-off over a fake host: idle lanes answer, busy ones wait, a bad file keeps it open. +const std = @import("std"); +const Queue = @import("drama_host_voice.zig").Queue; +const t = std.testing; + +const Tts = struct { + c: struct { gpa: std.mem.Allocator } = .{ .gpa = t.allocator }, + fail: ?anyerror = null, + calls: usize = 0, + + pub fn encodeWav(tts: *Tts, wav: []const u8) ![][10]i32 { + tts.calls += 1; + if (tts.fail) |e| return switch (e) { + error.NotWav => error.NotWav, + error.UnsupportedWav => error.UnsupportedWav, + else => error.LaunchFailed, + }; + const codes = try tts.c.gpa.alloc([10]i32, wav.len); + for (codes, wav) |*row, byte| row.* = @splat(byte); + return codes; + } +}; + +const Host = struct { + io: std.Io = t.io, + mutex: std.Io.Mutex = .init, + wake: std.Io.Condition = .init, + closing: bool = false, + failed: struct { closed: bool = false } = .{}, + jobs: [2]?u8 = @splat(null), + queue: struct { lanes: usize = 2 } = .{}, + tts: [2]Tts = @splat(.{}), + sessions: [2]struct { t: *Tts } = undefined, + voices: Queue = .{}, + + fn lock(h: *Host) void { + h.mutex.lockUncancelable(h.io); + } + fn unlock(h: *Host) void { + h.mutex.unlock(h.io); + } +}; +const Voice = @import("drama_host_voice.zig").For(Host); + +const Asked = struct { + h: *Host, + out: @import("engine_api").EncodeVoiceError![][10]i32 = &.{}, + fn run(a: *Asked) void { + a.out = Voice.encode(a.h, t.allocator, "ab"); + } +}; + +/// One encode from another thread, answered by this one as the host loop would. +fn ask(h: *Host) ![][10]i32 { + var asked: Asked = .{ .h = h }; + const thread = try std.Thread.spawn(.{}, Asked.run, .{&asked}); + while (true) { + h.lock(); + if (h.voices.ask != null and Voice.step(h)) break; + h.unlock(); + std.Thread.yield() catch {}; + } + thread.join(); + return asked.out; +} + +test "drama voice encode: an idle lane answers; a bad file keeps the engine open, a device error closes it" { + var h: Host = .{}; + for (&h.sessions, &h.tts) |*s, *tts| s.* = .{ .t = tts }; + h.jobs[0] = 1; // lane 0 busy: lane 1 encodes + const codes = try ask(&h); + defer t.allocator.free(codes); + try t.expectEqualSlices([10]i32, &.{ @splat('a'), @splat('b') }, codes); + try t.expectEqual(@as(usize, 1), h.tts[1].calls); + h.tts[1].fail = error.NotWav; + try t.expectError(error.BadWav, ask(&h)); + h.tts[1].fail = error.UnsupportedWav; + try t.expectError(error.BadWav, ask(&h)); + try t.expect(!h.failed.closed); + h.tts[1].fail = error.LaunchFailed; + const level = t.log_level; + t.log_level = .err; // the closing warning is the expected outcome here + defer t.log_level = level; + try t.expectError(error.Failed, ask(&h)); + try t.expect(h.failed.closed); + try t.expectError(error.Closed, Voice.encode(&h, t.allocator, "ab")); + try t.expectEqual(@as(usize, 0), h.tts[0].calls); +} + +test "drama voice encode: every lane busy keeps the ask waiting; closing answers it" { + var h: Host = .{}; + for (&h.sessions, &h.tts) |*s, *tts| s.* = .{ .t = tts }; + h.jobs = .{ 1, 2 }; + var asked: Asked = .{ .h = &h }; + const thread = try std.Thread.spawn(.{}, Asked.run, .{&asked}); + while (true) { + h.lock(); + defer h.unlock(); + if (h.voices.ask != null) break; + } + h.lock(); + try t.expect(!Voice.step(&h)); // nothing ran: the mutex is still held + h.closing = true; + Voice.refuse(&h); + h.unlock(); + thread.join(); + try t.expectError(error.Closed, asked.out); + try t.expectEqual(@as(usize, 0), h.tts[0].calls + h.tts[1].calls); +} diff --git a/zig/src/platform/environment.zig b/zig/src/platform/environment.zig index 56a6426a21e..438892aa48c 100644 --- a/zig/src/platform/environment.zig +++ b/zig/src/platform/environment.zig @@ -3,7 +3,7 @@ const std = @import("std"); const sys = @import("sys.zig"); pub const Error = error{InvalidEnvironment}; -pub const Scope = enum { common, cuda, metal, xpu, slide, hooks, dsv41, gemma4, drama3, glm, flashnext }; +pub const Scope = enum { common, cuda, metal, xpu, slide, hooks, dsv41, gemma4, drama3, glm, flashnext, nemotron, minimax_m3 }; pub const Kind = enum { u32, u64, size, percent, positive, device, segments, mib, bit_width, word, prompt, flag, toggle, real, positive_real, signed_real, range, path }; pub const Rule = struct { name: [:0]const u8, @@ -211,6 +211,15 @@ pub const rules = [_]Rule{ .{ .name = "TF_FLASHNEXT_KV_PAGE_TEST", .scope = .flashnext, .kind = .size, .forms = "a page size the kernels take, whole blocks of the indexer's ratio up to the window (unset: off)" }, .{ .name = "TF_FLASHNEXT_CONFIDENCE", .scope = .flashnext, .kind = .signed_real, .forms = "a finite number (default -0.4)" }, .{ .name = "TF_FLASHNEXT_PROMPT", .scope = .flashnext, .kind = .word, .words = &.{"rows"}, .forms = "rows for the rows path (unset or blank keeps the plain path)" }, + // Family rank and prompt settings below are read through their own family's startup scope. + .{ .name = "TF_GLM_INDEX_CUDA", .scope = .glm, .kind = .word, .words = &.{ "1", "0", "scores" }, .forms = "1 (both kernels), 0 (neither) or scores (scores only; unset or blank is both)" }, + .{ .name = "TF_GLM_KV_HOST_GIB", .scope = .glm, .kind = .real, .forms = "a finite GiB amount of at least 0 (unset or blank uses one full window and 16 rows a page)" }, + .{ .name = "TF_GLM_RANK", .scope = .glm, .kind = .u64, .forms = "a whole rank index from 0 to 4294967295 (unset with TF_GLM_WORLD gives one rank)" }, + .{ .name = "TF_GLM_WORLD", .scope = .glm, .kind = .u64, .forms = "a whole rank count from 1 to 4294967295 (unset with TF_GLM_RANK gives one rank)" }, + .{ .name = "TF_NEMOTRON_RANK", .scope = .nemotron, .kind = .u64, .forms = "a whole rank index from 0 to 4294967295 (unset with TF_NEMOTRON_WORLD gives one rank)" }, + .{ .name = "TF_NEMOTRON_WORLD", .scope = .nemotron, .kind = .u64, .forms = "a whole rank count from 1 to 4294967295 (unset with TF_NEMOTRON_RANK gives one rank)" }, + .{ .name = "TF_MINIMAX_RANK", .scope = .minimax_m3, .kind = .u64, .forms = "a whole rank index, 0 or 1 at two ranks (unset with TF_MINIMAX_WORLD gives one rank)" }, + .{ .name = "TF_MINIMAX_WORLD", .scope = .minimax_m3, .kind = .u64, .forms = "a whole rank count, 2 on CUDA (unset with TF_MINIMAX_RANK gives one rank)" }, }; pub fn rule(name: []const u8) Rule { @@ -374,6 +383,8 @@ pub const Flags = struct { drama3: bool = false, glm: bool = false, flashnext: bool = false, + nemotron: bool = false, + minimax_m3: bool = false, device: ?u32 = null, segments: ?u32 = null, carveout: bool = false, @@ -391,6 +402,8 @@ pub const Flags = struct { .drama3 => f.drama3, .glm => f.glm, .flashnext => f.flashnext, + .nemotron => f.nemotron, + .minimax_m3 => f.minimax_m3, }; } }; diff --git a/zig/src/platform/environment_test.zig b/zig/src/platform/environment_test.zig index 16ac23c2e2a..de938481524 100644 --- a/zig/src/platform/environment_test.zig +++ b/zig/src/platform/environment_test.zig @@ -3,7 +3,7 @@ const std = @import("std"); const e = @import("environment.zig"); const t = std.testing; const a = t.allocator; -const all: e.Flags = .{ .cuda = true, .metal = true, .xpu = true, .slide = true, .hooks = true, .dsv41 = true, .gemma4 = true, .drama3 = true, .glm = true, .flashnext = true }; +const all: e.Flags = .{ .cuda = true, .metal = true, .xpu = true, .slide = true, .hooks = true, .dsv41 = true, .gemma4 = true, .drama3 = true, .glm = true, .flashnext = true, .nemotron = true, .minimax_m3 = true }; const Env = struct { name: []const u8, raw: ?[]const u8, @@ -131,6 +131,10 @@ const valid = [_]Case{ .{ .name = "TF_DSV41_ENGRAM_DIR", .raw = "engram-rows", .n = 0 }, .{ .name = "TF_DSV41_ENGRAM_VERIFY", .raw = "full", .n = 1 }, .{ .name = "TF_DSV41_ENGRAM_CACHE", .raw = "0", .n = 0 }, + .{ .name = "TF_NEMOTRON_RANK", .raw = "1", .n = 1 }, + .{ .name = "TF_NEMOTRON_WORLD", .raw = "2", .n = 2 }, + .{ .name = "TF_MINIMAX_RANK", .raw = "1", .n = 1 }, + .{ .name = "TF_MINIMAX_WORLD", .raw = "2", .n = 2 }, }; test "environment: valid forms remain raw numbers before existing consumer clamps and defaults" { diff --git a/zig/src/server/benchmark_server.zig b/zig/src/server/benchmark_server.zig index 8b1c6a31e06..035c5707a1c 100644 --- a/zig/src/server/benchmark_server.zig +++ b/zig/src/server/benchmark_server.zig @@ -46,10 +46,10 @@ pub fn argv(a: Allocator, plan: Plan) ![]const []const u8 { return out.items; } -/// The parent's variables without the API key, request log, seed salt and upload token; no live line or update check. +/// Parent variables minus the API key, request log, journal, seed salt and upload token; no live line or update check. pub fn environ(a: Allocator, parent: *const std.process.Environ.Map) !std.process.Environ.Map { var env = try parent.clone(a); - for ([_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_SEED_SALT", "TENSORFOLD_BENCHMARK_TOKEN" }) |k| _ = env.orderedRemove(k); + for ([_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_REQUEST_JOURNAL", "TENSORFOLD_SEED_SALT", "TENSORFOLD_BENCHMARK_TOKEN" }) |k| _ = env.orderedRemove(k); try env.put("TENSORFOLD_NO_LIVE", "1"); try env.put("TENSORFOLD_NO_UPDATE_CHECK", "1"); try env.put("HF_HUB_OFFLINE", "1"); diff --git a/zig/src/server/benchmark_server_test.zig b/zig/src/server/benchmark_server_test.zig index b1c12fc09b3..f10ff7f3bef 100644 --- a/zig/src/server/benchmark_server_test.zig +++ b/zig/src/server/benchmark_server_test.zig @@ -51,9 +51,9 @@ test "the child's environment drops the key, log, salt and token and turns off t defer arena.deinit(); const a = arena.allocator(); var parent: std.process.Environ.Map = .init(a); - for ([_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_SEED_SALT", "TENSORFOLD_BENCHMARK_TOKEN", "PATH" }) |k| try parent.put(k, "x"); + for ([_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_REQUEST_JOURNAL", "TENSORFOLD_SEED_SALT", "TENSORFOLD_BENCHMARK_TOKEN", "PATH" }) |k| try parent.put(k, "x"); const env = try server.environ(a, &parent); - for ([_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_SEED_SALT", "TENSORFOLD_BENCHMARK_TOKEN" }) |k| try std.testing.expect(env.get(k) == null); + for ([_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_REQUEST_JOURNAL", "TENSORFOLD_SEED_SALT", "TENSORFOLD_BENCHMARK_TOKEN" }) |k| try std.testing.expect(env.get(k) == null); for ([_][]const u8{ "TENSORFOLD_NO_LIVE", "TENSORFOLD_NO_UPDATE_CHECK", "HF_HUB_OFFLINE" }) |k| try std.testing.expectEqualStrings("1", env.get(k).?); try std.testing.expectEqualStrings("x", env.get("PATH").?); } diff --git a/zig/src/server/chat.zig b/zig/src/server/chat.zig index f8851faba6b..8a591e5ddf6 100644 --- a/zig/src/server/chat.zig +++ b/zig/src/server/chat.zig @@ -27,6 +27,7 @@ pub const Prompt = union(enum) { text: []const u8, ids: []const u32 }; pub const Input = struct { /// The client itself asked for thinking off (no server, template or route default counts): it must be honored. explicit_off: bool = false, + trace: ?*@import("request_trace.zig").Trace = null, // the request's journal records; null when the journal is off /// The server's own request (a compaction summary, a lesson's wordings): it never takes --instruct-sampling's set. own: bool = false, messages: Value = .{ .array = &.{} }, @@ -230,6 +231,7 @@ pub fn prepare(srv: *Server, cx: *Cx, input: Input, gone: anytype) Failure!Prepa request.logprobs = input.logprobs; request.prompt_logprobs = input.prompt_logprobs; if (try engine_refusal.of(srv.engine, cx, &request)) |message| return cx.refuse(message); + if (input.trace) |trace| trace.prepared(&request, thinking, effort); return .{ .input = input, .request = request, .prompt_len = rendered.ids.len, .received = received, .thinking = thinking, .reasoning = reasoning, .effort = effort, .sampled = sampling != null, .drafts = drafts, .token_ids = flag(f, "return_token_ids") orelse false, .stops = stops_opt, .preparing = preparing, .frames = rendered.frames }; } diff --git a/zig/src/server/cli.zig b/zig/src/server/cli.zig index 895ac6d1762..b24fb209200 100644 --- a/zig/src/server/cli.zig +++ b/zig/src/server/cli.zig @@ -52,7 +52,7 @@ pub const flags = [_]Flag{ .{ .name = "--chat-template", .path = true, .native = true }, .{ .name = "--voices", .path = true, .native = true }, .{ .name = "--default-voice", .native = true }, -} ++ @import("drama_cfg.zig").flags ++ @import("admission_cli.zig").flags ++ @import("connection_cli.zig").flags ++ [_]Flag{ +} ++ @import("drama_cfg.zig").flags ++ @import("admission_cli.zig").flags ++ @import("connection_cli.zig").flags ++ @import("voice_cli.zig").flags ++ [_]Flag{ .{ .name = "--alias", .kind = .append, .native = true }, .{ .name = "--name-priority", .kind = .append, .native = true }, .{ .name = "--api-key", .kind = .append, .native = true }, @@ -165,7 +165,7 @@ pub const flags = [_]Flag{ }; /// The variables this binary honours as the Python engine does, then the CUDA build's or the Metal build's. -pub const env = [_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_NO_LIVE", "TENSORFOLD_SEED_SALT", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_TOOL_ID_KEY_FILE", "TENSORFOLD_PHASE_METRICS", "TENSORFOLD_LIBPDFIUM", "TENSORFOLD_MAX_PDF_PAGES", "TENSORFOLD_DEVICE_CHECK", "HF_HOME", "HF_HUB_CACHE", "BRAVE_SEARCH_API_KEY" } ++ +pub const env = [_][]const u8{ "TENSORFOLD_API_KEY", "TENSORFOLD_NO_LIVE", "TENSORFOLD_SEED_SALT", "TENSORFOLD_REQUEST_LOG", "TENSORFOLD_REQUEST_JOURNAL", "TENSORFOLD_TOOL_ID_KEY_FILE", "TENSORFOLD_PHASE_METRICS", "TENSORFOLD_LIBPDFIUM", "TENSORFOLD_MAX_PDF_PAGES", "TENSORFOLD_DEVICE_CHECK", "HF_HOME", "HF_HUB_CACHE", "BRAVE_SEARCH_API_KEY" } ++ (if (cuda_build) [_][]const u8{ "TF_CUDA_DEVICE", "TF_CUDA_SEGMENTS", "TENSORFOLD_CUDA_KERNELS", "TENSORFOLD_MEMORY_RESERVE_GIB", "TENSORFOLD_CUDA_MEMORY_LIMIT_GB", "TENSORFOLD_P2P_DIAGNOSTICS", "TENSORFOLD_P2P_PROBE" } else [_][]const u8{}) ++ (if (builtin.os.tag == .macos) [_][]const u8{"TF_Q27_PROFILE"} else [_][]const u8{}); pub const Args = struct { @@ -194,6 +194,7 @@ pub const Args = struct { max_frames: ?u32 = null, silence: api.speech_guard.Config = .{}, cfg: @import("drama_cfg.zig").Flags = .{}, + voice: @import("voice_cli.zig").Flags = .{}, redraw: @import("speech_redraw.zig").Policy = .{}, speed_up: ?[]const u8 = null, // speed-up mode: this Mac's settings for the two-Mac link (Flash Next and the GLMs) prompt_cache_gib: ?f64 = null, // kept prompt states' budget (0: none; null: what 70% of RAM leaves past the loaded server) @@ -418,6 +419,7 @@ fn apply(a: Allocator, out: *Args, name: []const u8, value: ?[]const u8, u: *Usa } if (try cudaFlag(a, out, name, v, u) or try gpuFlag(a, out, name, v, u)) return; if (try @import("cli_recall.zig").flag(a, out, name, v, u)) return; + if (@import("voice_cli.zig").apply(&out.voice, name)) return; if (out.cfg.set(name, v) catch return fail(u, a, "--cfg-gamma must be 0 (off) or 1 (unguided) through 5", .{})) return; if (@import("cli_fsr.zig").apply(out, name, v) catch |err| return fail(u, a, "argument {s}: {s}", .{ name, @errorName(err) })) return; if (is(name, "--voices")) { diff --git a/zig/src/server/drama_voice.zig b/zig/src/server/drama_voice.zig index 7f6ba7aacd1..be06690f5c7 100644 --- a/zig/src/server/drama_voice.zig +++ b/zig/src/server/drama_voice.zig @@ -31,7 +31,12 @@ pub fn parse(a: Allocator, bytes: []const u8) ![]const prompt.Reference { .ok => |v| v, else => return error.BadVoice, }; - if (!std.mem.eql(u8, doc.strField("format") orelse "", "drama3-http-voice/1")) return error.BadVoice; + return parseDoc(a, doc); +} + +/// A parsed voice file, or an inline voice object, checked as a catalog file is. +pub fn parseDoc(a: Allocator, doc: json.Value) ![]const prompt.Reference { + if (doc != .object or !std.mem.eql(u8, doc.strField("format") orelse "", "drama3-http-voice/1")) return error.BadVoice; const source = doc.get("source") orelse return error.MissingAttestation; const kind = source.strField("kind") orelse return error.MissingAttestation; if (!std.mem.eql(u8, kind, "synthetic") and !std.mem.eql(u8, kind, "self") and !std.mem.eql(u8, kind, "consented")) return error.MissingAttestation; @@ -61,10 +66,13 @@ pub fn parse(a: Allocator, bytes: []const u8) ![]const prompt.Reference { /// A checked file's optional one-line `description`, shown in the listing. fn describe(a: Allocator, bytes: []const u8) ![]const u8 { - const doc = switch (try json.parse(a, bytes)) { + return describeDoc(switch (try json.parse(a, bytes)) { .ok => |v| v, else => return error.BadVoice, - }; + }); +} + +pub fn describeDoc(doc: json.Value) ![]const u8 { if (doc.get("description") == null) return ""; const s = doc.strField("description") orelse return error.BadVoice; if (s.len > 200 or !std.unicode.utf8ValidateSlice(s)) return error.BadVoice; diff --git a/zig/src/server/drama_voice_routes.zig b/zig/src/server/drama_voice_routes.zig new file mode 100644 index 00000000000..64da74c2456 --- /dev/null +++ b/zig/src/server/drama_voice_routes.zig @@ -0,0 +1,97 @@ +//! POST /v1/voices and DELETE /v1/voices/NAME under --manage-voices: attested catalog voices added and deleted live. +const std = @import("std"); +const json = @import("json"); +const prompt = @import("drama_prompt"); +const errors = @import("errors.zig"); +const http_body = @import("http_body.zig"); +const routes = @import("routes.zig"); +const voice = @import("drama_voice.zig"); +const tool = @import("drama_voice_tool.zig"); +const Server = @import("server.zig").Server; +const Conn = @import("http_conn.zig").Conn; +const Value = json.Value; +const Allocator = std.mem.Allocator; + +const unattested = "a voice needs source.kind synthetic, self or consented and a source.note"; +const bad_voice = "a voice needs 1 to 4 references, each a transcript a speech request accepts and its codes"; + +/// One frame stands in for the codes, so a request the catalog would refuse never reaches the encoder. +const placeholder = [1][10]i32{@splat(0)}; + +fn refuse(conn: *Conn, a: Allocator, code: u16, message: []const u8) void { + const o = json.newObject(a) catch return; + o.put(a, "message", .{ .string = message }) catch return; + o.put(a, "type", .{ .string = if (code >= 500) "server_error" else "invalid_request_error" }) catch return; + const wrapped = json.newObject(a) catch return; + wrapped.put(a, "error", .{ .object = o }) catch return; + routes.sendValue(conn, a, code, .{ .object = wrapped }); +} + +const Made = struct { file: []const u8, refs: []const prompt.Reference, description: []const u8 }; + +/// The attested voice file a request describes: a voice file's own fields, or a WAV with its transcript. +fn made(srv: *Server, a: Allocator, body: Value) !Made { + const description = voice.describeDoc(body) catch return error.BadDescription; + const source = body.get("source") orelse .null; + const kind = source.strField("kind") orelse ""; + const note = source.strField("note") orelse ""; + const audio = body.get("audio") orelse .null; + if (audio == .null) { + const refs = try voice.parseDoc(a, body); + return .{ .file = try tool.document(a, kind, note, description, refs), .refs = refs, .description = description }; + } + if (body.get("references") != null) return error.AudioAndReferences; + if (audio != .string) return error.BadAudio; + const text = body.strField("text") orelse return error.BadVoice; + _ = try tool.document(a, kind, note, description, &.{.{ .transcript = text, .codes = &placeholder }}); + const decoder = std.base64.standard.Decoder; + const wav = try a.alloc(u8, decoder.calcSizeForSlice(audio.string) catch return error.BadAudio); + decoder.decode(wav, audio.string) catch return error.BadAudio; + const encode = srv.engine.vtable.encode_voice orelse return error.NoEncoder; + const codes = try encode(srv.engine.ctx, a, wav); + if (codes.len == 0 or codes.len > voice.max_frames) return error.BadWav; + const refs = try a.dupe(prompt.Reference, &.{.{ .transcript = text, .codes = codes }}); + return .{ .file = try tool.document(a, kind, note, description, refs), .refs = refs, .description = description }; +} + +pub fn post(srv: *Server, conn: *Conn, a: Allocator) void { + var cx: errors.Cx = .{ .a = a }; + const body = http_body.readJson(conn, &cx) catch |e| return if (e == error.OutOfMemory) refuse(conn, a, 500, "out of memory") else refuse(conn, a, 400, cx.message); + const name = body.strField("name") orelse ""; + if (body != .object or !voice.validName(name)) return refuse(conn, a, 400, "name must be 1 to 64 letters, digits, '-' or '_', starting with a letter or digit, and not default"); + const voice_file = made(srv, a, body) catch |e| return switch (e) { + error.MissingAttestation => refuse(conn, a, 400, unattested), + error.BadVoice => refuse(conn, a, 400, bad_voice), + error.BadDescription => refuse(conn, a, 400, "description must be UTF-8 text of at most 200 bytes"), + error.AudioAndReferences => refuse(conn, a, 400, "send audio with its text, or a voice file's references, not both"), + error.BadAudio => refuse(conn, a, 400, "audio must be a WAV file in standard base64"), + error.BadWav => refuse(conn, a, 400, "audio must be a RIFF WAVE file (PCM 8, 16, 24 or 32-bit, or float32) of up to 30 seconds"), + error.NoEncoder => refuse(conn, a, 400, "this engine does not encode reference audio: send a voice file's references"), + error.Closed => refuse(conn, a, 503, "the speech engine is closed"), + error.OutOfMemory => refuse(conn, a, 500, "out of memory"), + else => refuse(conn, a, 500, "the reference audio could not be encoded"), + }; + const added = srv.voices.put(name, voice_file.file, voice_file.refs, voice_file.description) catch |e| return switch (e) { + error.TooManyVoices => refuse(conn, a, 409, "the catalog holds its most voices: delete one first"), + error.OutOfMemory => refuse(conn, a, 500, "out of memory"), + else => refuse(conn, a, 500, "the voice file could not be written to --voices"), + }; + const reply = json.newObject(a) catch return; + reply.put(a, "id", .{ .string = name }) catch return; + reply.put(a, "description", .{ .string = voice_file.description }) catch return; + reply.put(a, "added", .{ .bool = added }) catch return; + routes.sendValue(conn, a, if (added) 201 else 200, .{ .object = reply }); +} + +pub fn delete(srv: *Server, conn: *Conn, a: Allocator, name: []const u8) void { + srv.voices.remove(name, srv.config.voice.default) catch |e| return switch (e) { + error.UnknownVoice => refuse(conn, a, 404, "no such voice in the catalog"), + error.DefaultVoice => refuse(conn, a, 409, "the configured --default-voice cannot be deleted"), + error.OutOfMemory => refuse(conn, a, 500, "out of memory"), + else => refuse(conn, a, 500, "the voice file could not be removed from --voices"), + }; + const reply = json.newObject(a) catch return; + reply.put(a, "id", .{ .string = name }) catch return; + reply.put(a, "deleted", .{ .bool = true }) catch return; + routes.sendValue(conn, a, 200, .{ .object = reply }); +} diff --git a/zig/src/server/drama_voice_store.zig b/zig/src/server/drama_voice_store.zig new file mode 100644 index 00000000000..fb6a5143c96 --- /dev/null +++ b/zig/src/server/drama_voice_store.zig @@ -0,0 +1,141 @@ +//! The served voice catalog: --voices DIR at startup, then admin adds and deletes, read under one lock. +const std = @import("std"); +const json = @import("json"); +const prompt = @import("drama_prompt"); +const voice = @import("drama_voice.zig"); +const Allocator = std.mem.Allocator; +const Voice = voice.Voice; + +/// Readers copy what they need under the lock, so a change frees the old catalog at once and no request sees it go. +pub const Store = struct { + gpa: Allocator = undefined, + io: std.Io = undefined, + /// --voices DIR: where added voices are written and deleted ones removed; null keeps changes in memory. + dir: ?[]const u8 = null, + mutex: std.Io.Mutex = .init, + arena: ?*std.heap.ArenaAllocator = null, + voices: []const Voice = &.{}, + + /// The catalog in `dir`, sorted by name, as startup loads it. + pub fn load(s: *Store, dir: []const u8) !void { + var scratch: std.heap.ArenaAllocator = .init(s.gpa); + defer scratch.deinit(); + try s.swap(try voice.load(scratch.allocator(), s.io, dir)); + } + + pub fn deinit(s: *Store) void { + if (s.arena) |arena| free(s.gpa, arena); + s.arena = null; + s.voices = &.{}; + } + + /// The references `requested` selects (as drama_voice.select), copied into `a`. + pub fn select(s: *Store, a: Allocator, default: []const u8, requested: []const u8) ![]const prompt.Reference { + s.mutex.lockUncancelable(s.io); + defer s.mutex.unlock(s.io); + const refs = try voice.select(s.voices, default, requested); + const copy = try a.alloc(prompt.Reference, refs.len); + for (refs, copy) |ref, *out| out.* = .{ .transcript = try a.dupe(u8, ref.transcript), .codes = try a.dupe([10]i32, ref.codes) }; + return copy; + } + + /// GET /v1/voices's reply, its names and descriptions copied into `a`. + pub fn listing(s: *Store, a: Allocator) !json.Value { + s.mutex.lockUncancelable(s.io); + defer s.mutex.unlock(s.io); + const copy = try a.alloc(Voice, s.voices.len); + for (s.voices, copy) |v, *out| out.* = .{ .name = try a.dupe(u8, v.name), .references = &.{}, .description = try a.dupe(u8, v.description) }; + return voice.listing(a, copy); + } + + pub fn count(s: *Store) usize { + s.mutex.lockUncancelable(s.io); + defer s.mutex.unlock(s.io); + return s.voices.len; + } + + /// Adds or replaces `name`, first writing `file` (its attested voice file) when there is a directory; true: added. + pub fn put(s: *Store, name: []const u8, file: []const u8, refs: []const prompt.Reference, description: []const u8) !bool { + if (!voice.validName(name)) return error.BadVoiceName; + s.mutex.lockUncancelable(s.io); + defer s.mutex.unlock(s.io); + var next: std.ArrayList(Voice) = .empty; + defer next.deinit(s.gpa); + for (s.voices) |v| if (!std.mem.eql(u8, v.name, name)) try next.append(s.gpa, v); + const added = next.items.len == s.voices.len; + if (added and next.items.len >= max_voices) return error.TooManyVoices; + try next.append(s.gpa, .{ .name = name, .references = refs, .description = description }); + if (s.dir) |dir| try write(s.gpa, s.io, dir, name, file); + try s.swap(next.items); + return added; + } + + /// Deletes `name`, and its file when there is a directory; the configured default voice stays. + pub fn remove(s: *Store, name: []const u8, default: []const u8) !void { + if (!voice.validName(name)) return error.UnknownVoice; + if (std.mem.eql(u8, name, default)) return error.DefaultVoice; + s.mutex.lockUncancelable(s.io); + defer s.mutex.unlock(s.io); + var next: std.ArrayList(Voice) = .empty; + defer next.deinit(s.gpa); + for (s.voices) |v| if (!std.mem.eql(u8, v.name, name)) try next.append(s.gpa, v); + if (next.items.len == s.voices.len) return error.UnknownVoice; + if (s.dir) |dir| try unlink(s.io, dir, name); + try s.swap(next.items); + } + + /// The catalog becomes a sorted copy of `voices` and the old one is freed; the caller holds the lock or is alone. + pub fn swap(s: *Store, voices: []const Voice) !void { + const arena = try s.gpa.create(std.heap.ArenaAllocator); + arena.* = .init(s.gpa); + errdefer free(s.gpa, arena); + const a = arena.allocator(); + const copy = try a.alloc(Voice, voices.len); + for (voices, copy) |v, *out| { + const refs = try a.alloc(prompt.Reference, v.references.len); + for (v.references, refs) |ref, *r| r.* = .{ .transcript = try a.dupe(u8, ref.transcript), .codes = try a.dupe([10]i32, ref.codes) }; + out.* = .{ .name = try a.dupe(u8, v.name), .references = refs, .description = try a.dupe(u8, v.description) }; + } + std.mem.sort(Voice, copy, {}, struct { + fn less(_: void, left: Voice, right: Voice) bool { + return std.mem.lessThan(u8, left.name, right.name); + } + }.less); + if (s.arena) |old| free(s.gpa, old); + s.arena = arena; + s.voices = copy; + } +}; + +pub const max_voices = 256; + +fn free(gpa: Allocator, arena: *std.heap.ArenaAllocator) void { + arena.deinit(); + gpa.destroy(arena); +} + +/// NAME.json through a fresh hidden temporary in the same directory, renamed over any older file. +fn write(a: Allocator, io: std.Io, path: []const u8, name: []const u8, file: []const u8) !void { + var dir = try std.Io.Dir.cwd().openDir(io, path, .{}); + defer dir.close(io); + var nonce: [8]u8 = undefined; + io.random(&nonce); + const temp = try std.fmt.allocPrint(a, ".{s}.json.{x}", .{ name, std.mem.readInt(u64, &nonce, .native) }); + defer a.free(temp); + const final = try std.fmt.allocPrint(a, "{s}.json", .{name}); + defer a.free(final); + try dir.writeFile(io, .{ .sub_path = temp, .data = file, .flags = .{ .exclusive = true } }); + errdefer dir.deleteFile(io, temp) catch {}; + try dir.rename(temp, dir, final, io); +} + +fn unlink(io: std.Io, path: []const u8, name: []const u8) !void { + var dir = try std.Io.Dir.cwd().openDir(io, path, .{}); + defer dir.close(io); + var buf: [80]u8 = undefined; + dir.deleteFile(io, try std.fmt.bufPrint(&buf, "{s}.json", .{name})) catch |e| if (e != error.FileNotFound) return e; +} + +test { + _ = @import("drama_voice_store_test.zig"); +} diff --git a/zig/src/server/drama_voice_store_test.zig b/zig/src/server/drama_voice_store_test.zig new file mode 100644 index 00000000000..5412312abd5 --- /dev/null +++ b/zig/src/server/drama_voice_store_test.zig @@ -0,0 +1,62 @@ +//! The voice catalog store: copies outlive changes, files follow the catalog, the default voice stays. +const std = @import("std"); +const voice = @import("drama_voice.zig"); +const Store = @import("drama_voice_store.zig").Store; +const t = std.testing; + +const tone = + \\{"format":"drama3-http-voice/1","source":{"kind":"synthetic","note":"Tone A."}, + \\"references":[{"text":"One cloud.","codes":[[1,2,3,4,5,6,7,8,9,10]]}]} +; +const bright = + \\{"format":"drama3-http-voice/1","source":{"kind":"synthetic","note":"Tone B."},"description":"Bright.", + \\"references":[{"text":"Two clouds.","codes":[[2,2,3,4,5,6,7,8,9,10]]}]} +; + +test "voice store: a request's copy outlives a delete, and files follow adds and deletes" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(t.io, .{ .sub_path = "tone.json", .data = tone }); + var store: Store = .{ .gpa = t.allocator, .io = t.io, .dir = try std.fmt.allocPrint(a, ".zig-cache/tmp/{s}", .{tmp.sub_path}) }; + defer store.deinit(); + try store.load(store.dir.?); + const held = try store.select(a, "default", "tone"); + try t.expect(try store.put("bright", bright, try voice.parse(a, bright), "Bright.")); + try t.expect(!try store.put("bright", bright, try voice.parse(a, bright), "Bright.")); + try store.remove("tone", "default"); + try t.expectEqualStrings("One cloud.", held[0].transcript); + try t.expectEqual(@as(i32, 1), held[0].codes[0][0]); + try t.expectError(error.UnknownVoice, store.select(a, "default", "tone")); + try t.expectEqual(@as(usize, 0), (try store.select(a, "default", "default")).len); + try t.expectError(error.FileNotFound, tmp.dir.access(t.io, "tone.json", .{})); + try t.expectEqualStrings(bright, try tmp.dir.readFileAlloc(t.io, "bright.json", a, .limited(voice.max_file_bytes))); + const listed = try @import("json").stringify(a, try store.listing(a), .{}); + try t.expect(std.mem.indexOf(u8, listed, "\"voices\": [\"default\", \"bright\"]") != null); + try t.expect(std.mem.indexOf(u8, listed, "\"description\": \"Bright.\"") != null); + try t.expectError(error.UnknownVoice, store.remove("tone", "default")); + try t.expectError(error.DefaultVoice, store.remove("bright", "bright")); + try t.expectError(error.BadVoiceName, store.put("default", bright, &.{}, "")); + // a restart reads back what the routes wrote + var again: Store = .{ .gpa = t.allocator, .io = t.io }; + defer again.deinit(); + try again.load(store.dir.?); + try t.expectEqual(@as(usize, 1), again.count()); + try t.expectEqualStrings("Two clouds.", (try again.select(a, "default", "bright"))[0].transcript); +} + +test "voice store: without a directory changes stay in memory, and the catalog is capped" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var store: Store = .{ .gpa = t.allocator, .io = t.io }; + defer store.deinit(); + const refs = try voice.parse(a, tone); + for (0..@import("drama_voice_store.zig").max_voices) |i| try t.expect(try store.put(try std.fmt.allocPrint(a, "v{d}", .{i}), tone, refs, "")); + try t.expectError(error.TooManyVoices, store.put("one-more", tone, refs, "")); + try t.expect(!try store.put("v7", tone, refs, "kept")); + try store.remove("v7", "default"); + try t.expect(try store.put("one-more", tone, refs, "")); +} diff --git a/zig/src/server/drama_voice_tool.zig b/zig/src/server/drama_voice_tool.zig index df985d69b0a..ea3b09f4511 100644 --- a/zig/src/server/drama_voice_tool.zig +++ b/zig/src/server/drama_voice_tool.zig @@ -62,7 +62,7 @@ pub fn run(a: Allocator, io: std.Io, err: *Writer, argv: []const []const u8) !u8 if (kind == null or note == null) return refuse(err, unattested); const refs = try a.alloc(prompt.Reference, texts.items.len); for (refs, texts.items) |*ref, text| ref.* = .{ .transcript = text, .codes = &placeholder }; - _ = document(a, kind.?, note.?, refs) catch |e| return refuse(err, switch (e) { + _ = document(a, kind.?, note.?, "", refs) catch |e| return refuse(err, switch (e) { error.MissingAttestation => unattested, error.BadVoice => "drama3-voice: refused, give 1 to 4 references, each a transcript a speech request accepts\n", else => return e, @@ -156,7 +156,7 @@ fn encode( if (bytes.len % @sizeOf([10]i32) != 0) return error.BadCodes; ref.codes = std.mem.bytesAsSlice([10]i32, bytes); } - try private.writeFile(io, .{ .sub_path = base, .data = try document(a, kind, note, refs), .flags = .{ .exclusive = true } }); + try private.writeFile(io, .{ .sub_path = base, .data = try document(a, kind, note, "", refs), .flags = .{ .exclusive = true } }); try private.rename(base, parent, base, io); return 0; } @@ -166,15 +166,19 @@ fn refuse(err: *Writer, message: []const u8) !u8 { return 2; } -/// The voice file's JSON, accepted by the catalog's own parser. -fn document(a: Allocator, kind: []const u8, note: []const u8, refs: []const prompt.Reference) ![]const u8 { +/// The voice file's JSON, with its listing `description` when not empty, accepted by the catalog's own parser. +pub fn document(a: Allocator, kind: []const u8, note: []const u8, description: []const u8, refs: []const prompt.Reference) ![]const u8 { var out: Writer.Allocating = .init(a); const w = &out.writer; try w.writeAll("{\"format\": \"drama3-http-voice/1\", \"source\": {\"kind\": "); try json.writeString(w, kind, .{ .ascii = false }); try w.writeAll(", \"note\": "); try json.writeString(w, note, .{ .ascii = false }); - try w.writeAll("},\n\"references\": ["); + if (description.len > 0) { + try w.writeAll("}, \"description\": "); + try json.writeString(w, description, .{ .ascii = false }); + } else try w.writeByte('}'); + try w.writeAll(",\n\"references\": ["); for (refs, 0..) |ref, r| { try w.writeAll(if (r == 0) "\n{\"text\": " else ",\n{\"text\": "); try json.writeString(w, ref.transcript, .{ .ascii = false }); @@ -188,6 +192,10 @@ fn document(a: Allocator, kind: []const u8, note: []const u8, refs: []const prom } try w.writeAll("\n]}\n"); _ = try voice.parse(a, out.written()); + if (description.len > 0) _ = try voice.describeDoc(switch (try json.parse(a, out.written())) { + .ok => |doc| doc, + else => return error.BadVoice, + }); return out.written(); } diff --git a/zig/src/server/openai.zig b/zig/src/server/openai.zig index a3f7e333ec2..1b5987da538 100644 --- a/zig/src/server/openai.zig +++ b/zig/src/server/openai.zig @@ -20,6 +20,7 @@ const routes = @import("routes.zig"); const warm = @import("warm.zig"); const cortheon = @import("cortheon/cortheon.zig"); const cancel_ids = @import("cancel_ids.zig"); +const ClientOut = @import("openai_client.zig").ClientOut; const prompt_list = @import("prompt_list.zig"); const completion_prompt = @import("completion_prompt.zig"); const Server = @import("server.zig").Server; @@ -57,38 +58,6 @@ pub fn post(srv: *Server, conn: *Conn, a: Allocator, is_chat: bool) void { run(srv, a, client.out(), .{ .conn = conn }, is_chat, body); } -/// A chat reply written straight to the client. -const ClientOut = struct { - startup_at: ?u64 = null, - conn: *Conn, - a: Allocator, - - fn out(c: *ClientOut) Out { - return .{ .ctx = c, .vt = &.{ .open = open, .event = event, .reply = reply, .keepalive = keepalive } }; - } - - fn open(ctx: *anyopaque, _: usize) error{Closed}!void { - const c: *ClientOut = @ptrCast(@alignCast(ctx)); - return sse.open(c.conn); - } - - fn event(ctx: *anyopaque, payload: ?Value) error{Closed}!void { - const c: *ClientOut = @ptrCast(@alignCast(ctx)); - return if (payload) |p| sse.data(c.conn, c.a, p) else sse.done(c.conn); - } - - fn reply(ctx: *anyopaque, status: u16, payload: Value) void { - const c: *ClientOut = @ptrCast(@alignCast(ctx)); - routes.sendValue(c.conn, c.a, status, payload); - if (status == 200 and c.conn.response_complete and !c.conn.broken) @import("startup_receipt.zig").complete(c.startup_at, payload); - } - - fn keepalive(ctx: *anyopaque) error{Closed}!void { - const c: *ClientOut = @ptrCast(@alignCast(ctx)); - return sse.comment(c.conn); - } -}; - /// Whether the client has gone, read between rounds (Python's socket_cancellation). pub const Gone = @import("stream_live.zig").Gone; @@ -200,11 +169,16 @@ pub fn runNamed(srv: *Server, a: Allocator, out: Out, gone: Gone, is_chat: bool, const field: []const u8 = if (is_chat) "messages" else "prompt"; const id = ids.make(a, if (is_chat) "chatcmpl-" else "cmpl-", 32) catch return; var cx: Cx = .{ .a = a, .skip_request_log = skip_request_log }; + // TENSORFOLD_REQUEST_JOURNAL: off, `observed` is `out` and the trace does nothing + var trace: @import("request_trace.zig").Trace = .{ .journal = srv.config.journal, .a = a, .id = id, .parent = out }; + defer trace.finish(); + const observed = trace.out(); + if (trace.begin(raw, is_chat, gone.conn.key_label orelse "")) return trace.refuse(id); var p = plan(srv, &cx, is_chat, raw, format, client_thinking) catch |e| { if (e == error.OutOfMemory) cx.message = "out of memory"; logRefused(id, cx.message); const body = errorBody(a, &cx, field) catch return; - out.vt.reply(out.ctx, cx.status(), wrapError(a, body) catch return); + observed.vt.reply(observed.ctx, cx.status(), wrapError(a, body) catch return); return; }; p.input.id = id; @@ -214,9 +188,10 @@ pub fn runNamed(srv: *Server, a: Allocator, out: Out, gone: Gone, is_chat: bool, cancel_ids.registry.add(srv.io, &names, &asked); defer cancel_ids.registry.remove(srv.io, &names, &asked); p.input.cancel = &asked.asked; - if (p.prompts.len > 0) return prompt_list.run(srv, a, out, gone, p, p.prompts, raw); + if (p.prompts.len > 0) return prompt_list.run(srv, a, observed, gone, p, p.prompts, raw); + if (srv.config.journal != null) p.input.trace = &trace; const turn = cortheon.begin(srv, a, raw, id, is_chat, &p.input); - var r: Run = .{ .srv = srv, .a = a, .out = out, .is_chat = is_chat, .plan = p, .id = id, .created = std.Io.Clock.real.now(srv.io).toSeconds(), .turn = turn, .call_ids = .{ .key = &srv.tool_ids, .body = raw } }; + var r: Run = .{ .srv = srv, .a = a, .out = observed, .is_chat = is_chat, .plan = p, .id = id, .created = std.Io.Clock.real.now(srv.io).toSeconds(), .turn = turn, .call_ids = .{ .key = &srv.tool_ids, .body = raw } }; if (p.stream) r.stream(gone, field) else r.whole(gone, field); } diff --git a/zig/src/server/openai_client.zig b/zig/src/server/openai_client.zig new file mode 100644 index 00000000000..3f3b31122ac --- /dev/null +++ b/zig/src/server/openai_client.zig @@ -0,0 +1,39 @@ +//! A chat reply written straight to the client: its own Out, an SSE stream or one JSON reply (openai.zig). +const std = @import("std"); +const sse = @import("sse.zig"); +const routes = @import("routes.zig"); +const Conn = @import("http_conn.zig").Conn; +const Value = @import("json").Value; +const Out = @import("openai.zig").Out; +const Allocator = std.mem.Allocator; + +pub const ClientOut = struct { + startup_at: ?u64 = null, + conn: *Conn, + a: Allocator, + + pub fn out(c: *ClientOut) Out { + return .{ .ctx = c, .vt = &.{ .open = open, .event = event, .reply = reply, .keepalive = keepalive } }; + } + + fn open(ctx: *anyopaque, _: usize) error{Closed}!void { + const c: *ClientOut = @ptrCast(@alignCast(ctx)); + return sse.open(c.conn); + } + + fn event(ctx: *anyopaque, payload: ?Value) error{Closed}!void { + const c: *ClientOut = @ptrCast(@alignCast(ctx)); + return if (payload) |p| sse.data(c.conn, c.a, p) else sse.done(c.conn); + } + + fn reply(ctx: *anyopaque, status: u16, payload: Value) void { + const c: *ClientOut = @ptrCast(@alignCast(ctx)); + routes.sendValue(c.conn, c.a, status, payload); + if (status == 200 and c.conn.response_complete and !c.conn.broken) @import("startup_receipt.zig").complete(c.startup_at, payload); + } + + fn keepalive(ctx: *anyopaque) error{Closed}!void { + const c: *ClientOut = @ptrCast(@alignCast(ctx)); + return sse.comment(c.conn); + } +}; diff --git a/zig/src/server/request_journal.zig b/zig/src/server/request_journal.zig new file mode 100644 index 00000000000..2a249f88383 --- /dev/null +++ b/zig/src/server/request_journal.zig @@ -0,0 +1,288 @@ +//! TENSORFOLD_REQUEST_JOURNAL: an opt-in, owner-only, rotated request journal; crashed requests are quarantined. +const std = @import("std"); +const platform = @import("sys"); +const json = @import("json"); +const log = @import("log.zig"); +const private = @import("request_log.zig").private; +const Allocator = std.mem.Allocator; +const Value = json.Value; +const Sha256 = std.crypto.hash.sha2.Sha256; +const c = platform.c; + +/// Past this a file becomes `.1`, each older file moves up one, and the oldest of `files` is removed. +pub const file_limit: usize = 64 << 20; +pub const files = 4; +/// The most one record holds: a larger body or reply is journaled by its size and SHA-256 only. +pub const record_limit: usize = 8 << 20; +/// A quarantine lapses a day after the crash that set it, unless cleared sooner; at most `quarantine_limit` hold. +pub const quarantine_s: i64 = 24 * 60 * 60; +pub const quarantine_limit = 4096; +/// Requests in flight at one crash are only flagged; one in flight at a second crash too is refused. +const refuse_at = 2; +const path_max = 4000; + +/// The API key's label, the route and the whole body: one key's crashed request never blocks another key's. +pub const Fingerprint = [32]u8; + +pub fn fingerprint(key: []const u8, chat: bool, body: Value) Fingerprint { + var buf: [4096]u8 = undefined; + var w: std.Io.Writer.Hashing(Sha256) = .init(&buf); + w.writer.print("tensorfold-quarantine-1\x00{s}\x00{s}\x00", .{ key, if (chat) "chat" else "completion" }) catch unreachable; + json.write(&w.writer, body, .{ .compact = true }) catch unreachable; // hashing drains never fail + w.writer.flush() catch unreachable; + return w.hasher.finalResult(); +} + +/// What serve prints when the journal can't be opened. +pub fn why(e: anyerror) []const u8 { + return switch (e) { + error.JournalBusy => "another server holds it (its .lock file is locked)", + error.JournalPermissions => "it or its .lock file is not a regular file only its owner can read and write", + error.JournalOpen => "it or its .lock file cannot be opened, or is a symbolic link", + error.JournalPath => "the path is empty or too long", + else => @errorName(e), + }; +} + +pub const Journal = struct { + gpa: Allocator, + io: std.Io, + path: [:0]const u8, + lock: c.fd_t, + fd: c.fd_t, + mutex: std.Io.Mutex = .init, + bytes: usize = 0, + limit: usize = file_limit, + lost: std.atomic.Value(u64) = .init(0), + blocked: std.AutoHashMapUnmanaged(Fingerprint, i64) = .empty, // the second each refusal lapses; fixed once open + + /// Takes `path.lock`, reads every kept file and quarantines the requests a crash left without a finish. + pub fn open(gpa: Allocator, io: std.Io, path: []const u8) !*Journal { + if (path.len == 0 or path.len > path_max or std.mem.indexOfScalar(u8, path, 0) != null) return error.JournalPath; + const j = try gpa.create(Journal); + errdefer gpa.destroy(j); + j.* = .{ .gpa = gpa, .io = io, .path = try gpa.dupeSentinel(u8, path, 0), .lock = -1, .fd = -1 }; + errdefer j.release(); + var buf: [path_max + 16]u8 = undefined; + j.lock = try openPrivate(try sibling(&buf, path, ".lock"), .{ .ACCMODE = .RDWR, .CREAT = true, .NOFOLLOW = true, .CLOEXEC = true }); + if (c.flock(j.lock, c.LOCK.EX | c.LOCK.NB) != 0) return error.JournalBusy; + j.fd = try openPrivate(j.path, .{ .ACCMODE = .RDWR, .APPEND = true, .CREAT = true, .NOFOLLOW = true, .CLOEXEC = true }); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + var r: Recovery = .{ .a = arena.allocator(), .gpa = gpa, .now = j.now() }; + var older: usize = files; + while (older > 1) { + older -= 1; + const fd = openPrivate(try sibling(&buf, path, suffix(older)), .{ .NOFOLLOW = true, .CLOEXEC = true }) catch continue; + defer _ = c.close(fd); + try r.scan(fd); + } + try r.scan(j.fd); + j.bytes = r.whole; + // a crash mid-write leaves a torn last line; the next record starts on a fresh one + if (r.size > r.whole and c.ftruncate(j.fd, @intCast(r.whole)) != 0) return error.JournalWrite; + try r.settle(j); + if (r.skipped > 0) log.line("request journal {s}: {d} unreadable record(s) passed over", .{ path, r.skipped }); + if (j.blocked.count() > 0) log.line("request journal {s}: {d} request(s) quarantined after crashes", .{ path, j.blocked.count() }); + return j; + } + + pub fn close(j: *Journal) void { + const lost = j.lost.load(.monotonic); + if (lost > 0) log.line("request journal {s}: {d} record(s) were not written", .{ j.path, lost }); + j.release(); + j.gpa.destroy(j); + } + + fn release(j: *Journal) void { + if (j.fd >= 0) _ = c.close(j.fd); + if (j.lock >= 0) _ = c.close(j.lock); + j.blocked.deinit(j.gpa); + j.gpa.free(j.path); + } + + /// A clean stop: requests still open now were not in flight at a crash. + pub fn stopped(j: *Journal) void { + var arena: std.heap.ArenaAllocator = .init(j.gpa); + defer arena.deinit(); + const o = j.record(arena.allocator(), "stop", null) catch return j.lose(); + j.append(arena.allocator(), .{ .object = o }); + } + + /// Whether this fingerprint crashed the server and is refused until it lapses or the operator clears it. + pub fn quarantined(j: *Journal, fp: Fingerprint) bool { + const until = j.blocked.get(fp) orelse return false; + return j.now() < until; + } + + pub fn record(j: *Journal, a: Allocator, kind: []const u8, id: ?[]const u8) Allocator.Error!*json.Object { + const o = try json.newObject(a); + try o.put(a, "version", .{ .int = "1" }); + try o.put(a, "kind", .{ .string = kind }); + if (id) |s| try o.put(a, "id", .{ .string = s }); + try o.put(a, "at", try json.intValue(a, j.now())); + return o; + } + + /// One record as one line in one write, with no sync; a failure or a full file loses the record, never the request. + pub fn append(j: *Journal, a: Allocator, value: Value) void { + var out: std.Io.Writer.Allocating = .init(a); + json.write(&out.writer, value, .{ .compact = true }) catch return j.lose(); + out.writer.writeByte('\n') catch return j.lose(); + const line = out.written(); + if (line.len > record_limit) return j.lose(); + j.mutex.lockUncancelable(j.io); + defer j.mutex.unlock(j.io); + if (j.fd >= 0 and j.bytes > 0 and j.bytes + line.len > j.limit) j.rotate(); + if (j.fd < 0) return j.lose(); + const n = c.write(j.fd, line.ptr, line.len); + if (n == @as(isize, @intCast(line.len))) { + j.bytes += line.len; + return; + } + if (n > 0) _ = c.ftruncate(j.fd, @intCast(j.bytes)); // no torn line for the next record to follow + j.lose(); + } + + /// The current file becomes `.1`, older ones move up, and a new one starts; a failure stops the journal. + fn rotate(j: *Journal) void { + _ = c.close(j.fd); + j.fd = -1; + var from: [path_max + 16]u8 = undefined; + var to: [path_max + 16]u8 = undefined; + var i: usize = files - 1; + while (i > 0) : (i -= 1) _ = c.rename(sibling(&from, j.path, suffix(i - 1)) catch return, sibling(&to, j.path, suffix(i)) catch return); + j.fd = openPrivate(j.path, .{ .ACCMODE = .WRONLY, .APPEND = true, .CREAT = true, .EXCL = true, .NOFOLLOW = true, .CLOEXEC = true }) catch -1; + j.bytes = 0; + } + + fn lose(j: *Journal) void { + if (j.lost.fetchAdd(1, .monotonic) == 0) log.line("request journal {s}: a record was not written (a full disk, an I/O error or a record past {d} MiB); requests go on", .{ j.path, record_limit >> 20 }); + } + + fn now(j: *const Journal) i64 { + return std.Io.Clock.real.now(j.io).toSeconds(); + } +}; + +fn suffix(n: usize) []const u8 { + return ([_][]const u8{ "", ".1", ".2", ".3", ".4", ".5", ".6", ".7", ".8" })[n]; +} + +fn sibling(buf: []u8, path: []const u8, tail: []const u8) ![:0]const u8 { + return std.fmt.bufPrintSentinel(buf, "{s}{s}", .{ path, tail }, 0) catch error.JournalPath; +} + +/// Opened only as a regular file no one but its owner can read or write; a link or a shared file is refused. +fn openPrivate(path: [*:0]const u8, flags: c.O) !c.fd_t { + const fd = c.open(path, flags, @as(c.mode_t, 0o600)); + if (fd < 0) return error.JournalOpen; + if (private(fd)) return fd; + _ = c.close(fd); + return error.JournalPermissions; +} + +/// The kept files read oldest first: starts still open at the end were in flight when the server last stopped. +const Recovery = struct { + a: Allocator, + gpa: Allocator, + now: i64, + pending: std.StringArrayHashMapUnmanaged(Fingerprint) = .empty, + crashes: std.AutoArrayHashMapUnmanaged(Fingerprint, Crashes) = .empty, + skipped: usize = 0, + size: usize = 0, + whole: usize = 0, // the last file's bytes up to and including its last newline + const Crashes = struct { n: u32 = 0, until: i64 = 0 }; + + fn scan(r: *Recovery, fd: c.fd_t) !void { + var line: std.ArrayList(u8) = .empty; + defer line.deinit(r.gpa); + var scratch: std.heap.ArenaAllocator = .init(r.gpa); + defer scratch.deinit(); + var chunk: [1 << 16]u8 = undefined; + var over = false; // past a record's size: the line is passed over + r.size = 0; + r.whole = 0; + while (true) { + const n = c.read(fd, &chunk, chunk.len); + if (n < 0) return error.JournalRead; + if (n == 0) break; + var rest: []const u8 = chunk[0..@intCast(n)]; + r.size += rest.len; + while (std.mem.indexOfScalar(u8, rest, '\n')) |at| { + if (!over) try line.appendSlice(r.gpa, rest[0..at]); + if (over) r.skipped += 1 else try r.entry(scratch.allocator(), line.items); + _ = scratch.reset(.retain_capacity); + line.clearRetainingCapacity(); + over = false; + rest = rest[at + 1 ..]; + r.whole = r.size - rest.len; + } + if (!over and line.items.len + rest.len > record_limit) { + over = true; + line.clearRetainingCapacity(); + } else if (!over) try line.appendSlice(r.gpa, rest); + } + } + + fn entry(r: *Recovery, a: Allocator, text: []const u8) !void { + if (text.len == 0) return; + const v = switch (try json.parse(a, text)) { + .ok => |v| v, + .err => return r.skip(), + }; + if (((v.get("version") orelse return r.skip()).int64() orelse return r.skip()) != 1) return r.skip(); + const kind = v.strField("kind") orelse return r.skip(); + if (eql(kind, "stop")) return r.pending.clearRetainingCapacity(); + if (eql(kind, "clear")) { + if (json.truthyField(v, "all")) return r.crashes.clearRetainingCapacity(); + _ = r.crashes.orderedRemove(hexOf(v) orelse return r.skip()); + return; + } + const id = v.strField("id") orelse return r.skip(); + if (eql(kind, "start")) return r.pending.put(r.a, try r.a.dupe(u8, id), hexOf(v) orelse return r.skip()); + if (!eql(kind, "finish") and !eql(kind, "quarantine")) return; + _ = r.pending.orderedRemove(id); + if (!eql(kind, "quarantine")) return; + const at = (v.get("at") orelse return r.skip()).int64() orelse return r.skip(); + try r.add(hexOf(v) orelse return r.skip(), at + quarantine_s); + } + + fn add(r: *Recovery, fp: Fingerprint, until: i64) !void { + if (until <= r.now) return; + const w = try r.crashes.getOrPut(r.a, fp); + if (!w.found_existing) w.value_ptr.* = .{}; + w.value_ptr.n += 1; + w.value_ptr.until = @max(w.value_ptr.until, until); + } + + /// The last session's open starts are quarantined, then every fingerprint in flight at two crashes is refused. + fn settle(r: *Recovery, j: *Journal) !void { + for (r.pending.keys(), r.pending.values()) |id, fp| { + const o = try j.record(r.a, "quarantine", id); + const hex = std.fmt.bytesToHex(fp, .lower); + try o.put(r.a, "fingerprint", .{ .string = try r.a.dupe(u8, &hex) }); + j.append(r.a, .{ .object = o }); + try r.add(fp, r.now + quarantine_s); + } + for (r.crashes.keys(), r.crashes.values()) |fp, w| { + if (w.n >= refuse_at and j.blocked.count() < quarantine_limit) try j.blocked.put(j.gpa, fp, w.until); + } + } + + fn skip(r: *Recovery) void { + r.skipped += 1; + } +}; + +fn hexOf(v: Value) ?Fingerprint { + const text = v.strField("fingerprint") orelse return null; + var fp: Fingerprint = undefined; + if (text.len != 64) return null; + _ = std.fmt.hexToBytes(&fp, text) catch return null; + return fp; +} + +fn eql(a: []const u8, b: []const u8) bool { + return std.mem.eql(u8, a, b); +} diff --git a/zig/src/server/request_journal_test.zig b/zig/src/server/request_journal_test.zig new file mode 100644 index 00000000000..83de76cc271 --- /dev/null +++ b/zig/src/server/request_journal_test.zig @@ -0,0 +1,461 @@ +//! The request journal on a fake engine: records, replay by the resolved seed, crash quarantine, rotation, failures. +const std = @import("std"); +const builtin = @import("builtin"); +const api = @import("engine_api"); +const json = @import("json"); +const platform = @import("sys"); +const journal_mod = @import("request_journal.zig"); +const Journal = journal_mod.Journal; +const Trace = @import("request_trace.zig").Trace; +const openai = @import("openai.zig"); +const Server = @import("server.zig").Server; +const Conn = @import("http_conn.zig").Conn; +const TestText = @import("stream_preflight_test.zig").TestText; +const t = std.testing; +const Allocator = std.mem.Allocator; +const Value = json.Value; + +/// Replies with the decimal digits of the seed it was given, so a replay without that seed reads differently. +const Fake = struct { + submitted: usize = 0, + fn engine(f: *Fake) api.Engine { + return .{ .ctx = f, .vtable = &.{ .info = info, .submit = submit, .cancel = cancel, .status = status, .memory = memory } }; + } + fn info(_: *anyopaque) api.Info { + return .{ .context_window = 4096 }; + } + fn submit(ctx: *anyopaque, id: api.Id, r: *const api.Request, sink: api.Sink) api.SubmitError!void { + const f: *Fake = @ptrCast(@alignCast(ctx)); + f.submitted += 1; + var buf: [24]u8 = undefined; + const text = std.fmt.bufPrint(&buf, "{d}", .{if (r.sampling) |s| s.seed else 7}) catch unreachable; + var ids: [24]u32 = undefined; + for (text, 0..) |b, i| ids[i] = b; + sink.event(sink.ctx, id, &.{ .prefilled = 0 }); + sink.event(sink.ctx, id, &.{ .tokens = ids[0..text.len] }); + sink.event(sink.ctx, id, &.{ .finished = .{ .reason = .stop } }); + } + fn cancel(_: *anyopaque, _: api.Id) void {} + fn status(_: *anyopaque, out: *api.Status, _: []u32) void { + out.* = .{}; + } + fn memory(_: *anyopaque, _: bool) ?api.Memory { + return null; + } +}; + +/// The bytes a client would read: each payload serialized as the socket writers do. +const Wire = struct { + a: Allocator, + bytes: std.ArrayList(u8) = .empty, + status: u16 = 0, + last: Value = .null, + fn out(w: *Wire) openai.Out { + return .{ .ctx = w, .vt = &.{ .open = open, .event = event, .reply = reply } }; + } + fn open(ctx: *anyopaque, _: usize) error{Closed}!void { + const w: *Wire = @ptrCast(@alignCast(ctx)); + w.status = 200; + } + fn event(ctx: *anyopaque, payload: ?Value) error{Closed}!void { + const w: *Wire = @ptrCast(@alignCast(ctx)); + const p = payload orelse return w.bytes.appendSlice(w.a, "data: [DONE]\n\n") catch error.Closed; + w.last = p; + const text = json.stringify(w.a, p, .{}) catch return error.Closed; + w.bytes.appendSlice(w.a, std.mem.concat(w.a, u8, &.{ "data: ", text, "\n\n" }) catch return error.Closed) catch return error.Closed; + } + fn reply(ctx: *anyopaque, code: u16, payload: Value) void { + const w: *Wire = @ptrCast(@alignCast(ctx)); + w.status = code; + w.last = payload; + w.bytes.appendSlice(w.a, json.stringify(w.a, payload, .{}) catch return) catch {}; + } + fn tokens(w: *const Wire) []const u8 { + return w.last.get("tensorfold").?.strField("token_sha256").?; + } +}; + +const hello = "{\"model\":\"m\",\"messages\":[{\"role\":\"user\",\"content\":\"hello\"}],\"temperature\":1,\"max_tokens\":8"; + +fn serve(fake: *Fake, text: *TestText, journal: ?*Journal) !*Server { + return Server.init(t.allocator, t.io, fake.engine(), text.text(), .{ .served_name = "m", .model_ids = &.{"m"}, .enable_thinking = false, .use_drafts = false, .journal = journal }, null); +} + +fn ask(srv: *Server, a: Allocator, body: []const u8, key: ?[]const u8) !Wire { + var wire: Wire = .{ .a = a }; + var conn: Conn = .{ .fd = -1, .peer = "", .buf = &.{}, .gpa = a, .key_label = key }; + openai.run(srv, a, wire.out(), .{ .conn = &conn }, true, (try json.parse(a, body)).ok); + return wire; +} + +fn records(a: Allocator, path: []const u8) ![]Value { + const raw = try std.Io.Dir.cwd().readFileAlloc(t.io, path, a, .limited(1 << 26)); + var found: std.ArrayList(Value) = .empty; + var it = std.mem.splitScalar(u8, raw, '\n'); + while (it.next()) |line| if (line.len > 0) try found.append(a, (try json.parse(a, line)).ok); + return found.items; +} + +fn kinds(a: Allocator, path: []const u8, kind: []const u8) ![]Value { + var found: std.ArrayList(Value) = .empty; + for (try records(a, path)) |r| if (std.mem.eql(u8, r.strField("kind").?, kind)) try found.append(a, r); + return found.items; +} + +fn journalPath(a: Allocator, tmp: t.TmpDir, name: []const u8) ![]const u8 { + return std.fmt.allocPrint(a, ".zig-cache/tmp/{s}/{s}", .{ tmp.sub_path, name }); +} + +/// A request that began and never finished: the process died with it in flight. +fn inFlight(j: *Journal, a: Allocator, body: []const u8, key: []const u8) !void { + var wire: Wire = .{ .a = a }; + var trace: Trace = .{ .journal = j, .a = a, .id = try std.fmt.allocPrint(a, "chatcmpl-{d}", .{j.bytes}), .parent = wire.out() }; + try t.expect(!trace.begin((try json.parse(a, body)).ok, true, key)); +} + +test "request journal: whole and streamed replies keep their start, resolved seed and exact reply bytes" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + var fake: Fake = .{}; + var text: TestText = .{}; + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + inline for (.{ "}", ",\"stream\":true}" }) |tail| { + const wire = try ask(srv, a, hello ++ ",\"seed\":1234" ++ tail, null); + try t.expectEqual(@as(u16, 200), wire.status); + const finishes = try kinds(a, path, "finish"); + const finish = finishes[finishes.len - 1]; + const id = finish.strField("id").?; + try t.expectEqualStrings("completed", finish.strField("outcome").?); + try t.expectEqual(tail.len > 1, finish.get("stream").?.bool); + const encoded = finish.strField("reply_base64").?; + const decoder = std.base64.standard.Decoder; + const bytes = try a.alloc(u8, try decoder.calcSizeForSlice(encoded)); + try decoder.decode(bytes, encoded); + try t.expectEqualStrings(wire.bytes.items, bytes); + try t.expectEqualStrings(wire.tokens(), finish.strField("token_sha256").?); + for (try records(a, path)) |r| if (std.mem.eql(u8, r.strField("id") orelse "", id)) { + const kind = r.strField("kind").?; + if (std.mem.eql(u8, kind, "prepared")) try t.expectEqual(@as(i64, 1234), r.get("seed").?.int64().?); + if (std.mem.eql(u8, kind, "start")) try t.expectEqual(@as(usize, 64), r.strField("fingerprint").?.len); + }; + } + try t.expectEqual(@as(usize, 2), (try kinds(a, path, "start")).len); + try t.expectEqual(@as(usize, 2), (try kinds(a, path, "prepared")).len); +} + +test "request journal: a two-prompt completion finishes whole and streamed with the merged reply" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + var fake: Fake = .{}; + var text: TestText = .{}; + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + const base = "{\"model\":\"m\",\"prompt\":[\"abc\",\"def\"],\"seed\":1234,\"max_tokens\":8"; + inline for (.{ "}", ",\"stream\":true}" }) |tail| { + var wire: Wire = .{ .a = a }; + var conn: Conn = .{ .fd = -1, .peer = "", .buf = &.{}, .gpa = a }; + openai.run(srv, a, wire.out(), .{ .conn = &conn }, false, (try json.parse(a, base ++ tail)).ok); + try t.expectEqual(@as(u16, 200), wire.status); + const finishes = try kinds(a, path, "finish"); + const finish = finishes[finishes.len - 1]; + try t.expectEqualStrings("completed", finish.strField("outcome").?); + const encoded = finish.strField("reply_base64").?; + const decoder = std.base64.standard.Decoder; + const bytes = try a.alloc(u8, try decoder.calcSizeForSlice(encoded)); + try decoder.decode(bytes, encoded); + try t.expectEqualStrings(wire.bytes.items, bytes); + try t.expectEqual(@as(usize, 0), (try kinds(a, path, "prepared")).len); + } +} + +test "request journal: an unseeded request's drawn seed replays the same tokens, and a replay without it differs" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + var fake: Fake = .{}; + var text: TestText = .{}; + const first = blk: { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + break :blk try ask(srv, a, hello ++ "}", null); + }; + const start = (try kinds(a, path, "start"))[0]; + const seed = (try kinds(a, path, "prepared"))[0].get("seed").?; + try t.expect(start.get("seed").? == .null); + const body = start.get("body").?; + try body.object.put(a, "seed", seed); + const replay = try json.stringify(a, body, .{}); + const srv = try serve(&fake, &text, null); + defer srv.deinit(); + const again = try ask(srv, a, replay, null); + try t.expectEqualStrings(first.tokens(), again.tokens()); + const content = first.last.get("choices").?.array[0].get("message").?.strField("content").?; + try t.expectEqualStrings(content, again.last.get("choices").?.array[0].get("message").?.strField("content").?); + _ = body.object.orderedRemove("seed"); + const fresh = try ask(srv, a, try json.stringify(a, body, .{}), null); + try t.expect(!std.mem.eql(u8, first.tokens(), fresh.tokens())); // a fresh seed: one chance in about 2^63 to match +} + +test "request journal: image and PDF data stay out, and the journal and its lock are owner-only" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + var fake: Fake = .{}; + var text: TestText = .{}; + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + const parts = "[{\"type\":\"image_url\",\"image_url\":{\"url\":\"https://example.test/private.png\"}},{\"type\":\"file\",\"file\":{\"filename\":\"a.pdf\",\"file_data\":\"SECRET-PDF\"}}]"; + _ = try ask(srv, a, "{\"model\":\"m\",\"messages\":[{\"role\":\"user\",\"content\":" ++ parts ++ "}]}", "alice"); + const raw = try std.Io.Dir.cwd().readFileAlloc(t.io, path, a, .limited(1 << 20)); + try t.expect(std.mem.indexOf(u8, raw, "private.png") == null and std.mem.indexOf(u8, raw, "SECRET-PDF") == null); + try t.expect(std.mem.indexOf(u8, raw, "a.pdf") != null and std.mem.indexOf(u8, raw, "") != null); + try t.expect(std.mem.indexOf(u8, raw, "alice") == null); // the key's label is in the fingerprint, not the file + if (builtin.os.tag == .windows) return; // NTFS keeps access in ACLs, not mode bits + for ([_][]const u8{ "requests.jsonl", "requests.jsonl.lock" }) |name| { + const st = try tmp.dir.statFile(t.io, name, .{}); + try t.expectEqual(@as(u32, 0o600), @as(u32, @intCast(st.permissions.toMode())) & 0o777); + } +} + +test "request journal: a request in flight at two crashes is refused after restart, for its own key only" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const crashed = hello ++ ",\"seed\":9}"; + var fake: Fake = .{}; + var text: TestText = .{}; + for (0..2) |crash| { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); // a close without a stop: the process died + try t.expectEqual(crash, (try kinds(a, path, "quarantine")).len); + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + try t.expectEqual(@as(u16, 200), (try ask(srv, a, crashed, "alice")).status); // one crash only flags it + try inFlight(j, a, crashed, "alice"); + } + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expectEqual(@as(usize, 2), (try kinds(a, path, "quarantine")).len); + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + const before = fake.submitted; + const refused = try ask(srv, a, crashed, "alice"); + try t.expectEqual(@as(u16, 400), refused.status); + try t.expectEqualStrings("request_quarantined", refused.last.get("error").?.strField("code").?); + try t.expectEqual(before, fake.submitted); // refused before the engine saw it + try t.expectEqual(@as(u16, 200), (try ask(srv, a, crashed, "bob")).status); + try t.expectEqual(@as(u16, 200), (try ask(srv, a, hello ++ ",\"seed\":10}", "alice")).status); + try t.expectEqual(before + 2, fake.submitted); + const finishes = try kinds(a, path, "finish"); + try t.expectEqualStrings("quarantined", finishes[finishes.len - 3].strField("outcome").?); + j.stopped(); + } + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expectEqual(@as(usize, 2), (try kinds(a, path, "quarantine")).len); // nothing in flight, nothing new + try t.expect(j.quarantined(journal_mod.fingerprint("alice", true, (try json.parse(a, crashed)).ok))); +} + +test "request journal: of several requests in flight at one crash, only one in flight again at a second is refused" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const bodies = [_][]const u8{ hello ++ ",\"seed\":1}", hello ++ ",\"seed\":2}", hello ++ ",\"seed\":3}" }; + const fp = struct { + fn of(arena_a: Allocator, body: []const u8) !journal_mod.Fingerprint { + return journal_mod.fingerprint("", true, (try json.parse(arena_a, body)).ok); + } + }.of; + for ([_][2]usize{ .{ 0, 1 }, .{ 0, 2 } }) |pair| { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + for (bodies) |body| try t.expect(!j.quarantined(try fp(a, body))); + for (pair) |k| try inFlight(j, a, bodies[k], ""); + } + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expect(j.quarantined(try fp(a, bodies[0]))); + try t.expect(!j.quarantined(try fp(a, bodies[1])) and !j.quarantined(try fp(a, bodies[2]))); + try t.expectEqual(@as(usize, 4), (try kinds(a, path, "quarantine")).len); +} + +test "request journal: a clean stop quarantines nothing, a clear record lifts one, and an old one lapses" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const body = hello ++ "}"; + const fp = journal_mod.fingerprint("", true, (try json.parse(a, body)).ok); + const hex = std.fmt.bytesToHex(fp, .lower); + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try inFlight(j, a, body, ""); + j.stopped(); + } + for (0..2) |_| { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try inFlight(j, a, body, ""); + } + try t.expectEqual(@as(usize, 1), (try kinds(a, path, "quarantine")).len); // the stopped one was not a crash + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expect(j.quarantined(fp)); + const line = try std.fmt.allocPrint(a, "{{\"version\":1,\"kind\":\"clear\",\"fingerprint\":\"{s}\"}}\n", .{hex}); + try t.expectEqual(@as(isize, @intCast(line.len)), platform.c.write(j.fd, line.ptr, line.len)); + } + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expect(!j.quarantined(fp)); + const old = std.Io.Clock.real.now(t.io).toSeconds() - journal_mod.quarantine_s - 1; + for (0..2) |_| { + const line = try std.fmt.allocPrint(a, "{{\"version\":1,\"kind\":\"quarantine\",\"id\":\"x\",\"fingerprint\":\"{s}\",\"at\":{d}}}\n", .{ hex, old }); + try t.expectEqual(@as(isize, @intCast(line.len)), platform.c.write(j.fd, line.ptr, line.len)); + } + } + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expect(!j.quarantined(fp)); +} + +test "request journal: a torn last line is cut, an unreadable one passed over, and a second server refused" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expectError(error.JournalBusy, Journal.open(t.allocator, t.io, path)); + try t.expectEqual(@as(isize, 4), platform.c.write(j.fd, "bad\n", 4)); + try t.expectEqual(@as(isize, 8), platform.c.write(j.fd, "{\"kind\":", 8)); + } + const j = try Journal.open(t.allocator, t.io, path); + j.stopped(); + j.close(); + const raw = try std.Io.Dir.cwd().readFileAlloc(t.io, path, a, .limited(1 << 20)); + try t.expect(std.mem.startsWith(u8, raw, "bad\n{\"version\":1,\"kind\":\"stop\"")); + if (builtin.os.tag == .windows) return; // refusal by mode bits and links; NTFS keeps access in ACLs + try tmp.dir.writeFile(t.io, .{ .sub_path = "shared.jsonl", .data = "" }); + try tmp.dir.setFilePermissions(t.io, "shared.jsonl", .fromMode(0o644), .{}); + try t.expectError(error.JournalPermissions, Journal.open(t.allocator, t.io, try journalPath(a, tmp, "shared.jsonl"))); + try tmp.dir.symLink(t.io, "requests.jsonl", "link.jsonl", .{}); + try t.expectError(error.JournalOpen, Journal.open(t.allocator, t.io, try journalPath(a, tmp, "link.jsonl"))); +} + +test "request journal: files rotate at their cap, four are kept, and a start in a rotated file is still flagged" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const body = hello ++ "}"; + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + j.limit = 2048; + try inFlight(j, a, body, ""); + for (0..40) |_| j.append(a, .{ .object = try j.record(a, "note", "filler") }); // records recovery ignores + } + try t.expectEqual(@as(usize, 1), (try kinds(a, try journalPath(a, tmp, "requests.jsonl.1"), "start")).len); + { + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + try t.expectEqual(@as(usize, 1), (try kinds(a, path, "quarantine")).len); + j.limit = 2048; + for (0..400) |_| j.append(a, .{ .object = try j.record(a, "note", "filler") }); + try t.expectEqual(@as(u64, 0), j.lost.load(.monotonic)); + } + for ([_][]const u8{ "requests.jsonl", "requests.jsonl.1", "requests.jsonl.2", "requests.jsonl.3" }) |name| { + try t.expect((try tmp.dir.statFile(t.io, name, .{})).size <= 2048); + } + try t.expectError(error.FileNotFound, tmp.dir.statFile(t.io, "requests.jsonl.4", .{})); +} + +test "request journal: a write that fails loses its record and the request still completes the same" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const path = try journalPath(a, tmp, "requests.jsonl"); + const j = try Journal.open(t.allocator, t.io, path); + defer j.close(); + const writable = j.fd; + j.fd = platform.c.open(try a.dupeSentinel(u8, path, 0), .{ .ACCMODE = .RDONLY }); // writes fail, as on a full disk + defer { + _ = platform.c.close(j.fd); + j.fd = writable; + } + var fake: Fake = .{}; + var text: TestText = .{}; + const srv = try serve(&fake, &text, j); + defer srv.deinit(); + const wire = try ask(srv, a, hello ++ ",\"seed\":5}", null); + try t.expectEqual(@as(u16, 200), wire.status); + try t.expectEqualStrings("5", wire.last.get("choices").?.array[0].get("message").?.strField("content").?); + try t.expect(j.lost.load(.monotonic) >= 3); +} + +test "request journal: off, a request's output path is the caller's and its tokens are a journaled one's" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + var wire: Wire = .{ .a = a }; + const parent = wire.out(); + var off: Trace = .{ .journal = null, .a = a, .id = "x", .parent = parent }; + try t.expect(off.out().vt == parent.vt and off.out().ctx == parent.ctx); + try t.expect(!off.begin((try json.parse(a, hello ++ "}")).ok, true, "")); + var fake: Fake = .{}; + var text: TestText = .{}; + const j = try Journal.open(t.allocator, t.io, try journalPath(a, tmp, "requests.jsonl")); + defer j.close(); + var replies: [2]Wire = undefined; + for ([_]?*Journal{ null, j }, &replies) |journal, *reply| { + const srv = try serve(&fake, &text, journal); + defer srv.deinit(); + reply.* = try ask(srv, a, hello ++ ",\"seed\":77,\"stream\":true}", null); + } + try t.expectEqualStrings(replies[0].tokens(), replies[1].tokens()); + try t.expect(json.equal(replies[0].last.get("choices").?, replies[1].last.get("choices").?)); +} diff --git a/zig/src/server/request_log.zig b/zig/src/server/request_log.zig index 9ce6ed35895..394dc63e83c 100644 --- a/zig/src/server/request_log.zig +++ b/zig/src/server/request_log.zig @@ -8,7 +8,7 @@ const Value = json.Value; const Allocator = std.mem.Allocator; /// The body with every image part's URL replaced, the rest kept. -fn redact(a: Allocator, v: Value) Allocator.Error!Value { +pub fn redact(a: Allocator, v: Value) Allocator.Error!Value { switch (v) { .array => |items| { const out = try a.alloc(Value, items.len); @@ -53,7 +53,7 @@ pub fn append(a: Allocator, path: []const u8, body: Value) void { } /// A regular file no one but its owner can read or write: a name in a shared directory can be someone else's file. -fn private(fd: platform.c.fd_t) bool { +pub fn private(fd: platform.c.fd_t) bool { if (builtin.os.tag == .windows) return true; // NTFS keeps access in ACLs, not mode bits const m = meta(fd, null) orelse return false; return m.mode & 0o170000 == 0o100000 and m.mode & 0o077 == 0; diff --git a/zig/src/server/request_trace.zig b/zig/src/server/request_trace.zig new file mode 100644 index 00000000000..92cc7e36857 --- /dev/null +++ b/zig/src/server/request_trace.zig @@ -0,0 +1,182 @@ +//! One request's journal records: its start before any work, its resolved settings, then its reply in one finish. +const std = @import("std"); +const api = @import("engine_api"); +const json = @import("json"); +const openai = @import("openai.zig"); +const journal_mod = @import("request_journal.zig"); +const Journal = journal_mod.Journal; +const Allocator = std.mem.Allocator; +const Value = json.Value; +const Sha256 = std.crypto.hash.sha2.Sha256; + +/// The reply bytes a finish keeps for replay; a longer reply keeps its size, SHA-256 and token hash. +pub const reply_limit: usize = 4 << 20; +pub const quarantine_message = "this request was in flight when the server crashed and is quarantined; its operator can clear it"; + +pub const Trace = struct { + journal: ?*Journal, + a: Allocator, + id: []const u8, + parent: openai.Out, + status: u16 = 0, + stream: bool = false, + done: bool = false, + failed: bool = false, + started: bool = false, + quarantined: bool = false, + whole: bool = true, // every reply byte is kept + size: usize = 0, + sha: Sha256 = .init(.{}), + kept: std.ArrayList(u8) = .empty, + token_sha256: ?[]const u8 = null, + + /// Writes the start before any work; true when this key's same request is quarantined, which the caller refuses. + pub fn begin(t: *Trace, body: Value, chat: bool, key: []const u8) bool { + const j = t.journal orelse return false; + const fp = journal_mod.fingerprint(key, chat, body); + t.started = true; + t.quarantined = j.quarantined(fp); + t.start(j, body, chat, fp) catch {}; + return t.quarantined; + } + + fn start(t: *Trace, j: *Journal, body: Value, chat: bool, fp: journal_mod.Fingerprint) Allocator.Error!void { + const a = t.a; + const o = try j.record(a, "start", t.id); + try o.put(a, "path", .{ .string = if (chat) "/v1/chat/completions" else "/v1/completions" }); + const hex = std.fmt.bytesToHex(fp, .lower); + try o.put(a, "fingerprint", .{ .string = try a.dupe(u8, &hex) }); + try o.put(a, "seed", body.get("seed") orelse .null); + const redacted = try @import("request_log.zig").redact(a, body); + var buf: [1024]u8 = undefined; + var counted: std.Io.Writer.Discarding = .init(&buf); + json.write(&counted.writer, redacted, .{ .compact = true }) catch {}; + // a body too large for one record keeps its size; replay then needs --body + if (counted.fullCount() + 4096 <= journal_mod.record_limit) try o.put(a, "body", redacted) else try o.put(a, "body_bytes", try json.intValue(a, counted.fullCount())); + j.append(a, .{ .object = o }); + } + + /// The settings the server resolved before the engine saw the request; its seed is what a replay needs. + pub fn prepared(t: *Trace, request: *const api.Request, thinking: bool, effort: ?[]const u8) void { + const j = t.journal orelse return; + t.settings(j, request, thinking, effort) catch {}; + } + + fn settings(t: *Trace, j: *Journal, request: *const api.Request, thinking: bool, effort: ?[]const u8) Allocator.Error!void { + const a = t.a; + const o = try j.record(a, "prepared", t.id); + if (request.sampling) |s| { + try o.put(a, "seed", try json.intValue(a, s.seed)); + try o.put(a, "temperature", .{ .float = s.temperature }); + try o.put(a, "top_k", try json.intValue(a, s.top_k)); + try o.put(a, "top_p", .{ .float = s.top_p }); + try o.put(a, "min_p", .{ .float = s.min_p }); + } else try o.put(a, "seed", .null); + try o.put(a, "max_tokens", try json.intValue(a, request.max_tokens)); + try o.put(a, "drafts", .{ .bool = request.drafts }); + try o.put(a, "thinking", .{ .bool = thinking }); + try o.put(a, "reasoning_effort", if (effort) |s| .{ .string = s } else .null); + try o.put(a, "prompt_tokens", try json.intValue(a, request.prompt.len)); + const sha = @import("tokens.zig").tokenSha256(request.prompt); + try o.put(a, "prompt_sha256", .{ .string = try a.dupe(u8, &sha) }); + j.append(a, .{ .object = o }); + } + + /// The finish: status, outcome and the reply as the chat route produced it, written once the reply has gone. + pub fn finish(t: *Trace) void { + const j = t.journal orelse return; + if (!t.started) return; + t.end(j) catch {}; + } + + fn end(t: *Trace, j: *Journal) Allocator.Error!void { + const a = t.a; + const o = try j.record(a, "finish", t.id); + try o.put(a, "status", try json.intValue(a, t.status)); + try o.put(a, "stream", .{ .bool = t.stream }); + const outcome = if (t.quarantined) "quarantined" else if (t.failed) "failed" else if (!t.done) "cancelled" else if (t.status >= 400) "refused" else "completed"; + try o.put(a, "outcome", .{ .string = outcome }); + try o.put(a, "reply_bytes", try json.intValue(a, t.size)); + const hex = std.fmt.bytesToHex(t.sha.finalResult(), .lower); + try o.put(a, "reply_sha256", .{ .string = try a.dupe(u8, &hex) }); + try o.put(a, "token_sha256", if (t.token_sha256) |s| .{ .string = s } else .null); + if (t.whole) { + const codec = std.base64.standard.Encoder; + const encoded = try a.alloc(u8, codec.calcSize(t.kept.items.len)); + try o.put(a, "reply_base64", .{ .string = codec.encode(encoded, t.kept.items) }); + } + j.append(a, .{ .object = o }); + } + + /// The quarantine refusal, a 400 a client should not retry, sent and journaled like any other reply. + pub fn refuse(t: *Trace, id: []const u8) void { + const cx: @import("errors.zig").Cx = .{ .a = t.a, .message = quarantine_message, .code = "request_quarantined" }; + var buf: [256]u8 = undefined; + @import("log.zig").line("{s}", .{@import("log.zig").refused(&buf, id, cx.message)}); + const body = openai.errorBody(t.a, &cx, null) catch return; + reply(t, cx.status(), openai.wrapError(t.a, body) catch return); + } + + /// The parent itself when the journal is off, so a request runs exactly as it would without one. + pub fn out(t: *Trace) openai.Out { + if (t.journal == null) return t.parent; + return .{ .ctx = t, .vt = &.{ .open = open, .event = event, .reply = reply, .keepalive = keepalive } }; + } + + fn keep(t: *Trace, bytes: []const u8) void { + t.sha.update(bytes); + t.size += bytes.len; + if (!t.whole) return; + if (t.kept.items.len + bytes.len > reply_limit) return t.drop(); + t.kept.appendSlice(t.a, bytes) catch t.drop(); + } + + fn keepJson(t: *Trace, value: Value) void { + var scratch: std.heap.ArenaAllocator = .init(t.journal.?.gpa); + defer scratch.deinit(); + t.keep(json.stringify(scratch.allocator(), value, .{}) catch return t.drop()); + if (value.get("tensorfold")) |runtime| if (runtime.strField("token_sha256")) |s| { + t.token_sha256 = t.a.dupe(u8, s) catch null; + }; + } + + fn drop(t: *Trace) void { + t.whole = false; + t.kept.clearAndFree(t.a); + } + + fn open(ctx: *anyopaque, n: usize) error{Closed}!void { + const t: *Trace = @ptrCast(@alignCast(ctx)); + t.stream = true; + t.status = 200; + return t.parent.vt.open(t.parent.ctx, n); + } + + fn event(ctx: *anyopaque, payload: ?Value) error{Closed}!void { + const t: *Trace = @ptrCast(@alignCast(ctx)); + if (payload) |p| { + if (p.has("error")) t.failed = true; + t.keep("data: "); + t.keepJson(p); + t.keep("\n\n"); + } else t.keep("data: [DONE]\n\n"); + try t.parent.vt.event(t.parent.ctx, payload); + if (payload == null) t.done = true; + } + + fn reply(ctx: *anyopaque, status: u16, value: Value) void { + const t: *Trace = @ptrCast(@alignCast(ctx)); + t.status = status; + if (status >= 500) t.failed = true; + t.keepJson(value); + t.parent.vt.reply(t.parent.ctx, status, value); + t.done = true; + } + + fn keepalive(ctx: *anyopaque) error{Closed}!void { + const t: *Trace = @ptrCast(@alignCast(ctx)); + const send = t.parent.vt.keepalive orelse return; + t.keep(": keepalive\n\n"); + return send(t.parent.ctx); + } +}; diff --git a/zig/src/server/root.zig b/zig/src/server/root.zig index 1ed3ed9f0bc..7069ccb3fc5 100644 --- a/zig/src/server/root.zig +++ b/zig/src/server/root.zig @@ -122,6 +122,7 @@ test { _ = @import("process_resident.zig"); _ = @import("log.zig"); _ = @import("request_log.zig"); + _ = @import("request_journal_test.zig"); _ = @import("messages.zig"); _ = @import("pdf.zig"); _ = @import("pdf_flags_test.zig"); @@ -319,6 +320,9 @@ test { _ = @import("open_connections_route_test.zig"); _ = @import("request_starts_turns_test.zig"); _ = @import("thinking_request_test.zig"); + _ = @import("voice_cli.zig"); + _ = @import("drama_voice_store.zig"); + if (comptime @import("builtin").os.tag != .windows) _ = @import("speech_voice_http_test.zig"); // over a Unix socket pair _ = @import("grafana_dashboard_test.zig"); _ = @import("ocr/types_test.zig"); _ = @import("ocr/geometry_test.zig"); diff --git a/zig/src/server/routes.zig b/zig/src/server/routes.zig index 37dd3f8e58b..820072b4a30 100644 --- a/zig/src/server/routes.zig +++ b/zig/src/server/routes.zig @@ -23,6 +23,7 @@ const slide = @import("slide.zig"); const recall = @import("recall_routes.zig"); const imprint = @import("imprint_routes.zig"); const slide_forget = @import("slide_forget.zig"); +const voice_routes = @import("drama_voice_routes.zig"); const Server = @import("server.zig").Server; const request_gate = @import("request_gate.zig"); const admission = @import("request_admission.zig"); @@ -33,6 +34,8 @@ const Allocator = std.mem.Allocator; /// DELETE's per-fact route: the fact's id follows it. const fact_path = "/v1/slide/fact/"; +/// DELETE's per-voice route under --manage-voices: the voice's name follows it. +const voice_path = "/v1/voices/"; pub fn dispatch(srv: *Server, conn: *Conn, a: Allocator) void { const m = conn.method; @@ -51,6 +54,7 @@ pub fn dispatch(srv: *Server, conn: *Conn, a: Allocator) void { if (std.mem.startsWith(u8, route, fact_path)) return slide_forget.route(srv, conn, a, route[fact_path.len..]); if (std.mem.eql(u8, route, recall.path)) return recall.empty(srv, conn, a); if (std.mem.eql(u8, route, "/v1/imprint")) return imprint.forget(srv, conn, a); + if (srv.config.voice.manage and std.mem.startsWith(u8, route, voice_path)) return voice_routes.delete(srv, conn, a, route[voice_path.len..]); return responses.delete(srv, conn, a, responses.route(route)); } const message = std.fmt.allocPrint(a, "Unsupported method ({s})", .{http_conn.pyRepr(a, m) catch m}) catch return; @@ -88,7 +92,7 @@ fn get(srv: *Server, conn: *Conn, a: Allocator) void { const route = auth.routePath(conn.path); if (std.mem.eql(u8, route, "/v1/voices")) { if (srv.info.speech == null) return unknown(conn, a); - const value = @import("drama_voice.zig").listing(a, srv.voices) catch return; + const value = srv.voices.listing(a) catch return; return sendValue(conn, a, 200, value); } if (std.mem.eql(u8, route, "/memory") or std.mem.eql(u8, route, "/v1/memory")) @@ -132,6 +136,7 @@ fn post(srv: *Server, conn: *Conn, a: Allocator) void { } for (tokens.paths) |r| if (std.mem.eql(u8, route, r)) return tokens.post(srv, conn, a, route); const is_speech = std.mem.eql(u8, route, "/v1/audio/speech"); + const is_voices = srv.config.voice.manage and std.mem.eql(u8, route, "/v1/voices"); const is_images = std.mem.eql(u8, route, "/v1/images/generations"); const is_embedding = std.mem.eql(u8, route, "/v1/embeddings"); const is_anthropic = anthropic.route(conn.path); @@ -147,7 +152,7 @@ fn post(srv: *Server, conn: *Conn, a: Allocator) void { const is_ollama_generate = std.mem.eql(u8, route, "/api/generate"); const is_ollama_embed = std.mem.eql(u8, route, "/api/embed"); const is_ollama_show = std.mem.eql(u8, route, "/api/show"); - if (!is_ocr and !is_rerank and !is_embedding and !is_speech and !is_images and !is_slide and imprint_op == null and !is_anthropic and !is_responses and !is_decisions and !is_systemone and !is_chat and !is_ollama_chat and !is_ollama_generate and !is_ollama_embed and !is_ollama_show and !std.mem.endsWith(u8, route, "/completions")) { + if (!is_voices and !is_ocr and !is_rerank and !is_embedding and !is_speech and !is_images and !is_slide and imprint_op == null and !is_anthropic and !is_responses and !is_decisions and !is_systemone and !is_chat and !is_ollama_chat and !is_ollama_generate and !is_ollama_embed and !is_ollama_show and !std.mem.endsWith(u8, route, "/completions")) { discardBody(conn, a); return unknown(conn, a); } @@ -158,6 +163,7 @@ fn post(srv: *Server, conn: *Conn, a: Allocator) void { defer entered.held.release(); if (entered.refusal) |refusal| return refuse(conn, a, is_anthropic, refusal); if (std.mem.eql(u8, route, "/v1/audio/speech")) return speech.post(srv, conn, a) catch {}; + if (is_voices) return voice_routes.post(srv, conn, a); if (is_images) return images.post(srv, conn, a) catch {}; if (is_embedding) return embeddings.post(srv, conn, a); if (is_ollama_chat) return ollama.chat(srv, conn, a); diff --git a/zig/src/server/serve.zig b/zig/src/server/serve.zig index 994206ed8bf..d06e5753a86 100644 --- a/zig/src/server/serve.zig +++ b/zig/src/server/serve.zig @@ -179,14 +179,18 @@ pub fn run(gpa: Allocator, io: std.Io, args: cli.Args, s: Setup) u8 { std.debug.print("tensorfold: TENSORFOLD_WIRE: expected spark or native\n", .{}); return 1; }; + const journal = if (env(s, "TENSORFOLD_REQUEST_JOURNAL")) |path| @import("request_journal.zig").Journal.open(gpa, io, path) catch |e| { + std.debug.print("tensorfold: TENSORFOLD_REQUEST_JOURNAL {s}: {s}\n", .{ path, @import("request_journal.zig").why(e) }); + return 1; + } else null; + defer if (journal) |j| j.close(); // after the server's own deinit, which runs first const config: server_mod.Config = .{ .browser = .{ .allowed_hosts = args.allowed_host, .allowed_origins = args.allowed_origin, .cors_origins = args.cors_origin }, .allowed_controls = args.allowed_controls, .redraw = args.redraw, .served_name = s.served, .model_dir = s.model_dir, - .voices_dir = args.voices, - .default_voice = args.default_voice, + .voice = .{ .dir = args.voices, .default = args.default_voice, .inline_voices = args.voice.inline_voices, .manage = args.voice.manage }, .model_ids = ids.items, .background_ids = backgrounds, .default_max_tokens = args.max_tokens, @@ -213,6 +217,7 @@ pub fn run(gpa: Allocator, io: std.Io, args: cli.Args, s: Setup) u8 { .prompt_seed = args.prompt_seed, .sse_keepalive_s = keepalive_s, .request_log = env(s, "TENSORFOLD_REQUEST_LOG"), + .journal = journal, .phase_metrics = if (env(s, "TENSORFOLD_PHASE_METRICS")) |v| std.mem.eql(u8, v, "1") else false, .spark_stats = spark_stats, .dashboard = args.dashboard, @@ -296,6 +301,7 @@ pub fn run(gpa: Allocator, io: std.Io, args: cli.Args, s: Setup) u8 { @import("startup_receipt.zig").ready(port); while (!stop_requested.load(.acquire)) std.Io.sleep(io, .fromMilliseconds(50), .awake) catch {}; drain(srv, io, s.stop, drain_s); + if (journal) |j| j.stopped(); // a stop, not a crash: requests still open are not quarantined accept_stop.store(true, .release); accept.join(); lis.close(); diff --git a/zig/src/server/server.zig b/zig/src/server/server.zig index 3bbb9bdfda9..1fcc94daf0e 100644 --- a/zig/src/server/server.zig +++ b/zig/src/server/server.zig @@ -31,7 +31,6 @@ const Cx = errors.Cx; const Allocator = std.mem.Allocator; /// auto compacts near the window. fraction compacts past that share of it. pub const CompactAt = union(enum) { auto, fraction: f64 }; - pub const Identity = @import("identity.zig").Identity; /// The most a kept-alive connection's arena keeps between requests; a longer request's memory goes back. pub const connection_arena_limit: usize = 1 << 20; @@ -43,8 +42,8 @@ pub const Config = struct { sse_keepalive_s: f64 = 15, served_name: []const u8, model_dir: []const u8 = "", - voices_dir: ?[]const u8 = null, - default_voice: []const u8 = "default", + /// --voices, --default-voice, --request-voices and --manage-voices; the last two off keep the startup catalog. + voice: @import("voice_cli.zig").Config = .{}, /// The served name first, then aliases, without repeats. model_ids: []const []const u8, /// Ids a request may name for background priority by default (--name-priority); each is in model_ids. @@ -79,6 +78,7 @@ pub const Config = struct { prompt_seed: bool = false, // --prompt-seed: historical prompt-keyed sampling when a request omits its seed /// TENSORFOLD_REQUEST_LOG: where chat and completion bodies are appended; null: nowhere. request_log: ?[]const u8 = null, + journal: ?*@import("request_journal.zig").Journal = null, // serve owns TENSORFOLD_REQUEST_JOURNAL /// TENSORFOLD_PHASE_METRICS=1: /metrics adds the queue phase's histogram; unset, its families are as before. phase_metrics: bool = false, /// The Spark server's keys in each reply's ``tensorfold`` block (spark_wire.zig): DeepSeek-V4, or TENSORFOLD_WIRE. @@ -137,7 +137,9 @@ pub const Server = struct { info: api.Info, text: model_text.Text, config: Config, - voices: []const @import("drama_voice.zig").Voice = &.{}, + voices: @import("drama_voice_store.zig").Store = .{}, + /// An engine-owned voice catalog in its own order (`SpeechRequest.voice` indexes it); the store's sort must not reorder it. + engine_voices: []const @import("drama_voice.zig").Voice = &.{}, keys: ?*auth.Store, late_system: []const u8 = "system", needs_user_after_tool: bool = false, @@ -206,17 +208,19 @@ pub const Server = struct { return error.InvalidVisionMarkers; }; srv.video_decoder = @import("input_types.zig").decodes(srv.info.vision); // no decoder: video parts are a 400, never a 500 + srv.voices = .{ .gpa = gpa, .io = io, .dir = config.voice.dir }; + if (srv.info.speech == null and (config.voice.dir != null or config.voice.inline_voices or config.voice.manage)) return error.VoicesRequireSpeech; const engine_voices = if (srv.info.speech) |sp| sp.voices else &.{}; if (engine_voices.len > 0) { + // the engine's own catalog answers by index: inline objects and admin edits the store never reaches it + if (config.voice.inline_voices or config.voice.manage) return error.EngineOwnedVoices; // the server's own copy: an idle unload frees the engine's names while /v1/voices still lists them const voices = try srv.arena.allocator().alloc(@import("drama_voice.zig").Voice, engine_voices.len); for (engine_voices, voices) |name, *voice| voice.* = .{ .name = try srv.arena.allocator().dupe(u8, name), .references = &.{} }; - srv.voices = voices; - } else if (config.voices_dir) |dir| { - if (srv.info.speech == null) return error.VoicesRequireSpeech; - srv.voices = try @import("drama_voice.zig").load(srv.arena.allocator(), io, dir); - } - _ = try @import("drama_voice.zig").select(srv.voices, config.default_voice, "default"); + srv.engine_voices = voices; + try srv.voices.swap(voices); + } else if (config.voice.dir) |dir| try srv.voices.load(dir); + _ = try srv.voices.select(srv.arena.allocator(), config.voice.default, "default"); if (!srv.info.capability(.text_generation)) { if (config.cortheon) return error.CortheonRequiresTextGeneration; return srv; @@ -273,6 +277,7 @@ pub const Server = struct { srv.stopKeepalive(); if (srv.grammars) |g| g.close(); srv.metrics.deinit(); + srv.voices.deinit(); srv.arena.deinit(); srv.store.deinit(); srv.slide.deinit(); diff --git a/zig/src/server/speech.zig b/zig/src/server/speech.zig index 5fe4426df91..608588032eb 100644 --- a/zig/src/server/speech.zig +++ b/zig/src/server/speech.zig @@ -82,9 +82,10 @@ fn listed(names: []const []const u8, key: []const u8) bool { } /// Refuses what this route would drop: unknown fields, set modifiers, non-strings, a bad ``stream``/``stream_format``. -fn checkFields(cx: *Cx, body: Value) errors.Refused!void { +fn checkFields(cx: *Cx, body: Value, inline_voices: bool) errors.Refused!void { for (body.object.keys(), body.object.values()) |key, value| { if (listed(&served_fields, key)) { + if (value == .object and inline_voices and std.mem.eql(u8, key, "voice")) continue; // an attested voice object if (value != .string) return cx.fail(.request, "{s} must be a string", .{key}); } else if (std.mem.eql(u8, key, "stream")) { if (value != .bool and value != .null) return cx.refuse("stream must be a boolean"); @@ -111,7 +112,7 @@ fn responseFormat(cx: *Cx, value: []const u8) errors.Refused!Format { /// Every check that can refuse the request, then its prompt ids, before anything reaches the engine. fn prepare(srv: *Server, cx: *Cx, sp: api.SpeechInfo, raw: Value) errors.Refused!Plan { if (raw != .object) return cx.refuse("speech request body must be a JSON object"); - try checkFields(cx, raw); + try checkFields(cx, raw, srv.config.voice.inline_voices); const sampling = try speech_sampling.parse(cx, raw); const model = raw.strField("model") orelse return cx.fail(.request, "model is required: send {s}", .{srv.config.served_name}); if (!listed(srv.config.model_ids, model)) @@ -132,20 +133,15 @@ fn prepare(srv: *Server, cx: *Cx, sp: api.SpeechInfo, raw: Value) errors.Refused // the engine draws with its own fixed flow temperature: Drama's sampling would be accepted and ignored for ([_][]const u8{ "temperature", "top_p", "top_k" }) |key| if (raw.field(key) != null) return cx.fail(.request, "{s} is not supported by this model", .{key}); - const named = if (voice.len == 0 or std.ascii.eqlIgnoreCase(voice, "default")) srv.config.default_voice else voice; - const index = if (std.mem.eql(u8, named, "default")) 0 else indexOf(srv.voices, named) orelse { + const named = if (voice.len == 0 or std.ascii.eqlIgnoreCase(voice, "default")) srv.config.voice.default else voice; + const index = if (std.mem.eql(u8, named, "default")) 0 else indexOf(srv.engine_voices, named) orelse { const name = try pyrepr.repr(cx.a, .{ .string = named }); return cx.fail(.request, "unknown voice {s}; see /v1/voices", .{name}); }; const prompt = try codepoints(cx.a, input); return .{ .input = input, .prompt = prompt, .sampling = sampling, .format = format, .stream = stream, .voice = index }; } - const refs = @import("drama_voice.zig").select(srv.voices, srv.config.default_voice, voice) catch { - const name = try pyrepr.repr(cx.a, .{ .string = voice }); - if (srv.config.voices_dir != null) - return cx.fail(.request, drama_prompt.error_prefix ++ " unknown voice {s}; see /v1/voices", .{name}); - return cx.fail(.request, drama_prompt.error_prefix ++ " unknown voice {s}; only the default voice is supported", .{name}); - }; + const refs = try voiceRefs(srv, cx, raw); if (try @import("drama_voice.zig").requestPrompt(cx, srv.text, sp, input, refs)) |made| return .{ .input = input, .prompt = made.prompt, .frames = made.frames, .refs = refs, .reference_rows = made.reference_rows, .sampling = sampling, .format = format, .stream = stream }; const prompt = try promptOf(srv, cx, sp, input); return .{ .input = input, .prompt = prompt, .sampling = sampling, .format = format, .stream = stream }; @@ -160,12 +156,32 @@ fn indexOf(voices: []const @import("drama_voice.zig").Voice, name: []const u8) ? /// The input's Unicode code points: the prompt of an engine that names its voices itself. fn codepoints(a: Allocator, input: []const u8) ![]const u32 { const out = try a.alloc(u32, std.unicode.utf8CountCodepoints(input) catch unreachable); - var it = std.unicode.Utf8Iterator{ .bytes = input, .i = 0 }; + var it = std.unicode.Utf8View.initUnchecked(input).iterator(); var n: usize = 0; while (it.nextCodepoint()) |cp| : (n += 1) out[n] = cp; return out; } +/// The request's references: an attested inline voice under --request-voices, else the named catalog voice's, copied. +fn voiceRefs(srv: *Server, cx: *Cx, raw: Value) errors.Refused![]const @import("drama_prompt").Reference { + if (raw.get("voice")) |value| if (value == .object) { + if (raw.get("speaker") != null) return cx.refuse("an inline voice object takes no speaker"); + return @import("drama_voice.zig").parseDoc(cx.a, value) catch |e| switch (e) { + error.OutOfMemory => error.OutOfMemory, + error.MissingAttestation => cx.refuse("an inline voice needs source.kind synthetic, self or consented and a source.note"), + else => cx.refuse("an inline voice is a drama3-http-voice/1 object with 1 to 4 references"), + }; + }; + const voice = raw.strField("voice") orelse raw.strField("speaker") orelse "default"; + return srv.voices.select(cx.a, srv.config.voice.default, voice) catch |e| { + if (e == error.OutOfMemory) return error.OutOfMemory; + const name = try pyrepr.repr(cx.a, .{ .string = voice }); + if (srv.config.voice.dir != null or srv.config.voice.manage) + return cx.fail(.request, drama_prompt.error_prefix ++ " unknown voice {s}; see /v1/voices", .{name}); + return cx.fail(.request, drama_prompt.error_prefix ++ " unknown voice {s}; only the default voice is supported", .{name}); + }; +} + /// The prompt ids of a valid UTF-8 input, refused when it cannot be spoken or is too long. fn promptOf(srv: *Server, cx: *Cx, sp: api.SpeechInfo, input: []const u8) errors.Refused![]const u32 { if (try drama_prompt.problem(cx.a, input)) |message| return cx.refuse(message); @@ -491,9 +507,9 @@ test "fields: unknown ones are refused even when null, modifiers when set" { var cx: Cx = .{ .a = a }; const body = (try json.parse(a, case[0])).ok; if (case[1].len == 0) { - try checkFields(&cx, body); + try checkFields(&cx, body, false); } else { - try std.testing.expectError(error.Refused, checkFields(&cx, body)); + try std.testing.expectError(error.Refused, checkFields(&cx, body, false)); try std.testing.expectEqualStrings(case[1], cx.message); } } diff --git a/zig/src/server/speech_stream_test.zig b/zig/src/server/speech_stream_test.zig index 6c389f88fa3..fd3cf7579e7 100644 --- a/zig/src/server/speech_stream_test.zig +++ b/zig/src/server/speech_stream_test.zig @@ -192,7 +192,7 @@ pub const Served = struct { s.* = .{ .srv = undefined, .client = pair[0], .route_fd = pair[1], .route = undefined, .write_ms = write_ms, .probe = probe }; s.srv = try server.Server.init(gpa, std.testing.io, script.engine(), s.text.text(), config, null); if (probe) |p| p.srv = s.srv; - if (script.voices.len > 0) s.srv.voices = script.voices; + if (script.voices.len > 0) try s.srv.voices.swap(script.voices); if (script.output_full) s.srv.speech_inflight.store(s.srv.info.lanes, .release); var head: [256]u8 = undefined; const method_path = if (script.get_voices) "GET /v1/voices" else "POST /v1/audio/speech"; diff --git a/zig/src/server/speech_voice_http_test.zig b/zig/src/server/speech_voice_http_test.zig new file mode 100644 index 00000000000..1b4b23135bc --- /dev/null +++ b/zig/src/server/speech_voice_http_test.zig @@ -0,0 +1,238 @@ +//! Real sockets: --manage-voices adds and deletes catalog voices for admin keys, --request-voices takes inline voices. +const std = @import("std"); +const api = @import("engine_api"); +const server = @import("server.zig"); +const auth = @import("auth.zig"); +const listener = @import("listener.zig"); +const voice = @import("drama_voice.zig"); +const wire = @import("speech_stream_test.zig"); +const KeyFile = @import("auth_scope_test.zig").KeyFile; +const posix = @import("sys").posix; +const t = std.testing; +const Allocator = std.mem.Allocator; + +const tone = + \\{"format":"drama3-http-voice/1","source":{"kind":"synthetic","note":"Generated fixture tone."}, + \\"description":"Warm fixture.","references":[{"text":"A small cloud passes.","codes":[[7,1,2,3,4,5,6,7,8,9]]}]} +; + +const Fake = struct { + hold: std.atomic.Value(bool) = .init(false), + held: std.atomic.Value(bool) = .init(false), + encodes: std.atomic.Value(u32) = .init(0), + frames: std.ArrayList([11]i32) = .empty, + + fn engine(e: *Fake) api.Engine { + return .{ .ctx = e, .vtable = &.{ .info = info, .submit = submit, .submit_speech = speech, .cancel = cancel, .status = status, .memory = memory, .encode_voice = encode } }; + } + fn info(_: *anyopaque) api.Info { + return .{ .text_generation = false, .speech = .{ .sample_rate = 44100, .frame_length = 2048, .max_frames = 4, .max_prompt_tokens = 4096 } }; + } + fn speech(ctx: *anyopaque, id: api.Id, request: *const api.SpeechRequest, sink: api.Sink) api.SpeechSubmitError!void { + const e: *Fake = @ptrCast(@alignCast(ctx)); + e.frames.clearRetainingCapacity(); + e.frames.appendSlice(t.allocator, request.frames) catch return error.Busy; + e.held.store(true, .release); + while (e.hold.load(.acquire)) std.Thread.yield() catch {}; + @memset(request.pcm[0..256], 0.125); + request.result.* = .{ .samples = 256, .reason = .stop }; + sink.event(sink.ctx, id, &.{ .finished = .{ .reason = .stop } }); + } + /// Codes from the file's bytes: one row a byte past the 44-byte header, so a test can predict them. + fn encode(ctx: *anyopaque, gpa: Allocator, wav: []const u8) api.EncodeVoiceError![][10]i32 { + const e: *Fake = @ptrCast(@alignCast(ctx)); + _ = e.encodes.fetchAdd(1, .monotonic); + if (wav.len <= 44 or !std.mem.eql(u8, wav[0..4], "RIFF")) return error.BadWav; + const codes = try gpa.alloc([10]i32, wav.len - 44); + for (codes, wav[44..]) |*row, byte| row.* = @splat(byte); + return codes; + } + fn submit(_: *anyopaque, _: api.Id, _: *const api.Request, _: api.Sink) api.SubmitError!void { + return error.Closed; + } + fn cancel(_: *anyopaque, _: api.Id) void {} + fn status(_: *anyopaque, out: *api.Status, _: []u32) void { + out.* = .{}; + } + fn memory(_: *anyopaque, _: bool) ?api.Memory { + return null; + } +}; + +const Harness = struct { + srv: *server.Server = undefined, + text: wire.Bytes = .{}, + listener: listener.Listener = undefined, + accept: std.Thread = undefined, + stop: std.atomic.Value(bool) = .init(false), + + fn start(h: *Harness, fake: *Fake, config: server.Config, keys: ?*auth.Store) !void { + h.srv = try server.Server.init(t.allocator, t.io, fake.engine(), h.text.text(), config, keys); + errdefer h.srv.deinit(); + h.listener = try listener.Listener.open(.{ .ip4 = .loopback(0) }); + errdefer h.listener.close(); + h.accept = try std.Thread.spawn(.{}, server.Server.serve, .{ h.srv, h.listener, &h.stop }); + } + fn deinit(h: *Harness) void { + h.stop.store(true, .release); + h.accept.join(); + var waited: usize = 0; + while (h.srv.open_connections.load(.acquire) > 0) : (waited += 1) { + if (waited == 5000) @panic("voice fixture did not quiesce"); + std.Io.sleep(t.io, .fromMilliseconds(1), .awake) catch {}; + } + h.listener.close(); + h.srv.deinit(); + } + /// The whole reply to one request on its own connection. + fn ask(h: *Harness, a: Allocator, method: []const u8, path: []const u8, key: []const u8, body: []const u8) ![]const u8 { + const address: std.Io.net.IpAddress = .{ .ip4 = .loopback(h.listener.port()) }; + var storage: std.Io.Threaded.PosixAddress = undefined; + const len = std.Io.Threaded.addressToPosix(&address, &storage); + const rc = posix.system.socket(posix.AF.INET, posix.SOCK.STREAM, 0); + if (posix.errno(rc) != .SUCCESS) return error.Socket; + const fd: posix.socket_t = @intCast(rc); + defer _ = posix.system.close(fd); + if (posix.errno(posix.system.connect(fd, &storage.any, len)) != .SUCCESS) return error.Connect; + const auth_line = if (key.len > 0) try std.fmt.allocPrint(a, "Authorization: Bearer {s}\r\n", .{key}) else ""; + const raw = try std.fmt.allocPrint(a, "{s} {s} HTTP/1.1\r\nHost: localhost\r\n{s}Content-Length: {d}\r\nConnection: close\r\n\r\n{s}", .{ method, path, auth_line, body.len, body }); + var sent: usize = 0; + while (sent < raw.len) { + const n = posix.system.write(fd, raw[sent..].ptr, raw.len - sent); + if (posix.errno(n) != .SUCCESS or n == 0) return error.Write; + sent += @intCast(n); + } + var out: std.ArrayList(u8) = .empty; + var buffer: [4096]u8 = undefined; + while (true) { + var fds = [_]posix.pollfd{.{ .fd = fd, .events = posix.POLL.IN, .revents = 0 }}; + if (try posix.poll(&fds, 5000) == 0) return error.Timeout; + const n = posix.system.read(fd, &buffer, buffer.len); + if (posix.errno(n) != .SUCCESS) return error.Read; + if (n == 0) return out.items; + try out.appendSlice(a, buffer[0..@intCast(n)]); + } + } +}; + +fn expectReply(reply: []const u8, status: []const u8, text: []const u8) !void { + if (!std.mem.startsWith(u8, reply, status) or std.mem.indexOf(u8, reply, text) == null) { + std.debug.print("expected {s} with {s}, got:\n{s}\n", .{ status, text, reply }); + return error.TestUnexpectedResult; + } +} + +fn wavBase64(a: Allocator, samples: []const u8) ![]const u8 { + const wav = try std.mem.concat(a, u8, &.{ "RIFF\x00\x00\x00\x00WAVE", "fmt and data headers stand here.", samples }); + const out = try a.alloc(u8, std.base64.standard.Encoder.calcSize(wav.len)); + return std.base64.standard.Encoder.encode(out, wav); +} + +test "voices HTTP: without --manage-voices and --request-voices every refusal stays as it was" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var fake: Fake = .{}; + defer fake.frames.deinit(t.allocator); + var h: Harness = .{}; + try h.start(&fake, .{ .served_name = "m", .model_ids = &.{"m"}, .keep_warm_s = 0 }, null); + defer h.deinit(); + try expectReply(try h.ask(a, "POST", "/v1/voices", "", "{\"name\":\"tone\"," ++ tone[1..]), "HTTP/1.1 404", "unknown path /v1/voices"); + try expectReply(try h.ask(a, "DELETE", "/v1/voices/tone", "", ""), "HTTP/1.1 404", "no stored response has id None"); + const as_null = try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"hi\",\"voice\":null}"); + const as_object = try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"hi\",\"voice\":" ++ tone ++ "}"); + try expectReply(as_object, "HTTP/1.1 400", "voice must be a string"); + try t.expectEqualStrings(as_null[std.mem.indexOf(u8, as_null, "\r\n\r\n").?..], as_object[std.mem.indexOf(u8, as_object, "\r\n\r\n").?..]); + try t.expectEqual(@as(u32, 0), fake.encodes.load(.monotonic)); +} + +test "voices HTTP: admin keys add and delete voices; a request already running keeps its voice" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var keys_file = try KeyFile.init("app[inference]: infer-secret\nmonitor[read]: read-secret\nops[admin]: admin-secret\n"); + defer keys_file.deinit(); + var problem: []const u8 = ""; + var keys = try auth.Store.init(t.allocator, &.{}, "", keys_file.path, false, &problem); + defer keys.deinit(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + const dir = try std.fmt.allocPrint(a, ".zig-cache/tmp/{s}", .{tmp.sub_path}); + var fake: Fake = .{}; + defer fake.frames.deinit(t.allocator); + var h: Harness = .{}; + try h.start(&fake, .{ .served_name = "m", .model_ids = &.{"m"}, .keep_warm_s = 0, .voice = .{ .dir = dir, .manage = true } }, &keys); + defer h.deinit(); + const add_tone = "{\"name\":\"tone\"," ++ tone[1..]; + for ([_][]const u8{ "infer-secret", "read-secret" }) |key| { + try expectReply(try h.ask(a, "POST", "/v1/voices", key, add_tone), "HTTP/1.1 403", ""); + try expectReply(try h.ask(a, "DELETE", "/v1/voices/tone", key, ""), "HTTP/1.1 403", ""); + } + const admin = "admin-secret"; + try expectReply(try h.ask(a, "POST", "/v1/voices", admin, "{\"name\":\"default\"," ++ tone[1..]), "HTTP/1.1 400", "not default"); + try expectReply(try h.ask(a, "POST", "/v1/voices", admin, "{\"name\":\"x\",\"format\":\"drama3-http-voice/1\",\"references\":[{\"text\":\"A.\",\"codes\":[[1,2,3,4,5,6,7,8,9,10]]}]}"), "HTTP/1.1 400", "source.kind"); + const unattested_wav = try std.fmt.allocPrint(a, "{{\"name\":\"clone\",\"text\":\"A small cloud passes.\",\"audio\":\"{s}\"}}", .{try wavBase64(a, "\x05\x06")}); + try expectReply(try h.ask(a, "POST", "/v1/voices", admin, unattested_wav), "HTTP/1.1 400", "source.kind"); + try t.expectEqual(@as(u32, 0), fake.encodes.load(.monotonic)); // refused before the codec ran + try expectReply(try h.ask(a, "POST", "/v1/voices", admin, add_tone), "HTTP/1.1 201", "\"added\": true"); + try expectReply(try h.ask(a, "POST", "/v1/voices", admin, add_tone), "HTTP/1.1 200", "\"added\": false"); + const written = try voice.parse(a, try tmp.dir.readFileAlloc(t.io, "tone.json", a, .limited(voice.max_file_bytes))); + try t.expectEqualStrings("A small cloud passes.", written[0].transcript); + try t.expectEqualSlices([10]i32, (try voice.parse(a, tone))[0].codes, written[0].codes); + const wav_body = try std.fmt.allocPrint(a, "{{\"name\":\"clone\",\"text\":\"A small cloud passes.\",\"source\":{{\"kind\":\"self\",\"note\":\"My own voice.\"}},\"audio\":\"{s}\"}}", .{try wavBase64(a, "\x05\x06")}); + try expectReply(try h.ask(a, "POST", "/v1/voices", admin, wav_body), "HTTP/1.1 201", "\"id\": \"clone\""); + const clone = try voice.parse(a, try tmp.dir.readFileAlloc(t.io, "clone.json", a, .limited(voice.max_file_bytes))); + try t.expectEqualSlices([10]i32, &.{ @splat(5), @splat(6) }, clone[0].codes); + try expectReply(try h.ask(a, "GET", "/v1/voices", "read-secret", ""), "HTTP/1.1 200", "\"voices\": [\"default\", \"clone\", \"tone\"]"); + // a request reading "tone" keeps its frames while an admin deletes it + fake.hold.store(true, .release); + const Speaker = struct { + h: *Harness, + reply: []const u8 = "", + fn run(s: *@This(), out: Allocator) void { + s.reply = s.h.ask(out, "POST", "/v1/audio/speech", "infer-secret", "{\"model\":\"m\",\"input\":\"hello\",\"voice\":\"tone\"}") catch "failed"; + } + }; + var speaker: Speaker = .{ .h = &h }; + var speaker_arena: std.heap.ArenaAllocator = .init(t.allocator); + defer speaker_arena.deinit(); + const thread = try std.Thread.spawn(.{}, Speaker.run, .{ &speaker, speaker_arena.allocator() }); + var joined = false; + defer if (!joined) { + fake.hold.store(false, .release); + thread.join(); + }; + while (!fake.held.load(.acquire)) std.Thread.yield() catch {}; + try expectReply(try h.ask(a, "DELETE", "/v1/voices/tone", admin, ""), "HTTP/1.1 200", "\"deleted\": true"); + try t.expectError(error.FileNotFound, tmp.dir.access(t.io, "tone.json", .{})); + fake.hold.store(false, .release); + thread.join(); + joined = true; + try expectReply(speaker.reply, "HTTP/1.1 200", "RIFF"); + const want = try voice.promptFor(a, h.text.text(), "hello", try voice.parse(a, tone)); + try t.expectEqualSlices([11]i32, want.frames, fake.frames.items); + try expectReply(try h.ask(a, "POST", "/v1/audio/speech", "infer-secret", "{\"model\":\"m\",\"input\":\"hello\",\"voice\":\"tone\"}"), "HTTP/1.1 400", "unknown voice 'tone'; see /v1/voices"); + try expectReply(try h.ask(a, "DELETE", "/v1/voices/tone", admin, ""), "HTTP/1.1 404", "no such voice"); +} + +test "voices HTTP: --request-voices takes an attested inline voice as the catalog's own" { + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var tmp = t.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(t.io, .{ .sub_path = "tone.json", .data = tone }); + var fake: Fake = .{}; + defer fake.frames.deinit(t.allocator); + var h: Harness = .{}; + try h.start(&fake, .{ .served_name = "m", .model_ids = &.{"m"}, .keep_warm_s = 0, .voice = .{ .dir = try std.fmt.allocPrint(a, ".zig-cache/tmp/{s}", .{tmp.sub_path}), .inline_voices = true } }, null); + defer h.deinit(); + try expectReply(try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"A cloud.\",\"voice\":\"tone\"}"), "HTTP/1.1 200", "RIFF"); + const from_catalog = try a.dupe([11]i32, fake.frames.items); + try expectReply(try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"A cloud.\",\"voice\":" ++ tone ++ "}"), "HTTP/1.1 200", "RIFF"); + try t.expectEqualSlices([11]i32, from_catalog, fake.frames.items); + try expectReply(try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"hi\",\"voice\":{\"format\":\"drama3-http-voice/1\",\"references\":[{\"text\":\"A.\",\"codes\":[[1,2,3,4,5,6,7,8,9,10]]}]}}"), "HTTP/1.1 400", "source.kind"); + try expectReply(try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"hi\",\"speaker\":\"tone\",\"voice\":" ++ tone ++ "}"), "HTTP/1.1 400", "takes no speaker"); + try expectReply(try h.ask(a, "POST", "/v1/audio/speech", "", "{\"model\":\"m\",\"input\":\"hi\",\"ref_audio\":\"x.wav\"}"), "HTTP/1.1 400", "ref_audio is not supported by this model"); + try expectReply(try h.ask(a, "POST", "/v1/voices", "", "{\"name\":\"x\"," ++ tone[1..]), "HTTP/1.1 404", "unknown path"); +} diff --git a/zig/src/server/speech_voices_test.zig b/zig/src/server/speech_voices_test.zig index 83337fafc0d..f2aaead5e4c 100644 --- a/zig/src/server/speech_voices_test.zig +++ b/zig/src/server/speech_voices_test.zig @@ -106,9 +106,9 @@ test "engine voices: the catalog outlives the engine's names, as across an idle @memset(@constCast(name), 'x'); // the unload frees the engine's catalog gpa.free(name); } - try std.testing.expectEqual(@as(usize, 2), srv.voices.len); - try std.testing.expectEqualStrings("juno", srv.voices[0].name); - try std.testing.expectEqualStrings("mira", srv.voices[1].name); + try std.testing.expectEqual(@as(usize, 2), srv.voices.voices.len); + try std.testing.expectEqualStrings("juno", srv.voices.voices[0].name); + try std.testing.expectEqualStrings("mira", srv.voices.voices[1].name); } test "engine voices: Drama's sampling fields are refused, the seed is kept" { diff --git a/zig/src/server/vision_inputs.zig b/zig/src/server/vision_inputs.zig index f1caebcb6df..51e9bc97901 100644 --- a/zig/src/server/vision_inputs.zig +++ b/zig/src/server/vision_inputs.zig @@ -299,7 +299,7 @@ fn videoGlm(srv: *Server, cx: *Cx, bytes: []const u8) errors.Refused!qi.glm.Vide const l = library(srv.io) orelse return cx.refuse(@import("sys").optional_libraries.spec(.video).message); var gs: GlmSize = .{ .budget = 16384 }; gs.budget = @import("sys").environment.read(u64, "TENSORFOLD_VIDEO_TOKENS", gs.budget) catch { - return cx.refuse(try @import("sys").environment.describe(cx.a, "TENSORFOLD_VIDEO_TOKENS", @import("sys").getenv("TENSORFOLD_VIDEO_TOKENS").?)); + return cx.refuse(try @import("sys").environment.describe(cx.a, "TENSORFOLD_VIDEO_TOKENS", (@import("sys").environment.Process{}).get("TENSORFOLD_VIDEO_TOKENS").?)); }; var v: TfVideo = undefined; const rc = l.decode(bytes.ptr, bytes.len, 2.0, 2, 256, 3600.0, 8192, sizeForGlm, @ptrCast(&gs), &v); @@ -328,7 +328,7 @@ fn video(srv: *Server, cx: *Cx, bytes: []const u8) errors.Refused!qi.Video { const l = library(srv.io) orelse return cx.refuse(@import("sys").optional_libraries.spec(.video).message); var budget: u64 = 16384; budget = @import("sys").environment.read(u64, "TENSORFOLD_VIDEO_TOKENS", budget) catch { - return cx.refuse(try @import("sys").environment.describe(cx.a, "TENSORFOLD_VIDEO_TOKENS", @import("sys").getenv("TENSORFOLD_VIDEO_TOKENS").?)); + return cx.refuse(try @import("sys").environment.describe(cx.a, "TENSORFOLD_VIDEO_TOKENS", (@import("sys").environment.Process{}).get("TENSORFOLD_VIDEO_TOKENS").?)); }; var v: TfVideo = undefined; const rc = l.decode(bytes.ptr, bytes.len, 2.0, 4, 256, 3600.0, 8192, sizeFor, @ptrCast(&budget), &v); diff --git a/zig/src/server/voice_cli.zig b/zig/src/server/voice_cli.zig new file mode 100644 index 00000000000..b7b2ad4f885 --- /dev/null +++ b/zig/src/server/voice_cli.zig @@ -0,0 +1,39 @@ +//! The opt-in voice flags of a speech server, parsed beside the serve parser's own flag dispatch. +const std = @import("std"); +const cli = @import("cli.zig"); + +pub const flags = [_]cli.Flag{ + .{ .name = "--request-voices", .kind = .store_true, .native = true }, + .{ .name = "--manage-voices", .kind = .store_true, .native = true }, +}; + +/// The served catalog's settings: --voices DIR, --default-voice NAME and the two flags. +pub const Config = struct { + dir: ?[]const u8 = null, + default: []const u8 = "default", + inline_voices: bool = false, + manage: bool = false, +}; + +pub const Flags = struct { + /// --request-voices: a speech request's `voice` may be an attested voice object instead of a catalog name. + inline_voices: bool = false, + /// --manage-voices: admin keys add (POST /v1/voices) and delete (DELETE /v1/voices/NAME) catalog voices. + manage: bool = false, +}; + +/// True when `name` is a voice flag, now set. +pub fn apply(f: *Flags, name: []const u8) bool { + if (std.mem.eql(u8, name, "--request-voices")) f.inline_voices = true else if (std.mem.eql(u8, name, "--manage-voices")) f.manage = true else return false; + return true; +} + +test "voice CLI: --request-voices and --manage-voices default off and are switches" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var u: cli.Usage = .{}; + try std.testing.expectEqual(Flags{}, (try cli.parse(a, &.{"m"}, &u)).voice); + try std.testing.expectEqual(Flags{ .inline_voices = true }, (try cli.parse(a, &.{ "m", "--request-voices" }, &u)).voice); + try std.testing.expectEqual(Flags{ .inline_voices = true, .manage = true }, (try cli.parse(a, &.{ "m", "--manage-voices", "--request-voices" }, &u)).voice); +} diff --git a/zig/src/server/web_cli.zig b/zig/src/server/web_cli.zig index efa15e85b29..def31010aed 100644 --- a/zig/src/server/web_cli.zig +++ b/zig/src/server/web_cli.zig @@ -82,8 +82,10 @@ pub fn command(ctx: Context, args: []const []const u8, version: Version) !u8 { } fn instructions(ctx: Context, spec: []const u8, need_uv: bool) !u8 { + if (need_uv) try ctx.out.writeAll( + "Install uv and add it to PATH: https://docs.astral.sh/uv/getting-started/installation/\n", + ); try ctx.out.writeAll("Run:\n"); - if (need_uv) try ctx.out.writeAll(if (builtin.os.tag == .windows) " py -m pip install --user uv\n" else " python3 -m pip install --user uv\n"); try ctx.out.print(" uv tool install \"{s}\"\nThen run tensorfold web again.\n", .{spec}); return 1; } diff --git a/zig/src/server/web_cli_test.zig b/zig/src/server/web_cli_test.zig index 0019a91732b..428d0cdb19b 100644 --- a/zig/src/server/web_cli_test.zig +++ b/zig/src/server/web_cli_test.zig @@ -95,7 +95,9 @@ fn check(c: Case) !void { const launched = tmp.dir.readFileAlloc(io, "launch.log", a, .limited(4096)) catch ""; try t.expectEqualStrings(if (c.launches) "/example path/tensorfold\n--port\n9090\ntwo words\n$(untouched);*\n\n" else "", launched); try t.expectEqualStrings("wrong-binary", env.get("TENSORFOLD_BIN").?); - if (!c.uv and !c.installed) try t.expect(std.mem.indexOf(u8, out.written(), "python3 -m pip install --user uv") != null); + const uv_guide = "Install uv and add it to PATH: https://docs.astral.sh/uv/getting-started/installation/"; + try t.expectEqual(!c.uv and !c.installed, std.mem.indexOf(u8, out.written(), uv_guide) != null); + try t.expect(std.mem.indexOf(u8, out.written(), "pip install --user uv") == null); if (!c.version.is_release and !c.installed) try t.expect(std.mem.indexOf(u8, out.written(), "Development build without a release tag") != null); } diff --git a/zig/src/tensorfold.zig b/zig/src/tensorfold.zig index 210d6b07c50..d5521bf032f 100644 --- a/zig/src/tensorfold.zig +++ b/zig/src/tensorfold.zig @@ -16,6 +16,8 @@ pub const qwen_vl_tower = @import("core/qwen_vl/metal.zig"); pub const qwen_image = @import("families/qwen_image/qwen_image.zig"); /// MOSS-Image's transformer on Metal: a denoiser driven by tf-moss-image, outside the lane engine. pub const moss_image = @import("families/moss_image/moss_image.zig"); +/// Idol's denoiser on Metal: driven by tf-idol, outside the lane engine. +pub const idol = @import("families/idol/idol.zig"); /// Unlimited-OCR-2 on Metal: document pages to text (its image encoder and decoder). pub const uocr = @import("families/uocr/uocr.zig"); pub const checkpoint = @import("core/checkpoint_metal.zig"); diff --git a/zig/tests/contract/baselines/glm_attn_main.metal.txt b/zig/tests/contract/baselines/glm_attn_main.metal.txt new file mode 100644 index 00000000000..2dcd02576ee --- /dev/null +++ b/zig/tests/contract/baselines/glm_attn_main.metal.txt @@ -0,0 +1,71 @@ +// GLM-5.3-Flash latent attention, rows reading all keys: the 64 query heads as one matrix against the one latent head. +#include +using namespace metal; +#include "../nax.h" +using namespace tfp; + +// fp32 parts of one output block added as one run would leave them: (0 + first) + second. +inline void glm_join(thread frag& c, thread const frag& d) { + c = (frag(0.0f) + c) + d; +} + +// S[64,n] = QK^T in 16-wide steps (simdgroup g: heads 16 g.., a threadgroup 32 keys); arg.y: two 256-dim halves joined. +[[kernel]] void glm_latent_scores(const device bfloat* q [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* s [[buffer(2)]], constant int2& arg [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]]) { + const int n = arg.x, col0 = int(tg.x) * 32, row0 = int(g) * 16; + const short2 home = frag_home(ushort(lane)); + frag c0 = 0.0f, c1 = 0.0f, d0 = 0.0f, d1 = 0.0f; + for (int k0 = 0; k0 < 512; k0 += 16) { + frag a, b0, b1; + frag_get_in(a, q, 512, row0, k0, home, 64, 512); + frag_get_t_in(b0, keys, 512, col0, k0, home, n, 512); + frag_get_t_in(b1, keys, 512, col0 + 16, k0, home, n, 512); + if (arg.y != 0 && k0 >= 256) { + mma_16x32(d0, d1, a, b0, b1); + } else { + mma_16x32(c0, c1, a, b0, b1); + } + } + if (arg.y != 0) { + glm_join(c0, d0); + glm_join(c1, d1); + } + frag_put_in(c0, s, n, row0, col0, home, 64, n); + frag_put_in(c1, s, n, row0, col0 + 16, home, 64, n); +} + +// Keys [lo, hi) of O += P K in 16-wide steps: whole 256-key blocks, then the rest rounded up to 32 (zeros past hi). +inline void glm_values_run(thread frag& c0, thread frag& c1, const device bfloat* p, + const device bfloat* keys, int n, int lo, int hi, int row0, int col0, short2 home) { + const int len = hi - lo; + const int steps = (len / 256) * 16 + ((len % 256) + 31) / 32 * 2; + for (int i = 0; i < steps; ++i) { + const int k0 = lo + 16 * i; + frag a, b0, b1; + frag_get_in(a, p, n, row0, k0, home, 64, hi); + frag_get_in(b0, keys, 512, k0, col0, home, hi, 512); + frag_get_in(b1, keys, 512, k0, col0 + 16, home, hi, 512); + mma_16x32(c0, c1, a, b0, b1); + } +} + +// O[64,512] = PK in 16-wide steps (simdgroup g: heads 16 g.., a threadgroup 32 dims); arg.y > 0: keys [0, arg.y) apart. +[[kernel]] void glm_latent_values(const device bfloat* p [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* o [[buffer(2)]], constant int2& arg [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]]) { + const int n = arg.x, part = arg.y, col0 = int(tg.x) * 32, row0 = int(g) * 16; + const short2 home = frag_home(ushort(lane)); + frag c0 = 0.0f, c1 = 0.0f; + glm_values_run(c0, c1, p, keys, n, 0, part > 0 ? part : n, row0, col0, home); + if (part > 0) { + frag d0 = 0.0f, d1 = 0.0f; + glm_values_run(d0, d1, p, keys, n, part, n, row0, col0, home); + glm_join(c0, d0); + glm_join(c1, d1); + } + frag_put_in(c0, o, 512, row0, col0, home, 64, 512); + frag_put_in(c1, o, 512, row0, col0 + 16, home, 64, 512); +} diff --git a/zig/tests/contract/baselines/glm_glue_main.metal.txt b/zig/tests/contract/baselines/glm_glue_main.metal.txt new file mode 100644 index 00000000000..422f7938115 --- /dev/null +++ b/zig/tests/contract/baselines/glm_glue_main.metal.txt @@ -0,0 +1,534 @@ +// GLM-5.3-Flash decode glue: MLX 0.32.3's arithmetic where the Python family calls MLX ops, our own elsewhere. +#include +using namespace metal; +typedef bfloat bfloat16_t; + +struct GlmRows { + int rows, width, x_stride, y_stride; + float eps; +}; + +// bf16 -> fp32, as x.astype(mx.float32) (the router's input). +kernel void glm_cast_f32(const device bfloat* x [[buffer(0)]], device float* y [[buffer(1)]], + constant uint& n [[buffer(2)]], uint i [[thread_position_in_grid]]) { + if (i < n) y[i] = float(x[i]); +} + +// MLX's rms_single_row on strided rows: thread t squares 4t..4t+3, simd_sum, a 32-slot simd_sum, precise rsqrt. +kernel void glm_rms(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], + device bfloat* y [[buffer(2)]], constant GlmRows& a [[buffer(3)]], + uint row [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + threadgroup float sg_sums[32]; + threadgroup float inv_rms[1]; + const uint width = uint(a.width), lo = 4 * t; + const device bfloat* src = x + size_t(row) * a.x_stride + lo; + device bfloat* dst = y + size_t(row) * a.y_stride + lo; + const device bfloat* gain = w + lo; + const bool whole = lo + 4 <= width; + float v[4]; + float sq = 0.0f; + if (whole) { + for (int j = 0; j < 4; ++j) { + v[j] = src[j]; + sq += v[j] * v[j]; + } + } else { + for (int j = 0; j < 4; ++j) { + v[j] = lo + j < width ? float(src[j]) : 0.0f; + sq += v[j] * v[j]; + } + } + sq = simd_sum(sq); + if (sg == 0) sg_sums[lane] = 0.0f; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 0) sg_sums[sg] = sq; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + const float all = simd_sum(sg_sums[lane]); + if (lane == 0) inv_rms[0] = metal::precise::rsqrt(all / float(width) + a.eps); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (whole) { + for (int j = 0; j < 4; ++j) dst[j] = gain[j] * static_cast(v[j] * inv_rms[0]); + } else { + for (int j = 0; j < 4; ++j) + if (lo + j < width) dst[j] = gain[j] * static_cast(v[j] * inv_rms[0]); + } +} + +// MLX's layer_norm_single_row (8 values a thread, 32 threads a row): the indexer's key norm with weight and bias. +inline float glm_tg_sum(float x, threadgroup float* xs, uint lane, uint sg) { + x = simd_sum(x); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 0) xs[sg] = x; + threadgroup_barrier(mem_flags::mem_threadgroup); + x = xs[lane]; + return simd_sum(x); +} + +kernel void glm_layer_norm(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], + const device bfloat* b [[buffer(2)]], device bfloat* y [[buffer(3)]], + constant GlmRows& a [[buffer(4)]], uint row [[threadgroup_position_in_grid]], + uint lid [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + constexpr int N_READS = 8; + float thread_x[N_READS] = {0}; + threadgroup float local_buffer[32]; + if (sg == 0) local_buffer[lane] = 0; + const int axis = a.width; + const device bfloat* xr = x + size_t(row) * a.x_stride + lid * N_READS; + device bfloat* out = y + size_t(row) * a.y_stride + lid * N_READS; + const device bfloat* wr = w + lid * N_READS; + const device bfloat* br = b + lid * N_READS; + const bool safe = int(lid) * N_READS + N_READS <= axis; + const int n = axis - int(lid) * N_READS; + if (safe) { + for (int i = 0; i < N_READS; i++) thread_x[i] = xr[i]; + } else { + for (int i = 0; i < n; i++) thread_x[i] = xr[i]; + } + float mean = 0; + for (int i = 0; i < N_READS; i++) mean += thread_x[i]; + mean = glm_tg_sum(mean, local_buffer, lane, sg); + mean /= axis; + float normalizer = 0; + if (!safe) { + for (int i = max(n, 0); i < N_READS; i++) thread_x[i] = mean; + } + for (int i = 0; i < N_READS; i++) { + thread_x[i] -= mean; + normalizer += thread_x[i] * thread_x[i]; + } + normalizer = glm_tg_sum(normalizer, local_buffer, lane, sg); + normalizer = metal::precise::rsqrt(normalizer / axis + a.eps); + if (safe) { + for (int i = 0; i < N_READS; i++) { + thread_x[i] *= normalizer; + out[i] = wr[i] * static_cast(thread_x[i]) + br[i]; + } + } else { + for (int i = 0; i < n; i++) { + thread_x[i] *= normalizer; + out[i] = wr[i] * static_cast(thread_x[i]) + br[i]; + } + } +} + +// The absorb q_nope [b, 256] @ W_k[h] [256, 512] (h = b % HEADS, kv_b's key rows) in affine_qvm's 4-bit sum order. +kernel void glm_absorb(const device uint32_t* w [[buffer(0)]], const device bfloat* scales [[buffer(1)]], + const device bfloat* biases [[buffer(2)]], const device bfloat* x [[buffer(3)]], + device bfloat* y [[buffer(4)]], constant uint& q_stride [[buffer(5)]], + constant uint& heads [[buffer(6)]], uint3 tid [[threadgroup_position_in_grid]], + uint simd_gid [[simdgroup_index_in_threadgroup]], uint simd_lid [[thread_index_in_simdgroup]]) { + constexpr int K = 256, N = 512, ROWS_PER_HEAD = 512, NW = N / 8, NG = N / 64; + const int HEADS = int(heads), b = int(tid.z), h = b % HEADS; + const int out_col = 32 * (int(tid.y) * 2 + int(simd_gid)); + const device uint32_t* ws = w + size_t(h * ROWS_PER_HEAD) * NW + out_col / 8 + simd_lid * NW; + const device bfloat* sc = scales + size_t(h * ROWS_PER_HEAD) * NG + out_col / 64 + simd_lid * NG; + const device bfloat* bi = biases + size_t(h * ROWS_PER_HEAD) * NG + out_col / 64 + simd_lid * NG; + const device bfloat* xp = x + size_t(b / HEADS) * q_stride + size_t(h) * K + simd_lid; + device bfloat* yp = y + size_t(b) * N + out_col; + float result[32] = {0}; + for (int i = 0; i < K; i += 32) { + const float xl = *xp; + const float scale = *sc; + const float bias = *bi; + uint32_t wl[4]; + for (int j = 0; j < 4; j++) wl[j] = ws[j]; + const thread uint8_t* wb = (const thread uint8_t*)wl; + const float s[2] = {scale, scale / 16.0f}; + for (int j = 0; j < 16; j++) { + result[2 * j] += xl * (s[0] * (wb[j] & 0x0f) + bias); + result[2 * j + 1] += xl * (s[1] * (wb[j] & 0xf0) + bias); + } + xp += 32; + sc += 32 * NG; + bi += 32 * NG; + ws += 32 * NW; + } + for (int k = 0; k < 32; k++) result[k] = simd_sum(result[k]); + if (simd_lid == 0) + for (int k = 0; k < 32; k++) yp[k] = static_cast(result[k]); +} + +// The unabsorb latent [b, 512] -> values [b, 256] (kv_b's value rows) in qmv_fast's 4-bit sum order, batched by head. +inline float glm_load16(const device bfloat* x, thread float* xt) { + float sum = 0.0f; + for (int i = 0; i < 16; i += 4) { + const bfloat a = x[i], b = x[i + 1], c = x[i + 2], d = x[i + 3]; + sum += float(bfloat(float(bfloat(float(bfloat(float(a) + float(b))) + float(c))) + float(d))); + xt[i] = float(a); xt[i + 1] = float(b) / 16.0f; xt[i + 2] = float(c) / 256.0f; xt[i + 3] = float(d) / 4096.0f; + } + return sum; +} +inline float glm_qdot16(const device uint8_t* w, const thread float* xt, float scale, float bias, float sum) { + const device uint16_t* ws = (const device uint16_t*)w; + float accum = 0.0f; + for (int i = 0; i < 4; i++) + accum += xt[4 * i] * float(ws[i] & 0x000f) + xt[4 * i + 1] * float(ws[i] & 0x00f0) + + xt[4 * i + 2] * float(ws[i] & 0x0f00) + xt[4 * i + 3] * float(ws[i] & 0xf000); + return scale * accum + sum * bias; +} + +kernel void glm_unabsorb(const device uint32_t* W [[buffer(0)]], const device bfloat* S [[buffer(1)]], + const device bfloat* B [[buffer(2)]], const device bfloat* X [[buffer(3)]], + device bfloat* OUT [[buffer(4)]], constant uint& heads [[buffer(5)]], + uint3 tg [[threadgroup_position_in_grid]], uint lane [[thread_index_in_simdgroup]]) { + constexpr int K = 512, N = 256, RPS = 4, KB = K / 2, KG = K / 64; + const int b = int(tg.z), h = b % int(heads); + const int row0 = h * 512 + 256 + int(tg.y) * RPS; + const device uint8_t* w = (const device uint8_t*)W + size_t(row0) * KB + lane * 8; + const device bfloat* sc = S + size_t(row0) * KG + lane / 4; + const device bfloat* bi = B + size_t(row0) * KG + lane / 4; + const device bfloat* x = X + size_t(b) * K + lane * 16; + float acc[RPS]; + for (int j = 0; j < RPS; j++) acc[j] = 0.0f; + for (int k0 = 0; k0 < K; k0 += 512) { + float xt[16]; + const float sum = glm_load16(x, xt); + for (int j = 0; j < RPS; j++) acc[j] += glm_qdot16(w + j * KB, xt, float(sc[j * KG]), float(bi[j * KG]), sum); + w += 256; sc += 8; bi += 8; x += 512; + } + for (int j = 0; j < RPS; j++) { + const float v = simd_sum(acc[j]); + if (lane == 0) OUT[size_t(b) * N + int(tg.y) * RPS + j] = bfloat(v); + } +} + +// y = bf16(x * s) for a power-of-two s (exact): the scaled queries of MLX's unfused attention, the indexer weights. +kernel void glm_scale(const device bfloat* x [[buffer(0)]], device bfloat* y [[buffer(1)]], + constant GlmRows& a [[buffer(2)]], uint2 p [[thread_position_in_grid]]) { + if (int(p.x) >= a.width || int(p.y) >= a.rows) return; + y[size_t(p.y) * a.y_stride + p.x] = bfloat(float(x[size_t(p.y) * a.x_stride + p.x]) * a.eps); +} + +// Pooled indexer keys of blocks [first, first + count): caches.pool_blocks' fp32 ops, each rounded alone. +#pragma clang fp contract(off) +kernel void glm_pool(const device bfloat* ik [[buffer(0)]], const device bfloat* ig [[buffer(1)]], + const device bfloat* ape [[buffer(2)]], device bfloat* pool [[buffer(3)]], + constant uint2& span [[buffer(4)]], uint2 p [[thread_position_in_grid]]) { + constexpr int DI = 128, KP = 4; + if (p.y >= span.y) return; + const uint blk = span.x + p.y, d = p.x; + float logit[KP], k[KP]; + for (int j = 0; j < KP; j++) { + const size_t at = size_t(blk * KP + j) * DI + d; + logit[j] = float(ig[at]) + float(ape[j * DI + d]); + k[j] = float(ik[at]); + } + float top = logit[0]; + for (int j = 1; j < KP; j++) top = metal::max(top, logit[j]); + float e[KP]; + for (int j = 0; j < KP; j++) e[j] = metal::precise::exp(logit[j] - top); + float total = e[0]; + for (int j = 1; j < KP; j++) total = total + e[j]; + float out = (e[0] / total) * k[0]; + for (int j = 1; j < KP; j++) out = out + (e[j] / total) * k[j]; + pool[size_t(blk) * DI + d] = bfloat(out); +} + +// The streams' fp32 mean (summed in stream order, * 1/4) as bf16: model.final_norm before its RMSNorm. +kernel void glm_stream_mean(const device bfloat* x [[buffer(0)]], device bfloat* y [[buffer(1)]], + constant uint2& dims [[buffer(2)]], uint2 p [[thread_position_in_grid]]) { + const uint D = dims.x; + if (p.x >= D || p.y >= dims.y) return; + const device bfloat* r = x + size_t(p.y) * 4 * D + p.x; + float raw = float(r[0]); + for (int s = 1; s < 4; s++) raw = raw + float(r[s * D]); + y[size_t(p.y) * D + p.x] = bfloat(raw * 0.25f); +} + +// out = bf16(a + b): the MTP block's residual adds. +kernel void glm_add(const device bfloat* a [[buffer(0)]], const device bfloat* b [[buffer(1)]], + device bfloat* out [[buffer(2)]], constant uint& n [[buffer(3)]], uint i [[thread_position_in_grid]]) { + if (i < n) out[i] = bfloat(float(a[i]) + float(b[i])); +} +#pragma clang fp contract(on) + +// MLX's bfloat math overloads (bf16_math.h) and fused.py's sigmoid_fast: nn.silu's compiled x * sigmoid(x). +#ifndef METAL_FUNC +#define METAL_FUNC inline __attribute__((__always_inline__)) +#endif +namespace metal { +METAL_FUNC bfloat16_t abs(bfloat16_t x) { return static_cast(__metal_fabs(static_cast(x), __METAL_MAYBE_FAST_MATH__)); } +METAL_FUNC bfloat16_t exp(bfloat16_t x) { return static_cast(__metal_exp(static_cast(x), __METAL_MAYBE_FAST_MATH__)); } +} +template +inline U sigmoid_fast(U x) { + U e = static_cast(metal::exp(metal::abs(x))); + U y = static_cast(1) / (static_cast(1) + e); + return (x < 0) ? y : (static_cast(1) - y); +} + +// The dense MLP's SwiGLU over [gate | up] rows, clipped at `limit`: the MoE kernel's (and the eager ops') bits. +kernel void glm_swiglu(const device bfloat* gu [[buffer(0)]], device bfloat* act [[buffer(1)]], + constant GlmRows& a [[buffer(2)]], uint2 p [[thread_position_in_grid]]) { + if (int(p.x) >= a.width || int(p.y) >= a.rows) return; + const device bfloat* row = gu + size_t(p.y) * a.x_stride; + const float lim = float(bfloat(a.eps)); + const bfloat gt = bfloat(metal::min(float(row[p.x]), lim)); + const bfloat up = bfloat(metal::min(metal::max(float(row[a.width + p.x]), -lim), lim)); + const bfloat sl = gt * sigmoid_fast(gt); + act[size_t(p.y) * a.y_stride + p.x] = sl * up; +} + +// Each row's argmax over bf16 logits (the larger value, the lower index on a tie), 1024 threads a row. +kernel void glm_argmax(const device bfloat* logits [[buffer(0)]], device uint* out [[buffer(1)]], + constant uint& vocab [[buffer(2)]], uint row [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + const device bfloat* x = logits + size_t(row) * vocab; + float best = -INFINITY; + uint at = 0xffffffffu; + for (uint i = t; i < vocab; i += 1024) { + const float v = float(x[i]); + if (v > best) { best = v; at = i; } + } + for (ushort o = 16; o > 0; o >>= 1) { + const float ob = simd_shuffle_xor(best, o); + const uint oa = simd_shuffle_xor(at, o); + if (ob > best || (ob == best && oa < at)) { best = ob; at = oa; } + } + threadgroup float vb[32]; + threadgroup uint va[32]; + if (lane == 0) { vb[sg] = best; va[sg] = at; } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg != 0) return; + best = vb[lane]; + at = va[lane]; + for (ushort o = 16; o > 0; o >>= 1) { + const float ob = simd_shuffle_xor(best, o); + const uint oa = simd_shuffle_xor(at, o); + if (ob > best || (ob == best && oa < at)) { best = ob; at = oa; } + } + if (lane == 0) out[row] = at; +} + +// Row r's (position p0 + r) fp32 block scores over its whole blocks: sum over heads in order of w_h relu(q_h . pool_b). +struct GlmScoreArgs { + uint p0, q_stride, w_stride, s_stride; +}; + +kernel void glm_index_scores(const device bfloat* iq [[buffer(0)]], const device bfloat* iw [[buffer(1)]], + const device bfloat* pool [[buffer(2)]], device float* scores [[buffer(3)]], + constant GlmScoreArgs& a [[buffer(4)]], uint2 tg [[threadgroup_position_in_grid]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + constexpr int HI = 32, DI = 128, SGS = 8; + const uint row = tg.y; + const uint blk = tg.x * SGS + sg; + const uint blocks = (a.p0 + row + 1) / 4; + if (tg.x * SGS >= blocks) return; + threadgroup float qs[HI * DI]; + threadgroup float ws[HI]; + const device bfloat* q = iq + size_t(row) * a.q_stride; + for (uint i = sg * 32 + lane; i < HI * DI; i += SGS * 32) qs[i] = float(q[i]); + if (sg == 0) ws[lane] = float(iw[size_t(row) * a.w_stride + lane]); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (blk >= blocks) return; + float k[4]; + for (int j = 0; j < 4; j++) k[j] = float(pool[size_t(blk) * DI + lane * 4 + j]); + float total = 0.0f; + for (int h = 0; h < HI; h++) { + float dot = 0.0f; + for (int j = 0; j < 4; j++) dot = fma(qs[h * DI + lane * 4 + j], k[j], dot); + dot = simd_sum(dot); + total = fma(ws[h], metal::max(dot, 0.0f), total); + } + if (lane == 0) scores[size_t(row) * a.s_stride + blk] = total; +} + +// Row r's key list: its TOP best blocks (ties: lower) in block order, its tail, -1 to `width` (a radix select). +struct GlmSelectArgs { + uint p0, top, width, s_stride, i_stride; +}; + +// Exclusive prefix sum over a 1024-thread threadgroup (32 simdgroups), `part` 32 slots of scratch. +inline uint glm_scan(uint v, threadgroup uint* part, uint t) { + const uint lane = t % 32, sg = t / 32; + const uint inside = simd_prefix_exclusive_sum(v); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 31) part[sg] = inside + v; + threadgroup_barrier(mem_flags::mem_threadgroup); + uint base = 0; + for (uint i = 0; i < sg; i++) base += part[i]; + threadgroup_barrier(mem_flags::mem_threadgroup); + return base + inside; +} + +inline uint glm_order_key(float v) { + const uint u = as_type(v); + return (u & 0x80000000u) ? ~u : (u | 0x80000000u); +} + +kernel void glm_index_select(const device float* scores [[buffer(0)]], device int* indices [[buffer(1)]], + constant GlmSelectArgs& g [[buffer(2)]], uint row [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]]) { + constexpr uint NT = 1024; + struct { uint blocks, top, position, width, s_stride, i_stride; } a = { + (g.p0 + row + 1) / 4, g.top, g.p0 + row, g.width, g.s_stride, g.i_stride}; + const device float* s = scores + size_t(row) * a.s_stride; + device int* out = indices + size_t(row) * a.i_stride; + threadgroup atomic_uint hist[256]; + threadgroup uint shared_prefix[1], shared_need[1]; + threadgroup uint counts[32]; + threadgroup uint seg[8]; // the digit counts' simdgroup totals, highest digits first + uint prefix = 0, need = a.top; + if (a.top < a.blocks) { + for (int shift = 24; shift >= 0; shift -= 8) { + for (uint i = t; i < 256; i += NT) atomic_store_explicit(&hist[i], 0u, memory_order_relaxed); + threadgroup_barrier(mem_flags::mem_threadgroup); + const uint hi_mask = shift == 24 ? 0u : (0xffffffffu << (shift + 8)); + for (uint b = t; b < a.blocks; b += NT) { + const uint key = glm_order_key(s[b]); + if ((key & hi_mask) == (prefix & hi_mask)) + atomic_fetch_add_explicit(&hist[(key >> shift) & 255u], 1u, memory_order_relaxed); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + // the digit holding the need-th largest key: thread t takes digit 255 - t, the counts above it summed in parallel + const uint d = 255u - min(t, 255u); + const uint c = t < 256 ? atomic_load_explicit(&hist[d], memory_order_relaxed) : 0u; + const uint incl = simd_prefix_inclusive_sum(c); + if (t < 256 && t % 32 == 31) seg[t / 32] = incl; + threadgroup_barrier(mem_flags::mem_threadgroup); + uint above = incl - c; + for (uint i = 0; i < min(t / 32, 8u); i++) above += seg[i]; + if (t < 256 && above < need && above + c >= need) { + shared_prefix[0] = prefix | (d << shift); + shared_need[0] = need - above; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + prefix = shared_prefix[0]; + need = shared_need[0]; + } + } + // blocks above the threshold key, plus the first `need` equal to it in block order: each thread a run of blocks + const bool all_blocks = a.top >= a.blocks; + const uint per = (a.blocks + NT - 1) / NT; + const uint lo = min(t * per, a.blocks), hi = min(lo + per, a.blocks); + uint above = 0, equal = 0; + if (!all_blocks) + for (uint b = lo; b < hi; b++) { + const uint key = glm_order_key(s[b]); + above += key > prefix ? 1u : 0u; + equal += key == prefix ? 1u : 0u; + } + const uint equal_before = glm_scan(equal, counts, t); + uint take = 0; + if (all_blocks) take = hi - lo; + else take = above + (equal_before >= need ? 0u : min(equal, need - equal_before)); + const uint before = glm_scan(take, counts, t); + uint eq_seen = equal_before; + uint at = before; + for (uint b = lo; b < hi; b++) { + bool chosen = all_blocks; + if (!all_blocks) { + const uint key = glm_order_key(s[b]); + if (key > prefix) chosen = true; + else if (key == prefix) { chosen = eq_seen < need; eq_seen++; } + } + if (chosen) { + for (uint j = 0; j < 4; j++) out[4 * at + j] = int(4 * b + j); + at++; + } + } + threadgroup_barrier(mem_flags::mem_device); + const uint chosen_blocks = min(a.top, a.blocks); + const uint tail = (a.position + 1) % 4; + for (uint i = 4 * chosen_blocks + t; i < a.width; i += NT) { + const uint j = i - 4 * chosen_blocks; + out[i] = j < tail ? int(a.position + 1 - tail + j) : -1; + } +} + +// y = exp(x) with MLX's Exp (precise): the KDA decay rates A = exp(A_log), once at load. +kernel void glm_exp_f32(const device float* x [[buffer(0)]], device float* y [[buffer(1)]], + constant uint& n [[buffer(2)]], uint i [[thread_position_in_grid]]) { + if (i < n) y[i] = metal::precise::exp(x[i]); +} + +// The embedding rows copied into the four hyper-connection streams: [rows, D] -> [rows, 4, D]. +kernel void glm_streams(const device bfloat* h [[buffer(0)]], device bfloat* x [[buffer(1)]], + constant uint2& dims [[buffer(2)]], uint2 p [[thread_position_in_grid]]) { + const uint D = dims.x; + if (p.x >= D || p.y >= dims.y) return; + const bfloat v = h[size_t(p.y) * D + p.x]; + for (int s = 0; s < 4; s++) x[(size_t(p.y) * 4 + s) * D + p.x] = v; +} + +// dst[i] = src[i] for n u32 values (a pick becoming the next window's token or the MTP head's input). +kernel void glm_copy_u32(const device uint* src [[buffer(0)]], device uint* dst [[buffer(1)]], + constant uint& n [[buffer(2)]], uint i [[thread_position_in_grid]]) { + if (i < n) dst[i] = src[i]; +} + +// The prompt's routing: each row's top experts and weights in the decode route's arithmetic, one simdgroup a row. +template +inline U glm_sigmoid_precise(U x) { + U e = static_cast(metal::precise::exp(metal::abs(x))); + U y = static_cast(1) / (static_cast(1) + e); + return (x < 0) ? y : (static_cast(1) - y); +} + +kernel void glm_route_rows(const device float* LOGITS [[buffer(0)]], const device float* BIAS [[buffer(1)]], + constant float& SCALE [[buffer(2)]], device uint* PICK [[buffer(3)]], + device float* WTS [[buffer(4)]], constant uint& rows [[buffer(5)]], + uint gid [[thread_position_in_grid]], uint lane [[thread_index_in_simdgroup]]) { + constexpr int NE = 288, TOPK = 8, PER = (NE + 31) / 32; + const int r = int(gid / 32); + if (r >= int(rows)) return; + float c[PER], sc[PER]; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < NE) { + sc[j] = glm_sigmoid_precise(LOGITS[r * NE + id]); + c[j] = sc[j] + BIAS[id]; + } else { + sc[j] = 0.0f; c[j] = -INFINITY; + } + } + float w[TOPK]; + for (int k = 0; k < TOPK; k++) { + float best = -INFINITY, bsc = 0.0f; + int bid = NE; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < NE && (c[j] > best || (c[j] == best && id < bid))) { best = c[j]; bid = id; bsc = sc[j]; } + } + for (int off = 16; off > 0; off /= 2) { + const float ob = simd_shuffle_xor(best, off); + const int oi = simd_shuffle_xor(bid, off); + const float os = simd_shuffle_xor(bsc, off); + if (ob > best || (ob == best && oi < bid)) { best = ob; bid = oi; bsc = os; } + } + w[k] = bsc; + if (int(lane) == bid % 32) c[bid / 32] = -INFINITY; + if (lane == 0) PICK[r * TOPK + k] = uint(bid); + } + if (lane == 0) { + float total = w[0]; + for (int k = 1; k < TOPK; k++) total = total + w[k]; + for (int k = 0; k < TOPK; k++) WTS[r * TOPK + k] = (w[k] / total) * SCALE; + } +} + +// The routed experts' activation for sorted pairs: the MoE kernel's SwiGLU on separate gate and up rows. +kernel void glm_act2(const device bfloat* G [[buffer(0)]], const device bfloat* U [[buffer(1)]], + device bfloat* ACT [[buffer(2)]], constant float& limit [[buffer(3)]], + constant uint& count [[buffer(4)]], uint i [[thread_position_in_grid]]) { + if (i >= count) return; + const float lim = float(bfloat(limit)); + const bfloat gt = bfloat(metal::min(float(G[i]), lim)); + const bfloat up = bfloat(metal::min(metal::max(float(U[i]), -lim), lim)); + const bfloat sl = gt * sigmoid_fast(gt); + ACT[i] = sl * up; +} + +// Key lists of rows that read every key (positions p0 + r with at most `dense` keys): 0 .. position, then -1. +kernel void glm_dense_indices(device int* indices [[buffer(0)]], constant uint4& a [[buffer(1)]], + uint2 p [[thread_position_in_grid]]) { + const uint width = a.x, p0 = a.y, rows = a.z; + if (p.x >= width || p.y >= rows) return; + const uint position = p0 + p.y; + indices[size_t(p.y) * width + p.x] = p.x <= position ? int(p.x) : -1; +} diff --git a/zig/tests/contract/baselines/glm_index_nax_main.metal.txt b/zig/tests/contract/baselines/glm_index_nax_main.metal.txt new file mode 100644 index 00000000000..f03222deece --- /dev/null +++ b/zig/tests/contract/baselines/glm_index_nax_main.metal.txt @@ -0,0 +1,174 @@ +// GLM prompt-chunk index scores, tensor units: row r's fp32 pool_b score, ordered head sum of w_h relu(q_h . pool_b). +#include +using namespace metal; +#include "../nax.h" +using namespace tfp; + +constant constexpr int HI = 32, DI = 128, PAD = DI + 8; + +struct GlmScoreArgs { + uint p0, q_stride, w_stride, s_stride, rows; +}; + +// A fragment of q at column c from a lane's two row starts (8-byte loads on M5). +inline frag ix_frag(const device bfloat* r0, const device bfloat* r1, int c, short2 home) { +#ifndef TF_SIMD_FRAGS + return frag(*(const device bfloat4*)(r0 + c + home.x), *(const device bfloat4*)(r1 + c + home.x)); +#else + frag f; + TF_UNROLL + for (short e = 0; e < 8; e++) { + f[e] = (e < 4 ? r0 : r1)[c + home.x + TF_COL(e)]; + } + return f; +#endif +} + +// Grid: 64-block, 64-row tiles; 4 simdgroups, 32 rows x 32 blocks; only read blocks stored, whole tiles beyond skipped. +[[kernel]] void glm_index_scores_nax(const device bfloat* iq [[buffer(0)]], const device bfloat* iw [[buffer(1)]], + const device bfloat* pool [[buffer(2)]], device float* scores [[buffer(3)]], + constant GlmScoreArgs& a [[buffer(4)]], uint sg [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { + threadgroup bfloat tile[64 * PAD]; + const int b0 = int(tg.x) * 64, r0 = int(tg.y) * 64; + const int rows = min(64, int(a.rows) - r0); + if (b0 >= (int(a.p0) + r0 + rows) / 4) return; // the tile's last row reads blocks below (p0 + row + 1) / 4 + const uint t = sg * 32 + lane; + for (uint i = t; i < 64 * (DI / 8); i += 128) { // the 64 blocks' pooled keys, 16 bytes a load (past the pool: its last) + const uint rr = i / (DI / 8), cc = (i % (DI / 8)) * 8; + const int b = min(b0 + int(rr), int(a.s_stride) - 1); + *(threadgroup uint4*)(tile + rr * PAD + cc) = *(const device uint4*)(pool + size_t(b) * DI + cc); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + const short2 home = frag_home(ushort(lane)); + const int tm = 32 * int(sg / 2), tn = 32 * int(sg % 2); + const device bfloat* qr[2][2]; + const device bfloat* wr[2][2]; + TF_UNROLL + for (short m = 0; m < 2; m++) { + TF_UNROLL + for (short h = 0; h < 2; h++) { + const int r = tm + 16 * m + home.y + 8 * h; + const long at = long(r0 + (r < rows ? r : 0)); // a dead row reads a live one; its scores are never stored + qr[m][h] = iq + at * a.q_stride; + wr[m][h] = iw + at * a.w_stride; + } + } + frag total[2][2]; + TF_UNROLL + for (short m = 0; m < 2; m++) { + total[m][0] = frag(0); + total[m][1] = frag(0); + } + for (int hd = 0; hd < HI; hd++) { + frag s[2][2]; + TF_UNROLL + for (short m = 0; m < 2; m++) { + s[m][0] = frag(0); + s[m][1] = frag(0); + } + TF_UNROLL + for (short q = 0; q < DI / 16; q++) { + frag k0, k1; + frag_get_t(k0, (const threadgroup bfloat*)tile, PAD, tn, 16 * q, home); + frag_get_t(k1, (const threadgroup bfloat*)tile, PAD, tn + 16, 16 * q, home); + TF_UNROLL + for (short m = 0; m < 2; m++) { + const frag qa = ix_frag(qr[m][0] + hd * DI, qr[m][1] + hd * DI, 16 * q, home); + mma_16x32(s[m][0], s[m][1], qa, k0, k1); + } + } + TF_UNROLL + for (short m = 0; m < 2; m++) { + const float w0 = float(wr[m][0][hd]), w1 = float(wr[m][1][hd]); + TF_UNROLL + for (short j = 0; j < 2; j++) { + TF_UNROLL + for (short e = 0; e < 8; e++) { + total[m][j][e] = fma(e < 4 ? w0 : w1, metal::max(s[m][j][e], 0.0f), total[m][j][e]); + } + } + } + } + TF_UNROLL + for (short m = 0; m < 2; m++) { + TF_UNROLL + for (short j = 0; j < 2; j++) { + TF_UNROLL + for (short e = 0; e < 8; e++) { + const int r = tm + 16 * m + home.y + (e >> 2) * 8; + const int b = b0 + tn + 16 * j + home.x + TF_COL(e); + if (r < rows && b < (int(a.p0) + r0 + r + 1) / 4) scores[size_t(r0 + r) * a.s_stride + b] = total[m][j][e]; + } + } + } +} + +// A transposed right operand's element e: key (a block, the op's column), dim (on M5 the op loads it as any operand). +#ifndef TF_SIMD_FRAGS +inline short ix_key(short e, short2 home) { return home.y + (e >> 2) * 8; } +inline short ix_dim(short e, short2 home) { return home.x + (e & 3); } +#else +inline short ix_key(short e, short2 home) { return home.x + TF_COL(e); } +inline short ix_dim(short e, short2 home) { return home.y + (e >> 2) * 8; } +#endif + +// Decode index scores, grid (128-block tiles, rows) of 4 simdgroups: a row's 32 heads as the op's rows (exact bf16 products), relu, weights, a fixed head-sum tree. +[[kernel]] void glm_index_decode(const device bfloat* iq [[buffer(0)]], const device bfloat* iw [[buffer(1)]], + const device bfloat* pool [[buffer(2)]], device float* scores [[buffer(3)]], + constant GlmScoreArgs& a [[buffer(4)]], uint sg [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint3 tg [[threadgroup_position_in_grid]]) { + const int row = int(tg.y), b0 = int(tg.x) * 128 + 32 * int(sg); + const int blocks = (int(a.p0) + row + 1) / 4; + if (b0 >= blocks) return; + const short2 home = frag_home(ushort(lane)); + const device bfloat* q = iq + long(row) * a.q_stride; + frag s[2][2]; + TF_UNROLL + for (short m = 0; m < 2; m++) { + s[m][0] = frag(0); + s[m][1] = frag(0); + } + TF_UNROLL + for (short kq = 0; kq < DI / 16; kq++) { + frag k0, k1; +#ifndef TF_SIMD_FRAGS + k0 = frag(*(const device bfloat4*)(pool + long(min(b0 + int(home.y), blocks - 1)) * DI + 16 * kq + home.x), + *(const device bfloat4*)(pool + long(min(b0 + int(home.y) + 8, blocks - 1)) * DI + 16 * kq + home.x)); + k1 = frag(*(const device bfloat4*)(pool + long(min(b0 + 16 + int(home.y), blocks - 1)) * DI + 16 * kq + home.x), + *(const device bfloat4*)(pool + long(min(b0 + 24 + int(home.y), blocks - 1)) * DI + 16 * kq + home.x)); +#else + TF_UNROLL + for (short e = 0; e < 8; e++) { + k0[e] = pool[long(min(b0 + int(ix_key(e, home)), blocks - 1)) * DI + 16 * kq + ix_dim(e, home)]; + k1[e] = pool[long(min(b0 + 16 + int(ix_key(e, home)), blocks - 1)) * DI + 16 * kq + ix_dim(e, home)]; + } +#endif + TF_UNROLL + for (short m = 0; m < 2; m++) { + const frag qa = ix_frag(q + (16 * m + home.y) * DI, q + (16 * m + home.y + 8) * DI, 16 * kq, home); + mma_16x32(s[m][0], s[m][1], qa, k0, k1); + } + } + float w[2][2]; // the weights of this lane's heads: 16 m + home.y (+ 8) + TF_UNROLL + for (short m = 0; m < 2; m++) { + w[m][0] = float(iw[long(row) * a.w_stride + 16 * m + home.y]); + w[m][1] = float(iw[long(row) * a.w_stride + 16 * m + home.y + 8]); + } + TF_UNROLL + for (short j = 0; j < 2; j++) { + TF_UNROLL + for (short c = 0; c < 4; c++) { + float t = w[0][0] * metal::max(s[0][j][c], 0.0f); + t = fma(w[0][1], metal::max(s[0][j][4 + c], 0.0f), t); + t = fma(w[1][0], metal::max(s[1][j][c], 0.0f), t); + t = fma(w[1][1], metal::max(s[1][j][4 + c], 0.0f), t); + t += simd_shuffle_xor(t, ushort(2)); + t += simd_shuffle_xor(t, ushort(4)); + t += simd_shuffle_xor(t, ushort(16)); + const int b = b0 + 16 * j + home.x + TF_COL(c); + if (home.y == 0 && b < blocks) scores[long(row) * a.s_stride + b] = t; + } + } +} diff --git a/zig/tests/contract/baselines/hc_boundary_main.metal.txt b/zig/tests/contract/baselines/hc_boundary_main.metal.txt new file mode 100644 index 00000000000..728069f9c6b --- /dev/null +++ b/zig/tests/contract/baselines/hc_boundary_main.metal.txt @@ -0,0 +1,189 @@ +// A hyper-connection boundary in two launches: the expand with the mix's and the norm's partial sums, then the split. +#include +using namespace metal; + +// Defines: TF_D (stream width, multiple of 1024), TF_ITERS (Sinkhorn iterations), TF_HC_EPS_INT (split's eps in 1e-9). +constant constexpr int S = 4, F = S * TF_D, MIX = (2 + S) * S, SLICES = F / 1024, PARTS = MIX + 1; + +#pragma clang fp contract(off) +inline float hc_sq_acc(float acc, float v) { return v * v + acc; } +inline float hc_add_nc(float a, float b) { return a + b; } +#pragma clang fp contract(on) + +// (SLICES, rows) of 256: slice j's thread t expands 1024 j + 4 t..; squares + 24 mixes into PART [rows, SLICES, 25]. +template +[[kernel]] void tf_hc_expand_mix(const device bfloat* XOLD [[buffer(0)]], const device bfloat* BRANCH [[buffer(1)]], + const device float* POST [[buffer(2)]], const device float* COMB [[buffer(3)]], + const device uint4* FNP [[buffer(4)]], device bfloat* XNEW [[buffer(5)]], + device float* PART [[buffer(6)]], uint2 tg [[threadgroup_position_in_grid]], + uint2 tpos [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + threadgroup float red[8][PARTS]; + const int j = int(tg.x), r = int(tg.y); + const uint t = tpos.x; + const device bfloat* xo = XOLD + size_t(r) * F; + float vals[4]; + float ss = 0.0f; + for (int tn = 0; tn < 4; tn++) { + const int f = 1024 * j + 4 * int(t) + tn; + float v; + if (EXPAND) { + const int s = f / TF_D, d = f - s * TF_D; + const float y = POST[r * S + s] * float(BRANCH[size_t(r) * TF_D + d]); + const device float* c = COMB + r * S * S; + float mm = c[0 * S + s] * float(xo[0 * TF_D + d]); + mm = fma(c[1 * S + s], float(xo[1 * TF_D + d]), mm); + mm = fma(c[2 * S + s], float(xo[2 * TF_D + d]), mm); + mm = fma(c[3 * S + s], float(xo[3 * TF_D + d]), mm); + const bfloat nb = bfloat(hc_add_nc(y, mm)); + XNEW[size_t(r) * F + f] = nb; + v = float(nb); + } else { + v = float(xo[f]); + } + vals[tn] = v; + ss = hc_sq_acc(ss, v); + } + float acc[PARTS]; + for (int og = 0; og < MIX / 4; og++) { // the packed mix: [og][sg][lane][slice][tm][tn] + const device uint4* w = FNP + (size_t(og * 8 + int(sg)) * 32 + lane) * SLICES * 2 + j * 2; + float inter[4][4]; + for (int h = 0; h < 2; h++) { + const uint4 v = w[h]; + const uint words[4] = {v.x, v.y, v.z, v.w}; + for (int k = 0; k < 4; k++) { + const int e = h * 8 + k * 2; + inter[e / 4][e % 4] = as_type(words[k] << 16); + inter[(e + 1) / 4][(e + 1) % 4] = as_type(words[k] & 0xffff0000u); + } + } + for (int tm = 0; tm < 4; tm++) { + float a = 0.0f; + for (int tn = 0; tn < 4; tn++) a += inter[tm][tn] * vals[tn]; + acc[og * 4 + tm] = a; + } + } + acc[MIX] = ss; + for (int i = 0; i < PARTS; i++) { + const float v = simd_sum(acc[i]); + if (lane == 0) red[sg][i] = v; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (int(t) < PARTS) { + float a = red[0][t]; + for (int k = 1; k < 8; k++) a += red[k][t]; + PART[(size_t(r) * SLICES + j) * PARTS + t] = a; + } +} + +template [[host_name("tf_hc_expand_mix")]] [[kernel]] decltype(tf_hc_expand_mix) tf_hc_expand_mix; +template [[host_name("tf_hc_first_mix")]] [[kernel]] decltype(tf_hc_expand_mix) tf_hc_expand_mix; + +// In-place pending branch to the streams (one prompt buffer): TF_D / 4 a row, 4 stream columns each, read before write. +[[kernel]] void tf_hc_expand_inplace(device bfloat* X [[buffer(0)]], const device bfloat* BRANCH [[buffer(1)]], + const device float* POST [[buffer(2)]], const device float* COMB [[buffer(3)]], + uint r [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]]) { + device bfloat* x = X + size_t(r) * F; + const device float* c = COMB + r * S * S; + for (int i = 0; i < 4; i++) { + const int d = 4 * int(t) + i; + float nb[S]; + for (int s = 0; s < S; s++) { + const float y = POST[r * S + s] * float(BRANCH[size_t(r) * TF_D + d]); + float mm = c[0 * S + s] * float(x[0 * TF_D + d]); + mm = fma(c[1 * S + s], float(x[1 * TF_D + d]), mm); + mm = fma(c[2 * S + s], float(x[2 * TF_D + d]), mm); + mm = fma(c[3 * S + s], float(x[3 * TF_D + d]), mm); + nb[s] = hc_add_nc(y, mm); + } + for (int s = 0; s < S; s++) x[s * TF_D + d] = bfloat(nb[s]); + } +} + +// The 4x4 comb's column sums over lanes 0-3 (the rest hold zeros): pairs, then pairs of pairs, simd_sum's bits. +inline float4 hc_col4(float4 v) { + v += simd_shuffle_xor(v, ushort(1)); + return v + simd_shuffle_xor(v, ushort(2)); +} + +// 1024 a row: slice sums in order, mixes by 1/norm, then the split (pre, post, Sinkhorn), streams collapsed, normed. +[[kernel]] void tf_hc_split(const device bfloat* X [[buffer(0)]], const device float* PART [[buffer(1)]], + const constant float* SCALE [[buffer(2)]], const device float* BASEV [[buffer(3)]], + const device bfloat* NORMW [[buffer(4)]], const constant float* EPS [[buffer(5)]], + device bfloat* NORMED [[buffer(6)]], device float* POST_OUT [[buffer(7)]], + device float* COMB_OUT [[buffer(8)]], uint tg [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + constexpr float HC_EPS = TF_HC_EPS_INT * 1e-9; + const int r = int(tg); + threadgroup float tot[PARTS]; + threadgroup float mixes[MIX]; + threadgroup float red[32]; + threadgroup float pre_s[S]; + threadgroup float inv_s[1]; + device const bfloat* xs = X + size_t(r) * F; + float xv[4][S]; // this thread's 4 columns of the streams, loaded while the mixes and the Sinkhorn run + for (int i = 0; i < 4; ++i) { + for (int s = 0; s < S; ++s) xv[i][s] = float(xs[s * TF_D + int(t) * 4 + i]); + } + if (int(t) < PARTS) { + const device float* p = PART + size_t(r) * SLICES * PARTS + t; + float a = p[0]; + for (int j = 1; j < SLICES; j++) a += p[j * PARTS]; + tot[t] = a; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (int(t) < MIX) mixes[t] = tot[t] * metal::precise::rsqrt(tot[MIX] / float(F) + EPS[0]); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + constexpr int BASE_OFF = 2 * S; + const float pre_scale = SCALE[0], post_scale = SCALE[1], comb_scale = SCALE[2]; + const float active = (lane < (uint)S) ? 1.0f : 0.0f; + const uint llane = metal::min(lane, (uint)(S - 1)); + const float pre_z = mixes[llane] * pre_scale + BASEV[llane]; + const float post_z = mixes[S + llane] * post_scale + BASEV[S + llane]; + const float pre_v = 1.0f / (1.0f + metal::fast::exp(-pre_z)) + HC_EPS; + const float post_v = 2.0f / (1.0f + metal::fast::exp(-post_z)); + if (lane < (uint)S) { + pre_s[lane] = pre_v; + POST_OUT[r * S + lane] = post_v; + } + const float4 m4 = float4(mixes[BASE_OFF + llane * S], mixes[BASE_OFF + llane * S + 1], mixes[BASE_OFF + llane * S + 2], + mixes[BASE_OFF + llane * S + 3]); + float4 v = (m4 * comb_scale + *(const device float4*)(BASEV + BASE_OFF + llane * S)) * active; + const float row_max = metal::max(metal::max(v.x, v.y), metal::max(v.z, v.w)); + const float4 e = metal::fast::exp(v - row_max) * active; + float4 rr = e * (1.0f / (e.x + e.y + e.z + e.w + HC_EPS)) + HC_EPS * active; + float4 col_inv = 1.0f / (hc_col4(rr) + HC_EPS); + rr *= col_inv; + for (int iter = 1; iter < TF_ITERS; ++iter) { + rr *= (1.0f / (rr.x + rr.y + rr.z + rr.w + HC_EPS)) * active; + col_inv = 1.0f / (hc_col4(rr) + HC_EPS); + rr *= col_inv; + } + if (lane < (uint)S) *(device float4*)(COMB_OUT + r * S * S + lane * S) = rr; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + const float p0 = pre_s[0], p1 = pre_s[1], p2 = pre_s[2], p3 = pre_s[3]; + float xc[4]; + float acc = 0.0f; + for (int i = 0; i < 4; ++i) { + const float res = fma(p0, xv[i][0], fma(p1, xv[i][1], fma(p2, xv[i][2], p3 * xv[i][3]))); + xc[i] = float(bfloat(res)); + acc = hc_sq_acc(acc, xc[i]); + } + acc = simd_sum(acc); + if (sg == 0) red[lane] = 0.0f; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 0) red[sg] = acc; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + const float a = simd_sum(red[lane]); + if (lane == 0) inv_s[0] = metal::precise::rsqrt(a / float(TF_D) + EPS[0]); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + for (int i = 0; i < 4; ++i) { + const int d = int(t) * 4 + i; + NORMED[size_t(r) * TF_D + d] = NORMW[d] * bfloat(xc[i] * inv_s[0]); + } +} diff --git a/zig/tests/contract/baselines/moe_route_main.metal.txt b/zig/tests/contract/baselines/moe_route_main.metal.txt new file mode 100644 index 00000000000..0d5df32b2fd --- /dev/null +++ b/zig/tests/contract/baselines/moe_route_main.metal.txt @@ -0,0 +1,155 @@ +// A MoE layer's route, 1-16 rows: router logits in the one-row kernel's order, then top-k and this Mac's expert groups. +#include +using namespace metal; + +#ifndef TF_OUT_T +#define TF_OUT_T float +#endif +constant constexpr int ITERS = TF_K / 32; +constant constexpr int PERL = ITERS / 32; // the 32-wide slices of k each lane takes +constant constexpr int PER = (TF_E + 31) / 32; + +// Logits [rows, E] = x W^T, tg 4 experts x 4 rows; simdgroup s: k=32i+4s+tm, lane l: PERL i's from PERL*l; 8 partials. +[[kernel]] void tf_route_logits(const device bfloat* X [[buffer(0)]], const device uint4* RP [[buffer(1)]], + constant int& rows [[buffer(2)]], device TF_OUT_T* OUT [[buffer(3)]], + uint2 tg [[threadgroup_position_in_grid]], uint2 tpos [[thread_position_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]], uint s [[simdgroup_index_in_threadgroup]]) { + threadgroup float part[8][16]; + const int q = int(tg.x), r0 = int(tg.y) * 4; + const device uint4* w = RP + ((size_t(q) * 8 + s) * ITERS + PERL * lane) * 2; + float acc[4][4]; // [row][expert] + for (int c = 0; c < 4; c++) + for (int tn = 0; tn < 4; tn++) acc[c][tn] = 0.0f; + for (int ii = 0; ii < PERL; ii++) { + float inter[4][4]; + for (int h = 0; h < 2; h++) { + const uint4 v = w[ii * 2 + h]; + const uint words[4] = {v.x, v.y, v.z, v.w}; + for (int j = 0; j < 4; j++) { + const int e = h * 8 + j * 2; + inter[e / 4][e % 4] = as_type(words[j] << 16); + inter[(e + 1) / 4][(e + 1) % 4] = as_type(words[j] & 0xffff0000u); + } + } + const int k = 32 * (PERL * int(lane) + ii) + 4 * int(s); + for (int c = 0; c < 4; c++) { + const device bfloat* x = X + size_t(min(r0 + c, rows - 1)) * TF_K + k; + for (int tm = 0; tm < 4; tm++) { + const float xv = float(x[tm]); + for (int tn = 0; tn < 4; tn++) acc[c][tn] += xv * inter[tm][tn]; + } + } + } + for (int c = 0; c < 4; c++) + for (int tn = 0; tn < 4; tn++) { + const float v = simd_sum(acc[c][tn]); + if (lane == 0) part[s][c * 4 + tn] = v; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + const int o = int(tpos.x); + if (o < 16 && r0 + o / 4 < rows) { + float v = part[0][o]; + for (int k = 1; k < 8; k++) v += part[k][o]; +#ifdef TF_ROUND_LOGITS + v = float(bfloat(v)); +#endif + OUT[size_t(r0 + o / 4) * TF_E + 4 * q + o % 4] = static_cast(v); + } +} + +inline float tf_sigmoid_precise(float x) { + float e = metal::precise::exp(metal::abs(x)); + float y = 1.0f / (1.0f + e); + return (x < 0) ? y : (1.0f - y); +} + +struct RouteArgs { + int rows; + int lo, hi; // the experts this Mac computes: [lo, hi) + float scale; +}; + +// 512 threads: each row's top-k by sigmoid + bias (ties to the lower id), weights, then this Mac's groups, pick lists. +[[kernel]] void tf_route_select(const device float* LOGITS [[buffer(0)]], const device float* BIAS [[buffer(1)]], + constant RouteArgs& a [[buffer(2)]], device int* PICK [[buffer(3)]], + device float* WTS [[buffer(4)]], device int* LIDS [[buffer(5)]], + device int* LMEM [[buffer(6)]], device int* LCOUNT [[buffer(7)]], + device int* MINE [[buffer(8)]], device int* THEIRS [[buffer(9)]], + device int* COUNTS [[buffer(10)]], device atomic_uint* CNT [[buffer(11)]], + uint t [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint g [[simdgroup_index_in_threadgroup]]) { + const int R = a.rows; + const int e = int(t); + threadgroup int picks[TF_MAXR * TF_TOPK]; + threadgroup int offs[3][16]; + if (int(g) < R) { + const int r = int(g); + float c[PER], sc[PER]; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < TF_E) { + sc[j] = tf_sigmoid_precise(LOGITS[r * TF_E + id]); + c[j] = sc[j] + BIAS[id]; + } else { + sc[j] = 0.0f; c[j] = -INFINITY; + } + } + float w[TF_TOPK]; + for (int k = 0; k < TF_TOPK; k++) { + float best = -INFINITY, bsc = 0.0f; + int bid = TF_E; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < TF_E && (c[j] > best || (c[j] == best && id < bid))) { best = c[j]; bid = id; bsc = sc[j]; } + } + for (int off = 16; off > 0; off /= 2) { + const float ob = simd_shuffle_xor(best, off); + const int oi = simd_shuffle_xor(bid, off); + const float os = simd_shuffle_xor(bsc, off); + if (ob > best || (ob == best && oi < bid)) { best = ob; bid = oi; bsc = os; } + } + w[k] = bsc; + if (int(lane) == bid % 32) c[bid / 32] = -INFINITY; + if (lane == 0) { picks[r * TF_TOPK + k] = bid; PICK[r * TF_TOPK + k] = bid; } + } + if (lane == 0) { + float total = w[0]; + for (int k = 1; k < TF_TOPK; k++) total = total + w[k]; + for (int k = 0; k < TF_TOPK; k++) WTS[r * TF_TOPK + k] = (w[k] / total) * a.scale; + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + // the held experts the window picked, ascending, with their member picks in pick order + int members[TF_MAXR]; + int count = 0; + const bool held_id = e >= a.lo && e < a.hi; + if (held_id) + for (int p = 0; p < R * TF_TOPK; p++) + if (picks[p] == e) members[count++] = p; + const int held = count > 0 ? 1 : 0; + // each pick: computed here or by the peer + const int pe = e < R * TF_TOPK ? picks[e] : -1; + const int mine = pe >= a.lo && pe < a.hi ? 1 : 0; + const int theirs = pe >= 0 && mine == 0 ? 1 : 0; + const int b0 = simd_prefix_exclusive_sum(held), b1 = simd_prefix_exclusive_sum(mine), b2 = simd_prefix_exclusive_sum(theirs); + if (lane == 31) { offs[0][g] = b0 + held; offs[1][g] = b1 + mine; offs[2][g] = b2 + theirs; } + threadgroup_barrier(mem_flags::mem_threadgroup); + int o0 = 0, o1 = 0, o2 = 0, n0 = 0, n1 = 0, n2 = 0; + for (uint k = 0; k < 16; k++) { + if (k < g) { o0 += offs[0][k]; o1 += offs[1][k]; o2 += offs[2][k]; } + n0 += offs[0][k]; n1 += offs[1][k]; n2 += offs[2][k]; + } + if (held) { + const int u = o0 + b0; + LIDS[u] = e - a.lo; + for (int j = 0; j < TF_MAXR; j++) LMEM[u * TF_MAXR + j] = j < count ? members[j] : -1; + } + if (mine) MINE[o1 + b1] = e; + if (theirs) THEIRS[o2 + b2] = e; + if (t == 0) { + LCOUNT[0] = n0; + COUNTS[0] = n1; + COUNTS[1] = n2; + atomic_store_explicit(CNT, uint(n1), memory_order_relaxed); + } +} diff --git a/zig/tests/contract/metal_glm_attn.zig b/zig/tests/contract/metal_glm_attn.zig new file mode 100644 index 00000000000..e5dabbbe104 --- /dev/null +++ b/zig/tests/contract/metal_glm_attn.zig @@ -0,0 +1,180 @@ +//! GLM's dense latent attention for a window (dense_attn.zig's attendRows) against main's scale and one-row launches. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const glm = tf.glm; + +const H = 64; +const RANK = 512; +const TOP = 2048; +const lat = H * RANK; // a row's latent queries and outputs +const plane = H * TOP; // and its scores and probabilities +/// Main's glm_attn.metal, before the window kernels: the one-row scores and values every window row must equal. +pub const main_attn = @embedFile("baselines/glm_attn_main.metal.txt"); +/// Main's glm_glue.metal: glm_scale, which scaled the dense rows' queries by 1/16 before the scores kernel read them. +pub const main_glue = @embedFile("baselines/glm_glue_main.metal.txt"); +const q_scale: f32 = 1.0 / 16.0; // forward.zig's attend + +/// Rows: the window's dense rows; n: the heads; k: the first row's keys (edges: the 256-key join, the 1,024-key split). +const served = [_]c.Shape{ .{ .rows = 8, .n = H, .k = 400 }, .{ .rows = 1, .n = H, .k = 1 }, .{ .rows = 16, .n = H, .k = 1 }, .{ .rows = 3, .n = H, .k = 5 }, .{ .rows = 2, .n = H, .k = 31 }, .{ .rows = 4, .n = H, .k = 33 }, .{ .rows = 16, .n = H, .k = 240 }, .{ .rows = 2, .n = H, .k = 255 }, .{ .rows = 1, .n = H, .k = 256 }, .{ .rows = 3, .n = H, .k = 700 }, .{ .rows = 16, .n = H, .k = 1010 }, .{ .rows = 2, .n = H, .k = 1024 }, .{ .rows = 8, .n = H, .k = 1500 }, .{ .rows = 16, .n = H, .k = 2033 }, .{ .rows = 1, .n = H, .k = 2048 } }; + +pub const Fault = enum { none, halves, softmax, split, prefetch, unscaled }; + +/// The loader's latent attention library on this GPU (nax.h inlined for it). +pub fn attnText(a: std.mem.Allocator, device: mtl.Device) ![]u8 { + return tf.frags.source(device, a, sources.glm_attn); +} + +/// kernels.zig's window softmax: ops/softmax.metal with glm_softmax_rows appended. +pub const softmax_rows_text = sources.ops_softmax ++ sources.glm_softmax_rows; + +pub const Case = struct { + a: std.mem.Allocator, + fault: Fault, + control: bool, + kern: glm.kernels.Kernels = undefined, + old: [4]mtl.Pipeline, + cfg: glm.config.Config = .{}, + + pub fn init(s: *bits.Suite, fault: Fault) !Case { + const loader = try s.production(); + const attn = try attnText(s.a, s.device); + defer s.a.free(attn); + _ = try loader.require(attn); + _ = try loader.require(softmax_rows_text); + const faults = [_][3][]const u8{ .{ "", "", "" }, .{ "void glm_latent_scores_rows(", "n, n < 256,", "n, n < 255," }, .{ "void glm_softmax_rows(", "a.n0 + int(tg.y)", "a.n0 + int(tg.y) + 1" }, .{ "void glm_latent_values_rows(", "n > 1024 ? 1024 : 0", "n > 1024 ? 512 : 0" }, .{ "inline void glm_scores_at(", "mma_16x32(c0, c1, ca, cb0, cb1);", "mma_16x32(c0, c1, a, cb0, cb1);" }, .{ "if (k0 + 16 < 512) {", "glm_q_scaled(a, qs);", "" } }; + const f = faults[@backingInt(fault)]; + const own_attn = if (fault == .halves or fault == .split or fault == .prefetch or fault == .unscaled) try bits.edited(s.a, attn, f[0], f[1], f[2]) else try s.a.dupe(u8, attn); + defer s.a.free(own_attn); + const own_soft = if (fault == .softmax) try bits.edited(s.a, softmax_rows_text, f[0], f[1], f[2]) else try s.a.dupe(u8, softmax_rows_text); + defer s.a.free(own_soft); + var x: Case = .{ .a = s.a, .fault = fault, .control = fault != .none, .old = undefined }; + x.kern.latent_scores_rows = try bits.pipeline(s.device, own_attn, "glm_latent_scores_rows"); + errdefer x.kern.latent_scores_rows.deinit(); + x.kern.latent_values_rows = try bits.pipeline(s.device, own_attn, "glm_latent_values_rows"); + errdefer x.kern.latent_values_rows.deinit(); + x.kern.softmax_rows = try bits.pipeline(s.device, own_soft, "glm_softmax_rows"); + errdefer x.kern.softmax_rows.deinit(); + const frozen = try tf.frags.source(s.device, s.a, main_attn); + defer s.a.free(frozen); + x.old[0] = try bits.pipeline(s.device, frozen, "glm_latent_scores"); + errdefer x.old[0].deinit(); + x.old[1] = try bits.pipeline(s.device, try loader.require(sources.ops_softmax), "tf_softmax_bf16"); + errdefer x.old[1].deinit(); + x.old[2] = try bits.pipeline(s.device, frozen, "glm_latent_values"); + errdefer x.old[2].deinit(); + x.old[3] = try bits.pipeline(s.device, main_glue, "glm_scale"); + return x; + } + pub fn deinit(x: *Case) void { + x.kern.latent_scores_rows.deinit(); + x.kern.latent_values_rows.deinit(); + x.kern.softmax_rows.deinit(); + for (x.old) |p| p.deinit(); + } + pub fn name(fault: Fault) []const u8 { + return switch (fault) { + .none => "metal glm launch attn rows glm_latent_scores_rows, glm_softmax_rows, glm_latent_values_rows", + .halves => "control: metal glm launch attn rows, the scores' two-half join from 255 keys", + .softmax => "control: metal glm launch attn rows, each row's softmax one key long", + .split => "control: metal glm launch attn rows, the values split at 512 keys", + .prefetch => "control: metal glm launch attn rows, a scores step multiplying the prefetched next query block", + .unscaled => "control: metal glm launch attn rows, the prefetched query blocks left unscaled", + }; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.fault), "main's glm_scale, then glm_latent_scores, tf_softmax_bf16 and glm_latent_values a row", "main's one-row bytes in the scores, probabilities and outputs, NaN payloads included", &served, "the one-row kernels' 16-wide MMA steps, both joins and the softmax's sums in their order"); + } + pub fn layout(_: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.rows > 16 or s.n != H or s.k == 0 or s.k + s.rows - 1 > TOP) return null; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * lat * 2, .bf16); + _ = l.add(.input, (s.k + s.rows - 1) * RANK * 2, .bf16); + _ = l.add(.output, s.rows * plane * 2, .bf16); + _ = l.add(.output, s.rows * plane * 2, .bf16); + _ = l.add(.output, s.rows * lat * 2, .bf16); + _ = l.add(.scratch, s.rows * lat * 2, .bf16); + return l; + } + /// The harness's queries and keys; gate 1 and every third shape plant NaN and both infinities in a query and keys. + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const q = std.mem.bytesAsSlice(u16, data[0]); + const keys = std.mem.bytesAsSlice(u16, data[1]); + for (q) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 4); + for (keys) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + if (f == .stress or (f == .random and seed % 3 != 2)) return; + q[3] = 0x7fc0; + const early: usize = if (s.k > 2) 2 else s.k - 1; + keys[early * RANK + 5] = 0x7f80; + keys[(s.k + s.rows - 2) * RANK + 9] = 0xff80; + } + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const R = glm.weights.Ref; + const ref = struct { + fn of(v: rig_.Ref) R { + return .{ .buf = v.buf, .off = v.off }; + } + }.of; + if (new) { + const ctx: glm.forward.Ctx = .{ .k = &x.kern, .c = &x.cfg, .w = undefined, .s = undefined, .sc = undefined }; + return glm.forward.attendRows(&ctx, e, ref(r[1]), ref(r[0]), q_scale, ref(r[2]), ref(r[3]), ref(r[4]), @intCast(s.k), @intCast(s.rows)); + } + e.setPipeline(x.old[3]); // main's attend: every dense row's queries through glm_scale, then each row's launches + e.setBuffer(r[0].buf, r[0].off, 0); + e.setBuffer(r[5].buf, r[5].off, 1); + e.setValue(glm.forward.Rows{ .rows = @intCast(s.rows * H), .width = RANK, .x_stride = RANK, .y_stride = RANK, .eps = q_scale }, 2); + e.dispatchThreads(mtl.Size.of(RANK, s.rows * H, 1), mtl.Size.of(256, 1, 1)); + for (0..s.rows) |z| x.oneRow(e, r, z, @intCast(s.k + z)); + } + /// Main's attendDense for window row z (forward.zig before the window kernels): its three launches as they were. + fn oneRow(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, z: usize, n: u32) void { + const bind = struct { + fn at(enc: mtl.ComputeEncoder, v: rig_.Ref, extra: usize, i: usize) void { + enc.setBuffer(v.buf, v.off + extra, i); + } + }.at; + e.setPipeline(x.old[0]); + bind(e, r[5], z * lat * 2, 0); + bind(e, r[1], 0, 1); + bind(e, r[2], z * plane * 2, 2); + e.setValue([2]i32{ @intCast(n), @intFromBool(n < 256) }, 3); + e.dispatchGroups(mtl.Size.of((n + 31) / 32, 1, 1), mtl.Size.of(2 * H, 1, 1)); + e.setPipeline(x.old[1]); + bind(e, r[2], z * plane * 2, 0); + e.setBytes(std.mem.asBytes(&[1]i32{@intCast(n)}), 1); + bind(e, r[3], z * plane * 2, 2); + e.dispatchGroups(mtl.Size.of(H, 1, 1), mtl.Size.of(((n + 3) / 4 + 31) / 32 * 32, 1, 1)); + e.setPipeline(x.old[2]); + bind(e, r[3], z * plane * 2, 0); + bind(e, r[1], 0, 1); + bind(e, r[4], z * lat * 2, 2); + e.setValue([2]i32{ @intCast(n), if (n > 1024) 1024 else 0 }, 3); + e.dispatchGroups(mtl.Size.of(RANK / 32, 1, 1), mtl.Size.of(2 * H, 1, 1)); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for (std.enums.values(Fault)) |fault| { + if (s.wanted(only, Case.name(fault))) try s.add(Case, try Case.init(s, fault)); + } +} + +/// Gate 5's registrations `glm launch attn ` and `glm launch softmax `. +pub const prefix = "glm launch attn "; +pub fn limitsText(a: std.mem.Allocator, device: mtl.Device, _: []const u8) !bits.Texts { + return .{ .here = try attnText(a, device), .pre_m5 = try tf.frags.precision.source(a, false, sources.glm_attn, sources.nax, false) }; +} +pub const softmax = struct { + pub const prefix = "glm launch softmax "; + pub fn limitsText(_: std.mem.Allocator, _: mtl.Device, _: []const u8) !bits.Texts { + return .{ .here = softmax_rows_text, .pre_m5 = softmax_rows_text }; + } +}; diff --git a/zig/tests/contract/metal_glm_bits.zig b/zig/tests/contract/metal_glm_bits.zig new file mode 100644 index 00000000000..dcc889d292b --- /dev/null +++ b/zig/tests/contract/metal_glm_bits.zig @@ -0,0 +1,279 @@ +//! GLM Metal launches that keep a predecessor's bits: each case's served launches against it on the same inputs. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; + +/// A buffer of one call: read only, written whole, read then written (the predecessor gets its own copy), or working. +pub const Kind = enum { input, output, inout, scratch }; +/// How gate 1 counts a written buffer's exceptional values: fp32 or bf16 elements, or none (indices, counts). +pub const Elem = enum { f32, bf16, int }; +pub const Slot = struct { kind: Kind, len: usize, elem: Elem = .int }; +pub const max_slots = 24; + +/// A case's own layout for a shape: its slots, or null where the shape is not one it serves. +pub const Layout = struct { + slots: [max_slots]Slot = undefined, + n: usize = 0, + pub fn add(l: *Layout, kind: Kind, len: usize, elem: Elem) usize { + l.slots[l.n] = .{ .kind = kind, .len = len, .elem = elem }; + l.n += 1; + return l.n - 1; + } +}; + +/// Exceptional elements (NaN, either infinity) of a written buffer. +fn exceptional(elem: Elem, bytes: []const u8) usize { + var n: usize = 0; + switch (elem) { + .int => {}, + .f32 => for (0..bytes.len / 4) |i| { + n += @intFromBool(!std.math.isFinite(c.read(.f32, bytes, i))); + }, + .bf16 => for (0..bytes.len / 2) |i| { + n += @intFromBool(!std.math.isFinite(c.read(.bf16, bytes, i))); + }, + } + return n; +} + +/// The probe of case type C: C has `spec`, `layout`, `fill`, `encode` (new or predecessor) and `deinit`. +pub fn Probe(comptime C: type) type { + return struct { + const P = @This(); + a: std.mem.Allocator, + rig: rig_.Rig, + case: C, + shape: c.Shape = undefined, + layout: Layout = .{}, + data: [max_slots][]u8 = @splat(&.{}), + refs: [max_slots]rig_.Ref = undefined, + base: [max_slots]rig_.Ref = undefined, + got: std.ArrayList(u8) = .empty, + want: std.ArrayList(u8) = .empty, + msg: [200]u8 = undefined, + + fn free(p: *P) void { + for (&p.data) |*d| { + p.a.free(d.*); + d.* = &.{}; + } + p.rig.reset(); + } + pub fn deinit(p: *P) void { + p.free(); + p.rig.deinit(); + p.got.deinit(p.a); + p.want.deinit(p.a); + p.case.deinit(); + } + const vt = blk: { + var v = g.hooks(P); + v.release = release; + break :blk v; + }; + fn release(ctx: *anyopaque) void { + const p: *P = @ptrCast(@alignCast(ctx)); + p.free(); + } + pub fn kernel(p: *P) g.Kernel { + const s = p.case.spec(); + return .{ .spec = s, .ctx = p, .vt = &vt, .control = if (p.case.control) .shapes else null }; + } + pub fn prepare(p: *P, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + p.free(); + p.layout = p.case.layout(shape) orelse return false; + p.shape = shape; + const slots = p.layout.slots[0..p.layout.n]; + for (slots, 0..) |s, i| if (s.kind == .input or s.kind == .inout) { + p.data[i] = try p.a.alloc(u8, s.len); + }; + try p.case.fill(shape, fill, seed, p.data[0..p.layout.n]); + for (slots, 0..) |s, i| p.refs[i] = switch (s.kind) { + .input => try p.rig.input(p.data[i]), + .output, .inout => try p.rig.output(s.len), + .scratch => try p.rig.scratch(s.len), + }; + for (slots, 0..) |s, i| p.base[i] = if (s.kind == .output or s.kind == .inout) try p.rig.scratch(s.len) else p.refs[i]; + return true; + } + /// Outputs poisoned (an element no launch writes stays 0xff), in-place buffers as prepared, scratch zeroed. + fn reset(p: *P, refs: []const rig_.Ref) void { + for (p.layout.slots[0..p.layout.n], refs, 0..) |s, r, i| { + const bytes = p.rig.bytes(r, s.len); + switch (s.kind) { + .input => {}, + .output => @memset(bytes, 0xff), + .inout => @memcpy(bytes, p.data[i]), + .scratch => @memset(bytes, 0), + } + } + } + fn launch(p: *P, refs: []const rig_.Ref, new: bool) !void { + p.reset(refs); + const pass = p.rig.begin(); + p.case.encode(pass.e, refs, p.shape, new); + try p.rig.finish(pass); + } + pub fn run(p: *P) !void { + try p.launch(p.refs[0..p.layout.n], true); + } + /// The predecessor's bytes on the same inputs, its written buffers in the order the rig gathers the probe's. + pub fn replaced(p: *P) ![]const u8 { + try p.launch(p.base[0..p.layout.n], false); + p.want.clearRetainingCapacity(); + for (p.layout.slots[0..p.layout.n], 0..) |s, i| if (s.kind == .output or s.kind == .inout) { + try p.want.appendSlice(p.a, p.rig.bytes(p.base[i], s.len)); + }; + return p.want.items; + } + /// Gate 1: the predecessor's bytes, NaN payloads included, where the planted values reach a written buffer. + pub fn check(p: *P, _: g.Gate) !?[]const u8 { + p.got.clearRetainingCapacity(); + try p.got.appendSlice(p.a, try p.rig.outputBytes()); + const want = try p.replaced(); + if (!std.mem.eql(u8, p.got.items, want)) { + const at = std.mem.indexOfDiff(u8, p.got.items, want).?; + return try std.fmt.bufPrint(&p.msg, "its bytes differ from the predecessor's from byte {d} of {d}", .{ at, want.len }); + } + var floats = false; + var planted: usize = 0; + var off: usize = 0; + for (p.layout.slots[0..p.layout.n]) |s| if (s.kind == .output or s.kind == .inout) { + floats = floats or s.elem != .int; + planted += exceptional(s.elem, want[off..][0..s.len]); + off += s.len; + }; + if (floats and planted == 0) return "the planted values reach no written buffer: no proof"; + return null; + } + pub fn count(p: *P) usize { + var n: usize = 0; + for (p.layout.slots[0..p.layout.n]) |s| n += if (s.kind == .output or s.kind == .inout) s.len else 0; + return n; + } + pub fn reference(_: *P, want: []f64, mag: []f64) !void { + @memset(want, 0); + @memset(mag, 0); + } + }; +} + +/// A registered probe, freed through its own type. +const Item = struct { ctx: *anyopaque, destroy: *const fn (*anyopaque, std.mem.Allocator) void }; + +pub const Suite = struct { + a: std.mem.Allocator, + device: mtl.Device, + queue: mtl.Queue, + kernels: *std.ArrayList(g.Kernel), + items: std.ArrayList(Item) = .empty, + loader: ?Loader = null, + + pub fn wanted(_: *const Suite, only: ?[]const u8, name: []const u8) bool { + const o = only orelse return true; + return std.mem.indexOf(u8, name, o) != null; + } + pub fn add(s: *Suite, comptime C: type, case: C) !void { + var x = case; + errdefer x.deinit(); + try s.items.ensureUnusedCapacity(s.a, 1); + try s.kernels.ensureUnusedCapacity(s.a, 1); + const p = try s.a.create(Probe(C)); + p.* = .{ .a = s.a, .rig = .{ .a = s.a, .device = s.device, .queue = s.queue }, .case = x }; + const destroy = struct { + fn f(ctx: *anyopaque, a: std.mem.Allocator) void { + const q: *Probe(C) = @ptrCast(@alignCast(ctx)); + q.deinit(); + a.destroy(q); + } + }.f; + s.items.appendAssumeCapacity(.{ .ctx = p, .destroy = destroy }); + s.kernels.appendAssumeCapacity(p.kernel()); + } + /// A test type of its own (created by the caller), freed with the suite. + pub fn own(s: *Suite, comptime T: type, p: *T) !void { + errdefer { + p.deinit(); + s.a.destroy(p); + } + try s.items.ensureUnusedCapacity(s.a, 1); + try s.kernels.ensureUnusedCapacity(s.a, 1); + const destroy = struct { + fn f(ctx: *anyopaque, a: std.mem.Allocator) void { + const q: *T = @ptrCast(@alignCast(ctx)); + q.deinit(); + a.destroy(q); + } + }.f; + s.items.appendAssumeCapacity(.{ .ctx = p, .destroy = destroy }); + s.kernels.appendAssumeCapacity(p.kernel()); + } + /// The GLM loader's libraries, assembled once: every case compiles text the loader compiles. + pub fn production(s: *Suite) !*Loader { + if (s.loader == null) { + s.loader = .{ .a = s.a }; + try tf.glm.kernels.visitSources(s.a, s.device, &s.loader.?); + } + return &s.loader.?; + } + pub fn deinit(s: *Suite) void { + for (s.items.items) |x| x.destroy(x.ctx, s.a); + s.items.deinit(s.a); + if (s.loader) |*l| l.deinit(); + } +}; + +/// The texts kernels.zig's loader compiles, as its source visitor reports them. +pub const Loader = struct { + a: std.mem.Allocator, + texts: std.ArrayList([]u8) = .empty, + pub fn raw(l: *Loader, _: []const u8, _: []const u8, text: []const u8) !void { + try l.texts.append(l.a, try l.a.dupe(u8, text)); + } + /// `text` when the loader compiles exactly it; a contract text that drifted from the loader's is refused. + pub fn require(l: *const Loader, text: []const u8) ![]const u8 { + for (l.texts.items) |t| if (std.mem.eql(u8, t, text)) return text; + std.debug.print("GLM contract text ({d} bytes) is not one the loader compiles\n", .{text.len}); + return error.NotTheLoadersLibrary; + } + fn deinit(l: *Loader) void { + for (l.texts.items) |t| l.a.free(t); + l.texts.deinit(l.a); + } +}; + +/// A gate-5 launch's two texts: this GPU's and the pre-M5 one (equal unless the source includes nax.h). +pub const Texts = struct { here: []const u8, pre_m5: []const u8 }; + +/// One function of `text`, compiled as the GLM loader compiles every library (MLX's options). +pub fn pipeline(device: mtl.Device, text: []const u8, name: []const u8) !mtl.Pipeline { + return rig_.pipeline(device, text, name); +} + +/// `text` with its first `from` after `kernel`'s name replaced: a control's planted fault (owned either way). +pub fn edited(a: std.mem.Allocator, text: []const u8, kernel: []const u8, from: []const u8, to: []const u8) ![]u8 { + const k = std.mem.indexOf(u8, text, kernel) orelse return error.ControlEditMissing; + const at = k + (std.mem.indexOf(u8, text[k..], from) orelse return error.ControlEditMissing); + return std.mem.concat(a, u8, &.{ text[0..at], to, text[at + from.len ..] }); +} + +/// fp32 to bf16 bits (round to nearest even, NaN kept). +pub fn bf(v: f32) u16 { + return c.toBf16(v); +} + +/// Every exceptional bf16 value a planted row can hold: NaN of both signs, both infinities, both zeros. +pub const special_bf16 = [_]u16{ 0x7fc0, 0xffc0, 0x7f80, 0xff80, 0x0000, 0x8000 }; + +pub fn noSums(_: c.Shape) usize { + return 0; +} + +/// A replacement's spec: every launch's written bytes against the predecessor's, which the gates run beside it. +pub fn spec(name: []const u8, replaces: []const u8, nan: []const u8, served: []const c.Shape, why: []const u8) c.Spec { + return .{ .name = name, .accum = .none, .depth = noSums, .out = .raw, .replaces = replaces, .nan = .{ .stated = nan }, .served = served, .sums = .{ .f16 = 0, .bf16 = 0, .why = why } }; +} diff --git a/zig/tests/contract/metal_glm_experts.zig b/zig/tests/contract/metal_glm_experts.zig new file mode 100644 index 00000000000..542c3271c4c --- /dev/null +++ b/zig/tests/contract/metal_glm_experts.zig @@ -0,0 +1,176 @@ +//! GLM's decode experts as moe.zig's `both` launches them against four outputs a simdgroup, on the same route tables. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const kernels = tf.glm.kernels; + +const E = 10; // experts in the pool: a row's 8 picks overlap the next row's +const D = 4096; +const N = 2048; +const TOPK = 8; +const MAXR = 16; // route_select's member rows an expert +const swiglu_limit: f32 = 10.0; // config.zig's +const pick_slot = "const int u = PART == 1 ? MAXU : int(threadgroup_position_in_grid.z);"; + +/// kernels.zig's routed-and-shared gathers: four outputs a simdgroup, and the `_one` pipelines' two. +pub fn texts(a: std.mem.Allocator) ![4][]u8 { + const gu = comptime kernels.generatedSource("moe_gateup_2") ++ kernels.instance("moe_gateup_2", "4096, 2048, 4, 8, 16, 128, 0, 4, 16, 8", "glm_moe_gateup_0"); + const dn = comptime kernels.generatedSource("moe_down_2") ++ kernels.instance("moe_down_2", "2048, 4096, 4, 8, 16, 128, 0, 4, 16, 8", "glm_moe_down_0"); + const gu4 = try std.mem.replaceOwned(u8, a, gu, pick_slot, "const int u = PART == 1 ? MAXU : (int(threadgroup_position_in_grid.z) == int(X_shape[0]) * TOPK ? MAXU : int(threadgroup_position_in_grid.z));"); + const dn4 = try std.mem.replaceOwned(u8, a, dn, pick_slot, "const int u = PART == 1 ? MAXU : (int(threadgroup_position_in_grid.z) == int(ACT_shape[0]) * TOPK ? MAXU : int(threadgroup_position_in_grid.z));"); + const gu2 = try std.mem.replaceOwned(u8, a, gu4, "<4096, 2048, 4, 8, 16, 128, 0, 4, 16, 8>", "<4096, 2048, 2, 8, 16, 128, 0, 4, 16, 8>"); + const dn2 = try std.mem.replaceOwned(u8, a, dn4, "<2048, 4096, 4, 8, 16, 128, 0, 4, 16, 8>", "<2048, 4096, 2, 8, 16, 128, 0, 4, 16, 8>"); + return .{ gu4, dn4, gu2, dn2 }; +} + +/// Rows: the window's rows; n: experts' intermediate width; k: the hidden width. +const served = [_]c.Shape{ .{ .rows = 4, .n = N, .k = D }, .{ .rows = 1, .n = N, .k = D }, .{ .rows = 2, .n = N, .k = D }, .{ .rows = 3, .n = N, .k = D }, .{ .rows = 5, .n = N, .k = D }, .{ .rows = 8, .n = N, .k = D } }; + +const Slot = enum(u8) { x, gw, gs, gb, uw, us, ub, sw, ss, sb, dw, ds, db, hw, hs, hb, ids, members, count, act, y }; + +pub const Case = struct { + control: bool, + new: [2][2]mtl.Pipeline, // [gate/up, down][two outputs a simdgroup, four] + old: [2]mtl.Pipeline, + + pub fn init(s: *bits.Suite, control: bool) !Case { + const loader = try s.production(); + const t = try texts(s.a); + defer for (t) |x| s.a.free(x); + for (t) |x| _ = try loader.require(x); + const shared = "(int(threadgroup_position_in_grid.z) == int(X_shape[0]) * TOPK ? MAXU"; + const gu2 = if (control) try bits.edited(s.a, t[2], "", shared, "(int(threadgroup_position_in_grid.z) == int(X_shape[0]) * TOPK - 1 ? MAXU") else try s.a.dupe(u8, t[2]); + defer s.a.free(gu2); + var x: Case = .{ .control = control, .new = undefined, .old = undefined }; + x.new[0][0] = try bits.pipeline(s.device, gu2, "glm_moe_gateup_0"); + errdefer x.new[0][0].deinit(); + x.new[1][0] = try bits.pipeline(s.device, t[3], "glm_moe_down_0"); + errdefer x.new[1][0].deinit(); + x.old[0] = try bits.pipeline(s.device, t[0], "glm_moe_gateup_0"); + errdefer x.old[0].deinit(); + x.old[1] = try bits.pipeline(s.device, t[1], "glm_moe_down_0"); + x.new[0][1] = x.old[0]; + x.new[1][1] = x.old[1]; + return x; + } + pub fn deinit(x: *Case) void { + x.new[0][0].deinit(); + x.new[1][0].deinit(); + for (x.old) |p| p.deinit(); + } + pub fn name(control: bool) []const u8 { + return if (control) "control: metal glm launch experts, two gate/up outputs a simdgroup taking the shared slot one early" else "metal glm launch experts gate/up and down at moe.zig's outputs a simdgroup"; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.control), "glm_moe_gateup_0 and glm_moe_down_0 at four outputs a simdgroup", "the four-output kernels' bytes in every pick's activations and outputs and the shared slot's", &served, "the generated kernels' sums; only the outputs a simdgroup change"); + } + pub fn layout(_: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.rows > 8 or s.n != N or s.k != D) return null; + const w: tf.glm.affine.Width = .{ .bits = 4, .group = 64 }; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * D * 2, .bf16); + for ([_][2]usize{ .{ E * N, D }, .{ E * N, D }, .{ 2 * N, D }, .{ E * D, N }, .{ D, N } }) |m| { + _ = l.add(.input, tf.glm.affine.wBytes(m[0], m[1], w), .int); + _ = l.add(.input, tf.glm.affine.sBytes(m[0], m[1], w), .bf16); + _ = l.add(.input, tf.glm.affine.sBytes(m[0], m[1], w), .bf16); + } + _ = l.add(.input, 128 * 4, .int); + _ = l.add(.input, 128 * MAXR * 4, .int); + _ = l.add(.input, 16, .int); + _ = l.add(.output, s.rows * (TOPK + 1) * N * 2, .bf16); + _ = l.add(.output, s.rows * (TOPK + 1) * D * 2, .bf16); + return l; + } + /// tf-glm-moe-rows' draws and route: each row 8 distinct experts of the pool, grouped as route_select groups them. + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + for (std.mem.bytesAsSlice(u16, data[@backingInt(Slot.x)])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + for (0..5) |m| { + const at = @backingInt(Slot.gw) + 3 * m; + rnd.bytes(data[at]); + for (std.mem.bytesAsSlice(u16, data[at + 1])) |*v| v.* = bits.bf(rnd.float(f32) * 0.02 + 0.001); + for (std.mem.bytesAsSlice(u16, data[at + 2])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 0.1); + } + var picks: [MAXR * TOPK]i32 = undefined; + for (0..s.rows) |row| { + var k: usize = 0; + while (k < TOPK) { + const e: i32 = @intCast(rnd.uintLessThan(usize, E)); + if (std.mem.indexOfScalar(i32, picks[row * TOPK .. row * TOPK + k], e) == null) { + picks[row * TOPK + k] = e; + k += 1; + } + } + } + const ids = std.mem.bytesAsSlice(i32, data[@backingInt(Slot.ids)]); + const members = std.mem.bytesAsSlice(i32, data[@backingInt(Slot.members)]); + @memset(ids, 0); + @memset(members, -1); + var n: usize = 0; + for (0..E) |e| { + var m: usize = 0; + for (picks[0 .. s.rows * TOPK], 0..) |p, pi| if (p == @as(i32, @intCast(e))) { + members[n * MAXR + m] = @intCast(pi); + m += 1; + }; + if (m > 0) { + ids[n] = @intCast(e); + n += 1; + } + } + std.mem.bytesAsSlice(i32, data[@backingInt(Slot.count)])[0] = @intCast(n); + if (f == .stress or (f == .random and seed % 3 != 2)) return; + const x = std.mem.bytesAsSlice(u16, data[@backingInt(Slot.x)]); + for ([_][2]usize{ .{ 0, 5 }, .{ 1, 700 }, .{ 2, 64 }, .{ 3, 9 }, .{ 3, 4000 } }, [_]u16{ 0x7fc0, 0x7f80, 0xff80, 0x7f80, 0xff80 }) |p, v| if (p[0] < s.rows) { + x[p[0] * D + p[1]] = v; + }; + } + /// moe.zig's `both`: gate/up at two outputs a simdgroup to 4 rows, down at two at one row; the predecessor at four. + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const rows = s.rows; + const zs = rows * TOPK + 1; + const gu_rps: usize = if (new and rows <= 4) 2 else 4; + const dn_rps: usize = if (new and rows == 1) 2 else 4; + const bind = struct { + fn at(enc: mtl.ComputeEncoder, v: rig_.Ref, j: usize) void { + enc.setBuffer(v.buf, v.off, j); + } + }.at; + e.setPipeline(if (new) x.new[0][if (gu_rps == 2) 0 else 1] else x.old[0]); + bind(e, r[@backingInt(Slot.x)], 0); + e.setBytes(std.mem.asBytes(&[2]i32{ @intCast(rows), D }), 1); + for (@backingInt(Slot.gw)..@backingInt(Slot.dw), 2..) |j, k| bind(e, r[j], k); + for ([_]Slot{ .ids, .members, .count }, 11..) |j, k| bind(e, r[@backingInt(j)], k); + e.setValue(swiglu_limit, 14); + bind(e, r[@backingInt(Slot.act)], 15); + e.dispatchThreads(mtl.Size.of(32 * rows, N / gu_rps, zs), mtl.Size.of(32 * rows, 1, 1)); + e.setPipeline(if (new) x.new[1][if (dn_rps == 2) 0 else 1] else x.old[1]); + bind(e, r[@backingInt(Slot.act)], 0); + e.setBytes(std.mem.asBytes(&[3]i32{ @intCast(rows), TOPK + 1, N }), 1); + for (@backingInt(Slot.dw)..@backingInt(Slot.ids), 2..) |j, k| bind(e, r[j], k); + for ([_]Slot{ .ids, .members, .count, .y }, 8..) |j, k| bind(e, r[@backingInt(j)], k); + e.dispatchThreads(mtl.Size.of(32 * rows, D / dn_rps, zs), mtl.Size.of(32 * rows, 1, 1)); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(control))) try s.add(Case, try Case.init(s, control)); + } +} + +/// Gate 5's registrations `glm launch experts
`: the loader's gather at that form. +pub const prefix = "glm launch experts "; +pub fn limitsText(a: std.mem.Allocator, _: mtl.Device, label: []const u8) !bits.Texts { + const t = try texts(a); + const one = std.mem.indexOf(u8, label, " two ") != null; + const down = std.mem.endsWith(u8, label, "glm_moe_down_0"); + const pick = t[@as(usize, if (one) 2 else 0) + @intFromBool(down)]; + return .{ .here = pick, .pre_m5 = pick }; +} diff --git a/zig/tests/contract/metal_glm_experts_pick.zig b/zig/tests/contract/metal_glm_experts_pick.zig new file mode 100644 index 00000000000..b6c24afeba8 --- /dev/null +++ b/zig/tests/contract/metal_glm_experts_pick.zig @@ -0,0 +1,201 @@ +//! A one-row MoE layer's experts replaying the route select's picks (moe.zig's `both`, one row) against main's select. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const experts = @import("metal_glm_experts.zig"); +const picks = @import("metal_glm_route_select.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const route = tf.moe_route; +const shape = tf.glm.kernels.route_shape; + +const E = shape.experts; +const POOL = 16; // experts with weights: every other expert's bias is -inf, so the picks stay in the pool +const D = 4096; +const N = 2048; +const TOPK = 8; +const MAXR = 16; +const swiglu_limit: f32 = 10.0; +const scale: f32 = 2.5; // config.zig's routed_scale + +/// kernels.zig's pickSources over the one-row gathers: groups take pick u by the select's routine, no member lists. +pub fn texts(a: std.mem.Allocator) ![2][]u8 { + const t = try experts.texts(a); + defer for (t) |x| a.free(x); + const member = " if (!shared && u >= UCOUNT[0]) return;\n const int pick = shared ? (m < R ? m * TOPK : -1) : UMEM[u * MAXR + m];"; + const by_pick = " const int pick = shared ? (m < R ? m * TOPK : -1) : u;"; + const edits = [_][2][]const u8{ + .{ member, by_pick }, + .{ " const size_t e = shared ? 0 : size_t(UIDS[u]);", " const size_t e = shared ? 0 : size_t(tf_route_pick_at(RLOGITS, RBIAS, u, lane, u == TOPK - 1 && threadgroup_position_in_grid.y == 0, RPICK, RWTS, RSCALE));" }, + .{ " const device int32_t* UIDS [[buffer(11)]],\n const device int32_t* UMEM [[buffer(12)]],\n const device int32_t* UCOUNT [[buffer(13)]],", " const device float* RLOGITS [[buffer(11)]],\n const device float* RBIAS [[buffer(12)]],\n device int32_t* RPICK [[buffer(13)]]," }, + .{ " device bfloat16_t* ACT [[buffer(15)]],", " device bfloat16_t* ACT [[buffer(15)]],\n device float* RWTS [[buffer(16)]],\n constant float& RSCALE [[buffer(17)]]," }, + }; + var gu = try a.dupe(u8, t[2]); + defer a.free(gu); + for (edits) |x| { + if (std.mem.count(u8, gu, x[0]) != 1) return error.KernelCompile; + const next = try std.mem.replaceOwned(u8, a, gu, x[0], x[1]); + a.free(gu); + gu = next; + } + const core = try route.source(a, shape); + defer a.free(core); + if (std.mem.count(u8, t[3], member) != 1) return error.KernelCompile; + return .{ try std.mem.concat(a, u8, &.{ core, gu }), try std.mem.replaceOwned(u8, a, t[3], member, by_pick) }; +} + +/// Rows: one-row MoE layers launched one after another, each on its own input and logits row; n, k: N and D. +const served = [_]c.Shape{ .{ .rows = 6, .n = N, .k = D }, .{ .rows = 1, .n = N, .k = D }, .{ .rows = 16, .n = N, .k = D } }; + +const Slot = enum(u8) { x, gw, gs, gb, uw, us, ub, sw, ss, sb, dw, ds, db, hw, hs, hb, logits, bias, act, ye, pick, wts, lists, none }; + +pub const Case = struct { + control: bool, + new: [2]mtl.Pipeline, + old: [3]mtl.Pipeline, // main's select, then the one-row gate/up and down + + pub fn init(s: *bits.Suite, control: bool) !Case { + const loader = try s.production(); + const t = try texts(s.a); + defer for (t) |x| s.a.free(x); + for (t) |x| _ = try loader.require(x); + const one = try experts.texts(s.a); + defer for (one) |x| s.a.free(x); + const gu = if (control) try bits.edited(s.a, t[0], "", "tf_route_pick_at(RLOGITS, RBIAS, u, lane,", "tf_route_pick_at(RLOGITS, RBIAS, (u + 1) % TOPK, lane,") else try s.a.dupe(u8, t[0]); + defer s.a.free(gu); + var x: Case = .{ .control = control, .new = undefined, .old = undefined }; + x.new[0] = try bits.pipeline(s.device, gu, "glm_moe_gateup_0"); + errdefer x.new[0].deinit(); + x.new[1] = try bits.pipeline(s.device, t[1], "glm_moe_down_0"); + errdefer x.new[1].deinit(); + const frozen = try picks.text(s.a, .glm, picks.main_route); + defer s.a.free(frozen); + x.old[0] = try bits.pipeline(s.device, frozen, route.names[1]); + errdefer x.old[0].deinit(); + x.old[1] = try bits.pipeline(s.device, one[2], "glm_moe_gateup_0"); + errdefer x.old[1].deinit(); + x.old[2] = try bits.pipeline(s.device, one[3], "glm_moe_down_0"); + return x; + } + pub fn deinit(x: *Case) void { + for (x.new) |p| p.deinit(); + for (x.old) |p| p.deinit(); + } + pub fn name(control: bool) []const u8 { + return if (control) "control: metal glm launch experts pick, each routed group taking the next pick's expert" else "metal glm launch experts pick one row, the gate/up groups replaying the route select"; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.control), "main's tf_route_select, then the one-row gate/up and down gathers", "main's bytes in every pick's activations and outputs, the shared slot's, the picks and the weights", &served, "the select's weights and the generated kernels' sums in their orders; only who picks moves"); + } + pub fn layout(_: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.rows > 16 or s.n != N or s.k != D) return null; + const w: tf.glm.affine.Width = .{ .bits = 4, .group = 64 }; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * D * 2, .bf16); + for ([_][2]usize{ .{ POOL * N, D }, .{ POOL * N, D }, .{ 2 * N, D }, .{ POOL * D, N }, .{ D, N } }) |m| { + _ = l.add(.input, tf.glm.affine.wBytes(m[0], m[1], w), .int); + _ = l.add(.input, tf.glm.affine.sBytes(m[0], m[1], w), .bf16); + _ = l.add(.input, tf.glm.affine.sBytes(m[0], m[1], w), .bf16); + } + _ = l.add(.input, s.rows * E * 4, .f32); + _ = l.add(.input, E * 4, .f32); + _ = l.add(.output, s.rows * (TOPK + 1) * N * 2, .bf16); + _ = l.add(.output, s.rows * (TOPK + 1) * D * 2, .bf16); + _ = l.add(.output, s.rows * TOPK * 4, .int); + _ = l.add(.output, s.rows * TOPK * 4, .f32); + _ = l.add(.scratch, 4 * TOPK * MAXR * MAXR * 4, .int); + _ = l.add(.scratch, 256, .int); + return l; + } + /// Pool logits random, in a few levels (ties) or equal by row; gate 1 and every third shape add NaN, +-Inf, -0. + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const x = std.mem.bytesAsSlice(u16, data[@backingInt(Slot.x)]); + for (x) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + for (0..5) |m| { + const at = @backingInt(Slot.gw) + 3 * m; + rnd.bytes(data[at]); + for (std.mem.bytesAsSlice(u16, data[at + 1])) |*v| v.* = bits.bf(rnd.float(f32) * 0.02 + 0.001); + for (std.mem.bytesAsSlice(u16, data[at + 2])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 0.1); + } + const lg = std.mem.bytesAsSlice(f32, data[@backingInt(Slot.logits)]); + for (lg, 0..) |*v, i| v.* = switch ((seed + i / E) % 3) { + 0 => (rnd.float(f32) - 0.5) * 8, + 1 => @round((rnd.float(f32) - 0.5) * 6) / 2, + else => 0.25, + }; + for (std.mem.bytesAsSlice(f32, data[@backingInt(Slot.bias)]), 0..) |*v, i| v.* = if (i >= POOL) -std.math.inf(f32) else if (i % 5 == 0) -0.0 else (rnd.float(f32) - 0.5) * 0.2; + if (f == .stress or (f == .random and seed % 3 != 2)) return; + for (0..s.rows) |r| { + lg[r * E + (r % POOL)] = if (r % 3 == 0) std.math.nan(f32) else if (r % 3 == 1) std.math.inf(f32) else -std.math.inf(f32); + lg[r * E + ((r + 7) % POOL)] = -0.0; + if (r % 4 == 0) x[r * D + 9] = if (r % 8 == 0) 0x7fc0 else 0xff80; + } + } + /// Each one-row layer: moe.zig's one-row `both` with the picks replayed, or main's select then the gathers. + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const at = struct { + fn of(v: rig_.Ref, extra: usize) rig_.Ref { + return .{ .buf = v.buf, .off = v.off + extra }; + } + }.of; + const bind = struct { + fn on(enc: mtl.ComputeEncoder, v: rig_.Ref, j: usize) void { + enc.setBuffer(v.buf, v.off, j); + } + }.on; + const ix = struct { + fn of(slot: Slot) usize { + return @backingInt(slot); + } + }.of; + const T = TOPK * MAXR * 4; + const lists = r[ix(.lists)]; + for (0..s.rows) |row| { + const lg = at(r[ix(.logits)], row * E * 4); + const pk = at(r[ix(.pick)], row * TOPK * 4); + const wt = at(r[ix(.wts)], row * TOPK * 4); + const act = at(r[ix(.act)], row * (TOPK + 1) * N * 2); + if (!new) route.select(e, x.old[0], lg, r[ix(.bias)], scale, 1, .{ 0, E }, route.Outputs(rig_.Ref){ .pick = pk, .wts = wt, .ids = lists, .members = at(lists, T), .count = at(lists, T + T * MAXR), .mine = at(lists, 2 * T + T * MAXR), .theirs = at(lists, 3 * T + T * MAXR), .counts = at(lists, 4 * T + T * MAXR), .word = at(lists, 4 * T + T * MAXR + 64) }); + e.setPipeline(if (new) x.new[0] else x.old[1]); + bind(e, at(r[ix(.x)], row * D * 2), 0); + e.setBytes(std.mem.asBytes(&[2]i32{ 1, D }), 1); + for (ix(.gw)..ix(.dw), 2..) |j, k| bind(e, r[j], k); + if (new) { + for ([_]rig_.Ref{ lg, r[ix(.bias)], pk }, 11..) |v, k| bind(e, v, k); + } else for ([_]rig_.Ref{ lists, at(lists, T), at(lists, T + T * MAXR) }, 11..) |v, k| bind(e, v, k); + e.setValue(swiglu_limit, 14); + bind(e, act, 15); + if (new) bind(e, wt, 16); + if (new) e.setValue(scale, 17); + e.dispatchThreads(mtl.Size.of(32, N / 2, TOPK + 1), mtl.Size.of(32, 1, 1)); + e.setPipeline(if (new) x.new[1] else x.old[2]); + bind(e, act, 0); + e.setBytes(std.mem.asBytes(&[3]i32{ 1, TOPK + 1, N }), 1); + for (ix(.dw)..ix(.logits), 2..) |j, k| bind(e, r[j], k); + if (new) { + for ([_]rig_.Ref{ pk, r[ix(.none)], r[ix(.none)] }, 8..) |v, k| bind(e, v, k); + } else for ([_]rig_.Ref{ lists, at(lists, T), at(lists, T + T * MAXR) }, 8..) |v, k| bind(e, v, k); + bind(e, at(r[ix(.ye)], row * (TOPK + 1) * D * 2), 11); + e.dispatchThreads(mtl.Size.of(32, D / 2, TOPK + 1), mtl.Size.of(32, 1, 1)); + } + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(control))) try s.add(Case, try Case.init(s, control)); + } +} + +/// Gate 5's registrations `glm launch experts pick `: the loader's pick gathers. +pub const prefix = "glm launch experts pick "; +pub fn limitsText(a: std.mem.Allocator, _: mtl.Device, label: []const u8) !bits.Texts { + const t = try texts(a); + const pick = t[@intFromBool(std.mem.endsWith(u8, label, "glm_moe_down_0"))]; + return .{ .here = pick, .pre_m5 = pick }; +} diff --git a/zig/tests/contract/metal_glm_hc.zig b/zig/tests/contract/metal_glm_hc.zig new file mode 100644 index 00000000000..75296df6b1c --- /dev/null +++ b/zig/tests/contract/metal_glm_hc.zig @@ -0,0 +1,206 @@ +//! GLM's hyper-connection boundary (core/hc.zig's launches) against main's combine, expand and split, same streams. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const hc = tf.glm.hc; +const shape = tf.glm.kernels.hc_shape; + +const D = shape.width; +const F = 4 * D; +const eps: f32 = 1e-5; // forward.zig's boundary passes the norm's eps +/// Main's hc_boundary.metal: one group a slice for the expand, one a row for the split. +pub const main_hc = @embedFile("baselines/hc_boundary_main.metal.txt"); + +/// A boundary's form: expanded into another buffer, in place (a prompt chunk), a first read, or a MoE block's combine. +pub const Mode = enum { expand, in_place, first, moe }; +pub const Fault = enum { none, parts_weights, split_post, moe_last }; +const topk = shape.topk; +/// Main's MoE combine before the boundary: the generated moe_combine with the shared expert's row in the last slot. +pub fn combineText(a: std.mem.Allocator) ![]u8 { + const comb = comptime tf.glm.kernels.generatedSource("moe_combine"); + const first = try std.mem.replaceOwned(u8, a, comb, "const device bfloat* y = Y + size_t(r) * TOPK * D + d;", "const device bfloat* y = Y + size_t(r) * (TOPK + 1) * D + d;"); + defer a.free(first); + return std.mem.replaceOwned(u8, a, first, "+ YS[size_t(r) * D + d];", "+ y[size_t(TOPK) * D];"); +} + +/// Rows: the boundary's rows (to 4: the expand's parts on six groups a slice); n: the streams; k: the width. +const served = [4][7]c.Shape{ + .{ .{ .rows = 4, .n = 4, .k = D }, .{ .rows = 1, .n = 4, .k = D }, .{ .rows = 2, .n = 4, .k = D }, .{ .rows = 3, .n = 4, .k = D }, .{ .rows = 5, .n = 4, .k = D }, .{ .rows = 8, .n = 4, .k = D }, .{ .rows = 16, .n = 4, .k = D } }, + .{ .{ .rows = 4, .n = 4, .k = D }, .{ .rows = 1, .n = 4, .k = D }, .{ .rows = 2, .n = 4, .k = D }, .{ .rows = 3, .n = 4, .k = D }, .{ .rows = 5, .n = 4, .k = D }, .{ .rows = 16, .n = 4, .k = D }, .{ .rows = 64, .n = 4, .k = D } }, + .{ .{ .rows = 4, .n = 4, .k = D }, .{ .rows = 1, .n = 4, .k = D }, .{ .rows = 2, .n = 4, .k = D }, .{ .rows = 3, .n = 4, .k = D }, .{ .rows = 5, .n = 4, .k = D }, .{ .rows = 8, .n = 4, .k = D }, .{ .rows = 16, .n = 4, .k = D } }, + .{ .{ .rows = 2, .n = 4, .k = D }, .{ .rows = 1, .n = 4, .k = D }, .{ .rows = 3, .n = 4, .k = D }, .{ .rows = 4, .n = 4, .k = D }, .{ .rows = 5, .n = 4, .k = D }, .{ .rows = 8, .n = 4, .k = D }, .{ .rows = 16, .n = 4, .k = D } }, +}; + +/// The loader's boundary library: hc.zig's defines over core/hc_boundary.metal. +pub fn text(a: std.mem.Allocator) ![]u8 { + return hc.source(a, shape); +} + +const S = struct { x: usize, branch: usize, post: usize, comb: usize, fnp: usize, x_new: usize, part: usize, scale: usize, base: usize, norm: usize, normed: usize, wts: usize = 0, mixed: usize = 0 }; + +pub const Case = struct { + a: std.mem.Allocator, + mode: Mode, + fault: Fault, + control: bool, + pipes: [hc.names.len]mtl.Pipeline, + old: [4]mtl.Pipeline, + combine: ?mtl.Pipeline = null, + + pub fn init(s: *bits.Suite, mode: Mode, fault: Fault) !Case { + const loader = try s.production(); + const own = try text(s.a); + defer s.a.free(own); + _ = try loader.require(own); + const body = switch (fault) { + .none => try s.a.dupe(u8, own), + .parts_weights => try bits.edited(s.a, own, "void tf_hc_expand_mix_parts(", "size_t(og * 8 + int(sg))", "size_t((og + 1) % 6 * 8 + int(sg))"), + .split_post => try bits.edited(s.a, own, "void tf_hc_split(", "simd_shuffle(mix, ushort(S + llane))", "simd_shuffle(mix, ushort(llane))"), + .moe_last => try bits.edited(s.a, own, "inline void hc_branch4(", "for (int k = 1; k < TF_HC_TOPK; k++)", "for (int k = 1; k < TF_HC_TOPK - 1; k++)"), + }; + defer s.a.free(body); + var x: Case = .{ .a = s.a, .mode = mode, .fault = fault, .control = fault != .none, .pipes = undefined, .old = undefined }; + var made: usize = 0; + errdefer for (x.pipes[0..made]) |p| p.deinit(); + for (hc.names, 0..) |n, i| { + x.pipes[i] = try bits.pipeline(s.device, body, n); + made += 1; + } + const frozen = try std.fmt.allocPrint(s.a, "#define TF_D {d}\n#define TF_ITERS {d}\n#define TF_HC_EPS_INT {d}\n{s}", .{ shape.width, shape.sinkhorn, shape.eps_e9, main_hc }); + defer s.a.free(frozen); + var old_made: usize = 0; + errdefer for (x.old[0..old_made]) |p| p.deinit(); + for ([_][]const u8{ "tf_hc_expand_mix", "tf_hc_first_mix", "tf_hc_split", "tf_hc_expand_inplace" }, 0..) |n, i| { + x.old[i] = try bits.pipeline(s.device, frozen, n); + old_made += 1; + } + if (mode == .moe) { + const comb = try combineText(s.a); + defer s.a.free(comb); + x.combine = try bits.pipeline(s.device, try loader.require(comb), comptime tf.glm.kernels.generatedFunction("moe_combine")); + } + return x; + } + pub fn deinit(x: *Case) void { + for (x.pipes) |p| p.deinit(); + for (x.old) |p| p.deinit(); + if (x.combine) |p| p.deinit(); + } + pub fn name(mode: Mode, fault: Fault) []const u8 { + const names = [4][4][]const u8{ + .{ "metal glm launch hc boundary expand", "control: metal glm launch hc boundary expand, a parts group reading the next group's mix weights", "control: metal glm launch hc boundary expand, the split's post from the pre mixes", "" }, + .{ "metal glm launch hc boundary in place", "control: metal glm launch hc boundary in place, a parts group reading the next group's mix weights", "control: metal glm launch hc boundary in place, the split's post from the pre mixes", "" }, + .{ "metal glm launch hc boundary first read", "control: metal glm launch hc boundary first read, a parts group reading the next group's mix weights", "control: metal glm launch hc boundary first read, the split's post from the pre mixes", "" }, + .{ "metal glm launch hc boundary combining a MoE block", "control: metal glm launch hc boundary combining a MoE block, a parts group reading the next group's mix weights", "", "control: metal glm launch hc boundary combining a MoE block, the last pick left out" }, + }; + return names[@backingInt(mode)][@backingInt(fault)]; + } + pub fn spec(x: *const Case) c.Spec { + var sp = bits.spec(name(x.mode, x.fault), if (x.mode == .moe) "main's MoE combine, tf_hc_expand_mix and tf_hc_split" else "main's tf_hc_expand_mix and tf_hc_split", "main's bytes in the streams, partial sums, normed row, post and comb (raw words, signed zeros and NaN payloads included)", &served[@backingInt(x.mode)], "the expand's fma sequence, each part's simd and serial sums, the split's slice order and its Sinkhorn steps"); + sp.in_place = true; + return sp; + } + fn slots(mode: Mode) S { + return if (mode == .in_place) .{ .x = 0, .branch = 1, .post = 2, .comb = 3, .fnp = 4, .x_new = 0, .part = 5, .scale = 6, .base = 7, .norm = 8, .normed = 9 } else .{ .x = 0, .branch = 1, .post = 2, .comb = 3, .fnp = 4, .x_new = 5, .part = 6, .scale = 7, .base = 8, .norm = 9, .normed = 10, .wts = 11, .mixed = 12 }; + } + pub fn layout(x: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.n != 4 or s.k != D) return null; + var l: bits.Layout = .{}; + _ = l.add(if (x.mode == .in_place) .inout else .input, s.rows * F * 2, .bf16); + _ = l.add(.input, s.rows * D * 2 * @as(usize, if (x.mode == .moe) topk + 1 else 1), .bf16); + _ = l.add(.inout, s.rows * 4 * 4, .f32); + _ = l.add(.inout, s.rows * 16 * 4, .f32); + _ = l.add(.input, 24 * F * 2, .bf16); + if (x.mode != .in_place) _ = l.add(.output, s.rows * F * 2, .bf16); + _ = l.add(.output, s.rows * hc.partBytes(shape), .f32); + _ = l.add(.input, 16, .f32); + _ = l.add(.input, 24 * 4, .f32); + _ = l.add(.input, D * 2, .bf16); + _ = l.add(.output, s.rows * D * 2, .bf16); + if (x.mode == .moe) { + _ = l.add(.input, s.rows * topk * 4, .f32); + _ = l.add(.scratch, s.rows * D * 2, .bf16); + } + return l; + } + /// tf-glm-hc-rows' draws; odd seeds add -0 and large streams; gate 1 and every third shape plant NaN, infinities. + pub fn fill(x: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const i = slots(x.mode); + const w: f32 = if (seed % 2 == 1) 16 else 1; + const xs = std.mem.bytesAsSlice(u16, data[i.x]); + for (xs, 0..) |*v, j| v.* = if (seed % 2 == 1 and j % 61 == 0) 0x8000 else if (seed % 2 == 1 and j % 67 == 0) bits.bf(3e4) else bits.bf((rnd.float(f32) - 0.5) * 4 * w); + const br = std.mem.bytesAsSlice(u16, data[i.branch]); + for (br) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2 * w); + for (std.mem.bytesAsSlice(f32, data[i.post])) |*v| v.* = rnd.float(f32) * 2; + for (std.mem.bytesAsSlice(f32, data[i.comb])) |*v| v.* = rnd.float(f32) * 0.5; + for (std.mem.bytesAsSlice(u16, data[i.fnp])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 0.05 * w); + @memcpy(std.mem.bytesAsSlice(f32, data[i.scale]), &[4]f32{ 0.9, 1.1, 0.7, 0 }); + if (x.mode == .moe) for (std.mem.bytesAsSlice(f32, data[i.wts])) |*v| { + v.* = rnd.float(f32) * 0.5; + }; + for (std.mem.bytesAsSlice(f32, data[i.base])) |*v| v.* = (rnd.float(f32) - 0.5) * w; + for (std.mem.bytesAsSlice(u16, data[i.norm])) |*v| v.* = bits.bf(0.5 + rnd.float(f32)); + if (f == .stress or (f == .random and seed % 3 != 2)) return; + const at = [_][3]usize{ .{ 0, 0, 7 }, .{ 1, 1, 100 }, .{ 2, 0, 3 * D + 9 }, .{ 3, 0, 11 }, .{ 3, 0, D + 12 } }; + const vals = [_]u16{ 0x7fc0, 0x7f80, 0xff80, 0x7f80, 0xff80 }; + for (at, vals) |p, v| if (p[0] < s.rows) { + if (p[1] == 0) xs[p[0] * F + p[2]] = v else br[p[0] * (br.len / s.rows) + p[2]] = v; + }; + } + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const i = slots(x.mode); + const rows: u32 = @intCast(s.rows); + const expand = x.mode != .first; + if (new and x.mode == .moe) return hc.boundary(e, x.pipes, shape, true, rows, eps, .{ .x_old = r[i.x], .branch = r[i.branch], .post = r[i.post], .comb = r[i.comb], .fn_packed = r[i.fnp], .x_new = r[i.x_new], .part = r[i.part], .scale = r[i.scale], .base = r[i.base], .norm = r[i.norm], .normed = r[i.normed], .wts = r[i.wts] }); + if (new) return hc.boundary(e, x.pipes, shape, expand, rows, eps, .{ .x_old = r[i.x], .branch = r[i.branch], .post = r[i.post], .comb = r[i.comb], .fn_packed = r[i.fnp], .x_new = r[i.x_new], .part = r[i.part], .scale = r[i.scale], .base = r[i.base], .norm = r[i.norm], .normed = r[i.normed] }); + const bind = struct { + fn at(enc: mtl.ComputeEncoder, v: rig_.Ref, j: usize) void { + enc.setBuffer(v.buf, v.off, j); + } + }.at; + var branch = i.branch; + if (x.combine) |p| { // moe.zig's combine_0 into the branch, as main launched it before the boundary + e.setPipeline(p); + for ([_]usize{ i.branch, i.branch, i.wts }, 0..) |j, k| bind(e, r[j], k); + e.setBytes(std.mem.asBytes(&[2]i32{ @intCast(rows), topk }), 3); + bind(e, r[i.mixed], 4); + e.dispatchThreads(mtl.Size.of(s.rows * D, 1, 1), mtl.Size.of(256, 1, 1)); + branch = i.mixed; + } + const one = x.mode == .in_place; // main's boundary: the expand in place, then the first read's sums + if (one) { + e.setPipeline(x.old[3]); + for ([_]usize{ i.x, branch, i.post, i.comb }, 0..) |j, k| bind(e, r[j], k); + e.dispatchGroups(mtl.Size.of(s.rows, 1, 1), mtl.Size.of(D / 4, 1, 1)); + } + e.setPipeline(x.old[if (expand and !one) 0 else 1]); + for ([_]usize{ i.x, branch, i.post, i.comb, i.fnp, i.x_new, i.part }, 0..) |j, k| bind(e, r[j], k); + e.dispatchGroups(mtl.Size.of(4 * D / 1024, s.rows, 1), mtl.Size.of(256, 1, 1)); + e.setPipeline(x.old[2]); + for ([_]usize{ if (expand) i.x_new else i.x, i.part, i.scale, i.base, i.norm }, 0..) |j, k| bind(e, r[j], k); + e.setValue(eps, 5); + for ([_]usize{ i.normed, i.post, i.comb }, 6..) |j, k| bind(e, r[j], k); + e.dispatchGroups(mtl.Size.of(s.rows, 1, 1), mtl.Size.of(1024, 1, 1)); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for (std.enums.values(Mode)) |mode| for (std.enums.values(Fault)) |fault| { + if (Case.name(mode, fault).len == 0) continue; + if (s.wanted(only, Case.name(mode, fault))) try s.add(Case, try Case.init(s, mode, fault)); + }; +} + +/// Gate 5's registrations `glm launch hc `: the loader's boundary library. +pub const prefix = "glm launch hc "; +pub fn limitsText(a: std.mem.Allocator, _: mtl.Device, _: []const u8) !bits.Texts { + const t = try text(a); + return .{ .here = t, .pre_m5 = t }; +} diff --git a/zig/tests/contract/metal_glm_index.zig b/zig/tests/contract/metal_glm_index.zig new file mode 100644 index 00000000000..b8fdaa9ad48 --- /dev/null +++ b/zig/tests/contract/metal_glm_index.zig @@ -0,0 +1,111 @@ +//! GLM's prompt index scores (glm_index_nax.metal, 16 rows x 64 blocks a simdgroup) against main's 32 x 32. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; + +/// Main's glm_index_nax.metal: 64-row tiles of 4 simdgroups, 32 rows x 32 blocks each. +pub const main_index = @embedFile("baselines/glm_index_nax_main.metal.txt"); + +const HI = 32; // indexer heads +const DI = 128; // a head's dims, a pooled key's +const QR = 20480; // qr_proj's row: 64 heads' q_nope, then the indexer's queries +const QOFF = 64 * 256; +const ScoreArgs = extern struct { p0: u32, q_stride: u32, w_stride: u32, s_stride: u32, rows: u32 }; + +/// Rows: a pass's rows (select_rows at most); k: its first position; n: a key's dims. Both tile heights are served. +const served = [_]c.Shape{ .{ .rows = 256, .n = DI, .k = 16384 }, .{ .rows = 1, .n = DI, .k = 2047 }, .{ .rows = 37, .n = DI, .k = 2048 }, .{ .rows = 128, .n = DI, .k = 4100 }, .{ .rows = 129, .n = DI, .k = 6141 }, .{ .rows = 255, .n = DI, .k = 33001 }, .{ .rows = 256, .n = DI, .k = 90000 }, .{ .rows = 200, .n = DI, .k = 130872 } }; + +fn stride(s: c.Shape) usize { + return (s.k + s.rows + 1) / 4 + 3; +} + +pub const Case = struct { + control: bool, + new: mtl.Pipeline, + old: mtl.Pipeline, + + /// The loader's library as it compiles it (nax.h inlined for this GPU), and main's the same way. + pub fn text(a: std.mem.Allocator, device: mtl.Device) ![]u8 { + return tf.frags.source(device, a, sources.glm_index_nax); + } + + pub fn init(s: *bits.Suite, control: bool) !Case { + const loader = try s.production(); + const own = try text(s.a, s.device); + defer s.a.free(own); + _ = try loader.require(own); + const body = if (control) try bits.edited(s.a, own, "void glm_index_scores_nax(", "const int tm = 16 * int(sg);", "const int tm = 16 * int(sg / 2);") else try s.a.dupe(u8, own); + defer s.a.free(body); + const main_text = try tf.frags.source(s.device, s.a, main_index); + defer s.a.free(main_text); + const new = try bits.pipeline(s.device, body, "glm_index_scores_nax"); + errdefer new.deinit(); + return .{ .control = control, .new = new, .old = try bits.pipeline(s.device, main_text, "glm_index_scores_nax") }; + } + pub fn deinit(x: *Case) void { + x.new.deinit(); + x.old.deinit(); + } + pub fn name(control: bool) []const u8 { + return if (control) "control: metal glm launch index scores, two simdgroups on each 16 rows" else "metal glm launch index scores glm_index_scores_nax, 16 rows x 64 blocks a simdgroup"; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.control), "main's glm_index_scores_nax (32 rows x 32 blocks a simdgroup)", "main's bytes in every score written, NaN payloads and infinities from the queries and weights included", &served, "the same tensor-unit products a head, the same head order and fused sums; only the tiles' rows change"); + } + pub fn layout(_: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.rows > 256 or s.n != DI or s.k + s.rows + 1 < 4) return null; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * QR * 2, .bf16); + _ = l.add(.input, s.rows * HI * 2, .bf16); + _ = l.add(.input, stride(s) * DI * 2, .bf16); + _ = l.add(.output, s.rows * stride(s) * 4, .f32); + return l; + } + /// Queries, weights, keys; gate 1 and every third shape plant specials in queries and weights (NaN keys relu to 0). + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + for (std.mem.bytesAsSlice(u16, data[0])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + for (std.mem.bytesAsSlice(u16, data[1])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 0.4); + const pool = std.mem.bytesAsSlice(u16, data[2]); + for (pool) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + if (f == .stress or (f == .random and seed % 3 != 2)) return; + const q = std.mem.bytesAsSlice(u16, data[0]); + const w = std.mem.bytesAsSlice(u16, data[1]); + for (bits.special_bf16, 0..) |v, i| { + const r = (i * 37) % s.rows; + q[r * QR + QOFF + (i * 131) % (HI * DI)] = v; + w[((i * 53 + 1) % s.rows) * HI + (i * 7) % HI] = v; + } + pool[(seed % stride(s)) * DI + 5] = 0x7fc0; + } + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const most = (s.k + s.rows) / 4; + e.setPipeline(if (new) x.new else x.old); + e.setBuffer(r[0].buf, r[0].off + QOFF * 2, 0); + e.setBuffer(r[1].buf, r[1].off, 1); + e.setBuffer(r[2].buf, r[2].off, 2); + e.setBuffer(r[3].buf, r[3].off, 3); + e.setValue(ScoreArgs{ .p0 = @intCast(s.k), .q_stride = QR, .w_stride = HI, .s_stride = @intCast(stride(s)), .rows = @intCast(s.rows) }, 4); + const tile: usize = if (new) tf.glm.prompt.scoreRows(@intCast(most), @intCast(s.rows)) else 64; // selectKeys', main's + e.dispatchGroups(mtl.Size.of((most + 63) / 64, (s.rows + tile - 1) / tile, 1), mtl.Size.of(2 * tile, 1, 1)); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(control))) try s.add(Case, try Case.init(s, control)); + } +} + +/// Gate 5's registration `glm launch index `: the loader's index library here, and as a pre-M5 GPU builds it. +pub const prefix = "glm launch index "; +pub fn limitsText(a: std.mem.Allocator, device: mtl.Device, _: []const u8) !bits.Texts { + return .{ .here = try Case.text(a, device), .pre_m5 = try tf.frags.precision.source(a, false, sources.glm_index_nax, sources.nax, false) }; +} diff --git a/zig/tests/contract/metal_glm_kda.zig b/zig/tests/contract/metal_glm_kda.zig new file mode 100644 index 00000000000..075edefe8a0 --- /dev/null +++ b/zig/tests/contract/metal_glm_kda.zig @@ -0,0 +1,199 @@ +//! GLM's windowed KDA steps (glm_kda_window.metal, glm_kda_parts.metal) against kda_rows on the same window and state. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const kernels = tf.glm.kernels; + +const D = 128; +const TAPS = 4; +const lower_bound: f32 = -5.0; // config.zig's gate_lower_bound and rms_norm_eps +const eps: f32 = 1e-5; + +/// The window step (all heads, one Mac's 32 heads at TP2), and an Ultra's two groups a head with the norm after. +pub const Form = enum { window, window_tp, parts }; + +/// kernels.zig's KDA library: kda_rows' source, then the prompt passes, the window step and the parts appended. +pub fn text(a: std.mem.Allocator) ![]u8 { + return std.mem.concat(a, u8, &.{ comptime kernels.generatedSource("kda_rows"), sources.glm_kda_prompt, sources.glm_kda_window, sources.glm_kda_parts }); +} + +fn heads(f: Form) usize { + return if (f == .window_tp) 32 else 64; +} + +/// Rows: the window's rows (one row keeps kda_rows); n: the heads; k: the head width. RB 8: 8 and 9 are edges. +const served_rows = [_]usize{ 16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; +fn servedOf(comptime f: Form) [served_rows.len]c.Shape { + var out: [served_rows.len]c.Shape = undefined; + for (&out, served_rows) |*s, r| s.* = .{ .rows = r, .n = heads(f), .k = D }; + return out; +} +const served = [3][served_rows.len]c.Shape{ servedOf(.window), servedOf(.window_tp), servedOf(.parts) }; + +/// The step's buffers in kda_rows' binding order (P, its shape is a value), then Y, the state and the window out. +const Slots = enum(u8) { p, cs, cw, fbw, fbs, fbb, gbw, gbs, gbb, a, dtb, st, onw, y, st_out, cs_out }; + +pub const Case = struct { + form: Form, + control: bool, + new: mtl.Pipeline, + norm: ?mtl.Pipeline = null, + old: mtl.Pipeline, + + pub fn init(s: *bits.Suite, form: Form, control: bool) !Case { + const loader = try s.production(); + const own = try text(s.a); + defer s.a.free(own); + _ = try loader.require(own); + const body = if (!control) try s.a.dupe(u8, own) else if (form == .parts) try bits.edited(s.a, own, "void glm_kda_parts(", "const uint dv0 = part * (uint)DV;", "const uint dv0 = 0u * part;") else try bits.edited(s.a, own, "void glm_kda_window(", "P[(size_t)(r0 + (int)tid) * PS + BO + h]", "P[(size_t)r0 * PS + BO + h]"); + defer s.a.free(body); + const fun = switch (form) { + .window => "glm_kda_window", + .window_tp => "glm_kda_window_tp", + .parts => "glm_kda_parts", + }; + const new = try bits.pipeline(s.device, body, fun); + errdefer new.deinit(); + const norm = if (form == .parts) try bits.pipeline(s.device, body, "glm_kda_norm") else null; + errdefer if (norm) |p| p.deinit(); + return .{ .form = form, .control = control, .new = new, .norm = norm, .old = try oldPipe(s, form == .window_tp) }; + } + pub fn deinit(x: *Case) void { + x.new.deinit(); + if (x.norm) |p| p.deinit(); + x.old.deinit(); + } + pub fn name(form: Form, control: bool) []const u8 { + return switch (form) { + .window => if (control) "control: metal glm launch kda glm_kda_window, every row's beta read from the first row" else "metal glm launch kda glm_kda_window 64 heads", + .window_tp => if (control) "control: metal glm launch kda glm_kda_window_tp, every row's beta read from the first row" else "metal glm launch kda glm_kda_window_tp 32 heads", + .parts => if (control) "control: metal glm launch kda glm_kda_parts, the second group on the first group's value columns" else "metal glm launch kda glm_kda_parts and glm_kda_norm 64 heads", + }; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.form, x.control), if (x.form == .window_tp) "kda_rows_tp" else "kda_rows", "kda_rows' bytes in the outputs, the next state and the next conv window, NaN payloads included", &served[@backingInt(x.form)], "kda_rows' sums in its order: quad dots, conv taps, simd sums and the serial recurrence"); + } + fn proj(f: Form) usize { + return 3 * heads(f) * D + 2 * D + heads(f); + } + pub fn layout(x: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows < 2 or s.rows > 16 or s.n != heads(x.form) or s.k != D) return null; + return kdaLayout(s.rows, heads(x.form), x.form == .parts); + } + pub fn fill(x: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + kdaFill(s.rows, heads(x.form), f, seed, data); + } + /// forward.zig's kdaStep: the parts take the gate rows at buffer 13 and 16 rows of lanes, then the norm. + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const h = heads(x.form); + if (!new or x.form != .parts) return kdaEncode(e, r, if (new) x.new else x.old, s.rows, h, 32, null); + kdaEncode(e, r, x.new, s.rows, h, 16, r[16]); + e.setPipeline(x.norm.?); + e.setBuffer(r[13].buf, r[13].off, 0); + e.setBuffer(r[16].buf, r[16].off, 1); + e.setBuffer(r[12].buf, r[12].off, 2); + e.setValue(eps, 3); + e.dispatchGroups(mtl.Size.of(h / 8, s.rows, 1), mtl.Size.of(256, 1, 1)); + } +}; + +/// The generated kda_rows (all 64 heads) or kda_rows_tp (one Mac's 32), from the loader's own library. +pub fn oldPipe(s: *bits.Suite, tp: bool) !mtl.Pipeline { + const loader = try s.production(); + if (tp) return bits.pipeline(s.device, try loader.require(comptime kernels.generatedSource("kda_rows_tp")), comptime kernels.generatedFunction("kda_rows_tp")); + return bits.pipeline(s.device, try loader.require(comptime kernels.generatedSource("kda_rows")), comptime kernels.generatedFunction("kda_rows")); +} + +/// The step's slots for `rows` rows of `h` heads (`gate`: kda_parts' gate rows after them). +pub fn kdaLayout(rows: usize, h: usize, gate: bool) bits.Layout { + const W = h * D; + var l: bits.Layout = .{}; + _ = l.add(.input, rows * (3 * W + 2 * D + h) * 2, .bf16); + _ = l.add(.input, (TAPS - 1) * 3 * W * 2, .bf16); + _ = l.add(.input, TAPS * 3 * W * 4, .f32); + for (0..2) |_| { + _ = l.add(.input, W * D * 4 / 8, .int); + _ = l.add(.input, W * (D / 64) * 2, .bf16); + _ = l.add(.input, W * (D / 64) * 2, .bf16); + } + _ = l.add(.input, h * 4, .f32); + _ = l.add(.input, W * 4, .f32); + _ = l.add(.input, h * D * D * 4, .f32); + _ = l.add(.input, D * 4, .f32); + _ = l.add(.output, rows * W * 2, .bf16); + _ = l.add(.output, h * D * D * 4, .f32); + _ = l.add(.output, (TAPS - 1) * 3 * W * 2, .bf16); + if (gate) _ = l.add(.scratch, rows * W * 2, .bf16); + return l; +} + +fn uniform(rnd: std.Random, lo: f32, hi: f32) f32 { + return lo + rnd.float(f32) * (hi - lo); +} + +/// tf-glm-kda-speed's draws; odd seeds add -0 and large inputs; gate 1 and every third shape plant NaN and infinities. +pub fn kdaFill(rows: usize, h: usize, f: g.Fill, seed: u64, data: [][]u8) void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const W = h * D; + const P = 3 * W + 2 * D + h; + for ([_]Slots{ .p, .cs }) |i| for (std.mem.bytesAsSlice(u16, data[@backingInt(i)])) |*v| { + v.* = bits.bf(uniform(rnd, -2, 2)); + }; + for (std.mem.bytesAsSlice(f32, data[@backingInt(Slots.cw)])) |*v| v.* = uniform(rnd, -0.5, 0.5); + for ([_]Slots{ .fbw, .gbw }) |i| rnd.bytes(data[@backingInt(i)]); + for ([_]Slots{ .fbs, .gbs }) |i| for (std.mem.bytesAsSlice(u16, data[@backingInt(i)])) |*v| { + v.* = bits.bf(uniform(rnd, 0.001, 0.02)); + }; + for ([_]Slots{ .fbb, .gbb }) |i| for (std.mem.bytesAsSlice(u16, data[@backingInt(i)])) |*v| { + v.* = bits.bf(uniform(rnd, -0.05, 0.05)); + }; + for (std.mem.bytesAsSlice(f32, data[@backingInt(Slots.a)])) |*v| v.* = uniform(rnd, 0.5, 2); + for (std.mem.bytesAsSlice(f32, data[@backingInt(Slots.dtb)])) |*v| v.* = uniform(rnd, -1, 1); + for (std.mem.bytesAsSlice(f32, data[@backingInt(Slots.st)])) |*v| v.* = uniform(rnd, -0.1, 0.1); + for (std.mem.bytesAsSlice(f32, data[@backingInt(Slots.onw)])) |*v| v.* = uniform(rnd, 0.5, 1.5); + const p = std.mem.bytesAsSlice(u16, data[@backingInt(Slots.p)]); + if (seed % 2 == 1) for (p, 0..) |*v, i| { + if (i % 97 == 0) v.* = 0x8000 else if (i % 89 == 0) v.* = bits.bf(40); + }; + if (f == .stress or (f == .random and seed % 3 != 2)) return; + // q of row 0, k of row 1, v of row 2, f_b's input in row 3, beta of row 4: NaN, +Inf, -Inf, both, NaN + const at = [_][2]usize{ .{ 0, 5 }, .{ 1, W + D + 7 }, .{ 2, 2 * W + 3 * D + 9 }, .{ 3, 3 * W + 11 }, .{ 3, 3 * W + 40 }, .{ 4, 3 * W + 2 * D + 1 } }; + const vals = [_]u16{ 0x7fc0, 0x7f80, 0xff80, 0x7f80, 0xff80, 0x7fc0 }; + for (at, vals) |q, v| if (q[0] < rows) { + p[q[0] * P + q[1]] = v; + }; +} + +/// forward.zig's kdaStep for the generated gate: `pipe` over a (32, 32, heads) grid of (32, `ty`) groups. +pub fn kdaEncode(e: mtl.ComputeEncoder, r: []const rig_.Ref, pipe: mtl.Pipeline, rows: usize, h: usize, ty: usize, gate: ?rig_.Ref) void { + e.setPipeline(pipe); + e.setBuffer(r[0].buf, r[0].off, 0); + const shape = [2]i32{ @intCast(rows), @intCast(3 * h * D + 2 * D + h) }; + e.setBytes(std.mem.asBytes(&shape), 1); + for (1..13) |i| e.setBuffer(r[i].buf, r[i].off, i + 1); + e.setValue(lower_bound, 14); + e.setValue(eps, 15); + for (13..16) |i| e.setBuffer(r[i].buf, r[i].off, i + 3); + if (gate) |q| e.setBuffer(q.buf, q.off, 13); + e.dispatchThreads(mtl.Size.of(32, 32, h), mtl.Size.of(32, ty, 1)); +} + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for (std.enums.values(Form)) |form| for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(form, control))) try s.add(Case, try Case.init(s, form, control)); + }; +} + +/// Gate 5's registrations `glm launch kda `: the loader's KDA library. +pub const prefix = "glm launch kda "; +pub fn limitsText(a: std.mem.Allocator, _: mtl.Device, _: []const u8) !bits.Texts { + const t = try text(a); + return .{ .here = t, .pre_m5 = t }; +} diff --git a/zig/tests/contract/metal_glm_launch.zig b/zig/tests/contract/metal_glm_launch.zig new file mode 100644 index 00000000000..2a5f4f0b6f8 --- /dev/null +++ b/zig/tests/contract/metal_glm_launch.zig @@ -0,0 +1,34 @@ +//! GLM-5.3-Flash's served Metal launches under the contract: gates 1-4 against their predecessors, then gate 5. +const std = @import("std"); +const mtl = @import("metal"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const Launch = @import("metal_limits.zig").Launch; + +const groups = .{ @import("metal_glm_select.zig"), @import("metal_glm_kda.zig"), @import("metal_glm_attn.zig"), @import("metal_glm_hc.zig"), @import("metal_glm_experts_pick.zig"), @import("metal_glm_experts.zig"), @import("metal_glm_route.zig"), @import("metal_glm_route_select.zig"), @import("metal_glm_mla_norms.zig"), @import("metal_glm_prompt_mm.zig"), @import("metal_glm_index.zig") }; +/// Gate 5's text owners by registration prefix (a longer prefix before its own start): the groups and the softmax. +const launches = groups ++ .{@import("metal_glm_attn.zig").softmax}; + +pub const Suite = struct { + inner: bits.Suite, + pub fn init(a: std.mem.Allocator, device: mtl.Device, queue: mtl.Queue, kernels: *std.ArrayList(contract.gates.Kernel)) Suite { + return .{ .inner = .{ .a = a, .device = device, .queue = queue, .kernels = kernels } }; + } + pub fn collect(s: *Suite, only: ?[]const u8) !void { + inline for (groups) |grp| try grp.collect(&s.inner, only); + } + pub fn deinit(s: *Suite) void { + s.inner.deinit(); + } +}; + +/// Gate 5 for a `glm launch ` registration: the library the loader builds for it here, and its pre-M5 form. +pub fn launchOf(a: std.mem.Allocator, device: mtl.Device, d: contract.limits.MetalLaunch, fun: []const u8, comptime assemble: bool) !?Launch { + if (!std.mem.startsWith(u8, d.name, "glm launch ")) return null; + inline for (launches) |grp| if (std.mem.startsWith(u8, d.name, grp.prefix)) { + if (!assemble) return @as(Launch, undefined); + const texts = try grp.limitsText(a, device, d.name); + return .{ .decl = d, .function = fun, .here = texts.here, .pre_m5 = texts.pre_m5 }; + }; + return error.UnknownLaunch; +} diff --git a/zig/tests/contract/metal_glm_mla_norms.zig b/zig/tests/contract/metal_glm_mla_norms.zig new file mode 100644 index 00000000000..ac206c1933e --- /dev/null +++ b/zig/tests/contract/metal_glm_mla_norms.zig @@ -0,0 +1,155 @@ +//! GLM's MLA norms in one launch (forward.zig's mlaNorms, glm_mla_norms) against main's four launches on x_proj rows. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const glm = tf.glm; + +const cfg: glm.config.Config = .{}; +const Q = cfg.q_lora; +const R = cfg.kv_lora; +const IK = cfg.i_dim; +const IW = cfg.i_heads; +/// Main's glm_glue.metal: glm_rms, glm_layer_norm and glm_scale as their own launches. +const main_glue = @import("metal_glm_attn.zig").main_glue; + +/// Four roles with the query norm (decode, x_proj rows xProj apart), three without (a prompt chunk's, rows 64-aligned). +pub const Roles = enum { four, three }; +fn stride(r: Roles) usize { + return if (r == .four) cfg.xProj() else std.mem.alignForward(usize, cfg.xProj(), 64); +} +/// Rows: x_proj rows; n: the roles; k: a row's stride. +const served = [2][5]c.Shape{ + .{ .{ .rows = 8, .n = 4, .k = stride(.four) }, .{ .rows = 1, .n = 4, .k = stride(.four) }, .{ .rows = 2, .n = 4, .k = stride(.four) }, .{ .rows = 5, .n = 4, .k = stride(.four) }, .{ .rows = 16, .n = 4, .k = stride(.four) } }, + .{ .{ .rows = 8, .n = 3, .k = stride(.three) }, .{ .rows = 1, .n = 3, .k = stride(.three) }, .{ .rows = 16, .n = 3, .k = stride(.three) }, .{ .rows = 64, .n = 3, .k = stride(.three) }, .{ .rows = 512, .n = 3, .k = stride(.three) } }, +}; + +pub const Case = struct { + roles: Roles, + control: bool, + kern: glm.kernels.Kernels = undefined, + old: [3]mtl.Pipeline, + + pub fn init(s: *bits.Suite, roles: Roles, control: bool) !Case { + const loader = try s.production(); + const glue = try loader.require(sources.glm_glue); + const body = if (control) try bits.edited(s.a, glue, "void glm_mla_norms(", "glm_ln_row(x + a.ik_at, ik_w,", "glm_ln_row(x + a.ik_at, kv_w,") else try s.a.dupe(u8, glue); + defer s.a.free(body); + var x: Case = .{ .roles = roles, .control = control, .old = undefined }; + x.kern.mla_norms = try bits.pipeline(s.device, body, "glm_mla_norms"); + errdefer x.kern.mla_norms.deinit(); + var made: usize = 0; + errdefer for (x.old[0..made]) |p| p.deinit(); + for ([_][]const u8{ "glm_rms", "glm_layer_norm", "glm_scale" }, 0..) |n, i| { + x.old[i] = try bits.pipeline(s.device, main_glue, n); + made += 1; + } + return x; + } + pub fn deinit(x: *Case) void { + x.kern.mla_norms.deinit(); + for (x.old) |p| p.deinit(); + } + pub fn name(roles: Roles, control: bool) []const u8 { + if (control) return if (roles == .four) "control: metal glm launch mla norms four roles, the key norm with the kv norm's weights" else "control: metal glm launch mla norms three roles, the key norm with the kv norm's weights"; + return if (roles == .four) "metal glm launch mla norms glm_mla_norms four roles (kv, key, index weights, query)" else "metal glm launch mla norms glm_mla_norms three roles (kv, key, index weights)"; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.roles, x.control), "main's glm_rms, glm_layer_norm and glm_scale launches", "main's bytes in the latent keys, indexer keys, index weights and query rows, NaN payloads included", &served[@backingInt(x.roles)], "MLX's rms and layer-norm sums in main's order, the weights' exact scale"); + } + pub fn layout(x: *const Case, s: c.Shape) ?bits.Layout { + const n: usize = if (x.roles == .four) 4 else 3; + if (s.rows == 0 or s.n != n or s.k != stride(x.roles)) return null; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * s.k * 2, .bf16); + _ = l.add(.input, R * 2, .bf16); + _ = l.add(.input, IK * 2, .bf16); + _ = l.add(.input, IK * 2, .bf16); + _ = l.add(.input, Q * 2, .bf16); + _ = l.add(.output, s.rows * R * 2, .bf16); + _ = l.add(.output, s.rows * IK * 2, .bf16); + _ = l.add(.output, s.rows * IW * 2, .bf16); + if (x.roles == .four) _ = l.add(.output, s.rows * Q * 2, .bf16); + return l; + } + /// x_proj rows and norm weights; gate 1 and every third shape plant NaN and infinities in each role's columns. + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const xp = std.mem.bytesAsSlice(u16, data[0]); + for (xp) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 6); + for (data[1..5], 0..) |d, i| for (std.mem.bytesAsSlice(u16, d)) |*v| { + v.* = bits.bf(if (i == 2) (rnd.float(f32) - 0.5) * 0.2 else 0.5 + rnd.float(f32)); + }; + if (f == .stress or (f == .random and seed % 3 != 2)) return; + const at = [_][2]usize{ .{ 0, Q + 3 }, .{ 1, Q + R + 5 }, .{ 2, Q + R + IK + 7 }, .{ 3, 11 }, .{ 3, Q + 40 } }; + for (at, [_]u16{ 0x7fc0, 0x7f80, 0xff80, 0x7f80, 0xff80 }) |p, v| if (p[0] < s.rows) { + xp[p[0] * s.k + p[1]] = v; + }; + } + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const rows: u32 = @intCast(s.rows); + const xs: u32 = @intCast(s.k); + const ref = struct { + fn of(v: rig_.Ref, extra: usize) glm.weights.Ref { + return .{ .buf = v.buf, .off = v.off + extra }; + } + }.of; + if (new) { + var w: glm.weights.Mla = undefined; + w.kv_norm = ref(r[1], 0); + w.k_norm_w = ref(r[2], 0); + w.k_norm_b = ref(r[3], 0); + w.q_norm = ref(r[4], 0); + return glm.forward.mlaNorms(&x.kern, &cfg, e, &w, ref(r[0], 0), xs, ref(r[5], 0), ref(r[6], 0), ref(r[7], 0), if (x.roles == .four) ref(r[8], 0) else null, rows); + } + const Rows = glm.forward.Rows; + const bind = struct { + fn at(enc: mtl.ComputeEncoder, v: rig_.Ref, extra: usize, i: usize) void { + enc.setBuffer(v.buf, v.off + extra, i); + } + }.at; + e.setPipeline(x.old[0]); // main's mlaCache: the kv norm into the cache, the key norm, the index weights + bind(e, r[0], Q * 2, 0); + bind(e, r[1], 0, 1); + bind(e, r[5], 0, 2); + e.setValue(Rows{ .rows = @intCast(rows), .width = R, .x_stride = @intCast(xs), .y_stride = R, .eps = cfg.eps }, 3); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(((R + 3) / 4 + 31) / 32 * 32, 1, 1)); + e.setPipeline(x.old[1]); + bind(e, r[0], (Q + R) * 2, 0); + bind(e, r[2], 0, 1); + bind(e, r[3], 0, 2); + bind(e, r[6], 0, 3); + e.setValue(Rows{ .rows = @intCast(rows), .width = IK, .x_stride = @intCast(xs), .y_stride = IK, .eps = 1e-6 }, 4); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(32, 1, 1)); + e.setPipeline(x.old[2]); + bind(e, r[0], (Q + R + IK) * 2, 0); + bind(e, r[7], 0, 1); + e.setValue(Rows{ .rows = @intCast(rows), .width = IW, .x_stride = @intCast(xs), .y_stride = IW, .eps = 1.0 / 64.0 }, 2); + e.dispatchThreads(mtl.Size.of(IW, rows, 1), mtl.Size.of(IW, 1, 1)); + if (x.roles != .four) return; + e.setPipeline(x.old[0]); // main's mlaAttend: the query norm from the same rows + bind(e, r[0], 0, 0); + bind(e, r[4], 0, 1); + bind(e, r[8], 0, 2); + e.setValue(Rows{ .rows = @intCast(rows), .width = Q, .x_stride = @intCast(xs), .y_stride = Q, .eps = cfg.eps }, 3); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(((Q + 3) / 4 + 31) / 32 * 32, 1, 1)); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]Roles{ .four, .three }) |roles| for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(roles, control))) try s.add(Case, try Case.init(s, roles, control)); + }; +} + +/// Gate 5's registration `glm launch mla norms `: the loader's glue library. +pub const prefix = "glm launch mla norms "; +pub fn limitsText(_: std.mem.Allocator, _: mtl.Device, _: []const u8) !bits.Texts { + return .{ .here = sources.glm_glue, .pre_m5 = sources.glm_glue }; +} diff --git a/zig/tests/contract/metal_glm_prompt_mm.zig b/zig/tests/contract/metal_glm_prompt_mm.zig new file mode 100644 index 00000000000..66a65d94329 --- /dev/null +++ b/zig/tests/contract/metal_glm_prompt_mm.zig @@ -0,0 +1,258 @@ +//! GLM's prompt experts and dense products in column groups (glm_mm_groups.metal) against core/affine_mm.zig's. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const affine_mm = tf.affine_mm; +const groups = tf.glm.mm_groups; + +const E = 6; // experts in the pool +const TOPK = 2; // a token's picks: pairs / 2 tokens +const D = 4096; +const N = 2048; +const swiglu_limit: f32 = 10.0; // config.zig's + +/// kernels.zig's prompt matmul library: core/affine_mm.metal at 4/64, bf16 out, the column-group gathers appended. +pub fn text(a: std.mem.Allocator, device: mtl.Device) ![]u8 { + return groups.source(device, a); +} + +/// The same library as a GPU without tensor units builds it (nax.h's simdgroup-matrix layout). +fn preM5(a: std.mem.Allocator) ![]u8 { + const body = try tf.frags.precision.source(a, false, sources.core_affine_mm, sources.nax, false); + defer a.free(body); + return std.mem.concat(a, u8, &.{ "#define TF_BITS 4\n#define TF_GROUP 64\n#define TF_OUT_T bfloat\n", body, sources.glm_mm_groups }); +} + +/// Rows: sorted pairs (experts' means 2, 43 and 183: both tile heights of each launch); n: gate/up's width; k: hidden. +const served = [_]c.Shape{ .{ .rows = 1100, .n = N, .k = D }, .{ .rows = 12, .n = N, .k = D }, .{ .rows = 260, .n = N, .k = D } }; + +const Slot = enum(u8) { x, gw, gs, gb, uw, us, ub, dw, ds, db, offs, order, sums, act, y }; + +pub const Case = struct { + control: bool, + ahead: bool, // the control's fault is in the step-ahead loads, not the column groups + mm: affine_mm.Pipes, + ours: groups.Pipes, + + pub fn init(s: *bits.Suite, control: bool, ahead: bool) !Case { + const loader = try s.production(); + const own = try text(s.a, s.device); + defer s.a.free(own); + _ = try loader.require(own); + const body = if (!control) try s.a.dupe(u8, own) else if (ahead) try bits.edited(s.a, own, "inline void gt_k_loop(", "next = am_load(wq + STEP_BYTES);", "next = am_load(wq);") else try bits.edited(s.a, own, "inline int gt_order(", "col = g * GT_GROUP + rem % GT_GROUP;", "col = rem % GT_GROUP + 0 * g;"); + defer s.a.free(body); + var x: Case = .{ .control = control, .ahead = ahead, .mm = undefined, .ours = undefined }; + var made: usize = 0; + errdefer for (x.mm[0..made]) |p| p.deinit(); + for (affine_mm.names, &x.mm) |n, *p| { + p.* = try bits.pipeline(s.device, own, n); + made += 1; + } + var ours: usize = 0; + errdefer for (x.ours[0..ours]) |p| p.deinit(); + for (groups.names, &x.ours) |n, *p| { + p.* = try bits.pipeline(s.device, body, n); + ours += 1; + } + return x; + } + pub fn deinit(x: *Case) void { + for (x.mm) |p| p.deinit(); + for (x.ours) |p| p.deinit(); + } + pub fn name(control: bool, ahead: bool) []const u8 { + if (control and ahead) return "control: metal glm launch prompt experts, each step's codes loaded again in place of the next step's"; + return if (control) "control: metal glm launch prompt experts, every column group taking the first group's columns" else "metal glm launch prompt experts gate/up and down in column groups, codes a step ahead"; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.control, x.ahead), "tf_affine_gather_glu and tf_affine_gather_scatter at 32 and 64 rows", "the one-launch gathers' bytes in every pair's activations and outputs", &served, "core/affine_mm.zig's tiles and sums; only the order the tiles run in and when their codes load change"); + } + pub fn layout(_: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.rows > 1100 or s.rows % TOPK != 0 or s.n != N or s.k != D) return null; + const w: tf.glm.affine.Width = .{ .bits = 4, .group = 64 }; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows / TOPK * D * 2, .bf16); + for ([_][2]usize{ .{ E * N, D }, .{ E * N, D }, .{ E * D, N } }) |m| { + _ = l.add(.input, tf.glm.affine.wBytes(m[0], m[1], w), .int); + _ = l.add(.input, tf.glm.affine.sBytes(m[0], m[1], w), .bf16); + _ = l.add(.input, tf.glm.affine.sBytes(m[0], m[1], w), .bf16); + } + _ = l.add(.input, E * 4, .int); + _ = l.add(.input, s.rows * 4, .int); + _ = l.add(.scratch, s.rows * (D / 64) * 4, .int); + _ = l.add(.output, s.rows * N * 2, .bf16); + _ = l.add(.output, s.rows * D * 2, .bf16); + return l; + } + /// Each token two distinct experts of the pool, pairs sorted by expert in pair order (the prompt's sort's). + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + for (std.mem.bytesAsSlice(u16, data[@backingInt(Slot.x)])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + for (0..3) |m| { + const at = @backingInt(Slot.gw) + 3 * m; + rnd.bytes(data[at]); + for (std.mem.bytesAsSlice(u16, data[at + 1])) |*v| v.* = bits.bf(rnd.float(f32) * 0.004 + 0.0005); + for (std.mem.bytesAsSlice(u16, data[at + 2])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 0.05); + } + var pick_buf: [1100]i32 = undefined; + const picks = pick_buf[0..s.rows]; + for (0..s.rows / TOPK) |t| { + const a = rnd.uintLessThan(usize, E); + picks[t * TOPK] = @intCast(a); + picks[t * TOPK + 1] = @intCast((a + 1 + rnd.uintLessThan(usize, E - 1)) % E); + } + const offs = std.mem.bytesAsSlice(i32, data[@backingInt(Slot.offs)]); + const order = std.mem.bytesAsSlice(i32, data[@backingInt(Slot.order)]); + var counts: [E]i32 = @splat(0); + for (picks) |p| counts[@intCast(p)] += 1; + var first: i32 = 0; + for (offs, counts) |*o, n| { + o.* = first; + first += n; + } + var fill_at: [E]i32 = undefined; + for (&fill_at, offs) |*fa, o| fa.* = o; + for (picks, 0..) |p, i| { + order[@intCast(fill_at[@intCast(p)])] = @intCast(i); + fill_at[@intCast(p)] += 1; + } + if (f == .stress or (f == .random and seed % 3 != 2)) return; + const x = std.mem.bytesAsSlice(u16, data[@backingInt(Slot.x)]); + const tokens = s.rows / TOPK; + for ([_][2]usize{ .{ 0, 5 }, .{ 1, 700 }, .{ 2, 64 }, .{ 3, 9 }, .{ 3, 4000 } }, bits.special_bf16[0..5]) |p, v| if (p[0] < tokens) { + x[p[0] * D + p[1]] = v; + }; + // the SwiGLU's clip takes NaN and infinities out of the activations: down's scales carry them to its outputs + const ds = std.mem.bytesAsSlice(u16, data[@backingInt(Slot.ds)]); + for ([_]usize{ 3, 64 * (N / 64) + 1, 2000 * (N / 64), (E * D - 1) * (N / 64) }, bits.special_bf16[0..4]) |at, v| ds[at] = v; + } + /// prompt.zig's routed experts on one Mac at 4/64: row sums, gate/up GLU, the activations' sums, down scattered. + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const n: u32 = @intCast(s.rows); + const q = struct { + fn mat(rr: []const rig_.Ref, at: Slot, rows: u32, k: u32) struct { w: rig_.Ref, s: rig_.Ref, b: rig_.Ref, n: u32, k: u32 } { + const i = @backingInt(at); + return .{ .w = rr[i], .s = rr[i + 1], .b = rr[i + 2], .n = rows, .k = k }; + } + }.mat; + const gate = q(r, .gw, N, D); + const up = q(r, .uw, N, D); + const down = q(r, .dw, D, N); + const xr = r[@backingInt(Slot.x)]; + const sums = r[@backingInt(Slot.sums)]; + const offs = r[@backingInt(Slot.offs)]; + const order = r[@backingInt(Slot.order)]; + const act = r[@backingInt(Slot.act)]; + const y = r[@backingInt(Slot.y)]; + affine_mm.rowSums(e, x.mm, 64, xr, sums, n / TOPK, D); + if (new) { + groups.gatherGlu(e, x.ours, xr, sums, gate, up, offs, order, act, n, E, TOPK, swiglu_limit); + } else affine_mm.gatherGlu(e, x.mm, xr, sums, gate, up, offs, order, act, n, E, TOPK, swiglu_limit); + affine_mm.rowSums(e, x.mm, 64, act, sums, n, N); + if (new) { + groups.gatherTo(e, x.ours, act, sums, down, offs, y, order, n, E); + } else affine_mm.gatherTo(e, x.mm, act, sums, down, offs, y, order, n, E); + } +}; + +/// Rows, n, k: prompt.zig's deep products (a partial last column group at 2240 and 24896 columns). +const dense_served = [_]c.Shape{ .{ .rows = 200, .n = 4096, .k = 8192 }, .{ .rows = 130, .n = 2240, .k = 4096 }, .{ .rows = 70, .n = 24896, .k = 4096 } }; + +const DSlot = enum(u8) { x, w, s, b, sums, y }; + +pub const Dense = struct { + control: bool, + mm: affine_mm.Pipes, + ours: groups.Pipes, + + pub fn init(s: *bits.Suite, control: bool) !Dense { + const loader = try s.production(); + const own = try text(s.a, s.device); + defer s.a.free(own); + _ = try loader.require(own); + const body = if (control) try bits.edited(s.a, own, "void glm_mm_grouped(", "const int row = (rem / gl) * 64", "const int row = (rem / GT_GROUP) * 64") else try s.a.dupe(u8, own); + defer s.a.free(body); + var x: Dense = .{ .control = control, .mm = undefined, .ours = undefined }; + var made: usize = 0; + errdefer for (x.mm[0..made]) |p| p.deinit(); + for (affine_mm.names, &x.mm) |n, *p| { + p.* = try bits.pipeline(s.device, own, n); + made += 1; + } + var ours: usize = 0; + errdefer for (x.ours[0..ours]) |p| p.deinit(); + for (groups.names, &x.ours) |n, *p| { + p.* = try bits.pipeline(s.device, body, n); + ours += 1; + } + return x; + } + pub fn deinit(x: *Dense) void { + for (x.mm) |p| p.deinit(); + for (x.ours) |p| p.deinit(); + } + pub fn name(control: bool) []const u8 { + return if (control) "control: metal glm launch prompt dense, the last column group's row tiles counted as a whole group's" else "metal glm launch prompt dense products in column groups"; + } + pub fn spec(x: *const Dense) c.Spec { + return bits.spec(name(x.control), "tf_affine_mm at one batch", "tf_affine_mm's bytes in every output", &dense_served, "core/affine_mm.zig's tiles and sums; only the order the tiles run in changes"); + } + pub fn layout(_: *const Dense, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.n % 64 != 0 or s.k % 64 != 0 or s.k < groups.dense_from) return null; + const w: tf.glm.affine.Width = .{ .bits = 4, .group = 64 }; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * s.k * 2, .bf16); + _ = l.add(.input, tf.glm.affine.wBytes(s.n, s.k, w), .int); + _ = l.add(.input, tf.glm.affine.sBytes(s.n, s.k, w), .bf16); + _ = l.add(.input, tf.glm.affine.sBytes(s.n, s.k, w), .bf16); + _ = l.add(.scratch, s.rows * (s.k / 64) * 4, .int); + _ = l.add(.output, s.rows * s.n * 2, .bf16); + return l; + } + pub fn fill(_: *const Dense, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + for (std.mem.bytesAsSlice(u16, data[@backingInt(DSlot.x)])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 2); + rnd.bytes(data[@backingInt(DSlot.w)]); + for (std.mem.bytesAsSlice(u16, data[@backingInt(DSlot.s)])) |*v| v.* = bits.bf(rnd.float(f32) * 0.004 + 0.0005); + for (std.mem.bytesAsSlice(u16, data[@backingInt(DSlot.b)])) |*v| v.* = bits.bf((rnd.float(f32) - 0.5) * 0.05); + if (f == .stress or (f == .random and seed % 3 != 2)) return; + const x = std.mem.bytesAsSlice(u16, data[@backingInt(DSlot.x)]); + for ([_][2]usize{ .{ 0, 5 }, .{ 1, 700 }, .{ 2, 64 }, .{ 3, 9 }, .{ 69, 4000 } }, bits.special_bf16[0..5]) |p, v| if (p[0] < s.rows) { + x[p[0] * s.k + p[1]] = v; + }; + } + /// prompt.zig's qmm: the rows' group sums, then the product (ours past mm_groups.dense_from deep). + pub fn encode(x: *const Dense, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const rows: u32 = @intCast(s.rows); + const q = .{ .w = r[@backingInt(DSlot.w)], .s = r[@backingInt(DSlot.s)], .b = r[@backingInt(DSlot.b)], .n = @as(u32, @intCast(s.n)), .k = @as(u32, @intCast(s.k)) }; + const xr = r[@backingInt(DSlot.x)]; + const sums = r[@backingInt(DSlot.sums)]; + const y = r[@backingInt(DSlot.y)]; + affine_mm.rowSums(e, x.mm, 64, xr, sums, rows, q.k); + if (new) { + groups.dense(e, x.ours, xr, sums, q, y, rows, .{ .x_row = @intCast(q.k), .y_row = @intCast(q.n) }); + } else affine_mm.dense(e, x.mm, xr, sums, q, y, rows); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(control, false))) try s.add(Case, try Case.init(s, control, false)); + if (s.wanted(only, Dense.name(control))) try s.add(Dense, try Dense.init(s, control)); + } + if (s.wanted(only, Case.name(true, true))) try s.add(Case, try Case.init(s, true, true)); +} + +/// Gate 5's registrations `glm launch prompt `: the loader's prompt matmul library. +pub const prefix = "glm launch prompt "; +pub fn limitsText(a: std.mem.Allocator, device: mtl.Device, _: []const u8) !bits.Texts { + return .{ .here = try text(a, device), .pre_m5 = try preM5(a) }; +} diff --git a/zig/tests/contract/metal_glm_route.zig b/zig/tests/contract/metal_glm_route.zig new file mode 100644 index 00000000000..9bf8dd98ae6 --- /dev/null +++ b/zig/tests/contract/metal_glm_route.zig @@ -0,0 +1,128 @@ +//! GLM's one-row router and indexer-gate logits (glm_route_one.metal) against float64 and tf_route_logits' bits. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const Logits = @import("metal_flint_route.zig").Logits; +const c = contract.spec; +const g = contract.gates; +const route = tf.moe_route; +const kernels = tf.glm.kernels; + +/// Rows: one-row windows, each its own launch as moe.zig and forward.zig's mlaCache launch it; n: outputs; k: hidden. +fn servedOf(comptime s: route.Shape) [3]c.Shape { + return .{ .{ .rows = 16, .n = s.experts, .k = s.hidden }, .{ .rows = 1, .n = s.experts, .k = s.hidden }, .{ .rows = 6, .n = s.experts, .k = s.hidden } }; +} +const served = [2][3]c.Shape{ servedOf(kernels.route_shape), servedOf(kernels.igate_shape) }; + +/// The loader's router library at a shape: core/moe_route.metal's logits and select, glm_route_one.metal appended. +pub fn text(a: std.mem.Allocator, s: route.Shape) ![]u8 { + const core = try route.source(a, s); + defer a.free(core); + return std.mem.concat(a, u8, &.{ core, sources.glm_route_one }); +} + +pub const RouteOne = struct { + inner: Logits, + rig: *rig_.Rig, + one: mtl.Pipeline, + igate: bool, + control: bool, + base: rig_.Ref = undefined, + + fn shape(t: *const RouteOne) route.Shape { + return if (t.igate) kernels.igate_shape else kernels.route_shape; + } + pub fn name(igate: bool, control: bool) []const u8 { + if (control) return if (igate) "control: metal glm launch route glm_route_logits_one indexer gate, one simdgroup's partial left out" else "control: metal glm launch route glm_route_logits_one router, one simdgroup's partial left out"; + return if (igate) "metal glm launch route glm_route_logits_one indexer gate 128 outputs, bf16 out" else "metal glm launch route glm_route_logits_one router 288 experts, fp32 out"; + } + pub fn create(s: *bits.Suite, igate: bool, control: bool) !*RouteOne { + const loader = try s.production(); + const own = try text(s.a, if (igate) kernels.igate_shape else kernels.route_shape); + defer s.a.free(own); + _ = try loader.require(own); + const body = if (control) try bits.edited(s.a, own, "void glm_route_logits_one(", "for (int k = 1; k < 8; k++)", "for (int k = 2; k < 8; k++)") else try s.a.dupe(u8, own); + defer s.a.free(body); + const one = try bits.pipeline(s.device, body, "glm_route_logits_one"); + errdefer one.deinit(); + const old = try bits.pipeline(s.device, own, route.names[0]); + errdefer old.deinit(); + const t = try s.a.create(RouteOne); + const Router = @FieldType(Logits, "r"); + const r: Router = .{ .label = if (igate) "glm igate" else "glm", .shape = if (igate) kernels.igate_shape else kernels.route_shape }; + t.* = .{ .inner = .{ .a = s.a, .rig = .{ .a = s.a, .device = s.device, .queue = s.queue }, .pipe = old, .r = r, .served = served[@intFromBool(igate)] }, .rig = undefined, .one = one, .igate = igate, .control = control }; + t.rig = &t.inner.rig; + return t; + } + pub fn deinit(t: *RouteOne) void { + t.inner.deinit(); + t.one.deinit(); + } + const vt = g.hooks(RouteOne); + pub fn kernel(t: *RouteOne) g.Kernel { + var sp = Logits.spec(name(t.igate, t.control), t.inner.r, &served[@intFromBool(t.igate)]); + sp.tiles = .{ .{}, .{}, .{} }; + sp.replaces = "tf_route_logits at one row"; + return .{ .spec = sp, .ctx = t, .vt = &vt, .control = if (t.control) .shapes else null }; + } + fn outBytes(t: *const RouteOne) usize { + return if (t.igate) 2 else 4; + } + pub fn prepare(t: *RouteOne, s: c.Shape, fill: g.Fill, seed: u64) !bool { + if (!try t.inner.prepare(s, fill, seed)) return false; + t.base = try t.rig.scratch(s.rows * s.n * t.outBytes()); + return true; + } + /// Each row a one-row window: moe_route.logits at one row, on that row's input and output. + fn launch(t: *RouteOne, pipe: mtl.Pipeline, out: rig_.Ref) !void { + const sh = t.shape(); + const pass = t.rig.begin(); + for (0..t.inner.rows) |r| { + const x: rig_.Ref = .{ .buf = t.inner.ins[0].buf, .off = t.inner.ins[0].off + r * sh.hidden * 2 }; + const o: rig_.Ref = .{ .buf = out.buf, .off = out.off + r * sh.experts * t.outBytes() }; + route.logits(pass.e, pipe, sh, x, t.inner.ins[1], o, 1); + } + try t.rig.finish(pass); + } + pub fn run(t: *RouteOne) !void { + try t.launch(t.one, t.inner.out); + } + pub fn replaced(t: *RouteOne) ![]const u8 { + const n = t.inner.count() * t.outBytes(); + @memset(t.rig.bytes(t.base, n), 0xff); + try t.launch(t.inner.pipe, t.base); + return t.rig.bytes(t.base, n); + } + pub fn count(t: *RouteOne) usize { + return t.inner.count(); + } + pub fn reference(t: *RouteOne, want: []f64, mag: []f64) !void { + try t.inner.reference(want, mag); + } + pub fn intervals(t: *RouteOne, low: []f64, high: []f64) !void { + try t.inner.intervals(low, high); + } + pub fn bounds(t: *RouteOne, want: []const f64, mag: []const f64, allow: []f64) !void { + try t.inner.bounds(want, mag, allow); + } + pub fn simulate(t: *RouteOne, acc: c.Accum, order: g.Order, out: []f64) !void { + try t.inner.simulate(acc, order, out); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]bool{ false, true }) |igate| for ([_]bool{ false, true }) |control| { + if (s.wanted(only, RouteOne.name(igate, control))) try s.own(RouteOne, try RouteOne.create(s, igate, control)); + }; +} + +/// Gate 5's registrations `glm launch route router|igate `: the loader's router library at that shape. +pub const prefix = "glm launch route "; +pub fn limitsText(a: std.mem.Allocator, _: mtl.Device, label: []const u8) !bits.Texts { + const t = try text(a, if (std.mem.indexOf(u8, label, " igate ") != null) kernels.igate_shape else kernels.route_shape); + return .{ .here = t, .pre_m5 = t }; +} diff --git a/zig/tests/contract/metal_glm_route_select.zig b/zig/tests/contract/metal_glm_route_select.zig new file mode 100644 index 00000000000..9cc361c0275 --- /dev/null +++ b/zig/tests/contract/metal_glm_route_select.zig @@ -0,0 +1,135 @@ +//! The core route select (core/moe_route.metal's tf_route_select) at GLM's and Step-5's shapes against main's kernel. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; +const route = tf.moe_route; + +/// Main's core/moe_route.metal: the select each row's simdgroup ran before the simd picks and prefix offsets. +pub const main_route = @embedFile("baselines/moe_route_main.metal.txt"); +const M = 16; // the shapes' max_rows +const scale: f32 = 2.5; // config.zig's routed_scale (both families) + +/// GLM's router (MLX's options; expert parallel splits the held experts) and Step-5's (precise math, every expert). +pub const Family = enum { glm, step5 }; +fn shapeOf(f: Family) route.Shape { + return if (f == .glm) tf.glm.kernels.route_shape else .{ .hidden = 4096, .experts = 352, .topk = 8 }; +} +fn options(f: Family) mtl.CompileOptions { + return if (f == .glm) mtl.CompileOptions.mlx() else .{ .language = mtl.CompileOptions.mlx().language, .math_functions = .precise }; +} + +/// Rows: the window's rows; n: the experts; k: the held experts (0 all, 1 the lower half, 2 the upper: two Macs). +fn servedOf(comptime f: Family) [if (f == .glm) 8 else 4]c.Shape { + const E = shapeOf(f).experts; + return if (f == .glm) .{ .{ .rows = 16, .n = E, .k = 0 }, .{ .rows = 1, .n = E, .k = 0 }, .{ .rows = 3, .n = E, .k = 0 }, .{ .rows = 8, .n = E, .k = 0 }, .{ .rows = 1, .n = E, .k = 1 }, .{ .rows = 16, .n = E, .k = 1 }, .{ .rows = 2, .n = E, .k = 2 }, .{ .rows = 16, .n = E, .k = 2 } } else .{ .{ .rows = 16, .n = E, .k = 0 }, .{ .rows = 1, .n = E, .k = 0 }, .{ .rows = 5, .n = E, .k = 0 }, .{ .rows = 12, .n = E, .k = 0 } }; +} +const served_glm = servedOf(.glm); +const served_step5 = servedOf(.step5); + +/// The family's router library (core/moe_route.zig's defines) over `body`: today's core or main's frozen one. +pub fn text(a: std.mem.Allocator, f: Family, body: ?[]const u8) ![]u8 { + const t = try route.source(a, shapeOf(f)); + if (body == null) return t; + defer a.free(t); + return std.mem.concat(a, u8, &.{ t[0 .. t.len - sources.core_moe_route.len], body.? }); +} + +pub const Case = struct { + family: Family, + control: bool, + new: mtl.Pipeline, + old: mtl.Pipeline, + + pub fn init(s: *bits.Suite, family: Family, control: bool) !Case { + const own = try text(s.a, family, null); + defer s.a.free(own); + const body = if (control) try bits.edited(s.a, own, "void tf_route_select(", "offs[0][g] = b0 + held;", "offs[0][g] = b0;") else try s.a.dupe(u8, own); + defer s.a.free(body); + const frozen = try text(s.a, family, main_route); + defer s.a.free(frozen); + const new = try compile(s.device, body, family); + errdefer new.deinit(); + return .{ .family = family, .control = control, .new = new, .old = try compile(s.device, frozen, family) }; + } + fn compile(device: mtl.Device, t: []const u8, f: Family) !mtl.Pipeline { + const lib = try mtl.Library.fromSource(device, t, options(f)); + defer lib.deinit(); + return mtl.Pipeline.init(device, lib, route.names[1], false); + } + pub fn deinit(x: *Case) void { + x.new.deinit(); + x.old.deinit(); + } + pub fn name(family: Family, control: bool) []const u8 { + if (control) return if (family == .glm) "control: metal glm launch picks tf_route_select glm 288 experts, a group's held count dropping its last lane" else "control: metal glm launch picks tf_route_select step5 352 experts, a group's held count dropping its last lane"; + return if (family == .glm) "metal glm launch picks tf_route_select glm 288 experts top 8" else "metal glm launch picks tf_route_select step5 352 experts top 8"; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.family, x.control), "main's tf_route_select", "main's picks (ties to the lower id, its NaN rule), weights, held groups and members, pick lists, counts and word", if (x.family == .glm) &served_glm else &served_step5, "the weights' fp32 sum and scale in main's order; the rest compares and counts"); + } + /// The outputs: picks, weights, held ids, members, count, this Mac's and the peer's pick lists, counts, the word. + const sizes = [_]usize{ M * 8 * 4, M * 8 * 4, M * 8 * 4, M * 8 * M * 4, 16, M * 8 * 4, M * 8 * 4, 16, 16 }; + pub fn layout(x: *const Case, s: c.Shape) ?bits.Layout { + if (s.rows == 0 or s.rows > M or s.n != shapeOf(x.family).experts or s.k > 2) return null; + var l: bits.Layout = .{}; + _ = l.add(.input, M * s.n * 4, .f32); + _ = l.add(.input, s.n * 4, .f32); + for (sizes, 0..) |n, i| _ = l.add(.output, n, if (i == 1) .f32 else .int); + return l; + } + /// tf-glm-route-select's draws by row: random, levels (ties), edge values (NaN, -0, +-90, -inf bias), all equal. + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const lg = std.mem.bytesAsSlice(f32, data[0]); + const bs = std.mem.bytesAsSlice(f32, data[1]); + const d = if (f == .nonfinite) 2 else seed % 4; + for (lg, 0..) |*v, i| v.* = switch ((d + i / s.n) % 4) { + 0 => (rnd.float(f32) - 0.5) * 8, + 1 => @round((rnd.float(f32) - 0.5) * 6) / 2, + 2 => if (i % 97 == 0) -0.0 else if (i % 89 == 0) 90 else if (i % 83 == 0) -90 else if (i % 79 == 0) 1e-30 else if (i % 211 == 5) std.math.nan(f32) else (rnd.float(f32) - 0.5) * 4, + else => 0.25, + }; + for (bs, 0..) |*v, i| v.* = switch (d) { + 0 => (rnd.float(f32) - 0.5) * 0.2, + 1, 3 => @as(f32, @floatFromInt(i % 4)) * 0.125, + else => if (i == 7 or i == 200) -std.math.inf(f32) else if (i % 13 == 0) 0.0 else (rnd.float(f32) - 0.5) * 0.1, + }; + } + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const E: u32 = @intCast(s.n); + const own: [2]u32 = switch (s.k) { + 0 => .{ 0, E }, + 1 => .{ 0, E / 2 }, + else => .{ E / 2, E }, + }; + route.select(e, if (new) x.new else x.old, r[0], r[1], scale, @intCast(s.rows), own, route.Outputs(rig_.Ref){ .pick = r[2], .wts = r[3], .ids = r[4], .members = r[5], .count = r[6], .mine = r[7], .theirs = r[8], .counts = r[9], .word = r[10] }); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + if (s.wanted(only, Case.name(.glm, false))) { + const loader = try s.production(); + const own = try text(s.a, .glm, null); + defer s.a.free(own); + var found = false; + for (loader.texts.items) |t| found = found or std.mem.startsWith(u8, t, own); + if (!found) return error.NotTheLoadersLibrary; // GLM's router library is this text with glm_route_one appended + } + for ([_]Family{ .glm, .step5 }) |family| for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(family, control))) try s.add(Case, try Case.init(s, family, control)); + }; +} + +/// Gate 5's registrations `glm launch picks glm|step5 `: that family's router library. +pub const prefix = "glm launch picks "; +pub fn limitsText(a: std.mem.Allocator, _: mtl.Device, label: []const u8) !bits.Texts { + const t = try text(a, if (std.mem.indexOf(u8, label, " step5 ") != null) .step5 else .glm, null); + return .{ .here = t, .pre_m5 = t }; +} diff --git a/zig/tests/contract/metal_glm_select.zig b/zig/tests/contract/metal_glm_select.zig new file mode 100644 index 00000000000..9b3cc48b08e --- /dev/null +++ b/zig/tests/contract/metal_glm_select.zig @@ -0,0 +1,168 @@ +//! GLM's decode select (glm_select.metal's mark and merge) against glm_index_select's key lists, as forward.zig picks. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const contract = @import("contract"); +const bits = @import("metal_glm_bits.zig"); +const rig_ = @import("rig.zig"); +const c = contract.spec; +const g = contract.gates; + +const top = 512; // index_topk 2048 / kpool 4 +const width = 2048 + 4 - 1; // the key list a row: 2,048 tokens and the causal tail +const cap = 3072; // glm_select.metal's CAP and forward.zig's select_cap +const marks = 8192; // forward.zig's select_marks: between the two, glm_index_select alone +const span = 4096; +const SelectArgs = extern struct { p0: u32, top: u32, width: u32, s_stride: u32, i_stride: u32 }; + +pub const Path = enum { direct, marked }; + +/// Rows: the window's rows; n: the blocks kept; k: the window's first position. +fn served(path: Path) []const c.Shape { + return switch (path) { + .direct => &.{ .{ .rows = 16, .n = top, .k = 8180 }, .{ .rows = 1, .n = top, .k = 0 }, .{ .rows = 1, .n = top, .k = 2044 }, .{ .rows = 3, .n = top, .k = 2046 }, .{ .rows = 16, .n = top, .k = 2040 }, .{ .rows = 5, .n = top, .k = 4097 }, .{ .rows = 2, .n = top, .k = 12286 }, .{ .rows = 16, .n = top, .k = 12275 } }, + .marked => &.{ .{ .rows = 16, .n = top, .k = 65530 }, .{ .rows = 1, .n = top, .k = 32772 }, .{ .rows = 16, .n = top, .k = 32761 }, .{ .rows = 4, .n = top, .k = 40000 }, .{ .rows = 3, .n = top, .k = 120000 }, .{ .rows = 16, .n = top, .k = 131000 }, .{ .rows = 2, .n = top, .k = 262140 }, .{ .rows = 16, .n = top, .k = 262137 }, .{ .rows = 4, .n = top, .k = 300000 } }, + }; +} + +fn most(s: c.Shape) usize { + return (s.k + s.rows) / 4; +} + +fn stride(s: c.Shape) usize { + return (s.k + s.rows + 1) / 4 + 3; +} + +fn words(s: c.Shape) u32 { + return tf.glm.state.selectWords(@intCast(s.k + s.rows + 64), 4); +} + +pub const Case = struct { + a: std.mem.Allocator, + path: Path, + control: bool, + mark: mtl.Pipeline, + merge: mtl.Pipeline, + old: mtl.Pipeline, + + /// A control's fault: direct rows read each block's score one block late; marked blocks listed one block late. + const faults = [2][2][]const u8{ .{ "s[t + m * T2]", "s[t + m * T2 + 1]" }, .{ "cblock[at++] = ushort(32 * w + ctz(m))", "cblock[at++] = ushort(32 * w + ctz(m) + 1)" } }; + + pub fn init(s: *bits.Suite, path: Path, control: bool) !Case { + const loader = try s.production(); + const text = try loader.require(sources.glm_select); + const f = faults[@backingInt(path)]; + const own = if (control) try bits.edited(s.a, text, "void glm_select_merge", f[0], f[1]) else try s.a.dupe(u8, text); + defer s.a.free(own); + const mark = try bits.pipeline(s.device, own, "glm_select_mark"); + errdefer mark.deinit(); + const merge = try bits.pipeline(s.device, own, "glm_select_merge"); + errdefer merge.deinit(); + return .{ .a = s.a, .path = path, .control = control, .mark = mark, .merge = merge, .old = try bits.pipeline(s.device, try loader.require(sources.glm_glue), "glm_index_select") }; + } + pub fn deinit(x: *Case) void { + x.mark.deinit(); + x.merge.deinit(); + x.old.deinit(); + } + pub fn name(path: Path, control: bool) []const u8 { + return switch (path) { + .direct => if (control) "control: metal glm launch select merge within 3,072 blocks, each score read a block late" else "metal glm launch select merge within 3,072 blocks", + .marked => if (control) "control: metal glm launch select mark and merge past 8,192 blocks, marks listed a block late" else "metal glm launch select mark and merge past 8,192 blocks", + }; + } + pub fn spec(x: *const Case) c.Spec { + return bits.spec(name(x.path, x.control), "glm_index_select", "glm_index_select's lists: its key order (-0 below +0, NaNs by their bits), ties to the earliest blocks, the causal tail and -1 padding", served(x.path), "a selection compares keys and sums none"); + } + pub fn layout(x: *const Case, s: c.Shape) ?bits.Layout { + const m = most(s); + const ok = switch (x.path) { + .direct => m <= cap, + .marked => m > marks, + }; + if (!ok or s.rows == 0 or s.rows > 16 or s.n != top) return null; + var l: bits.Layout = .{}; + _ = l.add(.input, s.rows * stride(s) * 4, .int); + _ = l.add(.output, s.rows * width * 4, .int); + _ = l.add(.scratch, s.rows * @as(usize, words(s)) * 4, .int); + return l; + } + /// Whether glm_select.metal's floor samples block i of n (256 runs of 8 at even spacing). + fn sampled(i: usize, n: usize) bool { + var q: usize = 0; + while (q < 2048) : (q += 8) { + const at = q / 8 * n / 256 / 8 * 8; + if (i >= at and i < at + 8) return true; + } + return false; + } + /// Each row a pattern of its own (ties, specials, ramps, a hot span, a floor that overshoots); gate 1 specials. + pub fn fill(_: *const Case, s: c.Shape, f: g.Fill, seed: u64, data: [][]u8) !void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + const scores = std.mem.bytesAsSlice(f32, data[0]); + for (scores) |*v| v.* = rnd.float(f32) * 100 - 50; + for (0..s.rows) |row| { + const n = (s.k + row + 1) / 4; + const pattern = if (f == .nonfinite) 2 else (seed + row) % 9; + for (scores[row * stride(s) ..][0..n], 0..) |*v, i| v.* = switch (pattern) { + 0 => rnd.float(f32) * 8 - 2, + 1 => @floatFromInt(rnd.uintLessThan(u32, 6)), + 2 => switch (rnd.uintLessThan(u32, 16)) { + 0 => std.math.nan(f32), + 1 => -std.math.nan(f32), + 2 => 0.0, + 3 => -0.0, + 4 => std.math.inf(f32), + 5 => -std.math.inf(f32), + else => rnd.float(f32) - 0.5, + }, + 3 => @floatFromInt(i / 3), + 4 => @floatFromInt(n - i / 2), + 5 => if (i >= n / 3 and i < n / 3 + 700) 5.0 + rnd.float(f32) else rnd.float(f32), + 6 => 1.5, + 7 => if (sampled(i, n)) 3.0 + rnd.float(f32) else rnd.float(f32), + else => @as(f32, @floatFromInt(rnd.intRangeAtMost(i32, -1000, 1000))) / 64, + }; + } + } + pub fn encode(x: *const Case, e: mtl.ComputeEncoder, r: []const rig_.Ref, s: c.Shape, new: bool) void { + const sel = SelectArgs{ .p0 = @intCast(s.k), .top = top, .width = width, .s_stride = @intCast(stride(s)), .i_stride = width }; + const n: usize = s.rows; + if (!new) { + e.setPipeline(x.old); + e.setBuffer(r[0].buf, r[0].off, 0); + e.setBuffer(r[1].buf, r[1].off, 1); + e.setValue(sel, 2); + return e.dispatchGroups(mtl.Size.of(n, 1, 1), mtl.Size.of(1024, 1, 1)); + } + if (most(s) > cap) { // forward.zig's selectKeys past select_marks: each span's blocks at or above the floor + e.setPipeline(x.mark); + e.setBuffer(r[0].buf, r[0].off, 0); + e.setBuffer(r[2].buf, r[2].off, 1); + e.setValue(sel, 2); + e.setValue(words(s), 3); + e.dispatchGroups(mtl.Size.of((most(s) + span - 1) / span, n, 1), mtl.Size.of(256, 1, 1)); + } + e.setPipeline(x.merge); + e.setBuffer(r[0].buf, r[0].off, 0); + e.setBuffer(r[1].buf, r[1].off, 1); + e.setValue(sel, 2); + e.setValue(words(s), 3); + e.setBuffer(r[2].buf, r[2].off, 4); + e.dispatchGroups(mtl.Size.of(n, 1, 1), mtl.Size.of(512, 1, 1)); + } +}; + +pub fn collect(s: *bits.Suite, only: ?[]const u8) !void { + for ([_]Path{ .direct, .marked }) |path| for ([_]bool{ false, true }) |control| { + if (s.wanted(only, Case.name(path, control))) try s.add(Case, try Case.init(s, path, control)); + }; +} + +/// Gate 5's registrations `glm launch select `: glm_select.metal as the loader compiles it. +pub const prefix = "glm launch select "; +pub fn limitsText(_: std.mem.Allocator, _: mtl.Device, _: []const u8) !bits.Texts { + return .{ .here = sources.glm_select, .pre_m5 = sources.glm_select }; +} diff --git a/zig/tests/contract/metal_idol.zig b/zig/tests/contract/metal_idol.zig new file mode 100644 index 00000000000..50d1284ae4c --- /dev/null +++ b/zig/tests/contract/metal_idol.zig @@ -0,0 +1,190 @@ +//! Idol's Metal kernels under the contract, each at idol-sdk's fp16 points; controls drop or add one rounding point. +const std = @import("std"); +const mtl = @import("metal"); +const rig_ = @import("rig.zig"); +const id = @import("metal_idol_common.zig"); +const gemm = @import("metal_idol_gemm.zig"); +const norms = @import("metal_idol_norms.zig"); +const steps = @import("metal_idol_steps.zig"); +const elems = @import("metal_idol_rows.zig"); +const attn = @import("metal_idol_attention.zig"); + +const g = id.g; +const ks = id.ks; +const Control = id.Control; +const Lib = id.Lib; + +/// The NAX fp32 GEMM (the tensor unit's fp32 path, not fp32-accurate on M5) in id_gemm32's place. +const nax_gemm32 = + \\[[max_total_threads_per_threadgroup(128)]] [[kernel]] void id_gemm32( + \\ const device float* x [[buffer(0)]], const device float* w [[buffer(1)]], device float* y [[buffer(2)]], + \\ constant IdGemm32& p [[buffer(3)]], uint2 tg [[threadgroup_position_in_grid]], + \\ uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + \\ const int row = int(tg.y) * 64 + 32 * int(sg / 2), col = int(tg.x) * 64 + 32 * int(sg % 2); + \\ const int rows = min(32, int(p.M) - row), cols = min(32, int(p.N) - col); + \\ const short2 home = tfp::frag_home(ushort(lane)); + \\ tfp::frag acc[2][2]; + \\ tfp::gemm_block(acc, x + long(row) * p.K, w + long(col) * p.K, int(p.K), int(p.K), + \\ int(p.K), int(p.K) / 32, rows, cols, home); + \\ if (rows > 0 && cols > 0) tfp::gemm_store(acc, y + long(row) * p.ldy + col, int(p.ldy), rows, cols, home); + \\} +; + +const mma_line = "for (uint j = 0; j < 4; j++) simdgroup_multiply_accumulate(acc[i][j], a[i], b[j], acc[i][j]);"; +const mma_half = "for (uint j = 0; j < 4; j++) { simdgroup_multiply_accumulate(acc[i][j], a[i], b[j], acc[i][j]); " ++ + "acc[i][j].thread_elements()[0] = id_h(acc[i][j].thread_elements()[0]); " ++ + "acc[i][j].thread_elements()[1] = id_h(acc[i][j].thread_elements()[1]); }"; + +const controls = [_]Control{ + .{ .kernel = "id_linear_gelu_01", .what = "drops fp16(x w + b) before the GELU", .edits = &.{.{ .from = "const float v = id_h(acc[i][j][e] + b);", .to = "const float v = (acc[i][j][e] + b);" }} }, + .{ .kernel = "id_linear_01", .what = "adds fp16(x w) before the bias", .edits = &.{.{ .from = "const float v = id_h(acc[i][j][e] + b);", .to = "const float v = id_h(id_h(acc[i][j][e]) + b);" }} }, + .{ .kernel = "id_norm modulated", .what = "drops fp16(y s1)", .edits = &.{.{ .from = "v = id_h(id_h(v * float(s1[i])) + float(sh[i]));", .to = "v = id_h((v * float(s1[i])) + float(sh[i]));" }} }, + .{ .kernel = "id_norm affine", .what = "adds fp16(y) before the affine", .edits = &.{.{ .from = "if (p.mode == 1) v = v * w[i] + b[i];", .to = "if (p.mode == 1) v = id_h(v) * w[i] + b[i];" }} }, + .{ .kernel = "id_norm32 modulated", .what = "adds fp16(y) before the modulation", .edits = &.{.{ .from = "yr[i] = p.mode == 2 ? v * (1.0f + w[i])", .to = "yr[i] = p.mode == 2 ? id_h(v) * (1.0f + w[i])" }} }, + .{ .kernel = "id_norm32 modulated", .what = "sums the simdgroups in fp16", .gate = .sums, .edits = &.{.{ .from = " v = simd_sum(v);\n if (lane == 0) part[sg] = v;", .to = " v = float(simd_sum(half(v)));\n if (lane == 0) part[sg] = v;" }} }, + .{ .kernel = "id_norm_split", .what = "rounds the row to fp16 before its split", .edits = &.{.{ .from = "const float v = (float(xr[i]) - mean) * inv * w[i] + b[i];", .to = "const float v = id_h((float(xr[i]) - mean) * inv * w[i] + b[i]);" }} }, + .{ .kernel = "id_repo", .what = "adds fp16(u)", .edits = &.{.{ .from = "u[i] = (a / (1.0f + metal::precise::exp(-a))) * (g[128 + i] * p.inv);", .to = "u[i] = id_h((a / (1.0f + metal::precise::exp(-a))) * (g[128 + i] * p.inv));" }} }, + .{ .kernel = "id_repo", .what = "sums d in fp16", .gate = .sums, .edits = &.{.{ .from = "s = fma(u[k], wf[t * 128 + k], s);", .to = "s = id_h(fma(u[k], wf[t * 128 + k], s));" }} }, + .{ .kernel = "id_qk", .what = "drops fp16(q0 c - q1 s)", .edits = &.{.{ .from = "const float rq0 = id_h(q0 * c - q1 * s), rq1", .to = "const float rq0 = (q0 * c - q1 * s), rq1" }} }, + .{ .kernel = "id_qk", .what = "sums q's squares in fp16", .gate = .sums, .edits = &.{.{ .from = "simd_sum(rq0 * rq0 + rq1 * rq1)", .to = "float(simd_sum(half(rq0 * rq0 + rq1 * rq1)))" }} }, + .{ .kernel = "id_gate_add", .what = "drops fp16(g y)", .edits = &.{.{ .from = "half(float(x[i]) + id_h(float(g[at.x]) * float(y[i])));", .to = "half(float(x[i]) + (float(g[at.x]) * float(y[i])));" }} }, + .{ .kernel = "id_embed", .what = "drops fp16(z w + b)", .edits = &.{.{ .from = "x[i] = half(float(half(s + b[c])) + float(pe[i]));", .to = "x[i] = half((s + b[c]) + float(pe[i]));" }} }, + .{ .kernel = "id_embed", .what = "sums z w in fp16", .gate = .sums, .edits = &.{.{ .from = "s = fma(z[r * 16 + k], w[c * 16 + k], s);", .to = "s = id_h(fma(z[r * 16 + k], w[c * 16 + k], s));" }} }, + .{ .kernel = "id_cond", .what = "adds fp16(a + ba)", .edits = &.{.{ .from = "y[i] = half((a[i] + ba[at.x]) + (c[i] + bc[at.x]));", .to = "y[i] = half(id_h(a[i] + ba[at.x]) + (c[i] + bc[at.x]));" }} }, + .{ .kernel = "id_bias32", .what = "adds fp16(b)", .edits = &.{.{ .from = "y[ulong(at.y) * width + at.x] += b[at.x];", .to = "y[ulong(at.y) * width + at.x] += id_h(b[at.x]);" }} }, + .{ .kernel = "id_gemm32", .what = "sums in fp16", .gate = .sums, .edits = &.{.{ .from = mma_line, .to = mma_half }} }, + .{ .kernel = "id_gemm32", .what = "takes the NAX fp32 path", .gate = .sums, .edits = &.{.{ .from = "void id_gemm32(", .to = "void id_gemm32_simd(" }}, .append = nax_gemm32 }, + .{ .kernel = "id_attention_00", .what = "keys past Lk unmasked", .edits = &.{.{ .from = "s[f][e] = (16 * f + home.x + TF_COL(e)) < k_rows ? s[f][e] : kIdMasked;", .to = "s[f][e] = s[f][e];" }} }, +}; + +/// A test the suite made, and how it goes. +const Made = struct { ptr: *anyopaque, free: *const fn (std.mem.Allocator, *anyopaque) void }; + +pub const Suite = struct { + a: std.mem.Allocator, + libs: std.ArrayList(*Lib) = .empty, + names: std.ArrayList([]u8) = .empty, + made: std.ArrayList(Made) = .empty, + + fn label(s: *Suite, comptime fmt: []const u8, args: anytype) ![]const u8 { + const name = try std.fmt.allocPrint(s.a, fmt, args); + errdefer s.a.free(name); + try s.names.append(s.a, name); + return name; + } + + fn make(s: *Suite, comptime T: type, value: T) !*T { + const t = try s.a.create(T); + errdefer s.a.destroy(t); + t.* = value; + const f = struct { + fn free(a: std.mem.Allocator, p: *anyopaque) void { + const x: *T = @ptrCast(@alignCast(p)); + x.deinit(); + a.destroy(x); + } + }; + try s.made.append(s.a, .{ .ptr = t, .free = f.free }); + return t; + } + + /// Each kernel (or, with `ctl`, the one it breaks) on `lib`'s pipelines. + fn add(s: *Suite, device: mtl.Device, queue: mtl.Queue, lib: *Lib, ctl: ?Control, out: *std.ArrayList(g.Kernel), only: ?[]const u8) !void { + const suffix = if (ctl) |x| try s.label(" control: {s}", .{x.what}) else ""; + const gate: ?g.Gate = if (ctl) |x| x.gate else null; + const rig: rig_.Rig = .{ .a = s.a, .device = device, .queue = queue }; + const ends: id.Ends = .{ .a = s.a }; + const W = struct { + s: *Suite, + ctl: ?Control, + suffix: []const u8, + only: ?[]const u8, + /// The test's name when this pass registers `kernel`, else null. + fn name(w: @This(), kernel: []const u8) !?[]const u8 { + if (w.ctl) |x| if (!std.mem.eql(u8, x.kernel, kernel)) return null; + const full = try w.s.label("metal idol {s}{s}", .{ kernel, w.suffix }); + if (w.only) |needle| if (std.mem.indexOf(u8, full, needle) == null) return null; + return full; + } + }; + const w = W{ .s = s, .ctl = ctl, .suffix = suffix, .only = only }; + for ([_]gemm.Kind{ .linear, .gelu, .split }) |kind| for (0..4) |f| { + const form: u2 = @intCast(f); + if (kind == .split and form & 1 == 0) continue; + const fun = gemm.pipeline(kind, form); + const name = (try w.name(fun)) orelse continue; + const t = try s.make(gemm.Gemm16, .{ .a = s.a, .rig = rig, .lib = lib, .kind = kind, .form = form, .name = name, .ends = ends }); + try out.append(s.a, t.kernel(gate)); + }; + if (try w.name("id_gemm32")) |name| { + const t = try s.make(gemm.Gemm32, .{ .a = s.a, .rig = rig, .lib = lib, .name = name }); + try out.append(s.a, t.kernel(gate)); + } + const norm_kinds = [_]struct { kind: norms.Kind, mode: ks.Norm, fun: []const u8 }{ + .{ .kind = .norm, .mode = .plain, .fun = "id_norm plain" }, + .{ .kind = .norm, .mode = .affine, .fun = "id_norm affine" }, + .{ .kind = .norm, .mode = .modulated, .fun = "id_norm modulated" }, + .{ .kind = .norm32, .mode = .affine, .fun = "id_norm32 affine" }, + .{ .kind = .norm32, .mode = .modulated, .fun = "id_norm32 modulated" }, + .{ .kind = .split, .mode = .affine, .fun = "id_norm_split" }, + }; + for (norm_kinds) |nk| { + const name = (try w.name(nk.fun)) orelse continue; + const t = try s.make(norms.Norm, .{ .a = s.a, .rig = rig, .lib = lib, .kind = nk.kind, .mode = nk.mode, .name = name, .ends = ends }); + try out.append(s.a, t.kernel(gate)); + } + if (try w.name("id_repo")) |name| { + const t = try s.make(steps.Repo, .{ .a = s.a, .rig = rig, .lib = lib, .name = name, .ends = ends }); + try out.append(s.a, t.kernel(gate)); + } + if (try w.name("id_qk")) |name| { + const t = try s.make(steps.Qk, .{ .a = s.a, .rig = rig, .lib = lib, .name = name, .ends = ends }); + try out.append(s.a, t.kernel(gate)); + } + inline for (.{ .{ elems.GateAdd, "id_gate_add" }, .{ elems.Embed, "id_embed" }, .{ elems.Cond, "id_cond" }, .{ elems.Bias32, "id_bias32" } }) |e| { + if (try w.name(e[1])) |name| { + const t = try s.make(e[0], .{ .a = s.a, .rig = rig, .lib = lib, .name = name, .ends = ends }); + try out.append(s.a, t.kernel(gate)); + } + } + for (attn.forms, 0..) |f, i| { + const name = (try w.name(f.name)) orelse continue; + const t = try s.make(attn.Attention, .{ .a = s.a, .rig = rig, .lib = lib, .form = i, .name = name }); + try out.append(s.a, t.kernel(gate)); + } + } + + pub fn create(a: std.mem.Allocator, device: mtl.Device, queue: mtl.Queue, out: *std.ArrayList(g.Kernel), only: ?[]const u8) !*Suite { + const s = try a.create(Suite); + s.* = .{ .a = a }; + errdefer s.destroy(); + if (!device.tensorUnits()) { + std.debug.print("UNSUPPORTED metal idol: the family runs on tensor units (M5) alone; its kernels unchecked here\n", .{}); + return s; + } + for ([_]?Control{null} ++ controls) |x| { + const lib = try a.create(Lib); + lib.* = .{ .a = a, .device = device, .ctl = x }; + s.libs.append(a, lib) catch |err| { + a.destroy(lib); + return err; + }; + try s.add(device, queue, lib, x, out, only); + } + return s; + } + + pub fn destroy(s: *Suite) void { + const a = s.a; + for (s.made.items) |m| m.free(a, m.ptr); + s.made.deinit(a); + for (s.libs.items) |l| { + l.deinit(); + a.destroy(l); + } + s.libs.deinit(a); + for (s.names.items) |n| a.free(n); + s.names.deinit(a); + a.destroy(s); + } +}; diff --git a/zig/tests/contract/metal_idol_attention.zig b/zig/tests/contract/metal_idol_attention.zig new file mode 100644 index 00000000000..fc75fac7471 --- /dev/null +++ b/zig/tests/contract/metal_idol_attention.zig @@ -0,0 +1,233 @@ +//! id_attention under the contract: softmax(q k^T / 8) v at head width 64, against attention_ref's float64 formula. +const std = @import("std"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const id = @import("metal_idol_common.zig"); + +const c = id.c; +const g = id.g; +const D = id.D; +const kref = id.kref; + +const heads = id.cfg.heads; + +/// Query rows repeat at this period (prime to the 64-row blocks): float64 costs 89 queries a head over every key. +const query_period = 89; + +/// Each form's name, served lengths and edges by (Lq % 64 == 0)(Lk % 32 == 0); Lq is n, Lk is k. +pub const forms = [4]struct { name: []const u8, served: []const c.Shape, tiles: [3]c.Tile }{ + .{ + .name = "id_attention_00", + .served = &.{ .{ .rows = heads, .n = 12294, .k = 12294 }, .{ .rows = heads, .n = 4101, .k = 4101 } }, + .tiles = .{ .{}, .{ .size = 64 }, .{ .size = 32 } }, + }, + // no served call has Lq != Lk: the cross-length forms are checked at their tails + .{ + .name = "id_attention_01", + .served = &.{ .{ .rows = heads, .n = 4101, .k = 4128 }, .{ .rows = heads, .n = 100, .k = 64 } }, + .tiles = .{ .{}, .{ .size = 64 }, .{ .size = 64, .step = 32, .min = 32 } }, + }, + .{ + .name = "id_attention_10", + .served = &.{ .{ .rows = heads, .n = 4096, .k = 4101 }, .{ .rows = heads, .n = 128, .k = 70 } }, + .tiles = .{ .{}, .{ .size = 128, .step = 64, .min = 64 }, .{ .size = 32 } }, + }, + .{ + .name = "id_attention_11", + .served = &.{.{ .rows = heads, .n = 8192, .k = 8192 }}, + .tiles = .{ .{}, .{ .size = 128, .step = 64, .min = 64 }, .{ .size = 64, .step = 32, .min = 32 } }, + }, +}; + +pub fn form(lq: usize, lk: usize) usize { + return @as(usize, @intFromBool(lq % 64 == 0)) * 2 + @intFromBool(lk % 32 == 0); +} + +/// The scores' 64-deep sums, then the keys' sums. +fn attentionDepth(s: c.Shape) usize { + return D + s.k; +} + +pub const Attention = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + form: usize, + name: []const u8, + lq: usize = 0, + lk: usize = 0, + stress: bool = false, + q: []f16 = &.{}, + k: []f16 = &.{}, + v: []f16 = &.{}, + ins: [3]rig_.Ref = undefined, + out: rig_.Ref = undefined, + + /// Rows: the launch's 16 heads (fixed; a gate's fewer rows run all 16); n: query rows Lq; k: key rows Lk. + pub fn spec(name: []const u8, f: usize) c.Spec { + return .{ .name = name, .accum = .f32, .depth = attentionDepth, .ops = 8, .out = .f16, .tiles = forms[f].tiles, .served = forms[f].served }; + } + + pub fn deinit(t: *Attention) void { + t.free(); + t.rig.deinit(); + } + fn free(t: *Attention) void { + t.a.free(t.q); + t.a.free(t.k); + t.a.free(t.v); + t.q = &.{}; + t.k = &.{}; + t.v = &.{}; + } + pub fn kernel(t: *Attention, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name, t.form), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Attention); + + pub fn prepare(t: *Attention, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.n == 0 or shape.k == 0 or form(shape.n, shape.k) != t.form) return false; + t.rig.reset(); + t.free(); + t.lq = shape.n; + t.lk = shape.k; + t.stress = fill == .stress; + const L = t.lk; + t.q = try t.a.alloc(f16, heads * t.lq * D); + t.k = try t.a.alloc(f16, heads * L * D); + t.v = try t.a.alloc(f16, heads * L * D); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + if (t.stress) { + // equal scores (q = k = 0), each column's values integers whose partial sums reach ~2^23 and cancel to 4 + @memset(t.q, 0); + @memset(t.k, 0); + const half = L / 2; + for (0..heads) |h| for (0..L) |j| { + const at = if (j < half) j else j - half; + const positive: f32 = if (at % 2 == 0) 127 else 4064; + const residual: f32 = if (at < 8 and at % 2 == 0) 1 else 0; + const v: f32 = if (j < half) positive else if (j < 2 * half) residual - positive else 0; + @memset(t.v[(h * L + j) * D ..][0..D], @floatCast(v)); + }; + } else { + id.randomF16(rng, t.q, -2, 2); + id.randomF16(rng, t.k, -2, 2); + id.randomF16(rng, t.v, -1, 1); + } + if (fill == .nonfinite) { + // head 0: values NaN, +Inf, -Inf, and both infinities in one column; head 1: a NaN query, an infinite key + for ([_][2]usize{ .{ 0, 0 }, .{ 1, 1 }, .{ 2, 2 }, .{ 3, 3 }, .{ 4, 3 } }, [_]f16{ id.nan16, id.inf16, -id.inf16, id.inf16, -id.inf16 }) |p, v| if (p[0] < L) { + t.v[p[0] * D + p[1]] = v; + }; + t.q[(t.lq + 0) * D + 5] = id.nan16; + if (L > 7) t.k[(L + 7) * D + 3] = id.inf16; + } + // every head's queries repeat at the period, so float64 computes each distinct one once + const p = @min(t.lq, query_period); + for (0..heads) |h| for (p..t.lq) |i| { + @memcpy(t.q[(h * t.lq + i) * D ..][0..D], t.q[(h * t.lq + i % p) * D ..][0..D]); + }; + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.q)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(t.k)); + t.ins[2] = try t.rig.input(std.mem.sliceAsBytes(t.v)); + t.out = try t.rig.output(heads * t.lq * D * 2); + return true; + } + + pub fn run(t: *Attention) !void { + try t.lib.need(forms[t.form].name); + const p = t.rig.begin(); + t.lib.k.attention(p.e, kref(t.ins[0]), kref(t.ins[1]), kref(t.ins[2]), kref(t.out), t.lq, t.lk); + try t.rig.finish(p); + } + + pub fn count(t: *Attention) usize { + return heads * t.lq * D; + } + + /// attention_ref.head's formula, one pass over the keys a distinct query; O rows [Lq, heads * 64]. + pub fn reference(t: *Attention, want: []f64, mag: []f64) !void { + const L = t.lk; + const scale: f64 = @as(f32, 1.0 / @sqrt(@as(f32, D))); + const kf = try t.a.alloc(f64, L * D); + defer t.a.free(kf); + const vf = try t.a.alloc(f64, L * D); + defer t.a.free(vf); + const s = try t.a.alloc(f64, L); + defer t.a.free(s); + var qf: [D]f64 = undefined; + var out: [D]f64 = undefined; + var tol: [D]f64 = undefined; + const p = @min(t.lq, query_period); + for (0..heads) |h| { + for (kf, vf, t.k[h * L * D ..][0 .. L * D], t.v[h * L * D ..][0 .. L * D]) |*kd, *vd, kb, vb| { + kd.* = kb; + vd.* = vb; + } + for (0..p) |i| { + var zero = true; + for (&qf, t.q[(h * t.lq + i) * D ..][0..D]) |*x, b| { + x.* = b; + zero = zero and x.* == 0; + } + var m: f64 = -std.math.inf(f64); + var nan = false; + for (s, 0..) |*sj, j| { + var dot: f64 = 0; + if (!zero) { + const Vec = @Vector(8, f64); + var acc: Vec = @splat(0); + var e: usize = 0; + while (e < D) : (e += 8) acc += @as(Vec, qf[e..][0..8].*) * @as(Vec, kf[j * D + e ..][0..8].*); + dot = @reduce(.Add, acc); + } + sj.* = dot * scale; + nan = nan or std.math.isNan(sj.*); + m = @max(m, sj.*); + } + if (nan) m = std.math.nan(f64); + var l: f64 = 0; + @memset(&out, 0); + @memset(&tol, 0); + for (s, 0..) |sj, j| { + const pj = @exp(sj - m); + l += pj; + for (&out, &tol, vf[j * D ..][0..D]) |*o, *tl, vv| { + o.* += pj * vv; + tl.* += pj * @abs(vv); + } + } + var r = i; + while (r < t.lq) : (r += p) { + const at = (r * heads + h) * D; + for (out, tol, 0..) |o, tl, e| { + want[at + e] = o / l; + // P enters P x V at the tensor unit's fp32 (~2^-10 relative); O rounds to fp16 + mag[at + e] = tl / l * 0x1p-9 + @abs(o / l) * 0x1p-10 + 1e-6; + } + } + } + } + } + + pub fn bounds(t: *Attention, want: []const f64, tolerance: []const f64, allow: []f64) !void { + for (want, tolerance, allow) |w, tl, *l| l.* = if (t.stress) c.boundExact(spec(t.name, t.form), w) else if (std.math.isFinite(w)) tl else 0; + } + + pub fn simulate(t: *Attention, acc: c.Accum, order: g.Order, out: []f64) !void { + if (!t.stress) return error.AttentionStressNeedsEqualScores; + const L = t.lk; + const terms = try t.a.alloc(f64, L); + defer t.a.free(terms); + const ones = try t.a.alloc(f64, L); + defer t.a.free(ones); + @memset(ones, 1); + const l = contract.rows.sumIn(acc, order, ones); + for (0..heads) |h| for (0..D) |e| { + for (terms, 0..) |*v, j| v.* = t.v[(h * L + j) * D + e]; + const o = contract.rows.sumIn(acc, order, terms) / l; + for (0..t.lq) |i| out[(i * heads + h) * D + e] = o; + }; + } +}; diff --git a/zig/tests/contract/metal_idol_common.zig b/zig/tests/contract/metal_idol_common.zig new file mode 100644 index 00000000000..222b6b22b48 --- /dev/null +++ b/zig/tests/contract/metal_idol_common.zig @@ -0,0 +1,245 @@ +//! Idol's kernel tests' shared parts: float64 values at fp16 points, their ranges, inputs and the family's library. +const std = @import("std"); +const mtl = @import("metal"); +pub const tf = @import("tensorfold"); +const contract = @import("contract"); +const sources = @import("kernel_sources"); +const rig_ = @import("rig.zig"); + +pub const c = contract.spec; +pub const g = contract.gates; +pub const rows = contract.rows; +pub const ks = tf.idol.kernels; +pub const cfg = tf.idol.config; +pub const H = cfg.hidden; +pub const D = cfg.head_dim; + +pub fn noSums(_: c.Shape) usize { + return 0; +} + +/// A value rounded once to fp16 (the kernels' half(fp32) of a value float64 holds exactly, or float64's own). +pub fn hf(v: f64) f64 { + return @as(f16, @floatCast(v)); +} + +pub fn kref(r: rig_.Ref) ks.Ref { + return .{ .buf = r.buf, .off = r.off }; +} + +/// Every value the kernel may hold at a step: its fp32 steps widen both ends, its fp16 points round them. +pub const Range = struct { + lo: f64, + hi: f64, + pub fn of(v: f64) Range { + return .{ .lo = v, .hi = v }; + } + /// An fp32 step good to `ulps` units in the last place (a correctly rounded one: 0.5). + pub fn fp32(a: Range, ulps: f64) Range { + const u = ulps * 0x1p-23; + return .{ .lo = a.lo - u * @abs(a.lo) - 0x1p-149, .hi = a.hi + u * @abs(a.hi) + 0x1p-149 }; + } + pub fn fp16(a: Range) Range { + return .{ .lo = hf(a.lo), .hi = hf(a.hi) }; + } + pub fn add(a: Range, b: Range) Range { + return .{ .lo = a.lo + b.lo, .hi = a.hi + b.hi }; + } + pub fn neg(a: Range) Range { + return .{ .lo = -a.hi, .hi = -a.lo }; + } + pub fn sub(a: Range, b: Range) Range { + return a.add(b.neg()); + } + pub fn widen(a: Range, e: f64) Range { + return .{ .lo = a.lo - e, .hi = a.hi + e }; + } + pub fn mul(a: Range, b: Range) Range { + const p = [4]f64{ a.lo * b.lo, a.lo * b.hi, a.hi * b.lo, a.hi * b.hi }; + return .{ .lo = @min(@min(p[0], p[1]), @min(p[2], p[3])), .hi = @max(@max(p[0], p[1]), @max(p[2], p[3])) }; + } + /// An increasing function at both ends. + pub fn up(a: Range, comptime f: fn (f64) f64) Range { + return .{ .lo = f(a.lo), .hi = f(a.hi) }; + } + /// 1 / sqrt(a), a positive. + pub fn rsqrt(a: Range) Range { + return .{ .lo = 1 / @sqrt(a.hi), .hi = 1 / @sqrt(a.lo) }; + } + /// 1 / a, a positive. + pub fn recip(a: Range) Range { + return .{ .lo = 1 / a.hi, .hi = 1 / a.lo }; + } + /// a^2 over the range. + pub fn square(a: Range) Range { + const m = @max(a.lo * a.lo, a.hi * a.hi); + return .{ .lo = if (a.lo <= 0 and a.hi >= 0) 0 else @min(a.lo * a.lo, a.hi * a.hi), .hi = m }; + } +}; + +pub fn tanh(x: f64) f64 { + return std.math.tanh(x); +} + +pub fn sqrt(x: f64) f64 { + return @sqrt(x); +} + +// Metal's error bounds with the engine's options (fast math on, the kernels' own `precise::` calls). +pub const div_ulps = 2.5; +pub const rsqrt_ulps = 2; +pub const sqrt_ulps = 3; +pub const exp_ulps = 4; +pub const tanh_ulps = 5; +pub const trig_ulps = 4; + +/// f over [lo, hi] (cos or sin): its ends, and 1 or -1 where an extreme (a multiple of pi past `at`) falls inside. +fn trigOver(lo: f64, hi: f64, comptime f: fn (f64) f64, at: f64) Range { + const pi = std.math.pi; + if (!(hi - lo < 2 * pi)) return .{ .lo = -1, .hi = 1 }; + var out = Range{ .lo = @min(f(lo), f(hi)), .hi = @max(f(lo), f(hi)) }; + var k = @ceil((lo - at) / pi); + while (k * pi + at <= hi) : (k += 1) { + if (@mod(k, 2) == 0) out.hi = 1 else out.lo = -1; + } + return out; +} + +fn cos(x: f64) f64 { + return @cos(x); +} + +fn sin(x: f64) f64 { + return @sin(x); +} + +pub fn cosOver(lo: f64, hi: f64) Range { + return trigOver(lo, hi, cos, 0); +} + +pub fn sinOver(lo: f64, hi: f64) Range { + return trigOver(lo, hi, sin, std.math.pi / 2.0); +} + +/// Each output's float64 value at the kernel's rounding points, and its range, kept for the bounds and intervals. +pub const Ends = struct { + a: std.mem.Allocator, + lo: []f64 = &.{}, + hi: []f64 = &.{}, + + pub fn deinit(e: *Ends) void { + e.a.free(e.lo); + e.a.free(e.hi); + e.lo = &.{}; + e.hi = &.{}; + } + + pub fn size(e: *Ends, n: usize) !void { + e.deinit(); + e.lo = try e.a.alloc(f64, n); + e.hi = try e.a.alloc(f64, n); + } + + pub fn put(e: *Ends, want: []f64, mag: []f64, i: usize, w: f64, r: Range) void { + want[i] = w; + mag[i] = if (std.math.isFinite(w)) @abs(w) else 0; + e.lo[i] = r.lo; + e.hi[i] = r.hi; + } + + /// The allowance about the float64 value: its range's farther end (a non-finite value is checked by class). + pub fn bounds(e: *const Ends, want: []const f64, allow: []f64) void { + for (allow, want, e.lo, e.hi) |*l, w, lo, hi| l.* = if (std.math.isFinite(w)) @max(@abs(w - lo), @abs(hi - w)) else 0; + } + + pub fn intervals(e: *const Ends, low: []f64, high: []f64) void { + @memcpy(low, e.lo); + @memcpy(high, e.hi); + } +}; + +pub fn randomF16(rng: std.Random, out: []f16, lo: f32, hi: f32) void { + for (out) |*v| v.* = @floatCast(lo + rng.float(f32) * (hi - lo)); +} + +pub fn randomF32(rng: std.Random, out: []f32, lo: f32, hi: f32) void { + for (out) |*v| v.* = lo + rng.float(f32) * (hi - lo); +} + +/// An integer in [lo, hi]. +pub fn int(rng: std.Random, lo: i32, hi: i32) f32 { + return @floatFromInt(lo + @as(i32, @intCast(rng.uintLessThan(u32, @intCast(hi - lo + 1))))); +} + +/// +1 or -1. +pub fn sign(rng: std.Random) f32 { + return if (rng.boolean()) 1 else -1; +} + +pub const nan16: f16 = std.math.nan(f16); +pub const inf16: f16 = std.math.inf(f16); +pub const nan32: f32 = std.math.nan(f32); +pub const inf32: f32 = std.math.inf(f32); + +/// [count, width] rows of which row r is `distinct`'s row r % (its rows): a period prime to every tile. +pub fn periodic(comptime T: type, a: std.mem.Allocator, distinct: []const T, width: usize, count: usize) ![]T { + const p = distinct.len / width; + const out = try a.alloc(T, count * width); + for (0..count) |r| @memcpy(out[r * width ..][0..width], distinct[(r % p) * width ..][0..width]); + return out; +} + +/// One text change a control makes to the family's source. +pub const Edit = struct { from: []const u8, to: []const u8 }; + +/// A control: the kernel it breaks, the gate that must go red, its source edits and any text it appends. +pub const Control = struct { kernel: []const u8, what: []const u8, gate: g.Gate = .shapes, edits: []const Edit = &.{}, append: []const u8 = "" }; + +/// The family's source as the engine compiles it (or a control's copy), its pipelines made as tests ask for them. +pub const Lib = struct { + a: std.mem.Allocator, + device: mtl.Device, + ctl: ?Control, + k: ks.Kernels = undefined, + built: bool = false, + made: [ks.names.len]bool = @splat(false), + + fn text(l: *Lib) ![]u8 { + var out = try tf.frags.source(l.device, l.a, sources.idol); + const x = l.ctl orelse return out; + for (x.edits) |e| { + errdefer l.a.free(out); + if (std.mem.count(u8, out, e.from) != 1) { + std.debug.print("control {s}: text not found once: {s}\n", .{ x.what, e.from }); + return error.ControlTextNotFoundOnce; + } + const next = try std.mem.replaceOwned(u8, l.a, out, e.from, e.to); + l.a.free(out); + out = next; + } + if (x.append.len == 0) return out; + defer l.a.free(out); + return std.mem.concat(l.a, u8, &.{ out, "\n", x.append }); + } + + /// The pipeline `name` made on this library (compiled on first use). + pub fn need(l: *Lib, name: []const u8) !void { + if (!l.built) { + const src = try l.text(); + defer l.a.free(src); + l.k.own = try mtl.Library.fromSource(l.device, src, mtl.CompileOptions.mlx()); + l.built = true; + } + for (ks.names, 0..) |n, i| if (std.mem.eql(u8, n, name)) { + if (!l.made[i]) l.k.p[i] = try mtl.Pipeline.init(l.device, l.k.own, n, false); + l.made[i] = true; + return; + }; + return error.NoSuchPipeline; + } + + pub fn deinit(l: *Lib) void { + for (l.k.p, l.made) |p, m| if (m) p.deinit(); + if (l.built) l.k.own.deinit(); + } +}; diff --git a/zig/tests/contract/metal_idol_gemm.zig b/zig/tests/contract/metal_idol_gemm.zig new file mode 100644 index 00000000000..7cb64720f49 --- /dev/null +++ b/zig/tests/contract/metal_idol_gemm.zig @@ -0,0 +1,430 @@ +//! id_linear (plain and GELU), id_split and id_gemm32 under the contract: products against float64, sums proven fp32. +const std = @import("std"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const id = @import("metal_idol_common.zig"); + +const c = id.c; +const g = id.g; +const H = id.H; +const Range = id.Range; +const Ends = id.Ends; +const hf = id.hf; +const kref = id.kref; + +/// Rows of x and of w (with the bias) repeat at these periods, prime to every tile: 97 x 131 dots a shape. +const row_period = 97; +const col_period = 131; + +pub const Kind = enum { linear, gelu, split }; + +/// An output's float64 value and its range. +const Out = struct { w: f64, r: Range }; + +/// The M5 tensor unit's fp32 sums: 36 roundings of 2^-24 of |acc| + sum |a b| a 16-deep step (attention_range's). +fn naxDepth(s: c.Shape) usize { + return s.k / 16 * contract.attention_range.mma_step + 8; +} + +/// float64's dot of an fp16 row pair and the tensor unit's allowance on its fp32 sums, step by 16-deep step. +fn naxDot(x: []const f16, w: []const f16) [3]f64 { + var s: f64 = 0; + var spread: f64 = 0; + var mag: f64 = 0; + var i: usize = 0; + while (i < x.len) : (i += 16) { + var t: f64 = 0; + var abs: f64 = 0; + for (x[i..@min(i + 16, x.len)], w[i..@min(i + 16, x.len)]) |a, b| { + const p = @as(f64, a) * @as(f64, b); + t += p; + abs += @abs(p); + } + spread += @abs(s) + abs; + s += t; + mag += abs; + } + return .{ s, spread * contract.attention_range.mma_step * 0x1p-24, mag }; +} + +const gelu_c: f64 = @as(f32, 0.7978845608028654); +const gelu_k: f64 = @as(f32, 0.044715); + +fn inner(x: f64) f64 { + return gelu_c * (x + gelu_k * x * x * x); +} + +/// torch's tanh GELU in float64 at the kernel's fp32 constants. +fn gelu(x: f64) f64 { + return 0.5 * x * (1 + std.math.tanh(inner(x))); +} + +/// The GELU's fp32 steps over a range of fp16 inputs: its inner polynomial rises, tanh rises, the rest as products. +fn geluRange(v: Range) Range { + const t = (Range{ .lo = inner(v.lo), .hi = inner(v.hi) }).fp32(3).up(id.tanh).fp32(id.tanh_ulps); + return (Range{ .lo = 0.5 * v.lo, .hi = 0.5 * v.hi }).mul(t.add(Range.of(1)).fp32(0.5)).fp32(0.5); +} + +const Served = struct { served: []const c.Shape, tiles: [3]c.Tile }; + +/// Forms by (M % 64 == 0)(N % 128 == 0); rows: 64-row tiles in whole-row forms, a last tile's rows first in the rest. +fn envelope(kind: Kind, form: u2) Served { + const row_tail: c.Tile = .{ .size = 64 }; + const row_whole: c.Tile = .{ .size = 2, .step = 1, .min = 1 }; + const col_tail: c.Tile = .{ .size = 128 }; + const col_whole: c.Tile = .{ .size = 256, .step = 128, .min = 128 }; + const k_tile: c.Tile = .{ .size = 256, .step = 32, .min = 32 }; + const rt = if (form & 2 != 0) row_whole else row_tail; + if (kind == .split) return .{ + .served = if (form & 2 != 0) &.{.{ .rows = 8192 / 64, .n = 256, .k = 3 * H }} else &.{ .{ .rows = 6, .n = 256, .k = 3 * H }, .{ .rows = 12294, .n = 256, .k = 3 * H }, .{ .rows = 4101, .n = 256, .k = 3 * H } }, + .tiles = .{ rt, .{}, .{} }, + }; + const ct = if (form & 1 != 0) col_whole else col_tail; + const tiles: [3]c.Tile = .{ rt, ct, k_tile }; + if (kind == .gelu) return .{ + .tiles = tiles, + .served = switch (form) { + 3 => &.{.{ .rows = 8192 / 64, .n = 4 * H, .k = H }}, + 1 => &.{ .{ .rows = 6, .n = 4 * H, .k = H }, .{ .rows = 12294, .n = 4 * H, .k = H }, .{ .rows = 4101, .n = 4 * H, .k = H } }, + // no served call takes a width short of 128 columns: these forms are checked at one + 2 => &.{.{ .rows = 4096 / 64, .n = 1000, .k = H }}, + 0 => &.{ .{ .rows = 5, .n = 1000, .k = H }, .{ .rows = 4101, .n = 1000, .k = H } }, + }, + }; + return .{ .tiles = tiles, .served = switch (form) { + 3 => &.{ .{ .rows = 8192 / 64, .n = 3 * H, .k = H }, .{ .rows = 8192 / 64, .n = H, .k = H }, .{ .rows = 8192 / 64, .n = H, .k = 4 * H } }, + 1 => &.{ .{ .rows = 6, .n = 3 * H, .k = H }, .{ .rows = 12294, .n = 3 * H, .k = H }, .{ .rows = 12294, .n = H, .k = H }, .{ .rows = 12294, .n = H, .k = 4 * H }, .{ .rows = 4101, .n = 3 * H, .k = H }, .{ .rows = 4101, .n = H, .k = H }, .{ .rows = 4101, .n = H, .k = 4 * H } }, + 2 => &.{.{ .rows = 4096 / 64, .n = 1000, .k = H }}, + 0 => &.{ .{ .rows = 5, .n = 1000, .k = H }, .{ .rows = 4101, .n = 1000, .k = H } }, + } }; +} + +/// The pipeline a kind and form run. +pub fn pipeline(kind: Kind, form: u2) []const u8 { + const names = [3][4][]const u8{ + .{ "id_linear_00", "id_linear_01", "id_linear_10", "id_linear_11" }, + .{ "id_linear_gelu_00", "id_linear_gelu_01", "id_linear_gelu_10", "id_linear_gelu_11" }, + .{ "id_split_0", "id_split_0", "id_split_1", "id_split_1" }, + }; + return names[@backingInt(kind)][form]; +} + +pub const Gemm16 = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + kind: Kind, + /// split's forms are 1 and 3: its N, 256, is whole 128-column tiles. + form: u2, + name: []const u8, + m: usize = 0, + n: usize = 0, + k: usize = 0, + stress: bool = false, + x: []f16 = &.{}, + w: []f16 = &.{}, + b: []f16 = &.{}, + out: rig_.Ref = undefined, + ins: [3]rig_.Ref = undefined, + ends: Ends, + + pub fn spec(name: []const u8, kind: Kind, form: u2) c.Spec { + const e = envelope(kind, form); + return .{ + .name = name, + .accum = .f32, + .depth = naxDepth, + .ops = 1, + .out = if (kind == .split) .f32 else .f16, + .tiles = e.tiles, + .served = e.served, + }; + } + + pub fn deinit(t: *Gemm16) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *Gemm16) void { + t.a.free(t.x); + t.a.free(t.w); + t.a.free(t.b); + t.x = &.{}; + t.w = &.{}; + t.b = &.{}; + } + pub fn kernel(t: *Gemm16, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name, t.kind, t.form), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Gemm16); + + pub fn prepare(t: *Gemm16, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + const m = if (t.form & 2 != 0) shape.rows * 64 else shape.rows; + if (m == 0 or shape.n == 0 or shape.k == 0 or shape.k % 2 != 0) return false; + if (t.kind == .split and (shape.n != 256 or shape.k != 3 * H)) return false; + const form = @as(u2, @intFromBool(m % 64 == 0)) * 2 + @intFromBool(shape.n % 128 == 0); + if (form != t.form) return false; + t.rig.reset(); + t.free(); + t.m = m; + t.n = shape.n; + t.k = shape.k; + t.stress = fill == .stress; + const K = shape.k; + const px = @min(m, row_period); + const pw = @min(shape.n, col_period); + t.x = try t.a.alloc(f16, px * K); + t.w = try t.a.alloc(f16, pw * K); + t.b = try t.a.alloc(f16, pw); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + if (t.stress) { + // integers in [hi / 2, hi), hi^2 K <= 2^24: fp32 sums exact in any order, a 32nd of a half past fp16's + const hi: i32 = @intFromFloat(@sqrt(@as(f64, 0x1p24) / @as(f64, @floatFromInt(K)))); + for (0..px) |r| for (0..K / 2) |i| { + const v = id.int(rng, @divTrunc(hi, 2), hi - 1); + t.x[r * K + i] = @floatCast(v); + // x's halves differ by 1 in their first 8: the sums cancel to a few hundred + t.x[r * K + K / 2 + i] = @floatCast(v - @as(f32, if (i < 8) 1 else 0)); + }; + for (0..pw) |j| for (0..K / 2) |i| { + const v = id.int(rng, @divTrunc(hi, 2), hi - 1); + t.w[j * K + i] = @floatCast(v); + t.w[j * K + K / 2 + i] = @floatCast(-v); + }; + for (t.b) |*v| v.* = @floatCast(id.int(rng, -4, 4)); + } else { + id.randomF16(rng, t.x, -2, 2); + id.randomF16(rng, t.w, -0.25, 0.25); + id.randomF16(rng, t.b, -1, 1); + } + if (fill == .nonfinite) { + const at = [_][2]usize{ .{ 0, K / 3 }, .{ 1, K / 2 }, .{ 2, K - 1 }, .{ 3, 0 }, .{ 3, K - 1 } }; + for (at, [_]f16{ id.nan16, id.inf16, -id.inf16, id.inf16, -id.inf16 }) |p, v| if (p[0] < px) { + t.x[p[0] * K + p[1]] = v; + }; + if (pw > 2) t.b[2] = id.inf16; + } + const xs = try id.periodic(f16, t.a, t.x, K, m); + defer t.a.free(xs); + const ws = try id.periodic(f16, t.a, t.w, K, shape.n); + defer t.a.free(ws); + const bs = try id.periodic(f16, t.a, t.b, 1, shape.n); + defer t.a.free(bs); + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(xs)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(ws)); + t.ins[2] = try t.rig.input(std.mem.sliceAsBytes(bs)); + t.out = try t.rig.output(m * shape.n * @as(usize, if (t.kind == .split) 4 else 2)); + return true; + } + + pub fn run(t: *Gemm16) !void { + try t.lib.need(pipeline(t.kind, t.form)); + const p = t.rig.begin(); + const k = &t.lib.k; + switch (t.kind) { + .split => k.split(p.e, kref(t.ins[0]), kref(t.ins[1]), kref(t.out), t.m), + else => k.linear(p.e, kref(t.ins[0]), kref(t.ins[1]), kref(t.ins[2]), kref(t.out), t.m, t.n, t.k, t.kind == .gelu), + } + try t.rig.finish(p); + } + + pub fn count(t: *Gemm16) usize { + return t.m * t.n; + } + + /// The output of a sum `s` (range `sr`) of column j: its bias, fp16 rounding and GELU; split's fp32 sum as is. + fn finish(t: *const Gemm16, s: f64, sr: Range, j: usize) Out { + if (t.kind == .split) return .{ .w = s, .r = sr.fp32(0.5) }; + const b: f64 = t.b[j]; + const v = hf(s + b); + const vr = sr.add(Range.of(b)).fp32(0.5).fp16(); + if (t.kind == .linear) return .{ .w = v, .r = vr }; + return .{ .w = hf(gelu(v)), .r = geluRange(vr).fp16() }; + } + + /// The distinct outputs' values and ranges by `value(r, j)`, then every output from its row's and column's. + fn table(t: *Gemm16, ends: *Ends, want: []f64, mag: []f64, ctx: anytype, comptime value: anytype) !void { + const px = t.x.len / t.k; + const pw = t.w.len / t.k; + const tw = try t.a.alloc(f64, 3 * px * pw); + defer t.a.free(tw); + for (0..px) |r| for (0..pw) |j| { + const o = value(ctx, t, r, j); + tw[3 * (r * pw + j) ..][0..3].* = .{ o.w, o.r.lo, o.r.hi }; + }; + for (0..t.m) |r| for (0..t.n) |j| { + const e = tw[3 * ((r % px) * pw + j % pw) ..][0..3]; + ends.put(want, mag, r * t.n + j, e[0], .{ .lo = e[1], .hi = e[2] }); + }; + } + + pub fn reference(t: *Gemm16, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + const f = struct { + fn value(_: void, s: *const Gemm16, r: usize, j: usize) Out { + const d = naxDot(s.x[r * s.k ..][0..s.k], s.w[j * s.k ..][0..s.k]); + return s.finish(d[0], if (s.stress) Range.of(d[0]) else Range.of(d[0]).widen(d[1]), j); + } + }; + try t.table(&t.ends, want, mag, {}, f.value); + } + pub fn bounds(t: *Gemm16, want: []const f64, _: []const f64, allow: []f64) !void { + t.ends.bounds(want, allow); + } + pub fn intervals(t: *Gemm16, low: []f64, high: []f64) !void { + t.ends.intervals(low, high); + } + + pub fn simulate(t: *Gemm16, acc: c.Accum, order: g.Order, out: []f64) !void { + const mag = try t.a.alloc(f64, out.len); + defer t.a.free(mag); + var scratch: Ends = .{ .a = t.a }; + defer scratch.deinit(); + try scratch.size(t.count()); + const terms = try t.a.alloc(f64, t.k); + defer t.a.free(terms); + const Ctx = struct { acc: c.Accum, order: g.Order, terms: []f64 }; + const f = struct { + fn value(x: Ctx, s: *const Gemm16, r: usize, j: usize) Out { + for (x.terms, s.x[r * s.k ..][0..s.k], s.w[j * s.k ..][0..s.k]) |*v, a, b| v.* = @as(f64, a) * @as(f64, b); + const sum = id.rows.sumIn(x.acc, x.order, x.terms); + return s.finish(sum, Range.of(sum), j); + } + }; + try t.table(&scratch, out, mag, Ctx{ .acc = acc, .order = order, .terms = terms }, f.value); + } +}; + +// --- id_gemm32: fp32 x [M, K] times w [N, K]^T, sums that must be fp32's (the NAX fp32 path's are not) ----------- + +/// Each 8x8 step's eight FMAs in one chain over K. +fn gemm32Depth(s: c.Shape) usize { + return s.k + 8; +} + +pub const Gemm32 = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + shape: c.Shape = undefined, + x: []f32 = &.{}, + w: []f32 = &.{}, + ins: [2]rig_.Ref = undefined, + out: rig_.Ref = undefined, + + pub fn spec(name: []const u8) c.Spec { + return .{ + .name = name, + .accum = .f32, + .depth = gemm32Depth, + .out = .f32, + .tiles = .{ .{ .size = 64 }, .{ .size = 64, .step = 8, .min = 8 }, .{ .size = 32, .step = 32, .min = 32 } }, + .served = &.{ .{ .rows = 4101, .n = H, .k = 1280 }, .{ .rows = 4101, .n = H, .k = 128 }, .{ .rows = 8192, .n = 16, .k = H } }, + }; + } + + pub fn deinit(t: *Gemm32) void { + t.free(); + t.rig.deinit(); + } + fn free(t: *Gemm32) void { + t.a.free(t.x); + t.a.free(t.w); + t.x = &.{}; + t.w = &.{}; + } + pub fn kernel(t: *Gemm32, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Gemm32); + + pub fn prepare(t: *Gemm32, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + const n_ok = shape.n % 64 == 0 or (shape.n < 64 and shape.n % 8 == 0); + if (shape.rows == 0 or shape.n == 0 or shape.k == 0 or shape.k % 32 != 0 or !n_ok) return false; + t.rig.reset(); + t.free(); + t.shape = shape; + const K = shape.k; + const px = @min(shape.rows, row_period); + const pw = @min(shape.n, col_period); + t.x = try t.a.alloc(f32, px * K); + t.w = try t.a.alloc(f32, pw * K); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + if (fill == .stress) { + // 13-bit integers against +-1, in turn on either side: exact fp32 products and sums below 2^24 + for (0..px) |r| for (0..K) |i| { + t.x[r * K + i] = id.sign(rng) * if (i % 2 == 0) id.int(rng, 4097, 8191) else 1; + }; + for (0..pw) |j| for (0..K) |i| { + t.w[j * K + i] = id.sign(rng) * if (i % 2 == 1) id.int(rng, 4097, 8191) else 1; + }; + } else { + id.randomF32(rng, t.x, -2, 2); + id.randomF32(rng, t.w, -0.25, 0.25); + } + if (fill == .nonfinite) { + const at = [_][2]usize{ .{ 0, K / 3 }, .{ 1, K / 2 }, .{ 2, K - 1 }, .{ 3, 0 }, .{ 3, K - 1 } }; + for (at, [_]f32{ id.nan32, id.inf32, -id.inf32, id.inf32, -id.inf32 }) |p, v| if (p[0] < px) { + t.x[p[0] * K + p[1]] = v; + }; + } + const xs = try id.periodic(f32, t.a, t.x, K, shape.rows); + defer t.a.free(xs); + const ws = try id.periodic(f32, t.a, t.w, K, shape.n); + defer t.a.free(ws); + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(xs)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(ws)); + t.out = try t.rig.output(shape.rows * shape.n * 4); + return true; + } + + pub fn run(t: *Gemm32) !void { + try t.lib.need("id_gemm32"); + const p = t.rig.begin(); + t.lib.k.linear32(p.e, kref(t.ins[0]), kref(t.ins[1]), kref(t.out), t.shape.rows, t.shape.n, t.shape.k, t.shape.n); + try t.rig.finish(p); + } + + pub fn count(t: *Gemm32) usize { + return t.shape.rows * t.shape.n; + } + + fn each(t: *Gemm32, want: []f64, mag: []f64, acc: ?c.Accum, order: g.Order) !void { + const K = t.shape.k; + const px = t.x.len / K; + const pw = t.w.len / K; + const tw = try t.a.alloc(f64, 2 * px * pw); + defer t.a.free(tw); + const terms = try t.a.alloc(f64, K); + defer t.a.free(terms); + for (0..px) |r| for (0..pw) |j| { + var s: f64 = 0; + var m: f64 = 0; + for (terms, t.x[r * K ..][0..K], t.w[j * K ..][0..K]) |*v, a, b| { + v.* = @as(f64, a) * @as(f64, b); + s += v.*; + m += @abs(v.*); + } + tw[2 * (r * pw + j) ..][0..2].* = .{ if (acc) |x| id.rows.sumIn(x, order, terms) else s, m }; + }; + for (0..t.shape.rows) |r| for (0..t.shape.n) |j| { + const e = tw[2 * ((r % px) * pw + j % pw) ..][0..2]; + want[r * t.shape.n + j] = e[0]; + mag[r * t.shape.n + j] = e[1]; + }; + } + + pub fn reference(t: *Gemm32, want: []f64, mag: []f64) !void { + try t.each(want, mag, null, .sequential); + } + + pub fn simulate(t: *Gemm32, acc: c.Accum, order: g.Order, out: []f64) !void { + const mag = try t.a.alloc(f64, out.len); + defer t.a.free(mag); + try t.each(out, mag, acc, order); + } +}; diff --git a/zig/tests/contract/metal_idol_norms.zig b/zig/tests/contract/metal_idol_norms.zig new file mode 100644 index 00000000000..c9ea5236595 --- /dev/null +++ b/zig/tests/contract/metal_idol_norms.zig @@ -0,0 +1,251 @@ +//! id_norm, id_norm32 and id_norm_split under the contract: LayerNorm32 in fp32, at idol-sdk's fp16 points. +const std = @import("std"); +const mtl = @import("metal"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const id = @import("metal_idol_common.zig"); + +const c = id.c; +const g = id.g; +const ks = id.ks; +const cfg = id.cfg; +const H = id.H; +const Range = id.Range; +const Ends = id.Ends; +const hf = id.hf; +const kref = id.kref; + +pub const Kind = enum { norm, norm32, split }; + +const norm_why = "an fp16 output follows the sums as var^-1/2: a bf16 sum's error is a few output ulps"; + +/// A thread's 4 values of the 1,024 in turn, the simdgroup tree, then the tree over the threadgroup's 8 simdgroups. +const sum_depth = 1024 / 256 + 5 + 5; + +fn normDepth(_: c.Shape) usize { + return sum_depth + 3; +} + +pub const Norm = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + kind: Kind, + mode: ks.Norm, + name: []const u8, + shape: c.Shape = undefined, + stress: bool = false, + x: []f16 = &.{}, + /// w then b, fp32 + wb: []f32 = &.{}, + /// the modulation's 1 + scale, then its shift, fp16 + mod: []f16 = &.{}, + ins: [5]rig_.Ref = undefined, + out: rig_.Ref = undefined, + ends: Ends, + + /// Rows: positions; n and k: the width, 1,024 (the launcher's). + pub fn spec(name: []const u8, kind: Kind, mode: ks.Norm) c.Spec { + const all: []const c.Shape = &.{ .{ .rows = 12294, .n = H, .k = H }, .{ .rows = 8192, .n = H, .k = H }, .{ .rows = 4101, .n = H, .k = H } }; + return .{ + .name = name, + .accum = .f32, + .depth = normDepth, + .ops = 2 * (id.div_ulps + id.rsqrt_ulps) + 3, + .out = if (kind == .norm32) .f32 else .f16, + .served = switch (kind) { + .norm => switch (mode) { + .modulated => all[0..2], + .affine => all[2..], + // no block calls the plain form: checked at every stream's length + .plain => all, + }, + // the output head's modulated LayerNorm; the affine form at the same rows + .norm32 => all[1..2], + .split => all, + }, + .sums = if (kind == .norm) .{ .bf16 = 0, .why = norm_why } else .{}, + }; + } + + pub fn deinit(t: *Norm) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *Norm) void { + t.a.free(t.x); + t.a.free(t.wb); + t.a.free(t.mod); + t.x = &.{}; + t.wb = &.{}; + t.mod = &.{}; + } + pub fn kernel(t: *Norm, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name, t.kind, t.mode), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Norm); + + fn eps(t: *const Norm) f32 { + return if (t.kind == .norm) cfg.block_eps else cfg.default_eps; + } + + pub fn prepare(t: *Norm, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n != H or shape.k != H) return false; + t.rig.reset(); + t.free(); + t.shape = shape; + t.stress = fill == .stress; + t.x = try t.a.alloc(f16, shape.rows * H); + t.wb = try t.a.alloc(f32, 2 * H); + t.mod = try t.a.alloc(f16, 2 * H); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + if (t.stress) { + // integers mirrored in each row's halves: a mean of exactly 0 and squares summing to ~2^22, exact in fp32 + for (0..shape.rows) |r| for (0..H / 2) |i| { + const v = id.int(rng, -64, 64); + t.x[r * H + i] = @floatCast(v); + t.x[r * H + H / 2 + i] = @floatCast(-v); + }; + } else id.randomF16(rng, t.x, -3, 3); + id.randomF32(rng, t.wb[0..H], 0.25, 2); + id.randomF32(rng, t.wb[H..], -1, 1); + id.randomF16(rng, t.mod[0..H], 0.5, 1.5); + id.randomF16(rng, t.mod[H..], -1, 1); + if (fill == .nonfinite) { + const at = [_][2]usize{ .{ 0, H / 3 }, .{ 1, H / 2 }, .{ 2, H - 1 }, .{ 3, 0 }, .{ 3, H - 1 } }; + for (at, [_]f16{ id.nan16, id.inf16, -id.inf16, id.inf16, -id.inf16 }) |p, v| if (p[0] < shape.rows) { + t.x[p[0] * H + p[1]] = v; + }; + t.wb[5] = id.nan32; + t.wb[H + 6] = id.inf32; + t.mod[7] = -id.inf16; + t.mod[H + 8] = id.nan16; + } + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.x)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(t.wb[0..H])); + t.ins[2] = try t.rig.input(std.mem.sliceAsBytes(t.wb[H..])); + t.ins[3] = try t.rig.input(std.mem.sliceAsBytes(t.mod[0..H])); + t.ins[4] = try t.rig.input(std.mem.sliceAsBytes(t.mod[H..])); + t.out = try t.rig.output(t.count() * @as(usize, if (t.kind == .norm32) 4 else 2)); + return true; + } + + pub fn run(t: *Norm) !void { + const k = &t.lib.k; + try t.lib.need(switch (t.kind) { + .norm => "id_norm", + .norm32 => "id_norm32", + .split => "id_norm_split", + }); + const p = t.rig.begin(); + const in = t.ins; + switch (t.kind) { + .norm => k.norm(p.e, kref(in[0]), kref(in[1]), kref(in[2]), kref(in[3]), kref(in[4]), kref(t.out), t.shape.rows, t.eps(), t.mode), + .norm32 => k.norm32(p.e, kref(in[0]), kref(in[1]), kref(in[2]), kref(t.out), t.shape.rows, t.eps(), t.mode), + .split => k.normSplit(p.e, kref(in[0]), kref(in[1]), kref(in[2]), kref(t.out), t.shape.rows, t.eps()), + } + try t.rig.finish(p); + } + + pub fn count(t: *Norm) usize { + return t.shape.rows * H * @as(usize, if (t.kind == .split) 3 else 1); + } + + /// Row r's outputs from the kernel's mean (range `mr`) and sum of squared deviations (range `qr`). + fn row(t: *Norm, ends: *Ends, r: usize, mean: f64, mr: Range, q: f64, qr: Range, want: []f64, mag: []f64) void { + const n: f64 = H; + const e: f64 = t.eps(); + const inv = 1 / @sqrt(q / n + e); + const ir = (Range{ .lo = qr.lo / n, .hi = qr.hi / n }).add(Range.of(e)).fp32(0.5).rsqrt().fp32(id.rsqrt_ulps); + for (0..H) |i| { + const x: f64 = t.x[r * H + i]; + const v = (x - mean) * inv; + const vr = Range.of(x).sub(mr).fp32(0.5).mul(ir).fp32(0.5); + const w: f64 = t.wb[i]; + const b: f64 = t.wb[H + i]; + const s1: f64 = t.mod[i]; + const sh: f64 = t.mod[H + i]; + const at = r * H + i; + switch (t.kind) { + .norm => switch (t.mode) { + .plain => ends.put(want, mag, at, hf(v), vr.fp16()), + .affine => ends.put(want, mag, at, hf(v * w + b), vr.mul(Range.of(w)).fp32(0.5).add(Range.of(b)).fp32(0.5).fp16()), + .modulated => { + const y = vr.fp16().mul(Range.of(s1)).fp32(0.5).fp16().add(Range.of(sh)).fp32(0.5).fp16(); + ends.put(want, mag, at, hf(hf(hf(v) * s1) + sh), y); + }, + }, + .norm32 => switch (t.mode) { + .modulated => ends.put(want, mag, at, v * (1 + w) + b, vr.mul(Range.of(1 + w).fp32(0.5)).fp32(0.5).add(Range.of(b)).fp32(0.5)), + else => ends.put(want, mag, at, v * w + b, vr.mul(Range.of(w)).fp32(0.5).add(Range.of(b)).fp32(0.5)), + }, + .split => { + const y = v * w + b; + const yr = vr.mul(Range.of(w)).fp32(0.5).add(Range.of(b)).fp32(0.5); + const hi = hf(y); + const hr = yr.fp16(); + // hi + lo: lo = fp16(y - hi), y - hi exact in fp32 for whichever fp16 hi the range rounds to + const lr = (Range{ .lo = yr.lo - hr.hi, .hi = yr.hi - hr.lo }).fp16(); + const base = r * 3 * H + i; + ends.put(want, mag, base, hi, hr); + ends.put(want, mag, base + H, hi, hr); + ends.put(want, mag, base + 2 * H, hf(y - hi), lr); + }, + } + } + } + + pub fn reference(t: *Norm, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + const n: f64 = H; + const gs = c.gamma(sum_depth, c.unit(.f32)); + const gq = c.gamma(sum_depth + 3, c.unit(.f32)); + for (0..t.shape.rows) |r| { + const xs = t.x[r * H ..][0..H]; + var s: f64 = 0; + var abs: f64 = 0; + for (xs) |v| { + s += v; + abs += @abs(@as(f64, v)); + } + const mean = s / n; + var q: f64 = 0; + for (xs) |v| q += (v - mean) * (v - mean); + if (t.stress) { + // a mean of 0 exactly, the deviations the integers and their squares' sums exact in fp32 + t.row(&t.ends, r, mean, Range.of(mean), q, Range.of(q), want, mag); + continue; + } + const mr = Range{ .lo = (s - gs * abs) / n, .hi = (s + gs * abs) / n }; + // the squares about the kernel's mean exceed float64's by n (m' - mean)^2, then fp32 rounds them + const dm = @max(@abs(mr.lo - mean), @abs(mr.hi - mean)); + const qr = Range{ .lo = q * (1 - gq), .hi = (q + n * dm * dm) * (1 + gq) }; + t.row(&t.ends, r, mean, mr, q, qr, want, mag); + } + } + pub fn bounds(t: *Norm, want: []const f64, _: []const f64, allow: []f64) !void { + t.ends.bounds(want, allow); + } + pub fn intervals(t: *Norm, low: []f64, high: []f64) !void { + t.ends.intervals(low, high); + } + + pub fn simulate(t: *Norm, acc: c.Accum, order: g.Order, out: []f64) !void { + const mag = try t.a.alloc(f64, out.len); + defer t.a.free(mag); + var scratch: Ends = .{ .a = t.a }; + defer scratch.deinit(); + try scratch.size(t.count()); + var terms: [H]f64 = undefined; + for (0..t.shape.rows) |r| { + const xs = t.x[r * H ..][0..H]; + for (&terms, xs) |*v, x| v.* = x; + const mean = contract.rows.sumIn(acc, order, &terms) / H; + for (&terms, xs) |*v, x| v.* = (x - mean) * (x - mean); + const q = contract.rows.sumIn(acc, order, &terms); + t.row(&scratch, r, mean, Range.of(mean), q, Range.of(q), out, mag); + } + } +}; diff --git a/zig/tests/contract/metal_idol_rows.zig b/zig/tests/contract/metal_idol_rows.zig new file mode 100644 index 00000000000..63fa5b1043e --- /dev/null +++ b/zig/tests/contract/metal_idol_rows.zig @@ -0,0 +1,442 @@ +//! id_gate_add, id_embed, id_cond and id_bias32 under the contract: elementwise steps at idol-sdk's fp16 points. +const std = @import("std"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const id = @import("metal_idol_common.zig"); + +const c = id.c; +const g = id.g; +const cfg = id.cfg; +const H = id.H; +const Range = id.Range; +const Ends = id.Ends; +const hf = id.hf; +const kref = id.kref; + +/// The steps' common parts: the outputs' ends, and its bounds and intervals from them. +fn Common(comptime T: type) type { + return struct { + pub fn bounds(t: *T, want: []const f64, _: []const f64, allow: []f64) !void { + t.ends.bounds(want, allow); + } + pub fn intervals(t: *T, low: []f64, high: []f64) !void { + t.ends.intervals(low, high); + } + }; +} + +// --- id_gate_add: x = fp16(x + fp16(g y)), in place ------------------------------------------------------------ + +pub const GateAdd = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + rows: usize = 0, + old: []f16 = &.{}, + y: []f16 = &.{}, + gv: []f16 = &.{}, + ins: [2]rig_.Ref = undefined, + out: rig_.Ref = undefined, + ends: Ends, + + /// Rows: positions; n: the stream's width, 1,024 (the launcher's). + pub fn spec(name: []const u8) c.Spec { + return .{ + .name = name, + .accum = .none, + .depth = id.noSums, + .ops = 1, + .mids = 1, + .out = .f16, + .in_place = true, + .served = &.{ .{ .rows = 12294, .n = H, .k = 1 }, .{ .rows = 8192, .n = H, .k = 1 }, .{ .rows = 4101, .n = H, .k = 1 } }, + }; + } + + pub fn deinit(t: *GateAdd) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *GateAdd) void { + t.a.free(t.old); + t.a.free(t.y); + t.a.free(t.gv); + t.old = &.{}; + t.y = &.{}; + t.gv = &.{}; + } + pub fn kernel(t: *GateAdd, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = blk: { + var hooks = g.hooks(GateAdd); + hooks.overlap = overlap; + break :blk hooks; + }; + /// The stream is its own output. + fn overlap(_: *anyopaque) bool { + return true; + } + pub const bounds = Common(GateAdd).bounds; + pub const intervals = Common(GateAdd).intervals; + + pub fn prepare(t: *GateAdd, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n != H) return false; + t.rig.reset(); + t.free(); + t.rows = shape.rows; + const n = shape.rows * H; + t.old = try t.a.alloc(f16, n); + t.y = try t.a.alloc(f16, n); + t.gv = try t.a.alloc(f16, H); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + id.randomF16(rng, t.old, -8, 8); + id.randomF16(rng, t.y, -4, 4); + id.randomF16(rng, t.gv, -2, 2); + if (fill == .nonfinite) { + for ([_]f16{ id.nan16, id.inf16, -id.inf16 }, 0..) |v, i| { + t.old[(i * 13) % n] = v; + t.y[(i * 17 + 1) % n] = v; + } + t.gv[5] = id.nan16; + } + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.y)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(t.gv)); + t.out = try t.rig.output(n * 2); + return true; + } + + pub fn run(t: *GateAdd) !void { + try t.lib.need("id_gate_add"); + // in place: the stream's rows go back before each independent run + @memcpy(t.rig.bytes(t.out, t.count() * 2), std.mem.sliceAsBytes(t.old)); + const p = t.rig.begin(); + t.lib.k.gateAdd(p.e, kref(t.out), kref(t.ins[0]), kref(t.ins[1]), t.rows); + try t.rig.finish(p); + } + + pub fn count(t: *GateAdd) usize { + return t.rows * H; + } + + pub fn reference(t: *GateAdd, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + for (t.old, t.y, 0..) |xb, yb, i| { + const x: f64 = xb; + const y: f64 = yb; + const gv: f64 = t.gv[i % H]; + const r = Range.of(gv * y).fp32(0.5).fp16().add(Range.of(x)).fp32(0.5).fp16(); + t.ends.put(want, mag, i, hf(x + hf(gv * y)), r); + } + } +}; + +// --- id_embed: x = fp16(fp16(z w^T + b) + pe), z [8192, 16] fp32 -------------------------------------------------- + +/// The 16 inputs' FMA chain. +fn embedDepth(_: c.Shape) usize { + return cfg.latent_channels + 1; +} + +pub const Embed = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + stress: bool = false, + z: []f32 = &.{}, + /// w [1024, 16] then b [1024] + wb: []f32 = &.{}, + pe: []f16 = &.{}, + ins: [4]rig_.Ref = undefined, + out: rig_.Ref = undefined, + ends: Ends, + + const R = cfg.latent_rows; + const K = cfg.latent_channels; + + /// Rows: the latent's 8,192, which the launcher fixes (a gate's fewer rows run all of them); k: its 16 channels. + pub fn spec(name: []const u8) c.Spec { + return .{ .name = name, .accum = .f32, .depth = embedDepth, .ops = 2, .mids = 1, .out = .f16, .served = &.{.{ .rows = R, .n = H, .k = K }} }; + } + + pub fn deinit(t: *Embed) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *Embed) void { + t.a.free(t.z); + t.a.free(t.wb); + t.a.free(t.pe); + t.z = &.{}; + t.wb = &.{}; + t.pe = &.{}; + } + pub fn kernel(t: *Embed, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Embed); + pub const bounds = Common(Embed).bounds; + pub const intervals = Common(Embed).intervals; + + pub fn prepare(t: *Embed, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n != H or shape.k != K) return false; + t.rig.reset(); + t.free(); + t.stress = fill == .stress; + t.z = try t.a.alloc(f32, R * K); + t.wb = try t.a.alloc(f32, H * K + H); + t.pe = try t.a.alloc(f16, R * H); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + if (t.stress) { + // products to 2^16 whose halves cancel but for the first: partial sums near 2^19, exact in fp32 + for (0..R) |r| for (0..K / 2) |k| { + t.z[r * K + k] = id.int(rng, 1, 255); + t.z[r * K + K / 2 + k] = t.z[r * K + k] + @as(f32, if (k == 0) 1 else 0); + }; + for (0..H) |o| for (0..K / 2) |k| { + t.wb[o * K + k] = id.sign(rng) * id.int(rng, 1, 255); + t.wb[o * K + K / 2 + k] = -t.wb[o * K + k]; + }; + for (t.wb[H * K ..]) |*v| v.* = id.int(rng, -8, 8); + for (t.pe) |*v| v.* = @floatCast(id.int(rng, -8, 8)); + } else { + id.randomF32(rng, t.z, -3, 3); + id.randomF32(rng, t.wb, -0.5, 0.5); + id.randomF16(rng, t.pe, -1, 1); + } + if (fill == .nonfinite) { + for ([_]f32{ id.nan32, id.inf32, -id.inf32 }, 0..) |v, i| t.z[i * K + 3 * i] = v; + t.wb[H * K + 9] = id.nan32; + t.pe[5 * H + 11] = id.inf16; + } + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.z)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(t.wb[0 .. H * K])); + t.ins[2] = try t.rig.input(std.mem.sliceAsBytes(t.wb[H * K ..])); + t.ins[3] = try t.rig.input(std.mem.sliceAsBytes(t.pe)); + t.out = try t.rig.output(R * H * 2); + return true; + } + + pub fn run(t: *Embed) !void { + try t.lib.need("id_embed"); + const p = t.rig.begin(); + t.lib.k.embed(p.e, kref(t.ins[0]), kref(t.ins[1]), kref(t.ins[2]), kref(t.ins[3]), kref(t.out)); + try t.rig.finish(p); + } + + pub fn count(_: *Embed) usize { + return R * H; + } + + fn each(t: *Embed, ends: *Ends, want: []f64, mag: []f64, acc: ?c.Accum, order: g.Order) void { + const gd = c.gamma(@floatFromInt(embedDepth(.{ .rows = 1, .n = 1, .k = 1 })), c.unit(.f32)); + var terms: [K]f64 = undefined; + for (0..R) |r| for (0..H) |o| { + var s: f64 = 0; + var abs: f64 = 0; + for (&terms, t.z[r * K ..][0..K], t.wb[o * K ..][0..K]) |*v, z, w| { + v.* = @as(f64, z) * @as(f64, w); + s += v.*; + abs += @abs(v.*); + } + var sr = Range.of(s).widen(gd * abs); + if (acc) |x| { + s = contract.rows.sumIn(x, order, &terms); + sr = Range.of(s); + } else if (t.stress) sr = Range.of(s); + const b: f64 = t.wb[H * K + o]; + const pe: f64 = t.pe[r * H + o]; + const y = sr.add(Range.of(b)).fp32(0.5).fp16().add(Range.of(pe)).fp32(0.5).fp16(); + ends.put(want, mag, r * H + o, hf(hf(s + b) + pe), y); + }; + } + + pub fn reference(t: *Embed, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + t.each(&t.ends, want, mag, null, .sequential); + } + + pub fn simulate(t: *Embed, acc: c.Accum, order: g.Order, out: []f64) !void { + const mag = try t.a.alloc(f64, out.len); + defer t.a.free(mag); + var scratch: Ends = .{ .a = t.a }; + defer scratch.deinit(); + try scratch.size(t.count()); + t.each(&scratch, out, mag, acc, order); + } +}; + +// --- id_cond: y = fp16((a + ba) + (c + bc)), the two condition projections' fp32 sums and biases ----------------- + +pub const Cond = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + rows: usize = 0, + /// a, c [rows, 1024], then ba, bc [1024] + v: []f32 = &.{}, + ins: [4]rig_.Ref = undefined, + out: rig_.Ref = undefined, + ends: Ends, + + /// Rows: the condition's 4,101; n: its width, 1,024 (the launcher's). + pub fn spec(name: []const u8) c.Spec { + return .{ .name = name, .accum = .none, .depth = id.noSums, .ops = 3, .out = .f16, .served = &.{.{ .rows = cfg.cond_rows, .n = H, .k = 1 }} }; + } + + pub fn deinit(t: *Cond) void { + t.a.free(t.v); + t.v = &.{}; + t.ends.deinit(); + t.rig.deinit(); + } + pub fn kernel(t: *Cond, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Cond); + pub const bounds = Common(Cond).bounds; + pub const intervals = Common(Cond).intervals; + + pub fn prepare(t: *Cond, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n != H) return false; + t.rig.reset(); + t.a.free(t.v); + t.rows = shape.rows; + const n = shape.rows * H; + t.v = try t.a.alloc(f32, 2 * n + 2 * H); + var prng = std.Random.DefaultPrng.init(seed); + id.randomF32(prng.random(), t.v, -8, 8); + if (fill == .nonfinite) { + for ([_]f32{ id.nan32, id.inf32, -id.inf32 }, 0..) |v, i| { + t.v[(i * 13) % n] = v; + t.v[n + (i * 17 + 1) % n] = v; + } + t.v[2 * n + 5] = id.inf32; + t.v[2 * n + H + 6] = id.nan32; + } + for (0..4) |i| { + const part = if (i < 2) t.v[i * n ..][0..n] else t.v[2 * n + (i - 2) * H ..][0..H]; + t.ins[i] = try t.rig.input(std.mem.sliceAsBytes(part)); + } + t.out = try t.rig.output(n * 2); + return true; + } + + pub fn run(t: *Cond) !void { + try t.lib.need("id_cond"); + const p = t.rig.begin(); + t.lib.k.cond(p.e, kref(t.ins[0]), kref(t.ins[2]), kref(t.ins[1]), kref(t.ins[3]), kref(t.out), t.rows); + try t.rig.finish(p); + } + + pub fn count(t: *Cond) usize { + return t.rows * H; + } + + pub fn reference(t: *Cond, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + const n = t.count(); + for (0..n) |i| { + const av: f64 = t.v[i]; + const cv: f64 = t.v[n + i]; + const ba: f64 = t.v[2 * n + i % H]; + const bc: f64 = t.v[2 * n + H + i % H]; + const r = Range.of(av + ba).fp32(0.5).add(Range.of(cv + bc).fp32(0.5)).fp32(0.5).fp16(); + t.ends.put(want, mag, i, hf((av + ba) + (cv + bc)), r); + } + } +}; + +// --- id_bias32: y += b by column, fp32, in place -------------------------------------------------------------- + +pub const Bias32 = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + shape: c.Shape = undefined, + old: []f32 = &.{}, + b: []f32 = &.{}, + ins: [1]rig_.Ref = undefined, + out: rig_.Ref = undefined, + ends: Ends, + + /// Rows: the latent's; n: the velocity's 16 channels. + pub fn spec(name: []const u8) c.Spec { + return .{ .name = name, .accum = .none, .depth = id.noSums, .ops = 1, .out = .f32, .in_place = true, .served = &.{.{ .rows = cfg.latent_rows, .n = cfg.latent_channels, .k = 1 }} }; + } + + pub fn deinit(t: *Bias32) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *Bias32) void { + t.a.free(t.old); + t.a.free(t.b); + t.old = &.{}; + t.b = &.{}; + } + pub fn kernel(t: *Bias32, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = blk: { + var hooks = g.hooks(Bias32); + hooks.overlap = overlap; + break :blk hooks; + }; + /// The sums are their own output. + fn overlap(_: *anyopaque) bool { + return true; + } + pub const bounds = Common(Bias32).bounds; + pub const intervals = Common(Bias32).intervals; + + pub fn prepare(t: *Bias32, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n == 0) return false; + t.rig.reset(); + t.free(); + t.shape = shape; + const n = shape.rows * shape.n; + t.old = try t.a.alloc(f32, n); + t.b = try t.a.alloc(f32, shape.n); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + id.randomF32(rng, t.old, -16, 16); + id.randomF32(rng, t.b, -2, 2); + if (fill == .nonfinite) { + for ([_]f32{ id.nan32, id.inf32, -id.inf32 }, 0..) |v, i| t.old[(i * 13) % n] = v; + if (shape.n > 6) t.b[5] = id.inf32; + } + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.b)); + t.out = try t.rig.output(n * 4); + return true; + } + + pub fn run(t: *Bias32) !void { + try t.lib.need("id_bias32"); + @memcpy(t.rig.bytes(t.out, t.count() * 4), std.mem.sliceAsBytes(t.old)); + const p = t.rig.begin(); + t.lib.k.bias32(p.e, kref(t.out), kref(t.ins[0]), t.shape.rows, t.shape.n); + try t.rig.finish(p); + } + + pub fn count(t: *Bias32) usize { + return t.shape.rows * t.shape.n; + } + + pub fn reference(t: *Bias32, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + for (t.old, 0..) |y, i| { + const b: f64 = t.b[i % t.shape.n]; + t.ends.put(want, mag, i, y + b, Range.of(y + b).fp32(0.5)); + } + } +}; diff --git a/zig/tests/contract/metal_idol_steps.zig b/zig/tests/contract/metal_idol_steps.zig new file mode 100644 index 00000000000..0202b284b20 --- /dev/null +++ b/zig/tests/contract/metal_idol_steps.zig @@ -0,0 +1,423 @@ +//! id_repo and id_qk under the contract: RePo's angles in fp32, and the heads rotated, normed and rounded to fp16. +const std = @import("std"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const id = @import("metal_idol_common.zig"); + +const c = id.c; +const g = id.g; +const H = id.H; +const D = id.D; +const Range = id.Range; +const Ends = id.Ends; +const hf = id.hf; +const kref = id.kref; + +const streams: []const c.Shape = &.{ .{ .rows = 12294, .n = 512, .k = 128 }, .{ .rows = 8192, .n = 512, .k = 128 }, .{ .rows = 4101, .n = 512, .k = 128 } }; + +// --- id_repo: u = silu(g) c, d = u final^T (48), angles x f pi as cos and sin [rows, 16, 32] -------------------- + +const pi32: f64 = @as(f32, std.math.pi); + +/// d's FMA chain over 128. +fn repoDepth(_: c.Shape) usize { + return 128 + 1; +} + +/// A pair's axis: 10 x, 10 y, then 12 z. +fn axis(j: usize) usize { + return if (j < 10) 0 else if (j < 20) 1 else 2; +} + +pub const Repo = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + rows: usize = 0, + stress: bool = false, + /// gate sums then content sums, 128 each a row + gc: []f32 = &.{}, + /// the final map [48, 128] + wf: []f32 = &.{}, + freqs: []f32 = &.{}, + inv: f32 = 0.5, + ins: [3]rig_.Ref = undefined, + outs: [2]rig_.Ref = undefined, + ends: Ends, + + /// Rows: positions; n: 16 heads x 32 pairs; k: RePo's hidden width. + pub fn spec(name: []const u8) c.Spec { + return .{ .name = name, .accum = .f32, .depth = repoDepth, .ops = id.exp_ulps + id.div_ulps + 2, .out = .f32, .served = streams }; + } + + pub fn deinit(t: *Repo) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *Repo) void { + t.a.free(t.gc); + t.a.free(t.wf); + t.a.free(t.freqs); + t.gc = &.{}; + t.wf = &.{}; + t.freqs = &.{}; + } + pub fn kernel(t: *Repo, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Repo); + + pub fn prepare(t: *Repo, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n != 512 or shape.k != 128) return false; + t.rig.reset(); + t.free(); + t.rows = shape.rows; + t.stress = fill == .stress; + t.gc = try t.a.alloc(f32, shape.rows * 256); + t.wf = try t.a.alloc(f32, 48 * 128); + t.freqs = try t.a.alloc(f32, 32); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + if (t.stress) { + // gates of 20 to 40 (sigmoid 1 in fp32), integer contents: u's halves differ by a gate twice, d small + for (0..shape.rows) |r| for (0..64) |i| { + const gr = t.gc[r * 256 ..][0..256]; + gr[i] = id.int(rng, 20, 40) / t.inv; + gr[i + 64] = gr[i]; + gr[128 + i] = id.sign(rng) * id.int(rng, 1, 8) / t.inv; + gr[128 + i + 64] = gr[128 + i] + @as(f32, if (i < 2) 1 / t.inv else 0); + }; + for (0..48) |o| for (0..64) |i| { + t.wf[o * 128 + i] = id.sign(rng) * id.int(rng, 1, 32); + t.wf[o * 128 + 64 + i] = -t.wf[o * 128 + i]; + }; + id.randomF32(rng, t.freqs, 0.001, 0.01); + } else { + id.randomF32(rng, t.gc, -4, 4); + id.randomF32(rng, t.wf, -0.2, 0.2); + id.randomF32(rng, t.freqs, 0.05, 1.5); + } + if (fill == .nonfinite) { + const at = [_]usize{ 0 * 256 + 5, 1 * 256 + 7, 2 * 256 + 128 + 3 }; + for (at, [_]f32{ id.nan32, id.inf32, -id.inf32 }) |p, v| if (p < t.gc.len) { + t.gc[p] = v; + }; + t.freqs[4] = id.nan32; + } + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.gc)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(t.wf)); + t.ins[2] = try t.rig.input(std.mem.sliceAsBytes(t.freqs)); + for (&t.outs) |*o| o.* = try t.rig.output(shape.rows * 512 * 4); + return true; + } + + pub fn run(t: *Repo) !void { + try t.lib.need("id_repo"); + const p = t.rig.begin(); + t.lib.k.repo(p.e, kref(t.ins[0]), t.inv, kref(t.ins[1]), kref(t.ins[2]), kref(t.outs[0]), kref(t.outs[1]), t.rows); + try t.rig.finish(p); + } + + pub fn count(t: *Repo) usize { + return 2 * t.rows * 512; + } + + /// Row r's u values in float64 and their ranges through the kernel's exp, add, division and product. + fn us(t: *const Repo, r: usize, u: *[128]f64, ur: *[128]Range) void { + const inv: f64 = t.inv; + for (u, ur, 0..) |*v, *vr, i| { + const a = @as(f64, t.gc[r * 256 + i]) * inv; + const cc = @as(f64, t.gc[r * 256 + 128 + i]) * inv; + v.* = a / (1 + @exp(-a)) * cc; + // a >= 20: 1 + exp(-a) is 1 in fp32 and a / 1 is a, so u = a c exactly + if (t.stress) { + v.* = a * cc; + vr.* = Range.of(v.*); + continue; + } + const den = Range.of(@exp(-a)).fp32(id.exp_ulps).add(Range.of(1)).fp32(0.5); + vr.* = Range.of(a).mul(den.recip()).fp32(id.div_ulps).mul(Range.of(cc)).fp32(0.5); + } + } + + /// Row r's outputs from its 48 offsets d (ranges dr). + fn row(t: *Repo, ends: *Ends, r: usize, d: *const [48]f64, dr: *const [48]Range, want: []f64, mag: []f64) void { + for (0..512) |i| { + const h = i / 32; + const j = i % 32; + const x = d[h * 3 + axis(j)]; + const xr = dr[h * 3 + axis(j)]; + const f: f64 = t.freqs[j]; + const th = std.math.tanh(f); + const ang = (x * th + x * (f - th)) * pi32; + // tanh's error cancels between the two products: fp32 rounds each product, the sum and the scale + const xm = @max(@abs(xr.lo), @abs(xr.hi)); + const e = 2 * 0x1p-24 * pi32 * xm * (@abs(th) + 2 * @abs(f - th) + 2 * @abs(f)) + 0x1p-140; + const lo = @min(xr.lo * f, xr.hi * f) * pi32 - e; + const hi = @max(xr.lo * f, xr.hi * f) * pi32 + e; + ends.put(want, mag, r * 512 + i, @cos(ang), id.cosOver(lo, hi).fp32(id.trig_ulps)); + ends.put(want, mag, (t.rows + r) * 512 + i, @sin(ang), id.sinOver(lo, hi).fp32(id.trig_ulps)); + } + } + + pub fn reference(t: *Repo, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + const gd = c.gamma(@floatFromInt(repoDepth(.{ .rows = 1, .n = 1, .k = 1 })), c.unit(.f32)); + var u: [128]f64 = undefined; + var ur: [128]Range = undefined; + var d: [48]f64 = undefined; + var dr: [48]Range = undefined; + for (0..t.rows) |r| { + t.us(r, &u, &ur); + for (&d, &dr, 0..) |*dv, *dv_r, o| { + var s: f64 = 0; + var rr = Range.of(0); + var abs: f64 = 0; + for (u, ur, t.wf[o * 128 ..][0..128]) |uv, uvr, wv| { + s += uv * wv; + rr = rr.add(uvr.mul(Range.of(wv))); + abs += @max(@abs(uvr.lo), @abs(uvr.hi)) * @abs(@as(f64, wv)); + } + dv.* = s; + dv_r.* = if (t.stress) rr else rr.widen(gd * abs); + } + t.row(&t.ends, r, &d, &dr, want, mag); + } + } + pub fn bounds(t: *Repo, want: []const f64, _: []const f64, allow: []f64) !void { + t.ends.bounds(want, allow); + } + pub fn intervals(t: *Repo, low: []f64, high: []f64) !void { + t.ends.intervals(low, high); + } + + pub fn simulate(t: *Repo, acc: c.Accum, order: g.Order, out: []f64) !void { + const mag = try t.a.alloc(f64, out.len); + defer t.a.free(mag); + var scratch: Ends = .{ .a = t.a }; + defer scratch.deinit(); + try scratch.size(t.count()); + var u: [128]f64 = undefined; + var ur: [128]Range = undefined; + var d: [48]f64 = undefined; + var dr: [48]Range = undefined; + var terms: [128]f64 = undefined; + for (0..t.rows) |r| { + t.us(r, &u, &ur); + for (&d, &dr, 0..) |*dv, *dv_r, o| { + for (&terms, u, t.wf[o * 128 ..][0..128]) |*v, uv, wv| v.* = uv * wv; + dv.* = contract.rows.sumIn(acc, order, &terms); + dv_r.* = Range.of(dv.*); + } + t.row(&scratch, r, &d, &dr, out, mag); + } + } +}; + +// --- id_qk: (q, k) pairs turned by cos and sin and rounded, F.normalize, times gamma and 8, rounded; v copied ----- + +const qk_why = "an fp16 output follows the head's sum of squares as its square root: a bf16 sum is off a few ulps"; + +/// A lane's two squares, then the simdgroup tree. +fn qkDepth(_: c.Shape) usize { + return 1 + 5; +} + +pub const Qk = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + lib: *id.Lib, + name: []const u8, + rows: usize = 0, + stress: bool = false, + qkv: []f16 = &.{}, + /// gq then gk [1024] each + gam: []f32 = &.{}, + /// cos then sin [rows, 512] each + rot: []f32 = &.{}, + ins: [5]rig_.Ref = undefined, + outs: [3]rig_.Ref = undefined, + ends: Ends, + + /// Rows: positions; n: heads; k: the head width. + pub fn spec(name: []const u8) c.Spec { + return .{ + .name = name, + .accum = .f32, + .depth = qkDepth, + .ops = id.sqrt_ulps + id.div_ulps + 2, + .out = .f16, + .served = &.{ .{ .rows = 12294, .n = 16, .k = D }, .{ .rows = 8192, .n = 16, .k = D }, .{ .rows = 4101, .n = 16, .k = D } }, + .sums = .{ .bf16 = 0, .why = qk_why }, + }; + } + + pub fn deinit(t: *Qk) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + fn free(t: *Qk) void { + t.a.free(t.qkv); + t.a.free(t.gam); + t.a.free(t.rot); + t.qkv = &.{}; + t.gam = &.{}; + t.rot = &.{}; + } + pub fn kernel(t: *Qk, control: ?g.Gate) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt, .control = control }; + } + const vt = g.hooks(Qk); + + pub fn prepare(t: *Qk, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n != 16 or shape.k != D) return false; + t.rig.reset(); + t.free(); + t.rows = shape.rows; + t.stress = fill == .stress; + const n = shape.rows; + t.qkv = try t.a.alloc(f16, n * 3 * H); + t.gam = try t.a.alloc(f32, 2 * H); + t.rot = try t.a.alloc(f32, 2 * n * 512); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + id.randomF16(rng, t.qkv, -4, 4); + id.randomF32(rng, t.gam, 0.25, 2); + for (0..n * 512) |i| { + if (t.stress) { + // quarter turns: exact rotations of integer heads, whose squares sum to ~2^20 exactly + const turns = [4][2]f32{ .{ 1, 0 }, .{ 0, 1 }, .{ -1, 0 }, .{ 0, -1 } }; + const turn = turns[rng.uintLessThan(usize, 4)]; + t.rot[i] = turn[0]; + t.rot[n * 512 + i] = turn[1]; + continue; + } + const angle = rng.float(f32) * 2 * std.math.pi; + t.rot[i] = @cos(angle); + t.rot[n * 512 + i] = @sin(angle); + } + if (t.stress) for (0..n) |r| for (0..2 * H) |i| { + t.qkv[r * 3 * H + i] = @floatCast(id.int(rng, -128, 128)); + }; + if (fill == .nonfinite) { + // q NaN, k +inf, v -inf, in turn; then a NaN cos + const at = [_]usize{ 0 * 3 * H + 0 * D + 5, 1 * 3 * H + H + 2 * D + 9, 2 * 3 * H + 2 * H + 3 * D + 1 }; + for (at, [_]f16{ id.nan16, id.inf16, -id.inf16 }) |p, v| if (p < t.qkv.len) { + t.qkv[p] = v; + }; + if (n > 3) t.rot[3 * 512 + 4 * 32 + 6] = id.nan32; + } + t.ins[0] = try t.rig.input(std.mem.sliceAsBytes(t.qkv)); + t.ins[1] = try t.rig.input(std.mem.sliceAsBytes(t.gam[0..H])); + t.ins[2] = try t.rig.input(std.mem.sliceAsBytes(t.gam[H..])); + t.ins[3] = try t.rig.input(std.mem.sliceAsBytes(t.rot[0 .. n * 512])); + t.ins[4] = try t.rig.input(std.mem.sliceAsBytes(t.rot[n * 512 ..])); + for (&t.outs) |*o| o.* = try t.rig.output(n * H * 2); + return true; + } + + pub fn run(t: *Qk) !void { + try t.lib.need("id_qk"); + const p = t.rig.begin(); + const in = t.ins; + t.lib.k.heads(p.e, kref(in[0]), kref(in[1]), kref(in[2]), kref(in[3]), kref(in[4]), kref(t.outs[0]), kref(t.outs[1]), kref(t.outs[2]), t.rows); + try t.rig.finish(p); + } + + pub fn count(t: *Qk) usize { + return 3 * t.rows * H; + } + + /// Head h of row r of q (0) or k (1): its pairs turned and rounded, as float64 values and ranges. + fn turned(t: *const Qk, which: usize, r: usize, h: usize, v: *[D]f64, vr: *[D]Range) void { + const x = t.qkv[r * 3 * H + which * H + h * D ..][0..D]; + for (0..D / 2) |p| { + const cs: f64 = t.rot[r * 512 + h * 32 + p]; + const sn: f64 = t.rot[(t.rows + r) * 512 + h * 32 + p]; + const a: f64 = x[2 * p]; + const b: f64 = x[2 * p + 1]; + v[2 * p] = hf(a * cs - b * sn); + v[2 * p + 1] = hf(a * sn + b * cs); + const ac = Range.of(a * cs).fp32(0.5); + const bs = Range.of(b * sn).fp32(0.5); + const as_ = Range.of(a * sn).fp32(0.5); + const bc = Range.of(b * cs).fp32(0.5); + vr[2 * p] = ac.sub(bs).fp32(0.5).fp16(); + vr[2 * p + 1] = as_.add(bc).fp32(0.5).fp16(); + } + } + + /// The head's outputs from its sum of squares `ss` (range `ssr`). + fn head(t: *Qk, ends: *Ends, which: usize, r: usize, h: usize, v: *const [D]f64, vr: *const [D]Range, ss: f64, ssr: Range, want: []f64, mag: []f64) void { + const e12: f64 = @as(f32, 1e-12); + // torch's clamp_min keeps a NaN norm (@max would drop it) + const norm = if (std.math.isNan(ss)) ss else @max(@sqrt(ss), e12); + const nr0 = ssr.up(id.sqrt).fp32(id.sqrt_ulps); + const nr = Range{ .lo = @max(nr0.lo, e12), .hi = @max(nr0.hi, e12) }; + const gam = t.gam[which * H + h * D ..][0..D]; + const base = which * t.rows * H + (h * t.rows + r) * D; + for (0..D) |i| { + const gv: f64 = gam[i]; + const w = hf(v[i] / norm * gv * 8); + const rr = vr[i].mul(nr.recip()).fp32(id.div_ulps).mul(Range.of(gv)).fp32(0.5).mul(Range.of(8)).fp32(0.5).fp16(); + ends.put(want, mag, base + i, w, rr); + } + } + + /// v's heads, copied bit for bit. + fn values(t: *Qk, ends: *Ends, want: []f64, mag: []f64) void { + for (0..t.rows) |r| for (0..16) |h| for (0..D) |i| { + const f: f64 = t.qkv[r * 3 * H + 2 * H + h * D + i]; + ends.put(want, mag, 2 * t.rows * H + (h * t.rows + r) * D + i, f, Range.of(f)); + }; + } + + pub fn reference(t: *Qk, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + const gd = c.gamma(@floatFromInt(qkDepth(.{ .rows = 1, .n = 1, .k = 1 })), c.unit(.f32)); + var v: [D]f64 = undefined; + var vr: [D]Range = undefined; + for (0..2) |which| for (0..t.rows) |r| for (0..16) |h| { + t.turned(which, r, h, &v, &vr); + var ss: f64 = 0; + var lo: f64 = 0; + var hi: f64 = 0; + for (v, vr) |x, xr| { + ss += x * x; + const q = xr.square(); + lo += q.lo; + hi += q.hi; + } + const ssr = if (t.stress) Range.of(ss) else Range{ .lo = lo * (1 - gd), .hi = hi * (1 + gd) }; + t.head(&t.ends, which, r, h, &v, &vr, ss, ssr, want, mag); + }; + t.values(&t.ends, want, mag); + } + pub fn bounds(t: *Qk, want: []const f64, _: []const f64, allow: []f64) !void { + t.ends.bounds(want, allow); + } + pub fn intervals(t: *Qk, low: []f64, high: []f64) !void { + t.ends.intervals(low, high); + } + + pub fn simulate(t: *Qk, acc: c.Accum, order: g.Order, out: []f64) !void { + const mag = try t.a.alloc(f64, out.len); + defer t.a.free(mag); + var scratch: Ends = .{ .a = t.a }; + defer scratch.deinit(); + try scratch.size(t.count()); + var v: [D]f64 = undefined; + var vr: [D]Range = undefined; + var terms: [D]f64 = undefined; + for (0..2) |which| for (0..t.rows) |r| for (0..16) |h| { + t.turned(which, r, h, &v, &vr); + for (&terms, v) |*s, x| s.* = x * x; + const ss = contract.rows.sumIn(acc, order, &terms); + t.head(&scratch, which, r, h, &v, &vr, ss, Range.of(ss), out, mag); + }; + t.values(&scratch, out, mag); + } +}; diff --git a/zig/tests/contract/metal_limits.zig b/zig/tests/contract/metal_limits.zig index aa7d88608dd..559cc197916 100644 --- a/zig/tests/contract/metal_limits.zig +++ b/zig/tests/contract/metal_limits.zig @@ -170,6 +170,7 @@ fn resolve(a: std.mem.Allocator, device: mtl.Device, d: limits.MetalLaunch, comp return .{ .decl = d, .function = fun, .here = text, .pre_m5 = text }; } if (try @import("metal_dsv41_limits.zig").launchOf(a, device, d, fun, assemble)) |l| return l; + if (try @import("metal_glm_launch.zig").launchOf(a, device, d, fun, assemble)) |l| return l; if (std.mem.startsWith(u8, d.name, "flint ") or std.mem.startsWith(u8, d.name, "moe_route ")) { if (!assemble) return undefined; const t = try @import("metal_flint.zig").limitsText(a, device, d.name); @@ -189,6 +190,11 @@ fn resolve(a: std.mem.Allocator, device: mtl.Device, d: limits.MetalLaunch, comp const body = @import("ling_metal").route; return .{ .decl = d, .function = fun, .here = body, .pre_m5 = body }; } + if (std.mem.startsWith(u8, d.name, "metal ling mla ")) { + if (!assemble) return undefined; + const body = @import("ling_metal").mla; + return .{ .decl = d, .function = fun, .here = body, .pre_m5 = body }; + } if (std.mem.startsWith(u8, d.name, "nemotron paged ")) { if (!assemble) return undefined; return pagedLaunch(a, device, d, fun); @@ -284,6 +290,10 @@ fn resolve(a: std.mem.Allocator, device: mtl.Device, d: limits.MetalLaunch, comp if (!assemble) return undefined; text = sources.moss_image; frags = true; + } else if (std.mem.startsWith(u8, d.name, "idol ")) { + if (!assemble) return undefined; + text = sources.idol; + frags = true; } else if (std.mem.startsWith(u8, d.name, "core deltanet ")) { if (!assemble) return undefined; text = sources.core_deltanet; diff --git a/zig/tests/contract/metal_ling_mla.zig b/zig/tests/contract/metal_ling_mla.zig new file mode 100644 index 00000000000..46a0dd42040 --- /dev/null +++ b/zig/tests/contract/metal_ling_mla.zig @@ -0,0 +1,327 @@ +//! Ling MLA extras under the contract: GPT-J RoPE on cache and q, and per-head gate expand. +const std = @import("std"); +const mtl = @import("metal"); +const contract = @import("contract"); +const rig_ = @import("rig.zig"); +const controls = @import("metal_ling_mla_controls.zig"); + +const c = contract.spec; +const g = contract.gates; +const Which = controls.Which; +const Mutation = controls.Mutation; + +const LAT: u32 = 512; +const ROPE: u32 = 64; +const KEY: u32 = LAT + ROPE; +const NOPE: u32 = 128; +const VD: u32 = 128; +const QD: u32 = NOPE + ROPE; +const NFREQ: u32 = ROPE / 2; +const HEADS: u32 = 16; +const THETA: f64 = 6_000_000; +const no_sums: c.Sums = .{ .f16 = 0, .bf16 = 0, .why = "no sums: elementwise rotate or a broadcast" }; + +const MlaRow = extern struct { slot: u32, pos: u32 }; +const MlaArgs = extern struct { + cache: u64, + slot_keys: u32, + heads: u32, + head0: u32, + rows: u32, + q_stride: u32, + kv_stride: u32, + gate_stride: u32, + out_stride: u32, + eps: f32, + scale: f32, +}; +comptime { + if (@sizeOf(MlaArgs) != 48) @compileError("MlaArgs must stay 48 bytes, matching k3"); +} + +fn none(_: c.Shape) usize { + return 0; +} + +fn invFreq(i: usize) f64 { + return 1.0 / std.math.pow(f64, THETA, @as(f64, @floatFromInt(2 * i)) / @as(f64, @floatFromInt(ROPE))); +} + +pub fn spec(w: Which) c.Spec { + const rope = [_]c.Shape{ .{ .rows = 8, .n = HEADS, .k = ROPE }, .{ .rows = 1, .n = HEADS, .k = ROPE } }; + const cache = [_]c.Shape{ .{ .rows = 8, .n = 1, .k = ROPE }, .{ .rows = 1, .n = 1, .k = ROPE } }; + const gate = [_]c.Shape{ .{ .rows = 8, .n = HEADS * VD, .k = HEADS }, .{ .rows = 1, .n = HEADS * VD, .k = HEADS } }; + return switch (w) { + .rope_cache => .{ .name = "metal ling mla tf_ling_mla_rope_cache", .accum = .none, .depth = none, .ops = 2, .mids = 1, .out = .bf16, .in_place = true, .served = &cache, .sums = no_sums }, + .rope_q => .{ .name = "metal ling mla tf_ling_mla_rope_q", .accum = .none, .depth = none, .ops = 2, .mids = 1, .out = .bf16, .in_place = true, .served = &rope, .sums = no_sums }, + .gate_expand => .{ .name = "metal ling mla tf_ling_mla_gate_expand", .accum = .none, .depth = none, .out = .bf16, .served = &gate, .sums = no_sums }, + }; +} + +fn random16(rng: std.Random, out: []u16, lo: f32, hi: f32) void { + for (out) |*v| v.* = c.toBf16(lo + rng.float(f32) * (hi - lo)); +} + +fn plant(v: []u16, stride: usize, rows: usize, col: usize) void { + const put = [_]f32{ std.math.nan(f32), std.math.inf(f32), -std.math.inf(f32) }; + for (put, 0..) |f, r| if (r < rows) { + v[r * stride + col] = c.toBf16(f); + }; +} + +pub const Probe = struct { + a: std.mem.Allocator, + rig: rig_.Rig, + which: Which, + mutation: Mutation, + lib: mtl.Library, + pipe: mtl.Pipeline, + shape: c.Shape = .{ .rows = 0, .n = 0, .k = 0 }, + q: []u16 = &.{}, + cache: []u16 = &.{}, + gate: []u16 = &.{}, + cs: []f32 = &.{}, + rows: []MlaRow = &.{}, + in_cs: rig_.Ref = undefined, + in_rows: rig_.Ref = undefined, + in_g: rig_.Ref = undefined, + out: rig_.Ref = undefined, + + pub fn init(a: std.mem.Allocator, device: mtl.Device, queue: mtl.Queue, which: Which, mutation: Mutation) !Probe { + const plain = @import("ling_metal").mla; + const src = try controls.apply(a, plain, mutation); + defer a.free(src); + const lib = try mtl.Library.fromSource(device, src, mtl.CompileOptions.mlx()); + errdefer lib.deinit(); + return .{ + .a = a, + .rig = .{ .a = a, .device = device, .queue = queue }, + .which = which, + .mutation = mutation, + .lib = lib, + .pipe = try mtl.Pipeline.init(device, lib, controls.function(which), false), + }; + } + + fn drop(p: *Probe) void { + for ([_]*[]u16{ &p.q, &p.cache, &p.gate }) |s| { + p.a.free(s.*); + s.* = &.{}; + } + p.a.free(p.cs); + p.cs = &.{}; + p.a.free(p.rows); + p.rows = &.{}; + p.rig.reset(); + } + + pub fn deinit(p: *Probe) void { + p.drop(); + p.rig.deinit(); + p.pipe.deinit(); + p.lib.deinit(); + } + + const vt = g.hooks(Probe); + + pub fn kernel(p: *Probe) g.Kernel { + var k: g.Kernel = .{ .spec = spec(p.which), .ctx = p, .vt = &vt }; + if (p.mutation != .none) { + k.spec.name = p.mutation.name(); + k.control = p.mutation.gate(); + } + return k; + } + + pub fn prepare(p: *Probe, s: c.Shape, fill: g.Fill, seed: u64) !bool { + switch (p.which) { + .rope_cache => if (s.k != ROPE or s.n != 1) return false, + .rope_q => if (s.k != ROPE or s.n != HEADS) return false, + .gate_expand => if (s.n != HEADS * VD or s.k != HEADS) return false, + } + if (s.rows == 0) return false; + p.drop(); + p.shape = s; + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + const rows: u32 = @intCast(s.rows); + p.rows = try p.a.alloc(MlaRow, rows); + for (p.rows, 0..) |*r, t| r.* = .{ .slot = 0, .pos = @intCast(t) }; + p.cs = try p.a.alloc(f32, rows * NFREQ * 2); + for (p.rows, 0..) |r, t| for (0..NFREQ) |i| { + const ang = @as(f64, @floatFromInt(r.pos)) * invFreq(i); + const at = (t * NFREQ + i) * 2; + p.cs[at] = @floatCast(@cos(ang)); + p.cs[at + 1] = @floatCast(@sin(ang)); + }; + p.in_cs = try p.rig.input(std.mem.sliceAsBytes(p.cs)); + switch (p.which) { + .rope_cache => { + p.cache = try p.a.alloc(u16, rows * KEY); + random16(rng, p.cache, -3, 3); + if (fill == .nonfinite) plant(p.cache, KEY, s.rows, LAT); + p.out = try p.rig.output(p.cache.len * 2); + }, + .rope_q => { + p.q = try p.a.alloc(u16, rows * HEADS * QD); + random16(rng, p.q, -3, 3); + if (fill == .nonfinite) plant(p.q, HEADS * QD, s.rows, NOPE); + p.out = try p.rig.output(p.q.len * 2); + }, + .gate_expand => { + p.gate = try p.a.alloc(u16, rows * HEADS); + random16(rng, p.gate, -2, 2); + if (fill == .nonfinite) plant(p.gate, HEADS, s.rows, 0); + p.in_g = try p.rig.input(std.mem.sliceAsBytes(p.gate)); + p.out = try p.rig.output(rows * HEADS * VD * 2); + }, + } + if (p.which == .rope_cache) p.in_rows = try p.rig.input(std.mem.sliceAsBytes(p.rows)); + return true; + } + + pub fn count(p: *Probe) usize { + const rows = p.shape.rows; + return switch (p.which) { + .rope_cache => rows * KEY, + .rope_q => rows * HEADS * QD, + .gate_expand => rows * HEADS * VD, + }; + } + + fn args(p: *Probe) MlaArgs { + const rows: u32 = @intCast(p.shape.rows); + return .{ + .cache = if (p.which == .rope_cache) p.out.buf.gpuAddress() + p.out.off else 0, + .slot_keys = rows, + .heads = HEADS, + .head0 = 0, + .rows = rows, + .q_stride = HEADS * QD, + .kv_stride = KEY, + .gate_stride = HEADS * VD, + .out_stride = HEADS * VD, + .eps = 1e-6, + .scale = 1, + }; + } + + pub fn run(p: *Probe) !void { + const rows = p.shape.rows; + switch (p.which) { + .rope_cache => @memcpy(p.rig.bytes(p.out, p.cache.len * 2), std.mem.sliceAsBytes(p.cache)), + .rope_q => @memcpy(p.rig.bytes(p.out, p.q.len * 2), std.mem.sliceAsBytes(p.q)), + .gate_expand => {}, + } + const pass = p.rig.begin(); + const e = pass.e; + e.setPipeline(p.pipe); + const aa = p.args(); + switch (p.which) { + .rope_cache => { + e.setBuffer(p.in_rows.buf, p.in_rows.off, 0); + e.setValue(aa, 1); + e.setBuffer(p.in_cs.buf, p.in_cs.off, 2); + e.useResource(p.out.buf, mtl.ResourceUsage.read | mtl.ResourceUsage.write); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(32, 1, 1)); + }, + .rope_q => { + e.setBuffer(p.out.buf, p.out.off, 0); + e.setValue(aa, 1); + e.setBuffer(p.in_cs.buf, p.in_cs.off, 2); + e.dispatchGroups(mtl.Size.of(HEADS, rows, 1), mtl.Size.of(32, 1, 1)); + }, + .gate_expand => { + e.setBuffer(p.in_g.buf, p.in_g.off, 0); + e.setBuffer(p.out.buf, p.out.off, 1); + e.setValue(aa, 2); + e.dispatchThreads(mtl.Size.of(HEADS * VD, rows, 1), mtl.Size.of(128, 1, 1)); + }, + } + try p.rig.finish(pass); + } + + pub fn reference(p: *Probe, want: []f64, mag: []f64) !void { + const rows = p.shape.rows; + switch (p.which) { + .rope_cache => for (0..rows) |t| { + const z = p.cache[t * KEY ..][0..KEY]; + for (0..LAT) |i| { + want[t * KEY + i] = c.fromBf16(z[i]); + mag[t * KEY + i] = @abs(want[t * KEY + i]); + } + rotateRef(want[t * KEY + LAT ..][0..ROPE], mag[t * KEY + LAT ..][0..ROPE], z[LAT..][0..ROPE], p.cs[t * NFREQ * 2 ..][0 .. NFREQ * 2]); + }, + .rope_q => for (0..rows) |t| for (0..HEADS) |h| { + const base = (t * HEADS + h) * QD; + const z = p.q[base..][0..QD]; + for (0..NOPE) |i| { + want[base + i] = c.fromBf16(z[i]); + mag[base + i] = @abs(want[base + i]); + } + rotateRef(want[base + NOPE ..][0..ROPE], mag[base + NOPE ..][0..ROPE], z[NOPE..][0..ROPE], p.cs[t * NFREQ * 2 ..][0 .. NFREQ * 2]); + }, + .gate_expand => for (0..rows) |t| for (0..HEADS) |h| { + const v = c.fromBf16(p.gate[t * HEADS + h]); + const lo = (t * HEADS + h) * VD; + for (0..VD) |d| { + want[lo + d] = v; + mag[lo + d] = @abs(v); + } + }, + } + } +}; + +fn rotateRef(want: []f64, mag: []f64, z: []const u16, cs: []const f32) void { + for (0..NFREQ) |i| { + const x0: f64 = c.fromBf16(z[2 * i]); + const x1: f64 = c.fromBf16(z[2 * i + 1]); + const cv: f64 = cs[i * 2]; + const sv: f64 = cs[i * 2 + 1]; + want[i] = x0 * cv - x1 * sv; + want[NFREQ + i] = x1 * cv + x0 * sv; + mag[i] = @abs(x0) * @abs(cv) + @abs(x1) * @abs(sv); + mag[NFREQ + i] = mag[i]; + } +} + +fn wanted(only: ?[]const u8, name: []const u8) bool { + const needle = only orelse return true; + return std.mem.indexOf(u8, name, needle) != null; +} + +pub const Suite = struct { + a: std.mem.Allocator, + device: mtl.Device, + queue: mtl.Queue, + probes: std.ArrayList(*Probe) = .empty, + + pub fn collect(s: *Suite, kernels: *std.ArrayList(g.Kernel), only: ?[]const u8) !void { + for (std.enums.values(Which)) |w| { + const name = spec(w).name; + if (!wanted(only, name)) continue; + const p = try s.a.create(Probe); + errdefer s.a.destroy(p); + p.* = try Probe.init(s.a, s.device, s.queue, w, .none); + try s.probes.append(s.a, p); + try kernels.append(s.a, p.kernel()); + } + for (std.enums.values(Mutation)) |m| { + if (m == .none or !wanted(only, m.name())) continue; + const p = try s.a.create(Probe); + errdefer s.a.destroy(p); + p.* = try Probe.init(s.a, s.device, s.queue, m.which(), m); + try s.probes.append(s.a, p); + try kernels.append(s.a, p.kernel()); + } + } + + pub fn deinit(s: *Suite) void { + for (s.probes.items) |p| { + p.deinit(); + s.a.destroy(p); + } + s.probes.deinit(s.a); + } +}; diff --git a/zig/tests/contract/metal_ling_mla_controls.zig b/zig/tests/contract/metal_ling_mla_controls.zig new file mode 100644 index 00000000000..31e96a46462 --- /dev/null +++ b/zig/tests/contract/metal_ling_mla_controls.zig @@ -0,0 +1,88 @@ +//! Planted controls for Ling MLA extras: one source edit a kernel, which gate 3 must report. +const std = @import("std"); +const contract = @import("contract"); + +pub const Which = enum { rope_cache, rope_q, gate_expand }; + +pub fn function(w: Which) []const u8 { + return switch (w) { + .rope_cache => "tf_ling_mla_rope_cache", + .rope_q => "tf_ling_mla_rope_q", + .gate_expand => "tf_ling_mla_gate_expand", + }; +} + +pub const Mutation = enum { + none, + rope_cache_cs0, + rope_q_cs0, + gate_head0, + + pub fn name(m: Mutation) []const u8 { + return switch (m) { + .none => "", + .rope_cache_cs0 => "control: metal ling mla rope_cache, every row rotates at cs[0]", + .rope_q_cs0 => "control: metal ling mla rope_q, every row rotates at cs[0]", + .gate_head0 => "control: metal ling mla gate_expand, every head takes gate 0", + }; + } + + pub fn gate(m: Mutation) ?contract.gates.Gate { + return switch (m) { + .none => null, + else => .shapes, + }; + } + + pub fn which(m: Mutation) Which { + return switch (m) { + .none => unreachable, + .rope_cache_cs0 => .rope_cache, + .rope_q_cs0 => .rope_q, + .gate_head0 => .gate_expand, + }; + } + + const Edit = struct { from: []const u8, to: []const u8 }; + + fn edit(m: Mutation) Edit { + return switch (m) { + .none => unreachable, + .rope_cache_cs0 => .{ + .from = "const float2 o = ling_apply(float(dst[2 * t]), float(dst[2 * t + 1]), cs, row, t);", + .to = "const float2 o = ling_apply(float(dst[2 * t]), float(dst[2 * t + 1]), cs, 0, t);", + }, + .rope_q_cs0 => .{ + .from = "const float2 o = ling_apply(float(z[2 * t]), float(z[2 * t + 1]), cs, row, t);", + .to = "const float2 o = ling_apply(float(z[2 * t]), float(z[2 * t + 1]), cs, 0, t);", + }, + .gate_head0 => .{ + .from = "g2[row * a.gate_stride + col] = g[row * a.heads + col / VD];", + .to = "g2[row * a.gate_stride + col] = g[row * a.heads];", + }, + }; + } +}; + +pub fn apply(a: std.mem.Allocator, text: []const u8, m: Mutation) ![]u8 { + if (m == .none) return a.dupe(u8, text); + const e = m.edit(); + if (std.mem.count(u8, text, e.from) != 1) return error.ControlEditMissing; + return std.mem.replaceOwned(u8, a, text, e.from, e.to); +} + +test "ling mla source control: each edit hits once" { + const a = std.testing.allocator; + const plain = @import("ling_metal").mla; + for (std.enums.values(Mutation)) |m| { + if (m == .none) continue; + const edited = try apply(a, plain, m); + defer a.free(edited); + try std.testing.expect(std.mem.indexOf(u8, edited, m.edit().to) != null); + try std.testing.expectError(error.ControlEditMissing, apply(a, edited, m)); + try std.testing.expectEqual(contract.gates.Gate.shapes, m.gate().?); + } + const unchanged = try apply(a, plain, .none); + defer a.free(unchanged); + try std.testing.expectEqualStrings(plain, unchanged); +} diff --git a/zig/tests/contract/metal_main.zig b/zig/tests/contract/metal_main.zig index 6e81164f84b..6f93fd08bd2 100644 --- a/zig/tests/contract/metal_main.zig +++ b/zig/tests/contract/metal_main.zig @@ -8,6 +8,7 @@ const affine_k = @import("metal_affine.zig"); const gather_k = @import("metal_affine_gather.zig"); const topk_k = @import("metal_topk.zig"); const ling_route = @import("metal_ling_route.zig"); +const ling_mla = @import("metal_ling_mla.zig"); const tile_k = @import("metal_tile.zig"); const h3_k = @import("metal_h3.zig"); const h3_topk = @import("metal_h3_topk.zig"); @@ -353,6 +354,9 @@ pub fn main(init: std.process.Init) !u8 { ling = try ling_route.Route.init(a, device, queue); try kernels.append(a, ling.?.kernel()); } + var ling_mla_set = ling_mla.Suite{ .a = a, .device = device, .queue = queue }; + defer ling_mla_set.deinit(); + try ling_mla_set.collect(&kernels, o.only); for ([_][]const Reg{ &common, if (tensor) &m5_only else &.{} }) |list| for (list) |v| { if (!wanted(o, v.name)) continue; const p = try a.create(affine_k.Proj); @@ -424,6 +428,9 @@ pub fn main(init: std.process.Init) !u8 { var glm_windows: @import("metal_glm_rows.zig").Suite = .{ .a = a, .device = device, .queue = queue, .kernels = &kernels }; defer glm_windows.deinit(); try glm_windows.collect(o.only); + var glm_launches = @import("metal_glm_launch.zig").Suite.init(a, device, queue, &kernels); + defer glm_launches.deinit(); + try glm_launches.collect(o.only); var flint: @import("metal_flint.zig").Suite = .{ .a = a, .device = device, .queue = queue, .kernels = &kernels }; defer flint.deinit(); try flint.collect(o.only); @@ -544,6 +551,8 @@ pub fn main(init: std.process.Init) !u8 { defer h3_products.destroy(); var dsv41_suites = try @import("metal_dsv41_main.zig").Suites.create(a, device, queue, &kernels, o.only); defer dsv41_suites.destroy(); + const idol = try @import("metal_idol.zig").Suite.create(a, device, queue, &kernels, o.only); + defer idol.destroy(); var t: g.Tally = .{}; const t0 = std.Io.Clock.awake.now(init.io); if (o.gates) { diff --git a/zig/tests/cuda/contract_attn.zig b/zig/tests/cuda/contract_attn.zig index afa284d55c7..11ad3705b94 100644 --- a/zig/tests/cuda/contract_attn.zig +++ b/zig/tests/cuda/contract_attn.zig @@ -24,6 +24,8 @@ pub const Ref = struct { want: []f64, tol: []f64, msg: [240]u8 = undefined, + /// The outputs' type as the kernel writes them (Idol's attention writes fp16). + out: c.Elem = .bf16, pub fn init(a: std.mem.Allocator, d: usize, most: usize) !Ref { const keys = try a.alloc(usize, most); @@ -54,7 +56,7 @@ pub const Ref = struct { try t.load(i, &r.head); ref.head(r.head.q, r.head.k, r.head.v, r.keys[0..r.head.n], r.d, scale, r.want, r.tol); for (r.want, r.tol, 0..) |w, tl, e| { - const got = c.read(.bf16, out, i * r.d + e); + const got = c.read(r.out, out, i * r.d + e); if (c.classOf(w) != .finite) planted += 1; if (c.classOf(got) != c.classOf(w)) return try std.fmt.bufPrint(&r.msg, "head {d} element {d}: {t} where float64 gives {t}", .{ i, e, c.classOf(got), c.classOf(w) }); if (at != .nonfinite and std.math.isFinite(w) and !(@abs(got - w) <= tl)) return try std.fmt.bufPrint(&r.msg, "head {d} element {d} is {e:.6} where float64 gives {e:.6}: {d:.2} of attention_ref's bound", .{ i, e, got, w, @abs(got - w) / tl }); diff --git a/zig/tests/cuda/contract_family_sets.zig b/zig/tests/cuda/contract_family_sets.zig index e112ebd3f9f..04049bae661 100644 --- a/zig/tests/cuda/contract_family_sets.zig +++ b/zig/tests/cuda/contract_family_sets.zig @@ -22,6 +22,7 @@ pub const Sets = struct { shared_down: *SharedDown, prompt: *Prompt, joint_schema: *@import("contract_joint_schema.zig").Set, + idol: *@import("contract_idol.zig").Set, /// Each set's kernels appended to `list`, in this order. pub fn init(gpu: check.Gpu, s: cuda.Stream, a: std.mem.Allocator, list: *std.ArrayList(g.Kernel), affine4: *cuda.qlinear.Affine4Kernels, cap: u32) !Sets { @@ -61,6 +62,8 @@ pub const Sets = struct { errdefer prompt.deinit(); try prompt.append(cap, a, list); const joint_schema = try @import("contract_joint_schema.zig").Set.init(gpu, s, a, list); + errdefer joint_schema.deinit(); + const idol = try @import("contract_idol.zig").Set.init(gpu, s, a, list); return .{ .gpa = gpu.gpa, .bf16_experts = bf16_experts, @@ -75,10 +78,12 @@ pub const Sets = struct { .shared_down = shared_down, .prompt = prompt, .joint_schema = joint_schema, + .idol = idol, }; } pub fn deinit(sets: Sets) void { + sets.idol.deinit(); sets.joint_schema.deinit(); sets.prompt.deinit(); sets.gpa.destroy(sets.prompt); diff --git a/zig/tests/cuda/contract_idol.zig b/zig/tests/cuda/contract_idol.zig new file mode 100644 index 00000000000..f8de4c62987 --- /dev/null +++ b/zig/tests/cuda/contract_idol.zig @@ -0,0 +1,123 @@ +//! Idol's denoiser kernels (idol.cu) under the contract, with controls that drop one fp16 rounding (idol-contract). +const std = @import("std"); +const cuda = @import("cuda"); +const core = @import("core"); +const idol = @import("idol_cuda"); +const check = @import("check.zig"); +const case = @import("contract_idol_case.zig"); +const norms = @import("contract_idol_norms.zig"); +const steps = @import("contract_idol_steps.zig"); +const rotary = @import("contract_idol_rotary.zig"); +const attn = @import("contract_idol_attn.zig"); + +const g = core.contract.gates; + +const controls = struct { + pub const bytes align(16) = @embedFile("fatbin_contract_controls").*; +}; + +/// Every registration, on the heap: the gates hold pointers to them. +pub const Set = struct { + gpa: std.mem.Allocator, + k: idol.Kernels, + ctl: cuda.Module, + /// The kernels with one function swapped for its control. + late_norm: idol.Kernels = undefined, + once_add: idol.Kernels = undefined, + late_bias: idol.Kernels = undefined, + norms: [2]case.Case(norms.Norm) = undefined, + norm32s: [2]case.Case(norms.Norm32) = undefined, + adds: case.Case(steps.GateAdd) = undefined, + biases: [2]case.Case(steps.Bias) = undefined, + cond: case.Case(steps.Cond) = undefined, + bias32: case.Case(steps.Bias32) = undefined, + qk: case.Case(rotary.Qk) = undefined, + repo: case.Case(rotary.Repo) = undefined, + embed: case.Case(rotary.Embed) = undefined, + attn: attn.Attn = undefined, + ctl_norm: case.Case(norms.Norm) = undefined, + ctl_add: case.Case(steps.GateAdd) = undefined, + ctl_bias: case.Case(steps.Bias) = undefined, + + /// The set, its kernels appended to `list` (the controls last). + pub fn init(gpu: check.Gpu, s: cuda.Stream, a: std.mem.Allocator, list: *std.ArrayList(g.Kernel)) !*Set { + const set = try gpu.gpa.create(Set); + errdefer gpu.gpa.destroy(set); + var k = try idol.Kernels.load(gpu.d); + errdefer k.unload(); + var ctl = try cuda.Module.load(gpu.d, &controls.bytes); + errdefer ctl.unload(); + set.* = .{ .gpa = gpu.gpa, .k = k, .ctl = ctl }; + set.late_norm = k; + set.late_norm.norm = try ctl.function("tf_ctl_idol_norm_late"); + set.once_add = k; + set.once_add.gate_add = try ctl.function("tf_ctl_idol_gate_add_once"); + set.late_bias = k; + set.late_bias.bias = try ctl.function("tf_ctl_idol_bias_late"); + const rig: @import("contract_rig.zig").Rig = .{ .gpu = gpu, .s = s }; + const norm_names = [_][]const u8{ "cuda idol tf_idol_norm, LayerNorm32 affine to fp16", "cuda idol tf_idol_norm, LayerNorm32 to fp16, modulated" }; + const norm32_names = [_][]const u8{ "cuda idol tf_idol_norm32, LayerNorm affine in fp32", "cuda idol tf_idol_norm32, LayerNorm times 1 + w in fp32" }; + for (&set.norms, norm_names, 1..) |*x, n, v| x.* = case.make(norms.Norm, rig, k, n, @intCast(v), null); + for (&set.norm32s, norm32_names, 1..) |*x, n, v| x.* = case.make(norms.Norm32, rig, k, n, @intCast(v), null); + set.adds = case.make(steps.GateAdd, rig, k, "cuda idol tf_idol_gate_add, x + fp16(g y)", 0, null); + set.biases[0] = case.make(steps.Bias, rig, k, "cuda idol tf_idol_bias, fp16(acc + b)", 0, null); + set.biases[1] = case.make(steps.Bias, rig, k, "cuda idol tf_idol_bias, fp16(GELU(fp16(acc + b)))", 1, null); + set.cond = case.make(steps.Cond, rig, k, "cuda idol tf_idol_cond, the condition projections' sum", 0, null); + set.bias32 = case.make(steps.Bias32, rig, k, "cuda idol tf_idol_bias32, fp32 bias in place", 0, null); + set.qk = case.make(rotary.Qk, rig, k, "cuda idol tf_idol_qk, RePo turn, F.normalize, gamma", 0, null); + set.repo = case.make(rotary.Repo, rig, k, "cuda idol tf_idol_repo, final map and angles", 0, null); + set.embed = case.make(rotary.Embed, rig, k, "cuda idol tf_idol_embed, input projection and position", 0, null); + set.attn = .{ .rig = rig, .k = &set.k, .name = "cuda idol tf_idol_attention, full<64, 8>, fp16" }; + set.ctl_norm = case.make(norms.Norm, rig, set.late_norm, "control: idol modulated norm unrounded before scale", 2, .shapes); + set.ctl_add = case.make(steps.GateAdd, rig, set.once_add, "control: idol gate_add without fp16(g y)", 0, .shapes); + set.ctl_bias = case.make(steps.Bias, rig, set.late_bias, "control: idol GELU of the unrounded linear", 1, .shapes); + for (&set.norms) |*x| try list.append(a, x.kernel()); + for (&set.norm32s) |*x| try list.append(a, x.kernel()); + try list.append(a, set.adds.kernel()); + for (&set.biases) |*x| try list.append(a, x.kernel()); + try list.append(a, set.cond.kernel()); + try list.append(a, set.bias32.kernel()); + try list.append(a, set.qk.kernel()); + try list.append(a, set.repo.kernel()); + try list.append(a, set.embed.kernel()); + try list.append(a, set.attn.kernel()); + try list.append(a, set.ctl_norm.kernel()); + try list.append(a, set.ctl_add.kernel()); + try list.append(a, set.ctl_bias.kernel()); + return set; + } + + pub fn deinit(set: *Set) void { + for (&set.norms) |*x| x.deinit(); + for (&set.norm32s) |*x| x.deinit(); + set.adds.deinit(); + for (&set.biases) |*x| x.deinit(); + set.cond.deinit(); + set.bias32.deinit(); + set.qk.deinit(); + set.repo.deinit(); + set.embed.deinit(); + set.attn.deinit(); + set.ctl_norm.deinit(); + set.ctl_add.deinit(); + set.ctl_bias.deinit(); + set.ctl.unload(); + set.k.unload(); + set.gpa.destroy(set); + } +}; + +/// Idol's kernels' gates 1-4 and their controls alone. +pub fn run(gpu: check.Gpu) !void { + const a = gpu.gpa; + var s = try cuda.Stream.init(gpu.d, false); + defer s.deinit(); + var list: std.ArrayList(g.Kernel) = .empty; + defer list.deinit(a); + const set = try Set.init(gpu, s, a, &list); + defer set.deinit(); + var t: g.Tally = .{}; + try g.runAll(a, list.items, 0x1d01, &t); + std.debug.print("SUMMARY idol: {d} kernels, {d} pass gates 1-4, {d} fail; {d} controls: {d} red as planted, {d} missed\n", .{ t.kernels, t.passed, t.failed, t.controls, t.caught, t.missed }); + try check.expect(t.problems() == 0, "idol-contract: {d} gate failures, {d} controls missed", .{ t.failed, t.missed }); +} diff --git a/zig/tests/cuda/contract_idol_attn.zig b/zig/tests/cuda/contract_idol_attn.zig new file mode 100644 index 00000000000..b180463e4fc --- /dev/null +++ b/zig/tests/cuda/contract_idol_attn.zig @@ -0,0 +1,187 @@ +//! tf_idol_attention under the contract: every row over every key, head width 64, fp16 in and out, head by head. +const std = @import("std"); +const cuda = @import("cuda"); +const idol = @import("idol_cuda"); +const rig_ = @import("contract_rig.zig"); +const attn = @import("contract_attn.zig"); +const r = @import("contract_idol_ref.zig"); + +const c = r.c; +const g = r.g; + +const why = "P enters the P x V mma as fp16: gates 1 and 3 hold each output to attention_ref's float64 bound (bf16 weights)"; + +/// A row's P x V chain: every key, a 64-key tile at a time, then the 4 lanes' fold. +fn keyChain(s: c.Shape) usize { + return s.k + 64 + 2; +} + +/// Heads (rows) over tokens (n, each a query and key): served token counts at one head, the head strides at 16. +const served = [_]c.Shape{ .{ .rows = 1, .n = r.cond, .k = r.cond }, .{ .rows = 1, .n = r.latent, .k = r.latent }, .{ .rows = 1, .n = r.joint, .k = r.joint }, .{ .rows = r.heads, .n = 300, .k = 300 } }; + +pub fn spec(name: []const u8) c.Spec { + return .{ .name = name, .accum = .f32, .depth = keyChain, .ops = 6, .out = .f16, .tiles = .{ .{}, .{ .size = 16 * idol.attention_warps }, .{} }, .served = &served, .sums = .{ .why = why } }; +} + +fn half(x: f64) u16 { + return @bitCast(@as(f16, @floatCast(@as(f32, @floatCast(x))))); +} + +fn value(b: u16) f64 { + return @as(f16, @bitCast(b)); +} + +pub const Attn = struct { + rig: rig_.Rig, + k: *const idol.Kernels, + name: []const u8, + ref: ?attn.Ref = null, + heads: usize = 0, + tokens: usize = 0, + qkv: std.ArrayList(u16) = .empty, + /// The key head whose K and V rows the reference holds now. + held: ?usize = null, + dev: u64 = 0, + out: u64 = 0, + + pub fn deinit(t: *Attn) void { + if (t.ref) |*x| x.deinit(); + t.qkv.deinit(t.rig.gpu.gpa); + t.rig.deinit(); + } + + pub fn kernel(t: *Attn) g.Kernel { + return .{ .spec = spec(t.name), .ctx = t, .vt = &vt }; + } + const vt = g.hooks(Attn); + + fn stride(t: *const Attn) usize { + return 3 * t.heads * r.D; + } + + pub fn prepare(t: *Attn, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (shape.rows == 0 or shape.n == 0) return false; + t.rig.reset(); + try t.inputs(t.rig.gpu.gpa, shape, fill, seed); + t.dev = try t.rig.input(std.mem.sliceAsBytes(t.qkv.items)); + t.out = try t.rig.output(t.count() * 2); + return true; + } + + /// The host side of prepare: qkv filled for `fill`, and the float64 reference sized for its tokens. + fn inputs(t: *Attn, a: std.mem.Allocator, shape: c.Shape, fill: g.Fill, seed: u64) !void { + t.heads = shape.rows; + t.tokens = shape.n; + t.held = null; + try t.qkv.resize(a, t.tokens * t.stride()); + var prng = std.Random.DefaultPrng.init(seed); + const rng = prng.random(); + for (t.qkv.items) |*e| e.* = half(rng.floatNorm(f64)); + if (t.ref) |*x| x.deinit(); + t.ref = null; + t.ref = try attn.Ref.init(a, r.D, t.tokens); + t.ref.?.out = .f16; + switch (fill) { + .random => {}, + .nonfinite => t.plant(), + .stress => t.stress(rng), + } + } + + fn at(t: *Attn, row: usize, part: usize, head: usize, e: usize) *u16 { + return &t.qkv.items[row * t.stride() + (part * t.heads + head) * r.D + e]; + } + + /// NaN in row 0's query (head 0); +inf and -inf in one value column of the last head, at two keys. + fn plant(t: *Attn) void { + const last = t.heads - 1; + t.at(0, 0, 0, 3).* = half(r.nan); + t.at(t.tokens / 2, 2, last, 7).* = half(r.inf); + t.at(t.tokens - 1, 2, last, 7).* = half(-r.inf); + t.at(t.tokens / 3, 2, last, 9).* = half(r.inf); + } + + /// Gate 4: keys alike (weights 1), odd values below 256 mirrored: fp16 lane sums pass 2048, fp32 sums stay exact. + fn stress(t: *Attn, rng: std.Random) void { + const n = t.tokens; + for (0..t.heads) |hd| for (0..r.D) |e| { + const key = t.at(0, 1, hd, e).*; + for (0..n) |row| t.at(row, 1, hd, e).* = key; + for (0..n / 2) |row| { + const v: f64 = @floatFromInt(1 + 2 * rng.uintLessThan(u32, 128)); + t.at(row, 2, hd, e).* = half(v); + t.at(n / 2 + row, 2, hd, e).* = half((if (row < 8) @as(f64, 1) else 0) - v); + } + if (n % 2 == 1) t.at(n - 1, 2, hd, e).* = half(0); + }; + } + + pub fn run(t: *Attn) !void { + try idol.attention(t.k, t.rig.s, t.dev, t.out, t.tokens, t.heads, 1.0 / 8.0); + try t.rig.s.synchronize(); + } + + pub fn count(t: *Attn) usize { + return t.tokens * t.heads * r.D; + } + + /// Output head i (token i / heads, head i % heads): its query and the head's every key and value. + pub fn load(t: *Attn, i: usize, hd: *attn.Head) !void { + const row = i / t.heads; + const head = i % t.heads; + for (hd.q, 0..) |*x, e| x.* = value(t.at(row, 0, head, e).*); + hd.n = t.tokens; + if (t.held == head) return; + for (0..t.tokens) |j| for (0..r.D) |e| { + hd.k[j * r.D + e] = value(t.at(j, 1, head, e).*); + hd.v[j * r.D + e] = value(t.at(j, 2, head, e).*); + }; + t.held = head; + } + + fn outputs(t: *Attn) usize { + return t.tokens * t.heads; + } + + pub fn check(t: *Attn, gate: g.Gate) !?[]const u8 { + return t.ref.?.check(t, t.outputs(), 1.0 / 8.0, try t.rig.outputBytes(), gate); + } + + pub fn reference(t: *Attn, want: []f64, mag: []f64) !void { + return t.ref.?.reference(t, t.outputs(), 1.0 / 8.0, want, mag); + } + + pub fn simulate(t: *Attn, acc: c.Accum, order: g.Order, out: []f64) !void { + return t.ref.?.simulate(t, t.outputs(), 1.0 / 8.0, acc, order, out); + } +}; + +/// The worst |got - want| / boundExact over the outputs, as gate 4 counts it (a non-finite sum misses infinitely). +fn worst(got: []const f64, want: []const f64) f64 { + var most: f64 = 0; + for (got, want) |x, w| most = @max(most, if (std.math.isFinite(x)) @abs(x - w) / c.boundExact(spec("host"), w) else std.math.inf(f64)); + return most; +} + +test "gate 4's attention inputs at the joint rows: fp32 sums exact in every order, fp16 and bf16 miss by 100x" { + const a = std.testing.allocator; + var t: Attn = .{ .rig = undefined, .k = undefined, .name = "host" }; + defer if (t.ref) |*x| x.deinit(); + defer t.qkv.deinit(a); + try t.inputs(a, .{ .rows = 1, .n = r.joint, .k = r.joint }, .stress, 0x1d01); + // Every key scores alike, so every token's output is token 0's: its head's d outputs stand for all of them. + var buf: [3 * r.D]f64 = undefined; + const want = buf[0..r.D]; + const got = buf[r.D .. 2 * r.D]; + try t.ref.?.reference(&t, 1, 1.0 / 8.0, want, buf[2 * r.D ..]); + var margin = [2]f64{ std.math.inf(f64), std.math.inf(f64) }; + for ([_]g.Order{ .sequential, .pairwise, .strided }) |o| { + try t.ref.?.simulate(&t, 1, 1.0 / 8.0, .f32, o, got); + try std.testing.expect(worst(got, want) <= 1); + for ([_]c.Accum{ .f16, .bf16 }, &margin) |acc, *m| { + try t.ref.?.simulate(&t, 1, 1.0 / 8.0, acc, o, got); + m.* = @min(m.*, worst(got, want)); + } + } + try std.testing.expect(margin[0] >= 100 and margin[1] >= 100); +} diff --git a/zig/tests/cuda/contract_idol_case.zig b/zig/tests/cuda/contract_idol_case.zig new file mode 100644 index 00000000000..46c83434fd0 --- /dev/null +++ b/zig/tests/cuda/contract_idol_case.zig @@ -0,0 +1,135 @@ +//! A test of one Idol kernel under the contract, from its `Op`: inputs, launch and float64 reference with ranges. +const std = @import("std"); +const cuda = @import("cuda"); +const idol = @import("idol_cuda"); +const rig_ = @import("contract_rig.zig"); +const r = @import("contract_idol_ref.zig"); + +const c = r.c; +const g = r.g; + +/// The gates' hooks over an Op: its kinds, out, in_place (input the output starts as), spec, sizes, fill, launch, ref. +pub fn Case(comptime Op: type) type { + const n = Op.kinds.len; + return struct { + const Self = @This(); + rig: rig_.Rig, + k: idol.Kernels, + name: []const u8, + /// The Op's own form (a norm's mode, the bias's GELU), passed to each of its functions. + variant: u32 = 0, + control: ?g.Gate = null, + shape: c.Shape = undefined, + fill: g.Fill = .random, + vals: [n][]f64 = @splat(&.{}), + dev: [n]u64 = @splat(0), + out: u64 = 0, + ends: r.Ends, + + pub fn deinit(t: *Self) void { + t.free(); + t.ends.deinit(); + t.rig.deinit(); + } + + fn free(t: *Self) void { + for (&t.vals) |*v| { + t.rig.gpu.gpa.free(v.*); + v.* = &.{}; + } + } + + pub fn kernel(t: *Self) g.Kernel { + return .{ .spec = Op.spec(t.name, t.variant), .ctx = t, .vt = &vt, .control = t.control }; + } + const vt = g.hooks(Self); + + pub fn prepare(t: *Self, shape: c.Shape, fill: g.Fill, seed: u64) !bool { + if (!Op.accepts(shape)) return false; + t.rig.reset(); + t.free(); + t.shape = shape; + t.fill = fill; + const a = t.rig.gpu.gpa; + for (&t.vals, Op.sizes(shape)) |*v, len| { + v.* = try a.alloc(f64, len); + @memset(v.*, 0); + } + var prng = std.Random.DefaultPrng.init(seed); + Op.fill(prng.random(), fill, shape, t.variant, &t.vals); + for (&t.vals, &t.dev, Op.kinds) |v, *d, kind| { + const bytes = try encode(a, kind, v); + defer a.free(bytes); + d.* = try t.rig.input(bytes); + } + t.out = try t.rig.output(Op.count(shape) * @as(usize, if (Op.out == .f16) 2 else 4)); + return true; + } + + /// The values as the device holds them (each rounded to its type), and their bytes. + fn encode(a: std.mem.Allocator, kind: r.Kind, v: []f64) ![]u8 { + const size: usize = if (kind == .f16) 2 else 4; + const out = try a.alloc(u8, v.len * size); + for (v, 0..) |*x, i| switch (kind) { + .f16 => { + const hv: f16 = @floatCast(@as(f32, @floatCast(x.*))); + std.mem.writeInt(u16, out[2 * i ..][0..2], @bitCast(hv), .little); + x.* = hv; + }, + .f32 => { + const fv: f32 = @floatCast(x.*); + std.mem.writeInt(u32, out[4 * i ..][0..4], @bitCast(fv), .little); + x.* = fv; + }, + }; + return out; + } + + pub fn run(t: *Self) !void { + if (Op.in_place) |i| { + const bytes = t.count() * @as(usize, if (Op.out == .f16) 2 else 4); + try (cuda.DeviceBuffer{ .d = t.rig.gpu.d, .ptr = t.out, .len = bytes }).copyFrom(0, t.dev[i], bytes, t.rig.s.handle); + } + try Op.launch(&t.k, t.rig.s, t.dev, t.out, t.shape, t.variant); + try t.rig.s.synchronize(); + } + + pub fn count(t: *Self) usize { + return Op.count(t.shape); + } + + fn constVals(t: *Self) [n][]const f64 { + var v: [n][]const f64 = undefined; + for (&v, t.vals) |*o, x| o.* = x; + return v; + } + + pub fn reference(t: *Self, want: []f64, mag: []f64) !void { + try t.ends.size(t.count()); + try Op.ref(t.rig.gpu.gpa, t.shape, t.variant, t.constVals(), .{ .range = t.fill == .stress }, &t.ends, want, mag); + } + + pub fn bounds(t: *Self, want: []const f64, _: []const f64, allow: []f64) !void { + t.ends.bounds(want, allow); + } + + pub fn intervals(t: *Self, low: []f64, high: []f64) !void { + t.ends.intervals(low, high); + } + + pub fn simulate(t: *Self, acc: c.Accum, order: g.Order, out: []f64) !void { + const a = t.rig.gpu.gpa; + const mag = try a.alloc(f64, out.len); + defer a.free(mag); + var scratch: r.Ends = .{ .a = a }; + defer scratch.deinit(); + try scratch.size(t.count()); + try Op.ref(a, t.shape, t.variant, t.constVals(), .{ .sim = .{ .acc = acc, .order = order } }, &scratch, out, mag); + } + }; +} + +/// The usual registration of a test: its rig on the stream, the kernels (or a control's copy), name and form. +pub fn make(comptime Op: type, rig: rig_.Rig, k: idol.Kernels, name: []const u8, variant: u32, control: ?g.Gate) Case(Op) { + return .{ .rig = rig, .k = k, .name = name, .variant = variant, .control = control, .ends = .{ .a = rig.gpu.gpa } }; +} diff --git a/zig/tests/cuda/contract_idol_host.zig b/zig/tests/cuda/contract_idol_host.zig new file mode 100644 index 00000000000..480b930cd59 --- /dev/null +++ b/zig/tests/cuda/contract_idol_host.zig @@ -0,0 +1,9 @@ +//! Idol's kernel-contract references on the host: their ranges hold the float64 values, no GPU work. +test { + _ = @import("contract_idol_ref.zig"); + _ = @import("contract_idol_norms.zig"); + _ = @import("contract_idol_steps.zig"); + _ = @import("contract_idol_rotary.zig"); + _ = @import("contract_idol_case.zig"); + _ = @import("contract_idol_attn.zig"); +} diff --git a/zig/tests/cuda/contract_idol_norms.zig b/zig/tests/cuda/contract_idol_norms.zig new file mode 100644 index 00000000000..010dd0e0a10 --- /dev/null +++ b/zig/tests/cuda/contract_idol_norms.zig @@ -0,0 +1,208 @@ +//! tf_idol_norm and tf_idol_norm32 under the contract: LayerNorm32 at idol-sdk's fp16 points, fp32 sums in gate 4. +const std = @import("std"); +const cuda = @import("cuda"); +const idol = @import("idol_cuda"); +const r = @import("contract_idol_ref.zig"); + +const c = r.c; +const Range = r.Range; +const Sum = r.Sum; + +const why = "an output follows the sums as (x - mean) / sqrt(var): an fp16 or bf16 sum's error is many output ulps"; + +/// A thread's share of the row in turn, the warp's 5 shuffles, then the 8 warps' partials in order. +fn depth(s: c.Shape) usize { + return (s.k + 255) / 256 + 5 + 8; +} + +const served = [_]c.Shape{ .{ .rows = r.joint, .n = r.hidden, .k = r.hidden }, .{ .rows = r.latent, .n = r.hidden, .k = r.hidden }, .{ .rows = r.cond, .n = r.hidden, .k = r.hidden } }; + +fn rowSpec(name: []const u8, out: c.Elem) c.Spec { + return .{ + .name = name, + .accum = .f32, + .depth = depth, + .ops = 2 * (r.div_ulps + r.sqrt_ulps) + 3, + .mids = 2, + .out = out, + .served = &served, + .sums = .{ .f16 = 0, .bf16 = 0, .why = why }, + }; +} + +fn rowOk(s: c.Shape) bool { + return s.rows > 0 and s.k == r.hidden and s.n == r.hidden; +} + +/// One row's mean and 1 / sqrt(var + eps) as float64 and in range, each sum formed as `sum` says. +const Stats = struct { + mean: f64, + mr: Range, + inv: f64, + ir: Range, + + fn of(a: std.mem.Allocator, x: []const f64, eps: f64, sum: Sum) !Stats { + const k: f64 = @floatFromInt(x.len); + const dp = (x.len + 255) / 256 + 5 + 8; + const m = sum.total(x, x, x, dp); + const mean = m.v / k; + const mr = (Range{ .lo = m.r.lo / k, .hi = m.r.hi / k }).fp32(r.div_ulps); + const buf = try a.alloc(f64, 3 * x.len); + defer a.free(buf); + const sq = buf[0..x.len]; + const lo = buf[x.len .. 2 * x.len]; + const hi = buf[2 * x.len ..]; + for (x, sq, lo, hi) |v, *q, *l, *u| { + q.* = (v - mean) * (v - mean); + const qr = Range.of(v).sub(mr).fp32(0.5).square().fp32(0.5); + l.* = qr.lo; + u.* = qr.hi; + } + const s = sum.total(sq, lo, hi, dp); + const vr = (Range{ .lo = s.r.lo / k, .hi = s.r.hi / k }).fp32(r.div_ulps).add(Range.of(eps)).fp32(0.5); + const root = vr.up(sqrt).fp32(r.sqrt_ulps); + return .{ .mean = mean, .mr = mr, .inv = 1 / @sqrt(s.v / k + eps), .ir = Range.of(1).div(root).fp32(r.div_ulps) }; + } + + /// (x - mean) inv: its float64 value and range. + fn at(st: Stats, x: f64) struct { v: f64, r: Range } { + return .{ .v = (x - st.mean) * st.inv, .r = Range.of(x).sub(st.mr).fp32(0.5).mul(st.ir).fp32(0.5) }; + } +}; + +fn sqrt(x: f64) f64 { + return @sqrt(@max(x, 0)); +} + +/// Gate 4's rows: integers whose second half mirrors the first, so the mean is 0 and every fp32 sum is exact. +fn rowsFill(rng: std.Random, fill: c.Shape, mode: r.g.Fill, x: []f64) void { + if (mode == .stress) { + const k = fill.k; + for (0..fill.rows) |row| { + const v = x[row * k ..][0..k]; + r.integers(rng, v[0 .. k / 2], 8); + for (v[k / 2 ..], v[0 .. k / 2]) |*o, a| o.* = -a; + } + } else r.uniform(rng, x, -3, 3); + if (mode == .nonfinite) { + const k = fill.k; + r.plant(x, &.{ k / 3, k + k / 2, 2 * k + k - 1 }); + } +} + +/// tf_idol_norm: fp16(y w + b) (variant 1, affine) or fp16(fp16(fp16(y) s1) + sh) (variant 2, modulated). +pub const Norm = struct { + pub const kinds = [_]r.Kind{ .f16, .f32, .f32, .f16, .f16 }; + pub const out: r.Kind = .f16; + pub const in_place: ?usize = null; + pub const accepts = rowOk; + + pub fn spec(name: []const u8, _: u32) c.Spec { + return rowSpec(name, .f16); + } + + pub fn sizes(s: c.Shape) [5]usize { + return .{ s.rows * s.k, s.k, s.k, s.k, s.k }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * s.k; + } + + pub fn fill(rng: std.Random, mode: r.g.Fill, s: c.Shape, _: u32, v: *[5][]f64) void { + rowsFill(rng, s, mode, v[0]); + r.uniform(rng, v[1], 0.25, 2); + r.uniform(rng, v[2], -1, 1); + // the modulation's 1 + scale, and its shift + r.uniform(rng, v[3], 0.5, 1.5); + r.uniform(rng, v[4], -1, 1); + if (mode == .nonfinite) for (v[1..]) |col| r.plant(col, &.{7}); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [5]u64, o: u64, shape: c.Shape, variant: u32) !void { + try idol.norm(k, s, dev[0], dev[1], dev[2], dev[3], dev[4], o, shape.rows, @as(f32, 1e-6), if (variant == 2) .modulated else .affine); + } + + pub fn ref(a: std.mem.Allocator, shape: c.Shape, variant: u32, v: [5][]const f64, sum: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + const k = shape.k; + for (0..shape.rows) |row| { + const x = v[0][row * k ..][0..k]; + const st = try Stats.of(a, x, r.f(1e-6), sum); + for (x, 0..) |xv, i| { + const y = st.at(xv); + const at = row * k + i; + if (variant == 2) { + const s1 = v[3][i]; + const sh = v[4][i]; + e.put(want, mag, at, r.h(r.h(r.h(y.v) * s1) + sh), y.r.half().mul(Range.of(s1)).fp32(0.5).half().add(Range.of(sh)).fp32(0.5).half()); + } else { + const w = v[1][i]; + const b = v[2][i]; + e.put(want, mag, at, r.h(y.v * w + b), y.r.mul(Range.of(w)).fp32(0.5).add(Range.of(b)).fp32(0.5).half()); + } + } + } + } +}; + +/// tf_idol_norm32: y w + b (variant 1, RePo's norm) or y (1 + w) + b (variant 2, the output's), in fp32. +pub const Norm32 = struct { + pub const kinds = [_]r.Kind{ .f16, .f32, .f32 }; + pub const out: r.Kind = .f32; + pub const in_place: ?usize = null; + pub const accepts = rowOk; + + pub fn spec(name: []const u8, _: u32) c.Spec { + return rowSpec(name, .f32); + } + + pub fn sizes(s: c.Shape) [3]usize { + return .{ s.rows * s.k, s.k, s.k }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * s.k; + } + + pub fn fill(rng: std.Random, mode: r.g.Fill, s: c.Shape, _: u32, v: *[3][]f64) void { + rowsFill(rng, s, mode, v[0]); + r.uniform(rng, v[1], -1, 2); + r.uniform(rng, v[2], -1, 1); + if (mode == .nonfinite) for (v[1..]) |col| r.plant(col, &.{9}); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [3]u64, o: u64, shape: c.Shape, variant: u32) !void { + try idol.norm32(k, s, dev[0], dev[1], dev[2], o, shape.rows, @as(f32, 1e-5), if (variant == 2) .modulated else .affine); + } + + pub fn ref(a: std.mem.Allocator, shape: c.Shape, variant: u32, v: [3][]const f64, sum: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + const k = shape.k; + for (0..shape.rows) |row| { + const x = v[0][row * k ..][0..k]; + const st = try Stats.of(a, x, r.f(1e-5), sum); + for (x, 0..) |xv, i| { + const y = st.at(xv); + const w = v[1][i]; + const b = v[2][i]; + const at = row * k + i; + if (variant == 2) { + const one = Range.of(1).add(Range.of(w)).fp32(0.5); + e.put(want, mag, at, y.v * (1 + w) + b, y.r.mul(one).fp32(0.5).add(Range.of(b)).fp32(0.5)); + } else e.put(want, mag, at, y.v * w + b, y.r.mul(Range.of(w)).fp32(0.5).add(Range.of(b)).fp32(0.5)); + } + } + } +}; + +test "a LayerNorm row's statistics lie in their ranges, and gate 4's mirrored integers sum to a zero mean" { + const a = std.testing.allocator; + var x: [1024]f64 = undefined; + var prng = std.Random.DefaultPrng.init(5); + rowsFill(prng.random(), .{ .rows = 1, .n = 1024, .k = 1024 }, .stress, &x); + const st = try Stats.of(a, &x, r.f(1e-6), .{ .range = true }); + try std.testing.expectEqual(@as(f64, 0), st.mean); + try std.testing.expect(st.ir.lo <= st.inv and st.inv <= st.ir.hi); + rowsFill(prng.random(), .{ .rows = 1, .n = 1024, .k = 1024 }, .random, &x); + const rs = try Stats.of(a, &x, r.f(1e-6), .{ .range = false }); + try std.testing.expect(rs.mr.lo <= rs.mean and rs.mean <= rs.mr.hi and rs.ir.lo <= rs.inv and rs.inv <= rs.ir.hi); +} diff --git a/zig/tests/cuda/contract_idol_ref.zig b/zig/tests/cuda/contract_idol_ref.zig new file mode 100644 index 00000000000..fe004a1d2e0 --- /dev/null +++ b/zig/tests/cuda/contract_idol_ref.zig @@ -0,0 +1,213 @@ +//! Idol's CUDA kernel tests' shared parts: float64 values at the kernels' fp16 points, and every value they may take. +const std = @import("std"); +const core = @import("core"); + +pub const c = core.contract.spec; +pub const g = core.contract.gates; +pub const rows = core.contract.rows; + +pub const hidden = 1024; +pub const heads = 16; +pub const D = 64; +pub const ffn = 4096; +/// The served row counts: the joint rows, the noise refiner's latent rows, the condition refiner's rows. +pub const joint = 12294; +pub const latent = 8192; +pub const cond = 4101; + +// nvcc's error bounds under the glue flags: IEEE division and square root; expf, tanhf, cosf and sinf 2 ulps +pub const div_ulps = 0.5; +pub const sqrt_ulps = 0.5; +pub const fn_ulps = 2; + +/// An input's element type on the device. +pub const Kind = enum { f16, f32 }; + +/// A value as fp32, then fp16, round to nearest even (overflow to infinity). +pub fn h(v: f64) f64 { + return @as(f16, @floatCast(@as(f32, @floatCast(v)))); +} + +/// A value as fp32. +pub fn f(v: f64) f64 { + return @as(f32, @floatCast(v)); +} + +/// fmaxf: a NaN operand gives the other. +pub fn fmax(a: f64, b: f64) f64 { + if (std.math.isNan(a)) return b; + if (std.math.isNan(b)) return a; + return @max(a, b); +} + +/// Every value the kernel may hold at a step: its fp32 steps widen both ends, its fp16 points round them. +pub const Range = struct { + lo: f64, + hi: f64, + + pub fn of(v: f64) Range { + return .{ .lo = v, .hi = v }; + } + /// An fp32 step good to `ulps` units in the last place (a correctly rounded one: 0.5); infinities stay. + pub fn fp32(a: Range, ulps: f64) Range { + const u = ulps * 0x1p-23; + return .{ .lo = if (std.math.isFinite(a.lo)) a.lo - u * @abs(a.lo) - 0x1p-149 else a.lo, .hi = if (std.math.isFinite(a.hi)) a.hi + u * @abs(a.hi) + 0x1p-149 else a.hi }; + } + pub fn half(a: Range) Range { + return .{ .lo = h(a.lo), .hi = h(a.hi) }; + } + pub fn add(a: Range, b: Range) Range { + return .{ .lo = a.lo + b.lo, .hi = a.hi + b.hi }; + } + pub fn sub(a: Range, b: Range) Range { + return .{ .lo = a.lo - b.hi, .hi = a.hi - b.lo }; + } + pub fn mul(a: Range, b: Range) Range { + const p = [4]f64{ a.lo * b.lo, a.lo * b.hi, a.hi * b.lo, a.hi * b.hi }; + return .{ .lo = @min(@min(p[0], p[1]), @min(p[2], p[3])), .hi = @max(@max(p[0], p[1]), @max(p[2], p[3])) }; + } + /// a / b for b of one sign. + pub fn div(a: Range, b: Range) Range { + return a.mul(.{ .lo = 1 / b.hi, .hi = 1 / b.lo }); + } + /// An increasing function at both ends. + pub fn up(a: Range, comptime fun: fn (f64) f64) Range { + return .{ .lo = fun(a.lo), .hi = fun(a.hi) }; + } + /// fmaxf against a constant. + pub fn atLeast(a: Range, v: f64) Range { + return .{ .lo = @max(a.lo, v), .hi = @max(a.hi, v) }; + } + /// x^2 over the range. + pub fn square(a: Range) Range { + const lo = if (a.lo <= 0 and a.hi >= 0) 0 else @min(a.lo * a.lo, a.hi * a.hi); + return .{ .lo = lo, .hi = @max(a.lo * a.lo, a.hi * a.hi) }; + } + /// cos or sin (`sine`) over the range, its extrema included when one lies inside. + pub fn trig(a: Range, sine: bool) Range { + if (!(std.math.isFinite(a.lo) and std.math.isFinite(a.hi)) or a.hi - a.lo >= 2 * std.math.pi) return .{ .lo = -1, .hi = 1 }; + const fun: *const fn (f64) f64 = if (sine) sinf64 else cosf64; + var lo = @min(fun(a.lo), fun(a.hi)); + var hi = @max(fun(a.lo), fun(a.hi)); + // extrema at k pi (cos) or pi / 2 + k pi (sin) + const shift: f64 = if (sine) std.math.pi / 2.0 else 0; + var k = @ceil((a.lo - shift) / std.math.pi); + while (k * std.math.pi + shift <= a.hi) : (k += 1) { + const v = fun(k * std.math.pi + shift); + lo = @min(lo, v); + hi = @max(hi, v); + } + return .{ .lo = lo, .hi = hi }; + } +}; + +fn sinf64(x: f64) f64 { + return @sin(x); +} +fn cosf64(x: f64) f64 { + return @cos(x); +} + +/// How a reference forms its sums: in float64 with their fp32 range (exact for gate 4's inputs), or in an accumulator. +pub const Sum = union(enum) { + range: bool, + sim: struct { acc: c.Accum, order: g.Order }, + + /// The terms' sum and its range, `lo` and `hi` each term's own ends, `depth` fp32 roundings deep. + pub fn total(s: Sum, terms: []const f64, lo: []const f64, hi: []const f64, depth: usize) struct { v: f64, r: Range } { + switch (s) { + .sim => |x| { + const v = rows.sumIn(x.acc, x.order, terms); + return .{ .v = v, .r = Range.of(v) }; + }, + .range => |exact| { + var v: f64 = 0; + var a: f64 = 0; + var b: f64 = 0; + var m: f64 = 0; + for (terms, lo, hi) |t, l, u| { + v += t; + a += l; + b += u; + m += @max(@abs(l), @abs(u)); + } + if (exact) return .{ .v = v, .r = Range.of(v) }; + const e = c.gamma(@floatFromInt(depth), c.unit(.f32)) * m; + return .{ .v = v, .r = .{ .lo = a - e, .hi = b + e } }; + }, + } + } +}; + +/// Each output's float64 value at the kernel's rounding points, and its range, kept for the bounds and intervals. +pub const Ends = struct { + a: std.mem.Allocator, + lo: []f64 = &.{}, + hi: []f64 = &.{}, + + pub fn deinit(e: *Ends) void { + e.a.free(e.lo); + e.a.free(e.hi); + e.lo = &.{}; + e.hi = &.{}; + } + + pub fn size(e: *Ends, n: usize) !void { + e.deinit(); + e.lo = try e.a.alloc(f64, n); + e.hi = try e.a.alloc(f64, n); + } + + pub fn put(e: *Ends, want: []f64, mag: []f64, i: usize, w: f64, r: Range) void { + want[i] = w; + mag[i] = if (std.math.isFinite(w)) @abs(w) else 0; + e.lo[i] = r.lo; + e.hi[i] = r.hi; + } + + /// The allowance about the float64 value: its range's farther end (a non-finite value is checked by class). + pub fn bounds(e: *const Ends, want: []const f64, allow: []f64) void { + for (allow, want, e.lo, e.hi) |*l, w, lo, hi| l.* = if (std.math.isFinite(w) and std.math.isFinite(lo) and std.math.isFinite(hi)) @max(@abs(w - lo), @abs(hi - w)) else 0; + } + + pub fn intervals(e: *const Ends, low: []f64, high: []f64) void { + @memcpy(low, e.lo); + @memcpy(high, e.hi); + } +}; + +/// Values uniform in [lo, hi]. +pub fn uniform(rng: std.Random, out: []f64, lo: f64, hi: f64) void { + for (out) |*v| v.* = lo + rng.float(f64) * (hi - lo); +} + +/// Integers in [-bound, bound]. +pub fn integers(rng: std.Random, out: []f64, bound: u32) void { + for (out) |*v| v.* = @as(f64, @floatFromInt(rng.uintLessThan(u32, 2 * bound + 1))) - @as(f64, @floatFromInt(bound)); +} + +pub const nan = std.math.nan(f64); +pub const inf = std.math.inf(f64); + +/// Plants NaN, +inf and -inf at `at` (indices taken modulo the length). +pub fn plant(out: []f64, at: []const usize) void { + const vals = [_]f64{ nan, inf, -inf }; + for (at, 0..) |i, j| out[i % out.len] = vals[j % 3]; +} + +test "fp16 points round to nearest even, ranges keep the exact value inside" { + try std.testing.expectEqual(@as(f64, 1.0), h(1.0 + 1.0 / 4096.0)); + try std.testing.expectEqual(inf, h(70000)); + const r = Range.of(0.3).fp32(0.5).mul(Range.of(1.7)).fp32(0.5).half(); + try std.testing.expect(r.lo <= h(0.3 * 1.7) and h(0.3 * 1.7) <= r.hi); + const t = (Range{ .lo = 3.1, .hi = 3.2 }).trig(false); + try std.testing.expectEqual(@as(f64, -1), t.lo); +} + +test "a sum's range holds the exact sum, and is the sum itself for gate 4's exact inputs" { + const t = [_]f64{ 1.5, -2.25, 3 }; + const s = (Sum{ .range = false }).total(&t, &t, &t, 3); + try std.testing.expect(s.r.lo < 2.25 and 2.25 < s.r.hi); + const e = (Sum{ .range = true }).total(&t, &t, &t, 3); + try std.testing.expectEqual(e.r.lo, e.r.hi); +} diff --git a/zig/tests/cuda/contract_idol_rotary.zig b/zig/tests/cuda/contract_idol_rotary.zig new file mode 100644 index 00000000000..6d23482ba9a --- /dev/null +++ b/zig/tests/cuda/contract_idol_rotary.zig @@ -0,0 +1,312 @@ +//! Idol's summing glue under the contract: RePo's angles, q and k turned and normed, the latent's input embed. +const std = @import("std"); +const cuda = @import("cuda"); +const idol = @import("idol_cuda"); +const r = @import("contract_idol_ref.zig"); + +const c = r.c; +const Range = r.Range; +const Sum = r.Sum; +const Fill = r.g.Fill; + +const why = "gate 4's integers keep fp32 exact; fp16 and bf16 sums miss by a margin it reports but cannot bound ahead"; + +fn summed(name: []const u8, out: c.Elem, served: []const c.Shape, depth: *const fn (c.Shape) usize) c.Spec { + return .{ .name = name, .accum = .f32, .depth = depth, .ops = 8, .mids = 2, .out = out, .served = served, .sums = .{ .f16 = 0, .bf16 = 0, .why = why } }; +} + +fn rowsOf(n: usize, k: usize) [3]c.Shape { + return .{ .{ .rows = r.joint, .n = n, .k = k }, .{ .rows = r.latent, .n = n, .k = k }, .{ .rows = r.cond, .n = n, .k = k } }; +} + +/// tf_idol_qk: q and k of [rows, 3072] turned by cos, sin [rows, 512], F.normalize times gamma times 8; v copied. +pub const Qk = struct { + pub const kinds = [_]r.Kind{ .f16, .f32, .f32, .f32, .f32 }; + pub const out: r.Kind = .f16; + pub const in_place: ?usize = null; + const served = rowsOf(3 * r.hidden, r.D); + + pub fn accepts(s: c.Shape) bool { + return s.rows > 0 and s.n == 3 * r.hidden and s.k == r.D; + } + + /// A lane's two squares and their sum, then the warp's 5 shuffles. + fn depth(_: c.Shape) usize { + return 7; + } + + pub fn spec(name: []const u8, _: u32) c.Spec { + return summed(name, .f16, &served, depth); + } + + pub fn sizes(s: c.Shape) [5]usize { + return .{ s.rows * 3 * r.hidden, r.hidden, r.hidden, s.rows * 512, s.rows * 512 }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * 3 * r.hidden; + } + + pub fn fill(rng: std.Random, mode: Fill, _: c.Shape, _: u32, v: *[5][]f64) void { + if (mode == .stress) { + r.integers(rng, v[0], 64); + @memset(v[3], 1); + @memset(v[4], 0); + } else { + r.uniform(rng, v[0], -4, 4); + for (v[3], v[4]) |*co, *si| { + const t = rng.float(f64) * 2 * std.math.pi; + co.* = @cos(t); + si.* = @sin(t); + } + } + r.uniform(rng, v[1], 0.5, 1.5); + r.uniform(rng, v[2], 0.5, 1.5); + if (mode == .nonfinite) { + r.plant(v[0], &.{ 5, 3072 + 1024 + 77, 2 * 3072 + 2048 + 9 }); + r.plant(v[1], &.{300}); + } + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [5]u64, o: u64, shape: c.Shape, _: u32) !void { + try idol.qk(k, s, dev[0], dev[1], dev[2], dev[3], dev[4], o, shape.rows); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, _: u32, v: [5][]const f64, sum: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + var rot: [64]f64 = undefined; + var rr: [64]Range = undefined; + var sq: [32]f64 = undefined; + var lo: [32]f64 = undefined; + var hi: [32]f64 = undefined; + for (0..shape.rows) |row| for (0..r.heads) |hd| { + const base = row * 3 * r.hidden + hd * r.D; + for (0..r.D) |j| e.put(want, mag, base + 2048 + j, v[0][base + 2048 + j], Range.of(v[0][base + 2048 + j])); + for ([_]usize{ 0, 1024 }, [_][]const f64{ v[1], v[2] }) |off, gamma| { + for (0..32) |l| { + const x0 = v[0][base + off + 2 * l]; + const x1 = v[0][base + off + 2 * l + 1]; + const co = v[3][row * 512 + hd * 32 + l]; + const si = v[4][row * 512 + hd * 32 + l]; + rot[2 * l] = r.h(x0 * co - x1 * si); + rot[2 * l + 1] = r.h(x0 * si + x1 * co); + const a = Range.of(x0).mul(Range.of(co)).fp32(0.5); + const b = Range.of(x1).mul(Range.of(si)).fp32(0.5); + const p = Range.of(x0).mul(Range.of(si)).fp32(0.5); + const q = Range.of(x1).mul(Range.of(co)).fp32(0.5); + rr[2 * l] = a.sub(b).fp32(0.5).half(); + rr[2 * l + 1] = p.add(q).fp32(0.5).half(); + sq[l] = rot[2 * l] * rot[2 * l] + rot[2 * l + 1] * rot[2 * l + 1]; + const t = rr[2 * l].square().fp32(0.5).add(rr[2 * l + 1].square().fp32(0.5)).fp32(0.5); + lo[l] = t.lo; + hi[l] = t.hi; + } + const s = sum.total(&sq, &lo, &hi, 5); + const n = clampMin(@sqrt(s.v)); + const nr = s.r.up(sqrt).fp32(r.sqrt_ulps).up(clampMin); + for (0..r.D) |j| { + const g = gamma[hd * r.D + j]; + const w = r.h(rot[j] / n * g * 8); + const wr = rr[j].div(nr).fp32(r.div_ulps).mul(Range.of(g)).fp32(0.5).mul(Range.of(8)).fp32(0.5).half(); + e.put(want, mag, base + off + j, w, wr); + } + } + }; + } +}; + +fn sqrt(x: f64) f64 { + return @sqrt(@max(x, 0)); +} + +/// F.normalize's clamp_min(1e-12) in fp32, NaN kept. +fn clampMin(x: f64) f64 { + return if (x < r.f(1e-12)) r.f(1e-12) else x; +} + +/// tf_idol_repo: from gate | content [rows, 256], d = final (silu(gate) content), angles; out cos then sin [rows, 512]. +pub const Repo = struct { + pub const kinds = [_]r.Kind{ .f32, .f32, .f32 }; + pub const out: r.Kind = .f32; + pub const in_place: ?usize = null; + const served = rowsOf(r.hidden, 128); + const pi = r.f(std.math.pi); + + pub fn accepts(s: c.Shape) bool { + return s.rows > 0 and s.n == r.hidden and s.k == 128; + } + + /// The final map's 128 fused steps in turn. + fn depth(_: c.Shape) usize { + return 128; + } + + pub fn spec(name: []const u8, _: u32) c.Spec { + return summed(name, .f32, &served, depth); + } + + pub fn sizes(s: c.Shape) [3]usize { + return .{ s.rows * 256, 48 * 128, 32 }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * 1024; + } + + pub fn fill(rng: std.Random, mode: Fill, s: c.Shape, _: u32, v: *[3][]f64) void { + if (mode == .stress) { + // gate 64..80: silu is the gate itself in fp32, so every term is an integer and every fp32 sum exact + for (0..s.rows) |row| { + for (v[0][row * 256 ..][0..128]) |*x| x.* = @floatFromInt(64 + rng.uintLessThan(u32, 17)); + r.integers(rng, v[0][row * 256 + 128 ..][0..128], 8); + } + r.integers(rng, v[1], 8); + @memset(v[2], 0x1p-19); + return; + } + r.uniform(rng, v[0], -4, 4); + r.uniform(rng, v[1], -0.2, 0.2); + r.uniform(rng, v[2], 0.5, 3); + if (mode == .nonfinite) { + r.plant(v[0], &.{ 7, 256 + 130, 2 * 256 + 50 }); + r.plant(v[1], &.{ 128 * 5 + 3, 128 * 20 }); + r.plant(v[2], &.{31}); + } + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [3]u64, o: u64, shape: c.Shape, _: u32) !void { + try idol.repo(k, s, dev[0], dev[1], dev[2], o, o + shape.rows * 512 * 4, shape.rows); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, _: u32, v: [3][]const f64, sum: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + var u: [128]f64 = undefined; + var ur: [128]Range = undefined; + var t: [128]f64 = undefined; + var lo: [128]f64 = undefined; + var hi: [128]f64 = undefined; + var d: [48]f64 = undefined; + var dr: [48]Range = undefined; + const half = shape.rows * 512; + for (0..shape.rows) |row| { + const g = v[0][row * 256 ..][0..256]; + for (0..128) |k| { + const a = g[k]; + const cv = g[128 + k]; + u[k] = a / (1 + @exp(-a)) * cv; + const den = Range.of(-a).up(exp).fp32(r.fn_ulps).add(Range.of(1)).fp32(0.5); + ur[k] = Range.of(a).div(den).fp32(r.div_ulps).mul(Range.of(cv)).fp32(0.5); + } + for (0..48) |o| { + for (0..128) |k| { + const w = v[1][o * 128 + k]; + t[k] = u[k] * w; + const p = ur[k].mul(Range.of(w)); + lo[k] = p.lo; + hi[k] = p.hi; + } + const s = sum.total(&t, &lo, &hi, 128); + d[o] = s.v; + dr[o] = s.r; + } + for (0..512) |i| { + const hd = i / 32; + const j = i % 32; + const axis: usize = if (j < 10) 0 else if (j < 20) 1 else 2; + const x = d[hd * 3 + axis]; + const xr = dr[hd * 3 + axis]; + const fr = v[2][j]; + const ft = std.math.tanh(fr); + const ang = (x * ft + x * (fr - ft)) * pi; + const ftr = Range.of(fr).up(tanh).fp32(r.fn_ulps); + const a1 = xr.mul(ftr).fp32(0.5); + const a2 = xr.mul(Range.of(fr).sub(ftr).fp32(0.5)).fp32(0.5); + const ar = a1.add(a2).fp32(0.5).mul(Range.of(pi)).fp32(0.5); + const at = row * 512 + i; + e.put(want, mag, at, @cos(ang), ar.trig(false).fp32(r.fn_ulps)); + e.put(want, mag, half + at, @sin(ang), ar.trig(true).fp32(r.fn_ulps)); + } + } + } +}; + +fn exp(x: f64) f64 { + return @exp(x); +} + +fn tanh(x: f64) f64 { + return std.math.tanh(x); +} + +/// tf_idol_embed: x = fp16(fp16(z w^T + b) + pe), 16 fp32 inputs a latent row, its fp16 position embedding. +pub const Embed = struct { + pub const kinds = [_]r.Kind{ .f32, .f32, .f32, .f16 }; + pub const out: r.Kind = .f16; + pub const in_place: ?usize = null; + const served = [_]c.Shape{.{ .rows = r.latent, .n = r.hidden, .k = 16 }}; + + pub fn accepts(s: c.Shape) bool { + return s.rows > 0 and s.n == r.hidden and s.k == 16; + } + + fn depth(_: c.Shape) usize { + return 16; + } + + pub fn spec(name: []const u8, _: u32) c.Spec { + return summed(name, .f16, &served, depth); + } + + pub fn sizes(s: c.Shape) [4]usize { + return .{ s.rows * 16, r.hidden * 16, r.hidden, s.rows * r.hidden }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * r.hidden; + } + + pub fn fill(rng: std.Random, mode: Fill, _: c.Shape, _: u32, v: *[4][]f64) void { + if (mode == .stress) { + for (v) |col| r.integers(rng, col, 8); + return; + } + r.uniform(rng, v[0], -3, 3); + r.uniform(rng, v[1], -0.5, 0.5); + r.uniform(rng, v[2], -0.5, 0.5); + r.uniform(rng, v[3], -1, 1); + if (mode == .nonfinite) for (v, 0..) |col, i| r.plant(col, &.{ 3 + 40 * i, 900 + i }); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [4]u64, o: u64, shape: c.Shape, _: u32) !void { + try idol.embed(k, s, dev[0], dev[1], dev[2], dev[3], o, shape.rows); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, _: u32, v: [4][]const f64, sum: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + var t: [16]f64 = undefined; + for (0..shape.rows) |row| for (0..r.hidden) |col| { + for (&t, 0..) |*x, k| x.* = v[0][row * 16 + k] * v[1][col * 16 + k]; + const s = sum.total(&t, &t, &t, 16); + const b = v[2][col]; + const at = row * r.hidden + col; + const pe = v[3][at]; + e.put(want, mag, at, r.h(r.h(s.v + b) + pe), s.r.add(Range.of(b)).fp32(0.5).half().add(Range.of(pe)).fp32(0.5).half()); + }; + } +}; + +test "q and k turned and normed by their warp's sum keep the float64 value inside its range" { + const a = std.testing.allocator; + const shape: c.Shape = .{ .rows = 1, .n = 3 * r.hidden, .k = r.D }; + var bufs: [5][]f64 = undefined; + for (&bufs, Qk.sizes(shape)) |*b, n| b.* = try a.alloc(f64, n); + defer for (bufs) |b| a.free(b); + var prng = std.Random.DefaultPrng.init(3); + Qk.fill(prng.random(), .random, shape, 0, &bufs); + var e: r.Ends = .{ .a = a }; + defer e.deinit(); + try e.size(Qk.count(shape)); + const want = try a.alloc(f64, Qk.count(shape)); + defer a.free(want); + const mag = try a.alloc(f64, Qk.count(shape)); + defer a.free(mag); + try Qk.ref(a, shape, 0, .{ bufs[0], bufs[1], bufs[2], bufs[3], bufs[4] }, .{ .range = false }, &e, want, mag); + for (want, e.lo, e.hi) |w, lo, hi| try std.testing.expect(lo <= w and w <= hi); +} diff --git a/zig/tests/cuda/contract_idol_steps.zig b/zig/tests/cuda/contract_idol_steps.zig new file mode 100644 index 00000000000..aa4d1f9fa8f --- /dev/null +++ b/zig/tests/cuda/contract_idol_steps.zig @@ -0,0 +1,217 @@ +//! Idol's epilogues under the contract: gated residual, linear biases (GELU), condition sum, fp32 bias and the embed. +const std = @import("std"); +const cuda = @import("cuda"); +const idol = @import("idol_cuda"); +const r = @import("contract_idol_ref.zig"); + +const c = r.c; +const Range = r.Range; +const Sum = r.Sum; +const Fill = r.g.Fill; + +fn none(_: c.Shape) usize { + return 0; +} + +const why = "no sums: each output is a few fp32 steps and its fp16 rounding, every one inside its interval"; + +/// A kernel with no sums: its outputs are held to their pointwise intervals alone. +fn plain(name: []const u8, out: c.Elem, served: []const c.Shape) c.Spec { + return .{ .name = name, .accum = .none, .depth = none, .ops = 4, .mids = 2, .out = out, .served = served, .sums = .{ .f16 = 0, .bf16 = 0, .why = why } }; +} + +fn wide(rows: usize, n: usize) c.Shape { + return .{ .rows = rows, .n = n, .k = n }; +} + +fn any(s: c.Shape) bool { + return s.rows > 0 and s.n > 0 and s.n == s.k; +} + +/// The 1024-wide residual stream's rows at every refiner. +const stream = [_]c.Shape{ wide(r.joint, r.hidden), wide(r.latent, r.hidden), wide(r.cond, r.hidden) }; + +/// tf_idol_gate_add: x = fp16(x + fp16(g y)), in place over x (input 0). +pub const GateAdd = struct { + pub const kinds = [_]r.Kind{ .f16, .f16, .f16 }; + pub const out: r.Kind = .f16; + pub const in_place: ?usize = 0; + pub const accepts = any; + + pub fn spec(name: []const u8, _: u32) c.Spec { + return plain(name, .f16, &stream); + } + + pub fn sizes(s: c.Shape) [3]usize { + return .{ s.rows * s.n, s.rows * s.n, s.n }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * s.n; + } + + pub fn fill(rng: std.Random, mode: Fill, _: c.Shape, _: u32, v: *[3][]f64) void { + r.uniform(rng, v[0], -8, 8); + r.uniform(rng, v[1], -4, 4); + r.uniform(rng, v[2], -2, 2); + if (mode == .nonfinite) for (v, 0..) |col, i| r.plant(col, &.{ 3 + 5 * i, 1000 + i }); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [3]u64, o: u64, shape: c.Shape, _: u32) !void { + try idol.gateAdd(k, s, o, dev[1], dev[2], shape.rows, shape.n); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, _: u32, v: [3][]const f64, _: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + for (0..shape.rows * shape.n) |i| { + const x = v[0][i]; + const y = v[1][i]; + const g = v[2][i % shape.n]; + const gy = Range.of(g).mul(Range.of(y)).fp32(0.5).half(); + e.put(want, mag, i, r.h(x + r.h(g * y)), gy.add(Range.of(x)).fp32(0.5).half()); + } + } +}; + +/// The block linears' widths: attention's 3072 and 1024, the MLP's 4096 (GELU) and 1024, at every refiner. +const linears = [_]c.Shape{ wide(r.joint, 3 * r.hidden), wide(r.joint, r.ffn), wide(r.joint, r.hidden), wide(r.latent, r.ffn), wide(r.cond, r.ffn) }; + +/// torch's tanh GELU of an fp16 value as the kernel forms it in fp32 (tanhf within fn_ulps): value and range. +pub fn gelu(x: f64) struct { v: f64, r: Range } { + const c1 = r.f(0.7978845608028654); + const c2 = r.f(0.044715); + const v = 0.5 * x * (1 + std.math.tanh(c1 * (x + c2 * x * x * x))); + const xr = Range.of(x); + const t = Range.of(c2).mul(xr).fp32(0.5).mul(xr).fp32(0.5).mul(xr).fp32(0.5); + const inner = Range.of(c1).mul(xr.add(t).fp32(0.5)).fp32(0.5); + const th = inner.up(tanh).fp32(r.fn_ulps); + return .{ .v = v, .r = Range.of(0.5).mul(xr).mul(Range.of(1).add(th).fp32(0.5)).fp32(0.5) }; +} + +fn tanh(x: f64) f64 { + return std.math.tanh(x); +} + +/// tf_idol_bias: y = fp16(acc + b) from fp32 sums and an fp16 bias; variant 1 then takes fp16(GELU(y)). +pub const Bias = struct { + pub const kinds = [_]r.Kind{ .f32, .f16 }; + pub const out: r.Kind = .f16; + pub const in_place: ?usize = null; + pub const accepts = any; + + pub fn spec(name: []const u8, _: u32) c.Spec { + return plain(name, .f16, &linears); + } + + pub fn sizes(s: c.Shape) [2]usize { + return .{ s.rows * s.n, s.n }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * s.n; + } + + pub fn fill(rng: std.Random, mode: Fill, _: c.Shape, _: u32, v: *[2][]f64) void { + r.uniform(rng, v[0], -6, 6); + r.uniform(rng, v[1], -1, 1); + if (mode == .nonfinite) for (v, 0..) |col, i| r.plant(col, &.{ 11 + 7 * i, 2048 + i }); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [2]u64, o: u64, shape: c.Shape, variant: u32) !void { + try idol.bias(k, s, dev[0], dev[1], o, shape.rows, shape.n, variant == 1); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, variant: u32, v: [2][]const f64, _: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + for (0..shape.rows * shape.n) |i| { + const y = r.h(v[0][i] + v[1][i % shape.n]); + const yr = Range.of(v[0][i]).add(Range.of(v[1][i % shape.n])).fp32(0.5).half(); + if (variant != 1) { + e.put(want, mag, i, y, yr); + continue; + } + // GELU's ranges at both fp16 ends, and its minimum (-0.16997 at -0.7518) when the range holds it + const lo = gelu(yr.lo); + const hi = gelu(yr.hi); + const g = gelu(y); + var gr: Range = .{ .lo = @min(@min(lo.r.lo, hi.r.lo), g.r.lo), .hi = @max(@max(lo.r.hi, hi.r.hi), g.r.hi) }; + if (yr.lo <= -0.751 and yr.hi >= -0.753) gr.lo = @min(gr.lo, -0.1701); + e.put(want, mag, i, r.h(g.v), gr.half()); + } + } +}; + +/// tf_idol_cond: y = fp16((a + ba) + (c + bc)), the two condition projections' fp32 sums and biases. +pub const Cond = struct { + pub const kinds = [_]r.Kind{ .f32, .f32, .f32, .f32 }; + pub const out: r.Kind = .f16; + pub const in_place: ?usize = null; + pub const accepts = any; + const served = [_]c.Shape{wide(r.cond, r.hidden)}; + + pub fn spec(name: []const u8, _: u32) c.Spec { + return plain(name, .f16, &served); + } + + pub fn sizes(s: c.Shape) [4]usize { + return .{ s.rows * s.n, s.n, s.rows * s.n, s.n }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * s.n; + } + + pub fn fill(rng: std.Random, mode: Fill, _: c.Shape, _: u32, v: *[4][]f64) void { + for (v) |col| r.uniform(rng, col, -4, 4); + if (mode == .nonfinite) for (v, 0..) |col, i| r.plant(col, &.{ 17 + 3 * i, 3000 + i }); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [4]u64, o: u64, shape: c.Shape, _: u32) !void { + try idol.cond(k, s, dev[0], dev[1], dev[2], dev[3], o, shape.rows, shape.n); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, _: u32, v: [4][]const f64, _: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + for (0..shape.rows * shape.n) |i| { + const j = i % shape.n; + const a = Range.of(v[0][i]).add(Range.of(v[1][j])).fp32(0.5); + const b = Range.of(v[2][i]).add(Range.of(v[3][j])).fp32(0.5); + e.put(want, mag, i, r.h((v[0][i] + v[1][j]) + (v[2][i] + v[3][j])), a.add(b).fp32(0.5).half()); + } + } +}; + +/// tf_idol_bias32: y += b in fp32, in place over y (input 0): RePo's 256 gate | content sums, the output's 16. +pub const Bias32 = struct { + pub const kinds = [_]r.Kind{ .f32, .f32 }; + pub const out: r.Kind = .f32; + pub const in_place: ?usize = 0; + pub const accepts = any; + const served = [_]c.Shape{ wide(r.joint, 256), wide(r.latent, 256), wide(r.cond, 256), wide(r.latent, 16) }; + + pub fn spec(name: []const u8, _: u32) c.Spec { + return plain(name, .f32, &served); + } + + pub fn sizes(s: c.Shape) [2]usize { + return .{ s.rows * s.n, s.n }; + } + + pub fn count(s: c.Shape) usize { + return s.rows * s.n; + } + + pub fn fill(rng: std.Random, mode: Fill, _: c.Shape, _: u32, v: *[2][]f64) void { + r.uniform(rng, v[0], -10, 10); + r.uniform(rng, v[1], -1, 1); + if (mode == .nonfinite) for (v, 0..) |col, i| r.plant(col, &.{ 5 + 9 * i, 777 + i }); + } + + pub fn launch(k: *const idol.Kernels, s: cuda.Stream, dev: [2]u64, o: u64, shape: c.Shape, _: u32) !void { + try idol.bias32(k, s, o, dev[1], shape.rows, shape.n); + } + + pub fn ref(_: std.mem.Allocator, shape: c.Shape, _: u32, v: [2][]const f64, _: Sum, e: *r.Ends, want: []f64, mag: []f64) !void { + for (0..shape.rows * shape.n) |i| { + const b = v[1][i % shape.n]; + e.put(want, mag, i, r.f(v[0][i] + b), Range.of(v[0][i]).add(Range.of(b)).fp32(0.5)); + } + } +}; diff --git a/zig/tests/cuda/contract_limits.zig b/zig/tests/cuda/contract_limits.zig index 7ae85733fd2..acc133eb369 100644 --- a/zig/tests/cuda/contract_limits.zig +++ b/zig/tests/cuda/contract_limits.zig @@ -47,7 +47,7 @@ pub fn image(name: []const u8) error{UnknownContractImage}![]const u8 { if (std.mem.eql(u8, name, "h3_image_modulation")) return &h3_image_modulation.bytes; inline for (.{ "qwen4_projection", "qwen4_hc", "qwen4_gdn", "qwen4_ple", "gemma4_ple" }) |n| if (std.mem.eql(u8, name, n)) return @field(kk, n); - inline for (.{ "tree_round", "act_rows", "gdn_prep", "qk_rows", "norms", "moe", "experts", "qwen36_mtp", "nemotron_attention", "nemotron_route", "nemotron_latent", "qmm_group", "qmm_prefill", "lane_gemv", "prompt16", "qmmf", "ck_experts", "nvfp4_experts", "nvfp4_experts_tile", "nvfp4_experts32", "rank_sum", "prefill_attention", "vit", "embed_rows", "route_rows", "flashnext_gdn", "flashnext_batch", "flashnext_hc", "flashnext_attn", "flashnext_mtp", "qwen_vision", "exl3_linear", "exl3_experts", "exl3_candidate", "experts3", "experts3_prefill", "drama3", "drama3_fp8", "drama3_codec", "glm_mm", "glm_dflash", "glm_glue", "glm_ops", "glm_index", "nemotron_mamba", "sample", "qwen35", "qwen35_bf16_rows", "qwen35_keep", "qwen35_kv8", "w4a8_prefill", "qwen35_draft", "ck_lane", "gdn_train", "train_q4", "train_attn", "flashnext_train", "train", "attn_train", "qwen27_train", "tree_attention", "block_attention", "window_attention", "window_pages", "moe_glue", "dense_rows", "qmm", "flashnext_fact", "flashnext_hcf", "flashnext_fexp", "experts_rows", "nemotron_ops", "minimax_m3", "minimax_m3_attn", "experts_bf16", "nemo_audio", "moss_image", "lfm2_moe", "lfm2", "dots_mocr" }) |n| if (std.mem.eql(u8, name, n)) return @field(kk, n); + inline for (.{ "tree_round", "act_rows", "gdn_prep", "qk_rows", "norms", "moe", "experts", "qwen36_mtp", "nemotron_attention", "nemotron_route", "nemotron_latent", "qmm_group", "qmm_prefill", "lane_gemv", "prompt16", "qmmf", "ck_experts", "nvfp4_experts", "nvfp4_experts_tile", "nvfp4_experts32", "rank_sum", "prefill_attention", "vit", "embed_rows", "route_rows", "flashnext_gdn", "flashnext_batch", "flashnext_hc", "flashnext_attn", "flashnext_mtp", "qwen_vision", "exl3_linear", "exl3_experts", "exl3_candidate", "experts3", "experts3_prefill", "drama3", "drama3_fp8", "drama3_codec", "glm_mm", "glm_dflash", "glm_glue", "glm_ops", "glm_index", "nemotron_mamba", "sample", "qwen35", "qwen35_bf16_rows", "qwen35_keep", "qwen35_kv8", "w4a8_prefill", "qwen35_draft", "ck_lane", "gdn_train", "train_q4", "train_attn", "flashnext_train", "train", "attn_train", "qwen27_train", "tree_attention", "block_attention", "window_attention", "window_pages", "moe_glue", "dense_rows", "qmm", "flashnext_fact", "flashnext_hcf", "flashnext_fexp", "experts_rows", "nemotron_ops", "minimax_m3", "minimax_m3_attn", "experts_bf16", "nemo_audio", "moss_image", "idol", "lfm2_moe", "lfm2", "dots_mocr" }) |n| if (std.mem.eql(u8, name, n)) return @field(kk, n); if (std.mem.eql(u8, name, "contract_controls")) return if (options.controls) &controls.bytes else &.{}; return error.UnknownContractImage; } diff --git a/zig/tests/cuda/main.zig b/zig/tests/cuda/main.zig index d445b64d6f8..db84ca38938 100644 --- a/zig/tests/cuda/main.zig +++ b/zig/tests/cuda/main.zig @@ -117,197 +117,7 @@ const kolibri_layer_tests = @import("kolibri_layer_tests.zig"); const aot_fallback_tests = @import("aot_fallback_tests.zig"); const qwen_draft_frames = @import("qwen_draft_frames.zig"); -const usage = - \\usage: tf-cuda-test - \\ qwen4 synthetic native Qwen4: binary64 logits/tokens, state seams, lanes and copied drafts - \\ qwen-draft-frames MODEL DRAFTER IDS OUT native 27B DFlash frames: raw bytes equal across partitions, controls red - \\ experts-rows experts_rows.cu's windows and chunks against the decode kernel's one-row launches - \\ route-rows route_rows.cu's router logits and softmax top-k against float64 (synthetic rows) - \\ flashnext-fidelity-single MODEL FIXTURE OUTPUT single-rank reference isolation - \\ flashnext-fidelity-rank MODEL RANK PORT FIXTURE OUTPUT fixed-history full score rows - \\ flashnext-window-rank MODEL RANK PORT IDS_FILE two-rank serial/window and rollback parity - \\ flashnext-windows MODEL IDS_FILE several streams' windows in one shared verify against each alone - \\ flashnext-mtp-parity MODEL IDS_FILE several streams' MTP heads in one shared pass against each alone - \\ flashnext-score MODEL IDS_FILE decisions' label scores against a plain pass's last row - \\ flashnext-model-rank MODEL RANK PORT IDS_FILE explicit full-model replay experiment (no drafts) - \\ flashnext-rank RANK PORT [sum|eof|timeout|missing|eof-scatter|timeout-scatter|exchange] two-process collectives, failures, the expert exchange - \\ flashnext-draft-affine proposal-head affine projection against FP64 and row-count invariance - \\ flashnext-shared separate MXFP8 shared expert and reserved-slot scatter against FP64 - \\ flashnext-nvfp4-tp rank-local expert cuts and FP32 partials against FP64 (one GPU) - \\ flashnext-fp8-experts the MTP head's block-FP8 experts (512 x 640 x 2560) through moe_native.fp8 against FP64 - \\ moetile whole shared down writes only slot 10 with identical FP32 bytes - \\ moetile-contract shared down replacement gates and the planted control - \\ moetile-bench alternate shared-down plus scatter and direct-slot GPU timings - \\ nvfp4-fact NVFP4 experts' prompt tiles with the decode form's sums: its bytes at every row, FP64 - \\ nvfp4-b32 block 32 experts with csf0 scales: block 16's bytes on equal scales, each form and width - \\ nvfp4-nz5 NVFP4_NZ5's block 32 experts: E2M1's bytes with each +5 a 4 under a scale 1.25x as large - \\ lane-half lane half tiles (MXFP8, BF16): bytes equal to the 64-column tile, FP64, cold-weight time - \\ flashnext-dense-hc dense connection weights and FP32 normalization against FP64 - \\ flashnext-hc Flash Next's own hyper-connection and n-gram glue against float64 (synthetic rows) - \\ flashnext-attn Flash Next's own attention glue, pooling and block scores against float64 (synthetic) - \\ flashnext-gdn-heads [BASELINE] DeltaNet full/half bytes, optionally against a frozen flashnext_batch.fatbin - \\ flashnext-tp-heads MODEL each rank's cut in-projections and attention heads equal the whole layer's bytes - \\ flashnext-pages the attention glue's caches through a page table: paged == contiguous, float64, controls - \\ info driver, device and library versions - \\ smoke copies, fills, launches, argument packing, module globals - \\ shared-context Context.shared and Stream.borrowed as a library inside a host's process sees them - \\ graph stream capture, explicit graphs, node and whole-exec updates - \\ overhead [n] [reps] dependent one-thread kernels: plain stream vs one graph - \\ overhead-pdl [n] [reps] the same with programmatic dependent launch on every kernel - \\ launch-ex cuLaunchKernelEx: clusters, cooperative grid, PDL on a stream and in a graph - \\ ptx hand-written PTX through the driver JIT, and a refused broken image - \\ symbols every gdn fatbin instantiation resolves by its listed symbol - \\ cublaslt bf16 GEMM through cuBLASLt against an fp64 reference - \\ nccl one-rank NCCL all-reduce and all-gather - \\ rank-scatter [id] rank-order reduce-scatter (NCCL_COMM_ID or an id file) against an all-gather - \\ roce-gather [world] the RoCE all-gather against NCCL's (NCCL_COMM_ID; world 2 by default, any on a switch): every size, graph replays, 3000 mixed calls, time a call - \\ rank-sum the reduce-scatter's sum kernel alone, 2 to 5 ranks as each rank (one GPU, no NCCL) - \\ nccl-pair one rank of a multi-host communicator: send/recv with every peer, all-reduce, all-gather - \\ gdn-replay replay_kernel bits against the Python oracle's fixture - \\ gdn-tree tree_kernel bits against the Python oracle's fixture - \\ triton a Triton cubin's bits against the Python oracle's fixture - \\ norms RMS norm and the residual step against float64 references (synthetic) - \\ norm-rows bf16-residual and gated norms, token rows against float64 (synthetic) - \\ norm-tail bf16 residual tails (branch norm, scalar, MLX rounding) against float64 (synthetic) - \\ embed-rows MLX affine token rows (2 to 8 bits, bf16 scale) against float64 (synthetic) - \\ tree-round tree_round.cu's picks, batched verified trees and commits against core/tree_round - \\ act-rows SwiGLU, output gates, group sums, DFlash2's dynamic conv against float64 (synthetic) - \\ gdn-prep Gated DeltaNet conv, norms, g and beta against float64 (synthetic) - \\ qk-rows QK norm, RoPE and the cache write against float64 references (synthetic) - \\ sample sample.cu's keyed draws against the Metal rule's host references (synthetic rows) - \\ nemotron-draws Nemotron's batched draws and row kernels against the per-row path, byte for byte - \\ glue Nemotron's glue kernels against their host references at its shapes (synthetic rows) - \\ lfm2-kernels LFM2's glue kernels against their host references at d1's shapes (synthetic rows) - \\ pocket [reps] the pocket's two kernels against tf_pocket_rows byte for byte; reps > 0 times them too - \\ lfm2-attention LFM2's GQA prompt attention (head dim 64), causal and packed trees, against float64 (synthetic rows) - \\ lfm2-vision [MODEL] LFM2-VL's vision kernels against host references; MODEL adds features against CPU goldens - \\ radio REF MODEL RADIO's tower and projector rows against float32 references on the same pixels - \\ radio-processor REF PICS MODEL decoded RGB, processor pixels, float resizes and grids against the reference - \\ radio-kernels RADIO's float-patch cast and position rows against host references (synthetic rows) - \\ radio-attention the head-dim-80 tower attention's time at five sizes, outputs finite (synthetic rows) - \\ audio-check MODEL WAV OUT [layers] | audio-contract Transcribe's audio encoder: a clip's stages to OUT | gates 1-4 - \\ gdn-back DeltaNet input gradients against FP64 - \\ q4-back Affine input gradients against FP64 - \\ moe-back Expert and router input gradients against FP64 - \\ attn-back Gated attention input gradients against FP64 - \\ fn-hc-back Hyper-connection input gradients against FP64 - \\ fn-moe-back MoE and pocket input gradients against FP64 - \\ fn-pocket [reps] Pocket kernels against the row reference - \\ fn-back All component gradient cases - \\ window-profile MODEL WIDTHS IDS_FILE a decode window's GPU ms by kernel class (WIDTHS like 1,4,16), beside its graph - \\ tree-accept MODEL IDS_FILE COUNT OUT a greedy reply's MTP chain and level-1 runner-up branches at every position (JSON) - \\ chunk-costs MODEL IDS_FILE WIDTHS r rows as the decode window graph (r up to its window) and as a prompt chunk (any r) - \\ resume MODEL IDS_FILE prompt states kept at off-grid rows: each resumed pass against a fresh one, byte for byte - \\ marks MODEL IDS_FILE N PATTERNS states kept inside chunks against chunks cut at the same rows, byte for byte - \\ prompt-cuts MODEL IDS_FILE a prompt keeping states inside chunks and at their ends (background passes too), and resumed from each, equals one uncut pass - \\ prompt-segments MODEL IDS_FILE a prompt run as 2 to 4 staggered segments a call equals one uncut pass, byte for byte - \\ cached-plans-tp2 MODEL IDS_FILE rank-zero cached plans and prompt resumes with the existing expert rank - \\ shared-fork MODEL the latent MoE's shared expert on the side stream (held back), lone and in shared windows of 2/4/8 streams, against one stream, byte for byte - \\ recapture MODEL graphs captured again while another sequence is bound: both keep their sampling rules - \\ paged MODEL IDS_FILE a paged sequence against the own one: prompt pass, decode, resumes across page edges - \\ grouped-plan the shared expert plan against experts.route's bytes (oracle/grouped_plan.py) - \\ fp8-lane block-FP8 projections against the Python lane matmul's bytes (oracle/fp8_lane.py) - \\ fp8-experts grouped block-FP8 experts against recorded fixture bytes - \\ nvfp4-experts grouped NVFP4 experts against recorded fixture bytes - \\ bf16-experts [contract] grouped bf16 experts against float64 (repack, up, downs, rows, forms); contract: gates 1-4, controls red - \\ projection-f32 FP32 projection outputs against FP64, rounding and row/reduction invariance - \\ mxfp8 MXFP8 strided projections against FP64 and row-count invariance - \\ quant-ref FP8 and NVFP4 projections and experts against float64 references (synthetic) - \\ affine8 MLX affine 2 to 8-bit tiles and the 8-bit lane_gemv: widened codes, float64, rows (synthetic) - \\ native-fp -Dnative-fp-decode: hardware e2m1/e4m3 pair decode equals software on every finite input - \\ affine4-decode affine-4 decode at the Qwen3.5 shapes: row counts and segmented launches byte for byte - \\ w4a8 int8-activation prompt matmuls on affine-4 tiles: float64 of their formula, rows (synthetic) - \\ carveout [MiB] [card] GB10 display memory: round trips and bandwidth (SKIP without the card) - \\ nvfp4 NVFP4 projections against recorded lane-matmul and prompt-GEMM fixture bytes - \\ moe softmax routing and SwiGLU experts against host references, then moe-live - \\ moe-live a captured bucket's padding rows: never routed, planned or combined (synthetic) - \\ moe-router-bench tf_moe_router against its register tiles by row count, alternating (35B-A3B shape) - \\ experts3 [reps] affine-3 packing and outputs against affine-4 and fp64; reps > 0 times decode - \\ ggml Bolt's IQ2_XXS experts and Q8_0 / IQ2_XXS dense rows on real tensors against fp64 (tools/zig/bolt_ggml_fixture.py) - \\ ggml-bench IQ2_XXS expert and Q8_0 lm_head decode GB/s (synthetic blocks) - \\ modelopt ModelOpt repack, FP8 and BF16 lane rows and relu^2 NVFP4 experts against fp64 - \\ checkpoint checkpoint prompt tiles, NVFP4 up rows and share sums byte-equal to the decode path (synthetic FP8 and NVFP4) - \\ exlr8 EXLR8 projections: every codebook state, FP64, row windows, the Metal frozen digests - \\ exlr8-bench DIR [MANIFEST] [LAYER] [SETS] a real EXLR8 layer: FP64, row windows, then GB/s by stage - \\ exlr8-dense [DIR] EXLR8 dense formats: decode bit-equal, FP64, row windows; DIR adds the real matrices - \\ tree tree attention (committed keys and paths) against float64 references (synthetic) - \\ block DFlash block attention over windowed contexts against float64 (synthetic) - \\ window sliding-window attention against float64 references (synthetic) - \\ window-rows window attention at head dims 256 and 512 against float64 ranges (synthetic) - \\ window-pages-512 head dim 512 (and 256 windowed) rows over shuffled pages: the reference bits (synthetic) - \\ window-bench WHICH window attention's GPU time: callers (Kolibri-1's shapes) or gemma (head dims 256, 512) - \\ moe-glue sigmoid top-k routing and the weighted combine against float64 references (synthetic) - \\ dense-rows bf16 rows times weight rows (routers, heads) against float64 references (synthetic) - \\ exl3 [dir] EXL3 decode-row linear: float64 checks, row invariance, the Python engine's fixture (dir none skips it) - \\ exl3-shapes [rows] the 27B's EXL3 shapes once each at plan()'s launch (1 and 16 rows), for ncu - \\ exl3-midm the mid-M kernels, linear_wc and the projection groups against the linear, byte for byte - \\ exl3-plans [shape] the 27B's EXL3 shapes: every (K splits, warps) and layout timed at 1 and 16 rows - \\ exl3-contract EXL3's replacements of linear_body through gates 1-4, each control red (kernel-contract's subset) - \\ exl3-tp2 [dir] EXL3 tensor parallel: rank shards vs the Python engine's, all-gathered (dir none skips them) - \\ exl3-tiles [DIR] EXL3's tile candidate: codebooks and tiles bit-equal, FP64, rows through qlinear and Dense - \\ train-pack MODEL EXAMPLES [COUNT] training passes holding several sequences against one a pass: differences, time - \\ kernel-contract [WORD...] the contract's gates, each planted control red (-Dnvcc); WORDs: kernels named so - \\ qmm-prefill-many-contract the GB10 bit-exact multi-projection prompt launch against separate launches - \\ qmm-prefill-tile22-contract the GB10 large-prompt 2x2 tile against the default tile - \\ qmmf-prompt BF16 K32 prompt staging: parent K64 bytes at current Flash Next shapes - \\ qmmf-prompt-contract K64 and K32 replacement gates with both new output controls - \\ qmmf-prompt-repro isolate M=65 N=8240 K=2560 SK=4 BF16 without clusters - \\ qmmf-prompt-bench rank0 normal-main weighted A-B-A timings, plus separate MTP hidden timings - \\ qmm-prefill-many-bench same-process A-B-A screening for the GB10 launch fusion - \\ prompt-swiglu-contract the lean gate/up SwiGLU pair against two products and the act kernel, controls red - \\ prompt-swiglu-bench same-process A-B-A: the lean SwiGLU pair against two products and the act kernel - \\ mtp-rows tf_q36m_attn_rows: gates 1-4 (byte-equal to tf_q36m_attn a segment) and float64 alone - \\ qwen-pages qwen35.cu's attention cache through a page table: paged == contiguous, float64, red controls - \\ qwen-shared-prefix [time] attn_rows's classes across streams on shared pages == each stream alone, red controls; time: A/B - \\ qwen-norm-shift qwen35.cu's _shift norms (BF16 checkpoints): 1 + w in FP32 within a BF16 ulp of float64, red controls - \\ clef tiny DIR | head MODEL CASES OUT [--piece N] Clef's joint schema head: the tiny fixture, gate 3's logits - \\ qwen-pending qwen35's pending kept rows: the slot scans and tf_q35k_apply_pend == tf_q35k_apply, red controls - \\ rope-yarn YaRN rope in tf_q35_rope, tf_q35_rope8 and tf_q36m_norm_rope against float64, to 1M - \\ kernel-contract-limits DIR each registered launch against release SMs or sm_110 in DIR's fatbins - \\ pocket-contract Nemotron's pocket kernels (learned neurons) through gates 1-4, controls red - \\ flashnext-modelopt-contract Flash Next NVFP4's BF16 dense and FP8 MTP-expert downs through gates 1-4 - \\ minimax-contract MiniMax-M3.1-Flash's indexer and block-sparse attention through gates 1-4, controls red - \\ moss-contract MOSS-Image's own kernels and its full attention through gates 1-4, controls red - \\ glm-exl3 GLM's EXL3 routed experts, decode and prompt, against float64 (synthetic) - \\ glm-kda-pad-split TF_GLM_KDA_PAD's padding of the bf16 and split KDA stacks at TP=3 (synthetic) - \\ glm-vision MODEL F32 BF16 IMG GLM's image tower and preparation against vision_ref.py's torch runs - \\ glm-mm-fixed Prompt K policies: FP64, every row alone/batched, offsets and guarded tails - \\ glm-mm-bench GLM's bf16 linears: b16.matmul against glm_mm, by rows (one GPU) - \\ glm-index-check GLM's indexer with glm_index against tf_glm_scores and tf_glm_select_rows, byte for byte (one GPU) - \\ glm-kv-host-slots TF_GLM_KV_HOST's gather past its slots is refused as error.GlmKvHostSlots, then one within (one GPU) - \\ glm-ref GLM projections (matmuls, router, attention, indexer, hc) against float64 (synthetic) - \\ glm-lanes-cover copy drafts, cancels, discards, eos and max_new on one lanes.Engine across requests - \\ glm-lanes-concurrent concurrent streams on one lanes.Engine, each against its solo run - \\ glm-shared-check shared verify windows against lone twins, logits and states byte for byte - \\ glm-pair-check paired prompt steps against twins a chunk a step, logits and states byte for byte - \\ glm-split-check prompt chunks with their indexer rows split across ranks against whole twins, byte for byte - \\ glm-solo-check solo prompt passes against twins a chunk a step, logits and states byte for byte - \\ glm-tap-split-check DFlash2 prompt taps: split and ring retained taps against gather, byte for byte, every rank - \\ glm-paged-check a paged stream (pages out of order, NaN first) against a whole-window twin - \\ dory MODEL LOOPS N TEXT Dory (NVFP4): N greedy tokens from TEXT, then verify windows of 2 to 16 rows bit-equal - \\ dory-serve MODEL LOOPS TEXT N Dory served: eager == graphs, copy drafts == plain, 2/4/8 streams == solo - \\ dory-states MODEL LOOPS TEXT N Dory kept prompt states at 8k and 32k resumed into wiped caches == fresh - \\ dory-bench MODEL LOOPS TEXT N [STREAMS...] Dory greedy decode tok/s at 1/2/4/8 streams (graphs on) - \\ dory-pages MODEL LOOPS TEXT N Dory with its full caches in pages == contiguous: fp32 logits bytes, then replies - \\ dory-store MODEL LOOPS TEXT N Dory prompts as pool pages (DORY_PAGED=1): resumes and shared streams == fresh - \\ dory-prefill MODEL LOOPS TEXT N Dory prompt time alone at 512, 2k, 8k and 16k rows (DORY_PAGED=1: on pages) - \\ gemma4-states MODEL DRAFTER TEXT N Gemma 4 + DFlash: stepped passes keep the drafter's context, resumed == fresh - \\ spark25-pages MODEL TEXT N Spark2.5: full-layer caches in pool pages == linear ones, replies and logits - \\ gemma4-pages MODEL TEXT N [DRAFTER] Gemma 4: global caches in pool pages == linear ones, replies and logits - \\ gemma4-ple Gemma 4 E-series: per-layer input rows bit-equal to the host steps - \\ gemma4-e4b-force MODEL REF OUT NAME... Gemma 4 E4B: a reference's tokens forced, logits as .npy - \\ kolibri-reference MODEL IDS Kolibri-1's layer 0 and head against float64 from the checkpoint (prompt and decode rows) - \\ kolibri-layers MODEL IDS Kolibri-1's window edge (513 keys) and its fifth layer's full reach, on the checkpoint - \\ kolibri-full MODEL IDS N Kolibri-1: eager rows, steps, drafted, sampled, shared rounds, cuts and kept states alike - \\ kolibri-pages MODEL TEXT N Kolibri-1: full layers in pool pages == linear caches, replies and logits - \\ kolibri-greedy MODEL PROMPTS N OUT Kolibri-1 greedy from each prompt (JSON id lists): ids and top-2 margins - \\ kolibri-logits MODEL IDS OUT [PROMPTS] Kolibri-1's teacher-forced fp32 logits of 2,048 prompt rows; each prompt's last - \\ glm-synth [fp8pb|local] a synthetic GLM-5.3-Flash checkpoint (2 layers, 16 experts) and its dc.json for the lane checks - \\ glm-loader-gate every rank's uploads at TP 1, 2 and 3 against the checkpoint cut on the host, byte for byte - \\ glm-fp8g-shares block-FP8 TP shares packed as GLM's loader packs them, on the lane, against FP64 of the cut - \\ aot-fallback a launch's 1 from the runtime-parameter variant: the folded variant's bits (#1003) - \\ -; +const usage = @import("main_usage.zig").usage; pub fn main(init: std.process.Init) !u8 { const args = try init.minimal.args.toSlice(init.arena.allocator()); @@ -541,6 +351,7 @@ fn run(gpu: check.Gpu, cmd: []const u8, rest: []const [:0]const u8) !void { if (std.mem.eql(u8, cmd, "pocket-contract")) return @import("contract_pocket.zig").run(gpu); if (std.mem.eql(u8, cmd, "flashnext-modelopt-contract")) return @import("contract_flashnext_modelopt.zig").run(gpu); if (std.mem.eql(u8, cmd, "moss-contract")) return @import("contract_moss_image.zig").run(gpu); + if (std.mem.eql(u8, cmd, "idol-contract")) return @import("contract_idol.zig").run(gpu); if (std.mem.eql(u8, cmd, "tree")) return tree_tests.run(gpu); if (std.mem.eql(u8, cmd, "block")) return block_tests.run(gpu); if (std.mem.eql(u8, cmd, "window")) return window_tests.run(gpu); diff --git a/zig/tests/cuda/main_usage.zig b/zig/tests/cuda/main_usage.zig new file mode 100644 index 00000000000..95f777b63e1 --- /dev/null +++ b/zig/tests/cuda/main_usage.zig @@ -0,0 +1,194 @@ +//! Command help for the CUDA test runner. + +pub const usage = + \\usage: tf-cuda-test + \\ qwen4 synthetic native Qwen4: binary64 logits/tokens, state seams, lanes and copied drafts + \\ qwen-draft-frames MODEL DRAFTER IDS OUT native 27B DFlash frames: raw bytes equal across partitions, controls red + \\ experts-rows experts_rows.cu's windows and chunks against the decode kernel's one-row launches + \\ route-rows route_rows.cu's router logits and softmax top-k against float64 (synthetic rows) + \\ flashnext-fidelity-single MODEL FIXTURE OUTPUT single-rank reference isolation + \\ flashnext-fidelity-rank MODEL RANK PORT FIXTURE OUTPUT fixed-history full score rows + \\ flashnext-window-rank MODEL RANK PORT IDS_FILE two-rank serial/window and rollback parity + \\ flashnext-windows MODEL IDS_FILE several streams' windows in one shared verify against each alone + \\ flashnext-mtp-parity MODEL IDS_FILE several streams' MTP heads in one shared pass against each alone + \\ flashnext-score MODEL IDS_FILE decisions' label scores against a plain pass's last row + \\ flashnext-model-rank MODEL RANK PORT IDS_FILE explicit full-model replay experiment (no drafts) + \\ flashnext-rank RANK PORT [sum|eof|timeout|missing|eof-scatter|timeout-scatter|exchange] two-process collectives, failures, the expert exchange + \\ flashnext-draft-affine proposal-head affine projection against FP64 and row-count invariance + \\ flashnext-shared separate MXFP8 shared expert and reserved-slot scatter against FP64 + \\ flashnext-nvfp4-tp rank-local expert cuts and FP32 partials against FP64 (one GPU) + \\ flashnext-fp8-experts the MTP head's block-FP8 experts (512 x 640 x 2560) through moe_native.fp8 against FP64 + \\ moetile whole shared down writes only slot 10 with identical FP32 bytes + \\ moetile-contract shared down replacement gates and the planted control + \\ moetile-bench alternate shared-down plus scatter and direct-slot GPU timings + \\ nvfp4-fact NVFP4 experts' prompt tiles with the decode form's sums: its bytes at every row, FP64 + \\ nvfp4-b32 block 32 experts with csf0 scales: block 16's bytes on equal scales, each form and width + \\ nvfp4-nz5 NVFP4_NZ5's block 32 experts: E2M1's bytes with each +5 a 4 under a scale 1.25x as large + \\ lane-half lane half tiles (MXFP8, BF16): bytes equal to the 64-column tile, FP64, cold-weight time + \\ flashnext-dense-hc dense connection weights and FP32 normalization against FP64 + \\ flashnext-hc Flash Next's own hyper-connection and n-gram glue against float64 (synthetic rows) + \\ flashnext-attn Flash Next's own attention glue, pooling and block scores against float64 (synthetic) + \\ flashnext-gdn-heads [BASELINE] DeltaNet full/half bytes, optionally against a frozen flashnext_batch.fatbin + \\ flashnext-tp-heads MODEL each rank's cut in-projections and attention heads equal the whole layer's bytes + \\ flashnext-pages the attention glue's caches through a page table: paged == contiguous, float64, controls + \\ info driver, device and library versions + \\ smoke copies, fills, launches, argument packing, module globals + \\ shared-context Context.shared and Stream.borrowed as a library inside a host's process sees them + \\ graph stream capture, explicit graphs, node and whole-exec updates + \\ overhead [n] [reps] dependent one-thread kernels: plain stream vs one graph + \\ overhead-pdl [n] [reps] the same with programmatic dependent launch on every kernel + \\ launch-ex cuLaunchKernelEx: clusters, cooperative grid, PDL on a stream and in a graph + \\ ptx hand-written PTX through the driver JIT, and a refused broken image + \\ symbols every gdn fatbin instantiation resolves by its listed symbol + \\ cublaslt bf16 GEMM through cuBLASLt against an fp64 reference + \\ nccl one-rank NCCL all-reduce and all-gather + \\ rank-scatter [id] rank-order reduce-scatter (NCCL_COMM_ID or an id file) against an all-gather + \\ roce-gather [world] the RoCE all-gather against NCCL's (NCCL_COMM_ID; world 2 by default, any on a switch): every size, graph replays, 3000 mixed calls, time a call + \\ rank-sum the reduce-scatter's sum kernel alone, 2 to 5 ranks as each rank (one GPU, no NCCL) + \\ nccl-pair one rank of a multi-host communicator: send/recv with every peer, all-reduce, all-gather + \\ gdn-replay replay_kernel bits against the Python oracle's fixture + \\ gdn-tree tree_kernel bits against the Python oracle's fixture + \\ triton a Triton cubin's bits against the Python oracle's fixture + \\ norms RMS norm and the residual step against float64 references (synthetic) + \\ norm-rows bf16-residual and gated norms, token rows against float64 (synthetic) + \\ norm-tail bf16 residual tails (branch norm, scalar, MLX rounding) against float64 (synthetic) + \\ embed-rows MLX affine token rows (2 to 8 bits, bf16 scale) against float64 (synthetic) + \\ tree-round tree_round.cu's picks, batched verified trees and commits against core/tree_round + \\ act-rows SwiGLU, output gates, group sums, DFlash2's dynamic conv against float64 (synthetic) + \\ gdn-prep Gated DeltaNet conv, norms, g and beta against float64 (synthetic) + \\ qk-rows QK norm, RoPE and the cache write against float64 references (synthetic) + \\ sample sample.cu's keyed draws against the Metal rule's host references (synthetic rows) + \\ nemotron-draws Nemotron's batched draws and row kernels against the per-row path, byte for byte + \\ glue Nemotron's glue kernels against their host references at its shapes (synthetic rows) + \\ lfm2-kernels LFM2's glue kernels against their host references at d1's shapes (synthetic rows) + \\ pocket [reps] the pocket's two kernels against tf_pocket_rows byte for byte; reps > 0 times them too + \\ lfm2-attention LFM2's GQA prompt attention (head dim 64), causal and packed trees, against float64 (synthetic rows) + \\ lfm2-vision [MODEL] LFM2-VL's vision kernels against host references; MODEL adds features against CPU goldens + \\ radio REF MODEL RADIO's tower and projector rows against float32 references on the same pixels + \\ radio-processor REF PICS MODEL decoded RGB, processor pixels, float resizes and grids against the reference + \\ radio-kernels RADIO's float-patch cast and position rows against host references (synthetic rows) + \\ radio-attention the head-dim-80 tower attention's time at five sizes, outputs finite (synthetic rows) + \\ audio-check MODEL WAV OUT [layers] | audio-contract Transcribe's audio encoder: a clip's stages to OUT | gates 1-4 + \\ gdn-back DeltaNet input gradients against FP64 + \\ q4-back Affine input gradients against FP64 + \\ moe-back Expert and router input gradients against FP64 + \\ attn-back Gated attention input gradients against FP64 + \\ fn-hc-back Hyper-connection input gradients against FP64 + \\ fn-moe-back MoE and pocket input gradients against FP64 + \\ fn-pocket [reps] Pocket kernels against the row reference + \\ fn-back All component gradient cases + \\ window-profile MODEL WIDTHS IDS_FILE a decode window's GPU ms by kernel class (WIDTHS like 1,4,16), beside its graph + \\ tree-accept MODEL IDS_FILE COUNT OUT a greedy reply's MTP chain and level-1 runner-up branches at every position (JSON) + \\ chunk-costs MODEL IDS_FILE WIDTHS r rows as the decode window graph (r up to its window) and as a prompt chunk (any r) + \\ resume MODEL IDS_FILE prompt states kept at off-grid rows: each resumed pass against a fresh one, byte for byte + \\ marks MODEL IDS_FILE N PATTERNS states kept inside chunks against chunks cut at the same rows, byte for byte + \\ prompt-cuts MODEL IDS_FILE a prompt keeping states inside chunks and at their ends (background passes too), and resumed from each, equals one uncut pass + \\ prompt-segments MODEL IDS_FILE a prompt run as 2 to 4 staggered segments a call equals one uncut pass, byte for byte + \\ cached-plans-tp2 MODEL IDS_FILE rank-zero cached plans and prompt resumes with the existing expert rank + \\ shared-fork MODEL the latent MoE's shared expert on the side stream (held back), lone and in shared windows of 2/4/8 streams, against one stream, byte for byte + \\ recapture MODEL graphs captured again while another sequence is bound: both keep their sampling rules + \\ paged MODEL IDS_FILE a paged sequence against the own one: prompt pass, decode, resumes across page edges + \\ grouped-plan the shared expert plan against experts.route's bytes (oracle/grouped_plan.py) + \\ fp8-lane block-FP8 projections against the Python lane matmul's bytes (oracle/fp8_lane.py) + \\ fp8-experts grouped block-FP8 experts against recorded fixture bytes + \\ nvfp4-experts grouped NVFP4 experts against recorded fixture bytes + \\ bf16-experts [contract] grouped bf16 experts against float64 (repack, up, downs, rows, forms); contract: gates 1-4, controls red + \\ projection-f32 FP32 projection outputs against FP64, rounding and row/reduction invariance + \\ mxfp8 MXFP8 strided projections against FP64 and row-count invariance + \\ quant-ref FP8 and NVFP4 projections and experts against float64 references (synthetic) + \\ affine8 MLX affine 2 to 8-bit tiles and the 8-bit lane_gemv: widened codes, float64, rows (synthetic) + \\ native-fp -Dnative-fp-decode: hardware e2m1/e4m3 pair decode equals software on every finite input + \\ affine4-decode affine-4 decode at the Qwen3.5 shapes: row counts and segmented launches byte for byte + \\ w4a8 int8-activation prompt matmuls on affine-4 tiles: float64 of their formula, rows (synthetic) + \\ carveout [MiB] [card] GB10 display memory: round trips and bandwidth (SKIP without the card) + \\ nvfp4 NVFP4 projections against recorded lane-matmul and prompt-GEMM fixture bytes + \\ moe softmax routing and SwiGLU experts against host references, then moe-live + \\ moe-live a captured bucket's padding rows: never routed, planned or combined (synthetic) + \\ moe-router-bench tf_moe_router against its register tiles by row count, alternating (35B-A3B shape) + \\ experts3 [reps] affine-3 packing and outputs against affine-4 and fp64; reps > 0 times decode + \\ ggml Bolt's IQ2_XXS experts and Q8_0 / IQ2_XXS dense rows on real tensors against fp64 (tools/zig/bolt_ggml_fixture.py) + \\ ggml-bench IQ2_XXS expert and Q8_0 lm_head decode GB/s (synthetic blocks) + \\ modelopt ModelOpt repack, FP8 and BF16 lane rows and relu^2 NVFP4 experts against fp64 + \\ checkpoint checkpoint prompt tiles, NVFP4 up rows and share sums byte-equal to the decode path (synthetic FP8 and NVFP4) + \\ exlr8 EXLR8 projections: every codebook state, FP64, row windows, the Metal frozen digests + \\ exlr8-bench DIR [MANIFEST] [LAYER] [SETS] a real EXLR8 layer: FP64, row windows, then GB/s by stage + \\ exlr8-dense [DIR] EXLR8 dense formats: decode bit-equal, FP64, row windows; DIR adds the real matrices + \\ tree tree attention (committed keys and paths) against float64 references (synthetic) + \\ block DFlash block attention over windowed contexts against float64 (synthetic) + \\ window sliding-window attention against float64 references (synthetic) + \\ window-rows window attention at head dims 256 and 512 against float64 ranges (synthetic) + \\ window-pages-512 head dim 512 (and 256 windowed) rows over shuffled pages: the reference bits (synthetic) + \\ window-bench WHICH window attention's GPU time: callers (Kolibri-1's shapes) or gemma (head dims 256, 512) + \\ moe-glue sigmoid top-k routing and the weighted combine against float64 references (synthetic) + \\ dense-rows bf16 rows times weight rows (routers, heads) against float64 references (synthetic) + \\ exl3 [dir] EXL3 decode-row linear: float64 checks, row invariance, the Python engine's fixture (dir none skips it) + \\ exl3-shapes [rows] the 27B's EXL3 shapes once each at plan()'s launch (1 and 16 rows), for ncu + \\ exl3-midm the mid-M kernels, linear_wc and the projection groups against the linear, byte for byte + \\ exl3-plans [shape] the 27B's EXL3 shapes: every (K splits, warps) and layout timed at 1 and 16 rows + \\ exl3-contract EXL3's replacements of linear_body through gates 1-4, each control red (kernel-contract's subset) + \\ exl3-tp2 [dir] EXL3 tensor parallel: rank shards vs the Python engine's, all-gathered (dir none skips them) + \\ exl3-tiles [DIR] EXL3's tile candidate: codebooks and tiles bit-equal, FP64, rows through qlinear and Dense + \\ train-pack MODEL EXAMPLES [COUNT] training passes holding several sequences against one a pass: differences, time + \\ kernel-contract [WORD...] the contract's gates, each planted control red (-Dnvcc); WORDs: kernels named so + \\ qmm-prefill-many-contract the GB10 bit-exact multi-projection prompt launch against separate launches + \\ qmm-prefill-tile22-contract the GB10 large-prompt 2x2 tile against the default tile + \\ qmmf-prompt BF16 K32 prompt staging: parent K64 bytes at current Flash Next shapes + \\ qmmf-prompt-contract K64 and K32 replacement gates with both new output controls + \\ qmmf-prompt-repro isolate M=65 N=8240 K=2560 SK=4 BF16 without clusters + \\ qmmf-prompt-bench rank0 normal-main weighted A-B-A timings, plus separate MTP hidden timings + \\ qmm-prefill-many-bench same-process A-B-A screening for the GB10 launch fusion + \\ prompt-swiglu-contract the lean gate/up SwiGLU pair against two products and the act kernel, controls red + \\ prompt-swiglu-bench same-process A-B-A: the lean SwiGLU pair against two products and the act kernel + \\ mtp-rows tf_q36m_attn_rows: gates 1-4 (byte-equal to tf_q36m_attn a segment) and float64 alone + \\ qwen-pages qwen35.cu's attention cache through a page table: paged == contiguous, float64, red controls + \\ qwen-shared-prefix [time] attn_rows's classes across streams on shared pages == each stream alone, red controls; time: A/B + \\ qwen-norm-shift qwen35.cu's _shift norms (BF16 checkpoints): 1 + w in FP32 within a BF16 ulp of float64, red controls + \\ clef tiny DIR | head MODEL CASES OUT [--piece N] Clef's joint schema head: the tiny fixture, gate 3's logits + \\ qwen-pending qwen35's pending kept rows: the slot scans and tf_q35k_apply_pend == tf_q35k_apply, red controls + \\ rope-yarn YaRN rope in tf_q35_rope, tf_q35_rope8 and tf_q36m_norm_rope against float64, to 1M + \\ kernel-contract-limits DIR each registered launch against release SMs or sm_110 in DIR's fatbins + \\ pocket-contract Nemotron's pocket kernels (learned neurons) through gates 1-4, controls red + \\ flashnext-modelopt-contract Flash Next NVFP4's BF16 dense and FP8 MTP-expert downs through gates 1-4 + \\ minimax-contract MiniMax-M3.1-Flash's indexer and block-sparse attention through gates 1-4, controls red + \\ moss-contract MOSS-Image's own kernels and its full attention through gates 1-4, controls red + \\ idol-contract Idol's denoiser glue and head-64 attention through gates 1-4, controls red + \\ glm-exl3 GLM's EXL3 routed experts, decode and prompt, against float64 (synthetic) + \\ glm-kda-pad-split TF_GLM_KDA_PAD's padding of the bf16 and split KDA stacks at TP=3 (synthetic) + \\ glm-vision MODEL F32 BF16 IMG GLM's image tower and preparation against vision_ref.py's torch runs + \\ glm-mm-fixed Prompt K policies: FP64, every row alone/batched, offsets and guarded tails + \\ glm-mm-bench GLM's bf16 linears: b16.matmul against glm_mm, by rows (one GPU) + \\ glm-index-check GLM's indexer with glm_index against tf_glm_scores and tf_glm_select_rows, byte for byte (one GPU) + \\ glm-kv-host-slots TF_GLM_KV_HOST's gather past its slots is refused as error.GlmKvHostSlots, then one within (one GPU) + \\ glm-ref GLM projections (matmuls, router, attention, indexer, hc) against float64 (synthetic) + \\ glm-lanes-cover copy drafts, cancels, discards, eos and max_new on one lanes.Engine across requests + \\ glm-lanes-concurrent concurrent streams on one lanes.Engine, each against its solo run + \\ glm-shared-check shared verify windows against lone twins, logits and states byte for byte + \\ glm-pair-check paired prompt steps against twins a chunk a step, logits and states byte for byte + \\ glm-split-check prompt chunks with their indexer rows split across ranks against whole twins, byte for byte + \\ glm-solo-check solo prompt passes against twins a chunk a step, logits and states byte for byte + \\ glm-tap-split-check DFlash2 prompt taps: split and ring retained taps against gather, byte for byte, every rank + \\ glm-paged-check a paged stream (pages out of order, NaN first) against a whole-window twin + \\ dory MODEL LOOPS N TEXT Dory (NVFP4): N greedy tokens from TEXT, then verify windows of 2 to 16 rows bit-equal + \\ dory-serve MODEL LOOPS TEXT N Dory served: eager == graphs, copy drafts == plain, 2/4/8 streams == solo + \\ dory-states MODEL LOOPS TEXT N Dory kept prompt states at 8k and 32k resumed into wiped caches == fresh + \\ dory-bench MODEL LOOPS TEXT N [STREAMS...] Dory greedy decode tok/s at 1/2/4/8 streams (graphs on) + \\ dory-pages MODEL LOOPS TEXT N Dory with its full caches in pages == contiguous: fp32 logits bytes, then replies + \\ dory-store MODEL LOOPS TEXT N Dory prompts as pool pages (DORY_PAGED=1): resumes and shared streams == fresh + \\ dory-prefill MODEL LOOPS TEXT N Dory prompt time alone at 512, 2k, 8k and 16k rows (DORY_PAGED=1: on pages) + \\ gemma4-states MODEL DRAFTER TEXT N Gemma 4 + DFlash: stepped passes keep the drafter's context, resumed == fresh + \\ spark25-pages MODEL TEXT N Spark2.5: full-layer caches in pool pages == linear ones, replies and logits + \\ gemma4-pages MODEL TEXT N [DRAFTER] Gemma 4: global caches in pool pages == linear ones, replies and logits + \\ gemma4-ple Gemma 4 E-series: per-layer input rows bit-equal to the host steps + \\ gemma4-e4b-force MODEL REF OUT NAME... Gemma 4 E4B: a reference's tokens forced, logits as .npy + \\ kolibri-reference MODEL IDS Kolibri-1's layer 0 and head against float64 from the checkpoint (prompt and decode rows) + \\ kolibri-layers MODEL IDS Kolibri-1's window edge (513 keys) and its fifth layer's full reach, on the checkpoint + \\ kolibri-full MODEL IDS N Kolibri-1: eager rows, steps, drafted, sampled, shared rounds, cuts and kept states alike + \\ kolibri-pages MODEL TEXT N Kolibri-1: full layers in pool pages == linear caches, replies and logits + \\ kolibri-greedy MODEL PROMPTS N OUT Kolibri-1 greedy from each prompt (JSON id lists): ids and top-2 margins + \\ kolibri-logits MODEL IDS OUT [PROMPTS] Kolibri-1's teacher-forced fp32 logits of 2,048 prompt rows; each prompt's last + \\ glm-synth [fp8pb|local] a synthetic GLM-5.3-Flash checkpoint (2 layers, 16 experts) and its dc.json for the lane checks + \\ glm-loader-gate every rank's uploads at TP 1, 2 and 3 against the checkpoint cut on the host, byte for byte + \\ glm-fp8g-shares block-FP8 TP shares packed as GLM's loader packs them, on the lane, against FP64 of the cut + \\ aot-fallback a launch's 1 from the runtime-parameter variant: the folded variant's bits (#1003) + \\ +; diff --git a/zig/tests/fixtures/gradient-serving.tsv b/zig/tests/fixtures/gradient-serving.tsv index 87228dc7dae..e8894409cc3 100644 --- a/zig/tests/fixtures/gradient-serving.tsv +++ b/zig/tests/fixtures/gradient-serving.tsv @@ -44,7 +44,7 @@ zig/kernels/cuda/nemotron_mamba.cu dcaba12253d3931ae48c7ebd4e13dfb956f540ae19f4a zig/kernels/cuda/nemotron_ops.cu 2ef87c655b49d33214f8856d2ad775aacf6198ab2ca343f87fde588639ecccd1 raw #3124 zig/kernels/cuda/nemotron_route.cu 65da41432442f9fd99f73abefe87f34cf3c46b4971afe3c3557a48bca96f6511 raw commits 739c924de, 8cfdaa739, b77a33b08, 7f6f940eb, 05d0617af, bc76d90d6; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/kernels/cuda/norms.cu 89d3c6cea39fe3e1bf8d5a2fe60465f7ae272548f14711abb59ddac709d2d1db raw main d4541b00e0 (rms_scale shared; same SASS) -zig/kernels/cuda/nvfp4_experts.cu 9ef08b957b02e1a3ef2ee814aaf79ed15d85ada6b99e6cca2c1cadc1cadd6964 raw +zig/kernels/cuda/nvfp4_experts.cu cb54357e2c06252cc594cd1223401170dadefd995b0c67db0cae5edf628719d0 raw #2266 (decode cp.async rings, GB10 SASS unchanged) zig/kernels/cuda/nvfp4q.cuh 5fe4fa58568f2293bb72ccfa58b362ba2783b21a781e56946a5a2c328303d111 raw zig/kernels/cuda/prefill_attention.cu 905fff2c9018d778557a60ed2c81c24ce220adf5b092c8c32f8a1782963f9f28 raw main 82f3dde92 (pattn_kernel<64, 8, 4, 8> over paged caches), 94a9a48d6 (helpers to prefill_attention.cuh, SASS unchanged), 191061381 (#2609: two new pattn_kernel instances at two query heads a block, head dims 128 and 64; existing instances unchanged) zig/kernels/cuda/prefill_attention_rows.cuh 21975248a7ec9efd199a28324bba837e7b78f066a63b426ab26587cba38fda5e raw main 94a9a48d6 (helpers shared with the contract controls, SASS unchanged) @@ -85,7 +85,7 @@ zig/src/cuda/aot.zig bd4e41f32eebf8e75e6f40e036847aaca2900aee7628167552c661824c7 zig/src/cuda/carveout.zig 5ebe77d420ec42d1494fbe7259ce12e20e56427d8f7d931d672b7ca1240b1759 raw main 6a1feb26e (malformed TF_CUDA_CARVEOUT settings refused by name) zig/src/cuda/ck.zig 5b247901025d0f001e44c98e022729d007758ffd4719ec34b957c55dcc008e46 raw commits 739c924de, a79678c56, e40bd6eae, 186c31eed, a6f4044fc, c0a58fd30, 48ea204ac, e367c8f55, 7e082a6df; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/src/cuda/context.zig f7c911e93cccd4f89d4a80a8a8786c765a94864a2c22102ff128a018eb55ec1f raw commits ac38ad1da, cc50aef49, e9bf05ffd, ef23b5934; series patches 14-runtime-foundation.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate; #2914 (the release SM refusal before any retain) -zig/src/cuda/cublaslt.zig c6e3b8892cad23bd08c7d9843da8117670e3a881e0708a89cdf72f0cc7ad5c40 raw main f1ab10fe98 (Clef's joint schema head on the GPU; a new path), 52375ee098 (#2285: layout_cols, the split-K and reduction algo-config attributes and cublasLtMatmulAlgoConfigGetAttribute for Qwen3 embeddings; existing entries unchanged) +zig/src/cuda/cublaslt.zig d87f865fc03cf94bdcbe83504f74a6e569d70c10ca792b675122e9eadda26eec raw main f1ab10fe98 (Clef's joint schema head on the GPU; a new path), 52375ee098 (#2285: layout_cols, the split-K and reduction algo-config attributes and cublasLtMatmulAlgoConfigGetAttribute for Qwen3 embeddings; existing entries unchanged), #1767 (Linear.initTyped: X and W as bf16, fp16 or fp32 for Idol's denoiser; initEpilogue passes bf16, so existing plans are unchanged) zig/src/cuda/driver.zig f20856bd06afe9365ab9ca1bc39800ccb260ade2704197c033e1344a0c8dd742 raw commits e9bf05ffd, b923e554c, b2c75a98a; series patches 14-runtime-foundation.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/src/cuda/embed_rows.zig 09fb2e612f43297c19d2cb77d45139dd98212a20075da0a15069a70544f72f6b raw zig/src/cuda/exlr8.zig 1e2164096ae949a8a9a4903df82c7c0c184a6f5e1ba5ba4423038a42b0633fc6 raw @@ -93,7 +93,7 @@ zig/src/cuda/experts.zig 8bfc2f15a742cceba87dd7eb8e80f3f1b4e3f7eb323b557eb1bb4bf zig/src/cuda/fp8.zig a9caf312cb451dc95572b493e69ae211dd1e8b5be5b2c48cae3febd5d9327143 raw series patches 65-pr-1024.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/src/cuda/graph.zig 17639aaef0298c934b3f5ad3511925169c096ae57ede8ebee655faa838844f7b raw zig/src/cuda/grouped.zig 5fa1f39394b701eab59383bc7ed214ea3e17652a1229236df49f5281e6e764b5 raw commits e1be0806d; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate -zig/src/cuda/kernels.zig 6e19f32d3549d949cefda734e1540afd9a50779a8d8cefa796afd6fe8e9aea9d raw main 42735f94f0 (#2335: the mla image registered), f35900e60c (#2709: the dots_mocr image registered), #1630 (the experts_bf16 image registered), #2914 (covers: the release SM check), #1631 (the nemo_audio image registered) +zig/src/cuda/kernels.zig ead90d65f23d9b6255ee53d95d41bebce0710d86547e579ce9d588ea12fdd548 raw main 42735f94f0 (#2335: the mla image registered), f35900e60c (#2709: the dots_mocr image registered), #1630 (the experts_bf16 image registered), #2914 (covers: the release SM check), #1631 (the nemo_audio image registered), #1767 (the idol image registered) zig/src/cuda/launch.zig 9ec64848834d82ddcea85a6123e975c95a5ae2bf85c2a71772244794b0bcd705 raw series patches 14-runtime-foundation.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/src/cuda/memory.zig 7d2a91bfca8a08ae59df16ddf30d22226aba773cc814dd106930840ab344fc52 raw commits 5dcf77d7c, f630f1a90, e9bf05ffd, 881cccaa4, a34cb6ded; series patches 14-runtime-foundation.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/src/cuda/modelopt.zig 648c9ba58197af0ce905f8792383502fc44a52c45d1413fe9e21d28d04c22253 raw @@ -131,7 +131,7 @@ zig/src/families/flashnext/cuda_images.zig 5bd8a6c06cb69440522f4392794d9ef52b376 zig/src/families/flashnext/cuda_images_test.zig df984d54d9de1bb732544785cddf82a124de2a7019041ed1f7483b2a4a2d7c99 raw zig/src/families/flashnext/cuda_lanes.zig 8578e64c69611c219709f48a4ba646bfd01fa02d793d788ea7e577ae03d07808 raw main 4f6017ced (marks inside the pass), fbca90714 (shared solo-chunk rule, #2391), 80e0fd72c (#2753: non-finite draft rows refused by name; finite rows unchanged), dfd9ac5ef4 (#2585: TF_FLASHNEXT_* read through platform/environment.zig, malformed text refused at startup; valid values keep their meaning), #1953: the ladder's values through snap_intermediate, #3308 (loader host test updates the named startup-refusal expectations; no runtime edit to this pinned file); #3135 (kept_disk renamed kept_view for the shared kept image; no served change) zig/src/families/flashnext/cuda_lanes_admission_test.zig 4b8052db793ba81f0e73e1b9bd77b1780bbc4fd550d90976d017da47e76faaa2 raw -zig/src/families/flashnext/cuda_lanes_load.zig 241d091d4b5199325665d25ea5d4def81fd15660351a199773c596ca2025fa18 raw main dfd9ac5ef4 (#2585: TF_FLASHNEXT_* read through platform/environment.zig, malformed text refused at startup; valid values keep their meaning) +zig/src/families/flashnext/cuda_lanes_load.zig 26596c5f9bb0fb01b96cb96b50d51a70cf8ef1ef4f2af91e33e6f4a0c74a6f10 raw main dfd9ac5ef4 (#2585: TF_FLASHNEXT_* read through platform/environment.zig, malformed text refused at startup; valid values keep their meaning), #3467: after load a shard drops its page cache except the n-gram ranges, and the sweep reaches nested shards; tensors and replies are unchanged zig/src/families/flashnext/cuda_lanes_restore_test.zig f9947521a6d9c7d7380ca1b784a93a43b364c6fa5861cad15efd3538d2b8ceff raw zig/src/families/flashnext/cuda_launch.zig f8bebb5ed074e6c8ab8cef667cb01fa2bb1a2b2d6a4d3874a92291390278d9f7 raw exports cuda_moe_exchange.zig for its device test; no served change; #2837 (Flash Next TP=2 graph replay) zig/src/families/flashnext/cuda_media.zig 394601e8a807f5516f501efcaefa6fb3308f392ee322db7296b11c90814f8eea raw @@ -157,7 +157,7 @@ zig/src/families/flashnext/cuda_prompt.zig 64dfa63d6c9608d04b524689047f3f2bcf193 zig/src/families/flashnext/cuda_prompt_load.zig 334d68cfca85c15c9d986d0c6b4f8f2a38569309b21bdac6d365935d73c115cd raw zig/src/families/flashnext/cuda_prompt_main.zig 2543cd166dc80cd97b1ca1ce930a6150f9d36b52ee231744606f83bf54f0669d raw main dfd9ac5ef4 (#2585: the TF_FLASHNEXT_* startup check), c274b45cc1 (the check through the flashnext module) zig/src/families/flashnext/cuda_prompt_step.zig e04030fb4a4fdb8780704a1bc0b5ba4b786159ab08a927fe32a636a893129d0c raw -zig/src/families/flashnext/cuda_prompt_wt.zig 9f0b8f853cc33e23c3ae3785c7031721615fc043e240161c84fb945e499e809f raw +zig/src/families/flashnext/cuda_prompt_wt.zig 4885be0ea938cfba80b34fbe9c160d200226761a73f8bd9d785172cbc7cef9bb raw #3467: after load a shard drops its page cache except the n-gram ranges, and the sweep reaches nested shards; tensors and replies are unchanged zig/src/families/flashnext/cuda_qmm.zig 6d035feb053691cc9750a369c86a5463d41ed942764ad85b861bb628c106dccf raw zig/src/families/flashnext/cuda_rank_engine.zig df6a83bcf80edfd94ac4474dbbc2e73818d40b7532430399af73f2eb95ccfa33 raw zig/src/families/flashnext/cuda_rank_media.zig e5c268c8cf257934bb49fe401ba6213ea8b108258bbfd4d06edb990d568c3c2b raw diff --git a/zig/tests/glm_attn_ref.metal b/zig/tests/glm_attn_ref.metal new file mode 100644 index 00000000000..4e357a60eba --- /dev/null +++ b/zig/tests/glm_attn_ref.metal @@ -0,0 +1,109 @@ +// tf-glm-attn-rows' reference: GLM-5.3-Flash's latent attention kernels before their loads ran a step ahead. +#include +using namespace metal; +#include "../nax.h" +using namespace tfp; + +// fp32 parts of one output block added as one run would leave them: (0 + first) + second. +inline void glm_join(thread frag& c, thread const frag& d) { + c = (frag(0.0f) + c) + d; +} + +// S[64,n] = QK^T in 16-wide steps (heads 16 hg.., keys 32 kb..); halves: two 256-dim halves joined. +inline void glm_scores_at(const device bfloat* q, const device bfloat* keys, device bfloat* s, int n, bool halves, + int kb, int hg, uint lane) { + const int col0 = kb * 32, row0 = hg * 16; + const short2 home = frag_home(ushort(lane)); + frag c0 = 0.0f, c1 = 0.0f, d0 = 0.0f, d1 = 0.0f; + for (int k0 = 0; k0 < 512; k0 += 16) { + frag a, b0, b1; + frag_get_in(a, q, 512, row0, k0, home, 64, 512); + frag_get_t_in(b0, keys, 512, col0, k0, home, n, 512); + frag_get_t_in(b1, keys, 512, col0 + 16, k0, home, n, 512); + if (halves && k0 >= 256) { + mma_16x32(d0, d1, a, b0, b1); + } else { + mma_16x32(c0, c1, a, b0, b1); + } + } + if (halves) { + glm_join(c0, d0); + glm_join(c1, d1); + } + frag_put_in(c0, s, n, row0, col0, home, 64, n); + frag_put_in(c1, s, n, row0, col0 + 16, home, 64, n); +} + +// One row: simdgroup g heads 16 g.., a threadgroup 32 keys; arg.y: two 256-dim halves joined (fewer than 256 keys). +[[kernel]] void glm_latent_scores(const device bfloat* q [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* s [[buffer(2)]], constant int2& arg [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]]) { + glm_scores_at(q, keys, s, arg.x, arg.y != 0, int(tg.x), int(g), lane); +} + +// A window's rows at once: row z (grid z) has n0 + z keys; its query, scores and output `stride` apart. +struct GlmAttnRows { + int n0, q_stride, s_stride, o_stride; +}; + +// Each row as glm_latent_scores leaves it: heads 16 (tg.y * simdgroups + g).., keys 32 tg.x.. (past n: nothing). +[[kernel]] void glm_latent_scores_rows(const device bfloat* q [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* s [[buffer(2)]], constant GlmAttnRows& a [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint sgs [[simdgroups_per_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + const int z = int(tg.z), n = a.n0 + z; + if (int(tg.x) * 32 >= n) return; + glm_scores_at(q + size_t(z) * a.q_stride, keys, s + size_t(z) * a.s_stride, n, n < 256, int(tg.x), + int(tg.y * sgs + g), lane); +} + +// Keys [lo, hi) of O += P K in 16-wide steps: whole 256-key blocks, then the rest rounded up to 32 (zeros past hi). +inline void glm_values_run(thread frag& c0, thread frag& c1, const device bfloat* p, + const device bfloat* keys, int n, int lo, int hi, int row0, int col0, short2 home) { + const int len = hi - lo; + const int steps = (len / 256) * 16 + ((len % 256) + 31) / 32 * 2; + for (int i = 0; i < steps; ++i) { + const int k0 = lo + 16 * i; + frag a, b0, b1; + frag_get_in(a, p, n, row0, k0, home, 64, hi); + frag_get_in(b0, keys, 512, k0, col0, home, hi, 512); + frag_get_in(b1, keys, 512, k0, col0 + 16, home, hi, 512); + mma_16x32(c0, c1, a, b0, b1); + } +} + +// O[64,512] = PK in 16-wide steps (heads 16 hg.., dims 32 db..); part > 0: keys [0, part) apart. +inline void glm_values_at(const device bfloat* p, const device bfloat* keys, device bfloat* o, int n, int part, int db, + int hg, uint lane) { + const int col0 = db * 32, row0 = hg * 16; + const short2 home = frag_home(ushort(lane)); + frag c0 = 0.0f, c1 = 0.0f; + glm_values_run(c0, c1, p, keys, n, 0, part > 0 ? part : n, row0, col0, home); + if (part > 0) { + frag d0 = 0.0f, d1 = 0.0f; + glm_values_run(d0, d1, p, keys, n, part, n, row0, col0, home); + glm_join(c0, d0); + glm_join(c1, d1); + } + frag_put_in(c0, o, 512, row0, col0, home, 64, 512); + frag_put_in(c1, o, 512, row0, col0 + 16, home, 64, 512); +} + +// One row: simdgroup g heads 16 g.., a threadgroup 32 dims; arg.y > 0: keys [0, arg.y) apart. +[[kernel]] void glm_latent_values(const device bfloat* p [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* o [[buffer(2)]], constant int2& arg [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint lane [[thread_index_in_simdgroup]]) { + glm_values_at(p, keys, o, arg.x, arg.y, int(tg.x), int(g), lane); +} + +// Each row as glm_latent_values leaves it (past 1,024 keys the first 1,024 apart, as the one-row launch sets). +[[kernel]] void glm_latent_values_rows(const device bfloat* p [[buffer(0)]], const device bfloat* keys [[buffer(1)]], + device bfloat* o [[buffer(2)]], constant GlmAttnRows& a [[buffer(3)]], + uint3 tg [[threadgroup_position_in_grid]], uint g [[simdgroup_index_in_threadgroup]], + uint sgs [[simdgroups_per_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + const int z = int(tg.z), n = a.n0 + z; + glm_values_at(p + size_t(z) * a.s_stride, keys, o + size_t(z) * a.o_stride, n, n > 1024 ? 1024 : 0, int(tg.x), + int(tg.y * sgs + g), lane); +} diff --git a/zig/tests/glm_attn_rows.zig b/zig/tests/glm_attn_rows.zig new file mode 100644 index 00000000000..0aad753ee54 --- /dev/null +++ b/zig/tests/glm_attn_rows.zig @@ -0,0 +1,117 @@ +//! tf-glm-attn-rows: a window's dense rows in three launches, 1/16 query scale folded, against glm_scale + the ref. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const glm = tf.glm; +const R = glm.weights.Ref; + +const H = 64; +const RANK = 512; +const TOP = 2048; +const MAXR = 16; +const reps = 11; // MLA layers a round + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +const Bufs = struct { keys: mtl.Buffer, q: mtl.Buffer, qs: mtl.Buffer, s: [2]mtl.Buffer, p: [2]mtl.Buffer, o: [2]mtl.Buffer }; + +fn perRow(e: mtl.ComputeEncoder, x: *const glm.forward.Ctx, b: *const Bufs, side: usize, n0: u32, rows: u32) void { + const lat = H * RANK * 2; + const plane = H * TOP * 2; + glm.forward.scale(x, e, R{ .buf = b.q }, R{ .buf = b.qs }, rows * H, RANK, RANK, RANK, 1.0 / 16.0); + for (0..rows) |r| glm.forward.attendDense(x, e, R{ .buf = b.keys }, (R{ .buf = b.qs }).at(r * lat), (R{ .buf = b.s[side] }).at(r * plane), (R{ .buf = b.p[side] }).at(r * plane), (R{ .buf = b.o[side] }).at(r * lat), n0 + @as(u32, @intCast(r))); +} + +fn batched(e: mtl.ComputeEncoder, x: *const glm.forward.Ctx, b: *const Bufs, side: usize, n0: u32, rows: u32) void { + glm.forward.attendRows(x, e, R{ .buf = b.keys }, R{ .buf = b.q }, 1.0 / 16.0, R{ .buf = b.s[side] }, R{ .buf = b.p[side] }, R{ .buf = b.o[side] }, n0, rows); +} + +/// The launches before the fold: glm_scale's queries, then the rows' kernels on them (scale 1). +fn scaled(e: mtl.ComputeEncoder, x: *const glm.forward.Ctx, b: *const Bufs, side: usize, n0: u32, rows: u32) void { + glm.forward.scale(x, e, R{ .buf = b.q }, R{ .buf = b.qs }, rows * H, RANK, RANK, RANK, 1.0 / 16.0); + glm.forward.attendRows(x, e, R{ .buf = b.keys }, R{ .buf = b.qs }, 1.0, R{ .buf = b.s[side] }, R{ .buf = b.p[side] }, R{ .buf = b.o[side] }, n0, rows); +} + +fn run(q: mtl.Queue, comptime f: anytype, args: anytype, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |_| @call(.auto, f, .{e} ++ args); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, comptime f: anytype, args: anytype) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try run(q, f, args, reps); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +pub fn main(init: std.process.Init) !void { + const gpa = init.gpa; + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + const k = try glm.kernels.load(gpa, device); + const c: glm.config.Config = .{}; + const x: glm.forward.Ctx = .{ .k = k, .c = &c, .w = undefined, .s = undefined, .sc = undefined }; + const ref_src = try tf.frags.source(device, gpa, @embedFile("glm_attn_ref.metal")); + const ref_lib = try mtl.Library.fromSource(device, ref_src, mtl.CompileOptions.mlx()); + var kr = k.*; // the reference kernels in the production launches + kr.latent_scores = try mtl.Pipeline.init(device, ref_lib, "glm_latent_scores", false); + kr.latent_values = try mtl.Pipeline.init(device, ref_lib, "glm_latent_values", false); + kr.latent_scores_rows = try mtl.Pipeline.init(device, ref_lib, "glm_latent_scores_rows", false); + kr.latent_values_rows = try mtl.Pipeline.init(device, ref_lib, "glm_latent_values_rows", false); + const xr: glm.forward.Ctx = .{ .k = &kr, .c = &c, .w = undefined, .s = undefined, .sc = undefined }; + const opts = mtl.ResourceOptions.shared; + const planes = MAXR * H * TOP; + var b: Bufs = .{ .keys = try device.buffer((TOP + MAXR) * RANK * 2, opts), .q = try device.buffer(MAXR * H * RANK * 2, opts), .qs = try device.buffer(MAXR * H * RANK * 2, opts), .s = undefined, .p = undefined, .o = undefined }; + for (0..2) |i| { + b.s[i] = try device.buffer(planes * 2, opts); + b.p[i] = try device.buffer(planes * 2, opts); + b.o[i] = try device.buffer(MAXR * H * RANK * 2, opts); + } + var prng = std.Random.DefaultPrng.init(0x3a); + const r = prng.random(); + for (b.keys.slice(u16, (TOP + MAXR) * RANK)) |*v| v.* = toBf((r.float(f32) - 0.5) * 2); + // unscaled queries, with -0, zeros and values that scale to subnormals or near them among them + for (b.q.slice(u16, MAXR * H * RANK), 0..) |*v, i| v.* = if (i % 97 == 0) 0x8000 else if (i % 89 == 0) 0 else if (i % 83 == 0) toBf(1e-38) else if (i % 79 == 0) toBf(2e-37) else toBf((r.float(f32) - 0.5) * 4); + const cases = [_][2]u32{ .{ 1, 1 }, .{ 1, 16 }, .{ 5, 3 }, .{ 31, 2 }, .{ 33, 4 }, .{ 240, 16 }, .{ 255, 2 }, .{ 256, 1 }, .{ 400, 1 }, .{ 400, 2 }, .{ 400, 4 }, .{ 400, 8 }, .{ 700, 3 }, .{ 1010, 16 }, .{ 1024, 2 }, .{ 1500, 8 }, .{ 2033, 16 }, .{ 2048, 1 } }; + var outputs: usize = 0; + std.debug.print("GPU {s}: a window's dense rows in three launches against each row's reference launches ({d} layers a timing)\n", .{ device.name(), reps }); + for (cases) |cs| { + const n0 = cs[0]; + const rows = cs[1]; + for (0..2) |i| { + @memset(b.s[i].slice(u16, planes), 0x7fc1); + @memset(b.p[i].slice(u16, planes), 0x7fc1); + @memset(b.o[i].slice(u16, MAXR * H * RANK), 0x7fc1); + } + _ = try run(queue, perRow, .{ &xr, &b, 0, n0, rows }, 1); + _ = try run(queue, batched, .{ &x, &b, 1, n0, rows }, 1); + const same = std.mem.eql(u16, b.s[0].slice(u16, planes), b.s[1].slice(u16, planes)) and std.mem.eql(u16, b.p[0].slice(u16, planes), b.p[1].slice(u16, planes)) and std.mem.eql(u16, b.o[0].slice(u16, MAXR * H * RANK), b.o[1].slice(u16, MAXR * H * RANK)); + if (!same) { + std.debug.print("keys {d}, {d} rows: BITS DIFFER\n", .{ n0, rows }); + return error.BitsDiffer; + } + var n: usize = 0; + for (0..rows) |i| n += 2 * H * (n0 + i) + H * RANK; + outputs += n; + for (0..16) |_| _ = try run(queue, batched, .{ &xr, &b, 0, n0, rows }, reps); // clocks up + const t0 = try time(queue, batched, .{ &xr, &b, 0, n0, rows }); + const ts = try time(queue, scaled, .{ &x, &b, 1, n0, rows }); + const t1 = try time(queue, batched, .{ &x, &b, 1, n0, rows }); + std.debug.print(" keys {d:4}, {d:2} rows: reference window {d:7.1} us, scale and ours {d:7.1}, scale folded {d:7.1} us a layer\n", .{ n0, rows, t0, ts, t1 }); + } + std.debug.print("{d} outputs equal glm_scale then each row's own reference launches\n", .{outputs}); +} diff --git a/zig/tests/glm_hc_rows.zig b/zig/tests/glm_hc_rows.zig new file mode 100644 index 00000000000..1d04f10b7ee --- /dev/null +++ b/zig/tests/glm_hc_rows.zig @@ -0,0 +1,218 @@ +//! tf-glm-hc-rows: the boundary (expand parts, split on two) against one each, and the MoE-combining expand; time. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const hc = tf.glm.hc; +const glm = tf.glm; +const R = glm.weights.Ref; + +const D = 4096; +const F = 4 * D; +const boundaries = 90; // a round's +const pool_fn = 1024; // fn copies the timed boundaries walk (768 MB: past the GPU's caches) +const fn_bytes = 24 * F * 2; + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +const Io = struct { xo: mtl.Buffer, br: mtl.Buffer, ye: mtl.Buffer, wts: mtl.Buffer, post: mtl.Buffer, comb: mtl.Buffer, fns: mtl.Buffer, scale: mtl.Buffer, base: mtl.Buffer, norm: mtl.Buffer, out: [2]struct { xn: mtl.Buffer, part: mtl.Buffer, normed: mtl.Buffer, post: mtl.Buffer, comb: mtl.Buffer } }; +const TOPK = 8; +const M = 16; // rows at most + +/// The reference split (tests/glm_hc_split_one.metal): one group a row, sg 0's Sinkhorn before the collapse. +var split_one: mtl.Pipeline = undefined; + +fn bindSplit(e: mtl.ComputeEncoder, io: *const Io, side: usize, expand: bool) void { + const o = io.out[side]; + inline for (.{ if (expand) o.xn else io.xo, o.part, io.scale, io.base, io.norm }, 0..) |b, j| e.setBuffer(b, 0, j); + e.setValue(@as(f32, 1e-6), 5); + inline for (.{ o.normed, io.post, io.comb }, 6..) |b, j| e.setBuffer(b, 0, j); +} + +/// The split alone: the reference's one group a row (side 0) or core/hc.zig's (side 1). +fn split(e: mtl.ComputeEncoder, _: usize, pipes: hc.Pipes, io: *const Io, side: usize, rows: u32, expand: bool) void { + e.setPipeline(if (side == 0) split_one else pipes[2]); + bindSplit(e, io, side, expand); + e.dispatchGroups(mtl.Size.of(rows, if (side == 0) 1 else hc.split_groups, 1), mtl.Size.of(1024, 1, 1)); +} + +fn one(e: mtl.ComputeEncoder, i: usize, pipes: hc.Pipes, io: *const Io, side: usize, rows: u32, expand: bool, parts: bool) void { + const o = io.out[side]; + if (side == 0) { // the reference: the expand on one group a slice, then the one-group split + e.setPipeline(pipes[if (expand) 0 else 1]); + inline for (.{ io.xo, io.br, io.post, io.comb }, 0..) |b, j| e.setBuffer(b, 0, j); + const fnp = (R{ .buf = io.fns }).at((i % pool_fn) * fn_bytes); + e.setBuffer(fnp.buf, fnp.off, 4); + e.setBuffer(o.xn, 0, 5); + e.setBuffer(o.part, 0, 6); + e.dispatchGroups(mtl.Size.of(4 * D / 1024, rows, 1), mtl.Size.of(256, 1, 1)); + return split(e, i, pipes, io, side, rows, expand); + } + hc.boundaryWith(e, pipes, glm.kernels.hc_shape, expand, rows, 1e-6, .{ + .x_old = R{ .buf = io.xo }, + .branch = R{ .buf = io.br }, + .post = R{ .buf = io.post }, + .comb = R{ .buf = io.comb }, + .fn_packed = (R{ .buf = io.fns }).at((i % pool_fn) * fn_bytes), + .x_new = R{ .buf = o.xn }, + .part = R{ .buf = o.part }, + .scale = R{ .buf = io.scale }, + .base = R{ .buf = io.base }, + .norm = R{ .buf = io.norm }, + .normed = R{ .buf = o.normed }, + }, parts); + _ = o.post; +} + +/// A MoE layer's branch: the combine kernel then the boundary (side 0), or the combining expand (side 1); parts. +fn moeOne(e: mtl.ComputeEncoder, i: usize, k: *const glm.kernels.Kernels, io: *const Io, side: usize, rows: u32, parts: ?bool) void { + const o = io.out[side]; + if (side == 0) { + e.setPipeline(k.combine_0); + inline for (.{ io.ye, io.ye, io.wts }, 0..) |b, j| e.setBuffer(b, 0, j); + e.setBytes(std.mem.asBytes(&[2]i32{ @intCast(rows), TOPK }), 3); + e.setBuffer(io.br, 0, 4); + e.dispatchThreads(mtl.Size.of(rows * D, 1, 1), mtl.Size.of(256, 1, 1)); + } + const b = .{ .x_old = R{ .buf = io.xo }, .branch = R{ .buf = io.br }, .post = R{ .buf = io.post }, .comb = R{ .buf = io.comb }, .fn_packed = (R{ .buf = io.fns }).at((i % pool_fn) * fn_bytes), .x_new = R{ .buf = o.xn }, .part = R{ .buf = o.part }, .scale = R{ .buf = io.scale }, .base = R{ .buf = io.base }, .norm = R{ .buf = io.norm }, .normed = R{ .buf = o.normed } }; + if (side == 0) return hc.boundary(e, k.hc_core, glm.kernels.hc_shape, true, rows, 1e-6, b); + var m: struct { x_old: R, branch: R, post: R, comb: R, fn_packed: R, x_new: R, part: R, scale: R, base: R, norm: R, normed: R, wts: R } = undefined; + inline for (@typeInfo(@TypeOf(b)).@"struct".field_names) |n| @field(m, n) = @field(b, n); + m.branch = .{ .buf = io.ye }; + m.wts = .{ .buf = io.wts }; + if (parts) |p| return hc.boundaryWith(e, k.hc_core, glm.kernels.hc_shape, true, rows, 1e-6, m, p); + hc.boundary(e, k.hc_core, glm.kernels.hc_shape, true, rows, 1e-6, m); +} + +fn run(q: mtl.Queue, comptime f: anytype, args: anytype, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |i| @call(.auto, f, .{ e, i } ++ args); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, comptime f: anytype, args: anytype) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try run(q, f, args, boundaries); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +pub fn main(init: std.process.Init) !void { + const gpa = init.gpa; + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + const k = try glm.kernels.load(gpa, device); + const ref_src = try std.mem.concat(gpa, u8, &.{ try hc.source(gpa, glm.kernels.hc_shape), @embedFile("glm_hc_split_one.metal") }); + const ref_lib = try mtl.Library.fromSource(device, ref_src, mtl.CompileOptions.mlx()); + split_one = try mtl.Pipeline.init(device, ref_lib, "tf_hc_split_one", false); + const opts = mtl.ResourceOptions.shared; + var io: Io = undefined; + io.xo = try device.buffer(M * F * 2, opts); + io.br = try device.buffer(M * D * 2, opts); + io.ye = try device.buffer(M * (TOPK + 1) * D * 2, opts); + io.wts = try device.buffer(M * TOPK * 4, opts); + io.post = try device.buffer(M * 4 * 4, opts); + io.comb = try device.buffer(M * 16 * 4, opts); + io.fns = try device.buffer(pool_fn * fn_bytes, opts); + io.scale = try device.buffer(16, opts); + io.base = try device.buffer(24 * 4, opts); + io.norm = try device.buffer(D * 2, opts); + for (&io.out) |*o| o.* = .{ .xn = try device.buffer(M * F * 2, opts), .part = try device.buffer(M * hc.partBytes(glm.kernels.hc_shape), opts), .normed = try device.buffer(M * D * 2, opts), .post = try device.buffer(M * 4 * 4, opts), .comb = try device.buffer(M * 16 * 4, opts) }; + var prng = std.Random.DefaultPrng.init(0x4c); + const r = prng.random(); + io.scale.slice(f32, 3)[0..3].* = .{ 0.9, 1.1, 0.7 }; + var post0: [M * 4]f32 = undefined; + var comb0: [M * 16]f32 = undefined; + var outs: [2][2][M * 16]f32 = undefined; + std.debug.print("GPU {s}: a round's {d} boundaries; the expand on six groups a slice (to 4 rows) and the split on two a row, against one each\n", .{ device.name(), boundaries }); + var checked: usize = 0; + for (0..2) |draw| for ([_]u32{ 1, 2, 3, 4, 8, 16 }) |rows| for ([_]bool{ true, false }) |expand| { + if (rows == 1 and expand) { // draw 1: wider values, zeros, -0 and large streams among them + const w: f32 = if (draw == 0) 1 else 16; + for (io.xo.slice(u16, M * F), 0..) |*v, i| v.* = if (draw == 1 and i % 61 == 0) 0x8000 else if (draw == 1 and i % 67 == 0) toBf(3e4) else toBf((r.float(f32) - 0.5) * 4 * w); + for (io.br.slice(u16, M * D)) |*v| v.* = toBf((r.float(f32) - 0.5) * 2 * w); + for (io.post.slice(f32, M * 4)) |*v| v.* = r.float(f32) * 2; + for (io.comb.slice(f32, M * 16)) |*v| v.* = r.float(f32) * 0.5; + for (io.fns.slice(u16, pool_fn * fn_bytes / 2)) |*v| v.* = toBf((r.float(f32) - 0.5) * 0.05 * w); + for (io.base.slice(f32, 24)) |*v| v.* = (r.float(f32) - 0.5) * w; + for (io.norm.slice(u16, D)) |*v| v.* = toBf(0.5 + r.float(f32)); + @memcpy(&post0, io.post.slice(f32, M * 4)); // the split writes the next boundary's post and comb over them + @memcpy(&comb0, io.comb.slice(f32, M * 16)); + } + for (0..2) |side| { + const o = io.out[side]; + @memset(o.xn.slice(u16, M * F), 0x7fc1); + @memset(o.normed.slice(u16, M * D), 0x7fc1); + @memset(o.part.slice(u32, M * hc.partBytes(glm.kernels.hc_shape) / 4), 0x7fc00001); + @memcpy(io.post.slice(f32, M * 4), &post0); + @memcpy(io.comb.slice(f32, M * 16), &comb0); + _ = try run(queue, one, .{ k.hc_core, &io, side, rows, expand, rows <= hc.parts_rows }, 1); + @memcpy(outs[side][0][0 .. M * 4], io.post.slice(f32, M * 4)); + @memcpy(&outs[side][1], io.comb.slice(f32, M * 16)); + } + if (!std.mem.eql(f32, &outs[0][1], &outs[1][1]) or !std.mem.eql(f32, outs[0][0][0 .. M * 4], outs[1][0][0 .. M * 4])) { + std.debug.print("draw {d}, {d} rows (expand {}): post or comb BITS DIFFER\n", .{ draw, rows, expand }); + return error.BitsDiffer; + } + const a = io.out[0]; + const b = io.out[1]; + const pb = rows * hc.partBytes(glm.kernels.hc_shape) / 4; + if (!std.mem.eql(u16, a.xn.slice(u16, rows * F), b.xn.slice(u16, rows * F)) or !std.mem.eql(u32, a.part.slice(u32, pb), b.part.slice(u32, pb)) or !std.mem.eql(u16, a.normed.slice(u16, rows * D), b.normed.slice(u16, rows * D))) { + std.debug.print("draw {d}, {d} rows (expand {}): BITS DIFFER\n", .{ draw, rows, expand }); + return error.BitsDiffer; + } + checked += rows * (F + D + 20) + pb; + if (draw > 0) continue; + for (0..16) |_| _ = try run(queue, one, .{ k.hc_core, &io, 0, rows, expand, false }, boundaries); + const t0 = try time(queue, one, .{ k.hc_core, &io, 0, rows, expand, false }); + const t1 = try time(queue, one, .{ k.hc_core, &io, 1, rows, expand, rows <= hc.parts_rows }); + const s0 = try time(queue, split, .{ k.hc_core, &io, 0, rows, expand }); + const s1 = try time(queue, split, .{ k.hc_core, &io, 1, rows, expand }); + std.debug.print(" {d:2} rows{s}: reference {d:6.2} us, ours {d:6.2} us a boundary ({d:.2}x); the split alone {d:5.2} -> {d:5.2} us\n", .{ rows, if (expand) "" else " (first)", t0, t1, t0 / t1, s0, s1 }); + }; + var moe_checked: usize = 0; + for (0..2) |draw| for ([_]u32{ 1, 2, 3, 4, 8, 16 }) |rows| { // draw 1: -0, zeros and large picks' rows among them + for (io.ye.slice(u16, M * (TOPK + 1) * D), 0..) |*v, i| v.* = if (draw == 1 and i % 61 == 0) 0x8000 else if (draw == 1 and i % 67 == 0) 0 else if (draw == 1 and i % 71 == 0) toBf(3e4) else toBf((r.float(f32) - 0.5) * 3); + for (io.wts.slice(f32, M * TOPK), 0..) |*v, i| v.* = if (draw == 1 and i % 13 == 0) 0 else r.float(f32) * 0.6; + for ([_]bool{ true, false }) |parts| for (0..2) |side| { + const o = io.out[side]; + @memset(o.xn.slice(u16, M * F), 0x7fc1); + @memset(o.normed.slice(u16, M * D), 0x7fc1); + @memcpy(io.post.slice(f32, M * 4), &post0); + @memcpy(io.comb.slice(f32, M * 16), &comb0); + _ = try run(queue, moeOne, .{ k, &io, side, rows, parts }, 1); + @memcpy(outs[side][0][0 .. M * 4], io.post.slice(f32, M * 4)); + @memcpy(&outs[side][1], io.comb.slice(f32, M * 16)); + if (side == 1) try sameAfterMoe(&io, &outs, rows, draw, parts); + }; + moe_checked += 2 * (rows * (F + D + 20) + rows * hc.partBytes(glm.kernels.hc_shape) / 4); + if (draw > 0) continue; + for (0..16) |_| _ = try run(queue, moeOne, .{ k, &io, 0, rows, null }, boundaries); // clocks up + const t0 = try time(queue, moeOne, .{ k, &io, 0, rows, null }); + const t1 = try time(queue, moeOne, .{ k, &io, 1, rows, null }); + std.debug.print(" {d:2} rows after MoE: combine and boundary {d:6.2} us, the combine in the expand {d:6.2} us\n", .{ rows, t0, t1 }); + }; + std.debug.print("{d} outputs equal over two draws; {d} with the MoE combine in the expand\n", .{ checked, moe_checked }); +} + +fn sameAfterMoe(io: *const Io, outs: anytype, rows: u32, draw: usize, parts: bool) !void { + const a = io.out[0]; + const b = io.out[1]; + const pb = rows * hc.partBytes(glm.kernels.hc_shape) / 4; + if (!std.mem.eql(f32, &outs[0][1], &outs[1][1]) or !std.mem.eql(f32, outs[0][0][0 .. M * 4], outs[1][0][0 .. M * 4]) or !std.mem.eql(u16, a.xn.slice(u16, rows * F), b.xn.slice(u16, rows * F)) or !std.mem.eql(u32, a.part.slice(u32, pb), b.part.slice(u32, pb)) or !std.mem.eql(u16, a.normed.slice(u16, rows * D), b.normed.slice(u16, rows * D))) { + std.debug.print("draw {d}, {d} rows, the MoE combine in the expand (parts {}): BITS DIFFER\n", .{ draw, rows, parts }); + return error.BitsDiffer; + } +} diff --git a/zig/tests/glm_hc_split_one.metal b/zig/tests/glm_hc_split_one.metal new file mode 100644 index 00000000000..12536ce7ebe --- /dev/null +++ b/zig/tests/glm_hc_split_one.metal @@ -0,0 +1,81 @@ +// tf-glm-hc-rows' reference, the one-group split: slice sums, mixes, pre, post, Sinkhorn, then the collapse and norm. +[[kernel]] void tf_hc_split_one(const device bfloat* X [[buffer(0)]], const device float* PART [[buffer(1)]], + const constant float* SCALE [[buffer(2)]], const device float* BASEV [[buffer(3)]], + const device bfloat* NORMW [[buffer(4)]], const constant float* EPS [[buffer(5)]], + device bfloat* NORMED [[buffer(6)]], device float* POST_OUT [[buffer(7)]], + device float* COMB_OUT [[buffer(8)]], uint tg [[threadgroup_position_in_grid]], + uint t [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + constexpr float HC_EPS = TF_HC_EPS_INT * 1e-9; + const int r = int(tg); + threadgroup float tot[PARTS]; + threadgroup float mixes[MIX]; + threadgroup float red[32]; + threadgroup float pre_s[S]; + threadgroup float inv_s[1]; + device const bfloat* xs = X + size_t(r) * F; + float xv[4][S]; // this thread's 4 columns of the streams, loaded while the mixes and the Sinkhorn run + for (int i = 0; i < 4; ++i) { + for (int s = 0; s < S; ++s) xv[i][s] = float(xs[s * TF_D + int(t) * 4 + i]); + } + if (int(t) < PARTS) { + const device float* p = PART + size_t(r) * SLICES * PARTS + t; + float a = p[0]; + for (int j = 1; j < SLICES; j++) a += p[j * PARTS]; + tot[t] = a; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (int(t) < MIX) mixes[t] = tot[t] * metal::precise::rsqrt(tot[MIX] / float(F) + EPS[0]); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + constexpr int BASE_OFF = 2 * S; + const float pre_scale = SCALE[0], post_scale = SCALE[1], comb_scale = SCALE[2]; + const float active = (lane < (uint)S) ? 1.0f : 0.0f; + const uint llane = metal::min(lane, (uint)(S - 1)); + const float pre_z = mixes[llane] * pre_scale + BASEV[llane]; + const float post_z = mixes[S + llane] * post_scale + BASEV[S + llane]; + const float pre_v = 1.0f / (1.0f + metal::fast::exp(-pre_z)) + HC_EPS; + const float post_v = 2.0f / (1.0f + metal::fast::exp(-post_z)); + if (lane < (uint)S) { + pre_s[lane] = pre_v; + POST_OUT[r * S + lane] = post_v; + } + const float4 m4 = float4(mixes[BASE_OFF + llane * S], mixes[BASE_OFF + llane * S + 1], mixes[BASE_OFF + llane * S + 2], + mixes[BASE_OFF + llane * S + 3]); + float4 v = (m4 * comb_scale + *(const device float4*)(BASEV + BASE_OFF + llane * S)) * active; + const float row_max = metal::max(metal::max(v.x, v.y), metal::max(v.z, v.w)); + const float4 e = metal::fast::exp(v - row_max) * active; + float4 rr = e * (1.0f / (e.x + e.y + e.z + e.w + HC_EPS)) + HC_EPS * active; + float4 col_inv = 1.0f / (hc_col4(rr) + HC_EPS); + rr *= col_inv; + for (int iter = 1; iter < TF_ITERS; ++iter) { + rr *= (1.0f / (rr.x + rr.y + rr.z + rr.w + HC_EPS)) * active; + col_inv = 1.0f / (hc_col4(rr) + HC_EPS); + rr *= col_inv; + } + if (lane < (uint)S) *(device float4*)(COMB_OUT + r * S * S + lane * S) = rr; + } + threadgroup_barrier(mem_flags::mem_threadgroup); + const float p0 = pre_s[0], p1 = pre_s[1], p2 = pre_s[2], p3 = pre_s[3]; + float xc[4]; + float acc = 0.0f; + for (int i = 0; i < 4; ++i) { + const float res = fma(p0, xv[i][0], fma(p1, xv[i][1], fma(p2, xv[i][2], p3 * xv[i][3]))); + xc[i] = float(bfloat(res)); + acc = hc_sq_acc(acc, xc[i]); + } + acc = simd_sum(acc); + if (sg == 0) red[lane] = 0.0f; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 0) red[sg] = acc; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + const float a = simd_sum(red[lane]); + if (lane == 0) inv_s[0] = metal::precise::rsqrt(a / float(TF_D) + EPS[0]); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + for (int i = 0; i < 4; ++i) { + const int d = int(t) * 4 + i; + NORMED[size_t(r) * TF_D + d] = NORMW[d] * bfloat(xc[i] * inv_s[0]); + } +} diff --git a/zig/tests/glm_index_speed.zig b/zig/tests/glm_index_speed.zig new file mode 100644 index 00000000000..609b418ca38 --- /dev/null +++ b/zig/tests/glm_index_speed.zig @@ -0,0 +1,270 @@ +//! tf-glm-index-speed: GLM's decode indexer and sparse attention, new kernels against the old bit for bit, GPU times. +const std = @import("std"); +const platform = @import("sys"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const kernels = tf.glm.kernels; +const st = tf.glm.state; + +const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked; +const a = std.heap.page_allocator; +const reps = 16; +const runs = 7; + +const HI = 32; +const DI = 128; +const QR = 20480; // qr_proj rows: 64 heads' q_nope, then the indexer's queries +const QOFF = 64 * 256; +const RANK = 512; +const H = 64; +const TOP = 2048; +const KPOOL = 4; +const WIDTH = TOP + KPOOL - 1; +const SPAN = 128; +const BLOCKS = (WIDTH + SPAN - 1) / SPAN; +const MAX_ROWS = 16; + +const ScoreArgs = extern struct { p0: u32, q_stride: u32, w_stride: u32, s_stride: u32, rows: u32 }; +const SelectArgs = extern struct { p0: u32, top: u32, width: u32, s_stride: u32, i_stride: u32 }; + +fn buf(device: mtl.Device, bytes: usize) !mtl.Buffer { + return device.buffer(@max(bytes, 16), opts); +} + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +fn fillBf(b: mtl.Buffer, n: usize, seed: u64, amp: f32) void { + var prng = std.Random.DefaultPrng.init(seed); + const r = prng.random(); + for (b.slice(u16, n)) |*v| v.* = toBf((r.float(f32) - 0.5) * 2 * amp); +} + +const Rig = struct { + queue: mtl.Queue, + k: *const kernels.Kernels, + cap: u32, + s_stride: u32, + pool: mtl.Buffer, + iq: mtl.Buffer, + iw: mtl.Buffer, + scores: mtl.Buffer, + indices: mtl.Buffer, + bits: mtl.Buffer, + keys: mtl.Buffer, + ql: mtl.Buffer, + part: mtl.Buffer, + out: mtl.Buffer, +}; + +const Shape = struct { p0: u32, rows: u32 }; + +const Op = enum { scores, select_old, select_new, attend, mark, merge }; + +fn encode(e: mtl.ComputeEncoder, r: *const Rig, op: Op, s: Shape) void { + const k = r.k; + const most = (s.p0 + s.rows) / KPOOL; + const sel = SelectArgs{ .p0 = s.p0, .top = TOP / KPOOL, .width = WIDTH, .s_stride = r.s_stride, .i_stride = WIDTH }; + switch (op) { + .scores => { + e.setPipeline(k.index_decode); + e.setBuffer(r.iq, QOFF * 2, 0); + e.setBuffer(r.iw, 0, 1); + e.setBuffer(r.pool, 0, 2); + e.setBuffer(r.scores, 0, 3); + e.setValue(ScoreArgs{ .p0 = s.p0, .q_stride = QR, .w_stride = HI, .s_stride = r.s_stride, .rows = s.rows }, 4); + e.dispatchGroups(mtl.Size.of((most + 127) / 128, s.rows, 1), mtl.Size.of(128, 1, 1)); + }, + .select_old => { + e.setPipeline(k.index_select); + e.setBuffer(r.scores, 0, 0); + e.setBuffer(r.indices, 0, 1); + e.setValue(sel, 2); + e.dispatchGroups(mtl.Size.of(s.rows, 1, 1), mtl.Size.of(1024, 1, 1)); + }, + .select_new, .mark, .merge => { // glm_select.metal's mark and merge (forward.zig: past 8,192 blocks) + const words = st.selectWords(r.cap, KPOOL); + if (most > 3072 and op != .merge) { + e.setPipeline(k.select_mark); + e.setBuffer(r.scores, 0, 0); + e.setBuffer(r.bits, 0, 1); + e.setValue(sel, 2); + e.setValue(words, 3); + e.dispatchGroups(mtl.Size.of((most + 4095) / 4096, s.rows, 1), mtl.Size.of(256, 1, 1)); + } + if (op == .mark) return; + e.setPipeline(k.select_merge); + e.setBuffer(r.scores, 0, 0); + e.setBuffer(r.indices, 0, 1); + e.setValue(sel, 2); + e.setValue(words, 3); + e.setBuffer(r.bits, 0, 4); + e.dispatchGroups(mtl.Size.of(s.rows, 1, 1), mtl.Size.of(512, 1, 1)); + }, + .attend => { + const vals = @as(usize, s.rows) * BLOCKS * H * RANK * 4; + const marks = @as(usize, s.rows) * BLOCKS * H * 4; + e.setPipeline(k.sparse_split); + e.setBuffer(r.ql, 0, 0); + e.setBuffer(r.keys, 0, 1); + e.setBuffer(r.indices, 0, 2); + e.setValue(@as(f32, 1.0 / 16.0), 3); + e.setValue([4]i32{ WIDTH, @intCast(s.p0 + s.rows), SPAN, 0 }, 4); + e.setBuffer(r.part, 0, 5); + e.setBuffer(r.part, vals, 6); + e.setBuffer(r.part, vals + marks, 7); + e.dispatchGroups(mtl.Size.of(H / 16, BLOCKS, s.rows), mtl.Size.of(128, 1, 1)); + e.setPipeline(k.sparse_combine); + e.setBuffer(r.part, 0, 0); + e.setBuffer(r.part, vals, 1); + e.setBuffer(r.part, vals + marks, 2); + e.setValue(@as(i32, BLOCKS), 3); + e.setBuffer(r.out, 0, 4); + e.dispatchGroups(mtl.Size.of(H, s.rows, 1), mtl.Size.of(128, 1, 1)); + }, + } +} + +fn submit(r: *const Rig, op: Op, s: Shape, count: usize) !f64 { + const cb = r.queue.commandBuffer(); + const e = cb.compute(.serial); + for (0..count) |_| encode(e, r, op, s); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(count)); +} + +/// Median GPU time of one launch of `op`, in microseconds. +fn time(r: *const Rig, op: Op, s: Shape) !f64 { + var t: [runs + 1]f64 = undefined; + for (&t) |*v| v.* = try submit(r, op, s, reps); + const sl = t[1..]; + std.mem.sort(f64, sl, {}, std.sort.asc(f64)); + return sl[runs / 2]; +} + +/// Score rows that stress the select: ties, NaNs, signed zeros, infinities, ramps and one hot span. +const Fill = enum { real, uniform, ties, specials, ascending, descending, hot_span, constant, sampled_high }; + +fn fillScores(r: *const Rig, f: Fill, s: Shape, seed: u64) void { + var prng = std.Random.DefaultPrng.init(seed); + const rnd = prng.random(); + for (0..s.rows) |row| { + const n = (s.p0 + @as(u32, @intCast(row)) + 1) / KPOOL; + const v = r.scores.slice(f32, MAX_ROWS * @as(usize, r.s_stride))[row * r.s_stride ..][0..n]; + for (v, 0..) |*x, i| x.* = switch (f) { + .real => x.*, + .uniform => rnd.float(f32) * 8 - 2, + .ties => @floatFromInt(rnd.uintLessThan(u32, 6)), + .specials => switch (rnd.uintLessThan(u32, 16)) { + 0 => std.math.nan(f32), + 1 => -std.math.nan(f32), + 2 => 0.0, + 3 => -0.0, + 4 => std.math.inf(f32), + 5 => -std.math.inf(f32), + else => rnd.float(f32) - 0.5, + }, + .ascending => @floatFromInt(i / 3), + .descending => @floatFromInt(n - i / 2), + .hot_span => if (i >= n / 3 and i < n / 3 + 700) 5.0 + rnd.float(f32) else rnd.float(f32), + .constant => 1.5, + .sampled_high => if (sampled(i, n)) 3.0 + rnd.float(f32) else rnd.float(f32), // the floor overshoots + }; + } +} + +/// Whether glm_select.metal's floor samples block i of n (256 runs of 8 at even spacing). +fn sampled(i: usize, n: u32) bool { + var q: u64 = 0; + while (q < 2048) : (q += 8) if (i >= q / 8 * n / 256 / 8 * 8 and i < q / 8 * n / 256 / 8 * 8 + 8) return true; + return false; +} + +/// The new select's key lists against the old kernel's on the same scores: true when every entry is the same. +fn same(r: *const Rig, s: Shape) !bool { + const n = @as(usize, s.rows) * WIDTH; + _ = try submit(r, .select_old, s, 1); + const want = try a.dupe(i32, r.indices.slice(i32, n)); + defer a.free(want); + @memset(r.indices.slice(i32, n), 0x5a5a5a5a); + _ = try submit(r, .select_new, s, 1); + return std.mem.eql(i32, want, r.indices.slice(i32, n)); +} + +pub fn main() !void { + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + defer device.deinit(); + const queue = try device.queue(); + defer queue.deinit(); + const k = try kernels.load(a, device); + const cap: u32 = 131072; + const s_stride = cap / KPOOL + 1; + const r = Rig{ + .queue = queue, + .k = k, + .cap = cap, + .s_stride = s_stride, + .pool = try buf(device, @as(usize, s_stride) * DI * 2), + .iq = try buf(device, @as(usize, MAX_ROWS) * QR * 2), + .iw = try buf(device, @as(usize, MAX_ROWS) * HI * 2), + .scores = try buf(device, @as(usize, MAX_ROWS) * s_stride * 4), + .indices = try buf(device, @as(usize, MAX_ROWS) * WIDTH * 4), + .bits = try buf(device, @as(usize, MAX_ROWS) * st.selectWords(cap, KPOOL) * 4), + .keys = try buf(device, @as(usize, cap) * RANK * 2), + .ql = try buf(device, @as(usize, MAX_ROWS) * H * RANK * 2), + .part = try buf(device, @as(usize, MAX_ROWS) * BLOCKS * H * (RANK + 2) * 4), + .out = try buf(device, @as(usize, MAX_ROWS) * H * RANK * 2), + }; + fillBf(r.pool, @as(usize, s_stride) * DI, 1, 1.0); + fillBf(r.iq, @as(usize, MAX_ROWS) * QR, 2, 1.0); + fillBf(r.iw, @as(usize, MAX_ROWS) * HI, 3, 0.2); + fillBf(r.keys, @as(usize, cap) * RANK, 4, 1.0); + fillBf(r.ql, @as(usize, MAX_ROWS) * H * RANK, 5, 1.0); + var failures: usize = 0; + var cases: usize = 0; + // every fill at positions across the select's paths: all blocks, one group's whole row, the marked candidates + const positions = [_]u32{ 2047, 2048, 2051, 2100, 8191, 12280, 16380, 16384, 16387, 16400, 20000, 40000, 90000, 120000, 131000 }; + for (positions) |p0| for ([_]u32{ 1, 3, 16 }) |rows| { + if (p0 + rows + 1 > cap) continue; + const s = Shape{ .p0 = p0, .rows = rows }; + for (std.enums.values(Fill), 0..) |f, fi| { + if (f == .real) _ = try submit(&r, .scores, s, 1); + fillScores(&r, f, s, p0 * 31 + rows * 7 + fi); + cases += 1; + if (!try same(&r, s)) { + failures += 1; + std.debug.print("DIFFER: position {d} rows {d} fill {t}\n", .{ p0, rows, f }); + } + } + }; + std.debug.print("select: {d} of {d} cases give the old kernel's key lists\n", .{ cases - failures, cases }); + if (platform.c.getenv("GLM_INDEX_TIMES") != null) { + _ = try submit(&r, .select_old, .{ .p0 = 120000, .rows = 16 }, 400); // the GPU at its clocks + var pit = std.mem.tokenizeScalar(u8, std.mem.span(platform.c.getenv("GLM_POS") orelse "4096,16384,32768,65536,90000,120000"), ','); + while (pit.next()) |pv| { + const p0 = try std.fmt.parseInt(u32, pv, 10); + for ([_]u32{ 1, 4 }) |rows| { + const s = Shape{ .p0 = p0, .rows = rows }; + _ = try submit(&r, .scores, s, 1); + const ts = try time(&r, .scores, s); + const t_old = try time(&r, .select_old, s); + const t_new = try time(&r, .select_new, s); + const ta = try time(&r, .attend, s); + const tm = try time(&r, .mark, s); + const tg = try time(&r, .merge, s); + std.debug.print("pos {d:6} rows {d:2}: scores {d:6.1} us select {d:6.1} -> {d:6.1} us (mark {d:5.1}, merge {d:5.1}) sparse attention {d:6.1} us\n", .{ p0, rows, ts, t_old, t_new, tm, tg, ta }); + } + } + } + if (failures > 0) std.process.exit(1); +} diff --git a/zig/tests/glm_kda_speed.zig b/zig/tests/glm_kda_speed.zig new file mode 100644 index 00000000000..e35e9bc480b --- /dev/null +++ b/zig/tests/glm_kda_speed.zig @@ -0,0 +1,208 @@ +//! tf-glm-kda-speed: GLM's KDA step on synthetic weights, the window kernel and kda_parts + kda_norm against kda_rows. +const std = @import("std"); +const platform = @import("sys"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const kernels = tf.glm.kernels; + +const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked; +const a = std.heap.page_allocator; +const reps = 40; // launches a timing, each on its own state slot +const slots = 40; // a round's 34 layers' states and more: past the caches +const runs = 7; + +const H = 64; +const D = 128; +const W = H * D; +const PS = 3 * W + 2 * D + H; // the stacked projection +const TAPS = 4; +const MAX_ROWS = 16; + +fn buf(device: mtl.Device, bytes: usize) !mtl.Buffer { + return device.buffer(@max(bytes, 16), opts); +} + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +fn fillBf(b: mtl.Buffer, n: usize, r: std.Random, lo: f32, hi: f32) void { + for (b.slice(u16, n)) |*v| v.* = toBf(lo + r.float(f32) * (hi - lo)); +} + +fn fillF(b: mtl.Buffer, n: usize, r: std.Random, lo: f32, hi: f32) void { + for (b.slice(f32, n)) |*v| v.* = lo + r.float(f32) * (hi - lo); +} + +const Rig = struct { + queue: mtl.Queue, + p: mtl.Buffer, + cs: mtl.Buffer, + cw: mtl.Buffer, + fb: [3]mtl.Buffer, + gb: [3]mtl.Buffer, + av: mtl.Buffer, + dtb: mtl.Buffer, + st: mtl.Buffer, + onw: mtl.Buffer, + y: mtl.Buffer, + st_out: mtl.Buffer, + cs_out: mtl.Buffer, + gate: mtl.Buffer, // kda_parts' gates (forward.zig: gu) + st_pool: mtl.Buffer, // timing: `slots` states in and out + out_pool: mtl.Buffer, + norm: mtl.Pipeline, + parts: mtl.Pipeline, +}; + +/// forward.zig's kdaStep for `rows` rows of the generated gate (state slot `slot` when timed). +fn encode(e: mtl.ComputeEncoder, r: *const Rig, pipe: mtl.Pipeline, rows: u32, heads: u32) void { + encodeAt(e, r, pipe, rows, heads, null); +} + +fn encodeAt(e: mtl.ComputeEncoder, r: *const Rig, pipe: mtl.Pipeline, rows: u32, heads: u32, slot: ?usize) void { + const parts = pipe.id == r.parts.id; + e.setPipeline(pipe); + e.setBuffer(r.p, 0, 0); + var shape = [2]i32{ @intCast(rows), @intCast(3 * heads * D + 2 * D + heads) }; + e.setBytes(std.mem.asBytes(&shape), 1); + const ins = [_]mtl.Buffer{ r.cs, r.cw, r.fb[0], r.fb[1], r.fb[2], r.gb[0], r.gb[1], r.gb[2], r.av, r.dtb, r.st, r.onw }; + for (ins, 2..) |b, i| e.setBuffer(b, 0, i); + e.setValue(@as(f32, -5.0), 14); + e.setValue(@as(f32, 1e-5), 15); + e.setBuffer(r.y, 0, 16); + e.setBuffer(r.st_out, 0, 17); + e.setBuffer(r.cs_out, 0, 18); + if (parts) e.setBuffer(r.gate, 0, 13); + if (slot) |i| { + e.setBuffer(r.st_pool, (i % slots) * H * D * D * 4, 12); + e.setBuffer(r.out_pool, (i % slots) * H * D * D * 4, 17); + } + e.dispatchThreads(mtl.Size.of(32, 32, heads), mtl.Size.of(32, if (parts) 16 else 32, 1)); + if (!parts) return; + e.setPipeline(r.norm); + e.setBuffer(r.y, 0, 0); + e.setBuffer(r.gate, 0, 1); + e.setBuffer(r.onw, 0, 2); + e.setValue(@as(f32, 1e-5), 3); + e.dispatchGroups(mtl.Size.of(heads / 8, rows, 1), mtl.Size.of(256, 1, 1)); +} + +fn submit(r: *const Rig, pipe: mtl.Pipeline, rows: u32, count: usize) !f64 { + return submitHeads(r, pipe, rows, count, H); +} + +fn submitHeads(r: *const Rig, pipe: mtl.Pipeline, rows: u32, count: usize, heads: u32) !f64 { + const cb = r.queue.commandBuffer(); + const e = cb.compute(.serial); + for (0..count) |i| encodeAt(e, r, pipe, rows, heads, if (count > 1) i else null); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(count)); +} + +fn time(r: *const Rig, pipe: mtl.Pipeline, rows: u32) !f64 { + var t: [runs + 1]f64 = undefined; + for (&t) |*v| v.* = try submit(r, pipe, rows, reps); + const sl = t[1..]; + std.mem.sort(f64, sl, {}, std.sort.asc(f64)); + return sl[runs / 2]; +} + +pub fn main() !void { + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + defer device.deinit(); + const queue = try device.queue(); + defer queue.deinit(); + const k = try kernels.load(a, device); + var prng = std.Random.DefaultPrng.init(7); + const rnd = prng.random(); + const fbw = W * D * 4 / 8; // [W, D] at 4 bits + const fbs = W * (D / 64) * 2; + const r = Rig{ + .queue = queue, + .p = try buf(device, MAX_ROWS * PS * 2), + .cs = try buf(device, (TAPS - 1) * 3 * W * 2), + .cw = try buf(device, TAPS * 3 * W * 4), + .fb = .{ try buf(device, fbw), try buf(device, fbs), try buf(device, fbs) }, + .gb = .{ try buf(device, fbw), try buf(device, fbs), try buf(device, fbs) }, + .av = try buf(device, H * 4), + .dtb = try buf(device, W * 4), + .st = try buf(device, H * D * D * 4), + .onw = try buf(device, D * 4), + .y = try buf(device, MAX_ROWS * W * 2), + .st_out = try buf(device, H * D * D * 4), + .cs_out = try buf(device, (TAPS - 1) * 3 * W * 2), + .gate = try buf(device, MAX_ROWS * W * 2), + .st_pool = try buf(device, slots * H * D * D * 4), + .out_pool = try buf(device, slots * H * D * D * 4), + .norm = k.kda_norm, + .parts = k.kda_parts, + }; + fillF(r.st_pool, slots * H * D * D, rnd, -0.1, 0.1); + fillBf(r.p, MAX_ROWS * PS, rnd, -2, 2); + fillBf(r.cs, (TAPS - 1) * 3 * W, rnd, -2, 2); + fillF(r.cw, TAPS * 3 * W, rnd, -0.5, 0.5); + for ([_]*const [3]mtl.Buffer{ &r.fb, &r.gb }) |q| { + for (q[0].slice(u32, fbw / 4)) |*v| v.* = rnd.int(u32); + fillBf(q[1], fbs / 2, rnd, 0.001, 0.02); + fillBf(q[2], fbs / 2, rnd, -0.05, 0.05); + } + fillF(r.av, H, rnd, 0.5, 2); + fillF(r.dtb, W, rnd, -1, 1); + fillF(r.st, H * D * D, rnd, -0.1, 0.1); + fillF(r.onw, D, rnd, 0.5, 1.5); + // every row count, three draws of inputs: the window kernel's outputs, state and conv window against kda_rows' + var cases: usize = 0; + var failures: usize = 0; + for (0..3) |seed| { + fillBf(r.p, MAX_ROWS * PS, rnd, -2, 2); + fillBf(r.cs, (TAPS - 1) * 3 * W, rnd, -2, 2); + fillF(r.st, H * D * D, rnd, -0.1, 0.1); + if (seed == 2) for (r.p.slice(u16, MAX_ROWS * PS), 0..) |*v, i| if (i % 97 == 0) { + v.* = 0x8000; // -0 and large values among the inputs + } else if (i % 89 == 0) { + v.* = toBf(40); + }; + for (1..MAX_ROWS + 1) |rows_| for ([_]u32{ H, H / 2, 0 }) |heads_| { // all heads, TP2's 32; 0: kda_parts + const rows: u32 = @intCast(rows_); + const heads = if (heads_ == 0) H else heads_; + const old_k = if (heads == H) k.kda_rows else k.kda_rows_tp; + const new_k = if (heads_ == 0) k.kda_parts else if (heads == H) k.kda_window else k.kda_window_tp; + const outs = [_]mtl.Buffer{ r.y, r.st_out, r.cs_out }; + const lens = [_]usize{ rows * heads * D * 2, heads * D * D * 4, (TAPS - 1) * 3 * heads * D * 2 }; + var want: [3][]u8 = undefined; + _ = try submitHeads(&r, old_k, rows, 1, heads); + for (outs, lens, 0..) |b, n, i| want[i] = try a.dupe(u8, b.contents()[0..n]); + for (outs, lens) |b, n| @memset(b.contents()[0..n], 0x5a); + _ = try submitHeads(&r, new_k, rows, 1, heads); + var same = true; + for (outs, lens, 0..) |b, n, i| { + same = same and std.mem.eql(u8, want[i], b.contents()[0..n]); + a.free(want[i]); + } + cases += 1; + if (!same) { + failures += 1; + std.debug.print("DIFFER: draw {d}, {d} rows, {d} heads{s}\n", .{ seed, rows, heads, if (heads_ == 0) " (two groups a head)" else "" }); + } + }; + } + std.debug.print("kda window and two groups a head: {d} of {d} cases give kda_rows' outputs, state and conv window\n", .{ cases - failures, cases }); + if (platform.c.getenv("GLM_KDA_TIMES") != null) _ = try submit(&r, k.kda_rows, 16, 400); // the GPU at its clocks + if (platform.c.getenv("GLM_KDA_TIMES") != null) for ([_]u32{ 1, 2, 3, 4, 5, 6, 8, 12, 16 }) |rows| { + const t_old = try time(&r, k.kda_rows, rows); + const t_new = try time(&r, k.kda_window, rows); + const t_parts = try time(&r, k.kda_parts, rows); + std.debug.print("{d:2} rows: kda_rows {d:6.1} us, window {d:6.1} us, two groups a head and the norm {d:6.1} us\n", .{ rows, t_old, t_new, t_parts }); + }; + if (failures > 0) std.process.exit(1); +} diff --git a/zig/tests/glm_mla_norms.zig b/zig/tests/glm_mla_norms.zig new file mode 100644 index 00000000000..c10b931b8d4 --- /dev/null +++ b/zig/tests/glm_mla_norms.zig @@ -0,0 +1,120 @@ +//! tf-glm-mla-norms: an MLA layer's small launches in one (glm_mla_norms) against the kept kernels, bytes; time. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const sources = @import("kernel_sources"); +const glm = tf.glm; +const R = glm.weights.Ref; +const Rows = glm.forward.Rows; + +const c: glm.config.Config = .{}; +const XP = 2240; // x_proj rows' widest stride: a prompt chunk's (2208 aligned to 64); decode's is 2208 +const M = 300; +const layers = 11; // a round's MLA layers + +const Side = struct { keys: mtl.Buffer, ik: mtl.Buffer, iw: mtl.Buffer, q: mtl.Buffer }; +const Rig = struct { xp: mtl.Buffer, w: glm.weights.Mla, out: [4]Side, refs: [3]mtl.Pipeline, k: *const glm.kernels.Kernels }; +const widths = [4]usize{ c.kv_lora, c.i_dim, c.i_heads, c.q_lora }; + +fn outs(o: Side) [4]mtl.Buffer { + return .{ o.keys, o.ik, o.iw, o.q }; +} + +/// Side 0: kept kernels; 1: glm_mla_norms (prompt: no query norm); 2: with the query norm; 3: kernels as now. +fn launch(e: mtl.ComputeEncoder, r: *const Rig, side: usize, rows: u32, stride: u32) void { + const o = r.out[side]; + const xp = R{ .buf = r.xp }; + if (side == 1 or side == 2) return glm.forward.mlaNorms(r.k, &c, e, &r.w, xp, stride, .{ .buf = o.keys }, .{ .buf = o.ik }, .{ .buf = o.iw }, if (side == 2) R{ .buf = o.q } else null, rows); + const p = if (side == 0) r.refs else [3]mtl.Pipeline{ r.k.rms, r.k.layer_norm, r.k.scale }; + const K = c.kv_lora; + e.setPipeline(p[0]); + inline for (.{ xp, r.w.q_norm, R{ .buf = o.q } }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(Rows{ .rows = @intCast(rows), .width = c.q_lora, .x_stride = @intCast(stride), .y_stride = c.q_lora, .eps = c.eps }, 3); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(((c.q_lora + 3) / 4 + 31) / 32 * 32, 1, 1)); + e.setPipeline(p[0]); + inline for (.{ xp.at(c.q_lora * 2), r.w.kv_norm, R{ .buf = o.keys } }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(Rows{ .rows = @intCast(rows), .width = K, .x_stride = @intCast(stride), .y_stride = K, .eps = c.eps }, 3); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(((K + 3) / 4 + 31) / 32 * 32, 1, 1)); + e.setPipeline(p[1]); + inline for (.{ xp.at((c.q_lora + K) * 2), r.w.k_norm_w, r.w.k_norm_b, R{ .buf = o.ik } }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(Rows{ .rows = @intCast(rows), .width = c.i_dim, .x_stride = @intCast(stride), .y_stride = c.i_dim, .eps = 1e-6 }, 4); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(32, 1, 1)); + e.setPipeline(p[2]); + inline for (.{ xp.at((c.q_lora + K + c.i_dim) * 2), R{ .buf = o.iw } }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(Rows{ .rows = @intCast(rows), .width = c.i_heads, .x_stride = @intCast(stride), .y_stride = c.i_heads, .eps = 1.0 / 64.0 }, 2); + e.dispatchThreads(mtl.Size.of(c.i_heads, rows, 1), mtl.Size.of(c.i_heads, 1, 1)); +} + +fn run(q: mtl.Queue, r: *const Rig, side: usize, rows: u32, stride: u32, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |_| launch(e, r, side, rows, stride); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, r: *const Rig, side: usize, rows: u32) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try run(q, r, side, rows, 2208, 4 * layers); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +pub fn main(init: std.process.Init) !void { + const gpa = init.gpa; + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + const k = try glm.kernels.load(gpa, device); + const lib = try mtl.Library.fromSource(device, try std.mem.concat(gpa, u8, &.{ sources.glm_glue, @embedFile("glm_mla_norms_ref.metal") }), mtl.CompileOptions.mlx()); + const opts = mtl.ResourceOptions.shared; + var r: Rig = .{ .xp = try device.buffer(M * XP * 2, opts), .w = undefined, .out = undefined, .refs = undefined, .k = k }; + const nw = c.kv_lora + 2 * c.i_dim + c.q_lora; + for (&r.refs, [_][:0]const u8{ "glm_rms_ref", "glm_layer_norm_ref", "glm_scale_ref" }) |*p, n| p.* = try mtl.Pipeline.init(device, lib, n, false); + const wb = try device.buffer(nw * 2, opts); + r.w.kv_norm = .{ .buf = wb }; + r.w.k_norm_w = (R{ .buf = wb }).at(c.kv_lora * 2); + r.w.k_norm_b = (R{ .buf = wb }).at((c.kv_lora + c.i_dim) * 2); + r.w.q_norm = (R{ .buf = wb }).at((c.kv_lora + 2 * c.i_dim) * 2); + for (&r.out) |*o| o.* = .{ .keys = try device.buffer(M * c.kv_lora * 2, opts), .ik = try device.buffer(M * c.i_dim * 2, opts), .iw = try device.buffer(M * c.i_heads * 2, opts), .q = try device.buffer(M * c.q_lora * 2, opts) }; + var prng = std.Random.DefaultPrng.init(0x6d); + const rnd = prng.random(); + std.debug.print("GPU {s}: an MLA layer's key norm, indexer key norm, indexer weights and query norm in one launch against four\n", .{device.name()}); + var checked: usize = 0; + for (0..3) |d| { // draw 1: wider values with zeros, -0, large and tiny ones; draw 2: rows of one value, zero rows + const span: f32 = if (d == 0) 2 else 64; + for (r.xp.slice(u16, M * XP), 0..) |*v, i| v.* = if (d == 2 and (i / XP) % 3 == 0) toBf(@floatFromInt((i / XP) % 7)) else if (d == 1 and i % 61 == 0) 0x8000 else if (d == 1 and i % 67 == 0) 0 else if (d == 1 and i % 71 == 0) toBf(3e4) else if (d == 1 and i % 73 == 0) toBf(1e-30) else toBf((rnd.float(f32) - 0.5) * span); + for (wb.slice(u16, nw), 0..) |*v, i| v.* = if (d == 1 and i % 29 == 0) 0x8000 else toBf((rnd.float(f32) - 0.3) * 2); + for ([_]u32{ 2208, XP }) |stride| for ([_]u32{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 37, M }) |rows| { + for (r.out) |o| for (outs(o), widths) |b, w| @memset(b.slice(u16, M * w), 0x7fc1); + for (0..4) |side| _ = try run(queue, &r, side, rows, stride, 1); + for (1..4) |side| for (outs(r.out[0]), outs(r.out[side]), widths, 0..) |b0, b1, w, part| { + if (side == 1 and part == 3) continue; // a prompt chunk's launch leaves the queries to their own + if (!std.mem.eql(u16, b0.slice(u16, M * w), b1.slice(u16, M * w))) { + std.debug.print("draw {d}, {d} rows (stride {d}), side {d}, part {d}: BITS DIFFER\n", .{ d, rows, stride, side, part }); + return error.BitsDiffer; + } + checked += rows * w; + }; + }; + } + for (0..64) |_| _ = try run(queue, &r, 0, 16, 2208, 4 * layers); // clocks up + for ([_]u32{ 1, 2, 4, 8, 16 }) |rows| { + const t0 = try time(queue, &r, 0, rows); + const t1 = try time(queue, &r, 2, rows); + std.debug.print(" {d:2} rows: four launches {d:5.2} us, one {d:5.2} us a layer\n", .{ rows, t0, t1 }); + } + std.debug.print("{d} outputs equal (merged with and without the query norm, the kernels as they are now) over three draws\n", .{checked}); +} diff --git a/zig/tests/glm_mla_norms_ref.metal b/zig/tests/glm_mla_norms_ref.metal new file mode 100644 index 00000000000..1c67e8d8bf9 --- /dev/null +++ b/zig/tests/glm_mla_norms_ref.metal @@ -0,0 +1,109 @@ +// tf-glm-mla-norms' reference: glm_glue.metal's rms, layer norm and scale before glm_mla_norms (appended). + +// MLX's rms_single_row on strided rows: thread t squares 4t..4t+3, simd_sum, a 32-slot simd_sum, precise rsqrt. +kernel void glm_rms_ref(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], + device bfloat* y [[buffer(2)]], constant GlmRows& a [[buffer(3)]], + uint row [[threadgroup_position_in_grid]], uint t [[thread_position_in_threadgroup]], + uint sg [[simdgroup_index_in_threadgroup]], uint lane [[thread_index_in_simdgroup]]) { + threadgroup float sg_sums[32]; + threadgroup float inv_rms[1]; + const uint width = uint(a.width), lo = 4 * t; + const device bfloat* src = x + size_t(row) * a.x_stride + lo; + device bfloat* dst = y + size_t(row) * a.y_stride + lo; + const device bfloat* gain = w + lo; + const bool whole = lo + 4 <= width; + float v[4]; + float sq = 0.0f; + if (whole) { + for (int j = 0; j < 4; ++j) { + v[j] = src[j]; + sq += v[j] * v[j]; + } + } else { + for (int j = 0; j < 4; ++j) { + v[j] = lo + j < width ? float(src[j]) : 0.0f; + sq += v[j] * v[j]; + } + } + sq = simd_sum(sq); + if (sg == 0) sg_sums[lane] = 0.0f; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 0) sg_sums[sg] = sq; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (sg == 0) { + const float all = simd_sum(sg_sums[lane]); + if (lane == 0) inv_rms[0] = metal::precise::rsqrt(all / float(width) + a.eps); + } + threadgroup_barrier(mem_flags::mem_threadgroup); + if (whole) { + for (int j = 0; j < 4; ++j) dst[j] = gain[j] * static_cast(v[j] * inv_rms[0]); + } else { + for (int j = 0; j < 4; ++j) + if (lo + j < width) dst[j] = gain[j] * static_cast(v[j] * inv_rms[0]); + } +} + +// MLX's layer_norm_single_row (8 values a thread, 32 threads a row): the indexer's key norm with weight and bias. +inline float glm_tg_sum_ref(float x, threadgroup float* xs, uint lane, uint sg) { + x = simd_sum(x); + threadgroup_barrier(mem_flags::mem_threadgroup); + if (lane == 0) xs[sg] = x; + threadgroup_barrier(mem_flags::mem_threadgroup); + x = xs[lane]; + return simd_sum(x); +} + +kernel void glm_layer_norm_ref(const device bfloat* x [[buffer(0)]], const device bfloat* w [[buffer(1)]], + const device bfloat* b [[buffer(2)]], device bfloat* y [[buffer(3)]], + constant GlmRows& a [[buffer(4)]], uint row [[threadgroup_position_in_grid]], + uint lid [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint sg [[simdgroup_index_in_threadgroup]]) { + constexpr int N_READS = 8; + float thread_x[N_READS] = {0}; + threadgroup float local_buffer[32]; + if (sg == 0) local_buffer[lane] = 0; + const int axis = a.width; + const device bfloat* xr = x + size_t(row) * a.x_stride + lid * N_READS; + device bfloat* out = y + size_t(row) * a.y_stride + lid * N_READS; + const device bfloat* wr = w + lid * N_READS; + const device bfloat* br = b + lid * N_READS; + const bool safe = int(lid) * N_READS + N_READS <= axis; + const int n = axis - int(lid) * N_READS; + if (safe) { + for (int i = 0; i < N_READS; i++) thread_x[i] = xr[i]; + } else { + for (int i = 0; i < n; i++) thread_x[i] = xr[i]; + } + float mean = 0; + for (int i = 0; i < N_READS; i++) mean += thread_x[i]; + mean = glm_tg_sum_ref(mean, local_buffer, lane, sg); + mean /= axis; + float normalizer = 0; + if (!safe) { + for (int i = max(n, 0); i < N_READS; i++) thread_x[i] = mean; + } + for (int i = 0; i < N_READS; i++) { + thread_x[i] -= mean; + normalizer += thread_x[i] * thread_x[i]; + } + normalizer = glm_tg_sum_ref(normalizer, local_buffer, lane, sg); + normalizer = metal::precise::rsqrt(normalizer / axis + a.eps); + if (safe) { + for (int i = 0; i < N_READS; i++) { + thread_x[i] *= normalizer; + out[i] = wr[i] * static_cast(thread_x[i]) + br[i]; + } + } else { + for (int i = 0; i < n; i++) { + thread_x[i] *= normalizer; + out[i] = wr[i] * static_cast(thread_x[i]) + br[i]; + } + } +} + +// y = bf16(x * s) for a power-of-two s (exact): the scaled queries of MLX's unfused attention, the indexer weights. +kernel void glm_scale_ref(const device bfloat* x [[buffer(0)]], device bfloat* y [[buffer(1)]], + constant GlmRows& a [[buffer(2)]], uint2 p [[thread_position_in_grid]]) { + if (int(p.x) >= a.width || int(p.y) >= a.rows) return; + y[size_t(p.y) * a.y_stride + p.x] = bfloat(float(x[size_t(p.y) * a.x_stride + p.x]) * a.eps); +} diff --git a/zig/tests/glm_mm_groups.zig b/zig/tests/glm_mm_groups.zig new file mode 100644 index 00000000000..77753880200 --- /dev/null +++ b/zig/tests/glm_mm_groups.zig @@ -0,0 +1,278 @@ +//! tf-glm-mm-groups [ROWS...]: prompt experts and dense products in column groups against affine_mm's: bits, time. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const affine_mm = tf.affine_mm; +const groups = tf.glm.mm_groups; + +const E = 288; +const topk = 8; +const D = 4096; +const I = 2048; + +const B = struct { buf: mtl.Buffer, off: usize = 0 }; +const Mat = struct { w: B, s: B, b: B, n: u32, k: u32 }; + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +fn matrix(device: mtl.Device, r: std.Random, rows: usize, n: u32, k: usize) !Mat { + const opts = mtl.ResourceOptions.shared; + const m: Mat = .{ .w = .{ .buf = try device.buffer(rows * k / 2, opts) }, .s = .{ .buf = try device.buffer(rows * k / 64 * 2, opts) }, .b = .{ .buf = try device.buffer(rows * k / 64 * 2, opts) }, .n = n, .k = @intCast(k) }; + r.bytes(m.w.buf.slice(u8, rows * k / 2)); + for (m.s.buf.slice(u16, rows * k / 64), m.b.buf.slice(u16, rows * k / 64)) |*s, *b| { + s.* = toBf((r.float(f32) + 0.5) / 256); + b.* = toBf(-(r.float(f32) + 0.5) * 0.03); + } + return m; +} + +/// Each row's top-8 distinct experts from skewed weights (load-balanced routers still give experts 0.3-3x the mean). +fn route(r: std.Random, rows: usize, picks: []i32) void { + var w: [E]f64 = undefined; + for (&w, 0..) |*v, e| v.* = 0.35 + 2.5 * std.math.pow(f64, @as(f64, @floatFromInt((e * 7919) % E)) / E, 3); + for (0..rows) |i| { + var taken: [E]bool = @splat(false); + for (0..topk) |s| { + var total: f64 = 0; + for (w, taken) |v, t| total += if (t) 0 else v; + var at = r.float(f64) * total; + const pick = for (w, 0..) |v, e| { + if (taken[e]) continue; + at -= v; + if (at <= 0) break e; + } else E - 1; + taken[pick] = true; + picks[i * topk + s] = @intCast(pick); + } + } +} + +const Io = struct { x: B, sums: B, gate: Mat, up: Mat, down: Mat, offs: B, order: B, act: [2]B, yp: [2]B, rows: u32, n: u32 }; + +/// Today's: core/affine_mm.zig's gathers at height `bm` (0: their own choice). +fn core(e: mtl.ComputeEncoder, mm: affine_mm.Pipes, io: *const Io, bm: u32, glu: bool, side: usize) void { + if (bm == 0) { + if (glu) return affine_mm.gatherGlu(e, mm, io.x, io.sums, io.gate, io.up, io.offs, io.order, io.act[side], io.n, E, topk, 10.0); + return affine_mm.gatherTo(e, mm, io.act[side], io.sums, io.down, io.offs, io.yp[side], io.order, io.n, E); + } + const t = @min(io.n, (io.n + bm - 1) / bm + E - 1); + if (glu) { + e.setPipeline(mm[if (bm == 64) 7 else 6]); + inline for (.{ io.x, io.gate.w, io.gate.s, io.gate.b, io.sums }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(affine_mm.Args{ .rows = @intCast(io.n), .n = I, .k = D, .experts = E }, 5); + inline for (.{ io.act[side], io.offs, io.order, io.up.w, io.up.s, io.up.b }, 6..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue([2]f32{ topk, 10.0 }, 12); + return e.dispatchGroups(mtl.Size.of(I / 32, t, 1), mtl.Size.of(32, 2, 2)); + } + e.setPipeline(mm[if (bm == 64) 5 else 4]); + inline for (.{ io.act[side], io.down.w, io.down.s, io.down.b, io.sums }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(affine_mm.Args{ .rows = @intCast(io.n), .n = D, .k = I, .experts = E }, 5); + inline for (.{ io.yp[side], io.offs, io.order }, 6..) |b, i| e.setBuffer(b.buf, b.off, i); + e.dispatchGroups(mtl.Size.of(D / 64, t, 1), mtl.Size.of(32, 2, 2)); +} + +/// Ours at height `bm` (0: groups.zig's choice). +fn ours(e: mtl.ComputeEncoder, p: groups.Pipes, io: *const Io, bm: u32, glu: bool, side: usize) void { + if (bm == 0) { + if (glu) return groups.gatherGlu(e, p, io.x, io.sums, io.gate, io.up, io.offs, io.order, io.act[side], io.n, E, topk, 10.0); + return groups.gatherTo(e, p, io.act[side], io.sums, io.down, io.offs, io.yp[side], io.order, io.n, E); + } + const t = @min(io.n, (io.n + bm - 1) / bm + E - 1); + if (glu) { + e.setPipeline(p[if (bm == 64) 1 else 0]); + inline for (.{ io.x, io.gate.w, io.gate.s, io.gate.b, io.sums }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(affine_mm.Args{ .rows = @intCast(io.n), .n = I, .k = D, .experts = E }, 5); + inline for (.{ io.act[side], io.offs, io.order, io.up.w, io.up.s, io.up.b }, 6..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue([2]f32{ topk, 10.0 }, 12); + return e.dispatchGroups(mtl.Size.of(t * (I / 32), 1, 1), mtl.Size.of(128, 1, 1)); + } + e.setPipeline(p[if (bm == 64) 3 else 2]); + inline for (.{ io.act[side], io.down.w, io.down.s, io.down.b, io.sums }, 0..) |b, i| e.setBuffer(b.buf, b.off, i); + e.setValue(affine_mm.Args{ .rows = @intCast(io.n), .n = D, .k = I, .experts = E }, 5); + inline for (.{ io.yp[side], io.offs, io.order }, 6..) |b, i| e.setBuffer(b.buf, b.off, i); + e.dispatchGroups(mtl.Size.of(t * (D / 64), 1, 1), mtl.Size.of(128, 1, 1)); +} + +/// The routed experts as a prompt chunk runs them, today's way (side 0) or ours (side 1) at height `bm`. +fn pass(q: mtl.Queue, mm: affine_mm.Pipes, p: groups.Pipes, io: *const Io, bm: u32, side: usize) !void { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + affine_mm.rowSums(e, mm, 64, io.x, io.sums, io.rows, D); + if (side == 0) core(e, mm, io, bm, true, 0) else ours(e, p, io, bm, true, 1); + affine_mm.rowSums(e, mm, 64, io.act[side], io.sums, io.n, I); + if (side == 0) core(e, mm, io, bm, false, 0) else ours(e, p, io, bm, false, 1); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } +} + +/// One launch's GPU ms (a command buffer of 3), the activations' sums made before. +fn once(q: mtl.Queue, mm: affine_mm.Pipes, p: groups.Pipes, io: *const Io, side: usize, glu: bool) !f64 { + const n = 3; + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |_| if (side == 0) core(e, mm, io, 0, glu, 0) else ours(e, p, io, 0, glu, 1); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure() != null) return error.GpuFailed; + return cb.gpuSeconds() * 1e3 / n; +} + +pub fn main(init: std.process.Init) !void { + const gpa = init.gpa; + const args = try init.minimal.args.toSlice(init.arena.allocator()); + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + var mm: affine_mm.Pipes = undefined; + var p: groups.Pipes = undefined; + { + const src = try groups.source(device, gpa); + defer gpa.free(src); + const lib = try mtl.Library.fromSource(device, src, mtl.CompileOptions.mlx()); + defer lib.deinit(); + for (affine_mm.names, &mm) |name, *pp| pp.* = try mtl.Pipeline.init(device, lib, name, false); + for (groups.names, &p) |name, *pp| pp.* = try mtl.Pipeline.init(device, lib, name, false); + } + var prng = std.Random.DefaultPrng.init(0x7e); + const r = prng.random(); + const opts = mtl.ResourceOptions.shared; + const max_rows = 16384; + const max_n = max_rows * topk; + var io: Io = undefined; + io.gate = try matrix(device, r, E * I, I, D); + io.up = try matrix(device, r, E * I, I, D); + io.down = try matrix(device, r, E * D, D, I); + io.x = .{ .buf = try device.buffer(max_rows * D * 2, opts) }; + io.sums = .{ .buf = try device.buffer(max_n * (I / 64) * 4, opts) }; + io.offs = .{ .buf = try device.buffer(E * 4, opts) }; + io.order = .{ .buf = try device.buffer(max_n * 4, opts) }; + for (&io.act) |*a| a.* = .{ .buf = try device.buffer(max_n * I * 2, opts) }; + for (&io.yp) |*y| y.* = .{ .buf = try device.buffer(max_n * D * 2, opts) }; + for (io.x.buf.slice(u16, max_rows * D), 0..) |*v, i| v.* = if (i % 499 == 0) 0x8000 else toBf((r.float(f32) - 0.5) * 3); + const picks = try gpa.alloc(i32, max_n); + defer gpa.free(picks); + std.debug.print("GPU {s}: 288 experts, top-8, gate/up 4096 -> 2 x 2048, down 2048 -> 4096, 4-bit/64\n", .{device.name()}); + var row_list: std.ArrayList(u32) = .empty; + for (args[1..]) |a| try row_list.append(gpa, try std.fmt.parseInt(u32, a, 10)); + if (row_list.items.len == 0) try row_list.appendSlice(gpa, &.{ 1, 37, 300, 2048, 7697, 8192, 13616, 16384 }); + var compared: usize = 0; + for (row_list.items) |rows| { + io.rows = rows; + io.n = rows * topk; + route(r, rows, picks[0..io.n]); + var counts: [E]i32 = @splat(0); + for (picks[0..io.n]) |pk| counts[@intCast(pk)] += 1; + const offs = io.offs.buf.slice(i32, E); + var at: i32 = 0; + for (offs, counts) |*o, c| { + o.* = at; + at += c; + } + var fill = offs[0..E].*; + const order = io.order.buf.slice(i32, io.n); + for (picks[0..io.n], 0..) |pk, i| { // sorted pairs in pair order within an expert (the prompt's sort's) + order[@intCast(fill[@intCast(pk)])] = @intCast(i); + fill[@intCast(pk)] += 1; + } + for ([_]u32{ 32, 64, 0 }) |bm| { // both heights against today's at the same height, then each one's own choice + for (0..2) |side| { + @memset(io.act[side].buf.slice(u16, max_n * I), 0x7fc1); + @memset(io.yp[side].buf.slice(u16, max_n * D), 0x7fc1); + } + try pass(queue, mm, p, &io, bm, 0); + try pass(queue, mm, p, &io, bm, 1); + if (!std.mem.eql(u16, io.act[0].buf.slice(u16, max_n * I), io.act[1].buf.slice(u16, max_n * I)) or + !std.mem.eql(u16, io.yp[0].buf.slice(u16, max_n * D), io.yp[1].buf.slice(u16, max_n * D))) + { + std.debug.print("{d} rows, {d}-row tiles: BITS DIFFER\n", .{ rows, bm }); + return error.BitsDiffer; + } + compared += io.n * (I + D); + } + var lo: i32 = std.math.maxInt(i32); + var hi: i32 = 0; + for (counts) |c| { + lo = @min(lo, c); + hi = @max(hi, c); + } + std.debug.print("{d} rows ({d} pairs, {d}-{d} an expert): equal at 32 and 64 rows and each choice\n", .{ rows, io.n, lo, hi }); + if (rows < 128) continue; + var hit: f64 = 0; // the experts a launch reads + for (counts) |c| hit += @floatFromInt(@intFromBool(c > 0)); + var t: [2][2][7]f64 = undefined; // [side][glu, down][trial], interleaved + for (0..7) |trial| for (0..2) |side| { + t[side][0][trial] = try once(queue, mm, p, &io, side, true); + t[side][1][trial] = try once(queue, mm, p, &io, side, false); + }; + for (&t) |*s| for (s) |*v| std.mem.sort(f64, v, {}, std.sort.asc(f64)); + const fl = @as(f64, @floatFromInt(io.n)) * D * I * 2; + std.debug.print(" gate/up {d:.3} -> {d:.3} ms ({d:.1} -> {d:.1} TFLOPS), down {d:.3} -> {d:.3} ms ({d:.1} -> {d:.1} TFLOPS)\n", .{ t[0][0][3], t[1][0][3], 2 * fl / t[0][0][3] / 1e9, 2 * fl / t[1][0][3] / 1e9, t[0][1][3], t[1][1][3], fl / t[0][1][3] / 1e9, fl / t[1][1][3] / 1e9 }); + const wb = hit * D * I * (0.5 + 4.0 / 64.0); // an expert matrix's codes, scales and biases + std.debug.print(" weights read: gate/up {d:.0} -> {d:.0} GB/s, down {d:.0} -> {d:.0} GB/s\n", .{ 2 * wb / t[0][0][3] / 1e6, 2 * wb / t[1][0][3] / 1e6, wb / t[0][1][3] / 1e6, wb / t[1][1][3] / 1e6 }); + } + for ([_][3]u32{ .{ 300, 4096, 8192 }, .{ 1000, 2240, 4096 }, .{ 8192, 4096, 8192 }, .{ 8192, 4096, 16384 }, .{ 8192, 24896, 4096 }, .{ 16384, 4096, 8192 } }) |sh| { + compared += try denseCase(device, queue, mm, p, r, sh[0], sh[1], sh[2]); + } + std.debug.print("{d} outputs equal\n", .{compared}); +} + +/// A dense product at prompt.zig's pitches: affine_mm.dense against mm_groups.dense, bits, then GPU time at 8K rows on. +fn denseCase(device: mtl.Device, queue: mtl.Queue, mm: affine_mm.Pipes, p: groups.Pipes, r: std.Random, M: u32, N: u32, K: u32) !usize { + const opts = mtl.ResourceOptions.shared; + const MK = @as(usize, M) * K; + const x: B = .{ .buf = try device.buffer(MK * 2, opts) }; + defer x.buf.deinit(); + for (x.buf.slice(u16, MK), 0..) |*v, i| v.* = if (i % 997 == 0) 0x8000 else toBf((r.float(f32) - 0.5) * 3); + const q: Mat = try matrix(device, r, N, N, K); + defer for ([_]B{ q.w, q.s, q.b }) |b| b.buf.deinit(); + const sums: B = .{ .buf = try device.buffer(MK / 64 * 4, opts) }; + defer sums.buf.deinit(); + const ys = [2]B{ .{ .buf = try device.buffer(@as(usize, M) * N * 2, opts) }, .{ .buf = try device.buffer(@as(usize, M) * N * 2, opts) } }; + defer for (ys) |y| y.buf.deinit(); + for (ys) |y| @memset(y.buf.slice(u16, @as(usize, M) * N), 0x7fc1); + const st: affine_mm.Strides = .{ .x_row = @intCast(K), .y_row = @intCast(N) }; + { + const cb = queue.commandBuffer(); + const e = cb.compute(.serial); + affine_mm.rowSums(e, mm, 64, x, sums, M, K); + affine_mm.dense(e, mm, x, sums, q, ys[0], M); + groups.dense(e, p, x, sums, q, ys[1], M, st); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure() != null) return error.GpuFailed; + } + if (!std.mem.eql(u16, ys[0].buf.slice(u16, @as(usize, M) * N), ys[1].buf.slice(u16, @as(usize, M) * N))) { + std.debug.print("dense {d} x {d} x {d}: BITS DIFFER\n", .{ M, N, K }); + return error.BitsDiffer; + } + std.debug.print("dense {d} rows, {d} x {d}: equal", .{ M, N, K }); + if (M < 8192) { + std.debug.print("\n", .{}); + return @as(usize, M) * N; + } + var t: [2][7]f64 = undefined; + for (0..7) |trial| for (0..2) |side| { + const cb = queue.commandBuffer(); + const e = cb.compute(.serial); + for (0..3) |_| if (side == 0) affine_mm.dense(e, mm, x, sums, q, ys[0], M) else groups.dense(e, p, x, sums, q, ys[1], M, st); + e.end(); + cb.commit(); + cb.wait(); + t[side][trial] = cb.gpuSeconds() * 1e3 / 3; + }; + for (&t) |*v| std.mem.sort(f64, v, {}, std.sort.asc(f64)); + const fl = 2.0 * @as(f64, @floatFromInt(M)) * @as(f64, @floatFromInt(N)) * @as(f64, @floatFromInt(K)); + std.debug.print("; {d:.3} -> {d:.3} ms ({d:.1} -> {d:.1} TFLOPS)\n", .{ t[0][3], t[1][3], fl / t[0][3] / 1e9, fl / t[1][3] / 1e9 }); + return @as(usize, M) * N; +} diff --git a/zig/tests/glm_moe_pick.zig b/zig/tests/glm_moe_pick.zig new file mode 100644 index 00000000000..da0e40e5892 --- /dev/null +++ b/zig/tests/glm_moe_pick.zig @@ -0,0 +1,173 @@ +//! tf-glm-moe-pick: one-row experts with the select in the gate/up groups against the select launch; bytes, time. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const kernels = tf.glm.kernels; +const affine = tf.glm.affine; +const route = tf.moe_route; +const Ref = affine.Ref; + +const opts = mtl.ResourceOptions.shared; +const a = std.heap.page_allocator; +const E = 288; +const D = 4096; +const N = 2048; +const TOPK = 8; +const MAXR = 16; +const layers = 42; // a round's MoE layers: each launch its own logits row +const block = 1 << 24; // random bytes the weights repeat + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +fn fillRepeat(dst: []u8, src: []const u8) void { + var i: usize = 0; + while (i < dst.len) : (i += src.len) { + const n = @min(src.len, dst.len - i); + @memcpy(dst[i..][0..n], src[0..n]); + } +} + +fn mat(device: mtl.Device, noise: []const u8, n: usize, k: usize, r: std.Random) !affine.Affine { + const w: affine.Width = .{ .bits = 4, .group = 64 }; + const wb = affine.wBytes(n, k, w); + const sb = affine.sBytes(n, k, w); + const bs = [3]mtl.Buffer{ try device.buffer(wb, opts), try device.buffer(sb, opts), try device.buffer(sb, opts) }; + fillRepeat(bs[0].slice(u8, wb), noise); + for (bs[1].slice(u16, sb / 2)) |*v| v.* = toBf(r.float(f32) * 0.02 + 0.001); + for (bs[2].slice(u16, sb / 2)) |*v| v.* = toBf((r.float(f32) - 0.5) * 0.1); + return .{ .w = .{ .buf = bs[0] }, .s = .{ .buf = bs[1] }, .b = .{ .buf = bs[2] }, .n = @intCast(n), .k = @intCast(k), .bits = 4, .group = 64 }; +} + +const W = struct { gate: affine.Affine, up: affine.Affine, down: affine.Affine, sh_gate_up: affine.Affine, sh_down: affine.Affine }; +const Out = struct { act: mtl.Buffer, ye: mtl.Buffer, pick: mtl.Buffer, wts: mtl.Buffer, ids: mtl.Buffer, members: mtl.Buffer, count: mtl.Buffer, lists: mtl.Buffer }; +const Rig = struct { k: *const kernels.Kernels, w: W, x: mtl.Buffer, logits: mtl.Buffer, bias: mtl.Buffer, none: mtl.Buffer, out: [2]Out }; + +fn of(b: mtl.Buffer) Ref { + return .{ .buf = b }; +} + +fn bind(e: mtl.ComputeEncoder, first: usize, refs: anytype) void { + inline for (refs, 0..) |r, i| e.setBuffer(r.buf, r.off, first + i); +} + +/// moe.zig's one-row `both`: side 0 select then experts, side 1 the pick kernels; launch i reads logits row i. +fn launch(e: mtl.ComputeEncoder, i: usize, r: *const Rig, side: usize) void { + const k = r.k; + const o = r.out[side]; + const w = r.w; + const lg = of(r.logits).at((i % layers) * E * 4); + if (side == 0) { + const T: usize = TOPK * MAXR * 4; + const l = of(o.lists); + route.select(e, k.route_select, lg, of(r.bias), 2.5, 1, .{ 0, E }, route.Outputs(Ref){ .pick = of(o.pick), .wts = of(o.wts), .ids = of(o.ids), .members = of(o.members), .count = of(o.count), .mine = l, .theirs = l.at(T), .counts = l.at(2 * T), .word = l.at(2 * T + 64) }); + } + e.setPipeline(if (side == 0) k.moe_gateup_0_one else k.moe_gateup_pick); + bind(e, 0, .{of(r.x)}); + e.setBytes(std.mem.asBytes(&[2]i32{ 1, D }), 1); + bind(e, 2, .{ w.gate.w, w.gate.s, w.gate.b, w.up.w, w.up.s, w.up.b, w.sh_gate_up.w, w.sh_gate_up.s, w.sh_gate_up.b }); + bind(e, 11, if (side == 0) .{ of(o.ids), of(o.members), of(o.count) } else .{ lg, of(r.bias), of(o.pick) }); + e.setValue(@as(f32, 10.0), 14); + bind(e, 15, .{of(o.act)}); + if (side == 1) bind(e, 16, .{of(o.wts)}); + if (side == 1) e.setValue(@as(f32, 2.5), 17); + e.dispatchThreads(mtl.Size.of(32, N / 2, TOPK + 1), mtl.Size.of(32, 1, 1)); + e.setPipeline(if (side == 0) k.moe_down_0_one else k.moe_down_pick); + bind(e, 0, .{of(o.act)}); + e.setBytes(std.mem.asBytes(&[3]i32{ 1, TOPK + 1, N }), 1); + bind(e, 2, .{ w.down.w, w.down.s, w.down.b, w.sh_down.w, w.sh_down.s, w.sh_down.b }); + bind(e, 8, if (side == 0) .{ of(o.ids), of(o.members), of(o.count) } else .{ of(o.pick), of(r.none), of(r.none) }); + bind(e, 11, .{of(o.ye)}); + e.dispatchThreads(mtl.Size.of(32, D / 2, TOPK + 1), mtl.Size.of(32, 1, 1)); +} + +fn run(q: mtl.Queue, r: *const Rig, side: usize, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |i| launch(e, i, r, side); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, r: *const Rig, side: usize) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try run(q, r, side, layers); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +/// Draw `d`'s logits rows and bias: 0 random, 1 a few levels (ties), 2 edge values (NaN, -inf bias, -0), 3 all equal. +fn fill(r: *const Rig, rnd: std.Random, d: usize) void { + for (r.logits.slice(f32, layers * E), 0..) |*v, i| v.* = switch (d) { + 0 => (rnd.float(f32) - 0.5) * 8, + 1 => @round((rnd.float(f32) - 0.5) * 6) / 2, + 2 => if (i % 97 == 0) -0.0 else if (i % 89 == 0) 90 else if (i % 211 == 5) std.math.nan(f32) else (rnd.float(f32) - 0.5) * 4, + else => 0.25, + }; + for (r.bias.slice(f32, E), 0..) |*v, i| v.* = switch (d) { + 0 => (rnd.float(f32) - 0.5) * 0.2, + 1, 3 => @as(f32, @floatFromInt(i % 4)) * 0.125, + else => if (i == 7 or i == 200) -std.math.inf(f32) else (rnd.float(f32) - 0.5) * 0.1, + }; +} + +pub fn main() !void { + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + const k = try kernels.load(a, device); + var prng = std.Random.DefaultPrng.init(0x7c); + const rnd = prng.random(); + const noise = try a.alloc(u8, block); + rnd.bytes(noise); + var r: Rig = .{ .k = k, .w = undefined, .x = try device.buffer(D * 2, opts), .logits = try device.buffer(layers * E * 4, opts), .bias = try device.buffer(E * 4, opts), .none = try device.buffer(64, opts), .out = undefined }; + r.w = .{ .gate = try mat(device, noise, E * N, D, rnd), .up = try mat(device, noise[17..], E * N, D, rnd), .down = try mat(device, noise[33..], E * D, N, rnd), .sh_gate_up = try mat(device, noise[49..], 2 * N, D, rnd), .sh_down = try mat(device, noise[65..], D, N, rnd) }; + for (&r.out) |*o| o.* = .{ .act = try device.buffer((TOPK + 1) * N * 2, opts), .ye = try device.buffer((TOPK + 1) * D * 2, opts), .pick = try device.buffer(TOPK * MAXR * 4, opts), .wts = try device.buffer(TOPK * MAXR * 4, opts), .ids = try device.buffer(TOPK * MAXR * 4, opts), .members = try device.buffer(TOPK * MAXR * MAXR * 4, opts), .count = try device.buffer(64, opts), .lists = try device.buffer(3 * TOPK * MAXR * 4 + 512, opts) }; + std.debug.print("GPU {s}: a one-row MoE layer's experts with the select in the gate/up groups against the select launch\n", .{device.name()}); + var checked: usize = 0; + for (0..4) |d| for (0..2) |_| { + fill(&r, rnd, d); + for (r.x.slice(u16, D)) |*v| v.* = toBf((rnd.float(f32) - 0.5) * 2); + for (0..layers) |i| { + for (r.out) |o| { + @memset(o.act.slice(u16, (TOPK + 1) * N), 0x7fc1); + @memset(o.ye.slice(u16, (TOPK + 1) * D), 0x7fc1); + @memset(o.pick.slice(u8, TOPK * 4), 0x5a); + @memset(o.wts.slice(u8, TOPK * 4), 0x5a); + } + for (0..2) |side| { + const cb = queue.commandBuffer(); + const e = cb.compute(.serial); + launch(e, i, &r, side); + e.end(); + cb.commit(); + cb.wait(); + } + const x0 = r.out[0]; + const x1 = r.out[1]; + if (!std.mem.eql(u16, x0.act.slice(u16, (TOPK + 1) * N), x1.act.slice(u16, (TOPK + 1) * N)) or !std.mem.eql(u16, x0.ye.slice(u16, (TOPK + 1) * D), x1.ye.slice(u16, (TOPK + 1) * D)) or + !std.mem.eql(u8, x0.pick.slice(u8, TOPK * 4), x1.pick.slice(u8, TOPK * 4)) or !std.mem.eql(u8, x0.wts.slice(u8, TOPK * 4), x1.wts.slice(u8, TOPK * 4))) + { + std.debug.print("draw {d}, logits row {d}: BYTES DIFFER\n", .{ d, i }); + return error.BitsDiffer; + } + checked += (TOPK + 1) * (N + D) + 2 * TOPK; + } + }; + fill(&r, rnd, 0); + for (0..8) |_| _ = try run(queue, &r, 0, layers); // clocks up + const t0 = try time(queue, &r, 0); + const t1 = try time(queue, &r, 1); + const t2 = try time(queue, &r, 0); + std.debug.print(" one row: select and experts {d:6.1} / {d:6.1} us, the select in the gate/up groups {d:6.1} us a layer\n", .{ t0, t2, t1 }); + std.debug.print("{d} outputs equal (activations, expert rows, picks, weights) over four draws\n", .{checked}); +} diff --git a/zig/tests/glm_moe_rows.zig b/zig/tests/glm_moe_rows.zig new file mode 100644 index 00000000000..127c88069c9 --- /dev/null +++ b/zig/tests/glm_moe_rows.zig @@ -0,0 +1,181 @@ +//! tf-glm-moe-rows: GLM-5.3-Flash's decode experts at two and four outputs a simdgroup, 1-16 rows: bits, then GPU time. +const std = @import("std"); +const platform = @import("sys"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const kernels = tf.glm.kernels; +const affine = tf.glm.affine; +const Ref = affine.Ref; + +const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked; +const a = std.heap.page_allocator; +const reps = 32; +const runs = 7; +const E = 64; // experts in the pool (906 MB: past the GPU's caches) +const D = 4096; +const N = 2048; +const TOPK = 8; +const MAXR = 16; + +fn buf(device: mtl.Device, bytes: usize) !mtl.Buffer { + return device.buffer(@max(bytes, 16), opts); +} + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +fn mat(device: mtl.Device, r: std.Random, n: usize, k: usize, list: *std.ArrayList(mtl.Buffer)) !affine.Affine { + const w: affine.Width = .{ .bits = 4, .group = 64 }; + const wb = affine.wBytes(n, k, w); + const sb = affine.sBytes(n, k, w); + const bs = [3]mtl.Buffer{ try buf(device, wb), try buf(device, sb), try buf(device, sb) }; + for (bs[0].slice(u32, wb / 4)) |*v| v.* = r.int(u32); + for (bs[1].slice(u16, sb / 2)) |*v| v.* = toBf(r.float(f32) * 0.02 + 0.001); + for (bs[2].slice(u16, sb / 2)) |*v| v.* = toBf((r.float(f32) - 0.5) * 0.1); + try list.appendSlice(a, &bs); + return .{ .w = .{ .buf = bs[0] }, .s = .{ .buf = bs[1] }, .b = .{ .buf = bs[2] }, .n = @intCast(n), .k = @intCast(k), .bits = 4, .group = 64 }; +} + +/// Launch i's route: picks from a window of the pool (a drafted window's overlap), grouped as route_select groups them. +fn route(ids: []i32, members: []i32, count: *i32, i: usize, rows: u32, r: std.Random) void { + const span: usize = @min(E, 8 + 5 * (rows - 1)); + var picks: [MAXR * TOPK]i32 = undefined; + for (0..rows) |row| { + var k: usize = 0; + while (k < TOPK) { + const e: i32 = @intCast((i * 13 + r.uintLessThan(usize, span)) % E); + if (std.mem.indexOfScalar(i32, picks[row * TOPK .. row * TOPK + k], e) == null) { + picks[row * TOPK + k] = e; + k += 1; + } + } + } + var n: i32 = 0; + @memset(members, -1); + for (0..E) |e| { + var c: usize = 0; + for (picks[0 .. rows * TOPK], 0..) |p, pi| if (p == @as(i32, @intCast(e))) { + members[@as(usize, @intCast(n)) * MAXR + c] = @intCast(pi); + c += 1; + }; + if (c > 0) { + ids[@intCast(n)] = @intCast(e); + n += 1; + } + } + count.* = n; +} + +const Route = struct { ids: Ref, members: Ref, count: Ref }; +const Experts = struct { gate: affine.Affine, up: affine.Affine, down: affine.Affine, sh_gate_up: affine.Affine, sh_down: affine.Affine }; +const Set = struct { w: Experts, rt: [reps]Route, x: Ref, act: Ref, y: Ref, act2: Ref, y2: Ref }; + +/// moe.zig `both` with gate/up at `rps[0]` and down at `rps[1]` outputs a simdgroup (2: the _one pipelines, 4: not). +fn launch(e: mtl.ComputeEncoder, i: usize, k: *const kernels.Kernels, s: *const Set, rows: u32, rps: [2]u32, out: [2]Ref) void { + const w = s.w; + const rt = s.rt[i % reps]; + const zs = rows * TOPK + 1; + e.setPipeline(if (rps[0] == 2) k.moe_gateup_0_one else k.moe_gateup_0); + e.setBuffer(s.x.buf, s.x.off, 0); + const xs = [2]i32{ @intCast(rows), D }; + e.setBytes(std.mem.asBytes(&xs), 1); + inline for (.{ w.gate.w, w.gate.s, w.gate.b, w.up.w, w.up.s, w.up.b, w.sh_gate_up.w, w.sh_gate_up.s, w.sh_gate_up.b, rt.ids, rt.members, rt.count }, 2..) |r, j| e.setBuffer(r.buf, r.off, j); + e.setValue(@as(f32, 10.0), 14); + e.setBuffer(out[0].buf, out[0].off, 15); + e.dispatchThreads(mtl.Size.of(32 * rows, N / rps[0], zs), mtl.Size.of(32 * rows, 1, 1)); + e.setPipeline(if (rps[1] == 2) k.moe_down_0_one else k.moe_down_0); + e.setBuffer(out[0].buf, out[0].off, 0); + const ds = [3]i32{ @intCast(rows), TOPK + 1, N }; + e.setBytes(std.mem.asBytes(&ds), 1); + inline for (.{ w.down.w, w.down.s, w.down.b, w.sh_down.w, w.sh_down.s, w.sh_down.b, rt.ids, rt.members, rt.count, out[1] }, 2..) |r, j| e.setBuffer(r.buf, r.off, j); + e.dispatchThreads(mtl.Size.of(32 * rows, D / rps[1], zs), mtl.Size.of(32 * rows, 1, 1)); +} + +fn run(q: mtl.Queue, comptime f: anytype, args: anytype, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |i| @call(.auto, f, .{ e, i } ++ args); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, comptime f: anytype, args: anytype) !f64 { + var t: [runs + 1]f64 = undefined; + for (&t) |*v| v.* = try run(q, f, args, reps); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[1 + runs / 2]; +} + +pub fn main() !void { + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + defer device.deinit(); + const queue = try device.queue(); + defer queue.deinit(); + const k = try kernels.load(a, device); + defer k.deinit(); + var prng = std.Random.DefaultPrng.init(0x77); + const r = prng.random(); + var bufs: std.ArrayList(mtl.Buffer) = .empty; + defer for (bufs.items) |b| b.deinit(); + var s: Set = undefined; + s.w = .{ .gate = try mat(device, r, E * N, D, &bufs), .up = try mat(device, r, E * N, D, &bufs), .down = try mat(device, r, E * D, N, &bufs), .sh_gate_up = try mat(device, r, 2 * N, D, &bufs), .sh_down = try mat(device, r, D, N, &bufs) }; + const io = [_]mtl.Buffer{ try buf(device, MAXR * D * 2), try buf(device, MAXR * 9 * N * 2), try buf(device, MAXR * 9 * D * 2), try buf(device, MAXR * 9 * N * 2), try buf(device, MAXR * 9 * D * 2) }; + try bufs.appendSlice(a, &io); + for (io[0].slice(u16, MAXR * D)) |*v| v.* = toBf((r.float(f32) - 0.5) * 2); + s.x = .{ .buf = io[0] }; + s.act = .{ .buf = io[1] }; + s.y = .{ .buf = io[2] }; + s.act2 = .{ .buf = io[3] }; + s.y2 = .{ .buf = io[4] }; + const route_buf = try buf(device, reps * (128 + 128 * MAXR + 1) * 4); + try bufs.append(a, route_buf); + const one = (128 + 128 * MAXR + 1) * 4; + const per_row = 3 * affine.bytes(N, D, .{ .bits = 4, .group = 64 }); + var checked: usize = 0; + std.debug.print("GPU {s}: decode experts, {d} launches a command buffer, median of {d}\n", .{ device.name(), reps, runs }); + var it = std.mem.tokenizeScalar(u8, if (platform.c.getenv("GLM_MOE_ROWS")) |v| std.mem.span(v) else "1,2,4,8", ','); + while (it.next()) |rv| { + const rows = try std.fmt.parseInt(u32, rv, 10); + var uniq: usize = 0; + for (0..reps) |i| { + const base = Ref{ .buf = route_buf, .off = i * one }; + const ids = route_buf.slice(i32, reps * one / 4)[i * one / 4 ..][0..128]; + const members = route_buf.slice(i32, reps * one / 4)[i * one / 4 + 128 ..][0 .. 128 * MAXR]; + const count = &route_buf.slice(i32, reps * one / 4)[i * one / 4 + 128 + 128 * MAXR]; + route(ids, members, count, i, rows, r); + uniq += @intCast(count.*); + s.rt[i] = .{ .ids = base, .members = base.at(128 * 4), .count = base.at((128 + 128 * MAXR) * 4) }; + } + const bytes = @as(f64, @floatFromInt(uniq)) / reps * @as(f64, @floatFromInt(per_row)) + @as(f64, @floatFromInt(per_row)); + const planes = [2]usize{ rows * 9 * N, rows * 9 * D }; + @memset(io[1].slice(u16, planes[0]), 0); + @memset(io[2].slice(u16, planes[1]), 0); + _ = try run(queue, launch, .{ k, &s, rows, [2]u32{ 4, 4 }, [2]Ref{ s.act, s.y } }, 1); + for (0..24) |_| _ = try run(queue, launch, .{ k, &s, rows, [2]u32{ 4, 4 }, [2]Ref{ s.act2, s.y2 } }, reps); // clocks up first + std.debug.print(" {d:2} rows ({d:.1} experts + shared), gate/up + down outputs a simdgroup:", .{ rows, @as(f64, @floatFromInt(uniq)) / reps }); + for ([_][2]u32{ .{ 4, 4 }, .{ 2, 2 }, .{ 2, 4 }, .{ 4, 2 }, .{ 4, 4 } }) |rps| { + @memset(io[3].slice(u16, planes[0]), 0xffff); + @memset(io[4].slice(u16, planes[1]), 0xffff); + _ = try run(queue, launch, .{ k, &s, rows, rps, [2]Ref{ s.act2, s.y2 } }, 1); + if (!std.mem.eql(u16, io[3].slice(u16, planes[0]), io[1].slice(u16, planes[0])) or !std.mem.eql(u16, io[4].slice(u16, planes[1]), io[2].slice(u16, planes[1]))) { + std.debug.print("\n{d} rows, {d} + {d}: BITS DIFFER\n", .{ rows, rps[0], rps[1] }); + return error.BitsDiffer; + } + checked += planes[0] + planes[1]; + const us = try time(queue, launch, .{ k, &s, rows, rps, [2]Ref{ s.act2, s.y2 } }); + std.debug.print(" {d}+{d} {d:.1} us ({d:.0} GB/s)", .{ rps[0], rps[1], us, bytes / us / 1e3 }); + } + std.debug.print("\n", .{}); + } + std.debug.print("{d} outputs equal four outputs a simdgroup's\n", .{checked}); +} diff --git a/zig/tests/glm_prompt_select.zig b/zig/tests/glm_prompt_select.zig new file mode 100644 index 00000000000..435d859c76d --- /dev/null +++ b/zig/tests/glm_prompt_select.zig @@ -0,0 +1,187 @@ +//! tf-glm-prompt-select: prompt index scores against main's, key lists against mark and merge: bits and GPU time. +const std = @import("std"); +const platform = @import("sys"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const kernels = tf.glm.kernels; +const st = tf.glm.state; + +const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked; +const a = std.heap.page_allocator; + +const HI = 32; +const DI = 128; +const QR = 20480; // qr_proj rows: 64 heads' q_nope, then the indexer's queries +const QOFF = 64 * 256; +const TOP = 2048; +const KPOOL = 4; +const WIDTH = TOP + KPOOL - 1; +const ROWS = 256; // prompt.zig's select_rows +/// Main's glm_index_nax.metal: 64-row tiles of 4 simdgroups, 32 rows x 32 blocks each. +const main_index = @embedFile("contract/baselines/glm_index_nax_main.metal.txt"); + +const ScoreArgs = extern struct { p0: u32, q_stride: u32, w_stride: u32, s_stride: u32, rows: u32 }; +const SelectArgs = extern struct { p0: u32, top: u32, width: u32, s_stride: u32, i_stride: u32 }; + +fn buf(device: mtl.Device, bytes: usize) !mtl.Buffer { + return device.buffer(@max(bytes, 16), opts); +} + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +fn fillBf(b: mtl.Buffer, n: usize, seed: u64, amp: f32) void { + var prng = std.Random.DefaultPrng.init(seed); + const r = prng.random(); + for (b.slice(u16, n)) |*v| v.* = toBf((r.float(f32) - 0.5) * 2 * amp); +} + +const Rig = struct { + queue: mtl.Queue, + k: *const kernels.Kernels, + main_scores: mtl.Pipeline, + cap: u32, + s_stride: u32, + words: u32, + pool: mtl.Buffer, + iq: mtl.Buffer, + iw: mtl.Buffer, + scores: mtl.Buffer, + indices: mtl.Buffer, + bits: mtl.Buffer, +}; + +const Op = enum { scores, rows64, rows128, main, old, mark, merge }; + +fn encode(e: mtl.ComputeEncoder, r: *const Rig, op: Op, p0: u32) void { + const k = r.k; + const most = (p0 + ROWS) / KPOOL; + const sel = SelectArgs{ .p0 = p0, .top = TOP / KPOOL, .width = WIDTH, .s_stride = r.s_stride, .i_stride = WIDTH }; + switch (op) { + .scores, .rows64, .rows128, .main => { + e.setPipeline(if (op == .main) r.main_scores else k.index_scores_nax); + e.setBuffer(r.iq, QOFF * 2, 0); + e.setBuffer(r.iw, 0, 1); + e.setBuffer(r.pool, 0, 2); + e.setBuffer(r.scores, 0, 3); + e.setValue([5]u32{ p0, QR, HI, r.s_stride, ROWS }, 4); + const tr: u32 = switch (op) { // prompt.zig's tiles, either height, main's + .scores => tf.glm.prompt.scoreRows(most, ROWS), + .rows128 => 128, + else => 64, + }; + e.dispatchGroups(mtl.Size.of((most + 63) / 64, (ROWS + tr - 1) / tr, 1), mtl.Size.of(2 * tr, 1, 1)); + }, + .old => { + e.setPipeline(k.index_select); + e.setBuffer(r.scores, 0, 0); + e.setBuffer(r.indices, 0, 1); + e.setValue(sel, 2); + e.dispatchGroups(mtl.Size.of(ROWS, 1, 1), mtl.Size.of(1024, 1, 1)); + }, + .mark => if (most > 3072) { + e.setPipeline(k.select_mark); + e.setBuffer(r.scores, 0, 0); + e.setBuffer(r.bits, 0, 1); + e.setValue(sel, 2); + e.setValue(r.words, 3); + e.dispatchGroups(mtl.Size.of((most + 4095) / 4096, ROWS, 1), mtl.Size.of(256, 1, 1)); + }, + .merge => { + e.setPipeline(k.select_merge); + e.setBuffer(r.scores, 0, 0); + e.setBuffer(r.indices, 0, 1); + e.setValue(sel, 2); + e.setValue(r.words, 3); + e.setBuffer(r.bits, 0, 4); + e.dispatchGroups(mtl.Size.of(ROWS, 1, 1), mtl.Size.of(512, 1, 1)); + }, + } +} + +fn submit(r: *const Rig, ops: []const Op, p0: u32, count: usize) !f64 { + const cb = r.queue.commandBuffer(); + const e = cb.compute(.serial); + for (0..count) |_| for (ops) |op| encode(e, r, op, p0); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(count)); +} + +/// Median GPU microseconds of `ops` once. +fn time(r: *const Rig, ops: []const Op, p0: u32) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try submit(r, ops, p0, 6); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +pub fn main() !void { + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + defer device.deinit(); + const queue = try device.queue(); + defer queue.deinit(); + const k = try kernels.load(a, device); + const main_src = try tf.frags.source(device, a, main_index); + const main_lib = try mtl.Library.fromSource(device, main_src, mtl.CompileOptions.mlx()); + const cap: u32 = 131072; + const s_stride = cap / KPOOL + 1; + const r = Rig{ + .queue = queue, + .k = k, + .main_scores = try mtl.Pipeline.init(device, main_lib, "glm_index_scores_nax", false), + .cap = cap, + .s_stride = s_stride, + .words = st.selectWords(cap, KPOOL), + .pool = try buf(device, @as(usize, s_stride) * DI * 2), + .iq = try buf(device, @as(usize, ROWS) * QR * 2), + .iw = try buf(device, @as(usize, ROWS) * HI * 2), + .scores = try buf(device, @as(usize, ROWS) * s_stride * 4), + .indices = try buf(device, @as(usize, ROWS) * WIDTH * 4), + .bits = try buf(device, @as(usize, ROWS) * st.selectWords(cap, KPOOL) * 4), + }; + fillBf(r.pool, @as(usize, s_stride) * DI, 1, 1.0); + fillBf(r.iq, @as(usize, ROWS) * QR, 2, 1.0); + fillBf(r.iw, @as(usize, ROWS) * HI, 3, 0.2); + var failures: usize = 0; + var pit = std.mem.tokenizeScalar(u8, std.mem.span(platform.c.getenv("GLM_POS") orelse "2048,4096,12288,16384,32768,65536,90000,120000"), ','); + const n = @as(usize, ROWS) * WIDTH; + const want = try a.alloc(i32, n); + defer a.free(want); + while (pit.next()) |pv| { + const p0 = try std.fmt.parseInt(u32, pv, 10); + if (p0 + ROWS + 1 > cap) continue; + const sn = @as(usize, ROWS) * r.s_stride; + @memset(r.scores.slice(u32, sn), 0x7fc00001); + _ = try submit(&r, &.{.main}, p0, 1); + const theirs = try a.dupe(u32, r.scores.slice(u32, sn)); + defer a.free(theirs); + @memset(r.scores.slice(u32, sn), 0x7fc00001); + _ = try submit(&r, &.{ .scores, .old }, p0, 1); + const same_scores = std.mem.eql(u32, theirs, r.scores.slice(u32, sn)); + if (!same_scores) failures += 1; + @memcpy(want, r.indices.slice(i32, n)); + @memset(r.indices.slice(i32, n), 0x5a5a5a5a); + _ = try submit(&r, &.{ .mark, .merge }, p0, 1); + const ok = std.mem.eql(i32, want, r.indices.slice(i32, n)); + if (!ok) failures += 1; + const t_main = try time(&r, &.{.main}, p0); + const t_new = try time(&r, &.{.scores}, p0); + const t64 = try time(&r, &.{.rows64}, p0); + const t128 = try time(&r, &.{.rows128}, p0); + const to = try time(&r, &.{.old}, p0); + const tm = try time(&r, &.{.mark}, p0); + const tg = try time(&r, &.{.merge}, p0); + std.debug.print("pos {d:6}, {d} rows: lists {s}, scores {s}; scores {d:7.1} -> {d:7.1} us (64 rows {d:7.1}, 128 rows {d:7.1}), select {d:7.1} -> {d:7.1} us (mark {d:6.1}, merge {d:6.1})\n", .{ p0, ROWS, if (ok) "equal" else "DIFFER", if (same_scores) "equal" else "DIFFER", t_main, t_new, t64, t128, to, tm + tg, tm, tg }); + } + if (failures > 0) std.process.exit(1); +} diff --git a/zig/tests/glm_route_one.zig b/zig/tests/glm_route_one.zig new file mode 100644 index 00000000000..f803d8a3cf9 --- /dev/null +++ b/zig/tests/glm_route_one.zig @@ -0,0 +1,99 @@ +//! tf-glm-route-one: GLM's router and indexer-gate logits for a one-row window against tf_route_logits; GPU time. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const glm = tf.glm; +const route = tf.moe_route; + +const K = 4096; +const copies = 64; // router copies the timed launches walk (past the GPU's caches) +const reps = 53; // a round's: 42 MoE routers and 11 indexer gates + +fn toBf(v: f32) u16 { + const u: u32 = @bitCast(v); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); +} + +const Rig = struct { x: mtl.Buffer, w: mtl.Buffer, out: [2]mtl.Buffer, experts: u32, s: route.Shape }; + +fn launch(e: mtl.ComputeEncoder, i: usize, pipe: mtl.Pipeline, r: *const Rig, side: usize) void { + const wb = @as(usize, r.experts) * K * 2; + route.logits(e, pipe, r.s, .{ .buf = r.x, .off = 0 }, .{ .buf = r.w, .off = (i % copies) * wb }, .{ .buf = r.out[side], .off = 0 }, 1); +} + +fn run(q: mtl.Queue, pipe: mtl.Pipeline, r: *const Rig, side: usize, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |i| launch(e, i, pipe, r, side); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, pipe: mtl.Pipeline, r: *const Rig) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try run(q, pipe, r, 0, reps); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +pub fn main(init: std.process.Init) !void { + const gpa = init.gpa; + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + const k = try glm.kernels.load(gpa, device); + const opts = mtl.ResourceOptions.shared; + var prng = std.Random.DefaultPrng.init(0x52); + const rnd = prng.random(); + std.debug.print("GPU {s}: one-row router logits against tf_route_logits ({d} launches a timing)\n", .{ device.name(), reps }); + var checked: usize = 0; + const kinds = [_]struct { name: []const u8, s: route.Shape, full: mtl.Pipeline, one: mtl.Pipeline }{ + .{ .name = "router (288, fp32)", .s = glm.kernels.route_shape, .full = k.route_logits, .one = k.route_logits_one }, + .{ .name = "indexer gate (128, bf16)", .s = glm.kernels.igate_shape, .full = k.igate_logits, .one = k.igate_logits_one }, + }; + for (kinds) |kd| { + const E = kd.s.experts; + const ob: usize = if (kd.s.out_bf16) 2 else 4; + var r = Rig{ .x = try device.buffer(16 * K * 2, opts), .w = try device.buffer(copies * @as(usize, E) * K * 2, opts), .out = undefined, .experts = E, .s = kd.s }; + for (&r.out) |*o| o.* = try device.buffer(16 * @as(usize, E) * 4, opts); + for (r.w.slice(u16, copies * @as(usize, E) * K)) |*v| v.* = toBf((rnd.float(f32) - 0.5) * 0.1); + for (0..3) |draw| { // draw 2: zeros, -0, large and tiny values among x + for (r.x.slice(u16, 16 * K), 0..) |*v, i| v.* = if (draw == 2 and i % 53 == 0) 0x8000 else if (draw == 2 and i % 59 == 0) toBf(6e4) else if (draw == 2 and i % 61 == 0) toBf(1e-30) else if (draw == 2 and i % 67 == 0) 0 else toBf((rnd.float(f32) - 0.5) * 4); + for (0..copies) |c| { + for (&r.out) |o| @memset(o.slice(u8, 16 * @as(usize, E) * 4), 0x5a); + try runAt(queue, kd.full, &r, 0, c); + try runAt(queue, kd.one, &r, 1, c); + if (!std.mem.eql(u8, r.out[0].slice(u8, E * ob), r.out[1].slice(u8, E * ob))) { + std.debug.print("{s}, draw {d}, copy {d}: BITS DIFFER\n", .{ kd.name, draw, c }); + return error.BitsDiffer; + } + checked += E; + } + } + for (0..8) |_| _ = try run(queue, kd.full, &r, 0, reps); // clocks up + const t0 = try time(queue, kd.full, &r); + const t1 = try time(queue, kd.one, &r); + std.debug.print(" {s}: tf_route_logits {d:5.2} us, one row {d:5.2} us a launch\n", .{ kd.name, t0, t1 }); + } + std.debug.print("{d} logits equal over three draws\n", .{checked}); +} + +fn runAt(q: mtl.Queue, pipe: mtl.Pipeline, r: *const Rig, side: usize, copy: usize) !void { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + launch(e, copy, pipe, r, side); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } +} diff --git a/zig/tests/glm_route_select.zig b/zig/tests/glm_route_select.zig new file mode 100644 index 00000000000..2072efc1965 --- /dev/null +++ b/zig/tests/glm_route_select.zig @@ -0,0 +1,112 @@ +//! tf-glm-route-select: GLM's route select (top-k, weights, expert groups) against the kept reference, bytes; GPU time. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); +const glm = tf.glm; +const route = tf.moe_route; + +const E = 288; +const TOPK = 8; +const M = 16; +const reps = 42; // a round's MoE layers + +const Out = struct { pick: mtl.Buffer, wts: mtl.Buffer, ids: mtl.Buffer, members: mtl.Buffer, count: mtl.Buffer, mine: mtl.Buffer, theirs: mtl.Buffer, counts: mtl.Buffer, word: mtl.Buffer }; +const sizes = [_]usize{ M * TOPK * 4, M * TOPK * 4, M * TOPK * 4, M * TOPK * M * 4, 16, M * TOPK * 4, M * TOPK * 4, 16, 16 }; + +fn buffers(o: *const Out) [9]mtl.Buffer { + return .{ o.pick, o.wts, o.ids, o.members, o.count, o.mine, o.theirs, o.counts, o.word }; +} + +const Rig = struct { logits: mtl.Buffer, bias: mtl.Buffer, out: [2]Out, pipes: [2]mtl.Pipeline }; + +fn launch(e: mtl.ComputeEncoder, r: *const Rig, side: usize, rows: u32, own: [2]u32) void { + const o = &r.out[side]; + const B = struct { + fn of(b: mtl.Buffer) glm.weights.Ref { + return .{ .buf = b }; + } + }; + route.select(e, r.pipes[side], B.of(r.logits), B.of(r.bias), 2.5, rows, own, route.Outputs(glm.weights.Ref){ .pick = B.of(o.pick), .wts = B.of(o.wts), .ids = B.of(o.ids), .members = B.of(o.members), .count = B.of(o.count), .mine = B.of(o.mine), .theirs = B.of(o.theirs), .counts = B.of(o.counts), .word = B.of(o.word) }); +} + +fn run(q: mtl.Queue, r: *const Rig, side: usize, rows: u32, own: [2]u32, n: usize) !f64 { + const cb = q.commandBuffer(); + const e = cb.compute(.serial); + for (0..n) |_| launch(e, r, side, rows, own); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |msg| { + std.debug.print("GPU failed: {s}\n", .{msg}); + return error.GpuFailed; + } + return cb.gpuSeconds() * 1e6 / @as(f64, @floatFromInt(n)); +} + +fn time(q: mtl.Queue, r: *const Rig, side: usize, rows: u32) !f64 { + var t: [8]f64 = undefined; + for (&t) |*v| v.* = try run(q, r, side, rows, .{ 0, E }, reps); + std.mem.sort(f64, t[1..], {}, std.sort.asc(f64)); + return t[4]; +} + +/// Draw `d`'s logits and bias: 0 random, 1 a few levels (ties within and across rows), 2 edge values, 3 all equal. +fn fill(r: *const Rig, rnd: std.Random, d: usize) void { + const lg = r.logits.slice(f32, M * E); + const bs = r.bias.slice(f32, E); + for (lg, 0..) |*v, i| v.* = switch (d) { + 0 => (rnd.float(f32) - 0.5) * 8, + 1 => @round((rnd.float(f32) - 0.5) * 6) / 2, + 2 => if (i % 97 == 0) -0.0 else if (i % 89 == 0) 90 else if (i % 83 == 0) -90 else if (i % 79 == 0) 1e-30 else if (i % 211 == 5) std.math.nan(f32) else (rnd.float(f32) - 0.5) * 4, + else => 0.25, + }; + for (bs, 0..) |*v, i| v.* = switch (d) { + 0 => (rnd.float(f32) - 0.5) * 0.2, + 1, 3 => @as(f32, @floatFromInt(i % 4)) * 0.125, + else => if (i == 7 or i == 200) -std.math.inf(f32) else if (i % 13 == 0) 0.0 else (rnd.float(f32) - 0.5) * 0.1, + }; +} + +pub fn main(init: std.process.Init) !void { + const gpa = init.gpa; + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + const device = try mtl.Device.init(); + const queue = try device.queue(); + const k = try glm.kernels.load(gpa, device); + const src = try std.mem.concat(gpa, u8, &.{ try route.source(gpa, glm.kernels.route_shape), @embedFile("glm_route_select_ref.metal") }); + const lib = try mtl.Library.fromSource(device, src, mtl.CompileOptions.mlx()); + const opts = mtl.ResourceOptions.shared; + var r: Rig = .{ .logits = try device.buffer(M * E * 4, opts), .bias = try device.buffer(E * 4, opts), .out = undefined, .pipes = .{ try mtl.Pipeline.init(device, lib, "tf_route_select_ref", false), k.route_select } }; + for (&r.out) |*o| { + var bs: [9]mtl.Buffer = undefined; + for (&bs, sizes) |*b, n| b.* = try device.buffer(n, opts); + o.* = .{ .pick = bs[0], .wts = bs[1], .ids = bs[2], .members = bs[3], .count = bs[4], .mine = bs[5], .theirs = bs[6], .counts = bs[7], .word = bs[8] }; + } + var prng = std.Random.DefaultPrng.init(0x5e); + std.debug.print("GPU {s}: the route select of 1-16 rows against the reference kernel ({d} launches a timing)\n", .{ device.name(), reps }); + var checked: usize = 0; + const owns = [_][2]u32{ .{ 0, E }, .{ 0, E / 2 }, .{ E / 2, E } }; + for (0..4) |d| { + for (0..3) |_| { // three fills a draw (draw 3 the same each time) + fill(&r, prng.random(), d); + for (1..M + 1) |rows| for (owns) |own| { + for (&r.out) |*o| for (buffers(o), sizes) |b, n| @memset(b.slice(u8, n), 0x5a); + for (0..2) |side| _ = try run(queue, &r, side, @intCast(rows), own, 1); + for (buffers(&r.out[0]), buffers(&r.out[1]), sizes, 0..) |a, b, n, i| if (!std.mem.eql(u8, a.slice(u8, n), b.slice(u8, n))) { + std.debug.print("draw {d}, {d} rows, experts {d}-{d}: output {d} BYTES DIFFER\n", .{ d, rows, own[0], own[1], i }); + return error.BitsDiffer; + }; + checked += rows * TOPK; + }; + } + } + fill(&r, prng.random(), 0); + for (0..16) |_| _ = try run(queue, &r, 0, 16, .{ 0, E }, reps); // clocks up + for ([_]u32{ 1, 2, 3, 4, 8, 16 }) |rows| { + const t0 = try time(queue, &r, 0, rows); + const t1 = try time(queue, &r, 1, rows); + std.debug.print(" {d:2} rows: reference {d:5.2} us, ours {d:5.2} us a launch\n", .{ rows, t0, t1 }); + } + std.debug.print("{d} picks equal (with weights, groups and pick lists) over four draws\n", .{checked}); +} diff --git a/zig/tests/glm_route_select_ref.metal b/zig/tests/glm_route_select_ref.metal new file mode 100644 index 00000000000..cc2c1c8135d --- /dev/null +++ b/zig/tests/glm_route_select_ref.metal @@ -0,0 +1,97 @@ +// tf-glm-route-select's reference: tf_route_select before its simd picks (appended to its source for TF_ defines). +inline float ref_sigmoid_precise(float x) { + float e = metal::precise::exp(metal::abs(x)); + float y = 1.0f / (1.0f + e); + return (x < 0) ? y : (1.0f - y); +} + +struct RefRouteArgs { + int rows; + int lo, hi; // the experts this Mac computes: [lo, hi) + float scale; +}; + +// 512 threads: each row's top-k by sigmoid + bias (ties to the lower id), weights, then this Mac's groups, pick lists. +[[kernel]] void tf_route_select_ref(const device float* LOGITS [[buffer(0)]], const device float* BIAS [[buffer(1)]], + constant RefRouteArgs& a [[buffer(2)]], device int* PICK [[buffer(3)]], + device float* WTS [[buffer(4)]], device int* LIDS [[buffer(5)]], + device int* LMEM [[buffer(6)]], device int* LCOUNT [[buffer(7)]], + device int* MINE [[buffer(8)]], device int* THEIRS [[buffer(9)]], + device int* COUNTS [[buffer(10)]], device atomic_uint* CNT [[buffer(11)]], + uint t [[thread_position_in_threadgroup]], uint lane [[thread_index_in_simdgroup]], + uint g [[simdgroup_index_in_threadgroup]]) { + const int R = a.rows; + const int e = int(t); + threadgroup int picks[TF_MAXR * TF_TOPK]; + threadgroup int offs[3][16]; + if (int(g) < R) { + const int r = int(g); + float c[PER], sc[PER]; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < TF_E) { + sc[j] = ref_sigmoid_precise(LOGITS[r * TF_E + id]); + c[j] = sc[j] + BIAS[id]; + } else { + sc[j] = 0.0f; c[j] = -INFINITY; + } + } + float w[TF_TOPK]; + for (int k = 0; k < TF_TOPK; k++) { + float best = -INFINITY, bsc = 0.0f; + int bid = TF_E; + for (int j = 0; j < PER; j++) { + const int id = j * 32 + int(lane); + if (id < TF_E && (c[j] > best || (c[j] == best && id < bid))) { best = c[j]; bid = id; bsc = sc[j]; } + } + for (int off = 16; off > 0; off /= 2) { + const float ob = simd_shuffle_xor(best, off); + const int oi = simd_shuffle_xor(bid, off); + const float os = simd_shuffle_xor(bsc, off); + if (ob > best || (ob == best && oi < bid)) { best = ob; bid = oi; bsc = os; } + } + w[k] = bsc; + if (int(lane) == bid % 32) c[bid / 32] = -INFINITY; + if (lane == 0) { picks[r * TF_TOPK + k] = bid; PICK[r * TF_TOPK + k] = bid; } + } + if (lane == 0) { + float total = w[0]; + for (int k = 1; k < TF_TOPK; k++) total = total + w[k]; + for (int k = 0; k < TF_TOPK; k++) WTS[r * TF_TOPK + k] = (w[k] / total) * a.scale; + } + } + threadgroup_barrier(mem_flags::mem_threadgroup); + // the held experts the window picked, ascending, with their member picks in pick order + int members[TF_MAXR]; + int count = 0; + const bool held_id = e >= a.lo && e < a.hi; + if (held_id) + for (int p = 0; p < R * TF_TOPK; p++) + if (picks[p] == e) members[count++] = p; + const int held = count > 0 ? 1 : 0; + // each pick: computed here or by the peer + const int pe = e < R * TF_TOPK ? picks[e] : -1; + const int mine = pe >= a.lo && pe < a.hi ? 1 : 0; + const int theirs = pe >= 0 && mine == 0 ? 1 : 0; + const int b0 = simd_prefix_exclusive_sum(held), b1 = simd_prefix_exclusive_sum(mine), b2 = simd_prefix_exclusive_sum(theirs); + if (lane == 31) { offs[0][g] = b0 + held; offs[1][g] = b1 + mine; offs[2][g] = b2 + theirs; } + threadgroup_barrier(mem_flags::mem_threadgroup); + int o0 = 0, o1 = 0, o2 = 0, n0 = 0, n1 = 0, n2 = 0; + for (uint k = 0; k < 16; k++) { + if (k < g) { o0 += offs[0][k]; o1 += offs[1][k]; o2 += offs[2][k]; } + n0 += offs[0][k]; n1 += offs[1][k]; n2 += offs[2][k]; + } + if (held) { + const int u = o0 + b0; + LIDS[u] = e - a.lo; + for (int j = 0; j < TF_MAXR; j++) LMEM[u * TF_MAXR + j] = j < count ? members[j] : -1; + } + if (mine) MINE[o1 + b1] = e; + if (theirs) THEIRS[o2 + b2] = e; + if (t == 0) { + LCOUNT[0] = n0; + COUNTS[0] = n1; + COUNTS[1] = n2; + atomic_store_explicit(CNT, uint(n1), memory_order_relaxed); + } +} diff --git a/zig/tests/glm_run.zig b/zig/tests/glm_run.zig index 6fee086b346..727013c39db 100644 --- a/zig/tests/glm_run.zig +++ b/zig/tests/glm_run.zig @@ -22,6 +22,7 @@ const usage = \\GLM_PROMPT_PROFILE=REPS (after the replies: each prompt's first chunk by class, each left out or alone), \\GLM_MARGINS=PREFIX (each emitted token's top-two logit margin, f32, to PREFIX.NAME.margins), GLM_MARGINS_VS=PREFIX \\(at the first token that differs from GLM_VS's reply, both runs' margins there), + \\GLM_STATE_HASH (each reply's caches hashed once its prompt is done: KDA states, conv tails, MLA keys, pooled keys), \\GLM_TRACE_LAST=PREFIX (each prompt's last row at every capture point, bf16, to PREFIX.NAME.trace: embedding, then \\each layer's attention input and output and MLP input and output, then the final norm), \\GLM_PROMPT=0 (prompts in 16-row decode windows), GLM_CHUNK=N (prompt chunks of N rows), GLM_COPY=N (copy drafts from @@ -40,11 +41,14 @@ const Collect = struct { logits: []u16 = &.{}, trace_from: []const u8 = &.{}, // the engine's last-row trace, copied into `trace` likewise trace: []u8 = &.{}, + state_of: ?*const glm.engine.Engine = null, // GLM_STATE_HASH: the caches' bytes hashed once the prompt is done + state: [4]u64 = @splat(0), fn prefilled(ctx: *anyopaque) void { const c: *Collect = @ptrCast(@alignCast(ctx)); if (c.logits_from.len > 0) c.logits = c.gpa.dupe(u16, c.logits_from) catch &.{}; if (c.trace_from.len > 0) c.trace = c.gpa.dupe(u8, c.trace_from) catch &.{}; + if (c.state_of) |e| c.state = stateHash(e); } fn tokens(ctx: *anyopaque, t: []const u32) bool { const c: *Collect = @ptrCast(@alignCast(ctx)); @@ -58,6 +62,27 @@ const Collect = struct { } }; +/// The prompt's caches by kind in layer order: KDA states, conv tails, MLA keys, index keys and gates, pooled keys. +fn stateHash(e: *const glm.engine.Engine) [4]u64 { + const c = &e.c; + var h: [4]std.hash.Wyhash = .{ .init(1), .init(2), .init(3), .init(4) }; + const st_bytes = @as(usize, c.kda_heads) * c.kda_dim * c.kda_dim * 4; + const cs_bytes = @as(usize, c.conv - 1) * 3 * c.kdaWidth() * 2; + for (e.s.kda[0..c.countKind(.kda)]) |k| { + h[0].update(k.st[k.cur].addr()[0..st_bytes]); + h[1].update(k.cs[k.cur].addr()[0..cs_bytes]); + } + const n_mla = c.countKind(.mla); + for (e.s.mla[0 .. n_mla + @as(usize, if (e.hasMtp()) 1 else 0)], 0..) |m, i| { + const rows: usize = if (i < n_mla) e.s.pos else e.s.mtp_pos; + h[2].update(m.keys.addr()[0 .. rows * c.kv_lora * 2]); + h[2].update(m.ik.addr()[0 .. rows * c.i_dim * 2]); + h[2].update(m.ig.addr()[0 .. rows * c.i_dim * 2]); + h[3].update(m.pool.addr()[0 .. (rows + c.kpool - 1) / c.kpool * c.i_dim * 2]); // a partial last block too + } + return .{ h[0].final(), h[1].final(), h[2].final(), h[3].final() }; +} + fn env(name: [:0]const u8, default: []const u8) []const u8 { return if (platform.c.getenv(name)) |v| std.mem.span(v) else default; } @@ -192,6 +217,7 @@ pub fn main(init: std.process.Init) !void { defer gpa.free(col.logits); defer gpa.free(col.trace); if (trace_prefix != null and run == 0 and d == depths.items[0]) col.trace_from = e.trace_last.?.addr()[0..trace_bytes]; + if (platform.c.getenv("GLM_STATE_HASH") != null) col.state_of = e; var margins: std.ArrayList(f32) = .empty; defer margins.deinit(gpa); const want_margins = run == 0 and d == depths.items[0] and (platform.c.getenv("GLM_MARGINS") != null or platform.c.getenv("GLM_MARGINS_VS") != null); @@ -204,6 +230,7 @@ pub fn main(init: std.process.Init) !void { const tps = @as(f64, @floatFromInt(toks.len -| 1)) / @max(r.decode_seconds, 1e-9); std.debug.print("{s} depth {d} run {d}: {d} prompt tokens in {d:.2} s ({d:.0} tok/s), {d} tokens at {d:.1} tok/s, {d} rounds, {d}/{d} drafts kept, hash {x:0>16}\n", .{ name, d, run, ids.len, r.prompt_seconds, @as(f64, @floatFromInt(ids.len)) / @max(r.prompt_seconds, 1e-9), toks.len, tps, r.rounds, r.accepted, r.drafted, hash(toks) }); std.debug.print(" tokens: {any}\n", .{toks[0..@min(toks.len, 48)]}); + if (col.state_of != null) std.debug.print(" state after the prompt: KDA states {x:0>16}, conv tails {x:0>16}, MLA keys {x:0>16}, pooled keys {x:0>16}\n", .{ col.state[0], col.state[1], col.state[2], col.state[3] }); if (r.rounds > 0) { const rn: f64 = @floatFromInt(r.rounds); std.debug.print(" a round: {d:.2} ms wall, {d:.2} ms GPU, {d:.2} ms encoding, {d:.2} ms GPU idle between rounds; {d:.2} tokens\n", .{ r.decode_seconds * 1e3 / rn, r.gpu_seconds * 1e3 / rn, r.encode_seconds * 1e3 / rn, r.gap_seconds * 1e3 / @max(rn - 1, 1), @as(f64, @floatFromInt(toks.len -| 1)) / rn }); diff --git a/zig/tests/hip/contract_main.zig b/zig/tests/hip/contract_main.zig index 9317e4d5f11..0e476a52483 100644 --- a/zig/tests/hip/contract_main.zig +++ b/zig/tests/hip/contract_main.zig @@ -239,9 +239,14 @@ fn run(a: std.mem.Allocator, io: std.Io) !usize { for (&streams, 0..) |*x, i| x.* = .init(a, &r, s, &l, i); defer for (&streams) |*x| x.deinit(); for (&streams) |*x| try kernels.append(a, x.kernel()); - var relu2 = relu2_k.Relu2.init(a, &r, s, &l); - defer relu2.deinit(); - try kernels.append(a, relu2.kernel()); + // each width's relu^2 stream tile, then each wider width's planted control (its codes read as 4-bit) + var relu2s: [2 * relu2_k.widths.len - 1]relu2_k.Relu2 = undefined; + for (&relu2s, 0..) |*x, i| { + const plant = i >= relu2_k.widths.len; + x.* = .init(a, &r, s, &l, relu2_k.widths[if (plant) i + 1 - relu2_k.widths.len else i], plant); + } + defer for (&relu2s) |*x| x.deinit(); + for (&relu2s) |*x| try kernels.append(a, x.kernel()); var kv_write = kv_k.KvWrite.init(a, &r, s, &l); defer kv_write.deinit(); try kernels.append(a, kv_write.kernel()); diff --git a/zig/tests/hip/contract_relu2.zig b/zig/tests/hip/contract_relu2.zig index ae57c3f7496..d8248926df6 100644 --- a/zig/tests/hip/contract_relu2.zig +++ b/zig/tests/hip/contract_relu2.zig @@ -1,4 +1,4 @@ -//! The stream tile with Nemotron's relu^2 as its epilogue under the contract on HIP: the plain tile then tf_nemo_relu2. +//! The stream tile with Nemotron's relu^2 as its epilogue under the contract on HIP, at each width oQ checkpoints hold. const std = @import("std"); const hip = @import("hip"); const core = @import("core"); @@ -6,6 +6,8 @@ const rig_ = @import("contract_rig.zig"); const kit = @import("contract_kit.zig"); const contract = core.contract; +const Allocator = std.mem.Allocator; +const Launcher = hip.Launcher; const c = contract.spec; const g = contract.gates; @@ -13,23 +15,32 @@ const Kernels = @FieldType(hip.Launcher, "affine"); /// launches/affine.zig's Arg, as relu2Go takes it. pub const Arg = @typeInfo(@TypeOf(Kernels.relu2Go)).@"fn".param_types[2].?; -const bits = 4; // Nano's MLX checkpoints const group = 64; +/// The widths Nemotron's MLX and oQ checkpoints store the relu^2 products at. +pub const widths = [_]u8{ 4, 5, 6, 8 }; /// A group's codes by dot2 pairs, its scale and bias, then the groups' sum: one fp32 chain over k. fn depth(s: c.Shape) usize { return s.k / 2 + s.k / group + 8; } -const names = [2][]const u8{ - "hip affine_dot2_stream_relu2 (4-bit, fp16)", - "hip affine_dot2_stream_relu2 (4-bit, bf16)", -}; +fn name(comptime bits: u8, k: kit.Kind, plant: bool) []const u8 { + const fmt = "hip affine_dot2_stream_relu2 ({d}-bit, {s})"; + const half = std.fmt.comptimePrint(fmt, .{ bits, "fp16" }); + const kinds = [2][]const u8{ half, std.fmt.comptimePrint(fmt, .{ bits, "bf16" }) }; + const control = std.fmt.comptimePrint("control: the {d}-bit relu2 stream tile reads its codes as 4-bit", .{bits}); + return if (plant) control else kinds[@intFromBool(k == .bf16)]; +} + +fn nameOf(bits: u8, k: kit.Kind, plant: bool) []const u8 { + inline for (widths) |b| if (b == bits) return name(b, k, plant); + unreachable; +} const bf16_why = "the bound's two roundings to bf16 cap the miss of a sum relu turns to 0 at 85x"; -pub fn spec(k: kit.Kind) c.Spec { +pub fn spec(k: kit.Kind, bits: u8, plant: bool) c.Spec { return .{ - .name = names[@intFromBool(k == .bf16)], + .name = nameOf(bits, k, plant), .accum = .f32, .depth = depth, .ops = 1, @@ -48,19 +59,23 @@ pub fn spec(k: kit.Kind) c.Spec { }; } -/// x [rows][k] of the kind times the MLX 4-bit matrix [n][k]: relu(round(y))^2 [rows][n] of the kind. +/// x [rows][k] of the kind times the MLX matrix [n][k] at `bits`: relu(round(y))^2 [rows][n] of the kind. pub const Relu2 = struct { rig: rig_.Rig, - l: *const hip.Launcher, + l: *const Launcher, k: kit.Kind, + bits: u8, + /// The planted control: the tile told 4-bit over codes packed at `bits`, which gate 3 must turn red. + plant: bool, arena: std.heap.ArenaAllocator, f: ?contract.affine.Affine = null, arg: Arg = undefined, sum: u64 = 0, base: u64 = 0, - pub fn init(a: std.mem.Allocator, rt: *const hip.Runtime, s: hip.Stream, l: *const hip.Launcher) Relu2 { - return .{ .rig = .{ .a = a, .r = rt, .s = s }, .l = l, .k = kit.act(), .arena = .init(a) }; + pub fn init(a: Allocator, rt: *const hip.Runtime, s: hip.Stream, l: *const Launcher, bits: u8, plant: bool) Relu2 { + const rig: rig_.Rig = .{ .a = a, .r = rt, .s = s }; + return .{ .rig = rig, .l = l, .k = kit.act(), .bits = bits, .plant = plant, .arena = .init(a) }; } pub fn deinit(self: *Relu2) void { @@ -69,7 +84,8 @@ pub const Relu2 = struct { } pub fn kernel(self: *Relu2) g.Kernel { - return .{ .spec = spec(self.k), .ctx = self, .vt = &vt }; + const control: ?g.Gate = if (self.plant) .shapes else null; + return .{ .spec = spec(self.k, self.bits, self.plant), .ctx = self, .vt = &vt, .control = control }; } const vt = g.hooks(Relu2); @@ -79,6 +95,7 @@ pub const Relu2 = struct { self.rig.reset(); _ = self.arena.reset(.retain_capacity); const a = self.arena.allocator(); + const bits = self.bits; var f = try contract.affine.Affine.init(a, shape, bits, group); try f.fill(fill, seed); // gate 4's rows sum to a negative product, which relu would hide: x negated makes it positive @@ -109,7 +126,7 @@ pub const Relu2 = struct { .m = @intCast(shape.rows), .n = @intCast(shape.n), .k = @intCast(shape.k), - .bits = bits, + .bits = if (self.plant) 4 else bits, .group = group, .fp16 = @intFromBool(self.k == .f16), .out16 = out, @@ -122,9 +139,10 @@ pub const Relu2 = struct { try self.rig.s.synchronize(); } - /// The plain stream tile's fp32 sums, then tf_nemo_relu2 into the kind. + /// The plain stream tile's fp32 sums at the codes' own width, then tf_nemo_relu2 into the kind. pub fn replaced(self: *Relu2) ![]const u8 { var plain = self.arg; + plain.bits = self.bits; plain.out = self.sum; plain.out16 = 0; try self.l.affine.streamGo(self.l.r, plain, .{}, plain.n, 1, self.rig.s.handle); diff --git a/zig/tests/hip/contract_relu2_pair.zig b/zig/tests/hip/contract_relu2_pair.zig index 15f7f072bc0..f837e2442d2 100644 --- a/zig/tests/hip/contract_relu2_pair.zig +++ b/zig/tests/hip/contract_relu2_pair.zig @@ -29,7 +29,7 @@ const names = [2][]const u8{ }; pub fn spec(k: kit.Kind) c.Spec { - var s = relu2_k.spec(k); + var s = relu2_k.spec(k, 4, false); s.name = names[@intFromBool(k == .bf16)]; s.nan = .{ .stated = "the separate launches' bytes and every float64 output class" }; s.depth = depth; diff --git a/zig/tests/idol.zig b/zig/tests/idol.zig new file mode 100644 index 00000000000..330d091952b --- /dev/null +++ b/zig/tests/idol.zig @@ -0,0 +1,41 @@ +//! tf-idol on Metal: idol_run.zig's case driver on the system GPU. +const std = @import("std"); +const mtl = @import("metal"); +const tf = @import("tensorfold"); + +const Metal = struct { + pub const id = tf.idol; + pub const st = tf.safetensors; + pub const seconds = mtl.clock.seconds; + + pub fn stream(m: *id.Model, rows: usize) ![]const f16 { + return m.stream(rows); + } + + pub const Device = struct { + pool: mtl.objc.Pool, + device: mtl.Device, + + pub fn init(g: *Device) !void { + g.pool = mtl.objc.Pool.push(); + errdefer g.pool.pop(); + g.device = try mtl.Device.init(); + } + + pub fn deinit(g: *Device) void { + g.pool.pop(); + } + + pub fn name(g: *Device) []const u8 { + return std.mem.span(g.device.name()); + } + + pub fn load(g: *Device, gpa: std.mem.Allocator, io: std.Io, dir: []const u8) !*id.Model { + return id.Model.load(gpa, io, g.device, dir); + } + }; +}; + +pub fn main(init: std.process.Init) !u8 { + return @import("idol_run.zig").run(Metal, init); +} diff --git a/zig/tests/idol_cuda.zig b/zig/tests/idol_cuda.zig new file mode 100644 index 00000000000..45d23286079 --- /dev/null +++ b/zig/tests/idol_cuda.zig @@ -0,0 +1,43 @@ +//! tf-idol on CUDA: idol_run.zig's case driver on the first GPU (sm_120 or sm_121; others are refused by name). +const std = @import("std"); +const cuda = @import("cuda"); +const core = @import("core"); + +const Cuda = struct { + pub const id = @import("idol"); + pub const st = core.safetensors; + pub const seconds = id.seconds; + + pub fn stream(m: *id.Model, rows: usize) ![]const f16 { + return m.residual(rows); + } + + pub const Device = struct { + driver: cuda.Driver, + ctx: cuda.Context, + buf: [256]u8, + + pub fn init(g: *Device) !void { + g.driver = try cuda.Driver.open(); + errdefer g.driver.close(); + g.ctx = try cuda.Context.init(&g.driver, 0); + } + + pub fn deinit(g: *Device) void { + g.ctx.deinit(); + g.driver.close(); + } + + pub fn name(g: *Device) []const u8 { + return g.ctx.name(&g.buf) catch "a CUDA GPU"; + } + + pub fn load(g: *Device, gpa: std.mem.Allocator, io: std.Io, dir: []const u8) !*id.Model { + return id.Model.load(gpa, io, &g.ctx, dir); + } + }; +}; + +pub fn main(init: std.process.Init) !u8 { + return @import("idol_run.zig").run(Cuda, init); +} diff --git a/zig/tests/idol_run.zig b/zig/tests/idol_run.zig new file mode 100644 index 00000000000..095ca78d215 --- /dev/null +++ b/zig/tests/idol_run.zig @@ -0,0 +1,248 @@ +//! tf-idol's case driver for a backend `B`: its family `id`, safetensors `st`, `seconds`, `Device` and `stream`. +const std = @import("std"); + +const usage = + \\tf-idol SNAPSHOT_DIR CASE_DIR [blocks STEP] + \\SNAPSHOT_DIR is a speridlabs/idol snapshot (config.json, denoiser.safetensors). CASE_DIR (tools/zig/idol_case.py) + \\holds case.safetensors: both image conditions, the starting noise and the SDK's run (each step's input and both + \\branches' velocities), and optionally exact.safetensors (the same steps in float32). Each step runs both branches on + \\the SDK's input; with exact.safetensors each 1 - cosine against float32 must be within twice the SDK's own, and + \\so must the worst row over the run. Then the whole guided schedule runs from the noise, timed; CASE_DIR gets tf-idol.json and + \\sample.f32 (8192 x 16, then the 5 camera values). Exit 1 on a failed gate or a forward that does not repeat. + \\With `blocks STEP`, runs each joint block alone on the SDK's input rows at that step (blocksSTEP.safetensors) + \\and gates it against the same block in float32 (blocksSTEP_f32.safetensors), worst row and 1 - cosine. +; + +/// The card's sampling defaults. +const guidance: f32 = 3.0; +const rescale: f64 = 3.0; + +fn take(a: std.mem.Allocator, f: anytype, name: []const u8, n: usize) ![]f32 { + const t = f.get(name) orelse { + std.debug.print("the case has no {s}\n", .{name}); + return error.MissingTensor; + }; + if (t.dtype != .f32 or t.numel() != n) { + std.debug.print("{s} is not {d} float32 values\n", .{ name, n }); + return error.BadCaseTensor; + } + const out = try a.alloc(f32, n); + @memcpy(std.mem.sliceAsBytes(out), t.bytes); + return out; +} + +fn print(list: *std.ArrayList(u8), a: std.mem.Allocator, comptime fmt: []const u8, args: anytype) !void { + try list.appendSlice(a, try std.fmt.allocPrint(a, fmt, args)); +} + +fn json(list: *std.ArrayList(u8), a: std.mem.Allocator, key: []const u8, m: anytype) !void { + try print(list, a, ", \"{s}\": {{\"max_abs\": {d:.6}, \"cosine\": {d:.9}, \"worst_row\": {d:.6}}}", .{ key, m.max_abs, m.cosine, m.worst_row }); +} + +const Case = struct { + steps: usize, + timesteps: []f32, + inputs: []f32, + inputs_camera: []f32, + velocity: [2][]f32, + velocity_camera: [2][]f32, + exact: ?[2][]f32, +}; + +const labels = [2][]const u8{ "conditional", "negative" }; + +/// Each step's two branches on the SDK's input against its velocities; returns false when a gate fails. +fn teacher(comptime B: type, a: std.mem.Allocator, c: Case, model: *B.id.Model, conds: *[2]B.id.Condition, out: *std.ArrayList(u8)) !bool { + const cfg = B.id.config; + const ref = B.id.reference; + const N = cfg.latent_rows * cfg.latent_channels; + var pass = true; + var worst = [2]f64{ 0, 0 }; + const v = try a.alloc(f32, N); + var vc: [cfg.camera_channels]f32 = undefined; + try print(out, a, ", \"teacher_forced\": [", .{}); + for (0..c.steps) |s| { + try print(out, a, "{s}{{\"step\": {d}, \"time\": {d:.4}", .{ if (s == 0) "" else ", ", s + 1, c.timesteps[s] }); + const cam: *const [cfg.camera_channels]f32 = c.inputs_camera[s * cfg.camera_channels ..][0..cfg.camera_channels]; + for (0..2) |b| { + _ = try model.forward(&conds[b], c.inputs[s * N ..][0..N], cam, c.timesteps[s], v, &vc); + const theirs = c.velocity[b][s * N ..][0..N]; + const m = ref.match(v, theirs, cfg.latent_channels); + const mc = ref.match(&vc, c.velocity_camera[b][s * cfg.camera_channels ..][0..cfg.camera_channels], cfg.camera_channels); + std.debug.print("step {d} {s}: against the SDK max |diff| {d:.5}, cosine {d:.8}, worst row {d:.5}; camera cosine {d:.7}\n", .{ s + 1, labels[b], m.max_abs, m.cosine, m.worst_row, mc.cosine }); + try json(out, a, try std.fmt.allocPrint(a, "{s}_sdk", .{labels[b]}), m); + try json(out, a, try std.fmt.allocPrint(a, "{s}_camera_sdk", .{labels[b]}), mc); + if (c.exact) |ex| if (ex[b].len >= (s + 1) * N) { + const want = ex[b][s * N ..][0..N]; + const ours = ref.match(v, want, cfg.latent_channels); + const sdk = ref.match(theirs, want, cfg.latent_channels); + const ok = ref.withinCosine(ours, sdk); + pass = pass and ok; + worst[0] = @max(worst[0], ours.worst_row); + worst[1] = @max(worst[1], sdk.worst_row); + std.debug.print(" against float32: worst row {d:.5}, cosine {d:.8}; the SDK's own {d:.5}, {d:.8}: {s}\n", .{ ours.worst_row, ours.cosine, sdk.worst_row, sdk.cosine, if (ok) "pass" else "FAIL" }); + try json(out, a, try std.fmt.allocPrint(a, "{s}_fp32", .{labels[b]}), ours); + try json(out, a, try std.fmt.allocPrint(a, "{s}_sdk_vs_fp32", .{labels[b]}), sdk); + }; + } + try out.append(a, '}'); + } + if (c.exact != null) { + const ok = worst[0] <= ref.factor * worst[1]; + std.debug.print("worst row over the run against float32: {d:.5}; the SDK's own {d:.5}: {s}\n", .{ worst[0], worst[1], if (ok) "pass" else "FAIL" }); + pass = pass and ok; + } + try print(out, a, "], \"worst_row_fp32\": {d:.6}, \"sdk_worst_row_fp32\": {d:.6}", .{ worst[0], worst[1] }); + return pass; +} + +/// The same step twice with the other branch between: identical bytes or not. +fn repeats(comptime B: type, a: std.mem.Allocator, c: Case, model: *B.id.Model, conds: *[2]B.id.Condition) !bool { + const cfg = B.id.config; + const N = cfg.latent_rows * cfg.latent_channels; + const first = try a.alloc(f32, N); + const again = try a.alloc(f32, N); + var vc: [cfg.camera_channels]f32 = undefined; + const cam: *const [cfg.camera_channels]f32 = c.inputs_camera[0..cfg.camera_channels]; + _ = try model.forward(&conds[0], c.inputs[0..N], cam, c.timesteps[0], first, &vc); + _ = try model.forward(&conds[1], c.inputs[0..N], cam, c.timesteps[@min(1, c.steps - 1)], again, &vc); + _ = try model.forward(&conds[0], c.inputs[0..N], cam, c.timesteps[0], again, &vc); + return std.mem.eql(u8, std.mem.sliceAsBytes(first), std.mem.sliceAsBytes(again)); +} + +/// The case tensor `name`, fp16 or fp32 rows, as f32. +fn rows(a: std.mem.Allocator, f: anytype, name: []const u8) ![]f32 { + const t = f.get(name) orelse return error.MissingTensor; + const out = try a.alloc(f32, t.numel()); + switch (t.dtype) { + .f16 => for (out, @as([*]align(1) const f16, @ptrCast(t.bytes.ptr))[0..out.len]) |*o, v| { + o.* = v; + }, + .f32 => @memcpy(std.mem.sliceAsBytes(out), t.bytes), + else => return error.BadCaseTensor, + } + return out; +} + +/// Each joint block alone on the SDK's own input rows at step `step`, against that block in float32; false on a fail. +fn blockGates(comptime B: type, a: std.mem.Allocator, io: std.Io, dir: []const u8, step: usize, c: Case, model: *B.id.Model) !bool { + const cfg = B.id.config; + const ref = B.id.reference; + var f = try B.st.File.open(a, io, try std.fmt.allocPrint(a, "{s}/blocks{d}.safetensors", .{ dir, step })); + defer f.close(io); + var g = try B.st.File.open(a, io, try std.fmt.allocPrint(a, "{s}/blocks{d}_f32.safetensors", .{ dir, step })); + defer g.close(io); + const H = cfg.hidden; + var pass = true; + var name: [32]u8 = undefined; + for (1..cfg.layers) |i| { + const input = try rows(a, &f, try std.fmt.bufPrint(&name, "block.{d}", .{i - 1})); + const in16 = try a.alloc(f16, input.len); + for (in16, input) |*o, v| o.* = @floatCast(v); + try model.blockAt(cfg.refiners + i, in16, c.timesteps[step]); + const ours = try a.alloc(f32, input.len); + for (ours, try B.stream(model, cfg.joint_rows)) |*o, v| o.* = v; + const label = try std.fmt.bufPrint(&name, "block.{d}", .{i}); + const want = try rows(a, &g, label); + const m = ref.match(ours, want, H); + const r = ref.match(try rows(a, &f, label), want, H); + const ok = ref.within(m, r); + pass = pass and ok; + std.debug.print("step {d} block {d} against float32: worst row {d:.5}, cosine {d:.9}; the SDK's own {d:.5}, {d:.9}: {s}\n", .{ step + 1, i, m.worst_row, m.cosine, r.worst_row, r.cosine, if (ok) "pass" else "FAIL" }); + } + return pass; +} + +pub fn run(comptime B: type, init: std.process.Init) !u8 { + const id = B.id; + const cfg = id.config; + const ref = id.reference; + const N = cfg.latent_rows * cfg.latent_channels; + const a = init.arena.allocator(); + const io = init.io; + const args = try init.minimal.args.toSlice(a); + if (args.len != 3 and args.len != 5) { + std.debug.print("{s}\n", .{usage}); + return 2; + } + var case = try B.st.File.open(a, io, try std.fmt.allocPrint(a, "{s}/case.safetensors", .{args[2]})); + defer case.close(io); + const steps = (case.get("timesteps") orelse return error.MissingTensor).numel(); + const S = steps; + const cam_n = cfg.camera_channels; + var c: Case = .{ .steps = S, .timesteps = try take(a, &case, "timesteps", S), .inputs = try take(a, &case, "inputs", S * N), .inputs_camera = try take(a, &case, "inputs_camera", S * cam_n), .velocity = .{ try take(a, &case, "velocity", S * N), try take(a, &case, "velocity_negative", S * N) }, .velocity_camera = .{ try take(a, &case, "velocity_camera", S * cam_n), try take(a, &case, "velocity_negative_camera", S * cam_n) }, .exact = null }; + const exact_path = try std.fmt.allocPrint(a, "{s}/exact.safetensors", .{args[2]}); + var exact_file: ?B.st.File = B.st.File.open(a, io, exact_path) catch null; + defer if (exact_file) |*f| f.close(io); + if (exact_file) |*f| { + const n = (f.get("velocity_f32") orelse return error.MissingTensor).numel(); + c.exact = .{ try take(a, f, "velocity_f32", n), try take(a, f, "velocity_negative_f32", n) }; + } + const f1 = try take(a, &case, "feature1", cfg.cond_rows * cfg.cond_channels); + const f2 = try take(a, &case, "feature2", cfg.cond_rows * cfg.cond2_channels); + const noise = try take(a, &case, "latent", N); + const noise_cam = try take(a, &case, "camera", cam_n); + + var gpu: B.Device = undefined; + try gpu.init(); + defer gpu.deinit(); + const device = gpu.name(); + const loading = B.seconds(); + const model = try gpu.load(std.heap.page_allocator, io, args[1]); + defer model.deinit(); + const load_s = B.seconds() - loading; + std.debug.print("{s}: {d} steps; loaded in {d:.1} s\n", .{ device, S, load_s }); + + var out: std.ArrayList(u8) = .empty; + const conditioning = B.seconds(); + var conds: [2]id.Condition = undefined; + conds[0] = try model.condition(f1, f2); + defer conds[0].deinit(); + @memset(f1, 0); + @memset(f2, 0); + conds[1] = try model.condition(f1, f2); + defer conds[1].deinit(); + const condition_s = B.seconds() - conditioning; + if (args.len == 5) return if (try blockGates(B, a, io, args[2], try std.fmt.parseInt(usize, args[4], 10), c, model)) 0 else 1; + try print(&out, a, "{{\"device\": \"{s}\", \"steps\": {d}, \"load_s\": {d:.2}, \"condition_s\": {d:.4}", .{ device, S, load_s, condition_s }); + const pass = try teacher(B, a, c, model, &conds, &out); + const repeat = try repeats(B, a, c, model, &conds); + std.debug.print("the same step twice, another between: {s}\n", .{if (repeat) "identical bytes" else "DIFFERENT bytes"}); + try print(&out, a, ", \"gates_pass\": {}, \"repeat_identical\": {}, \"run\": [", .{ pass and c.exact != null, repeat }); + + const ts = try a.alloc(f64, S + 1); + id.host.schedule(ts, rescale); + const x = try a.alloc(f32, N + cam_n); + @memcpy(x[0..N], noise); + @memcpy(x[N..], noise_cam); + const vc = try a.alloc(f32, N); + const vu = try a.alloc(f32, N); + var cc: [cam_n]f32 = undefined; + var cu: [cam_n]f32 = undefined; + var total: f64 = 0; + for (0..S) |s| { + const time: f32 = @floatCast(1000 * ts[s]); + const cam: *const [cam_n]f32 = x[N..][0..cam_n]; + const p = try model.forward(&conds[0], x[0..N], cam, time, vc, &cc); + const q = try model.forward(&conds[1], x[0..N], cam, time, vu, &cu); + const by: f32 = @floatCast(ts[s] - ts[s + 1]); + for (x[0..N], vc, vu) |*o, pc, pu| o.* -= ((1 + guidance) * pc - guidance * pu) * by; + for (x[N..], cc, cu) |*o, pc, pu| o.* -= ((1 + guidance) * pc - guidance * pu) * by; + const wall = p.wall + q.wall; + total += wall; + std.debug.print("step {d}/{d}: {d:.3} s ({d:.3} s on the GPU)\n", .{ s + 1, S, wall, p.gpu + q.gpu }); + try print(&out, a, "{s}{{\"wall_s\": {d:.4}, \"gpu_s\": {d:.4}}}", .{ if (s == 0) "" else ", ", wall, p.gpu + q.gpu }); + } + if (case.get("sample") != null) { + const sample = try take(a, &case, "sample", N); + const m = ref.match(x[0..N], sample, cfg.latent_channels); + std.debug.print("final sample against the SDK's: cosine {d:.6}, worst row {d:.4}\n", .{ m.cosine, m.worst_row }); + try print(&out, a, "]", .{}); + try json(&out, a, "sample_sdk", m); + try print(&out, a, ", \"denoise_s\": {d:.3}}}\n", .{total}); + } else try print(&out, a, "], \"denoise_s\": {d:.3}}}\n", .{total}); + std.debug.print("denoise: {d:.2} s for {d} steps ({d} forwards)\n", .{ total, S, 2 * S }); + try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = try std.fmt.allocPrint(a, "{s}/sample.f32", .{args[2]}), .data = std.mem.sliceAsBytes(x) }); + try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = try std.fmt.allocPrint(a, "{s}/tf-idol.json", .{args[2]}), .data = out.items }); + return if (repeat and (c.exact == null or pass)) 0 else 1; +} diff --git a/zig/tests/ling_mla_gpu.zig b/zig/tests/ling_mla_gpu.zig new file mode 100644 index 00000000000..15dc64e79d1 --- /dev/null +++ b/zig/tests/ling_mla_gpu.zig @@ -0,0 +1,6 @@ +//! GPU check of Ling MLA around k3_mla: RoPE, head-gate expand, mixer vs mla.zig. +test { + _ = @import("ling_mla_gpu_kernels.zig"); + _ = @import("ling_mla_gpu_mixer.zig"); + _ = @import("ling_mla_gpu_chunks.zig"); +} diff --git a/zig/tests/ling_mla_gpu_chunks.zig b/zig/tests/ling_mla_gpu_chunks.zig new file mode 100644 index 00000000000..412eaf117d3 --- /dev/null +++ b/zig/tests/ling_mla_gpu_chunks.zig @@ -0,0 +1,238 @@ +//! Ling MLA whole vs chunks, resume vs fresh, large-T and dump gates. +const std = @import("std"); +const mtl = @import("metal"); +const mla = @import("mla"); +const c = @import("ling_mla_gpu_common.zig"); +const dump = @import("ling_mla_gpu_dump.zig"); + +const k3_gpu_rows: u32 = 256; + +fn checkChunks() !void { + const a = std.testing.allocator; + const rows: u32 = 4; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const in = try c.Inputs.make(a, s, rows, 0x6d6c61); + defer in.free(a); + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var g = try c.Gpu.init(); + defer g.deinit(); + var whole = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer whole.deinit(); + try whole.dispatchMixer(g, 0, rows); + var chunks = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer chunks.deinit(); + try chunks.dispatchMixer(g, 0, 2); + try chunks.dispatchMixer(g, 2, 2); + try c.expectBitsEqual("whole vs chunks", whole.y(), chunks.y()); +} + +fn checkResume() !void { + const a = std.testing.allocator; + const rows: u32 = 4; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const in = try c.Inputs.make(a, s, rows, 0x72657375); + defer in.free(a); + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var g = try c.Gpu.init(); + defer g.deinit(); + var fresh = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer fresh.deinit(); + try fresh.dispatchMixer(g, 0, rows); + var continued = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer continued.deinit(); + try continued.dispatchMixer(g, 0, 2); + try continued.dispatchMixer(g, 2, 2); + const W = s.outWidth(); + try c.expectBitsEqual("resume vs fresh (all rows)", fresh.y(), continued.y()); + try c.expectBitsEqual("resume vs fresh (last 2)", fresh.y()[2 * W ..], continued.y()[2 * W ..]); +} + +fn checkRopeLargePos() !void { + const a = std.testing.allocator; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const rows_n: u32 = 2; + const first_pos: u32 = 29998; + const slot_keys: u32 = 30000; + const H = s.heads; + var seed: u64 = 0x72333030; + const q = try c.fill(&seed, rows_n * H * mla.qd, a); + defer a.free(q); + c.roundSlice(q); + const rope_in = try c.fill(&seed, rows_n * mla.rope_dim, a); + defer a.free(rope_in); + c.roundSlice(rope_in); + + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var gpu = try c.Gpu.init(); + defer gpu.deinit(); + const shared = mtl.ResourceOptions.shared; + const b_q = try gpu.device.buffer(q.len * 2, shared); + defer b_q.deinit(); + c.putBf16(b_q, q); + const b_rows = try gpu.device.buffer(rows_n * @sizeOf(c.MlaRow), shared); + defer b_rows.deinit(); + const rows = b_rows.slice(c.MlaRow, rows_n); + for (rows, 0..) |*r, i| r.* = .{ .slot = 0, .pos = first_pos + @as(u32, @intCast(i)) }; + const b_cs = try gpu.device.buffer(rows_n * mla.nfreq * 2 * 4, shared); + defer b_cs.deinit(); + c.writeCs(b_cs.slice(f32, rows_n * mla.nfreq * 2), rows, s.theta); + const b_cache = try gpu.device.buffer(@as(usize, slot_keys) * mla.key * 2, shared); + defer b_cache.deinit(); + const cache = b_cache.slice(u16, slot_keys * mla.key); + for (0..rows_n) |t| { + const base = (first_pos + t) * mla.key + mla.lat; + for (0..mla.rope_dim) |i| cache[base + i] = c.toBf16(rope_in[t * mla.rope_dim + i]); + } + const aa = c.MlaArgs{ + .cache = b_cache.gpuAddress(), + .slot_keys = slot_keys, + .heads = H, + .head0 = 0, + .rows = rows_n, + .q_stride = H * mla.qd, + .kv_stride = mla.key, + .gate_stride = H * mla.vd, + .out_stride = H * mla.vd, + .eps = s.eps, + .scale = @floatCast(s.scale()), + }; + + { + const cb = gpu.queue.commandBuffer(); + const e = cb.compute(.serial); + e.setPipeline(gpu.rope_q); + e.setBuffer(b_q, 0, 0); + e.setValue(aa, 1); + e.setBuffer(b_cs, 0, 2); + e.dispatchGroups(mtl.Size.of(H, rows_n, 1), mtl.Size.of(32, 1, 1)); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |why| { + std.debug.print("rope_q large pos failed: {s}\n", .{why}); + return error.GpuFailed; + } + } + const got_q = b_q.slice(u16, q.len); + const nq = rows_n * H * mla.rope_dim; + const metal_q = try a.alloc(f64, nq); + defer a.free(metal_q); + const f64_q = try a.alloc(f64, nq); + defer a.free(f64_q); + const bf_q = try a.alloc(f64, nq); + defer a.free(bf_q); + var k: usize = 0; + for (0..rows_n) |t| { + for (0..H) |h| { + var z64: [mla.rope_dim]f64 = undefined; + var out: [mla.rope_dim]f64 = undefined; + const base = (t * H + h) * mla.qd + mla.nope; + for (0..mla.rope_dim) |i| z64[i] = q[base + i]; + mla.rotate(&out, &z64, first_pos + @as(u32, @intCast(t)), s.theta); + for (0..mla.rope_dim) |i| { + f64_q[k] = out[i]; + bf_q[k] = c.fromBf16(c.toBf16(@floatCast(out[i]))); + metal_q[k] = c.fromBf16(got_q[base + i]); + k += 1; + } + } + } + const q_gate = c.gateNamedF64("rope_q pos 29998-29999", metal_q, f64_q, bf_q); + + { + const cb = gpu.queue.commandBuffer(); + const e = cb.compute(.serial); + e.setPipeline(gpu.rope_cache); + e.setBuffer(b_rows, 0, 0); + e.setValue(aa, 1); + e.setBuffer(b_cs, 0, 2); + e.useResource(b_cache, mtl.ResourceUsage.read | mtl.ResourceUsage.write); + e.dispatchGroups(mtl.Size.of(rows_n, 1, 1), mtl.Size.of(32, 1, 1)); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |why| { + std.debug.print("rope_cache large pos failed: {s}\n", .{why}); + return error.GpuFailed; + } + } + const nc = rows_n * mla.rope_dim; + const metal_c = try a.alloc(f64, nc); + defer a.free(metal_c); + const f64_c = try a.alloc(f64, nc); + defer a.free(f64_c); + const bf_c = try a.alloc(f64, nc); + defer a.free(bf_c); + k = 0; + for (0..rows_n) |t| { + var z64: [mla.rope_dim]f64 = undefined; + var out: [mla.rope_dim]f64 = undefined; + for (0..mla.rope_dim) |i| z64[i] = rope_in[t * mla.rope_dim + i]; + mla.rotate(&out, &z64, first_pos + @as(u32, @intCast(t)), s.theta); + const base = (first_pos + t) * mla.key + mla.lat; + for (0..mla.rope_dim) |i| { + f64_c[k] = out[i]; + bf_c[k] = c.fromBf16(c.toBf16(@floatCast(out[i]))); + metal_c[k] = c.fromBf16(cache[base + i]); + k += 1; + } + } + const cache_gate = c.gateNamedF64("rope_cache pos 29998-29999", metal_c, f64_c, bf_c); + q_gate catch |e| return e; + cache_gate catch |e| return e; +} + +fn checkLarge(rows: u32, left: u32, seed: u64, tag: []const u8) !void { + const a = std.testing.allocator; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const in = try c.Inputs.make(a, s, rows, seed); + defer in.free(a); + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var g = try c.Gpu.init(); + defer g.deinit(); + var whole = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer whole.deinit(); + try whole.dispatchMixer(g, 0, rows); + var parts = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer parts.deinit(); + try parts.dispatchMixer(g, 0, left); + try parts.dispatchMixer(g, left, rows - left); + var buf: [96]u8 = undefined; + const t1 = try std.fmt.bufPrint(&buf, "{s} whole vs chunks", .{tag}); + try c.expectBitsEqual(t1, whole.y(), parts.y()); + var buf2: [96]u8 = undefined; + const t2 = try std.fmt.bufPrint(&buf2, "{s} resume vs fresh", .{tag}); + try c.expectBitsEqual(t2, whole.y(), parts.y()); +} + +test "MLA mixer 4 rows equals 2+2 bits-equal" { + try checkChunks(); +} + +test "MLA mixer resume vs fresh bits-equal" { + try checkResume(); +} + +test "TFLINGA1 tiny layer 3 T=4 pos0=0 Metal and mixF64 vs python f64" { + try dump.checkDumpFile(dump.dump_a1_t4_path, 0, "dump T=4 pos0=0", true); +} + +test "TFLINGA1 tiny layer 3 T=2 pos0=30000 mixF64 vs python host-only" { + try dump.checkDumpFile(dump.dump_a1_t2_path, 1, "dump T=2 pos0=30000", false); +} + +test "Ling rope_q and rope_cache at pos 29998-29999 vs f64" { + try checkRopeLargePos(); +} + +test "MLA mixer T=100 as 37+63 bits-equal" { + try checkLarge(100, 37, 0x74313030, "T=100"); +} + +test "MLA mixer T=257 as 256+1 bits-equal (k3 gpu_rows)" { + try checkLarge(257, k3_gpu_rows, 0x74323537, "T=257"); +} diff --git a/zig/tests/ling_mla_gpu_common.zig b/zig/tests/ling_mla_gpu_common.zig new file mode 100644 index 00000000000..39b8b2316f0 --- /dev/null +++ b/zig/tests/ling_mla_gpu_common.zig @@ -0,0 +1,427 @@ +//! Shared Gpu/Launch/helpers for Ling MLA GPU tests around k3_mla. +const std = @import("std"); +const mtl = @import("metal"); +const mla = @import("mla"); +const metallib = @import("kimi_metallib"); + +const source = @import("ling_metal").mla; +const mla_splits: u32 = 16; + +pub const MlaRow = extern struct { slot: u32, pos: u32 }; +pub const MlaArgs = extern struct { + cache: u64, + slot_keys: u32, + heads: u32, + head0: u32, + rows: u32, + q_stride: u32, + kv_stride: u32, + gate_stride: u32, + out_stride: u32, + eps: f32, + scale: f32, +}; + +comptime { + if (@sizeOf(MlaArgs) != 48) @compileError("MlaArgs must stay 48 bytes, matching k3"); +} + +pub fn toBf16(v: f32) u16 { + const bits: u32 = @bitCast(v); + if (std.math.isNan(v)) return @truncate((bits >> 16) | 0x40); + return @truncate((bits +% 0x7fff +% ((bits >> 16) & 1)) >> 16); +} +pub fn fromBf16(h: u16) f32 { + return @bitCast(@as(u32, h) << 16); +} + +pub fn fill(seed: *u64, n: usize, a: std.mem.Allocator) ![]f32 { + const x = try a.alloc(f32, n); + for (x) |*v| { + seed.* = seed.* *% 1103515245 +% 12345; + v.* = @as(f32, @floatFromInt((seed.* >> 16) & 0x7fff)) / 16384.0 - 1.0; + } + return x; +} + +pub fn putBf16(buf: mtl.Buffer, x: []const f32) void { + const d = buf.slice(u16, x.len); + for (x, d) |v, *o| o.* = toBf16(v); +} + +pub fn roundSlice(x: []f32) void { + for (x) |*v| v.* = fromBf16(toBf16(v.*)); +} + +/// Host f64 cos/sin of each row's pos, rounded to f32. Layout [t][i][comp] = t*64 + i*2 + comp. +pub fn writeCs(cs: []f32, rows: []const MlaRow, theta: f64) void { + std.debug.assert(cs.len >= rows.len * mla.nfreq * 2); + for (rows, 0..) |r, t| { + for (0..mla.nfreq) |i| { + const ang = @as(f64, @floatFromInt(r.pos)) * mla.invFreq(theta, i); + const at = (t * mla.nfreq + i) * 2; + cs[at] = @floatCast(@cos(ang)); + cs[at + 1] = @floatCast(@sin(ang)); + } + } +} + +pub const Gpu = struct { + device: mtl.Device, + queue: mtl.Queue, + kimi: mtl.Library, + ling: mtl.Library, + cache: mtl.Pipeline, + qlat: mtl.Pipeline, + attend: mtl.Pipeline, + merge: mtl.Pipeline, + uv: mtl.Pipeline, + rope_cache: mtl.Pipeline, + rope_q: mtl.Pipeline, + gate_expand: mtl.Pipeline, + + pub fn init() !Gpu { + const device = try mtl.Device.init(); + errdefer device.deinit(); + const kimi = try mtl.Library.fromBytes(device, metallib.bytes); + errdefer kimi.deinit(); + const ling = try mtl.Library.fromSource(device, source, mtl.CompileOptions.mlx()); + errdefer ling.deinit(); + const cache = try mtl.Pipeline.init(device, kimi, "k3_mla_cache", false); + errdefer cache.deinit(); + const qlat = try mtl.Pipeline.init(device, kimi, "k3_mla_qlat", false); + errdefer qlat.deinit(); + const attend = try mtl.Pipeline.init(device, kimi, "k3_mla_attend", false); + errdefer attend.deinit(); + const merge = try mtl.Pipeline.init(device, kimi, "k3_mla_merge", false); + errdefer merge.deinit(); + const uv = try mtl.Pipeline.init(device, kimi, "k3_mla_uv", false); + errdefer uv.deinit(); + const rope_cache = try mtl.Pipeline.init(device, ling, "tf_ling_mla_rope_cache", false); + errdefer rope_cache.deinit(); + const rope_q = try mtl.Pipeline.init(device, ling, "tf_ling_mla_rope_q", false); + errdefer rope_q.deinit(); + const gate_expand = try mtl.Pipeline.init(device, ling, "tf_ling_mla_gate_expand", false); + errdefer gate_expand.deinit(); + const queue = try device.queue(); + return .{ + .device = device, + .queue = queue, + .kimi = kimi, + .ling = ling, + .cache = cache, + .qlat = qlat, + .attend = attend, + .merge = merge, + .uv = uv, + .rope_cache = rope_cache, + .rope_q = rope_q, + .gate_expand = gate_expand, + }; + } + + pub fn deinit(g: *Gpu) void { + g.gate_expand.deinit(); + g.rope_q.deinit(); + g.rope_cache.deinit(); + g.uv.deinit(); + g.merge.deinit(); + g.attend.deinit(); + g.qlat.deinit(); + g.cache.deinit(); + g.ling.deinit(); + g.kimi.deinit(); + g.queue.deinit(); + g.device.deinit(); + } +}; + +pub const Launch = struct { + s: mla.Shape, + cap: u32, + b_q: mtl.Buffer, + b_kv: mtl.Buffer, + b_w: mtl.Buffer, + b_kvb: mtl.Buffer, + b_g: mtl.Buffer, + b_g2: mtl.Buffer, + b_y: mtl.Buffer, + b_rows: mtl.Buffer, + b_cache: mtl.Buffer, + b_qlat: mtl.Buffer, + b_partial: mtl.Buffer, + b_olat: mtl.Buffer, + b_cs: mtl.Buffer, + + pub fn open(g: Gpu, s: mla.Shape, cap: u32, q: []const f32, kv: []const f32, w_rms: []const f32, kvb: []const f32, gate: []const f32) !Launch { + const H = s.heads; + const shared = mtl.ResourceOptions.shared; + const b_q = try g.device.buffer(q.len * 2, shared); + const b_kv = try g.device.buffer(kv.len * 2, shared); + const b_w = try g.device.buffer(w_rms.len * 2, shared); + const b_kvb = try g.device.buffer(kvb.len * 2, shared); + const b_g = try g.device.buffer(gate.len * 2, shared); + const b_g2 = try g.device.buffer(cap * H * mla.vd * 2, shared); + const b_y = try g.device.buffer(cap * H * mla.vd * 2, shared); + const b_rows = try g.device.buffer(cap * @sizeOf(MlaRow), shared); + const b_cache = try g.device.buffer(cap * mla.key * 2, shared); + const b_qlat = try g.device.buffer(cap * H * mla.lat * 4, shared); + const b_partial = try g.device.buffer(cap * H * mla_splits * (mla.lat + 2) * 4, shared); + const b_olat = try g.device.buffer(cap * H * mla.lat * 4, shared); + const b_cs = try g.device.buffer(cap * mla.nfreq * 2 * 4, shared); + putBf16(b_q, q); + putBf16(b_kv, kv); + putBf16(b_w, w_rms); + putBf16(b_kvb, kvb); + putBf16(b_g, gate); + @memset(b_g2.slice(u16, cap * H * mla.vd), 0); + @memset(b_y.slice(u16, cap * H * mla.vd), 0); + @memset(b_cache.slice(u16, cap * mla.key), 0); + return .{ + .s = s, + .cap = cap, + .b_q = b_q, + .b_kv = b_kv, + .b_w = b_w, + .b_kvb = b_kvb, + .b_g = b_g, + .b_g2 = b_g2, + .b_y = b_y, + .b_rows = b_rows, + .b_cache = b_cache, + .b_qlat = b_qlat, + .b_partial = b_partial, + .b_olat = b_olat, + .b_cs = b_cs, + }; + } + + pub fn deinit(l: *Launch) void { + l.b_q.deinit(); + l.b_kv.deinit(); + l.b_w.deinit(); + l.b_kvb.deinit(); + l.b_g.deinit(); + l.b_g2.deinit(); + l.b_y.deinit(); + l.b_rows.deinit(); + l.b_cache.deinit(); + l.b_qlat.deinit(); + l.b_partial.deinit(); + l.b_olat.deinit(); + l.b_cs.deinit(); + } + + pub fn args(l: *Launch, n: u32) MlaArgs { + const H = l.s.heads; + const ow = H * mla.vd; + return .{ + .cache = l.b_cache.gpuAddress(), + .slot_keys = l.cap, + .heads = H, + .head0 = 0, + .rows = n, + .q_stride = H * mla.qd, + .kv_stride = mla.key, + .gate_stride = ow, + .out_stride = ow, + .eps = l.s.eps, + .scale = @floatCast(l.s.scale()), + }; + } + + pub fn fillRows(l: *Launch, first: u32, n: u32) void { + const rows = l.b_rows.slice(MlaRow, n); + for (rows, 0..) |*r, i| r.* = .{ .slot = 0, .pos = first + @as(u32, @intCast(i)) }; + } + + pub fn fillCs(l: *Launch, n: u32) void { + writeCs(l.b_cs.slice(f32, n * mla.nfreq * 2), l.b_rows.slice(MlaRow, n), l.s.theta); + } + + pub fn dispatchMixer(l: *Launch, g: Gpu, first: u32, n: u32) !void { + const H = l.s.heads; + const a = l.args(n); + l.fillRows(first, n); + l.fillCs(n); + const q_off = first * a.q_stride * 2; + const kv_off = first * a.kv_stride * 2; + const g_off = first * H * 2; + const y_off = first * a.out_stride * 2; + const g2_off = first * a.gate_stride * 2; + const rw = mtl.ResourceUsage.read | mtl.ResourceUsage.write; + const cb = g.queue.commandBuffer(); + const e = cb.compute(.serial); + + e.setPipeline(g.cache); + e.setBuffer(l.b_kv, kv_off, 0); + e.setBuffer(l.b_w, 0, 1); + e.setBuffer(l.b_rows, 0, 2); + e.setValue(a, 3); + e.useResource(l.b_cache, rw); + e.dispatchGroups(mtl.Size.of(n, 1, 1), mtl.Size.of(256, 1, 1)); + + e.setPipeline(g.rope_cache); + e.setBuffer(l.b_rows, 0, 0); + e.setValue(a, 1); + e.setBuffer(l.b_cs, 0, 2); + e.useResource(l.b_cache, rw); + e.dispatchGroups(mtl.Size.of(n, 1, 1), mtl.Size.of(32, 1, 1)); + + e.setPipeline(g.qlat); + e.setBuffer(l.b_q, q_off, 0); + e.setBuffer(l.b_kvb, 0, 1); + e.setBuffer(l.b_qlat, 0, 2); + e.setValue(a, 3); + e.dispatchGroups(mtl.Size.of(2, H, 1), mtl.Size.of(256, 1, 1)); + + e.setPipeline(g.rope_q); + e.setBuffer(l.b_q, q_off, 0); + e.setValue(a, 1); + e.setBuffer(l.b_cs, 0, 2); + e.dispatchGroups(mtl.Size.of(H, n, 1), mtl.Size.of(32, 1, 1)); + + e.setPipeline(g.attend); + e.setBuffer(l.b_q, q_off, 0); + e.setBuffer(l.b_qlat, 0, 1); + e.setBuffer(l.b_rows, 0, 2); + e.setBuffer(l.b_partial, 0, 3); + e.setValue(a, 4); + e.useResource(l.b_cache, mtl.ResourceUsage.read); + const fit: u32 = @intCast(@min(32, g.attend.maxThreads() / 32)); + const groups = (H + fit - 1) / fit; + const per = (H + groups - 1) / groups; + e.dispatchGroups(mtl.Size.of(groups, mla_splits, n), mtl.Size.of(32 * per, 1, 1)); + + e.setPipeline(g.merge); + e.setBuffer(l.b_partial, 0, 0); + e.setBuffer(l.b_rows, 0, 1); + e.setBuffer(l.b_olat, 0, 2); + e.setValue(a, 3); + e.dispatchGroups(mtl.Size.of(H, n, 1), mtl.Size.of(256, 1, 1)); + + e.setPipeline(g.gate_expand); + e.setBuffer(l.b_g, g_off, 0); + e.setBuffer(l.b_g2, g2_off, 1); + e.setValue(a, 2); + e.dispatchThreads(mtl.Size.of(H * mla.vd, n, 1), mtl.Size.of(128, 1, 1)); + + e.setPipeline(g.uv); + e.setBuffer(l.b_olat, 0, 0); + e.setBuffer(l.b_kvb, 0, 1); + e.setBuffer(l.b_g2, g2_off, 2); + e.setBuffer(l.b_y, y_off, 3); + e.setValue(a, 4); + e.dispatchGroups(mtl.Size.of(mla.vd / 4, H, 1), mtl.Size.of(128, 1, 1)); + + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |why| { + std.debug.print("GPU mixer failed: {s}\n", .{why}); + return error.GpuFailed; + } + } + + pub fn y(l: *Launch) []u16 { + return l.b_y.slice(u16, l.cap * l.s.outWidth()); + } +}; + +pub const Dist = struct { rel_l2: f64, max_abs: f64 }; + +pub fn dist(got: []const f64, ref: []const f64) Dist { + var num: f64 = 0; + var den: f64 = 0; + var max_abs: f64 = 0; + for (got, ref) |a, b| { + const d = a - b; + num += d * d; + den += b * b; + max_abs = @max(max_abs, @abs(d)); + } + const rel = if (den == 0) @sqrt(num) else @sqrt(num) / @sqrt(den); + return .{ .rel_l2 = rel, .max_abs = max_abs }; +} + +pub fn bitsToF64(bits: []const u16, out: []f64) void { + for (bits, out) |h, *o| o.* = fromBf16(h); +} + +pub fn gateNamed(tag: []const u8, metal: []const u16, f64_y: []const f64, bf16_y: []const f64) !void { + const a = std.testing.allocator; + const metal_f = try a.alloc(f64, metal.len); + defer a.free(metal_f); + bitsToF64(metal, metal_f); + try gateNamedF64(tag, metal_f, f64_y, bf16_y); +} + +pub fn gateNamedF64(tag: []const u8, metal: []const f64, f64_y: []const f64, bf16_y: []const f64) !void { + const m = dist(metal, f64_y); + const b = dist(bf16_y, f64_y); + std.debug.print("{s} Metal-to-f64 rel L2 {e} max abs {e}; bf16-ref-to-f64 rel L2 {e} max abs {e}\n", .{ tag, m.rel_l2, m.max_abs, b.rel_l2, b.max_abs }); + if (m.rel_l2 > b.rel_l2 or m.max_abs > b.max_abs) { + std.debug.print("{s} gate miss: Metal further from f64 than bf16-ref\n", .{tag}); + return error.Gate; + } +} + +pub fn oProj(out: []f64, y: []const f64, wo: []const f32, rows: u32, hidden: u32, width: u32) void { + std.debug.assert(out.len == rows * hidden and y.len == rows * width and wo.len == hidden * width); + for (0..rows) |t| { + for (0..hidden) |j| { + var acc: f64 = 0; + const wr = j * width; + const yr = t * width; + for (0..width) |i| acc += y[yr + i] * @as(f64, wo[wr + i]); + out[t * hidden + j] = acc; + } + } +} + +pub fn expectBitsEqual(tag: []const u8, a: []const u16, b: []const u16) !void { + if (std.mem.eql(u16, a, b)) return; + var n: usize = 0; + var first: usize = 0; + for (a, b, 0..) |x, yv, i| { + if (x != yv) { + if (n == 0) first = i; + n += 1; + } + } + std.debug.print("{s} bits-equal miss: {d} of {d} first i={d} a={x} b={x}\n", .{ tag, n, a.len, first, a[first], b[first] }); + return error.BitsEqual; +} + +pub const Inputs = struct { + q: []f32, + kv: []f32, + w: []f32, + kvb: []f32, + g: []f32, + + pub fn make(alloc: std.mem.Allocator, s: mla.Shape, rows: u32, seed0: u64) !Inputs { + var seed = seed0; + const H = s.heads; + const q = try fill(&seed, rows * H * mla.qd, alloc); + const kv = try fill(&seed, rows * mla.key, alloc); + const w = try fill(&seed, mla.lat, alloc); + const kvb = try fill(&seed, H * (mla.nope + mla.vd) * mla.lat, alloc); + const g = try fill(&seed, rows * H, alloc); + for (w) |*v| v.* = 0.5 + 0.5 * v.*; + roundSlice(q); + roundSlice(kv); + roundSlice(w); + roundSlice(kvb); + roundSlice(g); + return .{ .q = q, .kv = kv, .w = w, .kvb = kvb, .g = g }; + } + + pub fn free(in: Inputs, alloc: std.mem.Allocator) void { + alloc.free(in.q); + alloc.free(in.kv); + alloc.free(in.w); + alloc.free(in.kvb); + alloc.free(in.g); + } +}; diff --git a/zig/tests/ling_mla_gpu_dump.zig b/zig/tests/ling_mla_gpu_dump.zig new file mode 100644 index 00000000000..9a94d0efd6f --- /dev/null +++ b/zig/tests/ling_mla_gpu_dump.zig @@ -0,0 +1,251 @@ +//! TFLINGM1/TFLINGA1 dump parsing and Metal-vs-python mixer check. +const std = @import("std"); +const mtl = @import("metal"); +const mla = @import("mla"); +const c = @import("ling_mla_gpu_common.zig"); + +const dump_dir = "/tmp/ling-mla-dumps"; +pub const dump_mixer_path = dump_dir ++ "/mla_tiny_mixer.bin"; +pub const dump_a1_t4_path = dump_dir ++ "/mla_tiny_t4_pos0.bin"; +pub const dump_a1_t2_path = dump_dir ++ "/mla_tiny_t2_pos30000.bin"; +const dump_py = "zig/src/families/ling/oracle/mla_dump.py"; + +fn takeU32(b: []const u8, off: *usize) u32 { + const v = std.mem.readInt(u32, b[off.*..][0..4], .little); + off.* += 4; + return v; +} + +fn takeF32s(alloc: std.mem.Allocator, b: []const u8, off: *usize, n: usize) ![]f32 { + const x = try alloc.alloc(f32, n); + @memcpy(std.mem.sliceAsBytes(x), b[off.* .. off.* + n * 4]); + off.* += n * 4; + return x; +} + +fn takeF64s(alloc: std.mem.Allocator, b: []const u8, off: *usize, n: usize) ![]f64 { + const x = try alloc.alloc(f64, n); + @memcpy(std.mem.sliceAsBytes(x), b[off.* .. off.* + n * 8]); + off.* += n * 8; + return x; +} + +const DumpCase = struct { + T: u32, + pos0: u32, + q: []f32, + kv: []f32, + g: []f32, + y_pre: []f64, + y64: []f64, + ybf: []f64, +}; + +const Dump = struct { + hidden: u32, + layer: u32, + heads: u32, + w: []f32, + kvb: []f32, + Wo: []f32, + cases: []DumpCase, + + fn load(alloc: std.mem.Allocator, bytes: []const u8) !Dump { + try std.testing.expect(std.mem.eql(u8, bytes[0..8], "TFLINGM1")); + var off: usize = 8; + const hidden = takeU32(bytes, &off); + const layer = takeU32(bytes, &off); + const heads = takeU32(bytes, &off); + const n_cases = takeU32(bytes, &off); + const w = try takeF32s(alloc, bytes, &off, mla.lat); + errdefer alloc.free(w); + const kvb = try takeF32s(alloc, bytes, &off, heads * (mla.nope + mla.vd) * mla.lat); + errdefer alloc.free(kvb); + const Wo = try takeF32s(alloc, bytes, &off, hidden * heads * mla.vd); + errdefer alloc.free(Wo); + const cases = try alloc.alloc(DumpCase, n_cases); + errdefer alloc.free(cases); + for (cases) |*case| { + const T = takeU32(bytes, &off); + const pos0 = takeU32(bytes, &off); + const q = try takeF32s(alloc, bytes, &off, T * heads * mla.qd); + const kv = try takeF32s(alloc, bytes, &off, T * mla.key); + const g = try takeF32s(alloc, bytes, &off, T * heads); + const y_pre = try takeF64s(alloc, bytes, &off, T * heads * mla.vd); + const y64 = try takeF64s(alloc, bytes, &off, T * hidden); + const ybf = try takeF64s(alloc, bytes, &off, T * hidden); + case.* = .{ .T = T, .pos0 = pos0, .q = q, .kv = kv, .g = g, .y_pre = y_pre, .y64 = y64, .ybf = ybf }; + } + try std.testing.expectEqual(bytes.len, off); + return .{ .hidden = hidden, .layer = layer, .heads = heads, .w = w, .kvb = kvb, .Wo = Wo, .cases = cases }; + } + + fn deinit(d: Dump, alloc: std.mem.Allocator) void { + for (d.cases) |case| { + alloc.free(case.q); + alloc.free(case.kv); + alloc.free(case.g); + alloc.free(case.y_pre); + alloc.free(case.y64); + alloc.free(case.ybf); + } + alloc.free(d.cases); + alloc.free(d.w); + alloc.free(d.kvb); + alloc.free(d.Wo); + } +}; + +fn parseA1(alloc: std.mem.Allocator, bytes: []const u8) !struct { T: u32, hidden: u32, layer: u32, pos0: u32, y64: []f64, ybf: []f64 } { + try std.testing.expect(std.mem.eql(u8, bytes[0..8], "TFLINGA1")); + var off: usize = 8; + const T = takeU32(bytes, &off); + const hidden = takeU32(bytes, &off); + const layer = takeU32(bytes, &off); + const pos0 = takeU32(bytes, &off); + const n = T * hidden; + const y64 = try takeF64s(alloc, bytes, &off, n); + errdefer alloc.free(y64); + const ybf = try takeF64s(alloc, bytes, &off, n); + errdefer alloc.free(ybf); + try std.testing.expectEqual(bytes.len, off); + return .{ .T = T, .hidden = hidden, .layer = layer, .pos0 = pos0, .y64 = y64, .ybf = ybf }; +} + +fn dupeRound(alloc: std.mem.Allocator, src: []const f32) ![]f32 { + const d = try alloc.dupe(f32, src); + c.roundSlice(d); + return d; +} + +fn fileOk(path: []const u8) bool { + std.Io.Dir.cwd().access(std.testing.io, path, .{}) catch return false; + return true; +} + +fn hasTorch(py: []const u8) bool { + const a = std.testing.allocator; + const r = std.process.run(a, std.testing.io, .{ + .argv = &.{ py, "-c", "import torch" }, + .stdout_limit = .limited(256), + .stderr_limit = .limited(4096), + }) catch return false; + defer a.free(r.stdout); + defer a.free(r.stderr); + return r.term.success(); +} + +fn findPython() ?[]const u8 { + if (std.c.getenv("TF_LING_PYTHON")) |p| { + const s = std.mem.span(p); + if (hasTorch(s)) return s; + } + if (hasTorch("python3")) return "python3"; + return null; +} + +fn ensureDumps() !void { + if (fileOk(dump_mixer_path) and fileOk(dump_a1_t4_path) and fileOk(dump_a1_t2_path)) return; + if (!fileOk(dump_py)) { + std.debug.print("skip: {s} not in cwd; TFLINGA1 dumps need ling_forward.py at test time\n", .{dump_py}); + return error.SkipZigTest; + } + const py = findPython() orelse { + std.debug.print("skip: no torch (set TF_LING_PYTHON or python3 on PATH); TFLINGA1 dumps come from ling_forward.py at test time\n", .{}); + return error.SkipZigTest; + }; + const a = std.testing.allocator; + const r = try std.process.run(a, std.testing.io, .{ + .argv = &.{ py, dump_py, dump_dir }, + .stdout_limit = .limited(4096), + .stderr_limit = .limited(65536), + }); + defer a.free(r.stdout); + defer a.free(r.stderr); + if (!r.term.success()) { + std.debug.print("mla_dump.py failed: {s}{s}\n", .{ r.stdout, r.stderr }); + return error.DumpGen; + } + if (!fileOk(dump_mixer_path) or !fileOk(dump_a1_t4_path) or !fileOk(dump_a1_t2_path)) return error.DumpGen; +} + +fn readDump(path: []const u8) ![]u8 { + return std.Io.Dir.cwd().readFileAlloc(std.testing.io, path, std.testing.allocator, .limited(32 << 20)); +} + +pub fn checkDumpFile(a1_path: []const u8, case_i: usize, tag: []const u8, gpu: bool) !void { + try ensureDumps(); + const a = std.testing.allocator; + const mixer_bytes = try readDump(dump_mixer_path); + defer a.free(mixer_bytes); + const a1_bytes = try readDump(a1_path); + defer a.free(a1_bytes); + try checkDump(mixer_bytes, a1_bytes, case_i, tag, gpu); +} + +fn checkDump(mixer_bytes: []const u8, a1_bytes: []const u8, case_i: usize, tag: []const u8, gpu: bool) !void { + const a = std.testing.allocator; + const dump = try Dump.load(a, mixer_bytes); + defer dump.deinit(a); + const a1 = try parseA1(a, a1_bytes); + defer a.free(a1.y64); + defer a.free(a1.ybf); + const case = dump.cases[case_i]; + try std.testing.expectEqual(a1.T, case.T); + try std.testing.expectEqual(a1.hidden, dump.hidden); + try std.testing.expectEqual(a1.layer, dump.layer); + try std.testing.expectEqual(a1.pos0, case.pos0); + try std.testing.expect(std.mem.eql(f64, a1.y64, case.y64)); + + const s = mla.Shape{ .heads = dump.heads, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const width = s.outWidth(); + const n_mix = case.T * width; + const mix64 = try a.alloc(f64, n_mix); + defer a.free(mix64); + try mla.mixF64(a, mix64, case.q, case.kv, dump.w, dump.kvb, case.g, s, case.T, case.pos0); + const d_pre = c.dist(mix64, case.y_pre); + std.debug.print("{s} mixF64-to-python mixer rel L2 {e} max abs {e}\n", .{ tag, d_pre.rel_l2, d_pre.max_abs }); + const layer_mix = try a.alloc(f64, case.T * dump.hidden); + defer a.free(layer_mix); + c.oProj(layer_mix, mix64, dump.Wo, case.T, dump.hidden, width); + const d_layer = c.dist(layer_mix, a1.y64); + std.debug.print("{s} mixF64+o_proj-to-TFLINGA1 rel L2 {e} max abs {e}\n", .{ tag, d_layer.rel_l2, d_layer.max_abs }); + if (!gpu) return; + + const mix_bf = try a.alloc(f64, n_mix); + defer a.free(mix_bf); + const q_m = try dupeRound(a, case.q); + defer a.free(q_m); + const kv_m = try dupeRound(a, case.kv); + defer a.free(kv_m); + const w_m = try dupeRound(a, dump.w); + defer a.free(w_m); + const kvb_m = try dupeRound(a, dump.kvb); + defer a.free(kvb_m); + const g_m = try dupeRound(a, case.g); + defer a.free(g_m); + try mla.mixBf16(a, mix_bf, q_m, kv_m, w_m, kvb_m, g_m, s, case.T, case.pos0); + + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var gpu_dev = try c.Gpu.init(); + defer gpu_dev.deinit(); + var l = try c.Launch.open(gpu_dev, s, case.T, q_m, kv_m, w_m, kvb_m, g_m); + defer l.deinit(); + try l.dispatchMixer(gpu_dev, 0, case.T); + const metal_mix = try a.alloc(f64, n_mix); + defer a.free(metal_mix); + c.bitsToF64(l.y(), metal_mix); + const d_metal_pre = c.dist(metal_mix, case.y_pre); + std.debug.print("{s} Metal-to-python mixer rel L2 {e} max abs {e}\n", .{ tag, d_metal_pre.rel_l2, d_metal_pre.max_abs }); + + const layer_bf = try a.alloc(f64, case.T * dump.hidden); + defer a.free(layer_bf); + const layer_metal = try a.alloc(f64, case.T * dump.hidden); + defer a.free(layer_metal); + c.oProj(layer_bf, mix_bf, dump.Wo, case.T, dump.hidden, width); + c.oProj(layer_metal, metal_mix, dump.Wo, case.T, dump.hidden, width); + var tbuf: [96]u8 = undefined; + const layer_tag = try std.fmt.bufPrint(&tbuf, "{s} TFLINGA1", .{tag}); + try c.gateNamedF64(layer_tag, layer_metal, a1.y64, layer_bf); +} diff --git a/zig/tests/ling_mla_gpu_kernels.zig b/zig/tests/ling_mla_gpu_kernels.zig new file mode 100644 index 00000000000..c5be824d160 --- /dev/null +++ b/zig/tests/ling_mla_gpu_kernels.zig @@ -0,0 +1,200 @@ +//! Ling MLA kernels-alone: rope_q, rope_cache, gate_expand vs host. +const std = @import("std"); +const mtl = @import("metal"); +const mla = @import("mla"); +const c = @import("ling_mla_gpu_common.zig"); + +fn checkRopeQ() !void { + const a = std.testing.allocator; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const rows: u32 = 4; + const H = s.heads; + var seed: u64 = 0x7271; + const q = try c.fill(&seed, rows * H * mla.qd, a); + defer a.free(q); + c.roundSlice(q); + const kv = try a.alloc(f32, rows * mla.key); + defer a.free(kv); + @memset(kv, 0); + const w_rms: [mla.lat]f32 = @splat(1); + const kvb_w = try a.alloc(f32, H * (mla.nope + mla.vd) * mla.lat); + defer a.free(kvb_w); + @memset(kvb_w, 0); + const g = try a.alloc(f32, rows * H); + defer a.free(g); + @memset(g, 0); + + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var gpu = try c.Gpu.init(); + defer gpu.deinit(); + var l = try c.Launch.open(gpu, s, rows, q, kv, &w_rms, kvb_w, g); + defer l.deinit(); + l.fillRows(0, rows); + l.fillCs(rows); + const aa = l.args(rows); + const cb = gpu.queue.commandBuffer(); + const e = cb.compute(.serial); + e.setPipeline(gpu.rope_q); + e.setBuffer(l.b_q, 0, 0); + e.setValue(aa, 1); + e.setBuffer(l.b_cs, 0, 2); + e.dispatchGroups(mtl.Size.of(H, rows, 1), mtl.Size.of(32, 1, 1)); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |why| { + std.debug.print("rope_q failed: {s}\n", .{why}); + return error.GpuFailed; + } + const got = l.b_q.slice(u16, q.len); + var worst: f32 = 0; + var bits_miss: usize = 0; + for (0..rows) |t| { + for (0..H) |h| { + var z64: [mla.rope_dim]f64 = undefined; + var out: [mla.rope_dim]f64 = undefined; + const base = (t * H + h) * mla.qd + mla.nope; + for (0..mla.rope_dim) |i| z64[i] = q[base + i]; + mla.rotate(&out, &z64, @intCast(t), s.theta); + for (0..mla.rope_dim) |i| { + const want = c.toBf16(@floatCast(out[i])); + const gbits = got[base + i]; + if (want != gbits) bits_miss += 1; + worst = @max(worst, @abs(c.fromBf16(want) - c.fromBf16(gbits))); + } + } + } + std.debug.print("rope_q vs host rotate: bits miss {d} worst abs {e}\n", .{ bits_miss, worst }); + if (worst > 2e-3) return error.RopeQ; +} + +fn checkRopeCache() !void { + const a = std.testing.allocator; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const rows: u32 = 4; + var seed: u64 = 0x7263; + const rope_in = try c.fill(&seed, rows * mla.rope_dim, a); + defer a.free(rope_in); + c.roundSlice(rope_in); + const H = s.heads; + const q = try a.alloc(f32, rows * H * mla.qd); + defer a.free(q); + @memset(q, 0); + const kv = try a.alloc(f32, rows * mla.key); + defer a.free(kv); + @memset(kv, 0); + const w_rms: [mla.lat]f32 = @splat(1); + const kvb_w = try a.alloc(f32, H * (mla.nope + mla.vd) * mla.lat); + defer a.free(kvb_w); + @memset(kvb_w, 0); + const g = try a.alloc(f32, rows * H); + defer a.free(g); + @memset(g, 0); + + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var gpu = try c.Gpu.init(); + defer gpu.deinit(); + var l = try c.Launch.open(gpu, s, rows, q, kv, &w_rms, kvb_w, g); + defer l.deinit(); + const cache = l.b_cache.slice(u16, rows * mla.key); + @memset(cache, 0); + for (0..rows) |t| { + for (0..mla.rope_dim) |i| cache[t * mla.key + mla.lat + i] = c.toBf16(rope_in[t * mla.rope_dim + i]); + } + l.fillRows(0, rows); + l.fillCs(rows); + const aa = l.args(rows); + const cb = gpu.queue.commandBuffer(); + const e = cb.compute(.serial); + e.setPipeline(gpu.rope_cache); + e.setBuffer(l.b_rows, 0, 0); + e.setValue(aa, 1); + e.setBuffer(l.b_cs, 0, 2); + e.useResource(l.b_cache, mtl.ResourceUsage.read | mtl.ResourceUsage.write); + e.dispatchGroups(mtl.Size.of(rows, 1, 1), mtl.Size.of(32, 1, 1)); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |why| { + std.debug.print("rope_cache failed: {s}\n", .{why}); + return error.GpuFailed; + } + var worst: f32 = 0; + var bits_miss: usize = 0; + for (0..rows) |t| { + var z64: [mla.rope_dim]f64 = undefined; + var out: [mla.rope_dim]f64 = undefined; + for (0..mla.rope_dim) |i| z64[i] = rope_in[t * mla.rope_dim + i]; + mla.rotate(&out, &z64, @intCast(t), s.theta); + for (0..mla.rope_dim) |i| { + const want = c.toBf16(@floatCast(out[i])); + const gbits = cache[t * mla.key + mla.lat + i]; + if (want != gbits) bits_miss += 1; + worst = @max(worst, @abs(c.fromBf16(want) - c.fromBf16(gbits))); + } + } + std.debug.print("rope_cache vs host rotate: bits miss {d} worst abs {e}\n", .{ bits_miss, worst }); + if (worst > 2e-3) return error.RopeCache; +} + +fn checkExpand() !void { + const a = std.testing.allocator; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const rows: u32 = 4; + const H = s.heads; + var seed: u64 = 0x6765; + const gate = try c.fill(&seed, rows * H, a); + defer a.free(gate); + c.roundSlice(gate); + const q = try a.alloc(f32, rows * H * mla.qd); + defer a.free(q); + @memset(q, 0); + const kv = try a.alloc(f32, rows * mla.key); + defer a.free(kv); + @memset(kv, 0); + const w_rms: [mla.lat]f32 = @splat(1); + const kvb_w = try a.alloc(f32, H * (mla.nope + mla.vd) * mla.lat); + defer a.free(kvb_w); + @memset(kvb_w, 0); + + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var gpu = try c.Gpu.init(); + defer gpu.deinit(); + var l = try c.Launch.open(gpu, s, rows, q, kv, &w_rms, kvb_w, gate); + defer l.deinit(); + const aa = l.args(rows); + const cb = gpu.queue.commandBuffer(); + const e = cb.compute(.serial); + e.setPipeline(gpu.gate_expand); + e.setBuffer(l.b_g, 0, 0); + e.setBuffer(l.b_g2, 0, 1); + e.setValue(aa, 2); + e.dispatchThreads(mtl.Size.of(H * mla.vd, rows, 1), mtl.Size.of(128, 1, 1)); + e.end(); + cb.commit(); + cb.wait(); + if (cb.failure()) |why| { + std.debug.print("gate_expand failed: {s}\n", .{why}); + return error.GpuFailed; + } + const g_bits = l.b_g.slice(u16, rows * H); + const want = try a.alloc(u16, rows * H * mla.vd); + defer a.free(want); + mla.expandGate(want, g_bits, rows, H); + try c.expectBitsEqual("gate_expand", l.b_g2.slice(u16, want.len), want); +} + +test "Ling rope_q GPT-J halves vs host rotate" { + try checkRopeQ(); +} + +test "Ling rope_cache GPT-J halves vs host rotate" { + try checkRopeCache(); +} + +test "Ling gate_expand (T,H) to (T,H*128) bits-equal" { + try checkExpand(); +} diff --git a/zig/tests/ling_mla_gpu_mixer.zig b/zig/tests/ling_mla_gpu_mixer.zig new file mode 100644 index 00000000000..9abd25f4fee --- /dev/null +++ b/zig/tests/ling_mla_gpu_mixer.zig @@ -0,0 +1,38 @@ +//! Ling MLA mixer on Metal vs mla.zig f64 and bf16-point. +const std = @import("std"); +const mtl = @import("metal"); +const mla = @import("mla"); +const c = @import("ling_mla_gpu_common.zig"); + +fn checkMixer(rows: u32) !void { + const a = std.testing.allocator; + const s = mla.Shape{ .heads = 16, .eps = mla.eps_tiny, .theta = mla.theta_tiny }; + const in = try c.Inputs.make(a, s, rows, 0x6d6c61); + defer in.free(a); + const n = rows * s.outWidth(); + const want64 = try a.alloc(f64, n); + defer a.free(want64); + const want_bf = try a.alloc(f64, n); + defer a.free(want_bf); + try mla.mixF64(a, want64, in.q, in.kv, in.w, in.kvb, in.g, s, rows, 0); + try mla.mixBf16(a, want_bf, in.q, in.kv, in.w, in.kvb, in.g, s, rows, 0); + + const pool = mtl.objc.Pool.push(); + defer pool.pop(); + var g = try c.Gpu.init(); + defer g.deinit(); + var l = try c.Launch.open(g, s, rows, in.q, in.kv, in.w, in.kvb, in.g); + defer l.deinit(); + try l.dispatchMixer(g, 0, rows); + var buf: [64]u8 = undefined; + const tag = try std.fmt.bufPrint(&buf, "mla {d} rows", .{rows}); + try c.gateNamed(tag, l.y(), want64, want_bf); +} + +test "MLA mixer Metal vs f64 and bf16-point on 2 rows from pos 0" { + try checkMixer(2); +} + +test "MLA mixer Metal vs f64 and bf16-point on 4 rows from pos 0" { + try checkMixer(4); +} diff --git a/zig/tests/qwen35/serve_check.py b/zig/tests/qwen35/serve_check.py index b6139fa787b..537ef4f2899 100644 --- a/zig/tests/qwen35/serve_check.py +++ b/zig/tests/qwen35/serve_check.py @@ -17,6 +17,21 @@ ] +DRAFTS = {"accepted": {}, "plain": 0} # drafts accepted per temperature, and tokens drafted by plain replies + + +class Reply: + """A reply's token hash (reasoning included); equal only to the same hash, never when either has no token.""" + + def __init__(self, doc): + runtime, usage = doc.get("tensorfold") or {}, doc.get("usage") or {} + self.sha = runtime.get("token_sha256") if usage.get("completion_tokens") else None + self.text = doc["choices"][0]["message"]["content"] + + def __eq__(self, other): + return isinstance(other, Reply) and self.sha is not None and self.sha == other.sha + + def ask(messages, draft=True, temperature=0.0, seed=7, url=URL): body = {"model": MODEL, "messages": messages, "max_tokens": TOKENS, "temperature": temperature, "seed": seed, "draft": draft, "chat_template_kwargs": {"enable_thinking": False}} @@ -24,7 +39,12 @@ def ask(messages, draft=True, temperature=0.0, seed=7, url=URL): {"Content-Type": "application/json"}) with urllib.request.urlopen(request, timeout=900) as reply: doc = json.load(reply) - return doc["choices"][0]["message"]["content"], doc.get("usage", {}).get("prompt_tokens_details", {}) + spec = doc.get("speculative") or {} + if draft: + DRAFTS["accepted"][temperature] = DRAFTS["accepted"].get(temperature, 0) + (spec.get("accepted") or 0) + else: + DRAFTS["plain"] += spec.get("drafted") or 0 + return Reply(doc), doc.get("usage", {}).get("prompt_tokens_details", {}) def user(text): @@ -45,6 +65,8 @@ def run(i): return out +# the resumed chat's first turn: Qwen 3.5 keeps only prompts of 4,096 tokens or more (serve with --context 8192+) +DOCUMENT = "An inventory: " + " ".join(f"crate{i % 89}-{(i * 6151) % 997}" for i in range(900)) LONG = "Summarise this list in one sentence: " + " ".join(f"item{i % 97}x{(i * 7919) % 1013}" for i in range(500)) @@ -74,21 +96,29 @@ def check(name, same): print(("ok " if same else "FAIL ") + name, flush=True) +greedy = None for label, temperature in (("greedy", 0.0), ("t0.8", 0.8)): serial = [ask(user(p), False, temperature)[0] for p in PROMPTS] drafted = [ask(user(p), True, temperature)[0] for p in PROMPTS] - check(f"{label}: drafted == serial", drafted == serial) + accepted, plain = DRAFTS["accepted"].get(temperature, 0), DRAFTS["plain"] + check(f"{label}: drafted == serial ({accepted} drafts accepted, plain drafted {plain})", + drafted == serial and accepted > 0 and plain == 0) check(f"{label}: solo == together", together(True, temperature) == drafted) check(f"{label}: serial together == serial solo", together(False, temperature) == serial) again = [ask(user(p), True, temperature)[0] for p in PROMPTS] - check(f"{label}: the same twice", again == drafted) + if greedy is None: + greedy = drafted + check(f"{label}: the same twice", again == drafted) + else: # the same seed twice, and unlike greedy for some prompt: the sampler ran + check(f"{label}: the same twice, unlike greedy", again == drafted and drafted != greedy) # the long prompt first among the decoders (its prompt goes in a chunk a round), then alone (resumed from its cuts) mixed = among_decoders(True, temperature) check(f"{label}: decoders unchanged by a long prompt", mixed[:3] == drafted[:3]) check(f"{label}: long prompt among decoders == alone", mixed[3] == ask(user(LONG), True, temperature)[0]) check(f"{label}: serial long prompt among decoders == alone", among_decoders(False, temperature)[3] == mixed[3]) -first, _ = ask(user(PROMPTS[0]), True) -turn = user(PROMPTS[0]) + [{"role": "assistant", "content": first}, {"role": "user", "content": "Now say it shorter."}] +opening = user(DOCUMENT + "\n\n" + PROMPTS[0]) +first, _ = ask(opening, True) +turn = opening + [{"role": "assistant", "content": first.text}, {"role": "user", "content": "Now say it shorter."}] # the fresh side on a server that keeps no prompts; a fresh reply that restored tokens fails by name fresh, fresh_details = ask(turn, False, url=FRESH_URL) resumed, details = ask(turn, True) @@ -97,6 +127,8 @@ def check(name, same): check("resumed == fresh: the fresh reply has no prompt_tokens_details.cached_tokens", False) elif restored != 0: check(f"resumed == fresh: the fresh request resumed {restored} tokens (FRESH_URL: --prompt-cache-gib 0)", False) +elif not details.get("cached_tokens"): + check(f"resumed == fresh: the resumed request resumed no tokens (vacuous; cached {details})", False) else: check(f"resumed == fresh (cached {details})", resumed == fresh) print("failed", failed)