sample: at eight ranks a rank keeps the candidates the merge can hold

Over a split vocabulary every rank's candidates are gathered and merged in one workgroup
(sample_merge_topk), and libr4d's row holds world_size * n_cand <= 4096 pairs in LDS. The engine
declared the default 1024 a rank, 8192 pairs at eight ranks, and the first step stopped on a shape
the merge does not serve. Declare now narrows the width to 4096 / world_size, 512 at eight ranks,
and says so in one line; a request whose top_k is wider is refused at admission, as a top_k over
the width already was. Two and four ranks keep 1024.

sample_test: at two, four and eight ranks declare succeeds, top_k at the width is admitted and one
more is refused, naming the width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 10:38:33 +02:00
1 parent 279214f520
commit 2c0dd8535e
3 files changed
+52

No files matched your search

+8
View File
@@ -145,6 +145,14 @@ int Sampler::declare(RadBuilder* b, const SamplerConfig& cfg) {
const int64_t rows = rows_for(cfg_);
const int64_t nv = cfg_.n_vocab_local;
if (vocab_parallel() && cfg_.max_candidates * cfg_.world_size > kSampleMergeCandidates) {
const int64_t cap = kSampleMergeCandidates / cfg_.world_size;
RAD_INFO("sampler: candidate width %lld a rank -> %lld: the merge of %d ranks' candidate "
"sets holds %lld pairs at most (top_k above %lld is refused per request)",
(long long)cfg_.max_candidates, (long long)cap, cfg_.world_size,
(long long)kSampleMergeCandidates, (long long)cap);
cfg_.max_candidates = cap;
}
const int64_t ncand = cfg_.max_candidates;
/* ---------------------------------------------------------- buffers */