okami.mom/strata

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

Niko1221Merge f-i8-mmqoff-int 70ef6d873 into f-p4-int (the build without llama.cpp's MMQ prompt kernels takes its own kernels by default)6572fbaf1

main
1.7 KiB36 linesraw
1// fp16_rows_rule (include/strata/prefill/fp16_rows_rule.hpp): the tokens the FP16 expert path's buffers are sized for.  No GPU, no model.
2#include <cstdio>
3
4#include "strata/prefill/fp16_rows_rule.hpp"
5
6using strata::prefill::fp16_buf_tokens;
7
8static int failed = 0;
9#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)
10
11int main() {
12    const int64_t floor = 1024;
13    // a fused layout: the tail below the floor only (the same size moe_bufs gives GU / H / Hq), at the floor and above, and a chunk below the floor keeps its own size
14    CHECK(fp16_buf_tokens(8192, true, floor) == 1023);
15    CHECK(fp16_buf_tokens(2048, true, floor) == 1023);
16    CHECK(fp16_buf_tokens(1025, true, floor) == 1023);
17    CHECK(fp16_buf_tokens(1024, true, floor) == 1023);
18    CHECK(fp16_buf_tokens(1023, true, floor) == 1023);
19    CHECK(fp16_buf_tokens(512, true, floor) == 512);
20    CHECK(fp16_buf_tokens(1, true, floor) == 1);
21    // a different floor (STRATA_PREFILL_STREAM_MIN, the CPU share's limit)
22    CHECK(fp16_buf_tokens(8192, true, 2048) == 2047);
23    CHECK(fp16_buf_tokens(2000, true, 2048) == 2000);
24    // no fused layout (the Tesla P100: FP16 from the floor up; STRATA_PF_FUSED=0; a card the fused kernels do not cover): the full chunk at every size
25    CHECK(fp16_buf_tokens(8192, false, floor) == 8192);
26    CHECK(fp16_buf_tokens(2048, false, floor) == 2048);
27    CHECK(fp16_buf_tokens(1024, false, floor) == 1024);
28    CHECK(fp16_buf_tokens(1023, false, floor) == 1023);
29    CHECK(fp16_buf_tokens(64, false, floor) == 64);
30    if (failed) {
31        std::fprintf(stderr, "fp16_rows_rule_test: %d check(s) failed\n", failed);
32        return 1;
33    }
34    std::printf("fp16_rows_rule_test: OK\n");
35    return 0;
36}