Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add llamafactory doc #16

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Add llamafactory doc #16

merged 1 commit into from
Jun 13, 2024

Conversation

MengqingCao
Copy link
Contributor

No description provided.

@FFFrog FFFrog merged commit 07e77c7 into Ascend:main Jun 13, 2024
1 check passed
Copy link
Contributor

@Yikun Yikun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体来看,这个doc,没有达到让开发者很爽的预期,不知道负责review的 @FFFrog 同学在apporve前有没有认真的看。🤷‍♂️

比较好的示例是:ascend和torch的安装:https://github.com/Ascend/docs/blob/main/sources/ascend/quick_install.rst

我觉得比较必备的是:

  1. 简明扼要的解释和可以直接安装的命令,以及必要简明扼要的检查是有必要的。
  2. 文档和注释是一样的假设用户什么都知道假设用户什么都不知道都是错的。
  3. 在安装指南和快速上手环节,不适合展示过多细节,目的是让用户玩起来。

业界不错的可以参考:
https://minikube.sigs.k8s.io/docs/start/?arch=%2Fwindows%2Fx86-64%2Fstable%2F.exe+download

思考下为什么docker会提供一个linux-install还会提供ubuntu
https://docs.docker.com/desktop/install/linux-install/
https://docs.docker.com/desktop/install/ubuntu/

Comment on lines +18 to +20
- `[32GB]LLaMA-Factory-Cann8-Python3.10-Pytorch2.2.0 <http://mirrors.cn-central-221.ovaijisuan.com/detail/130.html>`_

- `[64GB]LLaMA-Factory-Cann8-Python3.10-Pytorch2.2.0 <http://mirrors.cn-central-221.ovaijisuan.com/detail/131.html>`_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前和@MengqingCao提过,后续要切换为统一的基础容器栈。cc @wangxiyuan

可以尝试和LLAMAFactory共同合作,在上游构建容器镜像。

dockerfile在上游合入,并配套容器镜像的CI

FROM ascendai/cann:python3.8-pytorch2.2-cann8.0
pip install llamafactory

同样的,用户敲什么命令可以验证,容器是ok的?

昇腾环境安装
------------

请根据已有昇腾产品型号及CPU架构等按照 `快速安装昇腾环境指引 <https://ascend.github.io/docs/sources/ascend/quick_install.html>`_ 进行昇腾环境安装,或使用已安装好昇腾环境及 LLaMA-Factory 的 docker 镜像:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请根据已有昇腾产品型号及CPU架构等按照 快速安装昇腾环境指引 <https://ascend.github.io/docs/sources/ascend/quick_install.html>_ 进行昇腾环境安装

这个没问题,但是预期安装好的版本配套是什么?用户敲什么简单的命令可以验证?

Comment on lines +30 to +35
.. code-block:: shell
:linenos:
# 创建 python 3.10 的虚拟环境
conda create -n <your_env_name> python=3.10
# 激活虚拟环境
conda activate <your_env_name>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

命令显示的不对,在渲染后消失了。

Comment on lines +53 to +55
.. code-block:: shell
:linenos:
pip install -e .[torch_npu,metrics]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50行才讲到真正的安装,有点太长了。安装文档的关键信息。


.. code-block:: shell
:linenos:
git clone git@github.com:hiyouga/LLaMA-Factory.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文档是针对开发者的还是用户的?用户为什么要git clone下载。 或许pip install llamafactory[torch_npu,metrics]之类的就够了?


在[LLaMA-Factory 安装](#LLaMA-Factory 安装)中搭建好的 conda 虚拟环境下,使用 ``llamafactory-cli version`` 指令对 LLaMA-Factory × 昇腾的安装进行校验,如下图所示,正确显示 LLaMA-Factory 版本号说明 LLaMA-Factory 安装成功;显示 `Setting ds_accelerator to npu` 说明 deepspeed 及 npu 环境安装成功。

.. figure:: ./images/install_check.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片都换成code-block的文字

或许llamafactory-cli env也挺合适?
https://github.com/hiyouga/LLaMA-Factory/blob/main/src/llamafactory/extras/env.py#L34C28-L34C55

Comment on lines +68 to +72
根据 LLaMA-Factory 官方指引,现已支持的可选额外依赖项包括:

> 可选的额外依赖项:torch、torch_npu、metrics、deepspeed、bitsandbytes、vllm、galore、badam、gptq、awq、aqlm、qwen、modelscope、quality

可根据需要进行选择安装。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

个人认为这部分不应该在这个文档体现。只需要告诉用户,最适合的一个就好了。如果有其他的,也应该告诉用户,在什么时候需要安装其他的。有些库也显然还没有昇腾支持,安装也是不可用的

Comment on lines +18 to +30
昇腾 NPU 相关环境变量
^^^^^^^^^^^^^^^^^^^^^^

使用昇腾 NPU,只需临时指定 `ASCEND_RT_VISIBLE_DEVICES` 环境变量为 NPU 卡号,即可实现在指定 NPU 卡上运行程序。

- ``ASCEND_RT_VISIBLE_DEVICES=0`` 指定卡号为 0 的单卡
- ``ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7`` 指定卡号为 0~7 的八卡

.. note::

昇腾 NPU 卡从 0 开始编号,docker 容器内也是如此;

如映射物理机上的 6,7 号 NPU 卡到容器内使用,其对应的卡号分别为 0,1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既然是快速开始,不妨就简明扼要地限制用单卡?然后多卡可能是另一篇文章,或者在底部的一个新的section

不然开发者会卡在这里,我要选择那个卡?单卡还是多卡?

Comment on lines +54 to +75
使用 LLaMA-Factory 进行微调,需要对 ModelScope、Gradio 等功能用到的环境变量进行设置,下表为涉及到的环境变量的相关信息,可根据需要进行配置:

.. list-table::
:widths: 25 25 50 80
:header-rows: 1

* - 工具
- 功能
- 环境变量
- 含义
* - ModelScope
- 国内的 AI 模型/数据集托管平台
- USE_MODELSCOPE_HUB
- 1/0 启用/禁用 modelscope 进行模型或数据集的下载
* - Gradio
- 创建 AI 模型 webui 的 python 库
- - GRADIO_SHARE
- GRADIO_SERVER_PORT
- GRADIO_SERVER_NAME
- - 1/0 启用/禁用 gradio 外链分享模式
- 指定 gradio server 端口号
- 指定 gradio server IP 地址, docker 容器内使用 "0.0.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一样的,这些信息会影响阅读的连贯性,只写关键信息即可。快速上手的目的是为了用户快速跑起来,say hello。面面俱到的事情,可以放在后面单独章节。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants