speculative_compat.cpp¶
src/inference/speculative_compat.cpp
@file speculative_compat.cpp @brief Implementation of the target/draft compatibility check.
Owners: @tvanfossen
build_compat_diagnostic
std::string entropic::speculative::anonymous_namespace{speculative_compat.cpp}::build_compat_diagnostic(const llama_model *target, const llama_model *draft)Produce a diagnostic string for the target+draft pair, or empty on full success.
src/inference/speculative_compat.cpp:246
Called by check_compat
Calls check_arch_gate, llama_model_get_vocab, run_vocab_checks
Source · 16 lines
std::string build_compat_diagnostic(
const llama_model* target, const llama_model* draft) {
std::string err;
if (target == nullptr || draft == nullptr) {
err = "null model handle (target or draft)";
} else if (auto d = check_arch_gate(target); d.has_value()) {
err = std::move(*d);
} else {
const llama_vocab* vt = llama_model_get_vocab(target);
const llama_vocab* vd = llama_model_get_vocab(draft);
err = (vt == nullptr || vd == nullptr)
? std::string{"model vocab unavailable (target or draft)"}
: run_vocab_checks(vt, vd);
}
return err;
}Activity · 11 steps
Requirements
check_arch_gate
std::optional< std::string > entropic::speculative::anonymous_namespace{speculative_compat.cpp}::check_arch_gate(const llama_model *target)Refuse speculative pairing for recurrent OR hybrid target architectures.
src/inference/speculative_compat.cpp:59
Called by build_compat_diagnostic
Calls llama_model_is_hybrid, llama_model_is_recurrent
Source · 18 lines
std::optional<std::string> check_arch_gate(
const llama_model* target) {
if (llama_model_is_recurrent(target)) {
return std::string{
"target model is recurrent (Mamba/RWKV) — speculative "
"decoding is incompatible with recurrent architectures "
"at the v2.1.11 llama.cpp pin"};
}
if (llama_model_is_hybrid(target)) {
return std::string{
"target model is hybrid (e.g., QWEN35/QWEN35MOE, "
"NEMOTRON_H, JAMBA, GRANITE_HYBRID) — speculative "
"decoding produces divergent state at split-prefill "
"boundaries on hybrid SSM architectures at the v2.1.11 "
"llama.cpp pin (see proposal Implementation Log, Gate A)"};
}
return std::nullopt;
}Activity · 5 steps
Requirements
check_compat
CompatResult entropic::speculative::check_compat(const llama_model *target, const llama_model *draft)
Check whether a draft model can pair with a target for sequential speculative decoding.
src/inference/speculative_compat.cpp:279
Source · 5 lines
CompatResult check_compat(
const llama_model* target, const llama_model* draft) {
std::string err = build_compat_diagnostic(target, draft);
return CompatResult{err.empty(), std::move(err)};
}