MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / set_feature_range

Method set_feature_range

server/src/common/dflash_draft_ipc.cpp:316–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314 start_pos < 0 || n_tokens <= 0 || n_tokens > ring_cap_) return false;
315 const size_t count =
316 (size_t)n_tokens * (size_t)n_target_layers_ * (size_t)hidden_size_;
317 std::fprintf(cmd, "get_feature_range %d %d\n", start_pos, n_tokens);
318 std::fflush(cmd);
319 int32_t status = -1;
320 bool ok = read_exact_fd(stream_fd, &status, sizeof(status)) && status == 0;
321 if (ok) {
322 out.assign(count, 0.0f);
323 ok = read_exact_fd(stream_fd, out.data(), out.size() * sizeof(float));
324 }
325 if (!ok) {
326 std::fprintf(stderr, "draft-ipc get_feature_range failed status=%d\n", status);
327 }
328 return ok;
329#endif
330}
331
332bool DFlashDraftIpcClient::set_feature_range(int start_pos, int n_tokens,
333 const std::vector<float> & data) {
334#if defined(_WIN32)
335 (void)start_pos; (void)n_tokens; (void)data;
336 return false;
337#else
338 FILE * cmd = process_.command_stream();
339 const int stream_fd = process_.stream_fd();
340 if (!active_ || !cmd || stream_fd < 0 || ring_cap_ <= 0 ||
341 start_pos < 0 || n_tokens <= 0 || n_tokens > ring_cap_) return false;
342 const size_t expected =
343 (size_t)n_tokens * (size_t)n_target_layers_ * (size_t)hidden_size_;
344 if (data.size() != expected) return false;
345 const std::string path = process_.next_path("feature_range");
346 if (!write_binary_file(path, data.data(), data.size() * sizeof(float))) {
347 std::fprintf(stderr, "draft-ipc write feature range failed: %s\n", path.c_str());
348 return false;

Callers 1

Calls 7

write_binary_fileFunction · 0.85
read_exact_fdFunction · 0.85
next_pathMethod · 0.80
command_streamMethod · 0.45
stream_fdMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected