Skip to content

tools: served gates prove they ran: drafts landed, the sampler and the cache were used, requests overlapped - #3708

Merged
ashhart merged 5 commits into
ashhart:mainfrom
jschmied:gate-audit
Nov 19, 2026
Merged

ashhart merged 5 commits into
ashhart:mainfrom
jschmied:gate-audit

Conversation

@jschmied

@jschmied jschmied commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Head: e4ab4bdebb on main e3fb56cb09. Follows #2460 (comments 6711746590, 6716617133).

Since 47a72d569e, only tools/tests/fake_served_api.py changed: the fake now forms its concurrent pairs on Windows too, and it keeps main's FixtureHTTPServer backlog. The device results below were taken at 47a72d569e, and none of the gate or client code they ran has changed since. benchmark-clients passes at this head on windows-latest (199 tests, 194.6 s) and on ubuntu-latest (199 tests, 170.1 s), run 44439156164.

What was vacuous

A gate comparing two replies passes without testing anything when the property it names never ran.

  • zig/tests/qwen35/serve_check.py resumed == fresh is still vacuous on CUDA at main.
    • :95-99 now check the fresh side, but nothing checks that the resumed turn cached anything (:101).
    • Its chat is 23 to 201 tokens, and Qwen 3.5 keeps only prompts of 4,096 tokens or more (core/prompt_rules.zig:12).
  • The same gap exists elsewhere. Each item below names the condition under which the gate goes vacuous; each is now fixed.
    • Empty replies. The kit's same and serve_check's content compare hash "" == "".
    • A drafter that never lands.
      • The kit summed accepted drafts over both modes, so a sampled arm that never drafted passed.
      • serve_check, lfm3 serve_check and qwen27_http_gate never counted accepted drafts.
    • A plain arm that drafts anyway. If "draft": false is ignored, both arms draft and drafted == plain compares drafted against drafted. Nothing checked for this.
    • A seed or temperature that never reaches the sampler. Then every seeded pair is greedy == greedy.
    • Requests the server serialises. concurrent == solo then compares solo against solo.
    • A server that stops drafting under load.

The full audit covers every gate in scope and 18 more served or host scripts, with file:line and a verdict per gate. The fixes here are limited to the kit and the gates it replaces (list below); the rest are follow-ups.

The fixes

Each check fails by name when its property was not exercised.

  • tools/conformance.py:
    • a reply with no tokens is unverified;
    • drafted == plain needs a draft accepted in each mode, and 0 drafted by the plain replies;
    • repeat asks one sampled prompt with seed+1, prompt by prompt until one differs, and fails if none does;
    • concurrent polls GET /v1/load every 5 ms during each batch:
      • every batch of 2 or more must show http_active.chat_completions >= 2;
      • at each level, drafted rows must accept a draft and plain rows draft none.
        The census is conformance_lifecycle.census, shared rather than copied.
  • zig/tests/qwen35/serve_check.py:
    • compares token_sha256 (reasoning included; a reply with no tokens equals nothing);
    • drafted == serial needs accepted > 0 and plain drafted == 0;
    • t0.8 must differ from greedy;
    • resumed must resume tokens. Its first turn now carries a 900-item document (about 6k tokens), so a healthy server crosses the 4,096 floor. Serve it with --context 8192 or more.
    • The check names are unchanged, except t0.8's "the same twice, unlike greedy".
  • tools/lfm3/serve_check.py:
    • drafts/exercised: accepted > 0 over the drafted requests and 0 drafted on the plain ones;
    • sampled_*/sampler_ran: tensorfold.sampling == "exact".
  • tools/zig/qwen27_http_gate.py: a drafted reply must accept a draft, not only propose one.

Planted controls (red on main, green here)

The fake served API gains six faults, each named for the gate it turns red: undrafted, plain_drafts, sampled_drafts, unsampled, serial and empty. The new tests are tools/tests/test_bench_{conformance,serve_check,lfm3_serve_check,qwen27_http_gate}.py, which the test_bench*.py line in no-gpu.yml:37 finds, so the workflow is unchanged.

Tests run against Result
main's scripts test_bench_conformance 9 failures and 3 errors (the drafted gate's new signature); test_bench_serve_check 5 of 5 fail; lfm3 3 of 3; qwen27 HTTP 1 of 2
this head 168 tests OK
  • The clean fake passes every gate.
  • Each fault turns its gate red. Two faults also redden a second gate, and each such test names both:
    • undrafted and plain_drafts also redden concurrent, where batched rows draft;
    • unsampled also reddens resumed, because only the cached fake carries the fault.
  • The bench suite takes 185 s here, against 121.5 s on main.

On the GB10

main's native binary (038e4a2787, md5 caa8ca7c, CUDA sm_121) with this head's tools. The receipts are in the author's ledger.

  • Kit, qwen35-cuda (Qwen3.8-27B NVFP4 + DFlash2): 7 passed, 0 failed.
    • drafted: 457 of 2,820 drafts accepted.
    • repeat: another seed differs.
    • concurrent: 76/76, with 2 to 8 chat requests open at once.
    • resumed: 4,096 cached each turn.
    • cancel: 4/4.
    • evict: 4,096 -> 0.
  • Kit, gemma4-cuda (Gemma 4 31B 4-bit + DFlash): 7 passed, 0 failed.
    • drafted: 449 of 2,308 accepted.
    • concurrent: 76/76, 2 to 8 open at once.
    • resumed: 6,108 to 6,192 cached.
    • evict: 6,249 -> 4.
  • serve_check.py, this head, against a cached server and a --prompt-cache-gib 0 server, both --context 16384 --parallel 8: 15 of 15 ok.
    • drafted == serial: greedy 187 and t0.8 174 drafts accepted; plain drafted 0.
    • resumed == fresh: cached_tokens: 4096.
  • Main's serve_check.py, on the same two servers: also 15 of 15 ok, but its resumed == fresh passes with cached_tokens: 0. That is the vacuous pass, reproduced live.
  • No changed gate fails on these healthy runs.

Metal (M3 Pro 36 GB, mac-agent)

Server binary main 038e4a278; this PR's tools (47a72d569) against main's tools, on the same server.

  • Kit, qwen27-metal (Qwen3.8-27B MLX 4-bit + DFlash), same result with both tools:
    • drafted: PASS 10/10, 433 of 1,468 accepted.
    • repeat: PASS. This branch also checks that a different seed gives different text.
    • concurrent: PASS 40/40. This branch saw 2 to 4 requests open at once, so the overlap check holds even at --parallel 1, where requests queue.
    • refusals: PASS 4/4. evict: SKIP.
    • resumed and cancel: FAIL with both tools, so the server binary causes them, not the new checks.
      • Each passes when run alone: resumed+cancel PASS, cached [86,175,87,174].
      • In the full run, 13 memory-pressure warnings stop new kept states (cached [0,175,87,0]).
      • concurrent+cancel ends with "no idle census". After all 56 POSTs replied, /v1/load showed running 1, waiting 22 (memory_pressure 21), every http_active 0. It was still 15 waiting 70 s later.
      • That looks like a main-binary bug in the 27B Metal server under memory pressure. It's outside this PR; I can open an issue with the receipts if you want one.
  • qwen27_http_gate: this branch 16/16 PASS, every drafted row accepted (153 to 216 drafts). Main's gate is also 16/16. Inputs: ids from /v1/tokenize; CLI receipts from tf-qwen27-dflash-run --prototype q4 --compare-plain, where 4 of 4 drafted runs equal plain and the final state is equal.

Not run here

  • lfm3 serve_check: not on Metal either, without a download. lfm3-1.7b-base is bf16 (UnsupportedLfm3Quantization), and lfm3-vl-2b-4bit needs the stacked vision contribution. Both tools fail the same way at server start.
  • The kit's XPU profile: its new checks are proven only by the fake.

Follow-ups, not in this PR (from the audit)

  • flashnext_constraint_gate.py: draft counters and the two seeds are unchecked (Metal).
  • clef_head_gate.py compare: passes with 0 logits. It needs numpy, which CI lacks.
  • xpu_draft_receipt.py: prints FAIL but exits 0.
  • structured_served.py, vision_served.py, video_served.py: drafted == plain compares content only.
  • reuse_served.py: cancel is unchecked.
  • image_cache_turns.py: reuse never asserts cached_tokens.
  • bench_concurrent.py --serial/--alone: a reporter with no draft or overlap evidence.

Proposed CHANGELOG line (for you to place): - Tools: served gates fail by name when the property they compare never ran: the conformance kit, serve_check.py (Qwen 3.5 and LFM3) and qwen27's HTTP gate now require landed drafts, a plain arm without drafts, a sampler the seed reaches, overlapping requests, a resumed turn that resumed tokens, and replies with tokens (#2460).

No refusal changes; no speed claims; tools and tests only.

CI time: the bench tests take 185 s here against 121.5 s on main. Scaled from main's last CI run (an estimate, not measured), the Windows job would land near 4:20 of its 5-minute limit. If that is too close, I can split the new fault tests into their own step.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. The new fault controls make the gate changes clear, and the tooling changes look sound. tools/conformance.py at 600 lines is within the limit, so nothing to fold there.

One thing before landing: the new test_fault_seed_never_reaches_sampling (tools/tests/test_bench_conformance.py) fails in the benchmark-clients (windows-latest) job at this head. assert_only_red("unsampled", also=("resumed == fresh",)) sees three red lines where it expects two. Please make it pass on Windows (or say why that third line is expected there), and post the CI result at the new head.

The supplied device results and their stated failures stay separate from this.

  • Synthena

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. The watched partner window is now 60 ms, the census wait is 500 ms, and the unsampled test still requires exactly its two named failures. Please resolve fake_served_api.py against main’s FixtureHTTPServer while preserving its backlog, then post the Windows benchmark-clients result on that rebased head.

  • Synthena

@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart Rebased onto main e3fb56cb09. The head is now e4ab4bdebb. fake_served_api.py uses main's FixtureHTTPServer (request_queue_size 128), and our own backlog class is gone.

benchmark-clients at this head, run 44439156164:

  • windows-latest: 199 tests, OK, 194.6 s (job). test_fault_seed_never_reaches_sampling and test_clean_fake_passes_every_gate both pass.
  • ubuntu-latest: 199 tests, OK, 170.1 s (job).

The third red line on Windows was concurrent == solo: "N of 16 batches never showed two chat requests open at once". It was not the seed fault.

  • Cause: the threads a batch releases together can start one scheduler tick apart on Windows, about 16 ms. That is past the fake's 10 ms partner window, so a pair never formed, and no census could count it. Staggering each post by 0-30 ms on macOS reproduces the exact line.
  • Fix: while a client polls the census (two reads within 0.1 s), a request waits up to 60 ms for a partner, otherwise 10 ms as before. A counted pair stays open at most 0.5 s. One-off census reads, such as the refusals gate, don't pay the wait. test_fault_seed_never_reaches_sampling still requires exactly its two named red lines.

Only the fake changed since 47a72d569e, so the device results in the body still describe the gates as they are at this head.

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. The fake now uses main's FixtureHTTPServer with its backlog, the partner window explains the Windows-only third line, and the seed test still requires exactly its two named failures. The Windows and Ubuntu benchmark-clients runs are green at this head.

Nothing further is needed from you on this PR.

  • Synthena

jschmied and others added 5 commits November 19, 2026 08:04
…e cache were used, requests overlapped

A gate that compares two replies passes vacuously when the property it names never ran. serve_check.py's
resumed == fresh still never asserted the resumed turn cached anything (Qwen 3.5 keeps prompts from 4,096
tokens; its chat was 23-201), and the kit, lfm3's serve_check and qwen27's HTTP gate had the same gap for
drafts, sampling, overlap or empty replies. Each check now fails by name when its property was not exercised.

- conformance: a reply without a token is unverified (two empty replies hash the same); drafted == plain
  needs a draft accepted in each mode and none drafted by the plain replies; repeat asks a sampled prompt
  with the next seed and needs a different reply; concurrent polls GET /v1/load during each batch and needs
  two chat requests open at once, and at each level drafted rows that accepted and plain rows that drafted none.
- zig/tests/qwen35/serve_check.py: compares token_sha256 (reasoning included, empty never equal); drafted ==
  serial needs drafts accepted and none in plain; t0.8 must differ from greedy; the resumed turn must resume
  tokens, and its first turn carries a 900-item document so a healthy Qwen 3.5 server does.
- tools/lfm3/serve_check.py: drafts/exercised and sampled_*/sampler_ran (tensorfold.sampling == "exact").
- tools/zig/qwen27_http_gate.py: a drafted reply must accept a draft, not only propose one.
- The fake served API gains the faults undrafted, plain_drafts, sampled_drafts, unsampled, serial and empty;
  each new test is red on main's scripts and green here (test_bench*.py, found by no-gpu.yml).
…s counts them

On windows-latest every gate test failed concurrent == solo: 1 to 4 of 16 batches never showed two chat requests
open at once. A request that found a partner stayed open a fixed 25 ms, and there a GET /v1/load read can take
longer than that, so the census missed the overlap. It now stays open until a census counts two open at once (at
most 2 s). With census reads slowed to 30 ms the old fake fails the clean run and the new one passes at 100 ms.
At 2b7a41c every pair waited up to 2 s for a census, also in the serve_check and lfm3 tests, which send requests
together without reading one; both benchmark-clients jobs passed the 5 min limit. A pair now waits to be counted
only while a census was read in the last 0.25 s (and at most that long); otherwise it stays open 25 ms as before.
The listen backlog is main's FixtureHTTPServer (ba970d9).
…uest's partner

windows-latest at 72b7117 still saw 1 to 3 of 16 concurrent batches never open two requests at once. The threads
a batch releases together can start a scheduler tick apart there (about 16 ms), past the fake's 10 ms partner
window, so a pair never formed. Staggering each post by 0 to 30 ms reproduces it on macOS (1 of 16, same line).
While a client polls the census (two reads within 0.1 s, the last that recent) a request now waits 60 ms for a
partner; elsewhere it waits 10 ms as before, and a counted pair waits at most 0.5 s. Posts staggered 0 to 50 ms:
the clean gate run passes 3 of 3. Full test_bench* set merged with main 2a674b5: 199 OK in 177 s (157 s at
72b7117).
@ashhart
ashhart merged commit 813ff4c into ashhart:main Nov 19, 2026
13 of 22 checks passed
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

2 participants