Skip to content

fix(cuda server): a request without top_k samples with 0.6.6's 20 - #542

Merged
ashhart merged 1 commit into
ashhart:mainfrom
plotarmordev:fix/cuda-default-top-k
Oct 10, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
plotarmordev:fix/cuda-default-top-k

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

What this changes

On CUDA, a request that leaves out top_k now samples with 20, as 0.6.6's CUDA server did, instead of 0. The CUDA backend declares that default, and the server applies it only when neither the request, the checkpoint's generation config nor --top-k sets one. Metal keeps its behaviour. Fixes #515.

Receipt

  • Environment: one DGX Spark (GB10, CUDA 13), TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit @ d9d758fb. Native arms: the 1.0.2 release archive, main (f8fe17d2) built locally, and this branch built the same way, all three using the release's share/tensorfold/cuda/sm121 kernels. Reference: 0.6.6 (python-0.6 @ ed78d6fc). Every server was started with CUDA 1.0.2: a request without top_k samples with top_k 0, while 0.6.6's CUDA server defaults to 20 #515's flags: --context 16384 --parallel 4 --no-thinking.

  • Exactness: CUDA 1.0.2: a request without top_k samples with top_k 0, while 0.6.6's CUDA server defaults to 20 #515's request (temperature 0.8, top_p 0.95, seed 7, 256 tokens, streamed), sha256 of the reply text, first 12 hex. Each cell was run twice and repeated exactly:

    top_k in the request 0.6.6 1.0.2 release main this branch
    left out 2de9c394629e 376ffb549ad7 376ffb549ad7 2de9c394629e
    0 376ffb549ad7 376ffb549ad7 376ffb549ad7 376ffb549ad7
    20 2de9c394629e 2de9c394629e 2de9c394629e 2de9c394629e

    Only the "left out" cell changes, and it now equals 0.6.6. An explicit top_k: 0 still keeps every token. A second prompt (a short coding request) gave one identical reply in all 12 cells, on all four engines. The startup line now reads sampling: temperature 1.0, top_p 0.95, top_k 20.

  • Decode and prompt speed: not measured. This changes a default sampling setting, not a kernel or a schedule.

  • Tests: zig build test on Linux aarch64 passes 75 of 76. The one failure, direct_io: direct reads return the same bytes as buffered reads, fails the same way on unmodified main in the same environment (Docker on the Spark), so it predates this change.

  • Not run, and why: the server's own unit tests, because they build only on macOS and I have no Mac. A drafted vs "draft": false comparison on this branch, because the change only sets which top_k the sampler receives.

0.6.6's CUDA server also defaulted temperature to 1.0 and top_p to 0.95 when the generation config set neither. I left those out to keep this to #515's case; whether to match them too is your call.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Unchanged: no change to drafting, resume or batching. Not re-measured on this branch.)
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not. (CUDA GB10 only. No Metal: Metal's behaviour is unchanged, since only the CUDA backend declares the default.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new test: the server's tests don't build on Linux. The hash table above is the before/after check.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

On the GB10 the native server took top_k from the checkpoint's generation config and fell back to 0, so a
request that left top_k out sampled differently from 0.6.6, whose CUDA server defaults to 20 (ashhart#515). The CUDA
backend now declares that default; it applies when neither the request, the generation config nor --top-k
sets one. Metal keeps its behaviour.

Fixes ashhart#515
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you @plotarmordev. This is merged into main (118da14): a CUDA request that leaves out top_k samples with 20 again, as 0.6.6 did, while Metal keeps its behaviour. On a GB10 with the merged branch, a seeded sampled request without top_k returned the same text as the same request with top_k: 20. It ships in the next release.

@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

An update, @plotarmordev: we've settled on one top_k default for every backend, and it's none, so 2bc31d6 takes this default back out. A request with no top_k, on a checkpoint whose generation config sets none, keeps every token on CUDA as it does on Metal, and one seeded request draws the same on a Mac and on a GB10. --top-k 20 on the server, or top_k: 20 in the request, gives 0.6.6's CUDA draws. Thank you for the change and the comparison behind it; your commit stays in main's history and the CHANGELOG credits you.

BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 10, 2026
A request that sets no top_k, on a checkpoint whose generation config sets
none, keeps every token on both backends again, so one seeded request draws
the same on a Mac and on a GB10. This takes back ashhart#542's CUDA default of 20;
--top-k 20 or top_k: 20 in the request gives 0.6.6's CUDA draws. RUNBOOK,
CHANGELOG and the 1.0.0 notes say so.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
A request that sets no top_k, on a checkpoint whose generation config sets
none, keeps every token on both backends again, so one seeded request draws
the same on a Mac and on a GB10. This takes back ashhart#542's CUDA default of 20;
--top-k 20 or top_k: 20 in the request gives 0.6.6's CUDA draws. RUNBOOK,
CHANGELOG and the 1.0.0 notes say so.
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.

CUDA 1.0.2: a request without top_k samples with top_k 0, while 0.6.6's CUDA server defaults to 20

2 participants