From fd596314fd95276b061fb58009bcbcddc1d9db6f Mon Sep 17 00:00:00 2001 From: Jake Chavis Date: Mon, 2 Feb 2026 20:45:06 -0500 Subject: [PATCH] fix: only reset LoRa configs when they have changed from previous batch --- tools/server/server-context.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/server/server-context.cpp b/tools/server/server-context.cpp index 7f9c3c566b..9ea614fe96 100644 --- a/tools/server/server-context.cpp +++ b/tools/server/server-context.cpp @@ -136,6 +136,7 @@ struct server_slot { } std::vector lora; + std::vector previous_lora; int32_t alora_invocation_start = -1; // sampling @@ -191,6 +192,9 @@ struct server_slot { // clear alora start alora_invocation_start = -1; + + lora.clear(); + previous_lora.clear(); } void init_sampler() const { @@ -2576,8 +2580,11 @@ struct server_context_impl { SRV_DBG("decoding batch, n_tokens = %d\n", batch.n_tokens); if (slot_batched) { - // apply lora, only need to do it once per batch - common_set_adapter_lora(ctx, slot_batched->lora); + if (!are_lora_equal(slot_batched->previous_lora, slot_batched->lora)) { + // apply lora, only need to do it once per batch + common_set_adapter_lora(ctx, slot_batched->lora); + slot_batched->previous_lora = slot_batched->lora; + } // if the lora is temporarily disabled for an alora, re-enable it // for next time