Adjust split context for layer (#2054)

This commit is contained in:
Kawrakow 2026-06-29 15:09:40 +02:00 committed by GitHub
parent 843a939441
commit adefdb4b98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -179,13 +179,11 @@ struct create_tensors_helper : public create_tensors_helper_interface {
inline ggml_context * ctx_for_layer(int i) const {
return ctx_map.at(model.buft_layer[i].buft);
}
inline ggml_context * ctx_for_layer_split(int i, bool force_split = false) const {
inline ggml_context * ctx_for_layer_split(int i) const {
const bool is_mtp_layer = model.hparams.nextn_predict_layers > 0 &&
static_cast<uint32_t>(i) >= model.hparams.n_layer - model.hparams.nextn_predict_layers;
if (is_mtp_layer && !force_split && model.arch != LLM_ARCH_GLM4_MOE) {
return ctx_map.at(model.buft_layer[i].buft);
}
return ctx_map.at(model.buft_layer[i].buft_matrix);
const bool mtp_can_use_graph_split = model.arch == LLM_ARCH_GLM4_MOE || model.arch == LLM_ARCH_QWEN35;
return is_mtp_layer && !mtp_can_use_graph_split ? ctx_map.at(model.buft_layer[i].buft) : ctx_map.at(model.buft_layer[i].buft_matrix);
}
std::map<ggml_backend_buffer_type_t, int> buft_layer_count;
@ -1736,7 +1734,7 @@ bool create_tensors_helper::create_qwen35_tensors(const LLM_TN & tn) {
const bool is_mtp_layer = hparams.nextn_predict_layers > 0 &&
static_cast<uint32_t>(i) >= n_layer - hparams.nextn_predict_layers;
ggml_context * ctx_split = ctx_for_layer_split(i, true);
ggml_context * ctx_split = ctx_for_layer_split(i);
int flags = 0;
// Skip loading MTP layers if the feature is disabled