fix: 修复异常处理问题
This commit is contained in:
@@ -68,6 +68,9 @@ def apply_sampling_strategies(
|
||||
filter_value: float = -float("inf"),
|
||||
) -> Tensor:
|
||||
"""Apply sampling strategies to the logits tensor."""
|
||||
# Clone logits to avoid inplace updates on inference tensor
|
||||
logits = logits.clone()
|
||||
|
||||
if temperature != 1.0:
|
||||
logits = logits / temperature
|
||||
|
||||
@@ -377,6 +380,21 @@ class InferenceScheduler:
|
||||
self._running = False
|
||||
if hasattr(self, "_loop_thread"):
|
||||
self._loop_thread.join(timeout=1.0)
|
||||
|
||||
# Clear KV cache to free GPU memory
|
||||
if self.kv_cache is not None:
|
||||
k_cache, v_cache = self.kv_cache
|
||||
if k_cache is not None:
|
||||
k_cache.detach()
|
||||
if v_cache is not None:
|
||||
v_cache.detach()
|
||||
|
||||
# Clear seq mask
|
||||
self.seq_mask.detach()
|
||||
|
||||
# Clear task lists
|
||||
self.waiting_queue.clear()
|
||||
self.active_tasks.clear()
|
||||
|
||||
def get_stats(self) -> Dict[str, Any]:
|
||||
"""Get scheduler statistics."""
|
||||
|
||||
Reference in New Issue
Block a user