okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6572fbaf1
main
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 () { 12const 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 14CHECK (fp16_buf_tokens (8192 , true,floor )== 1023 ); 15CHECK (fp16_buf_tokens (2048 , true,floor )== 1023 ); 16CHECK (fp16_buf_tokens (1025 , true,floor )== 1023 ); 17CHECK (fp16_buf_tokens (1024 , true,floor )== 1023 ); 18CHECK (fp16_buf_tokens (1023 , true,floor )== 1023 ); 19CHECK (fp16_buf_tokens (512 , true,floor )== 512 ); 20CHECK (fp16_buf_tokens (1 , true,floor )== 1 ); 21// a different floor (STRATA_PREFILL_STREAM_MIN, the CPU share's limit) 22CHECK (fp16_buf_tokens (8192 , true,2048 )== 2047 ); 23CHECK (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 25CHECK (fp16_buf_tokens (8192 , false,floor )== 8192 ); 26CHECK (fp16_buf_tokens (2048 , false,floor )== 2048 ); 27CHECK (fp16_buf_tokens (1024 , false,floor )== 1024 ); 28CHECK (fp16_buf_tokens (1023 , false,floor )== 1023 ); 29CHECK (fp16_buf_tokens (64 , false,floor )== 64 ); 30if (failed ) { 31 std::fprintf (stderr ,"fp16_rows_rule_test: %d check(s) failed\n" ,failed ); 32return 1 ; 33 } 34 std::printf ("fp16_rows_rule_test: OK\n" ); 35return 0 ; 36}