From 487dc2cfbfb4037a113175528601d666f93ee9f5 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Thu, 5 Nov 2026 21:52:48 +0800 Subject: [PATCH] Verifier: release a slot's bias allocation when clearing it --- src/core/verify.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/verify.cpp b/src/core/verify.cpp index 61b32ded8b..8b30391cb1 100644 --- a/src/core/verify.cpp +++ b/src/core/verify.cpp @@ -4863,7 +4863,12 @@ bool Verifier::set_slot_logit_bias(int slot, const std::vector& bias, std if (le_ >= 0 && le_ < g_->n_layers) return true; if (slot < 0 || slot >= (int) slot_bias_dev_.size()) return true; const OnDevice on_device(device_); - if (bias.empty()) { slot_bias_dev_[(size_t) slot] = nullptr; slot_sp_[(size_t) slot].logit_bias = nullptr; return true; } + if (bias.empty()) { + if (slot_bias_dev_[(size_t) slot]) cudaFree(slot_bias_dev_[(size_t) slot]); + slot_bias_dev_[(size_t) slot] = nullptr; + slot_sp_[(size_t) slot].logit_bias = nullptr; + return true; + } if (bias.size() != (size_t) n_vocab_) { err = "logit_bias vocabulary size mismatch"; return false; } const size_t bytes = bias.size() * sizeof(float); if (slot_bias_dev_[(size_t) slot] == nullptr) {