okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
43b105a75
main
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" ); 19if (!ok )++ g_fail ; 20} 21}// namespace 22 23int main () { 24 std::printf ("draft_kv_plan_test\n" ); 25check (!dkv::split_env_on (nullptr ),"unset is off" ); 26check (!dkv::split_env_on ("" ),"empty is off" ); 27check (!dkv::split_env_on ("0" ),"0 is off" ); 28check (!dkv::split_env_on ("off" ),"text that is not a number is off" ); 29check (dkv::split_env_on ("1" ),"1 is on" ); 30check (dkv::split_env_on ("2" ),"any other whole number is on" ); 31 32for (const bool env : {false, true}) 33for (const bool native : {false, true}) { 34const dkv::Plan p = dkv::plan (true, false,env ,native ); 35check (p .try_batched && p .why == nullptr ,"one GPU: the batched pass is tried, nothing is reported" ); 36 } 37 38 { 39const dkv::Plan p = dkv::plan (true, true, false, true); 40check (!p .try_batched && p .why == nullptr ,"split, variable off: the drafter's own pass, silently" ); 41 } 42 { 43const dkv::Plan p = dkv::plan (true, true, false, false); 44check (!p .try_batched && p .why == nullptr ,"split, variable off, no token table: still silent" ); 45 } 46 { 47const dkv::Plan p = dkv::plan (true, true, true, true); 48check (p .try_batched && p .why == nullptr ,"split, variable on: the batched pass is tried on the last stage" ); 49 } 50 { 51const dkv::Plan p = dkv::plan (true, true, true, false); 52check (!p .try_batched && p .why != nullptr ,"split, variable on, no token table: declined with a reason" ); 53 } 54for (const bool multi : {false, true}) 55for (const bool env : {false, true}) { 56const dkv::Plan p = dkv::plan (false,multi ,env , true); 57check (!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 ); 61return g_fail == 0 ?0 :1 ; 62}