[Core] Add generic typing to LRUCache (#3511)
This commit is contained in:
+3
-3
@@ -4,7 +4,7 @@ import logging
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
from typing import (Any, Callable, Dict, Hashable, List, Optional, Tuple, Type)
|
||||
from typing import (Callable, Dict, Hashable, List, Optional, Tuple, Type)
|
||||
|
||||
import safetensors.torch
|
||||
import torch
|
||||
@@ -535,14 +535,14 @@ class LoRAModelManager:
|
||||
replacement_loras)
|
||||
|
||||
|
||||
class LoRALRUCache(LRUCache):
|
||||
class LoRALRUCache(LRUCache[LoRAModel]):
|
||||
|
||||
def __init__(self, capacity: int, deactivate_lora_fn: Callable[[Hashable],
|
||||
None]):
|
||||
super().__init__(capacity)
|
||||
self.deactivate_lora_fn = deactivate_lora_fn
|
||||
|
||||
def _on_remove(self, key: Hashable, value: Any):
|
||||
def _on_remove(self, key: Hashable, value: LoRAModel):
|
||||
logger.debug(f"Removing LoRA. int id: {key}")
|
||||
self.deactivate_lora_fn(key)
|
||||
return super()._on_remove(key, value)
|
||||
|
||||
Reference in New Issue
Block a user