serving: recommended sampling defaults (off), and the device-sampler validation tooling #286

Merged
Grok merged 9 commits from serve/sampling-defaults into master 2026-10-21 13:41:38 +02:00
Owner

Serving defaults for the recommended sampling settings, plus the bench tooling to validate the device sampler at those settings. Production is not changed: the default unit (ExecStart and readiness probe) evaluates to the same drv as master's (unit-tenstorrent-serving.service.drv dsk2hhfg…). Deploying is the owner's call.

What today actually does

  • The unit passes no --generation-config, so vLLM uses auto and applies the checkpoint's generation_config.json: T=1.0, top_k 20, top_p 0.95. This is the same for Qwen3.8-27B-FP8, ThinkingCap and packed-G2.
  • So a request that omits sampling fields is already served at the recommended settings, on the host sampler with MTP off: the server logs say "Default vLLM sampling parameters have been overridden by the model's generation_config.json".
  • Benches send temperature: 0 and are unaffected.
  • The host path costs about 10x: 6.4 vs 66.6 tok/s/user at B=8 (agentic pi bench, r2 vs r3; docs/analysis/agentic-ideas-20261020.md).

Changes

  • modules/tenstorrent-serving.nix
    • samplingDefaults (default null): renders --override-generation-config '<json>', e.g. { temperature = 1.0; top_p = 0.95; top_k = 20; min_p = 0.0; } (D-2026-10-20-serve-recommended).
    • Assertion: a non-greedy default needs extraEnv.QWEN36_DEVICE_SAMPLE = "1" or an explicit samplingDefaultsOnHost = true.
    • The readiness probe refuses a server with QWEN36_DEVICE_SAMPLE=1 and no QWEN36_DEVICE_SAMPLE self-test exact banner, so it fails closed on a tree without the sampler, which is master today.
    • The VM test asserts that no override is rendered by default.
  • docs/SERVING.md §7a: today's behaviour, the recommended settings, and how they pair with the device sampler.
  • Bench tooling, with tools/ttx/tests/test_sampling_tooling.py (30 tests):
    • gsm8k.py, kv-accuracy.py and serving-bench.py: --temperature/--top-p/--top-k/--server-defaults/--seed-base, threaded through ttx run/ab/resident. At their defaults they send exactly {"temperature": 0} as before.
    • ttx ab with a gate suite now passes gate options; it was silently dropping them. Its --tokens default is None, but --control mode still uses 1024, and CI and mkqueue are unaffected (checked by review with mocks).
    • batch-equiv-bench.py --sampled-companions N: T>0 streams share decode steps with the T=0 streams under test.
    • bench/sampling-dist-check.py (ref | sample | compare | --self-test): exact vLLM 0.26 apply_top_k_top_p target from raw logprobs; per-cell TV distance, chi-square and Fisher; hard fail on any out-of-support sample; detects a shared unseeded seed; includes a decode-step cell, because decode_only host-samples the first token.
  • bench/agentic-pi/: the 10-20 8-agent pi bench as a repeatable harness. pi_provider.py with no --sampling sends server defaults.

Validation

  • Default unit drv is identical to master's.
  • Variants evaluated by hand: assertion pass/fail cases, flag quoting, bash -n on the probe.
  • nix build .#checks.x86_64-linux.tenstorrent-serving passes.
  • tools/ttx/tests: 678 run. The 1 error is test_seed_symlink (no pytest here), which also errors on master.
  • sampling-dist-check.py --self-test OK.
  • run.sh smoke-tested against a stub server: cleanup verified.
  • Independent opus review: MERGEABLE. Its warnings are fixed in d751206a, except that the VM test still covers only the default render.
  • No card time, no new speed number.

The CI card run this PR triggers (S5 vs S5 for tooling paths) carries no ship decision and will be cancelled.

🤖 Generated with Claude Code

Serving defaults for the recommended sampling settings, plus the bench tooling to validate the device sampler at those settings. **Production is not changed**: the default unit (ExecStart and readiness probe) evaluates to the same drv as master's (`unit-tenstorrent-serving.service.drv` dsk2hhfg…). Deploying is the owner's call. ## What today actually does - The unit passes no `--generation-config`, so vLLM uses `auto` and applies the checkpoint's `generation_config.json`: **T=1.0, top_k 20, top_p 0.95**. This is the same for Qwen3.8-27B-FP8, ThinkingCap and packed-G2. - So a request that omits sampling fields is already served at the recommended settings, on the host sampler with MTP off: the server logs say "Default vLLM sampling parameters have been overridden by the model's generation_config.json". - Benches send `temperature: 0` and are unaffected. - The host path costs about 10x: 6.4 vs 66.6 tok/s/user at B=8 (agentic pi bench, r2 vs r3; `docs/analysis/agentic-ideas-20261020.md`). ## Changes - **`modules/tenstorrent-serving.nix`** - `samplingDefaults` (default `null`): renders `--override-generation-config '<json>'`, e.g. `{ temperature = 1.0; top_p = 0.95; top_k = 20; min_p = 0.0; }` (D-2026-10-20-serve-recommended). - Assertion: a non-greedy default needs `extraEnv.QWEN36_DEVICE_SAMPLE = "1"` or an explicit `samplingDefaultsOnHost = true`. - The readiness probe refuses a server with `QWEN36_DEVICE_SAMPLE=1` and no `QWEN36_DEVICE_SAMPLE self-test exact` banner, so it fails closed on a tree without the sampler, which is master today. - The VM test asserts that no override is rendered by default. - **`docs/SERVING.md` §7a:** today's behaviour, the recommended settings, and how they pair with the device sampler. - **Bench tooling**, with `tools/ttx/tests/test_sampling_tooling.py` (30 tests): - `gsm8k.py`, `kv-accuracy.py` and `serving-bench.py`: `--temperature/--top-p/--top-k/--server-defaults/--seed-base`, threaded through `ttx run/ab/resident`. At their defaults they send exactly `{"temperature": 0}` as before. - `ttx ab` with a gate suite now passes gate options; it was silently dropping them. Its `--tokens` default is `None`, but `--control` mode still uses 1024, and CI and mkqueue are unaffected (checked by review with mocks). - `batch-equiv-bench.py --sampled-companions N`: T>0 streams share decode steps with the T=0 streams under test. - `bench/sampling-dist-check.py` (`ref | sample | compare | --self-test`): exact vLLM 0.26 `apply_top_k_top_p` target from raw logprobs; per-cell TV distance, chi-square and Fisher; hard fail on any out-of-support sample; detects a shared unseeded seed; includes a decode-step cell, because `decode_only` host-samples the first token. - **`bench/agentic-pi/`:** the 10-20 8-agent pi bench as a repeatable harness. `pi_provider.py` with no `--sampling` sends server defaults. ## Validation - Default unit drv is identical to master's. - Variants evaluated by hand: assertion pass/fail cases, flag quoting, `bash -n` on the probe. - `nix build .#checks.x86_64-linux.tenstorrent-serving` passes. - `tools/ttx/tests`: 678 run. The 1 error is `test_seed_symlink` (no pytest here), which also errors on master. - `sampling-dist-check.py --self-test` OK. - `run.sh` smoke-tested against a stub server: cleanup verified. - Independent opus review: MERGEABLE. Its warnings are fixed in d751206a, except that the VM test still covers only the default render. - No card time, no new speed number. The CI card run this PR triggers (S5 vs S5 for tooling paths) carries no ship decision and will be cancelled. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A request that omits sampling fields is not served greedy, as had been assumed. vLLM's
default --generation-config auto applies the checkpoint's {T 1.0, top_k 20, top_p 0.95},
and the server log warns about it. Such requests therefore already run host-sampled
with MTP off. That path costs 6.4 vs 66.6 tok/s/user at B=8 (agentic pi bench, r2 vs r3).

The recommended T=0.6/top_p 0.95/top_k 20 defaults are wired as an option. A non-greedy
default is asserted to pair with QWEN36_DEVICE_SAMPLE, or with an explicit
samplingDefaultsOnHost. With null (the default), the unit script renders byte-identical
to production's (checked by eval), and the VM test asserts that no override is rendered.
Deploying it is the owner's call.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Every correctness gate here hard-coded temperature 0, so a device-side sampler
(QWEN36_DEVICE_SAMPLE) could only be gated on rows it never serves at the model's
recommended T=0.6 / top_p 0.95 / top_k 20, and nothing compared its distribution
with vLLM's host sampler.

- gsm8k.py, kv-accuracy.py: --temperature/--top-p/--top-k, --server-defaults (no
  sampling fields, the server's generation config decides) and --seed-base; not
  greedy, each request carries seed = hash(seed base, item) so a rerun repeats it.
  Records carry temperature/top_p/top_k/server_defaults/seed_base and greedy
  (true / false / null under server defaults). Shared helper bench/sampling_params.py.
- ttx gates: the same as gate options through `ttx run` and `ttx ab`. A sampled
  gsm8k/retrieval verdict is labelled as one stochastic draw to be read paired
  (McNemar against a control at the same settings); a paired control that sampled
  differently is warned about.
- ttx ab: positional A/B passed NO gate options to gate suites, refused gate lists
  (`--suite gsm8k,retrieval` reached suites.run as an unknown suite) and dropped
  --bench-extra for sweep32k. It now passes all three (gate lists through
  gates_shared, which takes card/attach/stagger for ab). ab's --tokens default moves
  from 1024 to None (1024 is applied in the switch mode) so it does not leak into
  equiv's token count.
- serving-bench.py: --server-defaults, --top-p, --top-k; checks.greedy is true only
  for an explicit T=0 and null under server defaults; a `sampling` block.
- sampling-dist-check.py: ref (exact vLLM q from raw top-20 logprobs: temperature,
  top-k with ties kept, softmax, top-p on the ascending cumsum), sample (seeded plus
  an unseeded subset, no logprobs), compare (TV, pooled chi-square, out-of-support
  hard fail, MC null for the median TV, Fisher), and a self-test. A `dec` cell per
  prompt samples the second token from a decode step, because with
  sample_on_device_mode=decode_only the first token is always host-sampled.
  Raw logprobs verified in the vLLM 0.26.0 source.
- batch-equiv-bench.py: --sampled-companions N runs seeded T>0 streams beside the
  T=0 ones, with slot turnover, never captured or compared; threaded as an equiv
  gate option. No card time was spent; no new speed number.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The 2026-10-20 agentic bench ran from ad-hoc scratchpad scripts with hard-coded paths, so
it could not be rerun from a queue. The s-sample validation needs a rerun at the
recommended sampling settings, sent as server defaults. This packages the same prompts,
collector and /metrics diff, opening an ssh tunnel when needed. pi_provider.py sets
what the agents send; omitting --sampling means the server's defaults apply.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
serving: recommended defaults are T=1.0/top_p 0.95/top_k 20/min_p 0; probe fails closed on the device sampler
Some checks failed
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 2m11s
tt-stack-ci / Report upstream drift (pull_request) Successful in 1m34s
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 9m40s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
cards-fresh cards: no verdict yet fp=a48a0540b567a60c
d751206a08
The defaults example said T=0.6. The checkpoint's own generation_config and the model
card's eval setup give T=1.0, top_p 0.95, top_k 20 (min_p 0), and the owner's goal
D-2026-10-20-serve-recommended is set at those values.

Review found that QWEN36_DEVICE_SAMPLE=1 passed evaluation even on a tree without the
sampler. Those requests would then be host-sampled with nothing saying so. The
readiness probe now requires the sampler's "self-test exact" banner whenever the env is
set. The check sits on an existing line, so the default unit (ExecStart and probe)
still evaluates to the same drv as master's.

Also from review: run.sh now always cleans up its tunnel, poller and 8 snapshot copies
via a trap, the collectors survive an empty or missing log, and the stale prompt
template is removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Owner

Cancelled CI run #9708. Its only card work would be S5 vs S5, for tooling paths: no ship decision, and it would hold the mesh ahead of the acc-curve/screen queues. The host-module checks it would have run are unchanged: the default unit drv is identical to master's (dsk2hhfg…), and nix build .#checks.x86_64-linux.tenstorrent-serving passed locally on this branch before the probe hunk (the probe hunk is a no-op at the default). tools/ttx/tests: 678 run, only the pre-existing pytest-import error.

Cancelled CI run #9708. Its only card work would be S5 vs S5, for tooling paths: no ship decision, and it would hold the mesh ahead of the acc-curve/screen queues. The host-module checks it would have run are unchanged: the default unit drv is identical to master's (dsk2hhfg…), and `nix build .#checks.x86_64-linux.tenstorrent-serving` passed locally on this branch before the probe hunk (the probe hunk is a no-op at the default). tools/ttx/tests: 678 run, only the pre-existing pytest-import error.
Owner

verdict: approve
tier: T1 (module + bench/ttx tooling; no production change — deploy is the owner's call)

rationale: Off-by-default, additive. samplingDefaults = null renders the unit script byte-identical to production's (flag inserted inline before --additional-config, empty string when null; the probe's new QWEN36_DEVICE_SAMPLE block is a ''}-joined no-op when the env is unset), so nothing ships on merge. Benches keep the historical argv: sampling_params.py defaults send exactly {"temperature": 0}; all new flags are default-empty with explicit refusals for impossible combinations (--server-defaults + explicit fields, T<0, top_p out of (0,1], top_k < -1). The two new module assertions (non-greedy default needs the device-sampler lever or explicit on-host acceptance; QWEN36_DEVICE_SAMPLE needs mounted prod sources) fail closed and only fire when the owner opts in. The paired-control sampling-mismatch warning and per-record sampling/seed fields are sound; --sampled-companions companions are never captured/compared and a companion error fails the run (correct: it is a server fault). Verified in-kernel on the head tree: 21/30 of the new test_sampling_tooling.py pass; the 9 errors are environmental (my partial scratch tree lacks the patches/prod-local-metal overlay, so A.load(ARM) refuses before any new code runs) — none indicate a defect.

concerns:

  • [warn] tools/ttx/ttxlib/cli.py — ttx ab --tokens default moved 1024 → None (falls back to 1024 in cmd_ab): byte-identical behavior, but it is a shared-tooling default change; keep it deliberate.
  • [warn] Head CI run 9708 was cancelled (the S5-vs-S5 card run "carries no ship decision" per the body), so the full tools/ttx/tests suite (678) has no green run on this head; my in-kernel check of the 30 new tests is the only independent test evidence here.
  • [nit] The VM test asserts the default renders no override but does not cover the positive render path (flag quoting for a non-null samplingDefaults) — the PR body already notes this; a follow-up test when the s-sample4 validation queue lands would close it.
**verdict:** approve **tier:** T1 (module + bench/ttx tooling; no production change — deploy is the owner's call) **rationale:** Off-by-default, additive. `samplingDefaults = null` renders the unit script byte-identical to production's (flag inserted inline before `--additional-config`, empty string when null; the probe's new QWEN36_DEVICE_SAMPLE block is a `''}`-joined no-op when the env is unset), so nothing ships on merge. Benches keep the historical argv: `sampling_params.py` defaults send exactly `{"temperature": 0}`; all new flags are default-empty with explicit refusals for impossible combinations (`--server-defaults` + explicit fields, T<0, top_p out of (0,1], top_k < -1). The two new module assertions (non-greedy default needs the device-sampler lever or explicit on-host acceptance; QWEN36_DEVICE_SAMPLE needs mounted prod sources) fail closed and only fire when the owner opts in. The paired-control sampling-mismatch warning and per-record `sampling`/`seed` fields are sound; `--sampled-companions` companions are never captured/compared and a companion error fails the run (correct: it is a server fault). Verified in-kernel on the head tree: 21/30 of the new `test_sampling_tooling.py` pass; the 9 errors are environmental (my partial scratch tree lacks the `patches/prod-local-metal` overlay, so `A.load(ARM)` refuses before any new code runs) — none indicate a defect. **concerns:** - [warn] `tools/ttx/ttxlib/cli.py` — `ttx ab --tokens` default moved 1024 → None (falls back to 1024 in `cmd_ab`): byte-identical behavior, but it is a shared-tooling default change; keep it deliberate. - [warn] Head CI run 9708 was cancelled (the S5-vs-S5 card run "carries no ship decision" per the body), so the full `tools/ttx/tests` suite (678) has no green run on this head; my in-kernel check of the 30 new tests is the only independent test evidence here. - [nit] The VM test asserts the default renders no override but does not cover the positive render path (flag quoting for a non-null `samplingDefaults`) — the PR body already notes this; a follow-up test when the s-sample4 validation queue lands would close it.
sampling-dist-check: a token tied with the lowest kept one is not a support violation
Some checks failed
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 2m31s
tt-stack-ci / Report upstream drift (pull_request) Successful in 2m33s
cards-fresh cards: queued (fingerprint has no successful verdict on this PR) fp=a48a0540b567a60c
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 4m3s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
bb782620bd
The first card run failed S5's own host sampler. At p08.pos1, three tokens were tied at
the top-p cut and token 70316 was drawn 6/400 times. vLLM's torch.sort is not stable, so
which tied token survives depends on sort order, not on the sampler. Those samples are
now reported as out_of_support_tied. An untied out-of-support token still fails. Re-read
of S5 at T=1.0: PASS, median TV 0.016 (null p99 0.020), Fisher p 0.999.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
sampling-dist-check: --extra-body for per-request server params
Some checks failed
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Has been cancelled
tt-stack-ci / Serialized card gate (pull_request) Has been cancelled
tt-stack-ci / Build simulators and check the host module (pull_request) Has been cancelled
tt-stack-ci / Report upstream drift (pull_request) Has been cancelled
4d5df90106
The exact speculative-sampling rule is selected per request via vllm_xargs
{"tt_spec_rule": ...}. To run the distribution check under each rule on one boot, every
sample request must carry that field. The value is recorded in the samples config.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
sampling-dist-check: --xarg KEY=VALUE, a quote-free vllm_xargs entry
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Successful in 1m18s
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 1m26s
cards-fresh cards: queued (fingerprint has no successful verdict on this PR) fp=a48a0540b567a60c
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 5m13s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
7ae861c4ab
When the sampler runs over ssh inside a queue line, the JSON of --extra-body passes
through two shells and loses its quotes. --xarg tt_spec_rule=exact needs no quoting.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tenstorrent-serving: nixfmt the device-sampler probe check
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Successful in 34s
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 4m32s
tt-stack-ci / Serialized card gate (pull_request) Has been cancelled
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Has been cancelled
c82fc20657
CI runs #9747 and #9751 failed the build job's nixfmt --check on this file. nixfmt 1.4
wants the ${lib.optionalString ...} interpolation broken onto its own lines. The probe
renders byte-identical: readiness probe zkqd36yd... with the device sampler off and
yh5npd12... with it on, before and after.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merge remote-tracking branch 'origin/master' into serve/sampling-defaults
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Has been cancelled
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Has been cancelled
tt-stack-ci / Serialized card gate (pull_request) Has been cancelled
tt-stack-ci / Build simulators and check the host module (pull_request) Has been cancelled
3d572a42e4
Grok force-pushed serve/sampling-defaults from 3d572a42e4
Some checks failed
tt-stack-ci / Report upstream drift (pull_request) Has been cancelled
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Has been cancelled
tt-stack-ci / Serialized card gate (pull_request) Has been cancelled
tt-stack-ci / Build simulators and check the host module (pull_request) Has been cancelled
to eee9a816be
Some checks are pending
cards-fresh cards: queued (fingerprint has no successful verdict on this PR) fp=012723a7054030de
tt-stack-ci / Report upstream drift (pull_request) Successful in 3m35s
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 9m52s
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 21m49s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
cards-fresh / Re-check cards-fresh on open PRs (push) Successful in 23m28s
2026-10-21 13:27:11 +02:00
Compare
Grok merged commit eee9a816be into master 2026-10-21 13:41:38 +02:00
Author
Owner

agent-gateway closeout (merged): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (merged): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!286
No description provided.