Skip to content

tools: verify cache state and retain benchmark evidence - #485

Merged
ashhart merged 1 commit into
ashhart:zig-flashnextfrom
akol1:codex/verified-cache-benchmarks
Oct 9, 2026
Merged

ashhart merged 1 commit into
ashhart:zig-flashnextfrom
akol1:codex/verified-cache-benchmarks

Conversation

@akol1

@akol1 akol1 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

The HTTP benchmarks discard actual prompt/cache usage, and absent token hashes can compare equal and produce a false exactness pass. Retain per-request evidence and require affirmative cache/hash observations.

  • Share strict usage validation and output fingerprinting across the existing single-stream and concurrent clients. Missing, malformed or truncated evidence stays unverified; invalid counts are never coerced to zero.
  • A cold observation requires explicit zero cached tokens in a completed stream. Positive valid counts indicate reuse. Neither phase order nor request text length determines cache state.
  • Missing token-ID hashes cannot pass exactness checks. Output fingerprints include content and reasoning and remain stable across network chunk boundaries; incomplete streams have no published fingerprint or decode rate.
  • Add a standard-library cache client for first, repeated and concurrent requests with no warm-up or automatic cache reset. Optional cold/reuse and exact prompt-count assertions fail closed. Raw checkpoint-tokenizer ID fixtures support exact-length prefill cells.
  • Export an allowlist of counts, hashes, timing and settings; exclude origins, model aliases, local paths, raw prompts/outputs and exception text. Document fingerprint privacy limits and the legacy single-stream sample.

Validation:

  • Both unchanged clients demonstrably discard an 8-token prompt's reported 7 cached tokens; the patched clients retain them.
  • 17 model-free regressions pass on Python 3.12 and 3.13, including real loopback HTTP concurrency, malformed counters, missing hashes, truncated/empty SSE, Unicode chunking, CLI summaries, assertion failures and receipt allowlisting.
  • Smoke against TensorFold's own native fake-engine HTTP API: first/repeated/concurrent requests report explicit zero reuse; a required-cold claim passes and a required-reuse claim fails. Fake timings are not model-performance measurements.
  • Clean composition with the independent native contributions; joint host/HTTP/golden checks pass with seven existing known golden differences and no unexpected differences.
  • Python compilation and diff checks pass. Lean checker remains at its 513-finding inherited baseline, with zero added findings.

No backend computation or memory policy changes. Actual checkpoint/device performance and exactness qualification were not run, and no such claim is made. The native baseline full suite is blocked by the unavailable Xcode Metal compiler; inherited golden allocator diagnostics are disclosed separately from passing comparisons.

Publication review covered the full tracked tree, fixtures, outgoing commit identity and PR text. No private operator identifiers, paths, credentials, prompts, model weights or runtime logs are included.

@akol1
akol1 marked this pull request as ready for review October 7, 2026 16:00
@SvangenStudios

Copy link
Copy Markdown

I ran this PR's tools against a real checkpoint on a DGX Spark, using both the native 1.0.2 server and Python 0.6.6. The tools did what the description says, and on one run they also caught a cold claim that wasn't true.

Setup.

  • Hardware and software: GB10 (sm_121), DGX OS 7.6.0 (kernel 7.0), driver 580.178.04.
  • Tools: this PR's 6c86dd5, Python 3.12.
  • Checkpoint: TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit @ d9d758fb, all files sha256-checked against the hub.
  • Servers: release archive tensorfold-1.0.2-linux-aarch64, and tensorfold 0.6.6 (tag) in NGC PyTorch 26.07.
  • Both servers ran with --context 69632 --parallel 4 --no-thinking --prompt-cache-gib 0, drafts on, a fresh process per engine.
  • Model-free tests: python3 -m unittest discover -s tools/tests -p 'test_bench*.py' passes 17/17 on Linux aarch64.

bench_cache.py (--tokens 64 --repeats 2 --streams 4 --require-cold)

first repeated concurrent ×4 qualified
1.0.2 cold, 0/2570 cold, 0/2570 cold, 0/2570 true
0.6.6 cold, 0/2570 reused, 2569/2570 reused, 2569/2570 true (--require-cold checks the first request only)

All 7 rows on both engines give the same token_sha (2b166da54e4f).

With --prompt-cache-gib 0, 0.6.6's CUDA server still reused the prefix. I first ran the prefill cells with token fixtures that all start with the same text, so each larger fixture began with the previous one. --require-cold then failed the 8K, 32K and 64K cells on 0.6.6 (reused, 2047/8191/32767 cached), which kept a resumed prompt out of the prefill numbers. The same cells on 1.0.2 were cold.

Cold prefill, --prompt-file with raw token IDs from the checkpoint's tokenizer. The fixture text is the repo's Apache-2.0 LICENSE, and each size starts at a different token, so none is a prefix of another. --expected-prompt-tokens N --require-cold, sizes in order on a fresh process. Each report has three requests: first, repeated and concurrent. The table uses the first request per size, all with cached_tokens == 0. On 1.0.2 the repeated and concurrent requests were cold too; on 0.6.6 they reused the prefix (2047/2048 … 65535/65536). TTFT-based tok/s, one measurement per size with no repetitions, so small differences aren't established:

Tokens 1.0.2 0.6.6 token_sha
2,048 7,146 6,406 same
8,192 7,197 7,101 same
32,768 6,275 6,354 same
65,536 5,328 5,410 same

Every first request has prompt_tokens == N and cached_tokens == 0.

bench_openai.py, bench_concurrent.py (--tokens 256 --reps 3 --temperatures 0)

1.0.2 0.6.6
decode, fibonacci-raw 210.3 tok/s 200.4
decode, gpu-chat-no-think 154.8 146.8
code, 4 streams: aggregate / per stream / TTFT max 322.3 / 85.3 / 0.24 s 197.7 / 200.0 / 3.91 s
chat, 4 streams: aggregate / per stream / TTFT max 274.1 / 70.7 / 0.28 s 145.0 / 146.4 / 5.32 s
--alone equal, --serial equal (per prompt) 3/3 at 1 stream, 12/12 at 4; serial 1/1 at both the same
--mixed, 4 streams, sampled 197.9 aggregate, alone 8/8, serial 4/4 148.2, 8/8, 4/4

0.6.6 with --parallel 4 ran the four Nemotron requests one after another on CUDA: its aggregate stays at the single-stream rate, and TTFT grows. 1.0.2 runs them in shared rounds.

Beyond the PR's own prompts, I sent eight different prompts four at a time (essay, story, code, edit, math, Swedish, JSON, list), greedy, 256 tokens. Each reply's text equals its solo run on both engines, 8/8. That check compares text only, not token IDs.

Not covered here: Metal, other checkpoints, and --require-reuse, since 1.0.2 on CUDA reports no reuse for Nemotron yet. Reports and fixtures are available on request.

@SvangenStudios SvangenStudios mentioned this pull request Oct 8, 2026
5 of 8 tasks
@ashhart
ashhart merged commit 782ce90 into ashhart:zig-flashnext Oct 9, 2026
@ashhart

ashhart commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Thanks @akol1 for the model-free benchmark tooling. The local integration passed the all-target build, host/native/golden tests and three-platform host builds, with no additional lean findings. We retained your original commits and kept our integration changes separate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants