disable control vector when data == nullptr
use -1 for disabled range (also on init) in case we ever support controlling layer 0 (embeddings)
This commit is contained in:
parent
fc6f042b30
commit
838c99c7d5
1 changed files with 9 additions and 2 deletions
11
llama.cpp
11
llama.cpp
|
@ -1876,8 +1876,8 @@ struct llama_control_vector {
|
|||
std::vector<struct ggml_context *> ctxs;
|
||||
std::vector<ggml_backend_buffer_t> 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue