mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-08-17 13:35:44 +08:00
[docker] upgrade NPU images to CANN 9.1 and PyTorch 2.10 (#10729)
This commit is contained in:
45
.github/workflows/docker_npu.yml
vendored
45
.github/workflows/docker_npu.yml
vendored
@@ -17,16 +17,16 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- device: "npu-a2"
|
- device: "npu-a2"
|
||||||
os: "ubuntu"
|
os: "ubuntu"
|
||||||
base_image: "quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11"
|
base_image: "quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12"
|
||||||
- device: "npu-a3"
|
- device: "npu-a3"
|
||||||
os: "ubuntu"
|
os: "ubuntu"
|
||||||
base_image: "quay.io/ascend/cann:9.0.0-a3-ubuntu22.04-py3.11"
|
base_image: "quay.io/ascend/cann:9.1.0-a3-ubuntu22.04-py3.12"
|
||||||
- device: "npu-a2"
|
- device: "npu-a2"
|
||||||
os: "openeuler"
|
os: "openeuler"
|
||||||
base_image: "quay.io/ascend/cann:9.0.0-910b-openeuler24.03-py3.11"
|
base_image: "quay.io/ascend/cann:9.1.0-910b-openeuler24.03-py3.12"
|
||||||
- device: "npu-a3"
|
- device: "npu-a3"
|
||||||
os: "openeuler"
|
os: "openeuler"
|
||||||
base_image: "quay.io/ascend/cann:9.0.0-a3-openeuler24.03-py3.11"
|
base_image: "quay.io/ascend/cann:9.1.0-a3-openeuler24.03-py3.12"
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Get llamafactory version
|
- name: Get LlamaFactory version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "release" ]; then
|
if [ "${{ github.event_name }}" = "release" ]; then
|
||||||
@@ -61,29 +61,46 @@ jobs:
|
|||||||
id: npu_tag
|
id: npu_tag
|
||||||
env:
|
env:
|
||||||
BASE_IMAGE: ${{ matrix.base_image }}
|
BASE_IMAGE: ${{ matrix.base_image }}
|
||||||
DEVICE: ${{ matrix.device }}
|
MATRIX_DEVICE: ${{ matrix.device }}
|
||||||
MATRIX_OS: ${{ matrix.os }}
|
MATRIX_OS: ${{ matrix.os }}
|
||||||
LLAMAFACTORY_VERSION: ${{ steps.version.outputs.tag }}
|
LLAMAFACTORY_VERSION: ${{ steps.version.outputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
base_image_tag="${BASE_IMAGE##*:}"
|
base_image_tag="${BASE_IMAGE##*:}"
|
||||||
cann_version="${base_image_tag%%-*}"
|
cann_version="${base_image_tag%%-*}"
|
||||||
torch_npu_version="$(sed -nE 's/^torch[-_]npu==([0-9]+(\.[0-9]+)*).*/\1/p' requirements/npu.txt)"
|
torch_npu_version="$(sed -nE 's/^torch[-_]npu==([0-9]+(\.[0-9]+)*(\.post[0-9]+)?).*/\1/p' requirements/npu.txt)"
|
||||||
accelerator="${DEVICE#npu-}"
|
soc="$(grep -oE '(910b|a3)' <<< "${base_image_tag}" | head -n 1)"
|
||||||
accelerator="${accelerator^^}"
|
operating_system="$(grep -oE '(ubuntu|openeuler)[0-9]+(\.[0-9]+)*' <<< "${base_image_tag}" | head -n 1)"
|
||||||
operating_system="$(grep -oE '(ubuntu|openeuler)' <<< "${base_image_tag}" | head -n 1)"
|
|
||||||
python_version="$(grep -oE 'py[0-9]+\.[0-9]+' <<< "${base_image_tag}" | head -n 1)"
|
python_version="$(grep -oE 'py[0-9]+\.[0-9]+' <<< "${base_image_tag}" | head -n 1)"
|
||||||
|
|
||||||
if [[ -z "${cann_version}" || -z "${torch_npu_version}" || -z "${operating_system}" || -z "${python_version}" ]]; then
|
if [[ -z "${cann_version}" || -z "${torch_npu_version}" || -z "${soc}" || -z "${operating_system}" || -z "${python_version}" ]]; then
|
||||||
echo "Failed to derive the NPU image tag from ${BASE_IMAGE} and requirements/npu.txt" >&2
|
echo "Failed to derive the NPU image tag from ${BASE_IMAGE} and requirements/npu.txt" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${operating_system}" != "${MATRIX_OS}" ]]; then
|
if [[ "${operating_system}" != "${MATRIX_OS}"* ]]; then
|
||||||
echo "Operating system ${operating_system} derived from ${BASE_IMAGE} does not match matrix OS ${MATRIX_OS}" >&2
|
echo "Operating system ${operating_system} derived from ${BASE_IMAGE} does not match matrix OS family ${MATRIX_OS}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "tag=${LLAMAFACTORY_VERSION}-cann${cann_version}-torch_npu${torch_npu_version}-${accelerator}-${operating_system}-${python_version}" >> "$GITHUB_OUTPUT"
|
case "${MATRIX_DEVICE}" in
|
||||||
|
npu-a2) expected_soc="910b" ;;
|
||||||
|
npu-a3) expected_soc="a3" ;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported NPU device ${MATRIX_DEVICE}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ "${soc}" != "${expected_soc}" ]]; then
|
||||||
|
echo "SoC ${soc} derived from ${BASE_IMAGE} does not match matrix device ${MATRIX_DEVICE}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${LLAMAFACTORY_VERSION}" == "latest" ]]; then
|
||||||
|
echo "tag=latest-${soc}-${MATRIX_OS}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "tag=${LLAMAFACTORY_VERSION}-cann${cann_version}-torch_npu${torch_npu_version}-${soc}-${operating_system}-${python_version}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|||||||
6
.github/workflows/tests_npu.yml
vendored
6
.github/workflows/tests_npu.yml
vendored
@@ -25,11 +25,11 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python:
|
python:
|
||||||
- "3.11"
|
- "3.12"
|
||||||
os:
|
os:
|
||||||
- "linux-aarch64-a2-4"
|
- "linux-aarch64-a2-4"
|
||||||
pytorch_npu:
|
pytorch_npu:
|
||||||
- "2.7.1"
|
- "2.10.0"
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||||
|
|
||||||
container:
|
container:
|
||||||
image: ascendai/cann:9.0.0-910b-ubuntu22.04-py3.11
|
image: ascendai/cann:9.1.0-910b-ubuntu22.04-py3.12
|
||||||
env:
|
env:
|
||||||
HF_ENDPOINT: https://hf-mirror.com
|
HF_ENDPOINT: https://hf-mirror.com
|
||||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||||
|
|||||||
102
README.md
102
README.md
@@ -1,9 +1,9 @@
|
|||||||

|

|
||||||
|
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/stargazers)
|
[](https://github.com/hiyouga/LlamaFactory/stargazers)
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/commits/main)
|
[](https://github.com/hiyouga/LlamaFactory/commits/main)
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors)
|
[](https://github.com/hiyouga/LlamaFactory/graphs/contributors)
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml)
|
[](https://github.com/hiyouga/LlamaFactory/actions/workflows/tests.yml)
|
||||||
[](https://pypi.org/project/llamafactory/)
|
[](https://pypi.org/project/llamafactory/)
|
||||||
[](https://scholar.google.com/scholar?cites=12620864006390196564)
|
[](https://scholar.google.com/scholar?cites=12620864006390196564)
|
||||||
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
|
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
|
||||||
@@ -95,7 +95,7 @@ Read technical notes:
|
|||||||
- [Download from Modelers Hub](#download-from-modelers-hub)
|
- [Download from Modelers Hub](#download-from-modelers-hub)
|
||||||
- [Use W&B Logger](#use-wb-logger)
|
- [Use W&B Logger](#use-wb-logger)
|
||||||
- [Use SwanLab Logger](#use-swanlab-logger)
|
- [Use SwanLab Logger](#use-swanlab-logger)
|
||||||
- [Projects using LLaMA Factory](#projects-using-llama-factory)
|
- [Projects using LlamaFactory](#projects-using-llamafactory)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
- [Citation](#citation)
|
- [Citation](#citation)
|
||||||
- [Acknowledgement](#acknowledgement)
|
- [Acknowledgement](#acknowledgement)
|
||||||
@@ -121,35 +121,35 @@ Read technical notes:
|
|||||||
## Blogs
|
## Blogs
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Now we have a dedicated blog for LLaMA Factory!
|
> Now we have a dedicated blog for LlamaFactory!
|
||||||
>
|
>
|
||||||
> Website: https://blog.llamafactory.net/en/
|
> Website: https://blog.llamafactory.net/en/
|
||||||
|
|
||||||
- 💡 [KTransformers Fine-Tuning × LLaMA Factory: Fine-tuning 1000 Billion models with 2 4090-GPU + CPU](https://blog.llamafactory.net/en/posts/ktransformers/) (English)
|
- 💡 [KTransformers Fine-Tuning × LlamaFactory: Fine-tuning 1000 Billion models with 2 4090-GPU + CPU](https://blog.llamafactory.net/en/posts/ktransformers/) (English)
|
||||||
- 💡 [Easy Dataset × LLaMA Factory: Enabling LLMs to Efficiently Learn Domain Knowledge](https://buaa-act.feishu.cn/wiki/GVzlwYcRFiR8OLkHbL6cQpYin7g) (English)
|
- 💡 [Easy Dataset × LlamaFactory: Enabling LLMs to Efficiently Learn Domain Knowledge](https://buaa-act.feishu.cn/wiki/GVzlwYcRFiR8OLkHbL6cQpYin7g) (English)
|
||||||
- 💡 [DataFlow × LLaMA Factory: Producing High-Quality Data for LLM Training with a Data Preparation Pipeline](https://wcny4qa9krto.feishu.cn/wiki/LWkkwTDBfiiRKqkDSvucG6yjnbW) (English) | [中文](https://wcny4qa9krto.feishu.cn/wiki/LlMxweUAJimrmykRD5qcGuswnHd)
|
- 💡 [DataFlow × LlamaFactory: Producing High-Quality Data for LLM Training with a Data Preparation Pipeline](https://wcny4qa9krto.feishu.cn/wiki/LWkkwTDBfiiRKqkDSvucG6yjnbW) (English) | [中文](https://wcny4qa9krto.feishu.cn/wiki/LlMxweUAJimrmykRD5qcGuswnHd)
|
||||||
- 💡 [DataFlex × LLaMA Factory: A Data-Centric Dynamic Training System Built on LLaMA-Factory](https://wcny4qa9krto.feishu.cn/wiki/OlREwPQWdi9K6ZkJNHIciLhtnkv) (English) | [中文](https://wcny4qa9krto.feishu.cn/wiki/H2A9wSsbCinzavkT2oyc2C5Vn0e)
|
- 💡 [DataFlex × LlamaFactory: A Data-Centric Dynamic Training System Built on LlamaFactory](https://wcny4qa9krto.feishu.cn/wiki/OlREwPQWdi9K6ZkJNHIciLhtnkv) (English) | [中文](https://wcny4qa9krto.feishu.cn/wiki/H2A9wSsbCinzavkT2oyc2C5Vn0e)
|
||||||
- [A One-Stop Code-Free Model Reinforcement Learning and Deployment Platform based on LLaMA-Factory and EasyR1](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/) (Chinese)
|
- [A One-Stop Code-Free Model Reinforcement Learning and Deployment Platform based on LlamaFactory and EasyR1](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/) (Chinese)
|
||||||
- [How Apoidea Group enhances visual information extraction from banking documents with multimodal models using LLaMA-Factory on Amazon SageMaker HyperPod](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/) (English)
|
- [How Apoidea Group enhances visual information extraction from banking documents with multimodal models using LlamaFactory on Amazon SageMaker HyperPod](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/) (English)
|
||||||
|
|
||||||
<details><summary>All Blogs</summary>
|
<details><summary>All Blogs</summary>
|
||||||
|
|
||||||
- [LLaMA Factory: Fine-tuning the DeepSeek-R1-Distill-Qwen-7B Model for News Classifier](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b) (Chinese)
|
- [LlamaFactory: Fine-tuning the DeepSeek-R1-Distill-Qwen-7B Model for News Classifier](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b) (Chinese)
|
||||||
- [A One-Stop Code-Free Model Fine-Tuning \& Deployment Platform based on SageMaker and LLaMA-Factory](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/) (Chinese)
|
- [A One-Stop Code-Free Model Fine-Tuning \& Deployment Platform based on SageMaker and LlamaFactory](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/) (Chinese)
|
||||||
- [LLaMA Factory Multi-Modal Fine-Tuning Practice: Fine-Tuning Qwen2-VL for Personal Tourist Guide](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl) (Chinese)
|
- [LlamaFactory Multi-Modal Fine-Tuning Practice: Fine-Tuning Qwen2-VL for Personal Tourist Guide](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl) (Chinese)
|
||||||
- [LLaMA Factory: Fine-tuning Llama3 for Role-Playing](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory) (Chinese)
|
- [LlamaFactory: Fine-tuning Llama3 for Role-Playing](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory) (Chinese)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
[25/10/26] We support Megatron-core training backend with [**mcore_adapter**](https://github.com/alibaba/ROLL/tree/main/mcore_adapter). See [PR #9237](https://github.com/hiyouga/LLaMA-Factory/pull/9237) to get started.
|
[25/10/26] We support Megatron-core training backend with [**mcore_adapter**](https://github.com/alibaba/ROLL/tree/main/mcore_adapter). See [PR #9237](https://github.com/hiyouga/LlamaFactory/pull/9237) to get started.
|
||||||
|
|
||||||
[25/08/22] We supported **[OFT](https://arxiv.org/abs/2306.07280)** and **[OFTv2](https://arxiv.org/abs/2506.19847)**. See [examples](examples/README.md) for usage.
|
[25/08/22] We supported **[OFT](https://arxiv.org/abs/2306.07280)** and **[OFTv2](https://arxiv.org/abs/2506.19847)**. See [examples](examples/README.md) for usage.
|
||||||
|
|
||||||
[25/08/20] We supported fine-tuning the **[Intern-S1-mini](https://huggingface.co/internlm/Intern-S1-mini)** models. See [PR #8976](https://github.com/hiyouga/LLaMA-Factory/pull/8976) to get started.
|
[25/08/20] We supported fine-tuning the **[Intern-S1-mini](https://huggingface.co/internlm/Intern-S1-mini)** models. See [PR #8976](https://github.com/hiyouga/LlamaFactory/pull/8976) to get started.
|
||||||
|
|
||||||
[25/08/06] We supported fine-tuning the **[GPT-OSS](https://github.com/openai/gpt-oss)** models. See [PR #8826](https://github.com/hiyouga/LLaMA-Factory/pull/8826) to get started.
|
[25/08/06] We supported fine-tuning the **[GPT-OSS](https://github.com/openai/gpt-oss)** models. See [PR #8826](https://github.com/hiyouga/LlamaFactory/pull/8826) to get started.
|
||||||
|
|
||||||
<details><summary>Full Changelog</summary>
|
<details><summary>Full Changelog</summary>
|
||||||
|
|
||||||
@@ -159,13 +159,13 @@ Read technical notes:
|
|||||||
|
|
||||||
[25/04/21] We supported the **[Muon](https://github.com/KellerJordan/Muon)** optimizer. See [examples](examples/README.md) for usage. Thank [@tianshijing](https://github.com/tianshijing)'s PR.
|
[25/04/21] We supported the **[Muon](https://github.com/KellerJordan/Muon)** optimizer. See [examples](examples/README.md) for usage. Thank [@tianshijing](https://github.com/tianshijing)'s PR.
|
||||||
|
|
||||||
[25/04/16] We supported fine-tuning the **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** model. See [PR #7258](https://github.com/hiyouga/LLaMA-Factory/pull/7258) to get started.
|
[25/04/16] We supported fine-tuning the **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** model. See [PR #7258](https://github.com/hiyouga/LlamaFactory/pull/7258) to get started.
|
||||||
|
|
||||||
[25/04/14] We supported fine-tuning the **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** and **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** models.
|
[25/04/14] We supported fine-tuning the **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** and **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** models.
|
||||||
|
|
||||||
[25/04/06] We supported fine-tuning the **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** model. See [PR #7611](https://github.com/hiyouga/LLaMA-Factory/pull/7611) to get started.
|
[25/04/06] We supported fine-tuning the **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** model. See [PR #7611](https://github.com/hiyouga/LlamaFactory/pull/7611) to get started.
|
||||||
|
|
||||||
[25/03/31] We supported fine-tuning the **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** model. See [PR #7537](https://github.com/hiyouga/LLaMA-Factory/pull/7537) to get started.
|
[25/03/31] We supported fine-tuning the **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** model. See [PR #7537](https://github.com/hiyouga/LlamaFactory/pull/7537) to get started.
|
||||||
|
|
||||||
[25/03/15] We supported **[SGLang](https://github.com/sgl-project/sglang)** as inference backend. Try `infer_backend: sglang` to accelerate inference.
|
[25/03/15] We supported **[SGLang](https://github.com/sgl-project/sglang)** as inference backend. Try `infer_backend: sglang` to accelerate inference.
|
||||||
|
|
||||||
@@ -217,13 +217,13 @@ Read technical notes:
|
|||||||
|
|
||||||
[24/04/26] We supported fine-tuning the **LLaVA-1.5** multimodal LLMs. See [examples](examples/README.md) for usage.
|
[24/04/26] We supported fine-tuning the **LLaVA-1.5** multimodal LLMs. See [examples](examples/README.md) for usage.
|
||||||
|
|
||||||
[24/04/22] We provided a **[Colab notebook](https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing)** for fine-tuning the Llama-3 model on a free T4 GPU. Two Llama-3-derived models fine-tuned using LLaMA Factory are available at Hugging Face, check [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) and [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese) for details.
|
[24/04/22] We provided a **[Colab notebook](https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing)** for fine-tuning the Llama-3 model on a free T4 GPU. Two Llama-3-derived models fine-tuned using LlamaFactory are available at Hugging Face, check [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) and [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese) for details.
|
||||||
|
|
||||||
[24/04/21] We supported **[Mixture-of-Depths](https://arxiv.org/abs/2404.02258)** according to [AstraMindAI's implementation](https://github.com/astramind-ai/Mixture-of-depths). See [examples](examples/README.md) for usage.
|
[24/04/21] We supported **[Mixture-of-Depths](https://arxiv.org/abs/2404.02258)** according to [AstraMindAI's implementation](https://github.com/astramind-ai/Mixture-of-depths). See [examples](examples/README.md) for usage.
|
||||||
|
|
||||||
[24/04/16] We supported **[BAdam](https://arxiv.org/abs/2404.02827)** optimizer. See [examples](examples/README.md) for usage.
|
[24/04/16] We supported **[BAdam](https://arxiv.org/abs/2404.02827)** optimizer. See [examples](examples/README.md) for usage.
|
||||||
|
|
||||||
[24/04/16] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s long-sequence training (Llama-2-7B-56k within 24GB). It achieves **117%** speed and **50%** memory compared with FlashAttention-2, more benchmarks can be found in [this page](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison).
|
[24/04/16] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s long-sequence training (Llama-2-7B-56k within 24GB). It achieves **117%** speed and **50%** memory compared with FlashAttention-2, more benchmarks can be found in [this page](https://github.com/hiyouga/LlamaFactory/wiki/Performance-comparison).
|
||||||
|
|
||||||
[24/03/31] We supported **[ORPO](https://arxiv.org/abs/2403.07691)**. See [examples](examples/README.md) for usage.
|
[24/03/31] We supported **[ORPO](https://arxiv.org/abs/2403.07691)**. See [examples](examples/README.md) for usage.
|
||||||
|
|
||||||
@@ -241,11 +241,11 @@ Read technical notes:
|
|||||||
|
|
||||||
[24/02/15] We supported **block expansion** proposed by [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro). See [examples](examples/README.md) for usage.
|
[24/02/15] We supported **block expansion** proposed by [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro). See [examples](examples/README.md) for usage.
|
||||||
|
|
||||||
[24/02/05] Qwen1.5 (Qwen2 beta version) series models are supported in LLaMA-Factory. Check this [blog post](https://qwenlm.github.io/blog/qwen1.5/) for details.
|
[24/02/05] Qwen1.5 (Qwen2 beta version) series models are supported in LlamaFactory. Check this [blog post](https://qwenlm.github.io/blog/qwen1.5/) for details.
|
||||||
|
|
||||||
[24/01/18] We supported **agent tuning** for most models, equipping model with tool using abilities by fine-tuning with `dataset: glaive_toolcall_en`.
|
[24/01/18] We supported **agent tuning** for most models, equipping model with tool using abilities by fine-tuning with `dataset: glaive_toolcall_en`.
|
||||||
|
|
||||||
[23/12/23] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s implementation to boost LoRA tuning for the LLaMA, Mistral and Yi models. Try `use_unsloth: true` argument to activate unsloth patch. It achieves **170%** speed in our benchmark, check [this page](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison) for details.
|
[23/12/23] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s implementation to boost LoRA tuning for the LLaMA, Mistral and Yi models. Try `use_unsloth: true` argument to activate unsloth patch. It achieves **170%** speed in our benchmark, check [this page](https://github.com/hiyouga/LlamaFactory/wiki/Performance-comparison) for details.
|
||||||
|
|
||||||
[23/12/12] We supported fine-tuning the latest MoE model **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)** in our framework. See hardware requirement [here](#hardware-requirement).
|
[23/12/12] We supported fine-tuning the latest MoE model **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)** in our framework. See hardware requirement [here](#hardware-requirement).
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ Read technical notes:
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> If you cannot use the latest feature, please pull the latest code and install LLaMA-Factory again.
|
> If you cannot use the latest feature, please pull the latest code and install LlamaFactory again.
|
||||||
|
|
||||||
## Supported Models
|
## Supported Models
|
||||||
|
|
||||||
@@ -604,23 +604,23 @@ To enable FlashAttention-2 on the Windows platform, please use the script from [
|
|||||||
|
|
||||||
<details><summary>For Ascend NPU users</summary>
|
<details><summary>For Ascend NPU users</summary>
|
||||||
|
|
||||||
To install LLaMA Factory on Ascend NPU devices, please upgrade Python to version 3.10 or higher: `pip install -r requirements/npu.txt`. Additionally, you need to install the **Ascend CANN Toolkit and Kernels**. Please follow the [installation tutorial](https://llamafactory.readthedocs.io/en/latest/multibackend/npu/npu_installation.html).
|
To install LlamaFactory on Ascend NPU devices, please use Python 3.12 and install the extra dependencies with `pip install -r requirements/npu.txt`. Additionally, you need to install the **Ascend CANN Toolkit and Kernels**. Please follow the [installation tutorial](https://llamafactory.readthedocs.io/en/latest/multibackend/npu/npu_installation.html).
|
||||||
|
|
||||||
|
|
||||||
You can also download the pre-built Docker images:
|
You can also download the pre-built Docker images:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Docker Hub
|
# Docker Hub
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
docker pull hiyouga/llamafactory:latest-910b-ubuntu
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-ubuntu-py3.11
|
docker pull hiyouga/llamafactory:latest-a3-ubuntu
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-openeuler-py3.11
|
docker pull hiyouga/llamafactory:latest-910b-openeuler
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-openeuler-py3.11
|
docker pull hiyouga/llamafactory:latest-a3-openeuler
|
||||||
|
|
||||||
# quay.io
|
# quay.io
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-910b-ubuntu
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-ubuntu-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-a3-ubuntu
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-openeuler-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-910b-openeuler
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-openeuler-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-a3-openeuler
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Install BitsAndBytes
|
#### Install BitsAndBytes
|
||||||
@@ -683,7 +683,7 @@ See [examples/README.md](examples/README.md) for advanced usage (including distr
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Use `llamafactory-cli help` to show help information.
|
> Use `llamafactory-cli help` to show help information.
|
||||||
>
|
>
|
||||||
> Read [FAQs](https://github.com/hiyouga/LLaMA-Factory/issues/4614) first if you encounter any problems.
|
> Read [FAQs](https://github.com/hiyouga/LlamaFactory/issues/4614) first if you encounter any problems.
|
||||||
|
|
||||||
### Fine-Tuning with LLaMA Board GUI (powered by [Gradio](https://github.com/gradio-app/gradio))
|
### Fine-Tuning with LLaMA Board GUI (powered by [Gradio](https://github.com/gradio-app/gradio))
|
||||||
|
|
||||||
@@ -701,28 +701,26 @@ docker compose up -d
|
|||||||
docker compose exec llamafactory bash
|
docker compose exec llamafactory bash
|
||||||
```
|
```
|
||||||
|
|
||||||
For Ascend NPU users (A2 with Ubuntu by default):
|
For Ascend NPU users:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd docker/docker-npu/
|
cd docker/docker-npu/
|
||||||
docker compose up -d llamafactory-a2-ubuntu
|
|
||||||
docker compose exec llamafactory-a2-ubuntu bash
|
|
||||||
```
|
|
||||||
|
|
||||||
Other NPU variants can be started with their corresponding profiles and services:
|
# A2 with Ubuntu
|
||||||
|
docker compose --profile a2-ubuntu up -d
|
||||||
|
docker compose --profile a2-ubuntu exec llamafactory-a2-ubuntu bash
|
||||||
|
|
||||||
```bash
|
|
||||||
# A3 with Ubuntu
|
# A3 with Ubuntu
|
||||||
docker compose --profile a3 up -d llamafactory-a3-ubuntu
|
docker compose --profile a3-ubuntu up -d
|
||||||
docker compose exec llamafactory-a3-ubuntu bash
|
docker compose --profile a3-ubuntu exec llamafactory-a3-ubuntu bash
|
||||||
|
|
||||||
# A2 with openEuler
|
# A2 with openEuler
|
||||||
docker compose --profile openeuler up -d llamafactory-a2-openeuler
|
docker compose --profile a2-openeuler up -d
|
||||||
docker compose exec llamafactory-a2-openeuler bash
|
docker compose --profile a2-openeuler exec llamafactory-a2-openeuler bash
|
||||||
|
|
||||||
# A3 with openEuler
|
# A3 with openEuler
|
||||||
docker compose --profile a3-openeuler up -d llamafactory-a3-openeuler
|
docker compose --profile a3-openeuler up -d
|
||||||
docker compose exec llamafactory-a3-openeuler bash
|
docker compose --profile a3-openeuler exec llamafactory-a3-openeuler bash
|
||||||
```
|
```
|
||||||
|
|
||||||
For AMD ROCm users:
|
For AMD ROCm users:
|
||||||
@@ -864,7 +862,7 @@ When launching training tasks, you can log in to SwanLab in three ways:
|
|||||||
2. Set the environment variable `SWANLAB_API_KEY` to your [API key](https://swanlab.cn/settings).
|
2. Set the environment variable `SWANLAB_API_KEY` to your [API key](https://swanlab.cn/settings).
|
||||||
3. Use the `swanlab login` command to complete the login.
|
3. Use the `swanlab login` command to complete the login.
|
||||||
|
|
||||||
## Projects using LLaMA Factory
|
## Projects using LlamaFactory
|
||||||
|
|
||||||
If you have a project that should be incorporated, please contact via email or create a pull request.
|
If you have a project that should be incorporated, please contact via email or create a pull request.
|
||||||
|
|
||||||
@@ -962,7 +960,7 @@ If you have a project that should be incorporated, please contact via email or c
|
|||||||
1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**: A multimodal large language model specialized in Chinese medical domain, based on LLaVA-1.5-7B.
|
1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**: A multimodal large language model specialized in Chinese medical domain, based on LLaVA-1.5-7B.
|
||||||
1. **[AutoRE](https://github.com/THUDM/AutoRE)**: A document-level relation extraction system based on large language models.
|
1. **[AutoRE](https://github.com/THUDM/AutoRE)**: A document-level relation extraction system based on large language models.
|
||||||
1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**: SDKs for fine-tuning LLMs on Windows PC for NVIDIA RTX.
|
1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**: SDKs for fine-tuning LLMs on Windows PC for NVIDIA RTX.
|
||||||
1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**: An easy and lazy way for building multi-agent LLMs applications and supports model fine-tuning via LLaMA Factory.
|
1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**: An easy and lazy way for building multi-agent LLMs applications and supports model fine-tuning via LlamaFactory.
|
||||||
1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**: A full pipeline for RAG retrieval model fine-tuning, inference, and distillation. [[blog]](https://zhuanlan.zhihu.com/p/987727357)
|
1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**: A full pipeline for RAG retrieval model fine-tuning, inference, and distillation. [[blog]](https://zhuanlan.zhihu.com/p/987727357)
|
||||||
1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**: A modified library that supports long sequence SFT & DPO using ring attention.
|
1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**: A modified library that supports long sequence SFT & DPO using ring attention.
|
||||||
1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**: An o1-like model fine-tuned by NovaSky AI with very small cost.
|
1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**: An o1-like model fine-tuned by NovaSky AI with very small cost.
|
||||||
|
|||||||
109
README_zh.md
109
README_zh.md
@@ -1,9 +1,9 @@
|
|||||||

|

|
||||||
|
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/stargazers)
|
[](https://github.com/hiyouga/LlamaFactory/stargazers)
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/commits/main)
|
[](https://github.com/hiyouga/LlamaFactory/commits/main)
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors)
|
[](https://github.com/hiyouga/LlamaFactory/graphs/contributors)
|
||||||
[](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml)
|
[](https://github.com/hiyouga/LlamaFactory/actions/workflows/tests.yml)
|
||||||
[](https://pypi.org/project/llamafactory/)
|
[](https://pypi.org/project/llamafactory/)
|
||||||
[](https://scholar.google.com/scholar?cites=12620864006390196564)
|
[](https://scholar.google.com/scholar?cites=12620864006390196564)
|
||||||
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
|
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
|
||||||
@@ -86,7 +86,7 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
- [数据集](#数据集)
|
- [数据集](#数据集)
|
||||||
- [软硬件依赖](#软硬件依赖)
|
- [软硬件依赖](#软硬件依赖)
|
||||||
- [如何使用](#如何使用)
|
- [如何使用](#如何使用)
|
||||||
- [安装 LLaMA Factory](#安装-llama-factory)
|
- [安装 LlamaFactory](#安装-llamafactory)
|
||||||
- [数据准备](#数据准备)
|
- [数据准备](#数据准备)
|
||||||
- [快速开始](#快速开始)
|
- [快速开始](#快速开始)
|
||||||
- [LLaMA Board 可视化微调](#llama-board-可视化微调由-gradio-驱动)
|
- [LLaMA Board 可视化微调](#llama-board-可视化微调由-gradio-驱动)
|
||||||
@@ -96,7 +96,7 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
- [从魔乐社区下载](#从魔乐社区下载)
|
- [从魔乐社区下载](#从魔乐社区下载)
|
||||||
- [使用 W&B 面板](#使用-wb-面板)
|
- [使用 W&B 面板](#使用-wb-面板)
|
||||||
- [使用 SwanLab 面板](#使用-swanlab-面板)
|
- [使用 SwanLab 面板](#使用-swanlab-面板)
|
||||||
- [使用了 LLaMA Factory 的项目](#使用了-llama-factory-的项目)
|
- [使用了 LlamaFactory 的项目](#使用了-llamafactory-的项目)
|
||||||
- [协议](#协议)
|
- [协议](#协议)
|
||||||
- [引用](#引用)
|
- [引用](#引用)
|
||||||
- [致谢](#致谢)
|
- [致谢](#致谢)
|
||||||
@@ -122,35 +122,35 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
## 官方博客
|
## 官方博客
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 我们现在拥有了 LLaMA Factory 的专属博客!
|
> 我们现在拥有了 LlamaFactory 的专属博客!
|
||||||
>
|
>
|
||||||
> 网站地址:https://blog.llamafactory.net/
|
> 网站地址:https://blog.llamafactory.net/
|
||||||
|
|
||||||
- 💡 [KTransformers Fine-Tuning × LLaMA Factory: 用2张4090级的GPU+CPU 微调 1000B规模的超大模型](https://swcil84qspu.feishu.cn/wiki/Z1sSwb2poijybxkyPEkcDG6enVc) (中文)
|
- 💡 [KTransformers Fine-Tuning × LlamaFactory: 用2张4090级的GPU+CPU 微调 1000B规模的超大模型](https://swcil84qspu.feishu.cn/wiki/Z1sSwb2poijybxkyPEkcDG6enVc) (中文)
|
||||||
- 💡 [Easy Dataset × LLaMA Factory: 让大模型高效学习领域知识](https://buaa-act.feishu.cn/wiki/KY9xwTGs1iqHrRkjXBwcZP9WnL9)(中文)
|
- 💡 [Easy Dataset × LlamaFactory: 让大模型高效学习领域知识](https://buaa-act.feishu.cn/wiki/KY9xwTGs1iqHrRkjXBwcZP9WnL9)(中文)
|
||||||
- 💡 [DataFlow × LLaMA Factory: 利用数据准备流水线产出高质量数据训练 LLM](https://wcny4qa9krto.feishu.cn/wiki/LlMxweUAJimrmykRD5qcGuswnHd)(中文)| [English](https://wcny4qa9krto.feishu.cn/wiki/LWkkwTDBfiiRKqkDSvucG6yjnbW)
|
- 💡 [DataFlow × LlamaFactory: 利用数据准备流水线产出高质量数据训练 LLM](https://wcny4qa9krto.feishu.cn/wiki/LlMxweUAJimrmykRD5qcGuswnHd)(中文)| [English](https://wcny4qa9krto.feishu.cn/wiki/LWkkwTDBfiiRKqkDSvucG6yjnbW)
|
||||||
- 💡 [DataFlex × LLaMA Factory: 构建在 LLaMA-Factory 之上的以数据为中心的动态训练系统](https://wcny4qa9krto.feishu.cn/wiki/H2A9wSsbCinzavkT2oyc2C5Vn0e)(中文)| [English](https://wcny4qa9krto.feishu.cn/wiki/OlREwPQWdi9K6ZkJNHIciLhtnkv)
|
- 💡 [DataFlex × LlamaFactory: 构建在 LlamaFactory 之上的以数据为中心的动态训练系统](https://wcny4qa9krto.feishu.cn/wiki/H2A9wSsbCinzavkT2oyc2C5Vn0e)(中文)| [English](https://wcny4qa9krto.feishu.cn/wiki/OlREwPQWdi9K6ZkJNHIciLhtnkv)
|
||||||
- [基于 LLaMA-Factory 和 EasyR1 打造一站式无代码大模型强化学习和部署平台 LLM Model Hub](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/)(中文)
|
- [基于 LlamaFactory 和 EasyR1 打造一站式无代码大模型强化学习和部署平台 LLM Model Hub](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/)(中文)
|
||||||
- [通过亚马逊 SageMaker HyperPod 上的 LLaMA-Factory 增强多模态模型银行文档的视觉信息提取](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/)(英文)
|
- [通过亚马逊 SageMaker HyperPod 上的 LlamaFactory 增强多模态模型银行文档的视觉信息提取](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/)(英文)
|
||||||
|
|
||||||
<details><summary>全部博客</summary>
|
<details><summary>全部博客</summary>
|
||||||
|
|
||||||
- [LLaMA Factory:微调 DeepSeek-R1-Distill-Qwen-7B 模型实现新闻标题分类器](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b)(中文)
|
- [LlamaFactory:微调 DeepSeek-R1-Distill-Qwen-7B 模型实现新闻标题分类器](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b)(中文)
|
||||||
- [基于 Amazon SageMaker 和 LLaMA-Factory 打造一站式无代码模型微调部署平台 Model Hub](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/)(中文)
|
- [基于 Amazon SageMaker 和 LlamaFactory 打造一站式无代码模型微调部署平台 Model Hub](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/)(中文)
|
||||||
- [LLaMA Factory 多模态微调实践:微调 Qwen2-VL 构建文旅大模型](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl)(中文)
|
- [LlamaFactory 多模态微调实践:微调 Qwen2-VL 构建文旅大模型](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl)(中文)
|
||||||
- [LLaMA Factory:微调 Llama3 模型实现角色扮演](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)(中文)
|
- [LlamaFactory:微调 Llama3 模型实现角色扮演](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)(中文)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
[25/10/26] 我们支持了Megatron-core作为训练后端和适配了[**mcore_adapter**](https://github.com/alibaba/ROLL/tree/main/mcore_adapter)。查看[PR #9237](https://github.com/hiyouga/LLaMA-Factory/pull/9237)以使用。
|
[25/10/26] 我们支持了Megatron-core作为训练后端和适配了[**mcore_adapter**](https://github.com/alibaba/ROLL/tree/main/mcore_adapter)。查看[PR #9237](https://github.com/hiyouga/LlamaFactory/pull/9237)以使用。
|
||||||
|
|
||||||
[25/08/22] 我们支持了 **[OFT](https://arxiv.org/abs/2306.07280)** 和 **[OFTv2](https://arxiv.org/abs/2506.19847)** 模型的微调。查看 [examples](examples/README.md) 以使用。
|
[25/08/22] 我们支持了 **[OFT](https://arxiv.org/abs/2306.07280)** 和 **[OFTv2](https://arxiv.org/abs/2506.19847)** 模型的微调。查看 [examples](examples/README.md) 以使用。
|
||||||
|
|
||||||
[25/08/20] 我们支持了 **[Intern-S1-mini](https://huggingface.co/internlm/Intern-S1-mini)** 模型的微调。查看 [PR #8976](https://github.com/hiyouga/LLaMA-Factory/pull/8976) 以使用。
|
[25/08/20] 我们支持了 **[Intern-S1-mini](https://huggingface.co/internlm/Intern-S1-mini)** 模型的微调。查看 [PR #8976](https://github.com/hiyouga/LlamaFactory/pull/8976) 以使用。
|
||||||
|
|
||||||
[25/08/06] 我们支持了 **[GPT-OSS](https://github.com/openai/gpt-oss)** 模型的微调。查看 [PR #8826](https://github.com/hiyouga/LLaMA-Factory/pull/8826) 以使用。
|
[25/08/06] 我们支持了 **[GPT-OSS](https://github.com/openai/gpt-oss)** 模型的微调。查看 [PR #8826](https://github.com/hiyouga/LlamaFactory/pull/8826) 以使用。
|
||||||
|
|
||||||
<details><summary>展开日志</summary>
|
<details><summary>展开日志</summary>
|
||||||
|
|
||||||
@@ -160,13 +160,13 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
|
|
||||||
[25/04/21] 我们支持了 **[Muon](https://github.com/KellerJordan/Muon)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@tianshijing](https://github.com/tianshijing) 的 PR。
|
[25/04/21] 我们支持了 **[Muon](https://github.com/KellerJordan/Muon)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@tianshijing](https://github.com/tianshijing) 的 PR。
|
||||||
|
|
||||||
[25/04/16] 我们支持了 **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** 模型的微调。查看 [PR #7258](https://github.com/hiyouga/LLaMA-Factory/pull/7258) 以使用。
|
[25/04/16] 我们支持了 **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** 模型的微调。查看 [PR #7258](https://github.com/hiyouga/LlamaFactory/pull/7258) 以使用。
|
||||||
|
|
||||||
[25/04/14] 我们支持了 **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** 和 **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** 模型的微调。
|
[25/04/14] 我们支持了 **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** 和 **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** 模型的微调。
|
||||||
|
|
||||||
[25/04/06] 我们支持了 **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** 模型的微调。查看 [PR #7611](https://github.com/hiyouga/LLaMA-Factory/pull/7611) 以使用。
|
[25/04/06] 我们支持了 **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** 模型的微调。查看 [PR #7611](https://github.com/hiyouga/LlamaFactory/pull/7611) 以使用。
|
||||||
|
|
||||||
[25/03/31] 我们支持了 **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** 模型的微调。查看 [PR #7537](https://github.com/hiyouga/LLaMA-Factory/pull/7537) 以使用。
|
[25/03/31] 我们支持了 **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** 模型的微调。查看 [PR #7537](https://github.com/hiyouga/LlamaFactory/pull/7537) 以使用。
|
||||||
|
|
||||||
[25/03/15] 我们支持了 **[SGLang](https://github.com/sgl-project/sglang)** 推理后端,请使用 `infer_backend: sglang` 启用。
|
[25/03/15] 我们支持了 **[SGLang](https://github.com/sgl-project/sglang)** 推理后端,请使用 `infer_backend: sglang` 启用。
|
||||||
|
|
||||||
@@ -214,17 +214,17 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
|
|
||||||
[24/05/18] 我们支持了 **[KTO](https://arxiv.org/abs/2402.01306)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。
|
[24/05/18] 我们支持了 **[KTO](https://arxiv.org/abs/2402.01306)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。
|
||||||
|
|
||||||
[24/05/14] 我们支持了昇腾 NPU 设备的训练和推理。详情请查阅[安装](#安装-llama-factory)部分。
|
[24/05/14] 我们支持了昇腾 NPU 设备的训练和推理。详情请查阅[安装](#安装-llamafactory)部分。
|
||||||
|
|
||||||
[24/04/26] 我们支持了多模态模型 **LLaVA-1.5** 的微调。详细用法请参照 [examples](examples/README_zh.md)。
|
[24/04/26] 我们支持了多模态模型 **LLaVA-1.5** 的微调。详细用法请参照 [examples](examples/README_zh.md)。
|
||||||
|
|
||||||
[24/04/22] 我们提供了在免费 T4 GPU 上微调 Llama-3 模型的 **[Colab 笔记本](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing)**。Hugging Face 社区公开了两个利用 LLaMA Factory 微调的 Llama-3 模型,详情请见 [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) 和 [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese)。
|
[24/04/22] 我们提供了在免费 T4 GPU 上微调 Llama-3 模型的 **[Colab 笔记本](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing)**。Hugging Face 社区公开了两个利用 LlamaFactory 微调的 Llama-3 模型,详情请见 [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) 和 [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese)。
|
||||||
|
|
||||||
[24/04/21] 我们基于 [AstraMindAI 的仓库](https://github.com/astramind-ai/Mixture-of-depths)支持了 **[混合深度训练](https://arxiv.org/abs/2404.02258)**。详细用法请参照 [examples](examples/README_zh.md)。
|
[24/04/21] 我们基于 [AstraMindAI 的仓库](https://github.com/astramind-ai/Mixture-of-depths)支持了 **[混合深度训练](https://arxiv.org/abs/2404.02258)**。详细用法请参照 [examples](examples/README_zh.md)。
|
||||||
|
|
||||||
[24/04/16] 我们支持了 **[BAdam](https://arxiv.org/abs/2404.02827)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。
|
[24/04/16] 我们支持了 **[BAdam](https://arxiv.org/abs/2404.02827)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。
|
||||||
|
|
||||||
[24/04/16] 我们支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的长序列训练(24GB 可训练 Llama-2-7B-56k)。该方法相比 FlashAttention-2 提供了 **117%** 的训练速度和 **50%** 的显存节约。更多数据请见[此页面](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison)。
|
[24/04/16] 我们支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的长序列训练(24GB 可训练 Llama-2-7B-56k)。该方法相比 FlashAttention-2 提供了 **117%** 的训练速度和 **50%** 的显存节约。更多数据请见[此页面](https://github.com/hiyouga/LlamaFactory/wiki/Performance-comparison)。
|
||||||
|
|
||||||
[24/03/31] 我们支持了 **[ORPO](https://arxiv.org/abs/2403.07691)**。详细用法请参照 [examples](examples/README_zh.md)。
|
[24/03/31] 我们支持了 **[ORPO](https://arxiv.org/abs/2403.07691)**。详细用法请参照 [examples](examples/README_zh.md)。
|
||||||
|
|
||||||
@@ -242,11 +242,11 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
|
|
||||||
[24/02/15] 我们支持了 [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro) 提出的**块扩展**方法。详细用法请参照 [examples](examples/README_zh.md)。
|
[24/02/15] 我们支持了 [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro) 提出的**块扩展**方法。详细用法请参照 [examples](examples/README_zh.md)。
|
||||||
|
|
||||||
[24/02/05] Qwen1.5(Qwen2 测试版)系列模型已在 LLaMA-Factory 中实现微调支持。详情请查阅该[博客页面](https://qwenlm.github.io/zh/blog/qwen1.5/)。
|
[24/02/05] Qwen1.5(Qwen2 测试版)系列模型已在 LlamaFactory 中实现微调支持。详情请查阅该[博客页面](https://qwenlm.github.io/zh/blog/qwen1.5/)。
|
||||||
|
|
||||||
[24/01/18] 我们针对绝大多数模型实现了 **Agent 微调**,微调时指定 `dataset: glaive_toolcall_zh` 即可使模型获得工具调用能力。
|
[24/01/18] 我们针对绝大多数模型实现了 **Agent 微调**,微调时指定 `dataset: glaive_toolcall_zh` 即可使模型获得工具调用能力。
|
||||||
|
|
||||||
[23/12/23] 我们针对 LLaMA, Mistral 和 Yi 模型支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的 LoRA 训练加速。请使用 `use_unsloth: true` 参数启用 unsloth 优化。该方法可提供 **170%** 的训练速度,详情请查阅[此页面](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison)。
|
[23/12/23] 我们针对 LLaMA, Mistral 和 Yi 模型支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的 LoRA 训练加速。请使用 `use_unsloth: true` 参数启用 unsloth 优化。该方法可提供 **170%** 的训练速度,详情请查阅[此页面](https://github.com/hiyouga/LlamaFactory/wiki/Performance-comparison)。
|
||||||
|
|
||||||
[23/12/12] 我们支持了微调最新的混合专家模型 **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)**。硬件需求请查阅[此处](#硬件依赖)。
|
[23/12/12] 我们支持了微调最新的混合专家模型 **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)**。硬件需求请查阅[此处](#硬件依赖)。
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 如果您无法使用最新的功能,请尝试重新拉取代码并再次安装 LLaMA-Factory。
|
> 如果您无法使用最新的功能,请尝试重新拉取代码并再次安装 LlamaFactory。
|
||||||
|
|
||||||
## 模型
|
## 模型
|
||||||
|
|
||||||
@@ -516,7 +516,7 @@ huggingface-cli login
|
|||||||
|
|
||||||
## 如何使用
|
## 如何使用
|
||||||
|
|
||||||
### 安装 LLaMA Factory
|
### 安装 LlamaFactory
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> 此步骤为必需。
|
> 此步骤为必需。
|
||||||
@@ -605,22 +605,22 @@ pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/downl
|
|||||||
|
|
||||||
<details><summary>昇腾 NPU 用户指南</summary>
|
<details><summary>昇腾 NPU 用户指南</summary>
|
||||||
|
|
||||||
在昇腾 NPU 设备上安装 LLaMA Factory 时,请升级 Python 到 3.10 及以上,并需要指定额外依赖项,使用 `pip install -r requirements/npu.txt` 命令安装。此外,还需要安装 **Ascend CANN Toolkit 与 Kernels**,安装方法请参考[安装教程](https://llamafactory.readthedocs.io/zh-cn/latest/multibackend/npu/npu_installation.html)。
|
在昇腾 NPU 设备上安装 LlamaFactory 时,请使用 Python 3.12,并使用 `pip install -r requirements/npu.txt` 命令安装额外依赖项。此外,还需要安装 **Ascend CANN Toolkit 与 Kernels**,安装方法请参考[安装教程](https://llamafactory.readthedocs.io/zh-cn/latest/multibackend/npu/npu_installation.html)。
|
||||||
|
|
||||||
您可以直接下载预安装的最新docker镜像:
|
您可以直接下载预安装的最新docker镜像:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Docker Hub
|
# Docker Hub
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
docker pull hiyouga/llamafactory:latest-910b-ubuntu
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-ubuntu-py3.11
|
docker pull hiyouga/llamafactory:latest-a3-ubuntu
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-openeuler-py3.11
|
docker pull hiyouga/llamafactory:latest-910b-openeuler
|
||||||
docker pull hiyouga/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-openeuler-py3.11
|
docker pull hiyouga/llamafactory:latest-a3-openeuler
|
||||||
|
|
||||||
# quay.io
|
# quay.io
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-910b-ubuntu
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-ubuntu-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-a3-ubuntu
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-openeuler-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-910b-openeuler
|
||||||
docker pull quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A3-openeuler-py3.11
|
docker pull quay.io/ascend/llamafactory:latest-a3-openeuler
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 安装 BitsAndBytes
|
#### 安装 BitsAndBytes
|
||||||
@@ -683,7 +683,7 @@ llamafactory-cli export examples/merge_lora/qwen3_lora_sft.yaml
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 使用 `llamafactory-cli help` 显示帮助信息。
|
> 使用 `llamafactory-cli help` 显示帮助信息。
|
||||||
>
|
>
|
||||||
> 遇到报错请先看[常见问题](https://github.com/hiyouga/LLaMA-Factory/issues/4614)。
|
> 遇到报错请先看[常见问题](https://github.com/hiyouga/LlamaFactory/issues/4614)。
|
||||||
|
|
||||||
### LLaMA Board 可视化微调(由 [Gradio](https://github.com/gradio-app/gradio) 驱动)
|
### LLaMA Board 可视化微调(由 [Gradio](https://github.com/gradio-app/gradio) 驱动)
|
||||||
|
|
||||||
@@ -701,28 +701,26 @@ docker compose up -d
|
|||||||
docker compose exec llamafactory bash
|
docker compose exec llamafactory bash
|
||||||
```
|
```
|
||||||
|
|
||||||
昇腾 NPU 用户(默认使用 A2 和 Ubuntu):
|
昇腾 NPU 用户:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd docker/docker-npu/
|
cd docker/docker-npu/
|
||||||
docker compose up -d llamafactory-a2-ubuntu
|
|
||||||
docker compose exec llamafactory-a2-ubuntu bash
|
|
||||||
```
|
|
||||||
|
|
||||||
其他 NPU 组合可以通过对应的 profile 和服务启动:
|
# A2 + Ubuntu
|
||||||
|
docker compose --profile a2-ubuntu up -d
|
||||||
|
docker compose --profile a2-ubuntu exec llamafactory-a2-ubuntu bash
|
||||||
|
|
||||||
```bash
|
|
||||||
# A3 + Ubuntu
|
# A3 + Ubuntu
|
||||||
docker compose --profile a3 up -d llamafactory-a3-ubuntu
|
docker compose --profile a3-ubuntu up -d
|
||||||
docker compose exec llamafactory-a3-ubuntu bash
|
docker compose --profile a3-ubuntu exec llamafactory-a3-ubuntu bash
|
||||||
|
|
||||||
# A2 + openEuler
|
# A2 + openEuler
|
||||||
docker compose --profile openeuler up -d llamafactory-a2-openeuler
|
docker compose --profile a2-openeuler up -d
|
||||||
docker compose exec llamafactory-a2-openeuler bash
|
docker compose --profile a2-openeuler exec llamafactory-a2-openeuler bash
|
||||||
|
|
||||||
# A3 + openEuler
|
# A3 + openEuler
|
||||||
docker compose --profile a3-openeuler up -d llamafactory-a3-openeuler
|
docker compose --profile a3-openeuler up -d
|
||||||
docker compose exec llamafactory-a3-openeuler bash
|
docker compose --profile a3-openeuler exec llamafactory-a3-openeuler bash
|
||||||
```
|
```
|
||||||
|
|
||||||
AMD ROCm 用户:
|
AMD ROCm 用户:
|
||||||
@@ -757,7 +755,6 @@ docker exec -it llamafactory bash
|
|||||||
```bash
|
```bash
|
||||||
docker build -f ./docker/docker-npu/Dockerfile \
|
docker build -f ./docker/docker-npu/Dockerfile \
|
||||||
--build-arg PIP_INDEX=https://pypi.org/simple \
|
--build-arg PIP_INDEX=https://pypi.org/simple \
|
||||||
--build-arg EXTRAS=torch-npu,metrics \
|
|
||||||
-t llamafactory:latest .
|
-t llamafactory:latest .
|
||||||
|
|
||||||
docker run -dit --ipc=host \
|
docker run -dit --ipc=host \
|
||||||
@@ -867,7 +864,7 @@ swanlab_run_name: test_run # 可选
|
|||||||
方式二:将环境变量 `SWANLAB_API_KEY` 设置为你的 [API 密钥](https://swanlab.cn/settings)。
|
方式二:将环境变量 `SWANLAB_API_KEY` 设置为你的 [API 密钥](https://swanlab.cn/settings)。
|
||||||
方式三:启动前使用 `swanlab login` 命令完成登录。
|
方式三:启动前使用 `swanlab login` 命令完成登录。
|
||||||
|
|
||||||
## 使用了 LLaMA Factory 的项目
|
## 使用了 LlamaFactory 的项目
|
||||||
|
|
||||||
如果您有项目希望添加至下述列表,请通过邮件联系或者创建一个 PR。
|
如果您有项目希望添加至下述列表,请通过邮件联系或者创建一个 PR。
|
||||||
|
|
||||||
@@ -964,7 +961,7 @@ swanlab_run_name: test_run # 可选
|
|||||||
1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**:中文多模态医学大模型,基于 LLaVA-1.5-7B 在中文多模态医疗数据上微调而得。
|
1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**:中文多模态医学大模型,基于 LLaVA-1.5-7B 在中文多模态医疗数据上微调而得。
|
||||||
1. **[AutoRE](https://github.com/THUDM/AutoRE)**:基于大语言模型的文档级关系抽取系统。
|
1. **[AutoRE](https://github.com/THUDM/AutoRE)**:基于大语言模型的文档级关系抽取系统。
|
||||||
1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**:在 Windows 主机上利用英伟达 RTX 设备进行大型语言模型微调的开发包。
|
1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**:在 Windows 主机上利用英伟达 RTX 设备进行大型语言模型微调的开发包。
|
||||||
1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**:一个低代码构建多 Agent 大模型应用的开发工具,支持基于 LLaMA Factory 的模型微调.
|
1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**:一个低代码构建多 Agent 大模型应用的开发工具,支持基于 LlamaFactory 的模型微调.
|
||||||
1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**:一个全链路 RAG 检索模型微调、推理和蒸馏代码库。[[blog]](https://zhuanlan.zhihu.com/p/987727357)
|
1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**:一个全链路 RAG 检索模型微调、推理和蒸馏代码库。[[blog]](https://zhuanlan.zhihu.com/p/987727357)
|
||||||
1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**:一个魔改后的代码库,通过 Ring Attention 支持长序列的 SFT 和 DPO 训练。
|
1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**:一个魔改后的代码库,通过 Ring Attention 支持长序列的 SFT 和 DPO 训练。
|
||||||
1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**:由 NovaSky AI 微调的低成本类 o1 长推理模型。
|
1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**:由 NovaSky AI 微调的低成本类 o1 长推理模型。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# https://hub.docker.com/r/ascendai/cann/tags
|
# https://hub.docker.com/r/ascendai/cann/tags
|
||||||
|
|
||||||
ARG BASE_IMAGE=quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11
|
ARG BASE_IMAGE=quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
# Installation arguments
|
# Installation arguments
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# LLaMA Factory for Ascend NPU
|
# LlamaFactory Image for Ascend NPU
|
||||||
|
|
||||||
LLaMA Factory Ascend NPU images provide a ready-to-use environment for fine-tuning, evaluating, and serving large language and multimodal models on Huawei Ascend Atlas NPUs. The images are based on Ascend CANN container images and include LLaMA Factory, Python, PyTorch, torch-npu, Triton Ascend, DeepSpeed, and the metric dependencies used by LLaMA Factory.
|
LlamaFactory Ascend NPU images are designed for Huawei Ascend Atlas NPUs and provide a ready-to-use LlamaFactory environment. Built on Ascend CANN container images, they include Python, PyTorch, TorchNPU, DeepSpeed, LlamaFactory, and other components.
|
||||||
|
|
||||||
For installation and troubleshooting details, see the [English NPU installation guide](https://llamafactory.readthedocs.io/en/latest/multibackend/npu/npu_installation.html).
|
For installation and troubleshooting details, see the [English NPU installation guide](https://llamafactory.readthedocs.io/en/latest/multibackend/npu/npu_installation.html).
|
||||||
|
|
||||||
@@ -11,77 +11,68 @@ For installation and troubleshooting details, see the [English NPU installation
|
|||||||
- `quay.io/ascend/llamafactory`
|
- `quay.io/ascend/llamafactory`
|
||||||
- Dockerfile: `docker/docker-npu/Dockerfile`
|
- Dockerfile: `docker/docker-npu/Dockerfile`
|
||||||
- Docker Compose file: `docker/docker-npu/docker-compose.yml`
|
- Docker Compose file: `docker/docker-npu/docker-compose.yml`
|
||||||
- Default base image: `quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11`
|
|
||||||
- Supported accelerators: Ascend A2 and A3
|
|
||||||
- Supported container operating systems: Ubuntu 22.04 and openEuler 24.03
|
|
||||||
- Target CPU architectures: `linux/amd64` and `linux/arm64`
|
|
||||||
- Exposed ports:
|
|
||||||
- `7860`: LLaMA Board Web UI
|
|
||||||
- `8000`: API service
|
|
||||||
- Ascend environment script: `/usr/local/Ascend/ascend-toolkit/set_env.sh`
|
|
||||||
|
|
||||||
The current image variants are:
|
The following `latest` NPU image tags are available:
|
||||||
|
|
||||||
| Accelerator | Container OS | CANN base image |
|
| Hardware series | Operating system | Tag |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| A2 | Ubuntu 22.04 | `quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11` |
|
| A2 | Ubuntu 22.04 | `latest-910b-ubuntu` |
|
||||||
| A3 | Ubuntu 22.04 | `quay.io/ascend/cann:9.0.0-a3-ubuntu22.04-py3.11` |
|
| A3 | Ubuntu 22.04 | `latest-a3-ubuntu` |
|
||||||
| A2 | openEuler 24.03 | `quay.io/ascend/cann:9.0.0-910b-openeuler24.03-py3.11` |
|
| A2 | openEuler 24.03 | `latest-910b-openeuler` |
|
||||||
| A3 | openEuler 24.03 | `quay.io/ascend/cann:9.0.0-a3-openeuler24.03-py3.11` |
|
| A3 | openEuler 24.03 | `latest-a3-openeuler` |
|
||||||
|
|
||||||
## Image Contents and Intended Use
|
## Image Overview
|
||||||
|
|
||||||
The image is intended for Ascend NPU training, fine-tuning, evaluation, Web UI, and API workflows supported by LLaMA Factory. It installs the following core components:
|
The image includes the following core components:
|
||||||
|
|
||||||
| Component | Version or source |
|
| Component | Version |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| CANN | Inherited from the selected CANN 9.0.0 base image |
|
| CANN | `9.1.0` |
|
||||||
| Python | Python 3.11, inherited from the base image |
|
| Python | `3.12` |
|
||||||
| PyTorch | `2.7.1` |
|
| PyTorch | `2.10.0` |
|
||||||
| torch-npu | `2.7.1.post4` |
|
| TorchNPU | `2.10.0.post2` |
|
||||||
| torchvision | `0.22.1` |
|
| torchvision / torchaudio | `0.25.0` / `2.10.0` |
|
||||||
| torchaudio | `2.7.1` |
|
| Transformers | Latest compatible version at build time |
|
||||||
| Triton Ascend | `3.2.1` |
|
| Triton Ascend | `3.2.1` |
|
||||||
| DeepSpeed | `>=0.10.0,<=0.18.4` |
|
| DeepSpeed | Latest compatible version at build time |
|
||||||
| LLaMA Factory | Installed from the repository build context |
|
| LlamaFactory | Installed from the repository build context |
|
||||||
|
|
||||||
The image does not include model weights or datasets. Mount or download them separately and comply with their respective licenses and acceptable-use requirements.
|
The image does not include model weights or datasets. Mount or download them separately and comply with their respective licenses and acceptable-use requirements.
|
||||||
|
|
||||||
## Image Tags and Dockerfile Archive
|
## Image Tags
|
||||||
|
|
||||||
Images use the following tag format:
|
NPU `latest` and release tags use different formats; the following rules do not apply to CUDA images.
|
||||||
|
|
||||||
|
Non-release builds reuse the following short tags. Each scheduled build updates the image referenced by the corresponding tag:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
<llamafactory-version>-cann<cann-version>-torch_npu<torch-npu-version>-<accelerator>-<os>-<python-version>
|
latest-<chip>-<os>
|
||||||
|
```
|
||||||
|
|
||||||
|
| Field | Values | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `chip` | `910b` or `a3` | Ascend chip model supported by the image |
|
||||||
|
| `os` | `ubuntu` or `openeuler` | Container operating system family |
|
||||||
|
|
||||||
|
Release builds use full tags:
|
||||||
|
|
||||||
|
```text
|
||||||
|
<LlamaFactory-version>-cann<CANN-version>-torch_npu<TorchNPU-version>-<chip>-<os>-<Python-version>
|
||||||
```
|
```
|
||||||
|
|
||||||
| Field | Example | Description |
|
| Field | Example | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `llamafactory-version` | `latest` or `0.9.6` | Non-release builds use `latest`; release builds use the LLaMA Factory version |
|
| `LlamaFactory-version` | `0.9.5` | LlamaFactory release version |
|
||||||
| `cann-version` | `9.0.0` | Parsed from the CANN base image tag |
|
| `CANN-version` | `9.1.0` | Parsed from the CANN base image tag |
|
||||||
| `torch-npu-version` | `2.7.1` | Parsed from `requirements/npu.txt`; a suffix such as `.post4` is not included in the image tag |
|
| `TorchNPU-version` | `2.10.0.post2` | Full TorchNPU version used by the image, including suffixes such as `.postN` |
|
||||||
| `accelerator` | `A2` or `A3` | Ascend hardware generation selected for the image |
|
| `chip` | `910b` or `a3` | Ascend chip model supported by the image |
|
||||||
| `os` | `ubuntu` or `openeuler` | Container operating system family |
|
| `os` | `ubuntu22.04` or `openeuler24.03` | Container operating system family and version |
|
||||||
| `python-version` | `py3.11` | Parsed from the CANN base image tag |
|
| `Python-version` | `py3.12` | Parsed from the CANN base image tag |
|
||||||
|
|
||||||
Examples:
|
For example:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
0.9.5-cann9.1.0-torch_npu2.10.0.post2-a3-ubuntu22.04-py3.12
|
||||||
latest-cann9.0.0-torch_npu2.7.1-A3-openeuler-py3.11
|
|
||||||
0.9.6-cann9.0.0-torch_npu2.7.1-A3-ubuntu-py3.11
|
|
||||||
```
|
|
||||||
|
|
||||||
The CPU architecture is not part of the tag. Published images are configured as multi-platform images, and Docker selects the `linux/amd64` or `linux/arm64` manifest for the host automatically.
|
|
||||||
|
|
||||||
The Dockerfile and its distribution overview are archived together at:
|
|
||||||
|
|
||||||
```text
|
|
||||||
docker/docker-npu/
|
|
||||||
├── Dockerfile
|
|
||||||
├── OVERVIEW.md
|
|
||||||
├── OVERVIEW.zh.md
|
|
||||||
└── docker-compose.yml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
@@ -94,33 +85,30 @@ Before starting a container:
|
|||||||
2. Verify that `npu-smi info` works on the host.
|
2. Verify that `npu-smi info` works on the host.
|
||||||
3. Install Docker with permission to access the required Ascend device nodes and driver files.
|
3. Install Docker with permission to access the required Ascend device nodes and driver files.
|
||||||
|
|
||||||
Driver, firmware, CANN, torch-npu, and the target Ascend hardware must be mutually compatible.
|
Driver, firmware, CANN, TorchNPU, and the target Ascend hardware must be mutually compatible.
|
||||||
|
|
||||||
### Pull and Run
|
### Pull and Run
|
||||||
|
|
||||||
The following example starts the latest A2 Ubuntu image with one NPU. Change the image tag and `/dev/davinci0` as needed.
|
The following example starts the latest A2 Ubuntu image with one NPU. Adjust `DOCKER_IMAGE` and the `--device` options for your environment.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export IMAGE=quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
CONTAINER_NAME=llamafactory-npu
|
||||||
|
DOCKER_IMAGE=hiyouga/llamafactory:latest-910b-ubuntu
|
||||||
docker pull "$IMAGE"
|
|
||||||
|
|
||||||
docker run --rm -it \
|
docker run --rm -it \
|
||||||
--name llamafactory-npu \
|
--net=host \
|
||||||
--ipc=host \
|
|
||||||
--device=/dev/davinci0 \
|
--device=/dev/davinci0 \
|
||||||
--device=/dev/davinci_manager \
|
--device=/dev/davinci_manager \
|
||||||
--device=/dev/devmm_svm \
|
--device=/dev/devmm_svm \
|
||||||
--device=/dev/hisi_hdc \
|
--device=/dev/hisi_hdc \
|
||||||
-v /usr/local/dcmi:/usr/local/dcmi \
|
|
||||||
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
||||||
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
|
-v /usr/local/dcmi:/usr/local/dcmi \
|
||||||
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
||||||
-v "$HOME/.cache/huggingface:/root/.cache/huggingface" \
|
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
|
||||||
-p 7860:7860 \
|
-v /data:/data \
|
||||||
-p 8000:8000 \
|
--name "$CONTAINER_NAME" \
|
||||||
"$IMAGE" \
|
"$DOCKER_IMAGE" \
|
||||||
bash
|
/bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
The host path for `npu-smi` may be `/usr/local/sbin/npu-smi` on some driver installations. Adjust the mount source when necessary. Add more `--device=/dev/davinci<N>` options to expose additional NPUs.
|
The host path for `npu-smi` may be `/usr/local/sbin/npu-smi` on some driver installations. Adjust the mount source when necessary. Add more `--device=/dev/davinci<N>` options to expose additional NPUs.
|
||||||
@@ -134,22 +122,16 @@ python -c "import torch, torch_npu; print(torch.__version__, torch_npu.__version
|
|||||||
llamafactory-cli help
|
llamafactory-cli help
|
||||||
```
|
```
|
||||||
|
|
||||||
Start LLaMA Board when needed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
llamafactory-cli webui
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build Locally
|
### Build Locally
|
||||||
|
|
||||||
Run the build from the repository root. The following example builds the A3 openEuler variant:
|
Run the build from the repository root. The following example builds the A2 Ubuntu variant:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build \
|
docker build \
|
||||||
-f ./docker/docker-npu/Dockerfile \
|
-f ./docker/docker-npu/Dockerfile \
|
||||||
--build-arg BASE_IMAGE=quay.io/ascend/cann:9.0.0-a3-openeuler24.03-py3.11 \
|
--build-arg BASE_IMAGE=quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12 \
|
||||||
--build-arg PIP_INDEX=https://pypi.org/simple \
|
--build-arg PIP_INDEX=https://pypi.org/simple \
|
||||||
-t llamafactory:npu-a3-openeuler \
|
-t llamafactory:npu-910b-ubuntu \
|
||||||
.
|
.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -157,76 +139,45 @@ Available build arguments:
|
|||||||
|
|
||||||
| Argument | Default | Purpose |
|
| Argument | Default | Purpose |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `BASE_IMAGE` | A2 Ubuntu CANN 9.0.0 image | Selects the accelerator and container OS variant |
|
| `BASE_IMAGE` | `quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12` | Selects the base image that matches the device model and container operating system |
|
||||||
| `PIP_INDEX` | `https://pypi.org/simple` | Selects the Python package index |
|
| `PIP_INDEX` | `https://pypi.org/simple` | Selects the Python package index |
|
||||||
| `PYTORCH_INDEX` | `https://download.pytorch.org/whl/cpu` | Selects the PyTorch wheel index used with torch-npu |
|
| `PYTORCH_INDEX` | `https://download.pytorch.org/whl/cpu` | Selects the PyTorch wheel index used with TorchNPU |
|
||||||
| `HTTP_PROXY` | Empty | Provides an optional HTTP/HTTPS proxy during the build |
|
| `HTTP_PROXY` | Empty | Provides an optional HTTP/HTTPS proxy during the build |
|
||||||
|
|
||||||
Docker Compose can build and start each supported variant:
|
### Start with Docker Compose
|
||||||
|
|
||||||
|
The preceding `docker build` command invokes the Dockerfile directly. It builds an image but does not start a container. Docker Compose does not use a separate build implementation: it reads the presets in `docker-compose.yml`, reuses the same Dockerfile, and selects a hardware-series and operating-system combination through a profile. Each `up -d` command below starts the selected container in the background. If the image is not available locally, Docker Compose builds it first:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd docker/docker-npu
|
cd docker/docker-npu
|
||||||
|
|
||||||
# A2 with Ubuntu
|
# A2 with Ubuntu
|
||||||
docker compose up -d llamafactory-a2-ubuntu
|
docker compose --profile a2-ubuntu up -d
|
||||||
|
|
||||||
# A3 with Ubuntu
|
# A3 with Ubuntu
|
||||||
docker compose --profile a3 up -d llamafactory-a3-ubuntu
|
docker compose --profile a3-ubuntu up -d
|
||||||
|
|
||||||
# A2 with openEuler
|
# A2 with openEuler
|
||||||
docker compose --profile openeuler up -d llamafactory-a2-openeuler
|
docker compose --profile a2-openeuler up -d
|
||||||
|
|
||||||
# A3 with openEuler
|
# A3 with openEuler
|
||||||
docker compose --profile a3-openeuler up -d llamafactory-a3-openeuler
|
docker compose --profile a3-openeuler up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### Extend or Develop from the Image
|
To build an image with Docker Compose without starting a container, use `docker compose --profile <profile> build`.
|
||||||
|
|
||||||
For interactive development, mount a local checkout and reinstall it in editable mode inside the container:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/hiyouga/LLaMA-Factory.git
|
|
||||||
cd LLaMA-Factory
|
|
||||||
|
|
||||||
# Add the same Ascend --device and driver mount options shown above.
|
|
||||||
docker run --rm -it \
|
|
||||||
--ipc=host \
|
|
||||||
-v "$PWD:/workspace/LLaMA-Factory" \
|
|
||||||
-w /workspace/LLaMA-Factory \
|
|
||||||
"$IMAGE" \
|
|
||||||
bash
|
|
||||||
|
|
||||||
pip install -e . --no-build-isolation
|
|
||||||
```
|
|
||||||
|
|
||||||
For a reproducible derived image, create a separate Dockerfile:
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
FROM quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
|
||||||
|
|
||||||
COPY requirements-extension.txt /tmp/requirements-extension.txt
|
|
||||||
RUN pip install --no-cache-dir -r /tmp/requirements-extension.txt
|
|
||||||
|
|
||||||
COPY . /workspace/application
|
|
||||||
WORKDIR /workspace/application
|
|
||||||
```
|
|
||||||
|
|
||||||
Pass Ascend devices and driver mounts when running the derived image; device access should not be embedded in the image itself.
|
|
||||||
|
|
||||||
## Hardware Support and Compatibility Notes
|
## Hardware Support and Compatibility Notes
|
||||||
|
|
||||||
- A2 images use the `910b` CANN base image; A3 images use the `a3` CANN base image.
|
- A2 images use the `910b` CANN base image; A3 images use the `a3` CANN base image.
|
||||||
- The image build targets both x86-64 (`linux/amd64`) and AArch64 (`linux/arm64`) hosts. This CPU architecture is independent of whether the accelerator is A2 or A3.
|
- The image build targets both x86-64 (`linux/amd64`) and AArch64 (`linux/arm64`) hosts. The CPU architecture is independent of whether the hardware series is A2 or A3.
|
||||||
- Ubuntu 22.04 and openEuler 24.03 refer to the operating system inside the container.
|
- Ubuntu 22.04 and openEuler 24.03 refer to the operating system inside the container.
|
||||||
- The current dependency baseline aligns PyTorch `2.7.1` with torch-npu `2.7.1.post4`. Upgrading either package independently may break compatibility.
|
- Legacy NPU tags are replaced by the `latest-<910b|a3>-<ubuntu|openeuler>` format.
|
||||||
- Use a fixed release tag for reproducible production deployments. The `latest` tag can change after scheduled builds.
|
|
||||||
- Legacy short tags such as `latest-npu-a2` do not encode the CANN, torch-npu, operating system, or Python versions. Prefer the full tag format documented above.
|
|
||||||
- Validate the exact driver, firmware, CANN, and SoC combination before production deployment.
|
- Validate the exact driver, firmware, CANN, and SoC combination before production deployment.
|
||||||
|
|
||||||
## License and Disclaimer
|
## License and Disclaimer
|
||||||
|
|
||||||
LLaMA Factory is distributed under the [Apache License 2.0](../../LICENSE).
|
LlamaFactory is distributed under the [Apache License 2.0](../../LICENSE).
|
||||||
|
|
||||||
Ascend CANN, torch-npu, Triton Ascend, DeepSpeed, base operating-system packages, model weights, datasets, and other third-party components are governed by their respective licenses and terms. The LLaMA Factory license does not replace or override those terms.
|
Ascend CANN, TorchNPU, Triton Ascend, DeepSpeed, base operating-system packages, model weights, datasets, and other third-party components are governed by their respective licenses and terms. The LlamaFactory license does not replace or override those terms.
|
||||||
|
|
||||||
The image is provided on an "AS IS" basis, without warranties or conditions of any kind. Users are responsible for validating hardware and software compatibility, securing the container and its runtime configuration, complying with applicable licenses and laws, and reviewing model and dataset terms before training, evaluation, or deployment.
|
The image is provided on an "AS IS" basis, without warranties or conditions of any kind. Users are responsible for validating hardware and software compatibility, securing the container and its runtime configuration, complying with applicable licenses and laws, and reviewing model and dataset terms before training, evaluation, or deployment.
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# 面向昇腾 NPU 的 LLaMA Factory 镜像
|
# 面向昇腾 NPU 的 LlamaFactory 镜像
|
||||||
|
|
||||||
LLaMA Factory 昇腾 NPU 镜像面向华为昇腾 Atlas NPU,提供可直接用于大语言模型和多模态模型微调、评测与服务部署的运行环境。镜像基于昇腾 CANN 容器镜像构建,预装 LLaMA Factory、Python、PyTorch、torch-npu、Triton Ascend、DeepSpeed 和 LLaMA Factory 评测依赖。
|
LlamaFactory 昇腾 NPU 镜像面向华为昇腾 Atlas NPU,提供可直接使用的 LlamaFactory 环境。镜像基于昇腾 CANN 容器镜像构建,预装 Python、PyTorch、TorchNPU、DeepSpeed、LlamaFactory 等组件。
|
||||||
|
|
||||||
安装方法和问题排查请参考 [LLaMA Factory NPU 安装及配置文档](https://llamafactory.readthedocs.io/zh-cn/latest/multibackend/npu/npu_installation.html)。
|
安装方法和问题排查请参考 [LlamaFactory NPU 安装及配置文档](https://llamafactory.readthedocs.io/zh-cn/latest/multibackend/npu/npu_installation.html)。
|
||||||
|
|
||||||
## 快速参考
|
## 快速参考
|
||||||
|
|
||||||
@@ -11,77 +11,68 @@ LLaMA Factory 昇腾 NPU 镜像面向华为昇腾 Atlas NPU,提供可直接用
|
|||||||
- `quay.io/ascend/llamafactory`
|
- `quay.io/ascend/llamafactory`
|
||||||
- Dockerfile:`docker/docker-npu/Dockerfile`
|
- Dockerfile:`docker/docker-npu/Dockerfile`
|
||||||
- Docker Compose 文件:`docker/docker-npu/docker-compose.yml`
|
- Docker Compose 文件:`docker/docker-npu/docker-compose.yml`
|
||||||
- 默认基础镜像:`quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11`
|
|
||||||
- 支持的加速器:昇腾 A2、A3
|
|
||||||
- 支持的容器操作系统:Ubuntu 22.04、openEuler 24.03
|
|
||||||
- 目标 CPU 架构:`linux/amd64`、`linux/arm64`
|
|
||||||
- 对外端口:
|
|
||||||
- `7860`:LLaMA Board Web UI
|
|
||||||
- `8000`:API 服务
|
|
||||||
- 昇腾环境脚本:`/usr/local/Ascend/ascend-toolkit/set_env.sh`
|
|
||||||
|
|
||||||
当前提供以下镜像组合:
|
当前提供以下 `latest` NPU 镜像 tag:
|
||||||
|
|
||||||
| 加速器 | 容器操作系统 | CANN 基础镜像 |
|
| 硬件系列 | 操作系统 | Tag |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| A2 | Ubuntu 22.04 | `quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11` |
|
| A2 | Ubuntu 22.04 | `latest-910b-ubuntu` |
|
||||||
| A3 | Ubuntu 22.04 | `quay.io/ascend/cann:9.0.0-a3-ubuntu22.04-py3.11` |
|
| A3 | Ubuntu 22.04 | `latest-a3-ubuntu` |
|
||||||
| A2 | openEuler 24.03 | `quay.io/ascend/cann:9.0.0-910b-openeuler24.03-py3.11` |
|
| A2 | openEuler 24.03 | `latest-910b-openeuler` |
|
||||||
| A3 | openEuler 24.03 | `quay.io/ascend/cann:9.0.0-a3-openeuler24.03-py3.11` |
|
| A3 | openEuler 24.03 | `latest-a3-openeuler` |
|
||||||
|
|
||||||
## 镜像介绍
|
## 镜像介绍
|
||||||
|
|
||||||
该镜像用于运行 LLaMA Factory 支持的昇腾 NPU 训练、微调、评测、Web UI 和 API 服务,主要包含以下组件:
|
镜像内预装以下主要组件:
|
||||||
|
|
||||||
| 组件 | 版本或来源 |
|
| 组件 | 版本 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| CANN | 继承自所选 CANN 9.0.0 基础镜像 |
|
| CANN | `9.1.0` |
|
||||||
| Python | Python 3.11,继承自基础镜像 |
|
| Python | `3.12` |
|
||||||
| PyTorch | `2.7.1` |
|
| PyTorch | `2.10.0` |
|
||||||
| torch-npu | `2.7.1.post4` |
|
| TorchNPU | `2.10.0.post2` |
|
||||||
| torchvision | `0.22.1` |
|
| torchvision / torchaudio | `0.25.0` / `2.10.0` |
|
||||||
| torchaudio | `2.7.1` |
|
| Transformers | 构建时的最新兼容版本 |
|
||||||
| Triton Ascend | `3.2.1` |
|
| Triton Ascend | `3.2.1` |
|
||||||
| DeepSpeed | `>=0.10.0,<=0.18.4` |
|
| DeepSpeed | 构建时的最新兼容版本 |
|
||||||
| LLaMA Factory | 从构建上下文中的仓库源码安装 |
|
| LlamaFactory | 从构建上下文中的仓库源码安装 |
|
||||||
|
|
||||||
镜像不包含模型权重和数据集。请通过目录挂载或运行时下载的方式单独提供,并遵守对应的许可证和使用要求。
|
镜像不包含模型权重和数据集。请通过目录挂载或运行时下载的方式单独提供,并遵守对应的许可证和使用要求。
|
||||||
|
|
||||||
## 镜像 Tag 说明与 Dockerfile 归档路径
|
## 镜像 Tag 说明
|
||||||
|
|
||||||
镜像使用以下 tag 格式:
|
NPU 镜像的 `latest` 和 release tag 使用不同格式;以下规则不适用于 CUDA 镜像。
|
||||||
|
|
||||||
|
非 release 构建复用以下简短 tag,每次定时构建会更新对应 tag 所指向的镜像:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
<llamafactory版本>-cann<CANN版本>-torch_npu<torch-npu版本>-<加速器>-<操作系统>-<Python版本>
|
latest-<芯片信息>-<操作系统>
|
||||||
|
```
|
||||||
|
|
||||||
|
| 字段 | 可选值 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `芯片信息` | `910b` 或 `a3` | 镜像所适配的昇腾芯片型号 |
|
||||||
|
| `操作系统` | `ubuntu` 或 `openeuler` | 容器操作系统类型 |
|
||||||
|
|
||||||
|
Release 构建使用完整 tag:
|
||||||
|
|
||||||
|
```text
|
||||||
|
<LlamaFactory版本>-cann<CANN版本>-torch_npu<TorchNPU版本>-<芯片信息>-<操作系统>-<Python版本>
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 示例 | 说明 |
|
| 字段 | 示例 | 说明 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `llamafactory版本` | `latest` 或 `0.9.6` | 非 release 构建使用 `latest`,release 构建使用 LLaMA Factory 版本号 |
|
| `LlamaFactory版本` | `0.9.5` | LlamaFactory release 版本号 |
|
||||||
| `CANN版本` | `9.0.0` | 从 CANN 基础镜像 tag 中提取 |
|
| `CANN版本` | `9.1.0` | 从 CANN 基础镜像 tag 中提取 |
|
||||||
| `torch-npu版本` | `2.7.1` | 从 `requirements/npu.txt` 中提取,镜像 tag 不包含 `.post4` 等后缀 |
|
| `TorchNPU版本` | `2.10.0.post2` | 镜像使用的 TorchNPU 完整版本,包含 `.postN` 等后缀 |
|
||||||
| `加速器` | `A2` 或 `A3` | 当前镜像所适配的昇腾硬件代际 |
|
| `芯片信息` | `910b` 或 `a3` | 镜像所适配的昇腾芯片型号 |
|
||||||
| `操作系统` | `ubuntu` 或 `openeuler` | 容器内操作系统类型 |
|
| `操作系统` | `ubuntu22.04` 或 `openeuler24.03` | 容器操作系统类型和版本 |
|
||||||
| `Python版本` | `py3.11` | 从 CANN 基础镜像 tag 中提取 |
|
| `Python版本` | `py3.12` | 从 CANN 基础镜像 tag 中提取 |
|
||||||
|
|
||||||
示例:
|
例如:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
0.9.5-cann9.1.0-torch_npu2.10.0.post2-a3-ubuntu22.04-py3.12
|
||||||
latest-cann9.0.0-torch_npu2.7.1-A3-openeuler-py3.11
|
|
||||||
0.9.6-cann9.0.0-torch_npu2.7.1-A3-ubuntu-py3.11
|
|
||||||
```
|
|
||||||
|
|
||||||
CPU 架构不写入 tag。发布镜像配置为多架构镜像,Docker 拉取时会根据宿主机自动选择 `linux/amd64` 或 `linux/arm64` 版本。
|
|
||||||
|
|
||||||
Dockerfile 和用于镜像分发的概述文件在同一目录归档:
|
|
||||||
|
|
||||||
```text
|
|
||||||
docker/docker-npu/
|
|
||||||
├── Dockerfile
|
|
||||||
├── OVERVIEW.md
|
|
||||||
├── OVERVIEW.zh.md
|
|
||||||
└── docker-compose.yml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 快速开始
|
## 快速开始
|
||||||
@@ -94,33 +85,30 @@ docker/docker-npu/
|
|||||||
2. 确认宿主机执行 `npu-smi info` 可以正常识别 NPU。
|
2. 确认宿主机执行 `npu-smi info` 可以正常识别 NPU。
|
||||||
3. 安装 Docker,并确保当前用户有权访问所需的昇腾设备节点和驱动文件。
|
3. 安装 Docker,并确保当前用户有权访问所需的昇腾设备节点和驱动文件。
|
||||||
|
|
||||||
驱动、固件、CANN、torch-npu 与目标昇腾硬件需要保持兼容。
|
驱动、固件、CANN、TorchNPU 与目标昇腾硬件需要保持兼容。
|
||||||
|
|
||||||
### 拉取并运行镜像
|
### 拉取并运行镜像
|
||||||
|
|
||||||
以下示例使用一张 NPU 启动最新的 A2 Ubuntu 镜像。请根据实际环境修改镜像 tag 和 `/dev/davinci0`。
|
以下示例使用一张 NPU 启动最新的 A2 Ubuntu 镜像。请根据实际情况修改 ``DOCKER_IMAGE`` 和 ``device``。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export IMAGE=quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
CONTAINER_NAME=llamafactory-npu
|
||||||
|
DOCKER_IMAGE=hiyouga/llamafactory:latest-910b-ubuntu
|
||||||
docker pull "$IMAGE"
|
|
||||||
|
|
||||||
docker run --rm -it \
|
docker run --rm -it \
|
||||||
--name llamafactory-npu \
|
--net=host \
|
||||||
--ipc=host \
|
|
||||||
--device=/dev/davinci0 \
|
--device=/dev/davinci0 \
|
||||||
--device=/dev/davinci_manager \
|
--device=/dev/davinci_manager \
|
||||||
--device=/dev/devmm_svm \
|
--device=/dev/devmm_svm \
|
||||||
--device=/dev/hisi_hdc \
|
--device=/dev/hisi_hdc \
|
||||||
-v /usr/local/dcmi:/usr/local/dcmi \
|
|
||||||
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
||||||
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
|
-v /usr/local/dcmi:/usr/local/dcmi \
|
||||||
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
||||||
-v "$HOME/.cache/huggingface:/root/.cache/huggingface" \
|
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
|
||||||
-p 7860:7860 \
|
-v /data:/data \
|
||||||
-p 8000:8000 \
|
--name "$CONTAINER_NAME" \
|
||||||
"$IMAGE" \
|
"$DOCKER_IMAGE" \
|
||||||
bash
|
/bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
部分驱动环境中的 `npu-smi` 位于 `/usr/local/sbin/npu-smi`,此时需要调整挂载源路径。使用多张 NPU 时,继续追加 `--device=/dev/davinci<N>` 参数。
|
部分驱动环境中的 `npu-smi` 位于 `/usr/local/sbin/npu-smi`,此时需要调整挂载源路径。使用多张 NPU 时,继续追加 `--device=/dev/davinci<N>` 参数。
|
||||||
@@ -134,22 +122,16 @@ python -c "import torch, torch_npu; print(torch.__version__, torch_npu.__version
|
|||||||
llamafactory-cli help
|
llamafactory-cli help
|
||||||
```
|
```
|
||||||
|
|
||||||
需要使用 LLaMA Board 时执行:
|
### 本地构建镜像
|
||||||
|
|
||||||
```bash
|
在仓库根目录执行构建。以下示例构建 A2 Ubuntu 镜像:
|
||||||
llamafactory-cli webui
|
|
||||||
```
|
|
||||||
|
|
||||||
### 本地构建
|
|
||||||
|
|
||||||
在仓库根目录执行构建。以下示例构建 A3 openEuler 镜像:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build \
|
docker build \
|
||||||
-f ./docker/docker-npu/Dockerfile \
|
-f ./docker/docker-npu/Dockerfile \
|
||||||
--build-arg BASE_IMAGE=quay.io/ascend/cann:9.0.0-a3-openeuler24.03-py3.11 \
|
--build-arg BASE_IMAGE=quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12 \
|
||||||
--build-arg PIP_INDEX=https://pypi.org/simple \
|
--build-arg PIP_INDEX=https://pypi.org/simple \
|
||||||
-t llamafactory:npu-a3-openeuler \
|
-t llamafactory:npu-910b-ubuntu \
|
||||||
.
|
.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -157,76 +139,45 @@ docker build \
|
|||||||
|
|
||||||
| 参数 | 默认值 | 用途 |
|
| 参数 | 默认值 | 用途 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `BASE_IMAGE` | A2 Ubuntu CANN 9.0.0 镜像 | 选择加速器和容器操作系统组合 |
|
| `BASE_IMAGE` | `quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12` | 根据设备型号和容器操作系统选择对应的基础镜像 |
|
||||||
| `PIP_INDEX` | `https://pypi.org/simple` | 指定 Python 软件包索引 |
|
| `PIP_INDEX` | `https://pypi.org/simple` | 指定 Python 软件包索引 |
|
||||||
| `PYTORCH_INDEX` | `https://download.pytorch.org/whl/cpu` | 指定配合 torch-npu 使用的 PyTorch wheel 索引 |
|
| `PYTORCH_INDEX` | `https://download.pytorch.org/whl/cpu` | 指定配合 TorchNPU 使用的 PyTorch wheel 索引 |
|
||||||
| `HTTP_PROXY` | 空 | 构建期间可选的 HTTP/HTTPS 代理 |
|
| `HTTP_PROXY` | 空 | 构建期间可选的 HTTP/HTTPS 代理 |
|
||||||
|
|
||||||
也可以通过 Docker Compose 构建并启动各个组合:
|
### 通过 Docker Compose 启动
|
||||||
|
|
||||||
|
前面的 `docker build` 命令直接调用 Dockerfile,只构建镜像,不启动容器。Docker Compose 不使用另一套构建逻辑:它读取 `docker-compose.yml` 中的预设配置,复用同一个 Dockerfile,并通过 profile 选择硬件系列和操作系统组合。下面的 `up -d` 会在后台启动容器;若本地镜像不存在,Docker Compose 会先构建镜像:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd docker/docker-npu
|
cd docker/docker-npu
|
||||||
|
|
||||||
# A2 + Ubuntu
|
# A2 + Ubuntu
|
||||||
docker compose up -d llamafactory-a2-ubuntu
|
docker compose --profile a2-ubuntu up -d
|
||||||
|
|
||||||
# A3 + Ubuntu
|
# A3 + Ubuntu
|
||||||
docker compose --profile a3 up -d llamafactory-a3-ubuntu
|
docker compose --profile a3-ubuntu up -d
|
||||||
|
|
||||||
# A2 + openEuler
|
# A2 + openEuler
|
||||||
docker compose --profile openeuler up -d llamafactory-a2-openeuler
|
docker compose --profile a2-openeuler up -d
|
||||||
|
|
||||||
# A3 + openEuler
|
# A3 + openEuler
|
||||||
docker compose --profile a3-openeuler up -d llamafactory-a3-openeuler
|
docker compose --profile a3-openeuler up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### 二次开发
|
如果只想通过 Docker Compose 构建镜像而不启动容器,请使用 `docker compose --profile <profile> build`。
|
||||||
|
|
||||||
交互式开发时,可以将本地源码挂载到容器中,并在容器内以 editable 模式重新安装:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/hiyouga/LLaMA-Factory.git
|
|
||||||
cd LLaMA-Factory
|
|
||||||
|
|
||||||
# 同时添加前述昇腾 --device 和驱动目录挂载参数。
|
|
||||||
docker run --rm -it \
|
|
||||||
--ipc=host \
|
|
||||||
-v "$PWD:/workspace/LLaMA-Factory" \
|
|
||||||
-w /workspace/LLaMA-Factory \
|
|
||||||
"$IMAGE" \
|
|
||||||
bash
|
|
||||||
|
|
||||||
pip install -e . --no-build-isolation
|
|
||||||
```
|
|
||||||
|
|
||||||
需要可复现的派生镜像时,可以新建独立 Dockerfile:
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
FROM quay.io/ascend/llamafactory:latest-cann9.0.0-torch_npu2.7.1-A2-ubuntu-py3.11
|
|
||||||
|
|
||||||
COPY requirements-extension.txt /tmp/requirements-extension.txt
|
|
||||||
RUN pip install --no-cache-dir -r /tmp/requirements-extension.txt
|
|
||||||
|
|
||||||
COPY . /workspace/application
|
|
||||||
WORKDIR /workspace/application
|
|
||||||
```
|
|
||||||
|
|
||||||
运行派生镜像时仍需传入昇腾设备和驱动挂载参数,不应将设备访问配置固化到镜像中。
|
|
||||||
|
|
||||||
## 硬件支持与兼容性说明
|
## 硬件支持与兼容性说明
|
||||||
|
|
||||||
- A2 镜像使用标记为 `910b` 的 CANN 基础镜像,A3 镜像使用标记为 `a3` 的 CANN 基础镜像。
|
- A2 镜像使用标记为 `910b` 的 CANN 基础镜像,A3 镜像使用标记为 `a3` 的 CANN 基础镜像。
|
||||||
- 镜像构建目标同时包含 x86-64(`linux/amd64`)和 AArch64(`linux/arm64`)宿主机。CPU 架构与加速器属于 A2 还是 A3 无关。
|
- 镜像构建目标同时包含 x86-64(`linux/amd64`)和 AArch64(`linux/arm64`)宿主机。CPU 架构与硬件系列是 A2 还是 A3 无关。
|
||||||
- Ubuntu 22.04 和 openEuler 24.03 指容器内部的操作系统。
|
- Ubuntu 22.04 和 openEuler 24.03 指容器内部的操作系统。
|
||||||
- 当前依赖基线将 PyTorch `2.7.1` 与 torch-npu `2.7.1.post4` 配套使用。单独升级其中一个软件包可能破坏兼容性。
|
- 旧式 NPU tag 已由 `latest-<910b|a3>-<ubuntu|openeuler>` 格式取代。
|
||||||
- 生产环境建议使用固定 release tag,以确保部署可复现;定时构建可能更新 `latest` tag。
|
|
||||||
- `latest-npu-a2` 等旧式短 tag 没有体现 CANN、torch-npu、操作系统和 Python 版本,建议迁移到本文所述的完整 tag。
|
|
||||||
- 正式部署前,请验证具体驱动、固件、CANN 和 SoC 组合的兼容性。
|
- 正式部署前,请验证具体驱动、固件、CANN 和 SoC 组合的兼容性。
|
||||||
|
|
||||||
## 许可证与免责声明
|
## 许可证与免责声明
|
||||||
|
|
||||||
LLaMA Factory 基于 [Apache License 2.0](../../LICENSE) 发布。
|
LlamaFactory 基于 [Apache License 2.0](../../LICENSE) 发布。
|
||||||
|
|
||||||
昇腾 CANN、torch-npu、Triton Ascend、DeepSpeed、基础操作系统软件包、模型权重、数据集和其他第三方组件分别受其自身许可证与条款约束。LLaMA Factory 的许可证不会替代或覆盖这些条款。
|
昇腾 CANN、TorchNPU、Triton Ascend、DeepSpeed、基础操作系统软件包、模型权重、数据集和其他第三方组件分别受其自身许可证与条款约束。LlamaFactory 的许可证不会替代或覆盖这些条款。
|
||||||
|
|
||||||
本镜像按“原样”提供,不附带任何明示或暗示的保证。用户需要自行验证软硬件兼容性、保障容器及运行配置的安全、遵守适用的许可证和法律,并在训练、评测或部署前审查模型与数据集的使用条款。
|
本镜像按“原样”提供,不附带任何明示或暗示的保证。用户需要自行验证软硬件兼容性、保障容器及运行配置的安全、遵守适用的许可证和法律,并在训练、评测或部署前审查模型与数据集的使用条款。
|
||||||
|
|||||||
@@ -26,25 +26,26 @@ x-npu-common: &npu-common
|
|||||||
services:
|
services:
|
||||||
llamafactory-a2-ubuntu:
|
llamafactory-a2-ubuntu:
|
||||||
<<: *npu-common
|
<<: *npu-common
|
||||||
|
profiles: ["a2-ubuntu"]
|
||||||
build:
|
build:
|
||||||
<<: *build
|
<<: *build
|
||||||
args:
|
args:
|
||||||
<<: *build-args
|
<<: *build-args
|
||||||
BASE_IMAGE: quay.io/ascend/cann:9.0.0-910b-ubuntu22.04-py3.11
|
BASE_IMAGE: quay.io/ascend/cann:9.1.0-910b-ubuntu22.04-py3.12
|
||||||
container_name: llamafactory-a2-ubuntu
|
container_name: llamafactory-910b-ubuntu
|
||||||
image: llamafactory:npu-a2-ubuntu
|
image: llamafactory:npu-910b-ubuntu
|
||||||
ports:
|
ports:
|
||||||
- "7860:7860"
|
- "7860:7860"
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
|
|
||||||
llamafactory-a3-ubuntu:
|
llamafactory-a3-ubuntu:
|
||||||
<<: *npu-common
|
<<: *npu-common
|
||||||
profiles: ["a3"]
|
profiles: ["a3-ubuntu"]
|
||||||
build:
|
build:
|
||||||
<<: *build
|
<<: *build
|
||||||
args:
|
args:
|
||||||
<<: *build-args
|
<<: *build-args
|
||||||
BASE_IMAGE: quay.io/ascend/cann:9.0.0-a3-ubuntu22.04-py3.11
|
BASE_IMAGE: quay.io/ascend/cann:9.1.0-a3-ubuntu22.04-py3.12
|
||||||
container_name: llamafactory-a3-ubuntu
|
container_name: llamafactory-a3-ubuntu
|
||||||
image: llamafactory:npu-a3-ubuntu
|
image: llamafactory:npu-a3-ubuntu
|
||||||
ports:
|
ports:
|
||||||
@@ -53,14 +54,14 @@ services:
|
|||||||
|
|
||||||
llamafactory-a2-openeuler:
|
llamafactory-a2-openeuler:
|
||||||
<<: *npu-common
|
<<: *npu-common
|
||||||
profiles: ["openeuler"]
|
profiles: ["a2-openeuler"]
|
||||||
build:
|
build:
|
||||||
<<: *build
|
<<: *build
|
||||||
args:
|
args:
|
||||||
<<: *build-args
|
<<: *build-args
|
||||||
BASE_IMAGE: quay.io/ascend/cann:9.0.0-910b-openeuler24.03-py3.11
|
BASE_IMAGE: quay.io/ascend/cann:9.1.0-910b-openeuler24.03-py3.12
|
||||||
container_name: llamafactory-a2-openeuler
|
container_name: llamafactory-910b-openeuler
|
||||||
image: llamafactory:npu-a2-openeuler
|
image: llamafactory:npu-910b-openeuler
|
||||||
ports:
|
ports:
|
||||||
- "7862:7860"
|
- "7862:7860"
|
||||||
- "8002:8000"
|
- "8002:8000"
|
||||||
@@ -72,7 +73,7 @@ services:
|
|||||||
<<: *build
|
<<: *build
|
||||||
args:
|
args:
|
||||||
<<: *build-args
|
<<: *build-args
|
||||||
BASE_IMAGE: quay.io/ascend/cann:9.0.0-a3-openeuler24.03-py3.11
|
BASE_IMAGE: quay.io/ascend/cann:9.1.0-a3-openeuler24.03-py3.12
|
||||||
container_name: llamafactory-a3-openeuler
|
container_name: llamafactory-a3-openeuler
|
||||||
image: llamafactory:npu-a3-openeuler
|
image: llamafactory:npu-a3-openeuler
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
torch==2.7.1
|
torch==2.10.0
|
||||||
torch-npu==2.7.1.post4
|
torch-npu==2.10.0.post2
|
||||||
torchvision==0.22.1
|
torchvision==0.25.0
|
||||||
torchaudio==2.7.1
|
torchaudio==2.10.0
|
||||||
decorator
|
decorator
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ model: Qwen/Qwen3-0.6B
|
|||||||
trust_remote_code: true
|
trust_remote_code: true
|
||||||
model_class: llm
|
model_class: llm
|
||||||
|
|
||||||
template: qwen3_nothink
|
|
||||||
|
|
||||||
kernel_config:
|
kernel_config:
|
||||||
name: auto
|
name: auto
|
||||||
|
|
||||||
@@ -41,7 +39,7 @@ dist_config:
|
|||||||
dcp_path: null
|
dcp_path: null
|
||||||
|
|
||||||
init_config:
|
init_config:
|
||||||
name: init_on_meta
|
name: init_on_default
|
||||||
|
|
||||||
# PEFT Configuration
|
# PEFT Configuration
|
||||||
peft_config:
|
peft_config:
|
||||||
|
|||||||
Reference in New Issue
Block a user