MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / common_speculative_draft

Function common_speculative_draft

common/speculative.cpp:1078–1108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1076}
1077
1078llama_tokens common_speculative_draft(
1079 common_speculative * spec,
1080 const common_params_speculative & params,
1081 const llama_tokens & prompt_tgt, // specified in target model vocab
1082 llama_token id_last) {
1083 llama_tokens result;
1084
1085 spec->curr_impl = nullptr; // reset current implementation
1086
1087 for (auto & impl : spec->impls) {
1088 {
1089 common_time_meas tm(impl->t_draft_us, !impl->gen_perf);
1090 impl->draft(params, prompt_tgt, id_last, result);
1091 impl->n_call_draft++;
1092 }
1093
1094 if (!result.empty()) {
1095 LOG_DBG("%s: called impl %s, hist size = %zu, call_count = %zu, gen = %zu\n", __func__,
1096 common_speculative_type_to_str(impl.get()->type).c_str(), prompt_tgt.size(),
1097 impl.get()->n_call_draft, result.size());
1098
1099 spec->curr_impl = impl.get(); // set current implementation for stats
1100 impl->n_gen_drafts++;
1101 impl->n_gen_tokens += result.size();
1102
1103 break; // We have a draft, so break out of the loop and return it.
1104 }
1105 }
1106
1107 return result;
1108}
1109
1110void common_speculative_accept(common_speculative * spec, uint16_t n_accepted) {
1111 if (n_accepted == 0) {

Callers 2

update_batchMethod · 0.85
mainFunction · 0.85

Calls 5

draftMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected