ROMA + GH200 reproducible Docker layer
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .dockerignore +15 -0
- .env.local +42 -0
- .gitattributes +26 -35
- .github/CODE_OF_CONDUCT.md +128 -0
- .github/CONTRIBUTING.md +67 -0
- .github/ISSUE_TEMPLATE/1-bug-report.yml +61 -0
- .github/ISSUE_TEMPLATE/2-feature-request.yml +41 -0
- .github/ISSUE_TEMPLATE/config.yml +1 -0
- .github/PULL_REQUEST_TEMPLATE.md +8 -0
- .github/SECURITY.md +7 -0
- .github/workflows/label_issue.yml +32 -0
- .github/workflows/publish.yml +36 -0
- .github/workflows/tests.yml +99 -0
- .gitignore +179 -0
- .pre-commit-config.yaml +28 -0
- ARCHITECTURE.md +234 -0
- CITATION.cff +44 -0
- LICENSE +201 -0
- README-GH200.md +114 -0
- assets/alert1.png +3 -0
- assets/alert2.png +3 -0
- assets/architecture.png +3 -0
- assets/benchmark.svg +1216 -0
- assets/logo.png +0 -0
- assets/narration.png +3 -0
- assets/omni.png +3 -0
- assets/ovo.png +3 -0
- assets/streaming.png +3 -0
- assets/teaser.png +3 -0
- assets/wechat.jpg +3 -0
- assets/wechat_npu.jpg +3 -0
- blank.jpg +0 -0
- data/belle_multiturn/belle_multiturn.py +82 -0
- data/hh_rlhf_en/hh_rlhf_en.py +98 -0
- data/mllm_demo_data/1.jpg +0 -0
- data/mllm_demo_data/1.mp3 +3 -0
- data/mllm_demo_data/1.mp4 +3 -0
- data/mllm_demo_data/2.avi +3 -0
- data/mllm_demo_data/2.jpg +0 -0
- data/mllm_demo_data/2.wav +0 -0
- data/mllm_demo_data/3.flac +3 -0
- data/mllm_demo_data/3.jpg +0 -0
- data/mllm_demo_data/3.mp4 +3 -0
- data/mllm_demo_data/4.mp3 +0 -0
- data/mllm_demo_data/4.mp4 +0 -0
- data/test_mix_data.json +118 -0
- data/ultra_chat/ultra_chat.py +74 -0
- debug_sft_singlegpu.py +73 -0
- docker/docker-cuda/Dockerfile +101 -0
- docker/docker-cuda/docker-compose.yml +37 -0
.dockerignore
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.vscode
|
| 2 |
+
.git
|
| 3 |
+
.github
|
| 4 |
+
.venv
|
| 5 |
+
cache
|
| 6 |
+
data
|
| 7 |
+
docker
|
| 8 |
+
saves
|
| 9 |
+
hf_cache
|
| 10 |
+
ms_cache
|
| 11 |
+
om_cache
|
| 12 |
+
output
|
| 13 |
+
.dockerignore
|
| 14 |
+
.gitattributes
|
| 15 |
+
.gitignore
|
.env.local
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Note: actually we do not support .env, just for reference
|
| 2 |
+
# api
|
| 3 |
+
API_HOST=
|
| 4 |
+
API_PORT=
|
| 5 |
+
API_KEY=
|
| 6 |
+
API_MODEL_NAME=
|
| 7 |
+
API_VERBOSE=
|
| 8 |
+
FASTAPI_ROOT_PATH=
|
| 9 |
+
MAX_CONCURRENT=
|
| 10 |
+
# general
|
| 11 |
+
DISABLE_VERSION_CHECK=
|
| 12 |
+
FORCE_CHECK_IMPORTS=
|
| 13 |
+
ALLOW_EXTRA_ARGS=
|
| 14 |
+
LLAMAFACTORY_VERBOSITY=
|
| 15 |
+
USE_MODELSCOPE_HUB=
|
| 16 |
+
USE_OPENMIND_HUB=
|
| 17 |
+
USE_RAY=
|
| 18 |
+
RECORD_VRAM=
|
| 19 |
+
OPTIM_TORCH=
|
| 20 |
+
NPU_JIT_COMPILE=
|
| 21 |
+
# torchrun
|
| 22 |
+
FORCE_TORCHRUN=
|
| 23 |
+
MASTER_ADDR=
|
| 24 |
+
MASTER_PORT=
|
| 25 |
+
NNODES=
|
| 26 |
+
NODE_RANK=
|
| 27 |
+
NPROC_PER_NODE=
|
| 28 |
+
# wandb
|
| 29 |
+
WANDB_DISABLED=
|
| 30 |
+
WANDB_PROJECT=
|
| 31 |
+
WANDB_API_KEY=
|
| 32 |
+
# gradio ui
|
| 33 |
+
GRADIO_SHARE=
|
| 34 |
+
GRADIO_SERVER_NAME=
|
| 35 |
+
GRADIO_SERVER_PORT=
|
| 36 |
+
GRADIO_ROOT_PATH=
|
| 37 |
+
GRADIO_IPV6=
|
| 38 |
+
# setup
|
| 39 |
+
ENABLE_SHORT_CONSOLE=
|
| 40 |
+
# reserved (do not use)
|
| 41 |
+
LLAMABOARD_ENABLED=
|
| 42 |
+
LLAMABOARD_WORKDIR=
|
.gitattributes
CHANGED
|
@@ -1,35 +1,26 @@
|
|
| 1 |
-
|
| 2 |
-
*
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
*.
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
# Auto detect text files and perform LF normalization
|
| 2 |
+
* text=auto
|
| 3 |
+
|
| 4 |
+
# Shell scripts must stay LF so they run on Linux hosts (e.g. the GH200) regardless of checkout OS
|
| 5 |
+
*.sh text eol=lf
|
| 6 |
+
assets/alert1.png filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
assets/alert2.png filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
assets/architecture.png filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
assets/narration.png filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
assets/omni.png filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
assets/ovo.png filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
assets/streaming.png filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
assets/teaser.png filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
assets/wechat.jpg filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
assets/wechat_npu.jpg filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
data/mllm_demo_data/1.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
data/mllm_demo_data/1.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
data/mllm_demo_data/2.avi filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
data/mllm_demo_data/3.flac filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
data/mllm_demo_data/3.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
evaluation/ceval/ceval.zip filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
evaluation/cmmlu/cmmlu.zip filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
evaluation/mmlu/mmlu.zip filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
gradio/aCkbw-aI4xU_cut80s.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
gradio/aCkbw-aI4xU_cut98s.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
gradio/bot.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributor Covenant Code of Conduct
|
| 2 |
+
|
| 3 |
+
## Our Pledge
|
| 4 |
+
|
| 5 |
+
We as members, contributors, and leaders pledge to make participation in our
|
| 6 |
+
community a harassment-free experience for everyone, regardless of age, body
|
| 7 |
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
| 8 |
+
identity and expression, level of experience, education, socio-economic status,
|
| 9 |
+
nationality, personal appearance, race, religion, or sexual identity
|
| 10 |
+
and orientation.
|
| 11 |
+
|
| 12 |
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
| 13 |
+
diverse, inclusive, and healthy community.
|
| 14 |
+
|
| 15 |
+
## Our Standards
|
| 16 |
+
|
| 17 |
+
Examples of behavior that contributes to a positive environment for our
|
| 18 |
+
community include:
|
| 19 |
+
|
| 20 |
+
* Demonstrating empathy and kindness toward other people
|
| 21 |
+
* Being respectful of differing opinions, viewpoints, and experiences
|
| 22 |
+
* Giving and gracefully accepting constructive feedback
|
| 23 |
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
| 24 |
+
and learning from the experience
|
| 25 |
+
* Focusing on what is best not just for us as individuals, but for the
|
| 26 |
+
overall community
|
| 27 |
+
|
| 28 |
+
Examples of unacceptable behavior include:
|
| 29 |
+
|
| 30 |
+
* The use of sexualized language or imagery, and sexual attention or
|
| 31 |
+
advances of any kind
|
| 32 |
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
| 33 |
+
* Public or private harassment
|
| 34 |
+
* Publishing others' private information, such as a physical or email
|
| 35 |
+
address, without their explicit permission
|
| 36 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
| 37 |
+
professional setting
|
| 38 |
+
|
| 39 |
+
## Enforcement Responsibilities
|
| 40 |
+
|
| 41 |
+
Community leaders are responsible for clarifying and enforcing our standards of
|
| 42 |
+
acceptable behavior and will take appropriate and fair corrective action in
|
| 43 |
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
| 44 |
+
or harmful.
|
| 45 |
+
|
| 46 |
+
Community leaders have the right and responsibility to remove, edit, or reject
|
| 47 |
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
| 48 |
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
| 49 |
+
decisions when appropriate.
|
| 50 |
+
|
| 51 |
+
## Scope
|
| 52 |
+
|
| 53 |
+
This Code of Conduct applies within all community spaces, and also applies when
|
| 54 |
+
an individual is officially representing the community in public spaces.
|
| 55 |
+
Examples of representing our community include using an official e-mail address,
|
| 56 |
+
posting via an official social media account, or acting as an appointed
|
| 57 |
+
representative at an online or offline event.
|
| 58 |
+
|
| 59 |
+
## Enforcement
|
| 60 |
+
|
| 61 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
| 62 |
+
reported to the community leaders responsible for enforcement at
|
| 63 |
+
`hoshihiyouga AT gmail DOT com`.
|
| 64 |
+
All complaints will be reviewed and investigated promptly and fairly.
|
| 65 |
+
|
| 66 |
+
All community leaders are obligated to respect the privacy and security of the
|
| 67 |
+
reporter of any incident.
|
| 68 |
+
|
| 69 |
+
## Enforcement Guidelines
|
| 70 |
+
|
| 71 |
+
Community leaders will follow these Community Impact Guidelines in determining
|
| 72 |
+
the consequences for any action they deem in violation of this Code of Conduct:
|
| 73 |
+
|
| 74 |
+
### 1. Correction
|
| 75 |
+
|
| 76 |
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
| 77 |
+
unprofessional or unwelcome in the community.
|
| 78 |
+
|
| 79 |
+
**Consequence**: A private, written warning from community leaders, providing
|
| 80 |
+
clarity around the nature of the violation and an explanation of why the
|
| 81 |
+
behavior was inappropriate. A public apology may be requested.
|
| 82 |
+
|
| 83 |
+
### 2. Warning
|
| 84 |
+
|
| 85 |
+
**Community Impact**: A violation through a single incident or series
|
| 86 |
+
of actions.
|
| 87 |
+
|
| 88 |
+
**Consequence**: A warning with consequences for continued behavior. No
|
| 89 |
+
interaction with the people involved, including unsolicited interaction with
|
| 90 |
+
those enforcing the Code of Conduct, for a specified period of time. This
|
| 91 |
+
includes avoiding interactions in community spaces as well as external channels
|
| 92 |
+
like social media. Violating these terms may lead to a temporary or
|
| 93 |
+
permanent ban.
|
| 94 |
+
|
| 95 |
+
### 3. Temporary Ban
|
| 96 |
+
|
| 97 |
+
**Community Impact**: A serious violation of community standards, including
|
| 98 |
+
sustained inappropriate behavior.
|
| 99 |
+
|
| 100 |
+
**Consequence**: A temporary ban from any sort of interaction or public
|
| 101 |
+
communication with the community for a specified period of time. No public or
|
| 102 |
+
private interaction with the people involved, including unsolicited interaction
|
| 103 |
+
with those enforcing the Code of Conduct, is allowed during this period.
|
| 104 |
+
Violating these terms may lead to a permanent ban.
|
| 105 |
+
|
| 106 |
+
### 4. Permanent Ban
|
| 107 |
+
|
| 108 |
+
**Community Impact**: Demonstrating a pattern of violation of community
|
| 109 |
+
standards, including sustained inappropriate behavior, harassment of an
|
| 110 |
+
individual, or aggression toward or disparagement of classes of individuals.
|
| 111 |
+
|
| 112 |
+
**Consequence**: A permanent ban from any sort of public interaction within
|
| 113 |
+
the community.
|
| 114 |
+
|
| 115 |
+
## Attribution
|
| 116 |
+
|
| 117 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
| 118 |
+
version 2.0, available at
|
| 119 |
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
| 120 |
+
|
| 121 |
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
| 122 |
+
enforcement ladder](https://github.com/mozilla/diversity).
|
| 123 |
+
|
| 124 |
+
[homepage]: https://www.contributor-covenant.org
|
| 125 |
+
|
| 126 |
+
For answers to common questions about this code of conduct, see the FAQ at
|
| 127 |
+
https://www.contributor-covenant.org/faq. Translations are available at
|
| 128 |
+
https://www.contributor-covenant.org/translations.
|
.github/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributing to LLaMA Factory
|
| 2 |
+
|
| 3 |
+
Everyone is welcome to contribute, and we value everybody's contribution. Code contributions are not the only way to help the community. Answering questions, helping others, and improving the documentation are also immensely valuable.
|
| 4 |
+
|
| 5 |
+
It also helps us if you spread the word! Reference the library in blog posts about the awesome projects it made possible, shout out on Twitter every time it has helped you, or simply ⭐️ the repository to say thank you.
|
| 6 |
+
|
| 7 |
+
However you choose to contribute, please be mindful and respect our [code of conduct](CODE_OF_CONDUCT.md).
|
| 8 |
+
|
| 9 |
+
**This guide was heavily inspired by [transformers guide to contributing](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).**
|
| 10 |
+
|
| 11 |
+
## Ways to contribute
|
| 12 |
+
|
| 13 |
+
There are several ways you can contribute to LLaMA Factory:
|
| 14 |
+
|
| 15 |
+
* Fix outstanding issues with the existing code.
|
| 16 |
+
* Submit issues related to bugs or desired new features.
|
| 17 |
+
* Contribute to the examples or to the documentation.
|
| 18 |
+
|
| 19 |
+
### Style guide
|
| 20 |
+
|
| 21 |
+
LLaMA Factory follows the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html), check it for details.
|
| 22 |
+
|
| 23 |
+
### Create a Pull Request
|
| 24 |
+
|
| 25 |
+
1. Fork the [repository](https://github.com/hiyouga/LLaMA-Factory) by clicking on the [Fork](https://github.com/hiyouga/LLaMA-Factory/fork) button on the repository's page. This creates a copy of the code under your GitHub user account.
|
| 26 |
+
|
| 27 |
+
2. Clone your fork to your local disk, and add the base repository as a remote:
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
git clone git@github.com:[username]/LLaMA-Factory.git
|
| 31 |
+
cd LLaMA-Factory
|
| 32 |
+
git remote add upstream https://github.com/hiyouga/LLaMA-Factory.git
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
3. Create a new branch to hold your development changes:
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
git checkout -b dev_your_branch
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
4. Set up a development environment by running the following command in a virtual environment:
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
pip install -e ".[dev]"
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
If LLaMA Factory was already installed in the virtual environment, remove it with `pip uninstall llamafactory` before reinstalling it in editable mode with the -e flag.
|
| 48 |
+
|
| 49 |
+
5. Check code before commit:
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
make commit
|
| 53 |
+
make style && make quality
|
| 54 |
+
make test
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
6. Submit changes:
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
git add .
|
| 61 |
+
git commit -m "commit message"
|
| 62 |
+
git fetch upstream
|
| 63 |
+
git rebase upstream/main
|
| 64 |
+
git push -u origin dev_your_branch
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
7. Create a merge request from your branch `dev_your_branch` at [origin repo](https://github.com/hiyouga/LLaMA-Factory).
|
.github/ISSUE_TEMPLATE/1-bug-report.yml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: "\U0001F41B Bug / help"
|
| 2 |
+
description: Create a report to help us improve the LLaMA Factory
|
| 3 |
+
labels: ["bug", "pending"]
|
| 4 |
+
body:
|
| 5 |
+
- type: markdown
|
| 6 |
+
attributes:
|
| 7 |
+
value: |
|
| 8 |
+
Issues included in **[FAQs](https://github.com/hiyouga/LLaMA-Factory/issues/4614)** or those with **insufficient** information may be closed without a response.
|
| 9 |
+
已经包含在 **[常见问题](https://github.com/hiyouga/LLaMA-Factory/issues/4614)** 内或提供信息**不完整**的 issues 可能不会被回复。
|
| 10 |
+
|
| 11 |
+
- type: markdown
|
| 12 |
+
attributes:
|
| 13 |
+
value: |
|
| 14 |
+
Please do not create issues that are not related to framework bugs under this category, use **[Discussions](https://github.com/hiyouga/LLaMA-Factory/discussions/categories/q-a)** instead.
|
| 15 |
+
请勿在此分类下创建和框架 bug 无关的 issues,训练问题求助请使用 **[讨论区](https://github.com/hiyouga/LLaMA-Factory/discussions/categories/q-a)**。
|
| 16 |
+
|
| 17 |
+
- type: checkboxes
|
| 18 |
+
id: reminder
|
| 19 |
+
attributes:
|
| 20 |
+
label: Reminder
|
| 21 |
+
description: |
|
| 22 |
+
Please ensure you have read the above rules carefully and searched the existing issues (including FAQs).
|
| 23 |
+
请确保您已经认真阅读了上述规则并且搜索过现有的 issues(包括常见问题)。
|
| 24 |
+
|
| 25 |
+
options:
|
| 26 |
+
- label: I have read the above rules and searched the existing issues.
|
| 27 |
+
required: true
|
| 28 |
+
|
| 29 |
+
- type: textarea
|
| 30 |
+
id: system-info
|
| 31 |
+
validations:
|
| 32 |
+
required: true
|
| 33 |
+
attributes:
|
| 34 |
+
label: System Info
|
| 35 |
+
description: |
|
| 36 |
+
Please share your system info with us. You can run the command **llamafactory-cli env** and copy-paste its output below.
|
| 37 |
+
请提供您的系统信息。您可以在命令行运行 **llamafactory-cli env** 并将其输出复制到该文本框中。
|
| 38 |
+
|
| 39 |
+
placeholder: llamafactory version, platform, python version, ...
|
| 40 |
+
|
| 41 |
+
- type: textarea
|
| 42 |
+
id: reproduction
|
| 43 |
+
validations:
|
| 44 |
+
required: true
|
| 45 |
+
attributes:
|
| 46 |
+
label: Reproduction
|
| 47 |
+
description: |
|
| 48 |
+
Please provide entry arguments, error messages and stack traces that reproduces the problem.
|
| 49 |
+
请提供入口参数,错误日志以及异常堆栈以便于我们复现问题。
|
| 50 |
+
|
| 51 |
+
value: |
|
| 52 |
+
```text
|
| 53 |
+
Put your message here.
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
- type: textarea
|
| 57 |
+
id: others
|
| 58 |
+
validations:
|
| 59 |
+
required: false
|
| 60 |
+
attributes:
|
| 61 |
+
label: Others
|
.github/ISSUE_TEMPLATE/2-feature-request.yml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: "\U0001F680 Feature request"
|
| 2 |
+
description: Submit a request for a new feature
|
| 3 |
+
labels: ["enhancement", "pending"]
|
| 4 |
+
body:
|
| 5 |
+
- type: markdown
|
| 6 |
+
attributes:
|
| 7 |
+
value: |
|
| 8 |
+
Please do not create issues that are not related to new features under this category.
|
| 9 |
+
请勿在此分类下创建和新特性无关的 issues。
|
| 10 |
+
|
| 11 |
+
- type: checkboxes
|
| 12 |
+
id: reminder
|
| 13 |
+
attributes:
|
| 14 |
+
label: Reminder
|
| 15 |
+
description: |
|
| 16 |
+
Please ensure you have read the above rules carefully and searched the existing issues.
|
| 17 |
+
请确保您已经认真阅读了上述规则并且搜索过现有的 issues。
|
| 18 |
+
|
| 19 |
+
options:
|
| 20 |
+
- label: I have read the above rules and searched the existing issues.
|
| 21 |
+
required: true
|
| 22 |
+
|
| 23 |
+
- type: textarea
|
| 24 |
+
id: description
|
| 25 |
+
validations:
|
| 26 |
+
required: true
|
| 27 |
+
attributes:
|
| 28 |
+
label: Description
|
| 29 |
+
description: |
|
| 30 |
+
A clear and concise description of the feature proposal.
|
| 31 |
+
请详细描述您希望加入的新功能特性。
|
| 32 |
+
|
| 33 |
+
- type: textarea
|
| 34 |
+
id: contribution
|
| 35 |
+
validations:
|
| 36 |
+
required: false
|
| 37 |
+
attributes:
|
| 38 |
+
label: Pull Request
|
| 39 |
+
description: |
|
| 40 |
+
Have you already created the relevant PR and submitted the code?
|
| 41 |
+
您是否已经创建了相关 PR 并提交了代码?
|
.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: false
|
.github/PULL_REQUEST_TEMPLATE.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# What does this PR do?
|
| 2 |
+
|
| 3 |
+
Fixes # (issue)
|
| 4 |
+
|
| 5 |
+
## Before submitting
|
| 6 |
+
|
| 7 |
+
- [ ] Did you read the [contributor guideline](https://github.com/hiyouga/LLaMA-Factory/blob/main/.github/CONTRIBUTING.md)?
|
| 8 |
+
- [ ] Did you write any new necessary tests?
|
.github/SECURITY.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Reporting Security Issues
|
| 2 |
+
|
| 3 |
+
To report a security issue, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/hiyouga/LLaMA-Factory/security/advisories/new) tab.
|
| 4 |
+
|
| 5 |
+
We will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.
|
| 6 |
+
|
| 7 |
+
Report security bugs in third-party modules to the person or team maintaining the module.
|
.github/workflows/label_issue.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: label_issue
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
issues:
|
| 5 |
+
types:
|
| 6 |
+
- opened
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
label_issue:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
|
| 12 |
+
permissions:
|
| 13 |
+
issues: write
|
| 14 |
+
|
| 15 |
+
steps:
|
| 16 |
+
- env:
|
| 17 |
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 18 |
+
ISSUE_URL: ${{ github.event.issue.html_url }}
|
| 19 |
+
ISSUE_TITLE: ${{ github.event.issue.title }}
|
| 20 |
+
run: |
|
| 21 |
+
LABEL=""
|
| 22 |
+
NPU_KEYWORDS=(npu huawei ascend 华为 昇腾)
|
| 23 |
+
ISSUE_TITLE_LOWER=$(echo $ISSUE_TITLE | tr '[:upper:]' '[:lower:]')
|
| 24 |
+
for KEYWORD in ${NPU_KEYWORDS[@]}; do
|
| 25 |
+
if [[ $ISSUE_TITLE_LOWER == *$KEYWORD* ]] && [[ $ISSUE_TITLE_LOWER != *input* ]]; then
|
| 26 |
+
LABEL="npu"
|
| 27 |
+
break
|
| 28 |
+
fi
|
| 29 |
+
done
|
| 30 |
+
if [ -n "$LABEL" ]; then
|
| 31 |
+
gh issue edit $ISSUE_URL --add-label $LABEL
|
| 32 |
+
fi
|
.github/workflows/publish.yml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: publish
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
release:
|
| 6 |
+
types:
|
| 7 |
+
- published
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
publish:
|
| 11 |
+
name: Upload release to PyPI
|
| 12 |
+
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
|
| 15 |
+
environment:
|
| 16 |
+
name: release
|
| 17 |
+
url: https://pypi.org/p/llamafactory
|
| 18 |
+
|
| 19 |
+
permissions:
|
| 20 |
+
id-token: write
|
| 21 |
+
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
|
| 26 |
+
- name: Set up Python
|
| 27 |
+
uses: actions/setup-python@v5
|
| 28 |
+
with:
|
| 29 |
+
python-version: "3.9"
|
| 30 |
+
|
| 31 |
+
- name: Build package
|
| 32 |
+
run: |
|
| 33 |
+
make build
|
| 34 |
+
|
| 35 |
+
- name: Publish package
|
| 36 |
+
uses: pypa/gh-action-pypi-publish@release/v1
|
.github/workflows/tests.yml
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: tests
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- "main"
|
| 8 |
+
paths:
|
| 9 |
+
- "**.py"
|
| 10 |
+
- "requirements.txt"
|
| 11 |
+
- ".github/workflows/*.yml"
|
| 12 |
+
pull_request:
|
| 13 |
+
branches:
|
| 14 |
+
- "main"
|
| 15 |
+
paths:
|
| 16 |
+
- "**.py"
|
| 17 |
+
- "requirements.txt"
|
| 18 |
+
- ".github/workflows/*.yml"
|
| 19 |
+
|
| 20 |
+
jobs:
|
| 21 |
+
tests:
|
| 22 |
+
strategy:
|
| 23 |
+
fail-fast: false
|
| 24 |
+
matrix:
|
| 25 |
+
python:
|
| 26 |
+
- "3.9"
|
| 27 |
+
- "3.10"
|
| 28 |
+
- "3.11"
|
| 29 |
+
- "3.12"
|
| 30 |
+
os:
|
| 31 |
+
- "ubuntu-latest"
|
| 32 |
+
- "windows-latest"
|
| 33 |
+
- "macos-13"
|
| 34 |
+
transformers:
|
| 35 |
+
- null
|
| 36 |
+
include: # test backward compatibility
|
| 37 |
+
- python: "3.9"
|
| 38 |
+
os: "ubuntu-latest"
|
| 39 |
+
transformers: "4.45.0"
|
| 40 |
+
- python: "3.9"
|
| 41 |
+
os: "ubuntu-latest"
|
| 42 |
+
transformers: "4.49.0"
|
| 43 |
+
|
| 44 |
+
runs-on: ${{ matrix.os }}
|
| 45 |
+
|
| 46 |
+
concurrency:
|
| 47 |
+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.transformers }}
|
| 48 |
+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
| 49 |
+
|
| 50 |
+
env:
|
| 51 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 52 |
+
OS_NAME: ${{ matrix.os }}
|
| 53 |
+
|
| 54 |
+
steps:
|
| 55 |
+
- name: Checkout
|
| 56 |
+
uses: actions/checkout@v4
|
| 57 |
+
|
| 58 |
+
- name: Set up Python
|
| 59 |
+
uses: actions/setup-python@v5
|
| 60 |
+
with:
|
| 61 |
+
python-version: ${{ matrix.python }}
|
| 62 |
+
cache: "pip"
|
| 63 |
+
cache-dependency-path: "**/requirements*.txt"
|
| 64 |
+
|
| 65 |
+
- name: Install dependencies
|
| 66 |
+
run: |
|
| 67 |
+
python -m pip install --upgrade pip
|
| 68 |
+
python -m pip install ".[torch,dev]"
|
| 69 |
+
|
| 70 |
+
- name: Install transformers
|
| 71 |
+
if: ${{ matrix.transformers }}
|
| 72 |
+
run: |
|
| 73 |
+
python -m pip install "transformers==${{ matrix.transformers }}"
|
| 74 |
+
|
| 75 |
+
- name: Cache files
|
| 76 |
+
id: hf-hub-cache
|
| 77 |
+
uses: actions/cache@v4
|
| 78 |
+
with:
|
| 79 |
+
path: ${{ runner.temp }}/huggingface
|
| 80 |
+
key: huggingface-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.transformers }}-${{ hashFiles('tests/version.txt') }}
|
| 81 |
+
|
| 82 |
+
- name: Check quality
|
| 83 |
+
run: |
|
| 84 |
+
make style && make quality
|
| 85 |
+
|
| 86 |
+
- name: Check license
|
| 87 |
+
run: |
|
| 88 |
+
make license
|
| 89 |
+
|
| 90 |
+
- name: Check build
|
| 91 |
+
run: |
|
| 92 |
+
make build
|
| 93 |
+
|
| 94 |
+
- name: Test with pytest
|
| 95 |
+
run: |
|
| 96 |
+
make test
|
| 97 |
+
env:
|
| 98 |
+
HF_HOME: ${{ runner.temp }}/huggingface
|
| 99 |
+
HF_HUB_OFFLINE: "${{ steps.hf-hub-cache.outputs.cache-hit == 'true' && '1' || '0' }}"
|
.gitignore
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib/
|
| 18 |
+
lib64/
|
| 19 |
+
parts/
|
| 20 |
+
sdist/
|
| 21 |
+
var/
|
| 22 |
+
wheels/
|
| 23 |
+
share/python-wheels/
|
| 24 |
+
*.egg-info/
|
| 25 |
+
.installed.cfg
|
| 26 |
+
*.egg
|
| 27 |
+
MANIFEST
|
| 28 |
+
|
| 29 |
+
# PyInstaller
|
| 30 |
+
# Usually these files are written by a python script from a template
|
| 31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 32 |
+
*.manifest
|
| 33 |
+
*.spec
|
| 34 |
+
|
| 35 |
+
# Installer logs
|
| 36 |
+
pip-log.txt
|
| 37 |
+
pip-delete-this-directory.txt
|
| 38 |
+
|
| 39 |
+
# Unit test / coverage reports
|
| 40 |
+
htmlcov/
|
| 41 |
+
.tox/
|
| 42 |
+
.nox/
|
| 43 |
+
.coverage
|
| 44 |
+
.coverage.*
|
| 45 |
+
.cache
|
| 46 |
+
nosetests.xml
|
| 47 |
+
coverage.xml
|
| 48 |
+
*.cover
|
| 49 |
+
*.py,cover
|
| 50 |
+
.hypothesis/
|
| 51 |
+
.pytest_cache/
|
| 52 |
+
cover/
|
| 53 |
+
|
| 54 |
+
# Translations
|
| 55 |
+
*.mo
|
| 56 |
+
*.pot
|
| 57 |
+
|
| 58 |
+
# Django stuff:
|
| 59 |
+
*.log
|
| 60 |
+
local_settings.py
|
| 61 |
+
db.sqlite3
|
| 62 |
+
db.sqlite3-journal
|
| 63 |
+
|
| 64 |
+
# Flask stuff:
|
| 65 |
+
instance/
|
| 66 |
+
.webassets-cache
|
| 67 |
+
|
| 68 |
+
# Scrapy stuff:
|
| 69 |
+
.scrapy
|
| 70 |
+
|
| 71 |
+
# Sphinx documentation
|
| 72 |
+
docs/_build/
|
| 73 |
+
|
| 74 |
+
# PyBuilder
|
| 75 |
+
.pybuilder/
|
| 76 |
+
target/
|
| 77 |
+
|
| 78 |
+
# Jupyter Notebook
|
| 79 |
+
.ipynb_checkpoints
|
| 80 |
+
|
| 81 |
+
# IPython
|
| 82 |
+
profile_default/
|
| 83 |
+
ipython_config.py
|
| 84 |
+
|
| 85 |
+
# pyenv
|
| 86 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 88 |
+
# .python-version
|
| 89 |
+
|
| 90 |
+
# pipenv
|
| 91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 94 |
+
# install all needed dependencies.
|
| 95 |
+
#Pipfile.lock
|
| 96 |
+
|
| 97 |
+
# poetry
|
| 98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 100 |
+
# commonly ignored for libraries.
|
| 101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 102 |
+
#poetry.lock
|
| 103 |
+
|
| 104 |
+
# pdm
|
| 105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 106 |
+
#pdm.lock
|
| 107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 108 |
+
# in version control.
|
| 109 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 110 |
+
.pdm.toml
|
| 111 |
+
|
| 112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 113 |
+
__pypackages__/
|
| 114 |
+
|
| 115 |
+
# Celery stuff
|
| 116 |
+
celerybeat-schedule
|
| 117 |
+
celerybeat.pid
|
| 118 |
+
|
| 119 |
+
# SageMath parsed files
|
| 120 |
+
*.sage.py
|
| 121 |
+
|
| 122 |
+
# Environments
|
| 123 |
+
.env
|
| 124 |
+
.venv
|
| 125 |
+
env/
|
| 126 |
+
venv/
|
| 127 |
+
ENV/
|
| 128 |
+
env.bak/
|
| 129 |
+
venv.bak/
|
| 130 |
+
|
| 131 |
+
# Spyder project settings
|
| 132 |
+
.spyderproject
|
| 133 |
+
.spyproject
|
| 134 |
+
|
| 135 |
+
# Rope project settings
|
| 136 |
+
.ropeproject
|
| 137 |
+
|
| 138 |
+
# mkdocs documentation
|
| 139 |
+
/site
|
| 140 |
+
|
| 141 |
+
# mypy
|
| 142 |
+
.mypy_cache/
|
| 143 |
+
.dmypy.json
|
| 144 |
+
dmypy.json
|
| 145 |
+
|
| 146 |
+
# Pyre type checker
|
| 147 |
+
.pyre/
|
| 148 |
+
|
| 149 |
+
# pytype static type analyzer
|
| 150 |
+
.pytype/
|
| 151 |
+
|
| 152 |
+
# Cython debug symbols
|
| 153 |
+
cython_debug/
|
| 154 |
+
|
| 155 |
+
# PyCharm
|
| 156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 160 |
+
.idea/
|
| 161 |
+
|
| 162 |
+
# vscode
|
| 163 |
+
.vscode/
|
| 164 |
+
|
| 165 |
+
# uv
|
| 166 |
+
uv.lock
|
| 167 |
+
|
| 168 |
+
# custom .gitignore
|
| 169 |
+
ms_cache/
|
| 170 |
+
hf_cache/
|
| 171 |
+
om_cache/
|
| 172 |
+
cache/
|
| 173 |
+
config/
|
| 174 |
+
saves/
|
| 175 |
+
output/
|
| 176 |
+
wandb/
|
| 177 |
+
swanlog/
|
| 178 |
+
generated_predictions.jsonl
|
| 179 |
+
predictions_score.json
|
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
repos:
|
| 2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
| 3 |
+
rev: v5.0.0
|
| 4 |
+
hooks:
|
| 5 |
+
- id: check-ast
|
| 6 |
+
- id: check-added-large-files
|
| 7 |
+
args: ['--maxkb=25000']
|
| 8 |
+
- id: check-merge-conflict
|
| 9 |
+
- id: check-yaml
|
| 10 |
+
- id: debug-statements
|
| 11 |
+
- id: end-of-file-fixer
|
| 12 |
+
- id: trailing-whitespace
|
| 13 |
+
args: [--markdown-linebreak-ext=md]
|
| 14 |
+
- id: no-commit-to-branch
|
| 15 |
+
args: ['--branch', 'main']
|
| 16 |
+
|
| 17 |
+
- repo: https://github.com/asottile/pyupgrade
|
| 18 |
+
rev: v3.17.0
|
| 19 |
+
hooks:
|
| 20 |
+
- id: pyupgrade
|
| 21 |
+
args: [--py38-plus]
|
| 22 |
+
|
| 23 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 24 |
+
rev: v0.6.9
|
| 25 |
+
hooks:
|
| 26 |
+
- id: ruff
|
| 27 |
+
args: [--fix]
|
| 28 |
+
- id: ruff-format
|
ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# How ROMA Works — Architecture & Implementation
|
| 2 |
+
|
| 3 |
+
This document explains ROMA (["Real-time Omni-Multimodal Assistant"](https://arxiv.org/abs/2601.10323))
|
| 4 |
+
in plain terms: what problem it solves, the model design, and **where each piece lives in this
|
| 5 |
+
codebase**. It is written from the actual code, with clickable pointers to the relevant files.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 1. The problem in one paragraph
|
| 10 |
+
|
| 11 |
+
A normal video-LLM is **reactive**: you give it a whole video + a question, it answers once.
|
| 12 |
+
ROMA is **streaming and proactive**: it watches audio + video as they arrive, *second by second*,
|
| 13 |
+
and decides **on its own when to speak** — to fire an alert the moment a condition is met, to
|
| 14 |
+
narrate an event right when it finishes, or to answer a spoken question at the right time. Two
|
| 15 |
+
hard sub-problems fall out of this:
|
| 16 |
+
|
| 17 |
+
1. **Granularity mismatch** — audio is *dense* (a continuous waveform), video is *sparse*
|
| 18 |
+
(a few discrete frames per second). They must be fused on one shared timeline.
|
| 19 |
+
2. **When to speak** — the model must continuously judge "should I respond *now*?" without a user
|
| 20 |
+
pressing enter. ROMA's answer is a tiny extra classifier called the **Speak Head**.
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## 2. The base model: Qwen2.5-Omni-7B
|
| 25 |
+
|
| 26 |
+
ROMA is **not trained from scratch**. It starts from **Qwen2.5-Omni-7B**, an omni-modal model with
|
| 27 |
+
two cooperating sub-models (you can see both referenced in the merge tooling at
|
| 28 |
+
[scripts/merger_new_module.py](scripts/merger_new_module.py#L23-L31)):
|
| 29 |
+
|
| 30 |
+
```
|
| 31 |
+
Qwen2_5OmniModel
|
| 32 |
+
├── thinker (Qwen2_5OmniThinkerForConditionalGeneration)
|
| 33 |
+
│ understands audio + video + text, generates TEXT
|
| 34 |
+
│ ← ROMA adds the "Speak Head" here
|
| 35 |
+
└── talker (turns the thinker's output into SPEECH tokens; uses spk_dict.pt voices)
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
- The **thinker** is the multimodal brain: it ingests interleaved audio/video/text tokens and
|
| 39 |
+
produces text. ROMA's new modules are bolted onto the thinker.
|
| 40 |
+
- The **talker** produces audio so ROMA can *speak* its responses. ROMA leaves it essentially as-is
|
| 41 |
+
(the `spk_dict.pt` speaker dictionary is carried along during merging,
|
| 42 |
+
[merger_new_module.py:73-79](scripts/merger_new_module.py#L73-L79)).
|
| 43 |
+
|
| 44 |
+
> Two repos, one model. The **model internals** (the Qwen2.5-Omni classes, the Speak-Head forward
|
| 45 |
+
> pass, the interleaved-RoPE position function) live in a **custom `transformers` fork**,
|
| 46 |
+
> `git+https://github.com/Eureka-Maggie/transformers.git@roma_patch` (pinned in
|
| 47 |
+
> [requirements.txt:205](requirements.txt#L205)). **This repo** (a fork of *LLaMA-Factory*) holds
|
| 48 |
+
> everything *around* the model: data formatting, the streaming chat template, training, and the
|
| 49 |
+
> demo/inference glue. When you see `model.thinker.gate_mixer` below, the *class* is defined in the
|
| 50 |
+
> fork; the *call site* is in this repo.
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
## 3. The key idea #1 — "synchronized multimodal units" (one packet per second)
|
| 55 |
+
|
| 56 |
+
Instead of feeding one giant audio blob and one giant video blob, ROMA slices the stream into
|
| 57 |
+
**1-second units** and interleaves the two modalities *inside each second*. This is done in the
|
| 58 |
+
multimodal plugin, [src/llamafactory/data/mm_plugin.py](src/llamafactory/data/mm_plugin.py#L1836-L1990).
|
| 59 |
+
|
| 60 |
+
How the alignment works:
|
| 61 |
+
|
| 62 |
+
- A common clock: `MODEL_TIME_UNITS_PER_SECOND = 25`
|
| 63 |
+
([mm_plugin.py:1859](src/llamafactory/data/mm_plugin.py#L1859)). Everything is converted to these
|
| 64 |
+
units so audio and video share one timeline.
|
| 65 |
+
- **Audio** is encoded to ~25 tokens/second (the dense signal, downsampled by the audio encoder —
|
| 66 |
+
see the length formula at [mm_plugin.py:1844-1847](src/llamafactory/data/mm_plugin.py#L1844-L1847)).
|
| 67 |
+
- **Video** frames (sampled at `video_fps = 2`) become a grid of tokens each; each frame's tokens
|
| 68 |
+
are stamped with their real time `frame_index × video_sec_per_grid × 25`
|
| 69 |
+
([mm_plugin.py:1887-1898](src/llamafactory/data/mm_plugin.py#L1887-L1898)).
|
| 70 |
+
- `processor.get_chunked_index(...)` then cuts both token streams into per-second chunks
|
| 71 |
+
([mm_plugin.py:1917-1928](src/llamafactory/data/mm_plugin.py#L1917-L1928)), and each second is
|
| 72 |
+
emitted as **one packet** with this exact layout
|
| 73 |
+
([mm_plugin.py:1965-1972](src/llamafactory/data/mm_plugin.py#L1965-L1972)):
|
| 74 |
+
|
| 75 |
+
```
|
| 76 |
+
<|vision_bos|><|audio_bos|> [ video tokens for this second ][ audio tokens for this second ] <|audio_eos|><|vision_eos|>
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
That single, repeated structure is the "synchronized multimodal unit". Dense audio and discrete
|
| 80 |
+
video for the *same* second sit side-by-side, so the model never has to guess which audio goes with
|
| 81 |
+
which frame. Positions are then assigned with an **interleaved RoPE** index
|
| 82 |
+
(`model.thinker.get_interleaved_rope_index(...)`, called at
|
| 83 |
+
[gradio/proactive_gradio.py:225-232](gradio/proactive_gradio.py#L225-L232)) that orders audio and
|
| 84 |
+
video by time rather than by modality.
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## 4. The key idea #2 — the Speak Head ("when to speak", decoupled from "what to say")
|
| 89 |
+
|
| 90 |
+
This is ROMA's headline contribution. It is a **tiny binary classifier** attached to the thinker
|
| 91 |
+
that, every second, outputs a probability "should I speak now?". Critically, it is **separate from**
|
| 92 |
+
the thinker's normal language-model head that decides *what* words to say — that's the "decoupling
|
| 93 |
+
of response initiation from generation" the paper describes.
|
| 94 |
+
|
| 95 |
+
It has two parts (the structure is visible where the merge tool re-creates them,
|
| 96 |
+
[merger_new_module.py:85-105](scripts/merger_new_module.py#L85-L105), and where inference calls
|
| 97 |
+
them, [gradio/proactive_gradio.py:259-277](gradio/proactive_gradio.py#L259-L277)):
|
| 98 |
+
|
| 99 |
+
1. **`gate_mixer`** — a learnable mixer over the last few transformer layers. It holds `K` logits
|
| 100 |
+
(`K = len(gate_layer_ids)`, default the **last 4 layers** `[-4, -3, -2, -1]`) and returns
|
| 101 |
+
`softmax(logits)` as mixing weights. It blends the **last token's** hidden state across those
|
| 102 |
+
layers:
|
| 103 |
+
|
| 104 |
+
```
|
| 105 |
+
h_mix = Σ_k w_k · hidden_state[layer_k][:, -1, :] # w = softmax(gate_mixer.logits)
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
2. **`gate_head`** — a small MLP that maps `h_mix` to a single number (a logit). The released model
|
| 109 |
+
uses the "pro" variant: `gate_head_pro_fc1 → activation → gate_head_pro_fc2`
|
| 110 |
+
([proactive_gradio.py:271-275](gradio/proactive_gradio.py#L271-L275)). A sigmoid turns the logit
|
| 111 |
+
into a probability:
|
| 112 |
+
|
| 113 |
+
```
|
| 114 |
+
p_speak = sigmoid( gate_head_pro_fc2( act( gate_head_pro_fc1( h_mix ) ) ) )
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
Then a simple rule fires the response
|
| 118 |
+
([proactive_gradio.py:283-288](gradio/proactive_gradio.py#L283-L288)):
|
| 119 |
+
|
| 120 |
+
```
|
| 121 |
+
if p_speak > THRESHOLD: -> speak (alert / narrate / answer)
|
| 122 |
+
else: -> stay silent
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
The threshold is task-dependent: **0.6** for proactive alerts
|
| 126 |
+
([proactive_gradio.py:20](gradio/proactive_gradio.py#L20)) and **0.975** for narration
|
| 127 |
+
([narration_gradio.py](gradio/narration_gradio.py)) — narration is stricter so it only speaks at
|
| 128 |
+
clear event boundaries.
|
| 129 |
+
|
| 130 |
+
Why this design is nice: the gate is *lightweight* (a few thousand parameters reading existing
|
| 131 |
+
hidden states), so checking "should I speak?" every second is cheap, and it doesn't disturb the
|
| 132 |
+
thinker's generation quality.
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
## 5. Putting it together — the real-time inference loop
|
| 137 |
+
|
| 138 |
+
The clearest end-to-end implementation is the proactive demo,
|
| 139 |
+
[gradio/proactive_gradio.py](gradio/proactive_gradio.py#L88-L292). One full pass:
|
| 140 |
+
|
| 141 |
+
```
|
| 142 |
+
load Qwen2_5OmniModel (bf16, flash_attention_2) # proactive_gradio.py:27-34
|
| 143 |
+
build per-second multimodal units via the template # :122-144 (uses streaming_turn template)
|
| 144 |
+
past_key_values = None # KV cache → makes it incremental/streaming
|
| 145 |
+
for each 1-second chunk:
|
| 146 |
+
wait until this second actually arrives (real-time) # :195-197 (time.sleep keeps it ~1 fps)
|
| 147 |
+
slice this second's video tokens + audio mel frames # :200-222 (audio: 100 mel frames/sec)
|
| 148 |
+
compute interleaved-RoPE positions, shift by KV pos # :225-239
|
| 149 |
+
out = model.thinker(..., past_key_values, use_cache, output_hidden_states) # :254-255
|
| 150 |
+
p_speak = SpeakHead(out.hidden_states) # :259-277 (gate_mixer + gate_head)
|
| 151 |
+
past_key_values = out.past_key_values # :279 carry the cache forward
|
| 152 |
+
if p_speak > THRESHOLD: emit alert # :283-288
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
Two things make it *streaming* rather than batch:
|
| 156 |
+
- **KV cache** (`past_key_values`): each second only the *new* chunk's tokens are forwarded; the
|
| 157 |
+
past is reused. Cost per step stays roughly constant instead of growing with video length.
|
| 158 |
+
- **Real-time pacing**: the loop sleeps so it advances ~1 second of input per wall-clock second
|
| 159 |
+
([:195-197](gradio/proactive_gradio.py#L195-L197)), mimicking a live feed.
|
| 160 |
+
|
| 161 |
+
The three demos differ only in the "what happens when the gate fires" part:
|
| 162 |
+
- [proactive_gradio.py](gradio/proactive_gradio.py) — fire an **alert** when a spoken condition is met.
|
| 163 |
+
- [narration_gradio.py](gradio/narration_gradio.py) — **narrate** the event that just ended.
|
| 164 |
+
- [mme_gradio.py](gradio/mme_gradio.py) — **answer** a multimodal question (reactive).
|
| 165 |
+
|
| 166 |
+
---
|
| 167 |
+
|
| 168 |
+
## 6. How it's trained
|
| 169 |
+
|
| 170 |
+
Training config: [yamls/train.yaml](yamls/train.yaml). It is **full supervised fine-tuning** of
|
| 171 |
+
Qwen2.5-Omni-7B with DeepSpeed ZeRO-3, FlashAttention-2, Liger kernels, bf16, the vision tower
|
| 172 |
+
frozen, lr `1e-5`, `max_steps: 6000`, on a **streaming** dataset (`streaming: true`,
|
| 173 |
+
interleaved `abl_all_1, abl_all_2`). The entry point on a multi-GPU node is
|
| 174 |
+
[sh/train.sh](sh/train.sh) → `launcher.py` → `run_exp`; the single-GPU debug path is
|
| 175 |
+
[debug_sft_singlegpu.py](debug_sft_singlegpu.py).
|
| 176 |
+
|
| 177 |
+
What the model learns comes from how the **labels** are built, in
|
| 178 |
+
[src/llamafactory/data/mm_plugin.py](src/llamafactory/data/mm_plugin.py#L1901-L1990) under the
|
| 179 |
+
`streaming_mix` template ([template.py:1630-1647](src/llamafactory/data/template.py#L1630-L1647)).
|
| 180 |
+
Each second gets a target:
|
| 181 |
+
|
| 182 |
+
- The dataset gives "say *this text* at time *t*" pairs; these are bucketed into
|
| 183 |
+
`answers_at_second` ([mm_plugin.py:1901-1914](src/llamafactory/data/mm_plugin.py#L1901-L1914)).
|
| 184 |
+
- A second **with** a target → the model should *speak* that content (gate label ≈ 1).
|
| 185 |
+
- A second **with no** target → for proactive alerts the gold output is literally `"no"`
|
| 186 |
+
(encoded in the system prompt,
|
| 187 |
+
[template.py:1636-1641](src/llamafactory/data/template.py#L1636-L1641)) → gate label ≈ 0.
|
| 188 |
+
|
| 189 |
+
So one objective trains **both** behaviors at once: the **Speak Head** learns the binary
|
| 190 |
+
speak/stay-silent decision per second, while the **thinker's LM head** learns to produce the right
|
| 191 |
+
content when it *does* speak. The system prompt also encodes the task rules — narrate only at event
|
| 192 |
+
transitions; for alerts, output the specified text (or `"alert"`) only when the condition holds,
|
| 193 |
+
otherwise `"no"`. The paper's "two-stage streaming curriculum" governs the order/mix in which these
|
| 194 |
+
streaming examples are presented.
|
| 195 |
+
|
| 196 |
+
The new gate parameters are flagged as trainable add-ons via `additional_target: gate_head,gate_mixer`
|
| 197 |
+
(and the freeze-mode variant `gate_head_pro_fc1,gate_head_pro_fc2,gate_mixer`) in
|
| 198 |
+
[yamls/train.yaml](yamls/train.yaml#L13-L24).
|
| 199 |
+
|
| 200 |
+
---
|
| 201 |
+
|
| 202 |
+
## 7. From trained weights to the released checkpoint
|
| 203 |
+
|
| 204 |
+
After full fine-tuning you have a `thinker` that contains the new `gate_*` modules. The merge tool
|
| 205 |
+
[scripts/merger_new_module.py](scripts/merger_new_module.py#L152-L205) (`save_full`):
|
| 206 |
+
|
| 207 |
+
1. Loads the fine-tuned thinker (and, if needed, back-fills the `gate_head` / `gate_mixer` tensors
|
| 208 |
+
straight out of the safetensors shards — [:108-149](scripts/merger_new_module.py#L108-L149)).
|
| 209 |
+
2. Drops it into a fresh top-level `Qwen2_5OmniModel` (`base_model.thinker = thinker`).
|
| 210 |
+
3. Saves the whole thing as sharded safetensors + processor, copying `spk_dict.pt` along.
|
| 211 |
+
|
| 212 |
+
That merged artifact is what you download from HuggingFace (`EurekaTian/ROMA`) and point the demos at
|
| 213 |
+
via `whole_model/model`.
|
| 214 |
+
|
| 215 |
+
---
|
| 216 |
+
|
| 217 |
+
## 8. Mental model / cheat-sheet
|
| 218 |
+
|
| 219 |
+
| Concept | What it is | Where in the code |
|
| 220 |
+
|---|---|---|
|
| 221 |
+
| Base model | Qwen2.5-Omni-7B (`thinker` + `talker`) | fork `transformers@roma_patch`; used in [merger_new_module.py](scripts/merger_new_module.py#L23-L31) |
|
| 222 |
+
| Synchronized unit | 1-second packet interleaving video + audio tokens | [mm_plugin.py:1965-1972](src/llamafactory/data/mm_plugin.py#L1965-L1972) |
|
| 223 |
+
| Shared clock | 25 model-time-units per second | [mm_plugin.py:1859](src/llamafactory/data/mm_plugin.py#L1859) |
|
| 224 |
+
| Interleaved RoPE | time-ordered positions for audio+video | call at [proactive_gradio.py:225](gradio/proactive_gradio.py#L225) |
|
| 225 |
+
| **Speak Head** | gate_mixer (layer blend) + gate_head (MLP→sigmoid) → p(speak) | [proactive_gradio.py:259-277](gradio/proactive_gradio.py#L259-L277), [merger_new_module.py:85-105](scripts/merger_new_module.py#L85-L105) |
|
| 226 |
+
| Streaming loop | KV-cache + real-time pacing, gate checked each second | [proactive_gradio.py:193-292](gradio/proactive_gradio.py#L193-L292) |
|
| 227 |
+
| Streaming template + labels | per-second targets; "no" when silent | [template.py:1630-1647](src/llamafactory/data/template.py#L1630-L1647), [mm_plugin.py:1901-1990](src/llamafactory/data/mm_plugin.py#L1901-L1990) |
|
| 228 |
+
| Training recipe | full SFT, ZeRO-3, fa2, streaming dataset | [yamls/train.yaml](yamls/train.yaml) |
|
| 229 |
+
|
| 230 |
+
> Note on accuracy: line numbers point at the code as cloned. The Speak-Head *module classes*,
|
| 231 |
+
> the Qwen2.5-Omni model code, and `get_interleaved_rope_index` are defined in the
|
| 232 |
+
> `Eureka-Maggie/transformers@roma_patch` fork, not in this repo — this repo calls into them.
|
| 233 |
+
> If you want to read the gate's exact `forward`/init, look in that fork's
|
| 234 |
+
> `modeling_qwen2_5_omni.py`.
|
CITATION.cff
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cff-version: 1.2.0
|
| 2 |
+
date-released: 2024-03
|
| 3 |
+
message: "If you use this software, please cite it as below."
|
| 4 |
+
authors:
|
| 5 |
+
- family-names: "Zheng"
|
| 6 |
+
given-names: "Yaowei"
|
| 7 |
+
- family-names: "Zhang"
|
| 8 |
+
given-names: "Richong"
|
| 9 |
+
- family-names: "Zhang"
|
| 10 |
+
given-names: "Junhao"
|
| 11 |
+
- family-names: "Ye"
|
| 12 |
+
given-names: "Yanhan"
|
| 13 |
+
- family-names: "Luo"
|
| 14 |
+
given-names: "Zheyan"
|
| 15 |
+
- family-names: "Feng"
|
| 16 |
+
given-names: "Zhangchi"
|
| 17 |
+
- family-names: "Ma"
|
| 18 |
+
given-names: "Yongqiang"
|
| 19 |
+
title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models"
|
| 20 |
+
url: "https://arxiv.org/abs/2403.13372"
|
| 21 |
+
preferred-citation:
|
| 22 |
+
type: conference-paper
|
| 23 |
+
conference:
|
| 24 |
+
name: "Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)"
|
| 25 |
+
authors:
|
| 26 |
+
- family-names: "Zheng"
|
| 27 |
+
given-names: "Yaowei"
|
| 28 |
+
- family-names: "Zhang"
|
| 29 |
+
given-names: "Richong"
|
| 30 |
+
- family-names: "Zhang"
|
| 31 |
+
given-names: "Junhao"
|
| 32 |
+
- family-names: "Ye"
|
| 33 |
+
given-names: "Yanhan"
|
| 34 |
+
- family-names: "Luo"
|
| 35 |
+
given-names: "Zheyan"
|
| 36 |
+
- family-names: "Feng"
|
| 37 |
+
given-names: "Zhangchi"
|
| 38 |
+
- family-names: "Ma"
|
| 39 |
+
given-names: "Yongqiang"
|
| 40 |
+
title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models"
|
| 41 |
+
url: "https://arxiv.org/abs/2403.13372"
|
| 42 |
+
year: 2024
|
| 43 |
+
publisher: "Association for Computational Linguistics"
|
| 44 |
+
address: "Bangkok, Thailand"
|
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
README-GH200.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Running ROMA reproducibly on an NVIDIA GH200
|
| 2 |
+
|
| 3 |
+
This guide reproduces the **inference / real-time streaming demos** of
|
| 4 |
+
[ROMA (arXiv:2601.10323)](https://arxiv.org/abs/2601.10323) on an **NVIDIA GH200**
|
| 5 |
+
(ARM64/aarch64 Grace CPU + Hopper GPU, sm_90), using Docker for reproducibility.
|
| 6 |
+
|
| 7 |
+
It covers the **real-time proactive** path (ROMA's headline capability — the model decides
|
| 8 |
+
*when* to speak via its Speak Head), plus the narration and reactive-QA demos.
|
| 9 |
+
|
| 10 |
+
> Training and the full evaluation suite are **out of scope** for this image (training needs the
|
| 11 |
+
> 136K dataset + dataset registration and a non-cluster launcher; evaluation needs many external
|
| 12 |
+
> benchmark datasets and a GPT-judge API key).
|
| 13 |
+
|
| 14 |
+
## Why a GH200-specific image?
|
| 15 |
+
|
| 16 |
+
The GH200 is **aarch64**. The upstream `requirements.txt` pins **x86_64-only** wheels —
|
| 17 |
+
`torch==2.6.0+cu124`, `torchvision/torchaudio +cu124`, `xformers`, `flash_attn==2.7.4.post1`,
|
| 18 |
+
and a set of `nvidia-*-cu12` wheels. On ARM, `pip install -r requirements.txt` **fails** (those
|
| 19 |
+
`+cu124` wheels aren't published for aarch64; `flash_attn` has no ARM wheel). The upstream
|
| 20 |
+
`docker/docker-cuda/` image runs that same install, so it does **not** work on a GH200.
|
| 21 |
+
|
| 22 |
+
This image instead bases on the **NGC PyTorch container** (`nvcr.io/nvidia/pytorch:24.12-py3`),
|
| 23 |
+
whose ARM64/sbsa variant is auto-selected on the GH200 and already ships PyTorch, flash-attention
|
| 24 |
+
and transformer-engine built for aarch64 + Hopper. We then install only a **filtered**
|
| 25 |
+
requirements list ([`requirements-gh200.txt`](requirements-gh200.txt)) plus ROMA's custom
|
| 26 |
+
`transformers` fork and the editable `llamafactory` package.
|
| 27 |
+
|
| 28 |
+
## Prerequisites (on the GH200 host)
|
| 29 |
+
|
| 30 |
+
- NVIDIA driver + **NVIDIA Container Toolkit** installed (`docker run --rm --gpus all nvidia/cuda:12.6.0-base-ubuntu22.04 nvidia-smi` should work).
|
| 31 |
+
- Docker with Compose v2.
|
| 32 |
+
- ~60 GB free disk (NGC base image + checkpoint).
|
| 33 |
+
- Network access to `nvcr.io`, `pypi.org`, `github.com`, and `huggingface.co`.
|
| 34 |
+
|
| 35 |
+
## 1. Build
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
git clone <your-fork-url> ROMA && cd ROMA
|
| 39 |
+
docker compose -f docker/docker-gh200/docker-compose.yml build
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
On the GH200 this automatically pulls the `linux/arm64` NGC image — no extra flags needed.
|
| 43 |
+
|
| 44 |
+
## 2. Start an interactive container
|
| 45 |
+
|
| 46 |
+
```bash
|
| 47 |
+
docker compose -f docker/docker-gh200/docker-compose.yml run --rm --service-ports roma bash
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
The checkpoint, HF cache and demo media are bind-mounted to the host (`./whole_model`,
|
| 51 |
+
`./hf_cache`, `./demo_media`) so they persist across runs.
|
| 52 |
+
|
| 53 |
+
## 3. Download the released checkpoint (inside the container)
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
bash scripts/gh200/download_model.sh # -> whole_model/model (~16-22 GB)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
(If the pull is rate-limited/gated, set `HF_TOKEN` — uncomment it in the compose file or
|
| 60 |
+
`export HF_TOKEN=...` before running.)
|
| 61 |
+
|
| 62 |
+
## 4. Run a real-time demo (inside the container)
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
bash scripts/gh200/run_demo.sh proactive # real-time proactive event alert (default)
|
| 66 |
+
# or
|
| 67 |
+
bash scripts/gh200/run_demo.sh narration # real-time streaming narration
|
| 68 |
+
bash scripts/gh200/run_demo.sh mme # reactive multimodal QA
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
Then open **`http://<gh200-host>:7860`** and click **▶ Start Detection Stream**. ROMA streams
|
| 72 |
+
its output live, with the Speak Head triggering above its threshold.
|
| 73 |
+
|
| 74 |
+
### Using your own clips
|
| 75 |
+
|
| 76 |
+
The demos ship default media paths; some referenced files aren't in the repo. Point them at your
|
| 77 |
+
own clips (place files under `./demo_media`, mounted at `/app/demo_media`):
|
| 78 |
+
|
| 79 |
+
```bash
|
| 80 |
+
ROMA_VIDEO=/app/demo_media/my_clip.mp4 \
|
| 81 |
+
ROMA_AUDIO=/app/demo_media/my_clip.wav \
|
| 82 |
+
bash scripts/gh200/run_demo.sh proactive
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
A ready-to-use sample video bundled in the repo: `gradio/aCkbw-aI4xU_cut80s.mp4`
|
| 86 |
+
(the default for the `narration` demo).
|
| 87 |
+
|
| 88 |
+
## Smoke test (verify the environment)
|
| 89 |
+
|
| 90 |
+
Inside the container:
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
python -c "import torch, flash_attn, transformers; \
|
| 94 |
+
print('torch', torch.__version__); \
|
| 95 |
+
print('flash_attn', flash_attn.__version__); \
|
| 96 |
+
print('transformers', transformers.__version__); \
|
| 97 |
+
print('gpu', torch.cuda.get_device_name(0))"
|
| 98 |
+
python -c "from transformers import Qwen2_5OmniModel; print('Qwen2_5OmniModel OK')"
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
You should see a Hopper / GH200 device name and a successful `Qwen2_5OmniModel` import from the
|
| 102 |
+
patched transformers fork.
|
| 103 |
+
|
| 104 |
+
## Troubleshooting
|
| 105 |
+
|
| 106 |
+
- **`flash_attn` import fails:** confirm the NGC base actually selected the arm64 variant
|
| 107 |
+
(`docker run --rm roma-gh200:latest python -c "import platform; print(platform.machine())"` →
|
| 108 |
+
`aarch64`). If you built on x86 by mistake, rebuild on the GH200.
|
| 109 |
+
- **transformers version conflict:** the fork is installed `--no-deps` so it can't downgrade the
|
| 110 |
+
NGC torch. If a dependency complains about the transformers version, it's safe to ignore for the
|
| 111 |
+
demos; report it if a demo actually fails to import.
|
| 112 |
+
- **UI not reachable:** ensure you started the container with `--service-ports` (or the compose
|
| 113 |
+
`ports:` mapping) and that the demo bound to `0.0.0.0` (it does by default via
|
| 114 |
+
`GRADIO_SERVER_NAME`).
|
assets/alert1.png
ADDED
|
Git LFS Details
|
assets/alert2.png
ADDED
|
Git LFS Details
|
assets/architecture.png
ADDED
|
Git LFS Details
|
assets/benchmark.svg
ADDED
|
|
assets/logo.png
ADDED
|
assets/narration.png
ADDED
|
Git LFS Details
|
assets/omni.png
ADDED
|
Git LFS Details
|
assets/ovo.png
ADDED
|
Git LFS Details
|
assets/streaming.png
ADDED
|
Git LFS Details
|
assets/teaser.png
ADDED
|
Git LFS Details
|
assets/wechat.jpg
ADDED
|
Git LFS Details
|
assets/wechat_npu.jpg
ADDED
|
Git LFS Details
|
blank.jpg
ADDED
|
data/belle_multiturn/belle_multiturn.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 the LlamaFactory team.
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
|
| 23 |
+
|
| 24 |
+
_DESCRIPTION = "BELLE multiturn chat dataset."
|
| 25 |
+
|
| 26 |
+
_CITATION = """\
|
| 27 |
+
@article{belle2023exploring,
|
| 28 |
+
title={Exploring the Impact of Instruction Data Scaling on Large Language Models},
|
| 29 |
+
author={Yunjie Ji, Yong Deng, Yan Gong, Yiping Peng, Qiang Niu, Lei Zhang, Baochang Ma, Xiangang Li},
|
| 30 |
+
journal={arXiv preprint arXiv:2303.14742},
|
| 31 |
+
year={2023}
|
| 32 |
+
}
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
_HOMEPAGE = f"{_HF_ENDPOINT}/datasets/BelleGroup/multiturn_chat_0.8M"
|
| 36 |
+
_LICENSE = "gpl-3.0"
|
| 37 |
+
_URL = f"{_HF_ENDPOINT}/datasets/BelleGroup/multiturn_chat_0.8M/resolve/main/multiturn_chat_0.8M.json"
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class BelleMultiturn(datasets.GeneratorBasedBuilder):
|
| 41 |
+
VERSION = datasets.Version("0.0.0")
|
| 42 |
+
|
| 43 |
+
def _info(self):
|
| 44 |
+
features = datasets.Features(
|
| 45 |
+
{"conversations": [{"from": datasets.Value("string"), "value": datasets.Value("string")}]}
|
| 46 |
+
)
|
| 47 |
+
return datasets.DatasetInfo(
|
| 48 |
+
description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 52 |
+
file_path = dl_manager.download(_URL)
|
| 53 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": file_path})]
|
| 54 |
+
|
| 55 |
+
def _generate_examples(self, filepath: str):
|
| 56 |
+
with open(filepath, encoding="utf-8") as f:
|
| 57 |
+
for key, row in enumerate(f):
|
| 58 |
+
data = json.loads(row)
|
| 59 |
+
conversations = []
|
| 60 |
+
prompt = data["instruction"].strip()
|
| 61 |
+
response = data["output"].strip()
|
| 62 |
+
|
| 63 |
+
assist_idx = prompt.rfind("Assistant:")
|
| 64 |
+
human_idx = prompt.rfind("Human:")
|
| 65 |
+
query = prompt[human_idx + 6 : assist_idx].strip()
|
| 66 |
+
prompt = prompt[:human_idx].strip()
|
| 67 |
+
conversations.insert(0, {"from": "gpt", "value": response})
|
| 68 |
+
conversations.insert(0, {"from": "human", "value": query})
|
| 69 |
+
|
| 70 |
+
while prompt.rfind("Assistant:") != -1:
|
| 71 |
+
assist_idx = prompt.rfind("Assistant:")
|
| 72 |
+
human_idx = prompt.rfind("Human:")
|
| 73 |
+
if human_idx != -1:
|
| 74 |
+
old_query = prompt[human_idx + 6 : assist_idx].strip()
|
| 75 |
+
old_resp = prompt[assist_idx + 10 :].strip()
|
| 76 |
+
conversations.insert(0, {"from": "gpt", "value": old_resp})
|
| 77 |
+
conversations.insert(0, {"from": "human", "value": old_query})
|
| 78 |
+
else:
|
| 79 |
+
break
|
| 80 |
+
prompt = prompt[:human_idx].strip()
|
| 81 |
+
|
| 82 |
+
yield key, {"conversations": conversations}
|
data/hh_rlhf_en/hh_rlhf_en.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 the LlamaFactory team.
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
|
| 23 |
+
_DESCRIPTION = "Human preference data about helpfulness and harmlessness."
|
| 24 |
+
_CITATION = ""
|
| 25 |
+
_HOMEPAGE = f"{_HF_ENDPOINT}/datasets/Anthropic/hh-rlhf"
|
| 26 |
+
_LICENSE = "mit"
|
| 27 |
+
_URL = f"{_HF_ENDPOINT}/datasets/Anthropic/hh-rlhf/resolve/main/"
|
| 28 |
+
_URLS = {
|
| 29 |
+
"train": [
|
| 30 |
+
_URL + "harmless-base/train.jsonl.gz",
|
| 31 |
+
_URL + "helpful-base/train.jsonl.gz",
|
| 32 |
+
_URL + "helpful-online/train.jsonl.gz",
|
| 33 |
+
_URL + "helpful-rejection-sampled/train.jsonl.gz",
|
| 34 |
+
],
|
| 35 |
+
"test": [
|
| 36 |
+
_URL + "harmless-base/test.jsonl.gz",
|
| 37 |
+
_URL + "helpful-base/test.jsonl.gz",
|
| 38 |
+
_URL + "helpful-online/test.jsonl.gz",
|
| 39 |
+
_URL + "helpful-rejection-sampled/test.jsonl.gz",
|
| 40 |
+
],
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class HhRlhfEn(datasets.GeneratorBasedBuilder):
|
| 45 |
+
VERSION = datasets.Version("0.0.0")
|
| 46 |
+
|
| 47 |
+
def _info(self) -> datasets.DatasetInfo:
|
| 48 |
+
features = datasets.Features(
|
| 49 |
+
{
|
| 50 |
+
"instruction": datasets.Value("string"),
|
| 51 |
+
"chosen": datasets.Value("string"),
|
| 52 |
+
"rejected": datasets.Value("string"),
|
| 53 |
+
"history": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
| 54 |
+
}
|
| 55 |
+
)
|
| 56 |
+
return datasets.DatasetInfo(
|
| 57 |
+
description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 61 |
+
file_path = dl_manager.download_and_extract(_URLS)
|
| 62 |
+
return [
|
| 63 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": file_path["train"]}),
|
| 64 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepaths": file_path["test"]}),
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
def _generate_examples(self, filepaths: list[str]):
|
| 68 |
+
key = 0
|
| 69 |
+
for filepath in filepaths:
|
| 70 |
+
with open(filepath, encoding="utf-8") as f:
|
| 71 |
+
for row in f:
|
| 72 |
+
data = json.loads(row)
|
| 73 |
+
chosen = data["chosen"]
|
| 74 |
+
rejected = data["rejected"]
|
| 75 |
+
|
| 76 |
+
assist_idx = rejected.rfind("\n\nAssistant: ")
|
| 77 |
+
r_reject = rejected[assist_idx + 13 :].strip()
|
| 78 |
+
assist_idx = chosen.rfind("\n\nAssistant: ")
|
| 79 |
+
r_accept = chosen[assist_idx + 13 :].strip()
|
| 80 |
+
|
| 81 |
+
human_idx = chosen.rfind("\n\nHuman: ")
|
| 82 |
+
query = chosen[human_idx + 9 : assist_idx].strip()
|
| 83 |
+
prompt = chosen[:human_idx]
|
| 84 |
+
history = []
|
| 85 |
+
|
| 86 |
+
while prompt.rfind("\n\nAssistant: ") != -1:
|
| 87 |
+
assist_idx = prompt.rfind("\n\nAssistant: ")
|
| 88 |
+
human_idx = prompt.rfind("\n\nHuman: ")
|
| 89 |
+
if human_idx != -1:
|
| 90 |
+
old_query = prompt[human_idx + 9 : assist_idx].strip()
|
| 91 |
+
old_resp = prompt[assist_idx + 13 :].strip()
|
| 92 |
+
history.insert(0, (old_query, old_resp))
|
| 93 |
+
else:
|
| 94 |
+
break
|
| 95 |
+
prompt = prompt[:human_idx]
|
| 96 |
+
|
| 97 |
+
yield key, {"instruction": query, "chosen": r_accept, "rejected": r_reject, "history": history}
|
| 98 |
+
key += 1
|
data/mllm_demo_data/1.jpg
ADDED
|
data/mllm_demo_data/1.mp3
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a1a83e5c7fc5c0842abf39e0be7051e3ecfeb5337a1e5371a2f631efe5ca45d
|
| 3 |
+
size 129024
|
data/mllm_demo_data/1.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3298926dcbd76709eb64cc194ec9fe0f81865149086c9b2acd935d92e8d8d57e
|
| 3 |
+
size 481185
|
data/mllm_demo_data/2.avi
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fb4fa70ba4a62ebfe74c6aa90172e8c714122c058d285e5d5560d24042063d36
|
| 3 |
+
size 385746
|
data/mllm_demo_data/2.jpg
ADDED
|
data/mllm_demo_data/2.wav
ADDED
|
Binary file (92.9 kB). View file
|
|
|
data/mllm_demo_data/3.flac
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e25e22555cd16e90edb0a3b49fdcf1fe652b2a1250ab643634db33895c75b41
|
| 3 |
+
size 120041
|
data/mllm_demo_data/3.jpg
ADDED
|
data/mllm_demo_data/3.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8f88dd5ce9dab723864bdf508a5656378f7cbb2b35399d33bc1c8ae9d3ef73f
|
| 3 |
+
size 270849
|
data/mllm_demo_data/4.mp3
ADDED
|
Binary file (80.9 kB). View file
|
|
|
data/mllm_demo_data/4.mp4
ADDED
|
Binary file (68.1 kB). View file
|
|
|
data/test_mix_data.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"task": "narration",
|
| 4 |
+
"id": "KkXybvkdFqo_3",
|
| 5 |
+
"videos": [
|
| 6 |
+
[
|
| 7 |
+
"COIN/images/KkXybvkdFqo/frame_000085.jpg",
|
| 8 |
+
"COIN/images/KkXybvkdFqo/frame_000086.jpg",
|
| 9 |
+
"COIN/images/KkXybvkdFqo/frame_000087.jpg",
|
| 10 |
+
"COIN/images/KkXybvkdFqo/frame_000088.jpg",
|
| 11 |
+
"COIN/images/KkXybvkdFqo/frame_000089.jpg",
|
| 12 |
+
"COIN/images/KkXybvkdFqo/frame_000090.jpg",
|
| 13 |
+
"COIN/images/KkXybvkdFqo/frame_000091.jpg",
|
| 14 |
+
"COIN/images/KkXybvkdFqo/frame_000092.jpg",
|
| 15 |
+
"COIN/images/KkXybvkdFqo/frame_000093.jpg",
|
| 16 |
+
"COIN/images/KkXybvkdFqo/frame_000094.jpg",
|
| 17 |
+
"COIN/images/KkXybvkdFqo/frame_000095.jpg",
|
| 18 |
+
"COIN/images/KkXybvkdFqo/frame_000096.jpg",
|
| 19 |
+
"COIN/images/KkXybvkdFqo/frame_000097.jpg",
|
| 20 |
+
"COIN/images/KkXybvkdFqo/frame_000098.jpg",
|
| 21 |
+
"COIN/images/KkXybvkdFqo/frame_000099.jpg",
|
| 22 |
+
"COIN/images/KkXybvkdFqo/frame_000100.jpg",
|
| 23 |
+
"COIN/images/KkXybvkdFqo/frame_000101.jpg",
|
| 24 |
+
"COIN/images/KkXybvkdFqo/frame_000102.jpg",
|
| 25 |
+
"COIN/images/KkXybvkdFqo/frame_000103.jpg",
|
| 26 |
+
"COIN/images/KkXybvkdFqo/frame_000104.jpg",
|
| 27 |
+
"COIN/images/KkXybvkdFqo/frame_000105.jpg",
|
| 28 |
+
"COIN/images/KkXybvkdFqo/frame_000106.jpg",
|
| 29 |
+
"COIN/images/KkXybvkdFqo/frame_000107.jpg",
|
| 30 |
+
"COIN/images/KkXybvkdFqo/frame_000108.jpg",
|
| 31 |
+
"COIN/images/KkXybvkdFqo/frame_000109.jpg",
|
| 32 |
+
"COIN/images/KkXybvkdFqo/frame_000110.jpg",
|
| 33 |
+
"COIN/images/KkXybvkdFqo/frame_000111.jpg",
|
| 34 |
+
"COIN/images/KkXybvkdFqo/frame_000112.jpg",
|
| 35 |
+
"COIN/images/KkXybvkdFqo/frame_000113.jpg",
|
| 36 |
+
"COIN/images/KkXybvkdFqo/frame_000114.jpg",
|
| 37 |
+
"COIN/images/KkXybvkdFqo/frame_000115.jpg",
|
| 38 |
+
"COIN/images/KkXybvkdFqo/frame_000116.jpg",
|
| 39 |
+
"COIN/images/KkXybvkdFqo/frame_000117.jpg",
|
| 40 |
+
"COIN/images/KkXybvkdFqo/frame_000118.jpg",
|
| 41 |
+
"COIN/images/KkXybvkdFqo/frame_000119.jpg",
|
| 42 |
+
"COIN/images/KkXybvkdFqo/frame_000120.jpg",
|
| 43 |
+
"COIN/images/KkXybvkdFqo/frame_000121.jpg",
|
| 44 |
+
"COIN/images/KkXybvkdFqo/frame_000122.jpg",
|
| 45 |
+
"COIN/images/KkXybvkdFqo/frame_000128.jpg",
|
| 46 |
+
"COIN/images/KkXybvkdFqo/frame_000129.jpg",
|
| 47 |
+
"COIN/images/KkXybvkdFqo/frame_000130.jpg",
|
| 48 |
+
"COIN/images/KkXybvkdFqo/frame_000131.jpg",
|
| 49 |
+
"COIN/images/KkXybvkdFqo/frame_000132.jpg",
|
| 50 |
+
"COIN/images/KkXybvkdFqo/frame_000133.jpg",
|
| 51 |
+
"COIN/images/KkXybvkdFqo/frame_000134.jpg",
|
| 52 |
+
"COIN/images/KkXybvkdFqo/frame_000151.jpg",
|
| 53 |
+
"COIN/images/KkXybvkdFqo/frame_000152.jpg",
|
| 54 |
+
"COIN/images/KkXybvkdFqo/frame_000153.jpg",
|
| 55 |
+
"COIN/images/KkXybvkdFqo/frame_000154.jpg",
|
| 56 |
+
"COIN/images/KkXybvkdFqo/frame_000155.jpg",
|
| 57 |
+
"COIN/images/KkXybvkdFqo/frame_000156.jpg",
|
| 58 |
+
"COIN/images/KkXybvkdFqo/frame_000157.jpg",
|
| 59 |
+
"COIN/images/KkXybvkdFqo/frame_000158.jpg"
|
| 60 |
+
]
|
| 61 |
+
],
|
| 62 |
+
"images": [],
|
| 63 |
+
"ans": [
|
| 64 |
+
{
|
| 65 |
+
"text": "install the light socket",
|
| 66 |
+
"time": 20.0
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"text": "install the bulb and light housing or shell",
|
| 70 |
+
"time": 22.5
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"text": "install the bulb and light housing or shell",
|
| 74 |
+
"time": 26.5
|
| 75 |
+
}
|
| 76 |
+
],
|
| 77 |
+
"query": [
|
| 78 |
+
{
|
| 79 |
+
"text": "<video>Describe the event flow.",
|
| 80 |
+
"audio": "COIN/tts_audio/S1DWismH1HE.wav",
|
| 81 |
+
"time": 0.0,
|
| 82 |
+
"duration": 0.97
|
| 83 |
+
}
|
| 84 |
+
]
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"task": "proactive_gate",
|
| 88 |
+
"id": "908",
|
| 89 |
+
"ans": [
|
| 90 |
+
{
|
| 91 |
+
"text": "alert",
|
| 92 |
+
"time": 4.0
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"text": "alert",
|
| 96 |
+
"time": 5.0
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"text": "alert",
|
| 100 |
+
"time": 6.0
|
| 101 |
+
}
|
| 102 |
+
],
|
| 103 |
+
"query": [
|
| 104 |
+
{
|
| 105 |
+
"text": "<video>When you see an 'oops' kind of moment, immediately say what happened, anything to watch out for?",
|
| 106 |
+
"audio": "data/stream/oops/oops/oops_audio_gate/908.wav",
|
| 107 |
+
"time": 0.0,
|
| 108 |
+
"duration": 3.91
|
| 109 |
+
}
|
| 110 |
+
],
|
| 111 |
+
"videos": [
|
| 112 |
+
[
|
| 113 |
+
"data/stream/oops/oops/oops_video/val/Throwback Fails - Saved It! (January 2018) _ FailArmy8.mp4"
|
| 114 |
+
]
|
| 115 |
+
],
|
| 116 |
+
"images": []
|
| 117 |
+
}
|
| 118 |
+
]
|
data/ultra_chat/ultra_chat.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 the LlamaFactory team.
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
|
| 23 |
+
|
| 24 |
+
_DESCRIPTION = "UltraChat: Large-scale, Informative, and Diverse Multi-round Dialogue Data."
|
| 25 |
+
|
| 26 |
+
_CITATION = """\
|
| 27 |
+
@misc{UltraChat,
|
| 28 |
+
author = {Ding, Ning and Chen, Yulin and Xu, Bokai and Hu, Shengding and others},
|
| 29 |
+
title = {UltraChat: A Large-scale Auto-generated Multi-round Dialogue Data},
|
| 30 |
+
year = {2023},
|
| 31 |
+
publisher = {GitHub},
|
| 32 |
+
journal = {GitHub repository},
|
| 33 |
+
howpublished = {\\url{https://github.com/thunlp/ultrachat}},
|
| 34 |
+
}
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
_HOMEPAGE = f"{_HF_ENDPOINT}/datasets/stingning/ultrachat"
|
| 38 |
+
_LICENSE = "cc-by-nc-4.0"
|
| 39 |
+
_BASE_DATA_URL = f"{_HF_ENDPOINT}/datasets/stingning/ultrachat/resolve/main/train_{{idx}}.jsonl"
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class UltraChat(datasets.GeneratorBasedBuilder):
|
| 43 |
+
VERSION = datasets.Version("0.0.0")
|
| 44 |
+
|
| 45 |
+
def _info(self):
|
| 46 |
+
features = datasets.Features(
|
| 47 |
+
{"conversations": [{"from": datasets.Value("string"), "value": datasets.Value("string")}]}
|
| 48 |
+
)
|
| 49 |
+
return datasets.DatasetInfo(
|
| 50 |
+
description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 54 |
+
file_paths = [dl_manager.download(_BASE_DATA_URL.format(idx=idx)) for idx in range(10)] # multiple shards
|
| 55 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": file_paths})]
|
| 56 |
+
|
| 57 |
+
def _generate_examples(self, filepaths: list[str]):
|
| 58 |
+
for filepath in filepaths:
|
| 59 |
+
with open(filepath, encoding="utf-8") as f:
|
| 60 |
+
for row in f:
|
| 61 |
+
try:
|
| 62 |
+
data = json.loads(row)
|
| 63 |
+
except Exception:
|
| 64 |
+
continue
|
| 65 |
+
key: int = data["id"]
|
| 66 |
+
content: list[str] = data["data"]
|
| 67 |
+
if len(content) % 2 == 1:
|
| 68 |
+
content.pop(-1)
|
| 69 |
+
if len(content) < 2:
|
| 70 |
+
continue
|
| 71 |
+
conversations = [
|
| 72 |
+
{"from": "human" if i % 2 == 0 else "gpt", "value": content[i]} for i in range(len(content))
|
| 73 |
+
]
|
| 74 |
+
yield key, {"conversations": conversations}
|
debug_sft_singlegpu.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import yaml
|
| 2 |
+
import os
|
| 3 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
| 4 |
+
import sys
|
| 5 |
+
import torch
|
| 6 |
+
# import wandb
|
| 7 |
+
# wandb.init(project="test", name="hello-world", notes="labmda")
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
import llamafactory
|
| 11 |
+
except ImportError:
|
| 12 |
+
project_root = os.path.abspath(os.path.dirname(__file__))
|
| 13 |
+
src_path = os.path.join(project_root, "src")
|
| 14 |
+
if os.path.isdir(src_path):
|
| 15 |
+
print(f"Adding LLaMA-Factory src directory to sys.path: {src_path}")
|
| 16 |
+
sys.path.insert(0, src_path)
|
| 17 |
+
else:
|
| 18 |
+
print(f"Warning: LLaMA-Factory src directory not found at {src_path}. "
|
| 19 |
+
"Ensure LLaMA-Factory is installed or PYTHONPATH is set correctly.")
|
| 20 |
+
|
| 21 |
+
from llamafactory.train.tuner import run_exp
|
| 22 |
+
|
| 23 |
+
def main_debug_exp(yaml_config_path: str):
|
| 24 |
+
"""
|
| 25 |
+
Loads configuration from a YAML file and calls run_exp for single-GPU debugging.
|
| 26 |
+
"""
|
| 27 |
+
print(f"Loading configuration from: {yaml_config_path}")
|
| 28 |
+
with open(yaml_config_path, 'r', encoding='utf-8') as f:
|
| 29 |
+
config_dict = yaml.safe_load(f)
|
| 30 |
+
|
| 31 |
+
# print("--- Initial Configuration from YAML ---")
|
| 32 |
+
# for key, value in config_dict.items():
|
| 33 |
+
# print(f"{key}: {value}")
|
| 34 |
+
# print("--------------------------------------")
|
| 35 |
+
|
| 36 |
+
# --- Prepare for Single-GPU, Non-Distributed Execution ---
|
| 37 |
+
# config_dict["local_rank"] = -1
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
if "use_ray" in config_dict and config_dict["use_ray"]:
|
| 41 |
+
print("Warning: 'use_ray' is true in YAML. Forcing to False for single-GPU direct debug.")
|
| 42 |
+
config_dict["use_ray"] = False
|
| 43 |
+
|
| 44 |
+
if "deepspeed" in config_dict and config_dict["deepspeed"]:
|
| 45 |
+
print(f"Warning: 'deepspeed' found in YAML ({config_dict['deepspeed']}). Forcing to None for single-GPU debug.")
|
| 46 |
+
config_dict["deepspeed"] = None
|
| 47 |
+
|
| 48 |
+
callbacks_list = None
|
| 49 |
+
|
| 50 |
+
run_exp(
|
| 51 |
+
args=config_dict,
|
| 52 |
+
callbacks=callbacks_list
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
print("run_exp finished or debugger detached.")
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
yaml_file_path = "yamls/train_ds.yaml"
|
| 59 |
+
|
| 60 |
+
if not os.path.exists(yaml_file_path):
|
| 61 |
+
print(f"Error: YAML configuration file not found at '{yaml_file_path}'")
|
| 62 |
+
print("Please update the 'yaml_file_path' variable in this script.")
|
| 63 |
+
sys.exit(1)
|
| 64 |
+
|
| 65 |
+
# Optional: Pass YAML path as a command-line argument
|
| 66 |
+
# if len(sys.argv) > 1:
|
| 67 |
+
# yaml_file_path_cli = sys.argv[1]
|
| 68 |
+
# if os.path.exists(yaml_file_path_cli):
|
| 69 |
+
# yaml_file_path = yaml_file_path_cli
|
| 70 |
+
# else:
|
| 71 |
+
# print(f"Warning: YAML path from CLI '{yaml_file_path_cli}' not found. Using hardcoded path.")
|
| 72 |
+
|
| 73 |
+
main_debug_exp(yaml_file_path)
|
docker/docker-cuda/Dockerfile
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Default use the NVIDIA official image with PyTorch 2.6.0
|
| 2 |
+
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/index.html
|
| 3 |
+
ARG BASE_IMAGE=nvcr.io/nvidia/pytorch:24.12-py3
|
| 4 |
+
FROM ${BASE_IMAGE}
|
| 5 |
+
|
| 6 |
+
# Define environments
|
| 7 |
+
ENV MAX_JOBS=4
|
| 8 |
+
ENV FLASH_ATTENTION_FORCE_BUILD=TRUE
|
| 9 |
+
ENV VLLM_WORKER_MULTIPROC_METHOD=spawn
|
| 10 |
+
|
| 11 |
+
# Define installation arguments
|
| 12 |
+
ARG INSTALL_BNB=false
|
| 13 |
+
ARG INSTALL_VLLM=false
|
| 14 |
+
ARG INSTALL_DEEPSPEED=false
|
| 15 |
+
ARG INSTALL_FLASHATTN=false
|
| 16 |
+
ARG INSTALL_LIGER_KERNEL=false
|
| 17 |
+
ARG INSTALL_HQQ=false
|
| 18 |
+
ARG INSTALL_EETQ=false
|
| 19 |
+
ARG PIP_INDEX=https://pypi.org/simple
|
| 20 |
+
ARG HTTP_PROXY=
|
| 21 |
+
|
| 22 |
+
# Set the working directory
|
| 23 |
+
WORKDIR /app
|
| 24 |
+
|
| 25 |
+
# Set http proxy
|
| 26 |
+
RUN if [ -n "$HTTP_PROXY" ]; then \
|
| 27 |
+
echo "Configuring proxy..."; \
|
| 28 |
+
export http_proxy=$HTTP_PROXY; \
|
| 29 |
+
export https_proxy=$HTTP_PROXY; \
|
| 30 |
+
fi
|
| 31 |
+
|
| 32 |
+
# Install the requirements
|
| 33 |
+
COPY requirements.txt /app
|
| 34 |
+
RUN pip config set global.index-url "$PIP_INDEX" && \
|
| 35 |
+
pip config set global.extra-index-url "$PIP_INDEX" && \
|
| 36 |
+
python -m pip install --upgrade pip && \
|
| 37 |
+
if [ -n "$HTTP_PROXY" ]; then \
|
| 38 |
+
python -m pip install --proxy=$HTTP_PROXY -r requirements.txt; \
|
| 39 |
+
else \
|
| 40 |
+
python -m pip install -r requirements.txt; \
|
| 41 |
+
fi
|
| 42 |
+
|
| 43 |
+
# Copy the rest of the application into the image
|
| 44 |
+
COPY . /app
|
| 45 |
+
|
| 46 |
+
# Install the LLaMA Factory
|
| 47 |
+
RUN EXTRA_PACKAGES="metrics"; \
|
| 48 |
+
if [ "$INSTALL_BNB" == "true" ]; then \
|
| 49 |
+
EXTRA_PACKAGES="${EXTRA_PACKAGES},bitsandbytes"; \
|
| 50 |
+
fi; \
|
| 51 |
+
if [ "$INSTALL_VLLM" == "true" ]; then \
|
| 52 |
+
EXTRA_PACKAGES="${EXTRA_PACKAGES},vllm"; \
|
| 53 |
+
fi; \
|
| 54 |
+
if [ "$INSTALL_DEEPSPEED" == "true" ]; then \
|
| 55 |
+
EXTRA_PACKAGES="${EXTRA_PACKAGES},deepspeed"; \
|
| 56 |
+
fi; \
|
| 57 |
+
if [ "$INSTALL_LIGER_KERNEL" == "true" ]; then \
|
| 58 |
+
EXTRA_PACKAGES="${EXTRA_PACKAGES},liger-kernel"; \
|
| 59 |
+
fi; \
|
| 60 |
+
if [ "$INSTALL_HQQ" == "true" ]; then \
|
| 61 |
+
EXTRA_PACKAGES="${EXTRA_PACKAGES},hqq"; \
|
| 62 |
+
fi; \
|
| 63 |
+
if [ "$INSTALL_EETQ" == "true" ]; then \
|
| 64 |
+
EXTRA_PACKAGES="${EXTRA_PACKAGES},eetq"; \
|
| 65 |
+
fi; \
|
| 66 |
+
if [ -n "$HTTP_PROXY" ]; then \
|
| 67 |
+
pip install --proxy=$HTTP_PROXY -e ".[$EXTRA_PACKAGES]"; \
|
| 68 |
+
else \
|
| 69 |
+
pip install -e ".[$EXTRA_PACKAGES]"; \
|
| 70 |
+
fi
|
| 71 |
+
|
| 72 |
+
# Rebuild flash attention
|
| 73 |
+
RUN pip uninstall -y transformer-engine flash-attn && \
|
| 74 |
+
if [ "$INSTALL_FLASHATTN" == "true" ]; then \
|
| 75 |
+
pip uninstall -y ninja && \
|
| 76 |
+
if [ -n "$HTTP_PROXY" ]; then \
|
| 77 |
+
pip install --proxy=$HTTP_PROXY ninja && \
|
| 78 |
+
pip install --proxy=$HTTP_PROXY --no-cache-dir flash-attn --no-build-isolation; \
|
| 79 |
+
else \
|
| 80 |
+
pip install ninja && \
|
| 81 |
+
pip install --no-cache-dir flash-attn --no-build-isolation; \
|
| 82 |
+
fi; \
|
| 83 |
+
fi
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
# Unset http proxy
|
| 87 |
+
RUN if [ -n "$HTTP_PROXY" ]; then \
|
| 88 |
+
unset http_proxy; \
|
| 89 |
+
unset https_proxy; \
|
| 90 |
+
fi
|
| 91 |
+
|
| 92 |
+
# Set up volumes
|
| 93 |
+
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/app/data", "/app/output" ]
|
| 94 |
+
|
| 95 |
+
# Expose port 7860 for the LLaMA Board
|
| 96 |
+
ENV GRADIO_SERVER_PORT 7860
|
| 97 |
+
EXPOSE 7860
|
| 98 |
+
|
| 99 |
+
# Expose port 8000 for the API service
|
| 100 |
+
ENV API_PORT 8000
|
| 101 |
+
EXPOSE 8000
|
docker/docker-cuda/docker-compose.yml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
llamafactory:
|
| 3 |
+
build:
|
| 4 |
+
dockerfile: ./docker/docker-cuda/Dockerfile
|
| 5 |
+
context: ../..
|
| 6 |
+
args:
|
| 7 |
+
INSTALL_BNB: "false"
|
| 8 |
+
INSTALL_VLLM: "false"
|
| 9 |
+
INSTALL_DEEPSPEED: "false"
|
| 10 |
+
INSTALL_FLASHATTN: "false"
|
| 11 |
+
INSTALL_LIGER_KERNEL: "false"
|
| 12 |
+
INSTALL_HQQ: "false"
|
| 13 |
+
INSTALL_EETQ: "false"
|
| 14 |
+
PIP_INDEX: https://pypi.org/simple
|
| 15 |
+
container_name: llamafactory
|
| 16 |
+
volumes:
|
| 17 |
+
- ../../hf_cache:/root/.cache/huggingface
|
| 18 |
+
- ../../ms_cache:/root/.cache/modelscope
|
| 19 |
+
- ../../om_cache:/root/.cache/openmind
|
| 20 |
+
- ../../data:/app/data
|
| 21 |
+
- ../../output:/app/output
|
| 22 |
+
ports:
|
| 23 |
+
- "7860:7860"
|
| 24 |
+
- "8000:8000"
|
| 25 |
+
ipc: host
|
| 26 |
+
tty: true
|
| 27 |
+
shm_size: "16gb"
|
| 28 |
+
stdin_open: true
|
| 29 |
+
command: bash
|
| 30 |
+
deploy:
|
| 31 |
+
resources:
|
| 32 |
+
reservations:
|
| 33 |
+
devices:
|
| 34 |
+
- driver: nvidia
|
| 35 |
+
count: "all"
|
| 36 |
+
capabilities: [gpu]
|
| 37 |
+
restart: unless-stopped
|