Archived
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:
1 parent
279214f520
commit
2c0dd8535e
3 files changed
+52
No files matched your search
@@ -197,6 +197,10 @@ int32_t host_argmax(const float* logits, int64_t n_vocab);
|
||||
|
||||
/* The candidate width every stage after top-k works in, SamplerConfig::max_candidates' default. */
|
||||
constexpr int64_t kSampleCandidates = 1024;
|
||||
/* Under a split vocabulary the merge (sample_merge_topk) holds world_size * n_cand gathered pairs
|
||||
* in one workgroup's LDS; libr4d's row serves 4096 at most, so the per-rank width shrinks with
|
||||
* the world (512 at eight ranks). */
|
||||
constexpr int64_t kSampleMergeCandidates = 4096;
|
||||
|
||||
enum class ChainOrder {
|
||||
Radiance = 0, /* penalties, DRY, temperature, mask, top-k, top-p/min-p/typical, XTC, pick */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in new issue
Block a user