[Core] Support load and unload LoRA in api server (#6566)
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
@@ -1224,3 +1224,28 @@ async def _run_task_with_lock(task: Callable, lock: asyncio.Lock, *args,
|
||||
def supports_dynamo() -> bool:
|
||||
base_torch_version = Version(Version(torch.__version__).base_version)
|
||||
return base_torch_version >= Version("2.4.0")
|
||||
|
||||
|
||||
class AtomicCounter:
|
||||
"""An atomic, thread-safe counter"""
|
||||
|
||||
def __init__(self, initial=0):
|
||||
"""Initialize a new atomic counter to given initial value"""
|
||||
self._value = initial
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def inc(self, num=1):
|
||||
"""Atomically increment the counter by num and return the new value"""
|
||||
with self._lock:
|
||||
self._value += num
|
||||
return self._value
|
||||
|
||||
def dec(self, num=1):
|
||||
"""Atomically decrement the counter by num and return the new value"""
|
||||
with self._lock:
|
||||
self._value -= num
|
||||
return self._value
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self._value
|
||||
|
||||
Reference in New Issue
Block a user