Simpify some of the changes

This commit is contained in:
Gaurav Garg
2026-07-10 21:48:33 +05:30
parent 3e753aa27d
commit 9c22762603
13 changed files with 120 additions and 119 deletions
+9 -7
View File
@@ -2292,6 +2292,7 @@ common_params common_base_params_to_speculative(const common_params & params) {
result.cache_type_k = params_spec.cache_type_k;
result.cache_type_v = params_spec.cache_type_v;
result.n_outputs_max = params.n_parallel;
result.n_sampling_outputs_per_seq_max = 1;
return result;
}
@@ -2377,14 +2378,15 @@ common_speculative_init_result_ptr common_speculative_init_from_params(common_pa
return std::make_unique<common_speculative_init_result>(params, model_tgt, ctx_tgt);
}
int32_t common_speculative_n_outputs_max(int32_t n_batch, int32_t n_parallel, int32_t n_draft) {
const int64_t n_outputs = (int64_t) n_parallel * (1 + (int64_t) std::max(0, n_draft));
return std::min<int64_t>(n_batch, n_outputs);
}
common_speculative_output_limits common_speculative_get_output_limits(
int32_t n_batch, int32_t n_parallel, int32_t n_draft) {
const int64_t per_seq = 1 + (int64_t) std::max(0, n_draft);
const int64_t total = (int64_t) n_parallel * per_seq;
int32_t common_speculative_n_outputs_per_seq_max(int32_t n_batch, int32_t n_draft) {
const int64_t n_outputs = 1 + (int64_t) std::max(0, n_draft);
return std::min<int64_t>(n_batch, n_outputs);
return {
/* .total = */ (int32_t) std::min<int64_t>(n_batch, total),
/* .per_seq = */ (int32_t) std::min<int64_t>(n_batch, per_seq),
};
}
// initialization of the speculative decoding system