From a148da2cfe4706745147de1e315972a19408f6ec Mon Sep 17 00:00:00 2001 From: liam Date: Thu, 31 Oct 2024 21:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8:=20rm=20sensitive=20info=20in=20confi?= =?UTF-8?q?g.yaml,=20add=20readme=20of=20makefile.=20support=20old=20model?= =?UTF-8?q?=5Fpath=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- README.md | 2 +- doc/en/makefile_usage.md | 26 ++++++++++++++++++++++++++ ktransformers/configs/config.yaml | 2 -- ktransformers/server/args.py | 13 ++++++++++++- ktransformers/server/config/config.py | 2 ++ 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 doc/en/makefile_usage.md diff --git a/.gitignore b/.gitignore index 1bb8666..c33a95d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ compile_commands.json *dist/ ktransformers/server/local_store/ ktransformers/server_test1.db -*.patch \ No newline at end of file +*.patch +img/ \ No newline at end of file diff --git a/README.md b/README.md index 2147485..5f82118 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ Some preparation: ``` install.bat ``` - +4. If you are developer, you can make use of the makefile to compile and format the code.
the detailed usage of makefile is [here](./doc/en/makefile_usage.md)

Local Chat

We provide a simple command-line local chat Python script that you can run for testing. diff --git a/doc/en/makefile_usage.md b/doc/en/makefile_usage.md new file mode 100644 index 0000000..599173b --- /dev/null +++ b/doc/en/makefile_usage.md @@ -0,0 +1,26 @@ +# Makefile +## Target +### flake_find: +```bash +make flake_find +``` +find all the python files under ./ktransformers dir and find the Error, Warning, Fatal... (their codes) into a list that are not consistent with the pep8 standard. For now we have get all this list in the .flake8 file's extend-ignore section in order to let flakes8 ignore them temporarily.(we may improve them in the future) +### format: +```bash +make format +``` +we use black to format all the python files under ./ktransformers dir. It obeys the pep8 standard +but we modify the line length to 120 by add +```toml +[tool.black] +line-length = 120 +preview = true +unstable = true +``` +in the pyproject.toml file. + +### dev_install: +```bash +make dev_install +``` +install the package in the development mode. It means that the package is installed in the editable mode. So if you modify the code, you don't need to reinstall the package. We recommend the developer to use this method to install the package. \ No newline at end of file diff --git a/ktransformers/configs/config.yaml b/ktransformers/configs/config.yaml index f6f6776..7bde376 100644 --- a/ktransformers/configs/config.yaml +++ b/ktransformers/configs/config.yaml @@ -24,9 +24,7 @@ model: type: ktransformers name: DeepSeek-Coder-V2-Instruct - # path: /mnt/data/model/DeepSeek-Coder-V2-Instruct/ path: deepseek-ai/DeepSeek-V2-Lite-Chat - # gguf_path: /mnt/data/model/DeepSeek-Coder-V2-GGUF-WJH/ gguf_path: ./DeepSeek-V2-Lite-Chat-GGUF device: cuda:0 diff --git a/ktransformers/server/args.py b/ktransformers/server/args.py index 61b88e7..5c0bb03 100644 --- a/ktransformers/server/args.py +++ b/ktransformers/server/args.py @@ -14,7 +14,8 @@ class ArgumentParser: parser.add_argument("--ssl_certfile", type=str) parser.add_argument("--web", type=bool, default=self.cfg.mount_web) parser.add_argument("--model_name", type=str, default=self.cfg.model_name) - parser.add_argument("--model_dir", type=str, default=self.cfg.model_dir) + parser.add_argument("--model_dir", type=str) + parser.add_argument("--model_path", type=str) parser.add_argument( "--device", type=str, default=self.cfg.model_device, help="Warning: Abandoning this parameter" ) @@ -100,6 +101,16 @@ class ArgumentParser: parser.add_argument("--prompt_file", type=str, default=self.cfg.prompt_file) args = parser.parse_args() + if (args.model_dir is not None): + if (args.model_path is not None): + # if pass model_dir and model_path, we use model_path + args.model_dir = args.model_path + else: + # if only pass model_dir, we use model_dir + args.model_path = args.model_dir + else: + args.model_dir = self.cfg.model_dir + args.model_path = self.cfg.model_path # set config from args for key, value in vars(args).items(): if value is not None and hasattr(self.cfg, key): diff --git a/ktransformers/server/config/config.py b/ktransformers/server/config/config.py index 3b38b1e..850b6db 100644 --- a/ktransformers/server/config/config.py +++ b/ktransformers/server/config/config.py @@ -88,6 +88,8 @@ class Config(metaclass=Singleton): self.model: dict = cfg.get("model", {}) self.backend_type: str = self.model.get("type", "transformers") self.model_dir: str = self.model.get("path", "") + # to make sure it consistent with previous version + self.model_path: str = self.model_dir self.model_name: str = self.model.get("name", "") self.model_device: str = self.model.get("device", "cuda:0") self.gguf_path: Optional[str] = self.model.get("gguf_path", None)