MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / common_speculative_init

Function common_speculative_init

smallthinker/common/speculative.cpp:21–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19};
20
21struct common_speculative * common_speculative_init(
22 struct llama_context * ctx_dft) {
23 auto * result = new common_speculative {
24 /* .ctx = */ ctx_dft,
25 /* .smpl = */ nullptr,
26 /* .batch = */ llama_batch_init(llama_n_batch(ctx_dft), 0, 1),
27 /* .prompt = */ {},
28 };
29
30 // TODO: optimize or pass from outside?
31#if 0
32 {
33 common_params_sampling params;
34 params.no_perf = false;
35
36 params.top_k = 40;
37 params.top_p = 0.9;
38
39 params.samplers = {
40 COMMON_SAMPLER_TYPE_TOP_K,
41 COMMON_SAMPLER_TYPE_TOP_P,
42 COMMON_SAMPLER_TYPE_INFILL,
43 };
44
45 result->smpl = common_sampler_init(llama_get_model(ctx_dft), params);
46 }
47#else
48 {
49 common_params_sampling params;
50 params.no_perf = false;
51
52 params.top_k = 10;
53
54 params.samplers = {
55 COMMON_SAMPLER_TYPE_TOP_K,
56 };
57
58 result->smpl = common_sampler_init(llama_get_model(ctx_dft), params);
59 }
60#endif
61
62 return result;
63}
64
65void common_speculative_free(struct common_speculative * spec) {
66 if (spec == nullptr) {

Callers 2

initMethod · 0.85
mainFunction · 0.85

Calls 4

llama_n_batchFunction · 0.85
common_sampler_initFunction · 0.85
llama_batch_initFunction · 0.50
llama_get_modelFunction · 0.50

Tested by

no test coverage detected