mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-10 23:09:24 +02:00
llama : support multi-output backend sampling (#25532)
* Enable backend sampling with token speculation * Clamp the mask sum before converting it into the sampled index * Add a numeric context parameter declaring the maximum outputs one sequence * More fixes * Don't reuse memory for output views. * Match dist between CPU and GPU * Fix CPU and backend sampling mismatches * Simpify some of the changes * Fix tests on Vulkan * More test fixes * Rebase changes * Rebase and address review comments * Address review comments * Address review comments * Update src/llama-sampler.cpp Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
#include "common.h"
|
||||
#include "download.h"
|
||||
#include "llama.h"
|
||||
#include "speculative.h"
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
@@ -14,6 +16,34 @@
|
||||
static void test(void) {
|
||||
common_params params;
|
||||
|
||||
auto assert_output_limits = [](int32_t n_batch, int32_t n_parallel, int32_t n_draft,
|
||||
int32_t total, int32_t per_seq) {
|
||||
const auto limits = common_speculative_get_output_limits(n_batch, n_parallel, n_draft);
|
||||
assert(limits.total == total);
|
||||
assert(limits.per_seq == per_seq);
|
||||
};
|
||||
|
||||
assert_output_limits(16, 2, 3, 8, 4);
|
||||
assert_output_limits(16, 2, -1, 2, 1);
|
||||
assert_output_limits( 6, 2, 3, 6, 4);
|
||||
assert_output_limits( 2, 1, 3, 2, 2);
|
||||
assert_output_limits(
|
||||
std::numeric_limits<int32_t>::max(),
|
||||
std::numeric_limits<int32_t>::max(),
|
||||
std::numeric_limits<int32_t>::max(),
|
||||
std::numeric_limits<int32_t>::max(),
|
||||
std::numeric_limits<int32_t>::max());
|
||||
|
||||
{
|
||||
common_params base;
|
||||
base.n_parallel = 4;
|
||||
base.n_outputs_max_per_seq = 8;
|
||||
|
||||
const auto draft = common_base_params_to_speculative(base);
|
||||
assert(draft.n_outputs_max == 4);
|
||||
assert(draft.n_outputs_max_per_seq == 1);
|
||||
}
|
||||
|
||||
printf("test-arg-parser: make sure there is no duplicated arguments in any examples\n\n");
|
||||
for (int ex = 0; ex < LLAMA_EXAMPLE_COUNT; ex++) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user