okami.mom/strata

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

waveringanaRestore the DeepSeek V4.1 engine and CPU tests removed upstream8ac8ce32e

main
1.8 KiB29 linesraw
1// Strata. Which way the DeepSeek V4.1 engine reads a prompt: the chunked pass (the "flow": each chunk goes through every layer at
2// once, the experts the GPUs do not hold streamed to the GPU once a chunk) or windows of 16 tokens (the CPU lane computes the experts
3// it holds, for every window again).  The choice is the prompt's length against one number, the same on every box and in every session,
4// so a prompt always takes the same path and gives the same bits (the two paths round differently).
5//
6// Why 96.  First prompt of a fresh process, the chunked pass warmed up (the BLAS library's start paid while the user types), r9700
7// 2.00 pack, milliseconds windows / flow:  1 card  28: 1144 / 2252, 100: 3384 / 3922, 300: 9310 / 7281, 600: 17349 / 8165, 1500: 42469 / 10920;
8// 4 cards  28: 585 / 922, 100: 1161 / 1264, 300: 2837 / 1923, 600: 5300 / 2675, 1500: 13353 / 4181 - the crossover is ~120-140 tokens
9// there.  Boxes whose experts come mostly from an SSD or a slower CPU lane cross earlier (P2003 RTX 3060, no warm-up: 28: 3322 / 4063,
10// 100: 8893 / 6817, 300: 26137 / 11417; the owner's RTX 5070 ~100; p620 100: 11839 / 7580), so a box-independent 96 costs the
11// fast-CPU boxes at most 0.5 s on a 100-token prompt and saves the slow ones 2-4 s; 600 tokens and up take the flow everywhere.
12#pragma once
13
14#include <cstdlib>
15
16namespace strata::ds4 {
17
18constexpr int kPromptFlowMin = 96;   // tokens from which a prompt goes through the chunked pass
19
20// env: DS4_PICK_MIN (null: the default)
21inline int prompt_flow_min(const char* env) {
22    if (env == nullptr || *env == 0) return kPromptFlowMin;
23    const int v = std::atoi(env);
24    return v < 1 ? 1 : v;
25}
26
27inline bool prompt_uses_flow(int tokens, int flow_min) { return tokens >= flow_min; }
28
29}  // namespace strata::ds4