mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2025-09-09 13:55:27 +00:00
Move KV cache creation to balance_serve
This commit is contained in:
parent
8770b6d573
commit
38e841900d
2 changed files with 45 additions and 38 deletions
|
@ -5,7 +5,6 @@ from fastapi.staticfiles import StaticFiles
|
|||
import uvicorn.logging
|
||||
import uvicorn
|
||||
import sys
|
||||
import atexit
|
||||
project_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from ktransformers.server.args import ArgumentParser
|
||||
|
@ -17,8 +16,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||
from ktransformers.server.api import router, post_db_creation_operations
|
||||
from ktransformers.server.utils.sql_utils import Base, SQLUtil
|
||||
from ktransformers.server.config.log import logger
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def mount_app_routes(mount_app: FastAPI):
|
||||
sql_util = SQLUtil()
|
||||
|
@ -108,27 +106,6 @@ def main():
|
|||
arg_parser = ArgumentParser(cfg)
|
||||
|
||||
args = arg_parser.parse_args()
|
||||
if args.backend_type == "balance_serve":
|
||||
import pickle
|
||||
def cleanup():
|
||||
if sched_process.poll() is None:
|
||||
sched_process.terminate()
|
||||
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
pickle.dump(args, temp_file)
|
||||
temp_file_path = temp_file.name
|
||||
current_file = __file__
|
||||
target_file = os.path.join(os.path.dirname(current_file), "balance_serve", "sched_rpc.py")
|
||||
target_file = os.path.normpath(target_file)
|
||||
log_path = os.path.join(args.log_dir, "rpc.log")
|
||||
log = open(log_path, "a")
|
||||
sched_process = subprocess.Popen(
|
||||
["python3", target_file, "--config", temp_file_path],
|
||||
stdout=log,
|
||||
stderr=log
|
||||
)
|
||||
print("sched_rpc started with PID:", sched_process.pid)
|
||||
atexit.register(cleanup)
|
||||
create_interface(config=cfg, default_args=cfg)
|
||||
app = create_app()
|
||||
custom_openapi(app)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue