diff --git a/llama.cpp b/llama.cpp index 09ff01b0b..ffac0e4ca 100644 --- a/llama.cpp +++ b/llama.cpp @@ -1876,8 +1876,8 @@ struct llama_control_vector { std::vector ctxs; std::vector bufs; - int32_t layer_start = 0; - int32_t layer_end = 0; + int32_t layer_start = -1; + int32_t layer_end = -1; ggml_tensor * tensor_for(int il) const { if (il < 0 || il < layer_start || il > layer_end || (size_t) il >= tensors.size()) { @@ -13343,6 +13343,13 @@ int32_t llama_control_vector_apply(struct llama_context * lctx, const float * da const llama_model & model = lctx->model; llama_control_vector & cvec = lctx->cvec; + if (data == nullptr) { + // disable the current control vector (but leave allocated for later) + cvec.layer_start = -1; + cvec.layer_end = -1; + return 0; + } + if (n_embd != (int) model.hparams.n_embd) { LLAMA_LOG_ERROR("%s: control vector n_embd does not match model\n", __func__); return 1;