okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-142-mgpu' into f-14243b105a75

main
2.7 KiB62 linesraw
1// src/program/draft_kv_plan_test.cpp - which path computes the draft layer's prompt K/V (header-only, CPU).
2//
3//   1. STRATA_SPLIT_MTP_BATCH: unset, empty, 0 and text that is not a number are off; any other whole number is on;
4//   2. one GPU: the batched pass is tried whatever the variable says (the default before this change);
5//   3. a layer split: the default stays the drafter's own pass, silently; with the variable on the batched pass is
6//      tried, unless the pack has no GGUF-form token table, which is reported instead;
7//   4. no draft layer: nothing is tried and nothing is said.
8#include "strata/program/draft_kv_plan.hpp"
9
10#include <cstdio>
11#include <initializer_list>
12
13namespace dkv = strata::program::draft_kv;
14
15namespace {
16int g_fail = 0;
17void check(bool ok, const char* what) {
18    std::printf("  %-72s %s\n", what, ok ? "ok" : "FAIL");
19    if (!ok) ++g_fail;
20}
21}  // namespace
22
23int main() {
24    std::printf("draft_kv_plan_test\n");
25    check(!dkv::split_env_on(nullptr), "unset is off");
26    check(!dkv::split_env_on(""), "empty is off");
27    check(!dkv::split_env_on("0"), "0 is off");
28    check(!dkv::split_env_on("off"), "text that is not a number is off");
29    check(dkv::split_env_on("1"), "1 is on");
30    check(dkv::split_env_on("2"), "any other whole number is on");
31
32    for (const bool env : {false, true})
33        for (const bool native : {false, true}) {
34            const dkv::Plan p = dkv::plan(true, false, env, native);
35            check(p.try_batched && p.why == nullptr, "one GPU: the batched pass is tried, nothing is reported");
36        }
37
38    {
39        const dkv::Plan p = dkv::plan(true, true, false, true);
40        check(!p.try_batched && p.why == nullptr, "split, variable off: the drafter's own pass, silently");
41    }
42    {
43        const dkv::Plan p = dkv::plan(true, true, false, false);
44        check(!p.try_batched && p.why == nullptr, "split, variable off, no token table: still silent");
45    }
46    {
47        const dkv::Plan p = dkv::plan(true, true, true, true);
48        check(p.try_batched && p.why == nullptr, "split, variable on: the batched pass is tried on the last stage");
49    }
50    {
51        const dkv::Plan p = dkv::plan(true, true, true, false);
52        check(!p.try_batched && p.why != nullptr, "split, variable on, no token table: declined with a reason");
53    }
54    for (const bool multi : {false, true})
55        for (const bool env : {false, true}) {
56            const dkv::Plan p = dkv::plan(false, multi, env, true);
57            check(!p.try_batched && p.why == nullptr, "no draft layer: nothing tried, nothing said");
58        }
59
60    std::printf(g_fail == 0 ? "draft_kv_plan_test: all ok\n" : "draft_kv_plan_test: %d FAILED\n", g_fail);
61    return g_fail == 0 ? 0 : 1;
62}