// The draft-head ban columns (core/draft_ban.hpp): token ids to subset columns, and the cases that must stay no-ops. #include "strata/core/draft_ban.hpp" #include "strata/core/logit_bias.hpp" #include #include #include int main() { using strata::core::draft_ban_columns; auto check = [](bool ok, const char* what) { if (!ok) { std::fprintf(stderr, "draft_ban_test: %s\n", what); std::exit(1); } }; const int32_t dvocab[] = {3, 7, 1, 9, 5}; // column i drafts token dvocab[i] std::vector bias; std::string err; check(draft_ban_columns(bias, dvocab, 5).empty(), "no bias must mask nothing"); check(draft_ban_columns(bias, nullptr, 0).empty(), "no bias must mask nothing (full head)"); check(strata::core::parse_logit_bias("2:1.5,7:-99.5,9:100", 10, bias, err), "parse finite"); check(draft_ban_columns(bias, dvocab, 5).empty(), "a finite bias must leave the drafter unchanged"); check(draft_ban_columns(bias, nullptr, 0).empty(), "a finite bias must leave the full head unchanged"); check(strata::core::parse_logit_bias("9:-100,0:-100,7:-100,5:2", 10, bias, err), "parse bans"); check(draft_ban_columns(bias, dvocab, 5) == std::vector{1, 3}, "bans map to their subset columns"); check(draft_ban_columns(bias, nullptr, 0) == std::vector{0, 7, 9}, "full head: columns are the ids"); check(strata::core::parse_logit_bias("0:-100,2:-100", 10, bias, err), "parse bans outside the subset"); check(draft_ban_columns(bias, dvocab, 5).empty(), "a ban outside the draft vocabulary masks nothing"); const int32_t odd[] = {-1, 12, 0}; // ids the bias does not cover are never masked check(strata::core::parse_logit_bias("0:-100", 10, bias, err), "parse"); check(draft_ban_columns(bias, odd, 3) == std::vector{2}, "out-of-range subset ids are skipped"); std::puts("draft_ban_test: passed"); }