Verifier: release a slot's bias allocation when clearing it

This commit is contained in:
shoucandanghehe committed 2026-11-13 17:38:38 +08:00
1 parent 13eedf5524
commit 487dc2cfbf
1 file changed
+6 -1
+6 -1
View File
@@ -4863,7 +4863,12 @@ bool Verifier::set_slot_logit_bias(int slot, const std::vector<float>& 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) {