From 9dd5f7d6423693a36d59a01f0bd85701fadf5554 Mon Sep 17 00:00:00 2001 From: MengqingCao Date: Wed, 5 Jun 2024 07:06:40 +0000 Subject: [PATCH 1/4] add npu for model export Former-commit-id: ce020b6eb3f35c1db37ee4835e694eddcd0f59b0 --- src/llamafactory/hparams/model_args.py | 4 ++-- src/llamafactory/webui/components/export.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/llamafactory/hparams/model_args.py b/src/llamafactory/hparams/model_args.py index 7003cbee..99c02850 100644 --- a/src/llamafactory/hparams/model_args.py +++ b/src/llamafactory/hparams/model_args.py @@ -145,9 +145,9 @@ class ModelArguments: default=1, metadata={"help": "The file shard size (in GB) of the exported model."}, ) - export_device: Literal["cpu", "cuda"] = field( + export_device: Literal["cpu", "cuda", "npu"] = field( default="cpu", - metadata={"help": "The device used in model export, use cuda to avoid addmm errors."}, + metadata={"help": "The device used in model export, use cuda to avoid addmm errors; use npu/cuda to speed up exporting."}, ) export_quantization_bit: Optional[int] = field( default=None, diff --git a/src/llamafactory/webui/components/export.py b/src/llamafactory/webui/components/export.py index 2f354011..32bedffb 100644 --- a/src/llamafactory/webui/components/export.py +++ b/src/llamafactory/webui/components/export.py @@ -89,7 +89,7 @@ def create_export_tab(engine: "Engine") -> Dict[str, "Component"]: export_size = gr.Slider(minimum=1, maximum=100, value=1, step=1) export_quantization_bit = gr.Dropdown(choices=["none"] + GPTQ_BITS, value="none") export_quantization_dataset = gr.Textbox(value="data/c4_demo.json") - export_device = gr.Radio(choices=["cpu", "cuda"], value="cpu") + export_device = gr.Radio(choices=["cpu", "cuda", "npu"], value="cpu") export_legacy_format = gr.Checkbox() with gr.Row(): From 8dc19691111b2c6e5d614c4620f0a5c7b61e2b65 Mon Sep 17 00:00:00 2001 From: MengqingCao Date: Wed, 5 Jun 2024 09:37:36 +0000 Subject: [PATCH 2/4] modify export_device option Former-commit-id: b2fc4a5499e21a5b9622c2285402efef6e27a74d --- src/llamafactory/webui/components/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llamafactory/webui/components/export.py b/src/llamafactory/webui/components/export.py index 32bedffb..791a833b 100644 --- a/src/llamafactory/webui/components/export.py +++ b/src/llamafactory/webui/components/export.py @@ -89,7 +89,7 @@ def create_export_tab(engine: "Engine") -> Dict[str, "Component"]: export_size = gr.Slider(minimum=1, maximum=100, value=1, step=1) export_quantization_bit = gr.Dropdown(choices=["none"] + GPTQ_BITS, value="none") export_quantization_dataset = gr.Textbox(value="data/c4_demo.json") - export_device = gr.Radio(choices=["cpu", "cuda", "npu"], value="cpu") + export_device = gr.Radio(choices=["cpu", "cuda/npu"], value="cpu") export_legacy_format = gr.Checkbox() with gr.Row(): From ee5853c5650b5999e96e9918d41a7bdbeb93e8a0 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Thu, 6 Jun 2024 03:14:23 +0800 Subject: [PATCH 3/4] Update model_args.py Former-commit-id: 09c0afd94a8a5f5b45a61b32c983d50e1b9e2941 --- src/llamafactory/hparams/model_args.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llamafactory/hparams/model_args.py b/src/llamafactory/hparams/model_args.py index 99c02850..024bc2f8 100644 --- a/src/llamafactory/hparams/model_args.py +++ b/src/llamafactory/hparams/model_args.py @@ -145,9 +145,9 @@ class ModelArguments: default=1, metadata={"help": "The file shard size (in GB) of the exported model."}, ) - export_device: Literal["cpu", "cuda", "npu"] = field( + export_device: Literal["cpu", "auto"] = field( default="cpu", - metadata={"help": "The device used in model export, use cuda to avoid addmm errors; use npu/cuda to speed up exporting."}, + metadata={"help": "The device used in model export, use `auto` to accelerate exporting."}, ) export_quantization_bit: Optional[int] = field( default=None, From f5b2749ec2ec35b04825ad7bfdf8e2d8c3a46ca7 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Thu, 6 Jun 2024 03:14:46 +0800 Subject: [PATCH 4/4] Update export.py Former-commit-id: 694833c1104d13929d4f181f014a121f25955dc5 --- src/llamafactory/webui/components/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llamafactory/webui/components/export.py b/src/llamafactory/webui/components/export.py index 791a833b..7e1493c8 100644 --- a/src/llamafactory/webui/components/export.py +++ b/src/llamafactory/webui/components/export.py @@ -89,7 +89,7 @@ def create_export_tab(engine: "Engine") -> Dict[str, "Component"]: export_size = gr.Slider(minimum=1, maximum=100, value=1, step=1) export_quantization_bit = gr.Dropdown(choices=["none"] + GPTQ_BITS, value="none") export_quantization_dataset = gr.Textbox(value="data/c4_demo.json") - export_device = gr.Radio(choices=["cpu", "cuda/npu"], value="cpu") + export_device = gr.Radio(choices=["cpu", "auto"], value="cpu") export_legacy_format = gr.Checkbox() with gr.Row():