okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
01529aaa8
main
1// GENERATED by tests/python/gen_ple_oracle.py - DO NOT EDIT BY HAND. 2// 3// Sources, none of them this project's own code: 4// hash ref/ngram.py::ngram_rows (qwen4exp.cpp L1092-1124, validated bit-exact in round 101) 5// table the ORIGINAL GGUF's bytes, read at the offset the validated gguf_reader reports, 6// dequantized with numpy 7// offsets pack/full/manifest.json 8 9#pragma once 10#include <cstdint> 11 12namespace strata::kernels::ple_oracle { 13 14struct HashCase { const char* name; int n_tokens; const int32_t* tokens; 15 const int32_t* prev; const uint32_t* rows; }; 16 17// window direction 18inline const int32_t case0_tokens[4] = {11, 22, 33, 44}; 19inline const int32_t case0_prev[8] = {-1, -1, 11, -1, 22, 11, 33, 22}; 20inline const uint32_t case0_rows[64] = { 21 13555483, 24877159, 54278900, 63631058, 98394898, 117447587, 136774765, 157274238, 173487882, 192109366, 213364329, 236577563, 258758149, 262164274, 283572184, 312653920, 22 3278367, 29880471, 46922633, 62971672, 94904487, 113013549, 120925297, 159537733, 161636484, 186269036, 207870452, 237789268, 242975733, 269388091, 285131318, 305889870, 23 2485282, 23858032, 54544880, 69506925, 82331991, 106607168, 133019998, 141570514, 173894108, 180423171, 211374553, 239810912, 253076960, 266343146, 290765399, 312876099, 24 12721672, 27113445, 44309803, 60385209, 97021817, 115900810, 134219364, 151977589, 161183764, 181257609, 201344488, 221596875, 241635416, 261674107, 281687144, 301751935, 25}; 26// EOS one back cuts both 27inline const int32_t case1_tokens[3] = {7, 8, 9}; 28inline const int32_t case1_prev[6] = {-1, -1, 7, 248044, 248044, 7}; 29inline const uint32_t case1_rows[48] = { 30 2927653, 34980843, 54748278, 66612378, 97814964, 109013870, 126560393, 151352333, 167888935, 182235580, 215170017, 237467519, 247510681, 278779700, 296141806, 304994522, 31 7508793, 29969020, 54939975, 74089003, 91535754, 104816064, 125484693, 154439441, 164805529, 181662903, 214193203, 238193346, 259492009, 262016223, 296463606, 310742083, 32 5471414, 32902469, 56618078, 65819961, 82278798, 107765152, 125994638, 156967341, 179716672, 187881262, 219224344, 222418510, 250276020, 278493068, 281311927, 316005603, 33}; 34// NULL reads as EOS 35inline const int32_t case2_tokens[2] = {100, 101}; 36inline const int32_t case2_prev[4] = {-1, -1, -1, -1}; 37inline const uint32_t case2_rows[32] = { 38 5727835, 21884476, 43702108, 66434789, 84094509, 104112171, 134886528, 157314943, 162363667, 189466439, 200618315, 232121522, 258547276, 266199001, 289022207, 305180972, 39 14526383, 36975477, 51939184, 65076202, 94510971, 111786935, 138448715, 155393638, 167579692, 181767276, 211184823, 226303266, 246271192, 267465224, 281469089, 313531602, 40}; 41// token id 0 is NOT missing 42inline const int32_t case3_tokens[2] = {100, 101}; 43inline const int32_t case3_prev[4] = {0, 0, 100, 0}; 44inline const uint32_t case3_rows[32] = { 45 223356, 29869136, 44693816, 65450370, 83243562, 109175069, 138072664, 149936704, 175869089, 193667153, 214433731, 233779437, 242682975, 271587098, 294555343, 309396483, 46 9825591, 35767834, 58740777, 62904867, 86476006, 107666813, 129453358, 151836075, 160726459, 190511348, 208596315, 234569026, 259467109, 264365567, 292665383, 314164387, 47}; 48// own EOS does not cut itself 49inline const int32_t case4_tokens[3] = {248044, 5, 248044}; 50inline const int32_t case4_prev[6] = {-1, -1, 248044, -1, 5, 248044}; 51inline const uint32_t case4_rows[48] = { 52 9663979, 26558231, 56120240, 74755659, 80459717, 109265651, 132697467, 151022725, 170054832, 192967038, 200687722, 225763581, 259275737, 272983544, 297596484, 300986548, 53 15389869, 39778609, 55713969, 62213332, 88817728, 118483999, 133731511, 155458159, 179763390, 197956758, 205378969, 220499474, 242466248, 265658744, 293662119, 315720898, 54 9663979, 26558231, 56120240, 74755659, 80459717, 109265651, 132697467, 151022725, 170054832, 192967038, 200687722, 225763581, 259275737, 272983544, 297596484, 300986548, 55}; 56// real vocabulary ids 57inline const int32_t case5_tokens[5] = {248043, 12345, 248043, 7, 200000}; 58inline const int32_t case5_prev[10] = {-1, -1, 248043, -1, 12345, 248043, 248043, 12345, 7, 248043}; 59inline const uint32_t case5_rows[80] = { 60 5224855, 30284709, 43929396, 72280505, 94883662, 109322550, 131203836, 140794991, 166459826, 181131035, 209237474, 226844350, 246236135, 265823742, 299063341, 305586418, 61 11270970, 23825822, 53627731, 75297762, 86108900, 117131242, 124369521, 148669731, 173053968, 186938961, 219076364, 237563026, 246838602, 277288915, 294366759, 301712965, 62 9040325, 23423119, 51729309, 72606490, 88803423, 101106903, 139785146, 145105493, 165075797, 186774126, 216848848, 228384799, 252197080, 276291559, 284385762, 305326936, 63 4918924, 35785322, 51404601, 69479989, 96595301, 119006811, 132661231, 157603286, 167367331, 194295259, 207336314, 231383366, 248222822, 265383752, 291175661, 300670030, 64 19540326, 36155593, 54730668, 61035256, 83860210, 111525643, 123077188, 158579165, 171421264, 181503411, 210257194, 220050508, 255765827, 271545193, 290152687, 303296503, 65}; 66 67inline const HashCase kHashCases[] = { 68 {"window direction", 4, case0_tokens, case0_prev, case0_rows}, 69 {"EOS one back cuts both", 3, case1_tokens, case1_prev, case1_rows}, 70 {"NULL reads as EOS", 2, case2_tokens, case2_prev, case2_rows}, 71 {"token id 0 is NOT missing", 2, case3_tokens, case3_prev, case3_rows}, 72 {"own EOS does not cut itself", 3, case4_tokens, case4_prev, case4_rows}, 73 {"real vocabulary ids", 5, case5_tokens, case5_prev, case5_rows}, 74}; 75inline constexpr int kHashCaseCount = 6; 76 77// The table: sampled values of two rows, plus the whole-row L1 sums so a wrong codebook or a 78// wrong scale cannot hide between the samples. Row 0 and the LAST row. 79inline constexpr uint64_t kTableRows = 320001536ull; 80inline constexpr uint64_t kTableDataStart = 192ull; 81inline constexpr uint64_t kTableFileSize = 28800138432ull; 82inline const uint32_t kProbeRows[] = {0, 12345, 320001535}; 83inline constexpr int kProbeCount = 3; 84inline const float kProbeHead[][8] = { 85 {-1.001119614e-02f, 1.290917397e-02f, -1.817822456e-02f, 1.290917397e-02f, -6.586313248e-03f, 5.795955658e-03f, -6.586313248e-03f, 5.795955658e-03f}, 86 {5.563795567e-03f, -4.314780235e-03f, 3.974139690e-03f, -1.476109028e-03f, -1.135468483e-04f, 1.135468483e-03f, -1.010566950e-02f, -6.017982960e-03f}, 87 {0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f}, 88}; 89inline const float kProbeTail[][8] = { 90 {2.571296692e-02f, 1.607060432e-02f, 3.139948845e-02f, 5.439281464e-03f, -1.705956459e-02f, -3.214120865e-03f, -2.200436592e-02f, 2.472400665e-03f}, 91 {-1.942408085e-02f, 5.811929703e-03f, -9.941458702e-03f, 3.823637962e-03f, -5.353093147e-03f, -1.529455185e-03f, -1.529455185e-03f, -5.353093147e-03f}, 92 {0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f}, 93}; 94inline const double kProbeSum[] = {2.011959553e+00, 9.968549609e-01, 0.000000000e+00}; 95inline constexpr float kInterleavedSeparation = 1.253766603e+00f; 96 97// pack/full/dense.bin regions for the two quantized PLE weights 98inline constexpr uint64_t kKeyCodesOffset = 1017723776ull; 99inline constexpr uint64_t kKeyCodesBytes = 6553600ull; 100inline constexpr uint64_t kKeyScalesOffset = 1024277376ull; 101inline constexpr uint64_t kKeyScalesBytes = 819200ull; 102inline constexpr uint64_t kValueOffset = 1025219456ull; 103inline constexpr uint64_t kValueBytes = 26214400ull; 104 105} // namespace strata::kernels::ple_oracle