MCPcopy Create free account
hub / github.com/Niko1221/Strata / parse_gen

Function parse_gen

engine/src/split/tools/sfnx.cpp:235–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235GenReq parse_gen(const std::string& line, int vocab, int pad, bool batch, bool images) {
236 std::istringstream is(line);
237 std::string cmd, word;
238 GenReq r;
239 is >> cmd;
240 if (batch) {
241 if (!(is >> word)) throw std::runtime_error(cmd + ": no slot");
242 r.slot = field_int(cmd, "slot", word);
243 }
244 if (!(is >> word)) throw std::runtime_error(cmd + ": no max_new");
245 r.max_new = field_int(cmd, "max_new", word);
246 if (r.max_new < 1) throw std::runtime_error(cmd + ": max_new must be a number >= 1");
247 std::string ids, emb_path;
248 std::vector<uint64_t> img_keys;
249 while (is >> word) {
250 const size_t eq = word.find('=');
251 if (eq == std::string::npos) {
252 if (images && emb_path.empty()) {
253 emb_path = word;
254 continue;
255 }
256 ids = word;
257 break;
258 }
259 const std::string k = word.substr(0, eq), v = word.substr(eq + 1);
260 if (k == "img_keys") {
261 for (const std::string& h : split_commas(v)) img_keys.push_back(field_hex64(cmd, k, h));
262 continue;
263 }
264 if (k == "temperature") r.s.temperature = field_float(cmd, k, v);
265 else if (k == "top_p") r.s.top_p = field_float(cmd, k, v);
266 else if (k == "top_k") r.s.top_k = field_int(cmd, k, v);
267 else if (k == "min_p") r.s.min_p = field_float(cmd, k, v);
268 else if (k == "penalty_repeat") r.s.pen_repeat = field_float(cmd, k, v);
269 else if (k == "penalty_freq") r.s.pen_freq = field_float(cmd, k, v);
270 else if (k == "penalty_present") r.s.pen_present = field_float(cmd, k, v);
271 else if (k == "penalty_last_n") r.s.pen_last_n = field_int(cmd, k, v);
272 else if (k == "seed") { // 0 to 2^64-1; no seed= draws one from std::random_device
273 if (v.empty() || v.size() > 20 || v.find_first_not_of("0123456789") != std::string::npos ||
274 (v.size() == 20 && v > "18446744073709551615"))
275 throw std::runtime_error(cmd + ": seed=" + v + " is not a whole number from 0 to 2^64-1");
276 r.s.seed = std::stoull(v);
277 }
278 else if (k == "logit_bias") throw std::runtime_error(cmd + ": logit_bias is not supported");
279 else if (k == "keep") r.hints.keep = field_int(cmd, k, v);
280 else if (k == "ckpt") {
281 if (v != "0" && v != "1") throw std::runtime_error(cmd + ": ckpt=" + v + " is not 0 or 1");
282 r.hints.cache = v == "1";
283 }
284 else if (k == "pin") { // a client's strata_prefix: sFNX's cache has no pinned checkpoints
285 static bool said = false;
286 if (!said) std::fprintf(stderr, "sfnx: pin= (a client's strata_prefix) is not supported: such requests go on without it\n");
287 said = true;
288 }
289 // Strata's per-request engine tuning (strata_tune) and its control vector: nothing in sFNX to set
290 else if (k == "pcie_frac" || k == "spec_min_p" || k == "pipe" || k == "aux_cpus" || k == "cvec") {
291 static std::set<std::string> said;
292 if (said.insert(k).second)

Callers 1

runMethod · 0.70

Calls 15

field_intFunction · 0.85
field_hex64Function · 0.85
field_floatFunction · 0.85
check_samplingFunction · 0.85
parse_wholeFunction · 0.85
attach_imagesFunction · 0.85
push_backMethod · 0.80
split_commasFunction · 0.70
stringFunction · 0.50
findMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected