Skip to content

Tests: pins for the documented limits, defaults and flag dependencies, a replay of the prompt cache's eviction, and a timing of its index - #2305

Merged
ashhart merged 9 commits into
mainfrom
lead/tests-1106
Nov 9, 2026
Merged

ashhart merged 9 commits into
mainfrom
lead/tests-1106

Conversation

@ashhart

@ashhart ashhart commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Two test-only additions. No production code changes.

Pins for the documented limits (zig/src/server/limit_pins_test.zig, zig build test-limit-pins-host): for each limit that docs/api.md or the README states with no existing test, one case at the bound that's accepted and one just outside that's refused, with the refusal text the server answers. The limits are the penalties' -2 to 2, min_p's 0 to 1, top_logprobs' 0 to 20 (and only with logprobs), n of 1, the Responses metadata caps (16 pairs, keys up to 64 characters, values up to 512), --max-frames 1 to 8,190, and --reasoning-effort's six levels. Limits that already had a test are cited in the test, not duplicated. A doc and the server can no longer drift apart on these without a red test.

Pins for the documented TF_* defaults (zig build test-env-defaults-host, in its own zig/build/env_defaults.zig): unset gives the documented default, a value in range is taken, and one just outside is refused or clamped as the code does today, for TF_DRAMA_PREFILL_ROWS, TF_LOAD_PREFETCH, TF_GLM_PREFILL_REDUCE, TF_GLM_PROMPT_K, TF_GLM_DENSE_BITS, TF_GLM_CLEAR_THINKING, TF_KV_PAGES and TF_QWEN27_COPIES where no test already did.

Pins for the flag dependencies (zig/src/server/flag_deps_test.zig, zig build test-flag-deps-host): a flag that needs another, such as --cfg-batched and --cfg-force-guided needing a gamma switch, and the backend build gates, each with its refusal text and its accepted form. Dependencies that already had a test are left to those tests.

A replay of the prompt cache's eviction (zig/cache_replay*.zig, zig build test-cache-replay-host, and zig build cache-replay to rerun it):

  • What it drives: the real Store.begin and Store.keep, including main's victim choice, with three agent-shaped traces: long coding sessions that grow turn by turn, one-off requests between them, and a session that goes idle and returns. It uses the 27B's real state sizes and a 2,000 tok/s recompute cost.
  • What it found: main's policy holds up. Keeping the states that save the most prefill time per byte cuts recompute by 2.7% at 4 GiB and 10.5% at 8 GiB, but costs 2.6% more at 16 GiB. Pure recency is level or worse. That's not consistent enough to change the policy.
  • Why keep it: a later change to the policy can be measured against the same traces.

A timing of the prompt cache's snapshot index (zig/src/core/prompt_cache_index_timing_test.zig, zig build test-cache-index-timing, ReleaseFast, host only, not part of the default test run). It times the index at 16 to 1,024 kept states. The costliest lookup at 1,024 states takes 9 µs with warm caches and 39 µs cold, about 1/128,000 of a 5 s prompt pass. So a prefix hash isn't worth building: hashing a 64K-token prompt costs about as much as the whole scan.

Checks:

  • zig build test-limit-pins-host test-cache-replay-host compile-cache-replay-host test-prompt-cache-host: 12 of 12 steps, 536 of 536 tests; test-cache-index-timing 3 of 3 steps, 11 of 11 tests; test-env-defaults-host test-capability-env-host test-flag-deps-host test-limit-pins-host 15 of 15 steps, 99 tests passed and 2 skipped.
  • zig fmt --check, no new lean finding, and a plain zig build (255 of 255 steps).

@ashhart ashhart changed the title Tests: pins for the documented request and flag limits, and a replay of the prompt cache's eviction Tests: pins for the documented limits, a replay of the prompt cache's eviction, and a timing of its index Nov 6, 2026
@ashhart ashhart changed the title Tests: pins for the documented limits, a replay of the prompt cache's eviction, and a timing of its index Tests: pins for the documented limits and flag dependencies, a replay of the prompt cache's eviction, and a timing of its index Nov 6, 2026
@ashhart ashhart changed the title Tests: pins for the documented limits and flag dependencies, a replay of the prompt cache's eviction, and a timing of its index Tests: pins for the documented limits, defaults and flag dependencies, a replay of the prompt cache's eviction, and a timing of its index Nov 6, 2026
ashhart added a commit that referenced this pull request Nov 6, 2026
ashhart added a commit that referenced this pull request Nov 9, 2026
…the backend gate

GLM's env_defaults_test module takes core and canon beside cuda and heat,
as main's GLM CUDA module has them: Settings.read now reaches cuda_l2pf.zig
and the weight, format and shard files that import them.

Drama's two settings read through the environment table since #2658, so a
word in TF_DRAMA_PREFILL_ROWS is refused with the table's text, which the pin
now expects; a new pin covers TF_DRAMA_REFERENCE_CACHE's default and its
refusal past 16, and the table cases add the values only drama_open bounds.

The flag-deps pin parsed --backend mlx everywhere, but off macOS a test
root's build serves auto and cuda (cli.zig backend_values), so it failed on
Linux; it now takes each build's own backend and refuses the other.
Add test-cache-index-timing, a host-only ReleaseFast step that fills the
store with interleaved chat conversations of 2K to 64K tokens (shared
system prompts, forks and unrelated prompts) and times find for a
next-turn hit, an edited-prefix hit, a miss and a hit on the longest
state, warm and cold, plus the whole lookup. Each query is checked
against the whole-store oracle before it is timed, so the index can be
re-measured before any change to it.
drama_cfg.zig serves --cfg-gamma, --cfg-batched and --cfg-force-guided natively only on macOS, so Linux and Windows
refuse them as not served and the pins failed there.
…the backend gate

GLM's env_defaults_test module takes core and canon beside cuda and heat,
as main's GLM CUDA module has them: Settings.read now reaches cuda_l2pf.zig
and the weight, format and shard files that import them.

Drama's two settings read through the environment table since #2658, so a
word in TF_DRAMA_PREFILL_ROWS is refused with the table's text, which the pin
now expects; a new pin covers TF_DRAMA_REFERENCE_CACHE's default and its
refusal past 16, and the table cases add the values only drama_open bounds.

The flag-deps pin parsed --backend mlx everywhere, but off macOS a test
root's build serves auto and cuda (cli.zig backend_values), so it failed on
Linux; it now takes each build's own backend and refuses the other.
@ashhart
ashhart merged commit 73eb950 into main Nov 9, 2026
5 of 10 checks passed
ashhart added a commit that referenced this pull request Nov 9, 2026
…the backend gate

GLM's env_defaults_test module takes core and canon beside cuda and heat,
as main's GLM CUDA module has them: Settings.read now reaches cuda_l2pf.zig
and the weight, format and shard files that import them.

Drama's two settings read through the environment table since #2658, so a
word in TF_DRAMA_PREFILL_ROWS is refused with the table's text, which the pin
now expects; a new pin covers TF_DRAMA_REFERENCE_CACHE's default and its
refusal past 16, and the table cases add the values only drama_open bounds.

The flag-deps pin parsed --backend mlx everywhere, but off macOS a test
root's build serves auto and cuda (cli.zig backend_values), so it failed on
Linux; it now takes each build's own backend and refuses the other.
@ashhart
ashhart deleted the lead/tests-1106 branch November 10, 2026 16:35
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.

1 participant