diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7564c8ba6..e7fe1519d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -55,11 +55,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Get llamafactory version id: version run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c3f729a08..7c8a1e433 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,10 +23,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v7 with: - python-version: "3.9" + python-version: "3.11" + github-token: ${{ github.token }} - name: Build package run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 089778ccb..036ff744e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,24 +63,23 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v7 with: python-version: ${{ matrix.python }} - - - name: Install uv - uses: astral-sh/setup-uv@v5 + github-token: ${{ github.token }} + enable-cache: false - name: Install dependencies run: | - uv pip install --system torch torchvision --index-url https://download.pytorch.org/whl/cpu - uv pip install --system -e "." - uv pip install --system -r examples/requirements/dev.txt + uv venv + uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + uv pip install -e ".[dev]" - name: Install transformers if: ${{ matrix.transformers }} run: | - uv pip install --system "transformers==${{ matrix.transformers }}" + uv pip install "transformers==${{ matrix.transformers }}" - name: Cache files id: hf-hub-cache @@ -92,18 +91,25 @@ jobs: - name: Check quality run: | make style && make quality + env: + UV_NO_SYNC: 1 - name: Check license run: | make license + env: + UV_NO_SYNC: 1 - name: Check build run: | make build + env: + UV_NO_SYNC: 1 - name: Test with pytest run: | make test env: + UV_NO_SYNC: 1 HF_HOME: ${{ runner.temp }}/huggingface HF_HUB_OFFLINE: "${{ steps.hf-hub-cache.outputs.cache-hit == 'true' && '1' || '0' }}" diff --git a/.github/workflows/tests_npu.yml b/.github/workflows/tests_npu.yml index 71f2299ea..1f178ec7d 100644 --- a/.github/workflows/tests_npu.yml +++ b/.github/workflows/tests_npu.yml @@ -54,8 +54,9 @@ jobs: - name: Install dependencies run: | - uv pip install --system -e "." torch-npu==${{matrix.pytorch_npu}} - uv pip install --system -r examples/requirements/dev.txt + uv venv + uv pip install torch-npu==${{matrix.pytorch_npu}} + uv pip install -e ".[dev]" - name: Install node run: | @@ -74,18 +75,25 @@ jobs: - name: Check quality run: | make style && make quality + env: + UV_NO_SYNC: 1 - name: Check license run: | make license + env: + UV_NO_SYNC: 1 - name: Check build run: | make build + env: + UV_NO_SYNC: 1 - name: Test with pytest run: | make test env: + UV_NO_SYNC: 1 HF_HOME: /root/.cache/huggingface HF_HUB_OFFLINE: "${{ steps.hf-hub-cache.outputs.cache-hit == 'true' && '1' || '0' }}" diff --git a/Makefile b/Makefile index 4c3a3216d..509718637 100644 --- a/Makefile +++ b/Makefile @@ -2,23 +2,27 @@ check_dirs := scripts src tests tests_v1 +RUN := $(shell command -v uv >/dev/null 2>&1 && echo "uv run" || echo "") +BUILD := $(shell command -v uv >/dev/null 2>&1 && echo "uv build" || echo "python -m build") +TOOL := $(shell command -v uv >/dev/null 2>&1 && echo "uvx" || echo "") + build: - uv build + $(BUILD) commit: - uv run pre-commit install - uv run pre-commit run --all-files + $(TOOL) pre-commit install + $(TOOL) pre-commit run --all-files license: - uv run python tests/check_license.py $(check_dirs) + $(RUN) python3 tests/check_license.py $(check_dirs) quality: - uv run ruff check $(check_dirs) - uv run ruff format --check $(check_dirs) + $(TOOL) ruff check $(check_dirs) + $(TOOL) ruff format --check $(check_dirs) style: - uv run ruff check $(check_dirs) --fix - uv run ruff format $(check_dirs) + $(TOOL) ruff check $(check_dirs) --fix + $(TOOL) ruff format $(check_dirs) test: - WANDB_DISABLED=true uv run pytest -vv --import-mode=importlib tests/ tests_v1/ + WANDB_DISABLED=true $(RUN) pytest -vv --import-mode=importlib tests/ tests_v1/ diff --git a/README.md b/README.md index 919cb2061..865eb43ea 100644 --- a/README.md +++ b/README.md @@ -514,7 +514,7 @@ huggingface-cli login ```bash git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git cd LLaMA-Factory -pip install -e "." --no-build-isolation +pip install -e ".[metrics]" --no-build-isolation ``` Optional dependencies available: `metrics`, `deepspeed`. Install with: `pip install -e ".[metrics,deepspeed]"` @@ -538,13 +538,7 @@ Please refer to [build docker](#build-docker) to build the image yourself. Create an isolated Python environment with [uv](https://github.com/astral-sh/uv): ```bash -uv sync --extra torch --extra metrics --prerelease=allow -``` - -Run LLaMA-Factory in the isolated environment: - -```bash -uv run --prerelease=allow llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yaml +uv run llamafactory-cli webui ``` @@ -581,7 +575,7 @@ To enable FlashAttention-2 on the Windows platform, please use the script from [
For Ascend NPU users -To install LLaMA Factory on Ascend NPU devices, please upgrade Python to version 3.10 or higher: `pip install -e "."`. Additionally, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. Please follow the [installation tutorial](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/600alphaX/softwareinstall/instg/atlasdeploy_03_0031.html) or use the following commands: +To install LLaMA Factory on Ascend NPU devices, please upgrade Python to version 3.10 or higher: `pip install -e . torch-npu==2.7.1`. Additionally, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. Please follow the [installation tutorial](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/600alphaX/softwareinstall/instg/atlasdeploy_03_0031.html) or use the following commands: ```bash # replace the url according to your CANN version and devices @@ -600,8 +594,8 @@ source /usr/local/Ascend/ascend-toolkit/set_env.sh | Requirement | Minimum | Recommend | | ------------ | ------- | -------------- | | CANN | 8.0.RC1 | 8.0.0.alpha002 | -| torch | 2.1.0 | 2.4.0 | -| torch-npu | 2.1.0 | 2.4.0.post2 | +| torch | 2.1.0 | 2.7.1 | +| torch-npu | 2.1.0 | 2.7.1 | | deepspeed | 0.13.2 | 0.13.2 | | vllm-ascend | - | 0.7.3 | diff --git a/README_zh.md b/README_zh.md index 7995c88ce..5521f440a 100644 --- a/README_zh.md +++ b/README_zh.md @@ -516,10 +516,12 @@ huggingface-cli login ```bash git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git cd LLaMA-Factory -pip install -e ".[torch,metrics]" --no-build-isolation +pip install -e ".[metrics]" --no-build-isolation ``` -可选的额外依赖项:torch、torch-npu、metrics、deepspeed、liger-kernel、bitsandbytes、hqq、eetq、gptq、aqlm、vllm、sglang、galore、apollo、badam、adam-mini、qwen、minicpm_v、openmind、swanlab、dev +可选的额外依赖项:`metrics`、`deepspeed`。使用 `pip install -e ".[metrics,deepspeed]"` 安装。 + +其他可选依赖项请参考 `examples/requirements/` 目录下的文件。 #### 从镜像安装 @@ -538,13 +540,7 @@ docker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest 使用 [uv](https://github.com/astral-sh/uv) 创建隔离的 Python 环境: ```bash -uv sync --extra torch --extra metrics --prerelease=allow -``` - -在环境中运行 LLaMA-Factory: - -```bash -uv run --prerelease=allow llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yaml +uv run llamafactory-cli webui ```
@@ -581,7 +577,7 @@ pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/downl
昇腾 NPU 用户指南 -在昇腾 NPU 设备上安装 LLaMA Factory 时,请升级 Python 到 3.10 及以上,并需要指定额外依赖项,使用 `pip install -e ".[torch-npu,metrics]"` 命令安装。此外,还需要安装 **[Ascend CANN Toolkit 与 Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**,安装方法请参考[安装教程](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/quickstart/quickstart/quickstart_18_0004.html)或使用以下命令: +在昇腾 NPU 设备上安装 LLaMA Factory 时,请升级 Python 到 3.10 及以上,并需要指定额外依赖项,使用 `pip install -e . torch-npu==2.7.1` 命令安装。此外,还需要安装 **[Ascend CANN Toolkit 与 Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**,安装方法请参考[安装教程](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/quickstart/quickstart/quickstart_18_0004.html)或使用以下命令: ```bash # 请替换 URL 为 CANN 版本和设备型号对应的 URL @@ -600,8 +596,8 @@ source /usr/local/Ascend/ascend-toolkit/set_env.sh | 依赖项 | 至少 | 推荐 | | ------------ | ------- | -------------- | | CANN | 8.0.RC1 | 8.0.0.alpha002 | -| torch | 2.1.0 | 2.4.0 | -| torch-npu | 2.1.0 | 2.4.0.post2 | +| torch | 2.1.0 | 2.7.1 | +| torch-npu | 2.1.0 | 2.7.1 | | deepspeed | 0.13.2 | 0.13.2 | | vllm-ascend | - | 0.7.3 | diff --git a/docker/docker-cuda/Dockerfile b/docker/docker-cuda/Dockerfile index 94184e791..b70ad5b50 100644 --- a/docker/docker-cuda/Dockerfile +++ b/docker/docker-cuda/Dockerfile @@ -26,13 +26,13 @@ WORKDIR /app # Change pip source RUN pip config set global.index-url "${PIP_INDEX}" && \ pip config set global.extra-index-url "${PIP_INDEX}" && \ - pip install --no-cache-dir --upgrade pip packaging wheel setuptools "hatchling>=1.18.0" editables + pip install --no-cache-dir --upgrade pip packaging wheel setuptools editables "hatchling>=1.18.0" # Copy the application into the image COPY . /app # Install LLaMA Factory -RUN pip install --no-cache-dir -e "." --no-build-isolation +RUN pip install --no-cache-dir --no-build-isolation -e ".[metrics,deepspeed]" # Rebuild flash attention RUN if [ "${INSTALL_FLASHATTN}" == "true" ]; then \ diff --git a/docker/docker-cuda/Dockerfile.megatron b/docker/docker-cuda/Dockerfile.megatron index ee6913192..7f457fefd 100644 --- a/docker/docker-cuda/Dockerfile.megatron +++ b/docker/docker-cuda/Dockerfile.megatron @@ -60,7 +60,7 @@ WORKDIR /app COPY . /app # Install LLaMA Factory -RUN pip install --no-cache-dir -e "." --no-build-isolation +RUN pip install --no-cache-dir -e ".[metrics]" --no-build-isolation RUN pip install "git+https://github.com/alibaba/roll.git#subdirectory=mcore_adapter" diff --git a/docker/docker-cuda/docker-compose.yml b/docker/docker-cuda/docker-compose.yml index ab0da4d87..eb4250ce6 100644 --- a/docker/docker-cuda/docker-compose.yml +++ b/docker/docker-cuda/docker-compose.yml @@ -5,7 +5,6 @@ services: context: ../.. args: PIP_INDEX: https://pypi.org/simple - EXTRAS: metrics container_name: llamafactory ports: - "7860:7860" diff --git a/docker/docker-npu/Dockerfile b/docker/docker-npu/Dockerfile index 95da49715..d3c7acbaa 100644 --- a/docker/docker-npu/Dockerfile +++ b/docker/docker-npu/Dockerfile @@ -27,17 +27,15 @@ WORKDIR /app # Change pip source RUN pip config set global.index-url "${PIP_INDEX}" && \ pip config set global.extra-index-url "${PIP_INDEX}" && \ - pip install --no-cache-dir --upgrade pip packaging wheel setuptools "hatchling>=1.18.0" editables - -# Install torch-npu -RUN pip uninstall -y torch torchvision torchaudio && \ - pip install --no-cache-dir "torch==2.7.1" "torch-npu==2.7.1" "torchvision==0.22.1" --index-url "${PYTORCH_INDEX}" + pip install --no-cache-dir --upgrade pip packaging wheel setuptools editables "hatchling>=1.18.0" # Copy the application into the image COPY . /app -# Install LLaMA Factory -RUN pip install --no-cache-dir -e "." --no-build-isolation +# Install torch-npu +RUN pip uninstall -y torch torchvision torchaudio && \ + pip install --no-cache-dir "torch==2.7.1" "torch-npu==2.7.1" "torchvision==0.22.1" "torchaudio==2.7.1" --index-url "${PYTORCH_INDEX}" && \ + pip install --no-cache-dir -e ".[metrics]" --no-build-isolation # Set up volumes # VOLUME [ "/root/.cache/huggingface", "/app/shared_data", "/app/output" ] diff --git a/docker/docker-npu/docker-compose.yml b/docker/docker-npu/docker-compose.yml index 8530efafd..8ef8ddd3b 100644 --- a/docker/docker-npu/docker-compose.yml +++ b/docker/docker-npu/docker-compose.yml @@ -5,7 +5,6 @@ services: context: ../.. args: PIP_INDEX: https://pypi.org/simple - EXTRAS: torch-npu,metrics container_name: llamafactory-a2 image: llamafactory:npu-a2 volumes: @@ -36,7 +35,6 @@ services: args: BASE_IMAGE: quay.io/ascend/cann:8.3.rc2-a3-ubuntu22.04-py3.11 PIP_INDEX: https://pypi.org/simple - EXTRAS: torch-npu,metrics container_name: llamafactory-a3 image: llamafactory:npu-a3 volumes: diff --git a/docker/docker-rocm/Dockerfile b/docker/docker-rocm/Dockerfile index c5af6aa27..d0a981767 100644 --- a/docker/docker-rocm/Dockerfile +++ b/docker/docker-rocm/Dockerfile @@ -27,17 +27,14 @@ WORKDIR /app # Change pip source RUN pip config set global.index-url "${PIP_INDEX}" && \ pip config set global.extra-index-url "${PIP_INDEX}" && \ - pip install --no-cache-dir --upgrade pip packaging wheel setuptools "hatchling>=1.18.0" editables - -# Reinstall pytorch rocm -RUN pip uninstall -y torch torchvision torchaudio && \ - pip install --no-cache-dir --pre torch torchvision torchaudio --index-url "${PYTORCH_INDEX}" + pip install --no-cache-dir --upgrade pip packaging wheel setuptools editables "hatchling>=1.18.0" # Copy the application into the image COPY . /app -# Install LLaMA Factory -RUN pip install --no-cache-dir -e "." --no-build-isolation +# Reinstall pytorch rocm and install LLaMA Factory +RUN pip uninstall -y torch torchvision torchaudio && \ + pip install --no-cache-dir --no-build-isolation -e --pre ".[metrics,deepspeed]" --index-url "${PYTORCH_INDEX}" # Rebuild flash attention RUN if [ "${INSTALL_FLASHATTN}" == "true" ]; then \ diff --git a/docker/docker-rocm/docker-compose.yml b/docker/docker-rocm/docker-compose.yml index 32cdf5633..7e6c83bfb 100644 --- a/docker/docker-rocm/docker-compose.yml +++ b/docker/docker-rocm/docker-compose.yml @@ -5,7 +5,6 @@ services: context: ../.. args: PIP_INDEX: https://pypi.org/simple - EXTRAS: metrics container_name: llamafactory ports: - "7860:7860" diff --git a/examples/requirements/dev.txt b/examples/requirements/dev.txt deleted file mode 100644 index f0fc17fcc..000000000 --- a/examples/requirements/dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -pre-commit -ruff -pytest -build diff --git a/pyproject.toml b/pyproject.toml index ec8473eb1..732a812c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,50 +38,47 @@ classifiers = [ ] dependencies = [ # core deps + "torch>=2.4.0", + "torchvision>=0.19.0", + "torchaudio>=2.4.0", "transformers>=4.49.0,<=4.56.2,!=4.52.0; python_version < '3.10'", "transformers>=4.49.0,<=4.57.1,!=4.52.0,!=4.57.0; python_version >= '3.10'", "datasets>=2.16.0,<=4.0.0", "accelerate>=1.3.0,<=1.11.0", "peft>=0.14.0,<=0.17.1", "trl>=0.8.6,<=0.9.6", - "torchdata", - # torch - "torch>=2.0.0", - "torchvision>=0.15.0", + "torchdata>=0.10.0,<=0.11.0", # gui - "gradio>=4.38.0,<=5.45.0", + "gradio>=4.38.0,<=6.2.0", "matplotlib>=3.7.0", "tyro<0.9.0", # ops "einops", - "numpy<2.0.0", - "pandas>=2.0.0", + "numpy", + "pandas", "scipy", # model and tokenizer "sentencepiece", "tiktoken", - "modelscope>=1.14.0", + "modelscope", "hf-transfer", - "safetensors<=0.5.3", + "safetensors", # python + "av", "fire", "omegaconf", "packaging", "protobuf", "pyyaml", - "pydantic<=2.10.6", + "pydantic", # api "uvicorn", "fastapi", - "sse-starlette", - # media - "av", - "librosa", - # yanked - "propcache!=0.4.0" + "sse-starlette" ] [project.optional-dependencies] +dev = ["pre-commit", "ruff", "pytest", "build"] metrics = ["nltk", "jieba", "rouge-chinese"] deepspeed = ["deepspeed>=0.10.0,<=0.16.9"] diff --git a/src/llamafactory/data/mm_plugin.py b/src/llamafactory/data/mm_plugin.py index 291554021..05acded2c 100644 --- a/src/llamafactory/data/mm_plugin.py +++ b/src/llamafactory/data/mm_plugin.py @@ -26,6 +26,7 @@ from typing import TYPE_CHECKING, BinaryIO, Literal, Optional, TypedDict, Union import numpy as np import torch +import torchaudio from transformers.image_utils import get_image_size, is_valid_image, to_numpy_array from transformers.models.mllama.processing_mllama import ( convert_sparse_cross_attention_mask_to_dense, @@ -34,16 +35,7 @@ from transformers.models.mllama.processing_mllama import ( from typing_extensions import NotRequired, override from ..extras.constants import AUDIO_PLACEHOLDER, IGNORE_INDEX, IMAGE_PLACEHOLDER, VIDEO_PLACEHOLDER -from ..extras.packages import ( - is_librosa_available, - is_pillow_available, - is_pyav_available, - is_transformers_version_greater_than, -) - - -if is_librosa_available(): - import librosa +from ..extras.packages import is_pillow_available, is_pyav_available, is_transformers_version_greater_than if is_pillow_available(): @@ -316,7 +308,14 @@ class MMPluginMixin: results, sampling_rates = [], [] for audio in audios: if not isinstance(audio, np.ndarray): - audio, sampling_rate = librosa.load(audio, sr=sampling_rate) + audio, sr = torchaudio.load(audio) + if audio.shape[0] > 1: + audio = audio.mean(dim=0, keepdim=True) + + if sr != sampling_rate: + audio = torchaudio.functional.resample(audio, sr, sampling_rate) + + audio = audio.squeeze(0).numpy() results.append(audio) sampling_rates.append(sampling_rate) @@ -500,13 +499,17 @@ class ErnieVLPlugin(BasePlugin): while IMAGE_PLACEHOLDER in content: image_seqlen = image_grid_thw[image_idx].prod() // merge_length if self.expand_mm_tokens else 1 content = content.replace( - IMAGE_PLACEHOLDER, f"Picture {image_idx + 1}:<|IMAGE_START|>{image_token * image_seqlen}<|IMAGE_END|>", 1 + IMAGE_PLACEHOLDER, + f"Picture {image_idx + 1}:<|IMAGE_START|>{image_token * image_seqlen}<|IMAGE_END|>", + 1, ) image_idx += 1 while VIDEO_PLACEHOLDER in content: video_seqlen = video_grid_thw[video_idx].prod() // merge_length if self.expand_mm_tokens else 1 content = content.replace( - VIDEO_PLACEHOLDER, f"Video {video_idx + 1}:<|VIDEO_START|>{video_token * video_seqlen}<|VIDEO_END|>", 1 + VIDEO_PLACEHOLDER, + f"Video {video_idx + 1}:<|VIDEO_START|>{video_token * video_seqlen}<|VIDEO_END|>", + 1, ) video_idx += 1 message["content"] = content diff --git a/src/llamafactory/extras/misc.py b/src/llamafactory/extras/misc.py index 5c4c24787..ba35bafb2 100644 --- a/src/llamafactory/extras/misc.py +++ b/src/llamafactory/extras/misc.py @@ -332,3 +332,7 @@ def fix_proxy(ipv6_enabled: bool = False) -> None: if ipv6_enabled: os.environ.pop("http_proxy", None) os.environ.pop("HTTP_PROXY", None) + os.environ.pop("https_proxy", None) + os.environ.pop("HTTPS_PROXY", None) + os.environ.pop("all_proxy", None) + os.environ.pop("ALL_PROXY", None) diff --git a/src/llamafactory/model/loader.py b/src/llamafactory/model/loader.py index 72f510a44..ef4f3f134 100644 --- a/src/llamafactory/model/loader.py +++ b/src/llamafactory/model/loader.py @@ -15,7 +15,6 @@ import os from typing import TYPE_CHECKING, Any, Optional, TypedDict -import torch from transformers import ( AutoConfig, AutoModelForCausalLM, @@ -158,6 +157,7 @@ def load_model( if model is None and not lazy_load: init_kwargs["config"] = config init_kwargs["pretrained_model_name_or_path"] = model_args.model_name_or_path + init_kwargs["torch_dtype"] = "auto" if model_args.mixture_of_depths == "load": model = load_mod_pretrained_model(**init_kwargs) diff --git a/src/llamafactory/model/patcher.py b/src/llamafactory/model/patcher.py index 7401641aa..67eee886b 100644 --- a/src/llamafactory/model/patcher.py +++ b/src/llamafactory/model/patcher.py @@ -156,16 +156,13 @@ def patch_config( # deepspeed zero3 is not compatible with low_cpu_mem_usage init_kwargs["low_cpu_mem_usage"] = model_args.low_cpu_mem_usage and (not is_deepspeed_zero3_enabled()) - # do not cast data type of the model deepspeed zero3 without qlora - if not (is_deepspeed_zero3_enabled() and model_args.quantization_bit is None): - init_kwargs["torch_dtype"] = "auto" + # fsdp/deepspeed zero3 does not need device map + if not (is_deepspeed_zero3_enabled() or is_fsdp_enabled()) and init_kwargs["low_cpu_mem_usage"]: + if "device_map" not in init_kwargs and model_args.device_map: + init_kwargs["device_map"] = model_args.device_map # device map requires low_cpu_mem_usage=True - if init_kwargs["low_cpu_mem_usage"] and not is_fsdp_enabled(): # fsdp does not need device map - if "device_map" not in init_kwargs and model_args.device_map: - init_kwargs["device_map"] = model_args.device_map # device map requires low_cpu_mem_usage=True - - if init_kwargs.get("device_map", None) == "auto": - init_kwargs["offload_folder"] = model_args.offload_folder + if init_kwargs.get("device_map", None) == "auto": + init_kwargs["offload_folder"] = model_args.offload_folder def patch_model( diff --git a/src/llamafactory/train/test_utils.py b/src/llamafactory/train/test_utils.py index 0f73d1c5e..f31b3d2fc 100644 --- a/src/llamafactory/train/test_utils.py +++ b/src/llamafactory/train/test_utils.py @@ -84,7 +84,7 @@ def load_reference_model( model: AutoModelForCausalLMWithValueHead = AutoModelForCausalLMWithValueHead.from_pretrained( model_path, torch_dtype=torch.float16, device_map="auto" ) - + return model model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, device_map="auto") diff --git a/src/llamafactory/webui/locales.py b/src/llamafactory/webui/locales.py index 7051b30e8..06e64e4a7 100644 --- a/src/llamafactory/webui/locales.py +++ b/src/llamafactory/webui/locales.py @@ -35,35 +35,40 @@ LOCALES = { "value": ( "

Visit " "GitHub Page " - "Documentation

" + "Documentation " + "Blog" ), }, "ru": { "value": ( "

Посетить " "страницу GitHub " - "Документацию

" + "Документацию " + "Блог" ), }, "zh": { "value": ( "

访问 " "GitHub 主页 " - "官方文档

" + "官方文档 " + "博客" ), }, "ko": { "value": ( "

" "GitHub 페이지 " - "공식 문서를 방문하세요.

" + "공식 문서 " + "블로그를 방문하세요." ), }, "ja": { "value": ( "

" "GitHub ページ " - "ドキュメントにアクセスする

" + "ドキュメント " + "ブログにアクセスする" ), }, },